rxrest
Version:
RxRest a reactive REST utility
1 lines • 115 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},createClass=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},possibleConstructorReturn=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},toConsumableArray=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)},RxRestProxyHandler=function(){function t(e){classCallCheck(this,t),this.$internal=[],this.$instance=e;do{this.$internal=this.$internal.concat(Object.getOwnPropertyNames(e),Object.getOwnPropertySymbols(e))}while(e=Object.getPrototypeOf(e))}return createClass(t,[{key:"getPrototypeOf",value:function(t){return Object.getPrototypeOf(this.$instance)}},{key:"defineProperty",value:function(t,e,r){return!!~this.$internal.indexOf(e)||(Object.defineProperty(t,e,r),!0)}},{key:"deleteProperty",value:function(t,e){return delete t[e]}},{key:"set",value:function(t,e,r,i){return~this.$internal.indexOf(e)?(this.$instance[e]=r,!0):(!0===this.$instance.$pristine&&t[e]!==r&&(this.$instance.$pristine=!1),t[e]=r,!0)}},{key:"get",value:function(t,e,r){return~this.$internal.indexOf(e)?this.$instance[e]:t[e]}}]),t}();function objectToMap(t,e){for(var r in e)if(Array.isArray(e[r]))for(var i=0;i<e[r].length;i++)t.append(r,e[r][i]);else t.append(r,e[r]);return t}function uuid(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}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 componentEmitter=createCommonjsModule(function(t){function e(t){if(t)return function(t){for(var r in e.prototype)t[r]=e.prototype[r];return t}(t)}t.exports=e,e.prototype.on=e.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},e.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,i=this._callbacks["$"+t];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n=0;n<i.length;n++)if((r=i[n])===e||r.fn===e){i.splice(n,1);break}return this},e.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks["$"+t];if(r)for(var i=0,n=(r=r.slice(0)).length;i<n;++i)r[i].apply(this,e);return this},e.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},e.prototype.hasListeners=function(t){return!!this.listeners(t).length}});function isObject(t){return null!==t&&"object"==typeof t}var isObject_1=isObject,requestBase=RequestBase;function RequestBase(t){if(t)return mixin(t)}function mixin(t){for(var e in RequestBase.prototype)t[e]=RequestBase.prototype[e];return t}RequestBase.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},RequestBase.prototype.parse=function(t){return this._parser=t,this},RequestBase.prototype.responseType=function(t){return this._responseType=t,this},RequestBase.prototype.serialize=function(t){return this._serializer=t,this},RequestBase.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},RequestBase.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var ERROR_CODES=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];RequestBase.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~ERROR_CODES.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},RequestBase.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},RequestBase.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,i){r?e(r):t(i)})})}return this._fullfilledPromise.then(t,e)},RequestBase.prototype.catch=function(t){return this.then(void 0,t)},RequestBase.prototype.use=function(t){return t(this),this},RequestBase.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},RequestBase.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},RequestBase.prototype.get=function(t){return this._header[t.toLowerCase()]},RequestBase.prototype.getHeader=RequestBase.prototype.get,RequestBase.prototype.set=function(t,e){if(isObject_1(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},RequestBase.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},RequestBase.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),isObject_1(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},RequestBase.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},RequestBase.prototype._auth=function(t,e,r,i){switch(r.type){case"basic":this.set("Authorization","Basic "+i(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},RequestBase.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},RequestBase.prototype.redirects=function(t){return this._maxRedirects=t,this},RequestBase.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},RequestBase.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},RequestBase.prototype.send=function(t){var e=isObject_1(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&isObject_1(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},RequestBase.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},RequestBase.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},RequestBase.prototype._appendQueryString=function(){console.trace("Unsupported")},RequestBase.prototype._timeoutError=function(t,e,r){if(!this._aborted){var i=new Error(t+e+"ms exceeded");i.timeout=e,i.code="ECONNABORTED",i.errno=r,this.timedout=!0,this.abort(),this.callback(i)}},RequestBase.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var type=function(t){return t.split(/ *; */).shift()},params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),i=r.shift(),n=r.shift();return i&&n&&(t[i]=n),t},{})},parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),i=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=i,t},{})},cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t},utils={type:type,params:params,parseLinks:parseLinks,cleanHeader:cleanHeader},responseBase=ResponseBase;function ResponseBase(t){if(t)return mixin$1(t)}function mixin$1(t){for(var e in ResponseBase.prototype)t[e]=ResponseBase.prototype[e];return t}function Agent(){this._defaults=[]}ResponseBase.prototype.get=function(t){return this.header[t.toLowerCase()]},ResponseBase.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=utils.type(e);var r=utils.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=utils.parseLinks(t.link))}catch(t){}},ResponseBase.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t},["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(t){Agent.prototype[t]=function(){return this._defaults.push({fn:t,arguments:arguments}),this}}),Agent.prototype._setDefaults=function(t){this._defaults.forEach(function(e){t[e.fn].apply(t,e.arguments)})};var agentBase=Agent,client=createCommonjsModule(function(t,e){var r;function i(){}"undefined"!=typeof window?r=window:"undefined"!=typeof self?r=self:(console.warn("Using browser-only version of superagent in non-browser environment"),r=commonjsGlobal);var n=e=t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1==arguments.length?new e.Request("GET",t):new e.Request(t,r)};e.Request=l,n.getXHR=function(){if(!(!r.XMLHttpRequest||r.location&&"file:"==r.location.protocol&&r.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only version of superagent could not find XHR")};var s="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function o(t){if(!isObject_1(t))return t;var e=[];for(var r in t)u(e,r,t[r]);return e.join("&")}function u(t,e,r){if(null!=r)if(Array.isArray(r))r.forEach(function(r){u(t,e,r)});else if(isObject_1(r))for(var i in r)u(t,e+"["+i+"]",r[i]);else t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));else null===r&&t.push(encodeURIComponent(e))}function c(t){for(var e,r,i={},n=t.split("&"),s=0,o=n.length;s<o;++s)-1==(r=(e=n[s]).indexOf("="))?i[decodeURIComponent(e)]="":i[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return i}function a(t){return/[\/+]json($|[^-\w])/.test(t)}function h(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.header=this.headers=function(t){for(var e,r,i,n,o=t.split(/\r?\n/),u={},c=0,a=o.length;c<a;++c)-1!==(e=(r=o[c]).indexOf(":"))&&(i=r.slice(0,e).toLowerCase(),n=s(r.slice(e+1)),u[i]=n);return u}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function l(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t,e=null,i=null;try{i=new h(r)}catch(t){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",i);try{r._isResponseOK(i)||(t=new Error(i.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=e,t.response=i,t.status=i.status,r.callback(t,i)):r.callback(null,i)})}function p(t,e,r){var i=n("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&i.send(e),r&&i.end(r),i}n.serializeObject=o,n.parseString=c,n.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},n.serialize={"application/x-www-form-urlencoded":o,"application/json":JSON.stringify},n.parse={"application/x-www-form-urlencoded":c,"application/json":JSON.parse},responseBase(h.prototype),h.prototype._parseBody=function(t){var e=n.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&a(this.type)&&(e=n.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null)},h.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,i="cannot "+e+" "+r+" ("+this.status+")",n=new Error(i);return n.status=this.status,n.method=e,n.url=r,n},n.Response=h,componentEmitter(l.prototype),requestBase(l.prototype),l.prototype.type=function(t){return this.set("Content-Type",n.types[t]||t),this},l.prototype.accept=function(t){return this.set("Accept",n.types[t]||t),this},l.prototype.auth=function(t,e,r){1===arguments.length&&(e=""),"object"==typeof e&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});return this._auth(t,e,r,function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")})},l.prototype.query=function(t){return"string"!=typeof t&&(t=o(t)),t&&this._query.push(t),this},l.prototype.attach=function(t,e,r){if(e){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},l.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},l.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},l.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},l.prototype.buffer=l.prototype.ca=l.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},l.prototype.pipe=l.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},l.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},l.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||i,this._finalizeQueryString(),this._end()},l.prototype._end=function(){var t=this,e=this.xhr=n.getXHR(),r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var i;try{i=e.status}catch(t){i=0}if(!i){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var i=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=i.bind(null,"download"),e.upload&&(e.upload.onprogress=i.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var s=this._header["content-type"],o=this._serializer||n.serialize[s?s.split(";")[0]:""];!o&&a(s)&&(o=n.serialize["application/json"]),o&&(r=o(r))}for(var u in this.header)null!=this.header[u]&&this.header.hasOwnProperty(u)&&e.setRequestHeader(u,this.header[u]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},n.agent=function(){return new agentBase},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){agentBase.prototype[t.toLowerCase()]=function(e,r){var i=new n.Request(t,e);return this._setDefaults(i),r&&i.end(r),i}}),agentBase.prototype.del=agentBase.prototype.delete,n.get=function(t,e,r){var i=n("GET",t);return"function"==typeof e&&(r=e,e=null),e&&i.query(e),r&&i.end(r),i},n.head=function(t,e,r){var i=n("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&i.query(e),r&&i.end(r),i},n.options=function(t,e,r){var i=n("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&i.send(e),r&&i.end(r),i},n.del=p,n.delete=p,n.patch=function(t,e,r){var i=n("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&i.send(e),r&&i.end(r),i},n.post=function(t,e,r){var i=n("POST",t);return"function"==typeof e&&(r=e,e=null),e&&i.send(e),r&&i.end(r),i},n.put=function(t,e,r){var i=n("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&i.send(e),r&&i.end(r),i}}),client_1=client.Request,superagent=Object.freeze({default:client,__moduleExports:client,Request:client_1}),extendStatics=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 __extends$1(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function isFunction(t){return"function"==typeof t}var _enable_super_gross_mode_that_will_cause_bad_things=!1,config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack;_enable_super_gross_mode_that_will_cause_bad_things=t},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};function hostReportError(t){setTimeout(function(){throw t})}var empty={closed:!0,next:function(t){},error:function(t){if(config.useDeprecatedSynchronousErrorHandling)throw t;hostReportError(t)},complete:function(){}},isArray=Array.isArray||function(t){return t&&"number"==typeof t.length};function isObject$1(t){return null!=t&&"object"==typeof t}var tryCatchTarget,errorObject={e:{}};function tryCatcher(){try{return tryCatchTarget.apply(this,arguments)}catch(t){return errorObject.e=t,errorObject}}function tryCatch(t){return tryCatchTarget=t,tryCatcher}var UnsubscriptionError=function(t){function e(r){var i=t.call(this,r?r.length+" errors occurred during unsubscription:\n "+r.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"")||this;return i.errors=r,i.name="UnsubscriptionError",Object.setPrototypeOf(i,e.prototype),i}return __extends$1(e,t),e}(Error),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,i=this._parents,n=this._unsubscribe,s=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var o=-1,u=i?i.length:0;r;)r.remove(this),r=++o<u&&i[o]||null;if(isFunction(n))tryCatch(n).call(this)===errorObject&&(e=!0,t=t||(errorObject.e instanceof UnsubscriptionError?flattenUnsubscriptionErrors(errorObject.e.errors):[errorObject.e]));if(isArray(s))for(o=-1,u=s.length;++o<u;){var c=s[o];if(isObject$1(c))if(tryCatch(c.unsubscribe).call(c)===errorObject){e=!0,t=t||[];var a=errorObject.e;a instanceof UnsubscriptionError?t=t.concat(flattenUnsubscriptionErrors(a.errors)):t.push(a)}}if(e)throw new 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 i=r;(r=new t)._subscriptions=[i]}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}();function flattenUnsubscriptionErrors(t){return t.reduce(function(t,e){return t.concat(e instanceof UnsubscriptionError?e.errors:e)},[])}var rxSubscriber="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("rxSubscriber"):"@@rxSubscriber",Subscriber=function(t){function e(e,r,i){var n=t.call(this)||this;switch(n.syncErrorValue=null,n.syncErrorThrown=!1,n.syncErrorThrowable=!1,n.isStopped=!1,arguments.length){case 0:n.destination=empty;break;case 1:if(!e){n.destination=empty;break}if("object"==typeof e){if(isTrustedSubscriber(e)){var s=e[rxSubscriber]();n.syncErrorThrowable=s.syncErrorThrowable,n.destination=s,s.add(n)}else n.syncErrorThrowable=!0,n.destination=new SafeSubscriber(n,e);break}default:n.syncErrorThrowable=!0,n.destination=new SafeSubscriber(n,e,r,i)}return n}return __extends$1(e,t),e.prototype[rxSubscriber]=function(){return this},e.create=function(t,r,i){var n=new e(t,r,i);return n.syncErrorThrowable=!1,n},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),SafeSubscriber=function(t){function e(e,r,i,n){var s,o=t.call(this)||this;o._parentSubscriber=e;var u=o;return isFunction(r)?s=r:r&&(s=r.next,i=r.error,n=r.complete,r!==empty&&(isFunction((u=Object.create(r)).unsubscribe)&&o.add(u.unsubscribe.bind(u)),u.unsubscribe=o.unsubscribe.bind(o))),o._context=u,o._next=s,o._error=i,o._complete=n,o}return __extends$1(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;config.useDeprecatedSynchronousErrorHandling&&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,r=config.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):hostReportError(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;hostReportError(t)}}},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)};config.useDeprecatedSynchronousErrorHandling&&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(t){if(this.unsubscribe(),config.useDeprecatedSynchronousErrorHandling)throw t;hostReportError(t)}},e.prototype.__tryOrSetError=function(t,e,r){if(!config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return config.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(hostReportError(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(Subscriber);function isTrustedSubscriber(t){return t instanceof Subscriber||"syncErrorThrowable"in t&&t[rxSubscriber]}function toSubscriber(t,e,r){if(t){if(t instanceof Subscriber)return t;if(t[rxSubscriber])return t[rxSubscriber]()}return t||e||r?new Subscriber(t,e,r):new Subscriber(empty)}var observable="function"==typeof Symbol&&Symbol.observable||"@@observable";function noop(){}function pipeFromArray(t){return t?1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}:noop}var Observable=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 i=this.operator,n=toSubscriber(t,e,r);if(i?i.call(n,this.source):n.add(this.source||!n.syncErrorThrowable?this._subscribe(n):this._trySubscribe(n)),config.useDeprecatedSynchronousErrorHandling&&n.syncErrorThrowable&&(n.syncErrorThrowable=!1,n.syncErrorThrown))throw n.syncErrorValue;return n},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){config.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=getPromiseCtor(e))(function(e,i){var n;n=r.subscribe(function(e){try{t(e)}catch(t){i(t),n&&n.unsubscribe()}},i,e)})},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[observable]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:pipeFromArray(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=getPromiseCtor(t))(function(t,r){var i;e.subscribe(function(t){return i=t},function(t){return r(t)},function(){return t(i)})})},t.create=function(e){return new t(e)},t}();function getPromiseCtor(t){if(t||(t=config.Promise||Promise),!t)throw new Error("no Promise impl found");return t}var ObjectUnsubscribedError=function(t){function e(){var r=t.call(this,"object unsubscribed")||this;return r.name="ObjectUnsubscribedError",Object.setPrototypeOf(r,e.prototype),r}return __extends$1(e,t),e}(Error),SubjectSubscription=function(t){function e(e,r){var i=t.call(this)||this;return i.subject=e,i.subscriber=r,i.closed=!1,i}return __extends$1(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},e}(Subscription),SubjectSubscriber=function(t){function e(e){var r=t.call(this,e)||this;return r.destination=e,r}return __extends$1(e,t),e}(Subscriber),Subject=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return __extends$1(e,t),e.prototype[rxSubscriber]=function(){return new SubjectSubscriber(this)},e.prototype.lift=function(t){var e=new AnonymousSubject(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new ObjectUnsubscribedError;if(!this.isStopped)for(var e=this.observers,r=e.length,i=e.slice(),n=0;n<r;n++)i[n].next(t)},e.prototype.error=function(t){if(this.closed)throw new ObjectUnsubscribedError;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,i=e.slice(),n=0;n<r;n++)i[n].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new ObjectUnsubscribedError;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),i=0;i<e;i++)r[i].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new ObjectUnsubscribedError;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new ObjectUnsubscribedError;return this.hasError?(t.error(this.thrownError),Subscription.EMPTY):this.isStopped?(t.complete(),Subscription.EMPTY):(this.observers.push(t),new SubjectSubscription(this,t))},e.prototype.asObservable=function(){var t=new Observable;return t.source=this,t},e.create=function(t,e){return new AnonymousSubject(t,e)},e}(Observable),AnonymousSubject=function(t){function e(e,r){var i=t.call(this)||this;return i.destination=e,i.source=r,i}return __extends$1(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):Subscription.EMPTY},e}(Subject);function refCount(){return function(t){return t.lift(new RefCountOperator(t))}}var RefCountOperator=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var r=this.connectable;r._refCount++;var i=new RefCountSubscriber(t,r),n=e.subscribe(i);return i.closed||(i.connection=r.connect()),n},t}(),RefCountSubscriber=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return __extends$1(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var r=this.connection,i=t._connection;this.connection=null,!i||r&&i!==r||i.unsubscribe()}}else this.connection=null},e}(Subscriber),ConnectableObservable=function(t){function e(e,r){var i=t.call(this)||this;return i.source=e,i.subjectFactory=r,i._refCount=0,i._isComplete=!1,i}return __extends$1(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new Subscription).add(this.source.subscribe(new ConnectableSubscriber(this.getSubject(),this))),t.closed?(this._connection=null,t=Subscription.EMPTY):this._connection=t),t},e.prototype.refCount=function(){return refCount()(this)},e}(Observable),ConnectableSubscriber=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return __extends$1(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(SubjectSubscriber),RefCountSubscriber$1=function(t){function e(e,r){var i=t.call(this,e)||this;return i.connectable=r,i}return __extends$1(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var r=this.connection,i=t._connection;this.connection=null,!i||r&&i!==r||i.unsubscribe()}}else this.connection=null},e}(Subscriber),GroupBySubscriber=function(t){function e(e,r,i,n,s){var o=t.call(this,e)||this;return o.keySelector=r,o.elementSelector=i,o.durationSelector=n,o.subjectSelector=s,o.groups=null,o.attemptedToUnsubscribe=!1,o.count=0,o}return __extends$1(e,t),e.prototype._next=function(t){var e;try{e=this.keySelector(t)}catch(t){return void this.error(t)}this._group(t,e)},e.prototype._group=function(t,e){var r=this.groups;r||(r=this.groups=new Map);var i,n=r.get(e);if(this.elementSelector)try{i=this.elementSelector(t)}catch(t){this.error(t)}else i=t;if(!n){n=this.subjectSelector?this.subjectSelector():new Subject,r.set(e,n);var s=new GroupedObservable(e,n,this);if(this.destination.next(s),this.durationSelector){var o=void 0;try{o=this.durationSelector(new GroupedObservable(e,n))}catch(t){return void this.error(t)}this.add(o.subscribe(new GroupDurationSubscriber(e,n,this)))}}n.closed||n.next(i)},e.prototype._error=function(t){var e=this.groups;e&&(e.forEach(function(e,r){e.error(t)}),e.clear()),this.destination.error(t)},e.prototype._complete=function(){var t=this.groups;t&&(t.forEach(function(t,e){t.complete()}),t.clear()),this.destination.complete()},e.prototype.removeGroup=function(t){this.groups.delete(t)},e.prototype.unsubscribe=function(){this.closed||(this.attemptedToUnsubscribe=!0,0===this.count&&t.prototype.unsubscribe.call(this))},e}(Subscriber),GroupDurationSubscriber=function(t){function e(e,r,i){var n=t.call(this,r)||this;return n.key=e,n.group=r,n.parent=i,n}return __extends$1(e,t),e.prototype._next=function(t){this.complete()},e.prototype._unsubscribe=function(){var t=this.parent,e=this.key;this.key=this.parent=null,t&&t.removeGroup(e)},e}(Subscriber),GroupedObservable=function(t){function e(e,r,i){var n=t.call(this)||this;return n.key=e,n.groupSubject=r,n.refCountSubscription=i,n}return __extends$1(e,t),e.prototype._subscribe=function(t){var e=new Subscription,r=this.refCountSubscription,i=this.groupSubject;return r&&!r.closed&&e.add(new InnerRefCountSubscription(r)),e.add(i.subscribe(t)),e},e}(Observable),InnerRefCountSubscription=function(t){function e(e){var r=t.call(this)||this;return r.parent=e,e.count++,r}return __extends$1(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(Subscription),BehaviorSubject=function(t){function e(e){var r=t.call(this)||this;return r._value=e,r}return __extends$1(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new ObjectUnsubscribedError;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(Subject),Action=function(t){function e(e,r){return t.call(this)||this}return __extends$1(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(Subscription),AsyncAction=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return __extends$1(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(i,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},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,i=void 0;try{this.work(t)}catch(t){r=!0,i=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),i},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,i=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==i&&r.splice(i,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(Action),QueueAction=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}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,i){return void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,i):e.flush(this)},e}(AsyncAction),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}(),AsyncScheduler=function(t){function e(r,i){void 0===i&&(i=Scheduler.now);var n=t.call(this,r,function(){return e.delegate&&e.delegate!==n?e.delegate.now():i()})||this;return n.actions=[],n.active=!1,n.scheduled=void 0,n}return __extends$1(e,t),e.prototype.schedule=function(r,i,n){return void 0===i&&(i=0),e.delegate&&e.delegate!==this?e.delegate.schedule(r,i,n):t.prototype.schedule.call(this,r,i,n)},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),QueueScheduler=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends$1(e,t),e}(AsyncScheduler),queue=new QueueScheduler(QueueAction),EMPTY=new Observable(function(t){return t.complete()});function empty$1(t){return t?emptyScheduled(t):EMPTY}function emptyScheduled(t){return new Observable(function(e){return t.schedule(function(){return e.complete()})})}function isScheduler(t){return t&&"function"==typeof t.schedule}var subscribeToArray=function(t){return function(e){for(var r=0,i=t.length;r<i&&!e.closed;r++)e.next(t[r]);e.closed||e.complete()}};function fromArray(t,e){return new Observable(e?function(r){var i=new Subscription,n=0;return i.add(e.schedule(function(){n!==t.length?(r.next(t[n++]),r.closed||i.add(this.schedule())):r.complete()})),i}:subscribeToArray(t))}function scalar(t){var e=new Observable(function(e){e.next(t),e.complete()});return e._isScalar=!0,e.value=t,e}function of(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t[t.length-1];switch(isScheduler(r)?t.pop():r=void 0,t.length){case 0:return empty$1(r);case 1:return r?fromArray(t,r):scalar(t[0]);default:return fromArray(t,r)}}function throwError(t,e){return new Observable(e?function(r){return e.schedule(dispatch,0,{error:t,subscriber:r})}:function(e){return e.error(t)})}function dispatch(t){var e=t.error;t.subscriber.error(e)}var Notification=function(){function t(t,e,r){this.kind=t,this.value=e,this.error=r,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,r){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return r&&r()}},t.prototype.accept=function(t,e,r){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,r)},t.prototype.toObservable=function(){switch(this.kind){case"N":return of(this.value);case"E":return throwError(this.error);case"C":return empty$1()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}(),ObserveOnSubscriber=function(t){function e(e,r,i){void 0===i&&(i=0);var n=t.call(this,e)||this;return n.scheduler=r,n.delay=i,n}return __extends$1(e,t),e.dispatch=function(t){var e=t.notification,r=t.destination;e.observe(r),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.add(this.scheduler.schedule(e.dispatch,this.delay,new ObserveOnMessage(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(Notification.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(Notification.createError(t))},e.prototype._complete=function(){this.scheduleMessage(Notification.createComplete())},e}(Subscriber),ObserveOnMessage=function(){return function(t,e){this.notification=t,this.destination=e}}(),ReplaySubject=function(t){function e(e,r,i){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var n=t.call(this)||this;return n.scheduler=i,n._events=[],n._infiniteTimeWindow=!1,n._bufferSize=e<1?1:e,n._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(n._infiniteTimeWindow=!0,n.next=n.nextInfiniteTimeWindow):n.next=n.nextTimeWindow,n}return __extends$1(e,t),e.prototype.nextInfiniteTimeWindow=function(e){var r=this._events;r.push(e),r.length>this._bufferSize&&r.shift(),t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this._events.push(new ReplayEvent(this._getNow(),e)),this._trimBufferThenGetEvents(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,r=this._infiniteTimeWindow,i=r?this._events:this._trimBufferThenGetEvents(),n=this.scheduler,s=i.length;if(this.closed)throw new ObjectUnsubscribedError;if(this.isStopped||this.hasError?e=Subscription.EMPTY:(this.observers.push(t),e=new SubjectSubscription(this,t)),n&&t.add(t=new ObserveOnSubscriber(t,n)),r)for(var o=0;o<s&&!t.closed;o++)t.next(i[o]);else for(o=0;o<s&&!t.closed;o++)t.next(i[o].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||queue).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,r=this._windowTime,i=this._events,n=i.length,s=0;s<n&&!(t-i[s].time<r);)s++;return n>e&&(s=Math.max(s,n-e)),s>0&&i.splice(0,s),i},e}(Subject),ReplayEvent=function(){return function(t,e){this.time=t,this.value=e}}(),AsyncSubject=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return __extends$1(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),Subscription.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),Subscription.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(Subject),nextHandle=1,tasksByHandle={};function runIfPresent(t){var e=tasksByHandle[t];e&&e()}var Immediate={setImmediate:function(t){var e=nextHandle++;return tasksByHandle[e]=t,Promise.resolve().then(function(){return runIfPresent(e)}),e},clearImmediate:function(t){delete tasksByHandle[t]}},AsapAction=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return __extends$1(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=Immediate.setImmediate(e.flush.bind(e,null))))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(Immediate.clearImmediate(r),e.scheduled=void 0)},e}(AsyncAction),AsapScheduler=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends$1(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i<n&&(t=r.shift()));if(this.active=!1,e){for(;++i<n&&(t=r.shift());)t.unsubscribe();throw e}},e}(AsyncScheduler),asap=new AsapScheduler(AsapAction),async=new AsyncScheduler(AsyncAction),AnimationFrameAction=function(t){function e(e,r){var i=t.call(this,e,r)||this;return i.scheduler=e,i.work=r,i}return __extends$1(e,t),e.prototype.requestAsyncId=function(e,r,i){return void 0===i&&(i=0),null!==i&&i>0?t.prototype.requestAsyncId.call(this,e,r,i):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame(function(){return e.flush(null)})))},e.prototype.recycleAsyncId=function(e,r,i){if(void 0===i&&(i=0),null!==i&&i>0||null===i&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,i);0===e.actions.length&&(cancelAnimationFrame(r),e.scheduled=void 0)},e}(AsyncAction),AnimationFrameScheduler=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends$1(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,i=-1,n=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++i<n&&(t=r.shift()));if(this.active=!1,e){for(;++i<n&&(t=r.shift());)t.unsubscribe();throw e}},e}(AsyncScheduler),animationFrame=new AnimationFrameScheduler(AnimationFrameAction),VirtualTimeScheduler=function(t){function e(e,r){void 0===e&&(e=VirtualAction),void 0===r&&(r=Number.POSITIVE_INFINITY);var i=t.call(this,e,function(){return i.frame})||this;return i.maxFrames=r,i.frame=0,i.index=-1,i}return __extends$1(e,t),e.prototype.flush=function(){for(var t,e,r=this.actions,i=this.maxFrames;(e=r.shift())&&(this.frame=e.delay)<=i&&!(t=e.execute(e.state,e.delay)););if(t){for(;e=r.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(AsyncScheduler),VirtualAction=function(t){function e(e,r,i){void 0===i&&(i=e.index+=1);var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.index=i,n.active=!0,n.index=e.index=i,n}return __extends$1(e,t),e.prototype.schedule=function(r,i){if(void 0===i&&(i=0),!this.id)return t.prototype.schedule.call(this,r,i);this.active=!1;var n=new e(this.scheduler,this.work);return this.add(n),n.schedule(r,i)},e.prototype.requestAsyncId=function(t,r,i){void 0===i&&(i=0),this.delay=t.frame+i;var n=t.actions;return n.push(this),n.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,r){void 0===r&&(r=0)},e.prototype._execute=function(e,r){if(!0===this.active)return t.prototype._execute.call(this,e,r)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(AsyncAction),ArgumentOutOfRangeError=function(t){function e(){var r=t.call(this,"argument out of range")||this;return r.name="ArgumentOutOfRangeError",Object.setPrototypeOf(r,e.prototype),r}return __extends$1(e,t),e}(Error),EmptyError=function(t){function e(){var r=t.call(this,"no elements in sequence")||this;return r.name="EmptyError",Object.setPrototypeOf(r,e.prototype),r}return __extends$1(e,t),e}(Error),TimeoutError=function(t){function e(){var r=t.call(this,"Timeout has occurred")||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return __extends$1(e,t),e}(Error);function map(t,e){return function(r){if("function"!=typeof t)throw n