/**
* kinvey-html5-sdk - Kinvey JavaScript SDK for HTML5 applications.
* @version v3.12.2
* @author Kinvey, Inc.
* @link http://www.kinvey.com
* @license Apache-2.0
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Kinvey=t():e.Kinvey=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=219)}([function(e,t,r){"use strict";function n(e,t,r,n){this.name="BaseError",this.message=e||"An error occurred.",this.debug=t||void 0,this.code=r||void 0,this.kinveyRequestId=n||void 0,this.stack=(new Error).stack}Object.defineProperty(t,"__esModule",{value:!0}),t.BaseError=n,n.prototype=Object.create(Error.prototype),n.prototype.constructor=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(225);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(226);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(227);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var u=r(228);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var s=r(229);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var a=r(0);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var c=r(230);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var l=r(231);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var f=r(232);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})});var h=r(233);Object.keys(h).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return h[e]}})});var p=r(234);Object.keys(p).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return p[e]}})});var d=r(235);Object.keys(d).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}})});var y=r(236);Object.keys(y).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return y[e]}})});var v=r(237);Object.keys(v).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return v[e]}})});var b=r(238);Object.keys(b).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return b[e]}})});var g=r(239);Object.keys(g).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return g[e]}})});var _=r(240);Object.keys(_).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return _[e]}})});var m=r(241);Object.keys(m).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return m[e]}})});var w=r(242);Object.keys(w).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return w[e]}})});var O=r(243);Object.keys(O).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return O[e]}})});var E=r(244);Object.keys(E).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return E[e]}})});var P=r(245);Object.keys(P).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return P[e]}})});var k=r(246);Object.keys(k).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return k[e]}})});var j=r(247);Object.keys(j).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return j[e]}})});var S=r(248);Object.keys(S).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return S[e]}})});var x=r(249);Object.keys(x).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return x[e]}})});var C=r(250);Object.keys(C).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return C[e]}})});var T=r(251);Object.keys(T).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return T[e]}})});var M=r(252);Object.keys(M).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return M[e]}})});var I=r(253);Object.keys(I).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return I[e]}})});var A=r(254);Object.keys(A).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return A[e]}})});var R=r(255);Object.keys(R).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return R[e]}})});var N=r(256);Object.keys(N).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return N[e]}})});var q=r(257);Object.keys(q).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return q[e]}})});var D=r(258);Object.keys(D).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return D[e]}})});var U=r(259);Object.keys(U).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return U[e]}})});var K=r(260);Object.keys(K).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return K[e]}})});var L=r(261);Object.keys(L).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return L[e]}})});var F=r(262);Object.keys(F).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return F[e]}})});var B=r(263);Object.keys(B).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return B[e]}})})},function(e,t,r){(function(t,n){var o;o=function(){"use strict";function e(e){return"function"==typeof e}var o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},i=0,u=void 0,s=void 0,a=function(e,t){y[i]=e,y[i+1]=t,2===(i+=2)&&(s?s(v):w())};var c="undefined"!=typeof window?window:void 0,l=c||{},f=l.MutationObserver||l.WebKitMutationObserver,h="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),p="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var e=setTimeout;return function(){return e(v,1)}}var y=new Array(1e3);function v(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};d(this,e);var r="https://baas.kinvey.com",n="https://auth.kinvey.com";if(t.instanceId){var o=t.instanceId;if(!(0,u.default)(o))throw new c.KinveyError("Instance ID must be a string.");r="https://"+o+"-baas.kinvey.com",n="https://"+o+"-auth.kinvey.com"}else(0,u.default)(t.apiHostname)&&(r=/^https?:\/\//i.test(t.apiHostname)?t.apiHostname:"https://"+t.apiHostname),(0,u.default)(t.micHostname)&&(n=/^https?:\/\//i.test(t.micHostname)?t.micHostname:"https://"+t.micHostname);var a=i.default.parse(r),l=i.default.parse(n);this.deviceId=(0,f.uuidv4)(),this.apiProtocol=a.protocol,this.apiHost=a.host,this.micProtocol=l.protocol,this.micHost=l.host,this.appKey=t.appKey,this.appSecret=t.appSecret,this.masterSecret=t.masterSecret,this.encryptionKey=t.encryptionKey,this.appVersion=t.appVersion,this.defaultTimeout=(0,s.default)(t.defaultTimeout)&&t.defaultTimeout>=0?t.defaultTimeout:y,this.activeUserStorage=new b,this.storage=t.storage||h.StorageProvider.Memory}return n(e,[{key:"getActiveUser",value:function(){return this.activeUserStorage.get(this.appKey+"."+f.activeUserKey)}},{key:"setActiveUser",value:function(e){return this.activeUserStorage.set(this.appKey+"."+f.activeUserKey,e)}},{key:"toPlainObject",value:function(){return{deviceId:this.deviceId,apiHostname:this.apiHostname,apiProtocol:this.apiProtocol,apiHost:this.apiHost,micHostname:this.micHostname,micProtocol:this.micProtocol,micHost:this.micHost,appKey:this.appKey,appSecret:this.appSecret,masterSecret:this.masterSecret,encryptionKey:this.encryptionKey,appVersion:this.appVersion,storage:this.storage}}},{key:"apiHostname",get:function(){return i.default.format({protocol:this.apiProtocol,host:this.apiHost})}},{key:"micHostname",get:function(){return i.default.format({protocol:this.micProtocol,host:this.micHost})}},{key:"appVersion",get:function(){return this._appVersion},set:function(e){e&&!(0,u.default)(e)&&(e=String(e)),this._appVersion=e}},{key:"defaultTimeout",get:function(){return this._defaultTimeout},set:function(e){if(e=parseInt(e,10),!1===(0,s.default)(e)||(0,a.default)(e))throw new c.KinveyError("Invalid timeout. Timeout must be a number.");e<0&&(l.Log.info("Default timeout is less than 0. Setting default timeout to "+this.defaultTimeout+"ms."),e=this.defaultTimeout),this._defaultTimeout=e}},{key:"storage",get:function(){return this._storage},set:function(e){if(!(0,f.isValidStorageProviderValue)(e))throw new c.KinveyError("Please provide a valid set of supported storage providers for this platform");this._storage=e}}],[{key:"initialize",value:function(){throw new c.KinveyError("Please use Client.init().")}},{key:"init",value:function(t){return v=new e(t)}},{key:"sharedInstance",value:function(){if(!1===(0,f.isDefined)(v))throw new c.KinveyError("You have not initialized the library. Please call Kinvey.init() to initialize the library.");return v}}]),e}()},function(e,t,r){"use strict";r.d(t,"a",function(){return c});var n=r(14),o=r(128),i=r(55),u=r(267),s=r(129),a=r(130),c=function(){function e(e){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,e&&(this._unsubscribe=e)}var t;return e.prototype.unsubscribe=function(){var e,t=!1;if(!this.closed){var r=this._parent,c=this._parents,f=this._unsubscribe,h=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var p=-1,d=c?c.length:0;r;)r.remove(this),r=++p0}},{key:"hasLimit",value:function(){return(0,c.isNumber)(this.limit)}},{key:"equalTo",value:function(e,t){return this.addFilter(e,t)}},{key:"contains",value:function(e,t){if(!1===(0,c.isDefined)(t))throw new a.QueryError("You must supply a value.");return!1===Array.isArray(t)&&(t=[t]),this.addFilter(e,"$in",t)}},{key:"containsAll",value:function(e,t){if(!1===(0,c.isDefined)(t))throw new a.QueryError("You must supply a value.");return!1===Array.isArray(t)&&(t=[t]),this.addFilter(e,"$all",t)}},{key:"greaterThan",value:function(e,t){if(!1===(0,c.isNumber)(t)&&"string"!=typeof t)throw new a.QueryError("You must supply a number or string.");return this.addFilter(e,"$gt",t)}},{key:"greaterThanOrEqualTo",value:function(e,t){if(!1===(0,c.isNumber)(t)&&"string"!=typeof t)throw new a.QueryError("You must supply a number or string.");return this.addFilter(e,"$gte",t)}},{key:"lessThan",value:function(e,t){if(!1===(0,c.isNumber)(t)&&"string"!=typeof t)throw new a.QueryError("You must supply a number or string.");return this.addFilter(e,"$lt",t)}},{key:"lessThanOrEqualTo",value:function(e,t){if(!1===(0,c.isNumber)(t)&&"string"!=typeof t)throw new a.QueryError("You must supply a number or string.");return this.addFilter(e,"$lte",t)}},{key:"notEqualTo",value:function(e,t){return this.addFilter(e,"$ne",t)}},{key:"notContainedIn",value:function(e,t){return!1===Array.isArray(t)&&(t=[t]),this.addFilter(e,"$nin",t)}},{key:"and",value:function(){for(var e=arguments.length,t=Array(e),r=0;r2&&void 0!==arguments[2]?arguments[2]:0;if("string"==typeof t&&(t=parseFloat(t)),"string"==typeof r&&(r=parseFloat(r)),!(0,c.isNumber)(t))throw new a.QueryError("divisor must be a number");if(!(0,c.isNumber)(r))throw new a.QueryError("remainder must be a number");return this.addFilter(e,"$mod",[t,r])}},{key:"matches",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[];if(t instanceof RegExp||(t=new RegExp(t)),0!==t.source.indexOf("^"))throw new a.QueryError("regExp must have '^' at the beginning of the expression to make it an anchored expression.");if((t.ignoreCase||r.ignoreCase)&&!1!==r.ignoreCase)throw new a.QueryError("ignoreCase flag is not supported");return(t.multiline||r.multiline)&&!1!==r.multiline&&n.push("m"),!0===r.extended&&n.push("x"),!0===r.dotMatchesAll&&n.push("s"),n.length>0&&this.addFilter(e,"$options",n.join("")),this.addFilter(e,"$regex",t.source)}},{key:"near",value:function(e,t,r){if(!Array.isArray(t)||!(0,c.isNumber)(t[0])||!(0,c.isNumber)(t[1]))throw new a.QueryError("coord must be a [number, number]");var n=this.addFilter(e,"$nearSphere",[t[0],t[1]]);return(0,c.isNumber)(r)&&this.addFilter(e,"$maxDistance",r),n}},{key:"withinBox",value:function(e,t,r){if(!Array.isArray(t)||!(0,c.isNumber)(t[0])||!(0,c.isNumber)(t[1]))throw new a.QueryError("bottomLeftCoord must be a [number, number]");if(!Array.isArray(r)||!(0,c.isNumber)(r[0])||!(0,c.isNumber)(r[1]))throw new a.QueryError("upperRightCoord must be a [number, number]");t[0]=parseFloat(t[0]),t[1]=parseFloat(t[1]),r[0]=parseFloat(r[0]),r[1]=parseFloat(r[1]);var n=[[t[0],t[1]],[r[0],r[1]]];return this.addFilter(e,"$within",{$box:n})}},{key:"withinPolygon",value:function(e,t){if(!1===Array.isArray(t)||0===t.length||t.length>3)throw new a.QueryError("coords must be a [[number, number]]");return t=t.map(function(e){if(!1===(0,c.isNumber)(e[0])||!1===(0,c.isNumber)(e[1]))throw new a.QueryError("coords argument must be a [number, number]");return[parseFloat(e[0]),parseFloat(e[1])]}),this.addFilter(e,"$within",{$polygon:t})}},{key:"size",value:function(e,t){if("string"==typeof t&&(t=parseFloat(t)),!(0,c.isNumber)(t))throw new a.QueryError("size must be a number");return this.addFilter(e,"$size",t)}},{key:"ascending",value:function(e){return(0,c.isDefined)(this._parent)?this._parent.ascending(e):this.sort[e]=1,this}},{key:"descending",value:function(e){return(0,c.isDefined)(this._parent)?this._parent.descending(e):this.sort[e]=-1,this}},{key:"addFilter",value:function(e,t,r){return(0,c.isDefined)(t)&&((0,c.isDefined)(r)||3===arguments.length)?((0,u.default)(this.filter[e])||(this.filter[e]={}),this.filter[e][t]=r):this.filter[e]=t,this}},{key:"join",value:function(t,r){var n=this,o=this,i={};return 0===(r=r.map(function(t){if(!(t instanceof e)){if(!(0,u.default)(t))throw new a.QueryError("query argument must be of type: Kinvey.Query[] or Object[].");t=new e(t)}return t.toPlainObject().filter})).length&&(r=[(o=new e).toPlainObject().filter],o._parent=this),Object.keys(this.filter).forEach(function(e){i[e]=n.filter[e],delete n.filter[e]}),this.filter[t]=[i].concat(r),o}},{key:"process",value:function(e){if(!this.isSupportedOffline()){var t="This query is not able to run locally. The following filters are not supported locally:";throw p.forEach(function(e){t=t+" "+e}),l.Log.error(t),new a.QueryError(t)}if(!Array.isArray(e))throw new a.QueryError("data argument must be of type: Array.");l.Log.debug("Data length before processiong query",e.length);var r=this.toPlainObject();if(e=(0,i.default)(r.filter,e),l.Log.debug("Data length after applying query filter",r.filter,e.length),(0,c.isDefined)(r.sort)&&(l.Log.debug("Sorting data",r.sort),e.sort(function(e,t){for(var n in r.sort)if(r.sort.hasOwnProperty(n)){var o=(0,c.nested)(e,n),i=(0,c.nested)(t,n),u=r.sort[n];if((0,c.isDefined)(o)&&!1===(0,c.isDefined)(i))return 1*u;if(!1===(0,c.isDefined)(o)&&(0,c.isDefined)(i))return-1*u;if(void 0===o&&null===i)return 0;if(null===o&&void 0===i)return 0;if(o!==i)return(o0){var n=[].concat(r.fields,h);l.Log.debug("Removing fields from data",r.fields),e=e.map(function(e){return Object.keys(e).forEach(function(t){-1===n.indexOf(t)&&delete e[t]}),e})}return(0,c.isNumber)(r.skip)?(0,c.isNumber)(r.limit)&&r.limit>0?(l.Log.debug("Skipping and limiting data",r.skip,r.limit),e.slice(r.skip,r.skip+r.limit)):(l.Log.debug("Skipping data",r.skip),e.slice(r.skip)):e}},{key:"toPlainObject",value:function(){return(0,c.isDefined)(this._parent)?this._parent.toPlainObject():{fields:this.fields,filter:this.filter,sort:this.sort,skip:this.skip,limit:this.limit}}},{key:"toQueryString",value:function(){var e={};return Object.keys(this.filter).length>0&&(e.query=this.filter),this.fields.length>0&&(e.fields=this.fields.join(",")),(0,c.isNumber)(this.limit)&&(e.limit=this.limit),(0,c.isNumber)(this.skip)&&this.skip>0&&(e.skip=this.skip),Object.keys(this.sort).length>0&&(e.sort=this.sort),Object.keys(e).forEach(function(t){e[t]="string"==typeof e[t]?e[t]:JSON.stringify(e[t])}),e}},{key:"toString",value:function(){return JSON.stringify(this.toQueryString())}},{key:"fields",get:function(){return this._fields},set:function(e){if(e=e||[],!Array.isArray(e))throw new a.QueryError("fields must be an Array");(0,c.isDefined)(this._parent)?this._parent.fields=e:this._fields=e}},{key:"filter",get:function(){return this._filter},set:function(e){this._filter=e}},{key:"sort",get:function(){return this._sort},set:function(e){if(e&&!(0,u.default)(e))throw new a.QueryError("sort must an Object");(0,c.isDefined)(this._parent)?this._parent.sort=e:this._sort=e||{}}},{key:"limit",get:function(){return this._limit},set:function(e){if("string"==typeof e&&(e=parseFloat(e)),(0,c.isDefined)(e)&&!1===(0,c.isNumber)(e))throw new a.QueryError("limit must be a number");this._parent?this._parent.limit=e:this._limit=e}},{key:"skip",get:function(){return this._skip},set:function(e){if("string"==typeof e&&(e=parseFloat(e)),!1===(0,c.isNumber)(e))throw new a.QueryError("skip must be a number");(0,c.isDefined)(this._parent)?this._parent.skip=e:this._skip=e}}]),e}();t.Query=d},function(e,t,r){var n=r(150),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0;var n,o=r(340),i=(n=o)&&n.__esModule?n:{default:n};i.default.setDefaultLevel(i.default.levels.SILENT);var u=i.default.methodFactory;i.default.methodFactory=function(e,t,r){var n=u(e,t,r);return function(e){e="Kinvey: "+e;for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o0?n(e,r):n(e)}},t.Log=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(449);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(450);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,r){"use strict";r.d(t,"a",function(){return o}),t.b=function(e){return e?function(e){return new n.a(function(t){return e.schedule(function(){return t.complete()})})}(e):o};var n=r(5),o=new n.a(function(e){return e.complete()})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(95);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(199);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(463);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var u=r(97);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var s=r(51);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var a=r(114);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var c=r(52);Object.keys(c).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}})});var l=r(24);Object.keys(l).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return l[e]}})});var f=r(81);Object.keys(f).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}})})},function(e,t,r){"use strict";var n=r(342),o=r(343);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=_,t.resolve=function(e,t){return _(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?_(e,!1,!0).resolveObject(t):t},t.format=function(e){o.isString(e)&&(e=_(e));return e instanceof i?e.format():i.prototype.format.call(e)},t.Url=i;var u=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(c),f=["%","/","?",";","#"].concat(l),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},v={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(344);function _(e,t,r){if(e&&o.isObject(e)&&e instanceof i)return e;var n=new i;return n.parse(e,t,r),n}i.prototype.parse=function(e,t,r){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),s=-1!==i&&i127?A+="x":A+=I[R];if(!A.match(p)){var q=T.slice(0,S),D=T.slice(S+1),U=I.match(d);U&&(q.push(U[1]),D.unshift(U[2])),D.length&&(_="/"+D.join(".")+_),this.hostname=q.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=n.toASCII(this.hostname));var K=this.port?":"+this.port:"",L=this.hostname||"";this.host=L+K,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!y[O])for(S=0,M=l.length;S0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift());return r.search=e.search,r.query=e.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!E.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=E.slice(-1)[0],j=(r.host||e.host||E.length>1)&&("."===k||".."===k)||""===k,S=0,x=E.length;x>=0;x--)"."===(k=E[x])?E.splice(x,1):".."===k?(E.splice(x,1),S++):S&&(E.splice(x,1),S--);if(!w&&!O)for(;S--;S)E.unshift("..");!w||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),j&&"/"!==E.join("/").substr(-1)&&E.push("");var C,T=""===E[0]||E[0]&&"/"===E[0].charAt(0);P&&(r.hostname=r.host=T?"":E.length?E.shift():"",(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift()));return(w=w||r.host&&E.length)&&!T&&E.unshift(""),E.length?r.pathname=E.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(113);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(185);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(186);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var u=r(189);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var s=r(458);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})});var a=r(188);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})})},function(e,t,r){"use strict";t.a=function(e){return e&&"function"==typeof e.schedule}},function(e,t,r){var n=r(37),o=r(319),i=r(320),u="[object Null]",s="[object Undefined]",a=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?s:u:a&&a in Object(e)?o(e):i(e)}},function(e,t,r){var n=r(161),o=r(148),i=r(30);e.exports=function(e){return i(e)?n(e):o(e)}},function(e,t,r){var n=r(318),o=r(323);e.exports=function(e,t){var r=o(e,t);return n(r)?r:void 0}},function(e,t,r){var n=r(26),o=r(12),i="[object AsyncFunction]",u="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";e.exports=function(e){if(!o(e))return!1;var t=n(e);return t==u||t==s||t==i||t==a}},function(e,t,r){var n=r(29),o=r(91);e.exports=function(e){return null!=e&&o(e.length)&&!n(e)}},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n="function"==typeof Symbol&&Symbol.observable||"@@observable"},function(e,t,r){"use strict";r.d(t,"b",function(){return l}),r.d(t,"a",function(){return f});var n=r(4),o=r(5),i=r(13),u=r(8),s=r(57),a=r(132),c=r(84),l=function(e){function t(t){var r=e.call(this,t)||this;return r.destination=t,r}return n.a(t,e),t}(i.a),f=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return n.a(t,e),t.prototype[c.a]=function(){return new l(this)},t.prototype.lift=function(e){var t=new h(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new s.a;if(!this.isStopped)for(var t=this.observers,r=t.length,n=t.slice(),o=0;o-1&&e%1==0&&e1&&void 0!==arguments[1])||arguments[1],r=(0,c.isPromiseLike)(e);return b.create(function(n){var o=void 0;if(r)o=e;else{var i=e(n);o=(0,c.wrapInPromise)(i)}o.then(function(e){r&&n.next(e),t&&n.complete()}).catch(function(e){return n.error(e)})})};var i=l(r(2)),u=r(126),s=r(348),a=l(r(29)),c=r(3);function l(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var d={closed:!0,next:function(){},error:function(e){throw e},complete:function(){},status:function(){},presence:function(){}},y=function(e){function t(e,r,n,o,i,u){f(this,t);var s=h(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),c=void 0,l=s;return s._parentSubscriber=e,(0,a.default)(r)?c=r:r&&(c=r.next,n=r.error,o=r.complete,r!==d&&(l=Object.create(r),(0,a.default)(l.unsubscribe)&&s.add(l.unsubscribe.bind(l)),l.unsubscribe=s.unsubscribe.bind(s))),s._context=l,s._next=c,s._error=n,s._complete=o,s._status=i,s._presence=u,s}return p(t,u.Subscriber),o(t,[{key:"next",value:function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}}},{key:"error",value:function(e){if(!this.isStopped){var t=this._parentSubscriber;if(this._error)t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else{if(!t.syncErrorThrowable)throw this.unsubscribe(),e;t.syncErrorValue=e,t.syncErrorThrown=!0,this.unsubscribe()}}}},{key:"complete",value:function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var r=function(){return e._complete.call(e._context)};t.syncErrorThrowable?(this.__tryOrSetError(t,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}}},{key:"status",value:function(e){if(!this.isStopped&&this._status){var t=this._parentSubscriber;t.syncErrorThrowable?this.__tryOrSetError(t,this._status,e)&&this.unsubscribe():this.__tryOrUnsub(this._status,e)}}},{key:"presence",value:function(e){if(!this.isStopped&&this._presence){var t=this._parentSubscriber;t.syncErrorThrowable?this.__tryOrSetError(t,this._presence,e)&&this.unsubscribe():this.__tryOrUnsub(this._presence,e)}}},{key:"__tryOrUnsub",value:function(e,t){try{e.call(this._context,t)}catch(e){throw this.error(e),e}}},{key:"__tryOrSetError",value:function(e,t,r){try{t.call(this._context,r)}catch(t){return e.syncErrorValue=t,e.syncErrorThrown=!0,!0}return!1}},{key:"_unsubscribe",value:function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()}}]),t}(),v=function(e){function t(e,r,o,i,s){f(this,t);var a=h(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r,o));switch(arguments.length){case 0:a.destination=d;break;case 1:if(!1===(0,c.isDefined)(e)){a.destination=d;break}if("object"===(void 0===e?"undefined":n(e))){e instanceof u.Subscriber?(a.destination=e,a.destination.add(a)):(a.syncErrorThrowable=!0,a.destination=new y(a,e));break}default:a.syncErrorThrowable=!0,a.destination=new y(a,e,r,o,i,s)}return a}return p(t,u.Subscriber),o(t,[{key:"status",value:function(e){this.isStopped||this._status(e)}},{key:"presence",value:function(e){this.isStopped||this._presence(e)}},{key:"_status",value:function(e){this.destination.status(e)}},{key:"_presence",value:function(e){this.destination.presence(e)}}]),t}();var b=t.KinveyObservable=function(e){function t(){return f(this,t),h(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return p(t,u.Observable),o(t,[{key:"subscribe",value:function(e,t,r,n,o){var i=this.operator,u=function(e,t,r,n,o){if(e){if(e instanceof v)return e;if(e[s.rxSubscriber])return e[s.rxSubscriber]()}return e||t||r||n||o?new v(e,t,r,n,o):new v(d)}(e,t,r,n,o);if(i?i.call(u,this.source):u.add(this._trySubscribe(u)),u.syncErrorThrowable&&(u.syncErrorThrowable=!1,u.syncErrorThrown))throw u.syncErrorValue;return u}},{key:"toPromise",value:function(){var e=this;return new i.default(function(t,r){var n=void 0;e.subscribe(function(e){n=e},r,function(){t(n)})})}}],[{key:"create",value:function(e){return new t(e)}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Aggregation=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[],t=this.toPlainObject(),r=Object.keys(t.key),n=t.reduceFn.replace(/function[\s\S]*?\([\s\S]*?\)/,"");if(t.reduce=new Function(["doc","out"],n),this.query&&(e=this.query.process(e)),r.length>0){var u=[];return r.forEach(function(r){var n={};e.forEach(function(e){var o=e[r],i=(0,f.isDefined)(n[o])?n[o]:(0,c.default)(t.initial),u=t.reduce(e,i);(0,f.isDefined)(u)&&(i=u),n[o]=i}),Object.keys(n).forEach(function(e){var t={};t[r]=e,t=(0,o.default)({},t,n[e]),u.push(t)})}),u}var s=(0,c.default)(t.initial);return(0,i.default)(e,function(e){var r=t.reduce(e,s);(0,f.isDefined)(r)&&(s=r)}),s}},{key:"toPlainObject",value:function(){return{key:this.key,initial:this.initial,reduce:this.reduceFn,reduceFn:this.reduceFn,condition:this.query?this.query.toPlainObject().filter:{},query:this.query?this.query.toPlainObject():null}}},{key:"initial",get:function(){return(0,c.default)(this._initial)},set:function(e){if(!(0,s.default)(e))throw new l.KinveyError("initial must be an Object.");this._initial=e}},{key:"query",get:function(){return this._query},set:function(e){if((0,f.isDefined)(e)&&!(e instanceof h.Query))throw new l.KinveyError("Invalid query. It must be an instance of the Query class.");this._query=e}},{key:"reduceFn",get:function(){return this._reduceFn},set:function(e){if((0,a.default)(e)&&(e=e.toString()),!(0,u.default)(e))throw new l.KinveyError("fn argument must be of type function or string.");this._reduceFn=e}}],[{key:"count",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var r=new e;return r.by(t),r.initial={count:0},r.reduceFn="function(doc, out) { out.count += 1; return out;}",r}},{key:"sum",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var r=new e;return r.initial={sum:0},r.reduceFn='function(doc, out) { out.sum += doc["'+t+'"]; return out;}',r}},{key:"min",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var r=new e;return r.initial={min:1/0},r.reduceFn='function(doc, out) { out.min = Math.min(out.min, doc["'+t+'"]); return out;}',r}},{key:"max",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var r=new e;return r.initial={max:-1/0},r.reduceFn='function(doc, out) { out.max = Math.max(out.max, doc["'+t+'"]); return out;}',r}},{key:"average",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var r=new e;return r.initial={count:0,average:0},r.reduceFn='function(doc, out) { out.average = (out.average * out.count + doc["'+t+'"]) / (out.count + 1); out.count += 1; return out;}',r}}]),e}()},function(e,t,r){var n=r(349),o=r(352)(n);e.exports=o},function(e,t,r){var n=r(353),o=r(354),i=r(355),u=r(356),s=r(357);function a(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.headers={},this.addAll(t)}return n(e,[{key:"get",value:function(e){if(e)return!1===(0,i.default)(e)&&(e=String(e)),this.headers[e.toLowerCase()]}},{key:"set",value:function(e,t){if(!1===(0,s.isDefined)(e)||!1===(0,s.isDefined)(t))throw new Error("A name and value must be provided to set a header.");!1===(0,i.default)(e)&&(e=String(e));var r=this.headers;return e=e.toLowerCase(),!1===(0,i.default)(t)?r[e]=JSON.stringify(t):r[e]=t,this.headers=r,this}},{key:"has",value:function(e){return!!this.get(e)}},{key:"add",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.set(e.name,e.value)}},{key:"addAll",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(r instanceof e&&(r=r.toPlainObject()),!1===(0,u.default)(r))throw new Error("Headers argument must be an object.");var n=Object.keys(r);return(0,o.default)(n,function(e){try{t.set(e,r[e])}catch(e){}}),this}},{key:"remove",value:function(e){if(e){!1===(0,i.default)(e)&&(e=String(e));var t=this.headers;delete t[e.toLowerCase()],this.headers=t}return this}},{key:"clear",value:function(){return this.headers={},this}},{key:"toPlainObject",value:function(){return this.headers}},{key:"toString",value:function(){return JSON.stringify(this.toPlainObject())}},{key:"requestStart",get:function(){return this.get(c)}}]),e}()},function(e,t,r){var n=r(6),o=r(108),i=r(422),u=r(425);e.exports=function(e,t){return n(e)?e:o(e,t)?[e]:i(u(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Middleware=void 0;var n,o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"Middleware";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t}return o(e,[{key:"handle",value:function(){return u.default.reject(new Error("A subclass middleware must override the handle function."))}},{key:"cancel",value:function(){return u.default.resolve()}},{key:"generateTree",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return{value:this.name,level:e,nodes:[]}}},{key:"toString",value:function(){var e=this.generateTree();return s.AsciiTree.generate(e)}}]),e}()},function(e,t,r){var n=r(166),o=4;e.exports=function(e){return n(e,o)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testSupportCollection=void 0,t.buildCollectionUrl=function(e,t,r){e=(0,o.stripTagFromCollectionName)(e);var i="appdata/"+n.Client.sharedInstance().appKey+"/"+e;t&&(i+="/"+t);r&&(i+="/"+r);return i},t.applyQueryToDataset=function(e,t){if(!t)return e;return t.process(e)},t.applyAggregationToDataset=function(e,t){return t.process(e)};var n=r(7),o=r(20);t.testSupportCollection="__testSupport__"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cacheEnabled=t,this._ttl=r}return n(e,[{key:"read",value:function(e){var t=this;return this._cacheEnabled&&o[e]?Promise.resolve(o[e]):this._readFromPersistance(e).then(function(r){return t._cacheEnabled&&(o[e]=r),r})}},{key:"write",value:function(e,t){var r=this;return this._invalidateCache(e),this._writeToPersistance(e,t).then(function(t){return r._cacheEnabled&&r._ttl<1/0&&setTimeout(function(){r._invalidateCache(e)},r._ttl),t})}},{key:"delete",value:function(e){var t=this;return this._deleteFromPersistance(e).then(function(r){return t._invalidateCache(e),r})}},{key:"getKeys",value:function(){this._throwNotImplementedError()}},{key:"_throwNotImplementedError",value:function(){throw new Error("Abstract method not implemented")}},{key:"_readFromPersistance",value:function(e){this._throwNotImplementedError(e)}},{key:"_writeToPersistance",value:function(e,t){this._throwNotImplementedError(e,t)}},{key:"_deleteFromPersistance",value:function(e){this._throwNotImplementedError(e)}},{key:"_invalidateCache",value:function(e){this._cacheEnabled&&delete o[e]}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryCacheCollectionName=void 0,t.getCachedQuery=function(e,t){var r=f(t);if(!r&&""!==r)return n.Promise.resolve(null);return s.repositoryProvider.getOfflineRepository().then(function(t){var n=(new u.Query).equalTo("collectionName",e).and().equalTo("query",r);return t.read(l,n).then(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.length>0?t[0]:{_id:(0,a.generateEntityId)(),collectionName:e,query:r}})})},t.createCachedQuery=function(e,t){var r=f(t);if(!r)return n.Promise.resolve(null);return s.repositoryProvider.getOfflineRepository().then(function(t){var n={_id:(0,a.generateEntityId)(),collectionName:e,query:r};return t.create(l,n)})},t.updateCachedQuery=function(e){if(!e)return n.Promise.resolve(null);return s.repositoryProvider.getOfflineRepository().then(function(t){return t.update(l,e)})},t.deleteCachedQuery=function(e){if(!e)return n.Promise.resolve(null);return s.repositoryProvider.getOfflineRepository().then(function(t){return t.deleteById(l,e._id)})},t.clearQueryCache=function(e){return s.repositoryProvider.getOfflineRepository().then(function(t){var r=(new u.Query).equalTo("collectionName",e);return t.delete(l,r)})};var n=r(2),o=c(r(38)),i=c(r(36)),u=r(16),s=r(24),a=r(20);function c(e){return e&&e.__esModule?e:{default:e}}var l=t.queryCacheCollectionName="_QueryCache";function f(e){if(e&&((0,o.default)(e.skip)&&e.skip>0||(0,o.default)(e.limit)))return null;var t=e?e.toQueryString():{};return t&&!(0,i.default)(t)?JSON.stringify(t):""}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(193);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(196);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(198);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var u=r(462);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})})},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,r){"use strict";t.a=function(e){setTimeout(function(){throw e})}},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("rxSubscriber"):"@@rxSubscriber"},function(e,t,r){"use strict";t.a=function(){}},function(e,t,r){"use strict";t.a=function(){for(var e=[],t=0;t-1&&e%1==0&&e<=r}},function(e,t,r){var n=r(329),o=r(93),i=r(94),u=i&&i.isTypedArray,s=u?o(u):n;e.exports=s},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,r){(function(e){var n=r(150),o="object"==typeof t&&t&&!t.nodeType&&t,i=o&&"object"==typeof e&&e&&!e.nodeType&&e,u=i&&i.exports===o&&n.process,s=function(){try{var e=i&&i.require&&i.require("util").types;return e||u&&u.binding&&u.binding("util")}catch(e){}}();e.exports=s}).call(t,r(60)(e))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheStore=void 0;var n,o=function(){function e(e,t){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=(0,p.formTaggedCollectionName)(e,n.tag);var o=r||f.processorFactory.getCacheOfflineDataProcessor(),i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,o,n));return i.ttl=n.ttl||void 0,i.syncManager=h.syncManagerProvider.getSyncManager(),i.useDeltaSet=!0===n.useDeltaSet,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,c.NetworkStore),o(t,[{key:"removeById",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,a.isDefined)(e)?function e(t,r,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in o)return o.value;var u=o.get;return void 0!==u?u.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"removeById",this).call(this,e,r):i.Promise.resolve({count:0})}},{key:"clear",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._validateQuery(e);if(r)return r;var n=this._buildOperationObject(l.OperationType.Clear,e);return this._executeOperation(n,t).then(function(e){return{count:e}})}},{key:"pendingSyncCount",value:function(e){return this.syncManager.getSyncItemCountByEntityQuery(this.collection,e)}},{key:"pendingSyncEntities",value:function(e){return this.syncManager.getSyncEntities(this.collection,e)}},{key:"push",value:function(e){return this.syncManager.push(this.collection,e)}},{key:"pull",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r=(0,s.default)({useDeltaSet:this.useDeltaSet},r),this.syncManager.getSyncItemCountByEntityQuery(this.collection,e).then(function(e){if(e>0){var t=(0,p.getEntitiesPendingPushError)(e,"fetch the entities");return i.Promise.reject(t)}return i.Promise.resolve()}).then(function(){return t.syncManager.pull(t.collection,e,r)})}},{key:"sync",value:function(e,t){var r=this;t=(0,s.default)({useDeltaSet:this.useDeltaSet},t);var n={};return this.push(t).then(function(o){return n.push=o,r.pull(e,t)}).then(function(e){return n.pull=e,n})}},{key:"clearSync",value:function(e){return this.syncManager.clearSync(this.collection,e)}}]),t}()},function(e,t,r){var n=r(155);e.exports=function(e,t,r){"__proto__"==t&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkStore=void 0;var n=function(){function e(e,t){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._processor=r||v.processorFactory.getNetworkProcessor(),t&&!(0,i.default)(t))throw new a.KinveyError("Collection must be a string.");this.collection=t,this.client=n.client}return n(e,[{key:"find",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._validateQuery(e);if(r)return(0,h.wrapInObservable)(r);t=(0,s.default)({useDeltaSet:this.useDeltaSet},t);var n=this._buildOperationObject(y.OperationType.Read,e),o=this._executeOperation(n,t);return this._ensureObservable(o)}},{key:"findById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return(0,h.wrapInObservable)(function(e){e.next(void 0)});var r=this._buildOperationObject(y.OperationType.ReadById,null,null,e),n=this._executeOperation(r,t);return this._ensureObservable(n)}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._validateAggregationQuery(e);if(r)return this._ensureObservable(r);var n=this._buildOperationObject(y.OperationType.Group,e),o=this._executeOperation(n,t);return this._ensureObservable(o)}},{key:"count",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._validateQuery(e);if(r)return(0,h.wrapInObservable)(r);var n=this._buildOperationObject(y.OperationType.Count,e),o=this._executeOperation(n,t);return this._ensureObservable(o)}},{key:"create",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,f.isDefined)(e))return o.Promise.resolve(null);if((0,u.default)(e))return o.Promise.reject(new a.KinveyError("Unable to create an array of entities.","Please create entities one by one."));var r=this._buildOperationObject(y.OperationType.Create,null,e);return this._executeOperation(r,t)}},{key:"update",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,f.isDefined)(e))return o.Promise.resolve(null);if((0,u.default)(e)){var r=new a.KinveyError("Unable to update an array of entities.","Please update entities one by one.");return o.Promise.reject(r)}if(!(0,f.isDefined)(e._id)){return o.Promise.reject(new a.KinveyError("The entity provided does not contain an _id. An _id is required to update the entity.",e))}var n=this._buildOperationObject(y.OperationType.Update,null,e),i=this._executeOperation(n,t);return this._ensurePromise(i)}},{key:"save",value:function(e,t){return e._id?this.update(e,t):this.create(e,t)}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._validateQuery(e);if(r)return r;var n=this._buildOperationObject(y.OperationType.Delete,e),o=this._executeOperation(n,t).then(function(e){return{count:e}});return this._ensurePromise(o)}},{key:"removeById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,f.isDefined)(e))return o.Promise.resolve(void 0);var r=this._buildOperationObject(y.OperationType.DeleteById,null,null,e);return this._executeOperation(r,t).then(function(e){return{count:e}})}},{key:"subscribe",value:function(e){return(0,d.getLiveCollectionManager)().subscribeCollection(this.collection,e)}},{key:"unsubscribe",value:function(){return(0,d.getLiveCollectionManager)().unsubscribeCollection(this.collection)}},{key:"_validateQuery",value:function(e){return!e||e instanceof c.Query?null:o.Promise.reject(new a.KinveyError("Invalid query. It must be an instance of the Query class."))}},{key:"_validateAggregationQuery",value:function(e){return e instanceof p.Aggregation?null:o.Promise.reject(new a.KinveyError("Invalid aggregation. It must be an instance of the Aggregation class."))}},{key:"_buildOperationObject",value:function(e,t,r,n){return new y.Operation(e,this.collection,t,r,n)}},{key:"_executeOperation",value:function(e,t){return this._processor.process(e,t)}},{key:"_ensureObservable",value:function(e){if((0,f.isPromiseLike)(e))return(0,h.wrapInObservable)(e);if((0,f.isObservable)(e))return e;throw new a.KinveyError("Unexpected result type.")}},{key:"_ensurePromise",value:function(e){if((0,f.isPromiseLike)(e))return e;throw new a.KinveyError("Unexpected result type.")}},{key:"client",get:function(){return(0,f.isDefined)(this._client)?this._client:l.Client.sharedInstance()},set:function(e){e instanceof l.Client?this._client=e:this._client=null}},{key:"pathname",get:function(){var e="/appdata/"+this.client.appKey;return this.collection&&(e=e+"/"+this.collection),e}}]),e}()},function(e,t,r){var n=r(149)(Object.getPrototypeOf,Object);e.exports=n},function(e,t,r){var n=r(69),o=r(358),i=r(359),u=r(360),s=r(361),a=r(362);function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=u,c.prototype.has=s,c.prototype.set=a,e.exports=c},function(e,t,r){var n=r(363),o=r(370),i=r(372),u=r(373),s=r(374);function a(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t0&&void 0!==arguments[0]?arguments[0]:{};c(this,e),t=(0,u.default)({statusCode:l.Empty,headers:new s.Headers,data:null},t),this.statusCode=t.statusCode,this.headers=t.headers,this.data=t.data}return o(e,[{key:"isSuccess",value:function(){return this.statusCode>=200&&this.statusCode<300||this.statusCode===l.MovedPermanently||this.statusCode===l.Found||this.statusCode===l.NotModified||this.statusCode===l.TemporaryRedirect||this.statusCode===l.PermanentRedirect}},{key:"isServerError",value:function(){return this.statusCode>=500&&this.statusCode<600}},{key:"isClientError",value:function(){return this.statusCode>=400&&this.statusCode<500}},{key:"toPlainObject",value:function(){return{statusCode:this.statusCode,headers:this.headers.toPlainObject(),data:this.data}}},{key:"headers",get:function(){return this._headers},set:function(e){e instanceof s.Headers||(e=new s.Headers(e)),this._headers=e}},{key:"error",get:function(){if(this.isSuccess())return null;var e=this.data||{},t=e.message||e.description,r=e.debug,n=this.statusCode,o=this.headers.get("X-Kinvey-Request-ID");return n===l.Unauthorized?new a.InsufficientCredentialsError(t,r,n,o):n===l.NotFound?new a.NotFoundError(t,r,n,o):n===l.ServerError?new a.ServerError(t,r,n,o):new a.KinveyError(t,r,n,o)}}]),e}();t.KinveyResponse=function(e){function t(){return c(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,f),o(t,[{key:"error",get:function(){if(this.isSuccess())return null;var e=this.data||{},r=e.name||e.error,n=e.message||e.description,o=e.debug,i=this.statusCode,u=this.headers.get("X-Kinvey-Request-ID"),s=void 0;if("APIVersionNotAvailable"===r)s=new a.APIVersionNotAvailableError(n,o,i,u);else if("APIVersionNotImplemented"===r)s=new a.APIVersionNotImplementedError(n,o,i,u);else if("AppProblem"===r)s=new a.AppProblemError(n,o,i,u);else if("AppProblem"===r)s=new a.AppProblemError(n,o,i,u);else if("BadRequest"===r)s=new a.BadRequestError(n,o,i,u);else if("BLInternalError"===r||"BLRuntimeError"===r||"BLSyntaxError"===r||"BLTimeoutError"===r||"BLViolationError"===r)s=new a.BLError(n,o,i,u);else if("CORSDisabled"===r)s=new a.CORSDisabledError(n,o,i,u);else if("DuplicateEndUsers"===r)s=new a.DuplicateEndUsersError(n,o,i,u);else if("FeatureUnavailable"===r)s=new a.FeatureUnavailableError(n,o,i,u);else if("IncompleteRequestBody"===r)s=new a.IncompleteRequestBodyError(n,o,i,u);else if("IndirectCollectionAccessDisallowed"===r)s=new a.IndirectCollectionAccessDisallowedError(n,o,i,u);else if("InsufficientCredentials"===r)s=new a.InsufficientCredentialsError(n,o,i,u);else if("InvalidCredentials"===r)s=new a.InvalidCredentialsError(n,o,i,u);else if("InvalidIdentifier"===r)s=new a.InvalidIdentifierError(n,o,i,u);else if("InvalidQuerySyntax"===r)s=new a.InvalidQuerySyntaxError(n,o,i,u);else if("JSONParseError"===r)s=new a.JSONParseError(n,o,i,u);else if("KinveyInternalErrorRetry"===r)s=new a.KinveyInternalErrorRetry(n,o,i,u);else if("KinveyInternalErrorStop"===r)s=new a.KinveyInternalErrorStop(n,o,i,u);else if("MissingQuery"===r)s=new a.MissingQueryError(n,o,i,u);else if("MissingRequestHeader"===r)s=new a.MissingRequestHeaderError(n,o,i,u);else if("MissingRequestParameter"===r)s=new a.MissingRequestParameterError(n,o,i,u);else if("MissingConfiguration"===r)s=new a.MissingConfigurationError(n,o,i,u);else if("EntityNotFound"===r||"CollectionNotFound"===r||"AppNotFound"===r||"UserNotFound"===r||"BlobNotFound"===r||"DocumentNotFound"===r)s=new a.NotFoundError(n,o,i,u);else if("ParameterValueOutOfRange"===r)s=new a.ParameterValueOutOfRangeError(n,o,i,u);else if("ResultSetSizeExceeded"===r)s=new a.ResultSetSizeExceededError(n,o,i,u);else if("ServerError"===r)s=new a.ServerError(n,o,i,u);else if("StaleRequest"===r)s=new a.StaleRequestError(n,o,i,u);else if("UserAlreadyExists"===r)s=new a.UserAlreadyExistsError(n,o,i,u);else{if("WritesToCollectionDisallowed"!==r)return function e(t,r,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in o)return o.value;var u=o.get;return void 0!==u?u.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"error",this);s=new a.WritesToCollectionDisallowedError(n,o,i,u)}return s}}]),t}()},function(e,t,r){var n=r(407),o=r(420),i=r(61),u=r(6),s=r(429);e.exports=function(e){return"function"==typeof e?e:null==e?i:"object"==typeof e?u(e)?o(e[0],e[1]):n(e):s(e)}},function(e,t,r){var n=r(75),o=r(50);e.exports=function(e,t){for(var r=0,i=(t=n(t,e)).length;null!=e&&r0&&this._events[e].length>u&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=!1;function o(){this.removeListener(e,o),r||(r=!0,t.apply(this,arguments))}return o.listener=t,this.on(e,o),this},r.prototype.removeListener=function(e,t){var r,i,u,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(u=(r=this._events[e]).length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=u;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OfflineDataProcessor=void 0;var n,o=function(){function e(e,t){for(var r=0;r1)||o.Promise.reject(new u.KinveyError("Delete by id matched more than one entity"))})}},{key:"_readEntityFromPersistance",value:function(e,t){this._throwNotImplementedError(t)}},{key:"_writeEntitiesToPersistance",value:function(e,t){this._throwNotImplementedError(t)}},{key:"_deleteEntityFromPersistance",value:function(e,t){this._throwNotImplementedError(t)}},{key:"_getEntityNotFoundError",value:function(e,t){return new u.NotFoundError("An entity with _id = "+t+" was not found in the "+e+" collection on the "+this._storeName+" database.")}},{key:"_storeName",get:function(){return i.Client.sharedInstance().appKey}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(466);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(200);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(467);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t){var r=0,n=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+n).toString(36))}},function(e,t,r){var n=r(54),o=r(40),i=r(120),u=r(494),s=r(213),a=function(e,t,r){var c,l,f,h,p=e&a.F,d=e&a.G,y=e&a.S,v=e&a.P,b=e&a.B,g=d?n:y?n[t]||(n[t]={}):(n[t]||{}).prototype,_=d?o:o[t]||(o[t]={}),m=_.prototype||(_.prototype={});for(c in d&&(r=t),r)f=((l=!p&&g&&void 0!==g[c])?g:r)[c],h=b&&l?s(f,n):v&&"function"==typeof f?s(Function.call,f):f,g&&u(g,c,f,e&a.U),_[c]!=f&&i(_,c,h),v&&m[c]!=f&&(m[c]=f)};n.core=o,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,e.exports=a},function(e,t,r){var n=r(488),o=r(493);e.exports=r(121)?function(e,t,r){return n.f(e,t,o(1,r))}:function(e,t,r){return e[t]=r,e}},function(e,t,r){e.exports=!r(122)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.isDefined=s,t.isNumber=function(e){return!Number.isNaN(parseFloat(e))&&Number.isFinite(e)},t.nested=function(e,t,r){if(!1===s(t))return e=r||e;var n=t.split("."),o=n.shift();for(;o&&e;)e=e[o],o=n.shift();return r||e},t.keyBy=function(e,t){if(!e)return{};return e.reduce(function(e,r){return e[t]=r[t],e},{})},t.isEmpty=function(e){return!s(e)||!(e.length>0)&&(0===e.length||"object"!==(void 0===e?"undefined":n(e))||Object.keys(e).reduce(function(t,r){return!!t&&!Object.hasOwnProperty.call(e,r)},!0))};var o=u(r(264)),i=u(r(265));function u(e){return e&&e.__esModule?e:{default:e}}function s(e){return!1===(0,i.default)(e)&&!1===(0,o.default)(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseQueue=void 0;var n,o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.pendingPromises=0,this.maxPendingPromises=t,this.maxQueuedPromises=r,this.queue=[]}return o(e,[{key:"enqueue",value:function(e){var t=this;return new u.default(function(r,n,o){t.queue.length>=t.maxQueuedPromises?n(new Error("Queue limit reached")):(t.queue.push({promiseGenerator:e,resolve:r,reject:n,notify:o||s.noop}),t._dequeue())})}},{key:"getPendingLength",value:function(){return this.pendingPromises}},{key:"getQueueLength",value:function(){return this.queue.length}},{key:"_dequeue",value:function(){var e=this;if(this.pendingPromises>=this.maxPendingPromises)return!1;var t=this.queue.shift();if(!t)return!1;try{this.pendingPromises+=1,(0,s.wrapInPromise)(t.promiseGenerator()).then(function(r){e.pendingPromises-=1,t.resolve(r),e._dequeue()},function(r){e.pendingPromises-=1,t.reject(r),e._dequeue()},function(e){t.notify(e)})}catch(e){this.pendingPromises-=1,t.reject(e),this._dequeue()}return!0}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.activeUserKey=void 0,t.noop=function(){},t.isPromiseLike=p,t.isObservable=function(e){return e instanceof o.Observable},t.wrapInPromise=function(e){if(p(e))return e;return n.Promise.resolve(e)},t.useIfDefined=d,t.ensureArray=y,t.isValidStorageProviderValue=function(e){var t=a.repositoryProvider.getSupportedStorages(),r=y(e);return!!e&&r.length&&r.every(function(e){return t.some(function(t){return e===t})})},t.forEachAsync=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,o=new c.PromiseQueue(r);return function(e,t){var r=0,o=e.length;if((0,i.default)(e))return n.Promise.resolve();return new n.Promise(function(n){var i=function(){(r+=1)===o&&n()};e.forEach(function(e){t(e).then(i).catch(i)})})}(e,function(e){return o.enqueue(function(){return t(e)})})},t.splitQueryIntoPages=function(e,t,r){if(!(0,s.default)(t)||!(0,s.default)(r))throw new f.KinveyError("Invalid page size or expected entity count parameter");var n=Math.ceil(r/t);return(0,u.default)(n,function(n){var o=new l.Query(e);return o.skip=e.skip+n*t,o.limit=Math.min(r-n*t,t),o})};var n=r(2),o=r(126),i=h(r(36)),u=h(r(152)),s=h(r(38)),a=r(22),c=r(124),l=r(16),f=r(1);function h(e){return e&&e.__esModule?e:{default:e}}t.activeUserKey="active_user";function p(e){return!!e&&"function"==typeof e.then&&"function"==typeof e.catch}function d(e,t){return void 0!==e?e:t}function y(e){return e=d(e,[]),Array.isArray(e)?e:[e]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5);r.d(t,"Observable",function(){return n.a});var o=r(268);r.d(t,"ConnectableObservable",function(){return o.a});var i=r(270);r.d(t,"GroupedObservable",function(){return i.a});var u=r(31);r.d(t,"observable",function(){return u.a});var s=r(32);r.d(t,"Subject",function(){return s.a});var a=r(271);r.d(t,"BehaviorSubject",function(){return a.a});var c=r(272);r.d(t,"ReplaySubject",function(){return c.a});var l=r(87);r.d(t,"AsyncSubject",function(){return l.a});var f=r(278);r.d(t,"asapScheduler",function(){return f.a});var h=r(88);r.d(t,"asyncScheduler",function(){return h.a});var p=r(133);r.d(t,"queueScheduler",function(){return p.a});var d=r(282);r.d(t,"animationFrameScheduler",function(){return d.a});var y=r(285);r.d(t,"VirtualTimeScheduler",function(){return y.b}),r.d(t,"VirtualAction",function(){return y.a});var v=r(134);r.d(t,"Scheduler",function(){return v.a});var b=r(8);r.d(t,"Subscription",function(){return b.a});var g=r(13);r.d(t,"Subscriber",function(){return g.a});var _=r(135);r.d(t,"Notification",function(){return _.a});var m=r(131);r.d(t,"pipe",function(){return m.a});var w=r(85);r.d(t,"noop",function(){return w.a});var O=r(89);r.d(t,"identity",function(){return O.a});var E=r(286);r.d(t,"isObservable",function(){return E.a});var P=r(287);r.d(t,"ArgumentOutOfRangeError",function(){return P.a});var k=r(288);r.d(t,"EmptyError",function(){return k.a});var j=r(57);r.d(t,"ObjectUnsubscribedError",function(){return j.a});var S=r(130);r.d(t,"UnsubscriptionError",function(){return S.a});var x=r(289);r.d(t,"TimeoutError",function(){return x.a});var C=r(290);r.d(t,"bindCallback",function(){return C.a});var T=r(291);r.d(t,"bindNodeCallback",function(){return T.a});var M=r(292);r.d(t,"combineLatest",function(){return M.a});var I=r(294);r.d(t,"concat",function(){return I.a});var A=r(145);r.d(t,"defer",function(){return A.a});var R=r(21);r.d(t,"empty",function(){return R.b});var N=r(302);r.d(t,"forkJoin",function(){return N.a});var q=r(35);r.d(t,"from",function(){return q.a});var D=r(303);r.d(t,"fromEvent",function(){return D.a});var U=r(304);r.d(t,"fromEventPattern",function(){return U.a});var K=r(305);r.d(t,"generate",function(){return K.a});var L=r(306);r.d(t,"iif",function(){return L.a});var F=r(307);r.d(t,"interval",function(){return F.a});var B=r(308);r.d(t,"merge",function(){return B.a});var H=r(147);r.d(t,"never",function(){return H.b});var z=r(86);r.d(t,"of",function(){return z.a});var G=r(309);r.d(t,"onErrorResumeNext",function(){return G.a});var V=r(310);r.d(t,"pairs",function(){return V.a});var Q=r(311);r.d(t,"race",function(){return Q.a});var $=r(312);r.d(t,"range",function(){return $.a});var Y=r(137);r.d(t,"throwError",function(){return Y.a});var W=r(313);r.d(t,"timer",function(){return W.a});var X=r(314);r.d(t,"using",function(){return X.a});var J=r(315);r.d(t,"zip",function(){return J.a}),r.d(t,"EMPTY",function(){return R.a}),r.d(t,"NEVER",function(){return H.a});var Z=r(56);r.d(t,"config",function(){return Z.a})},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(56),o=r(83),i={closed:!0,next:function(e){},error:function(e){if(n.a.useDeprecatedSynchronousErrorHandling)throw e;Object(o.a)(e)},complete:function(){}}},function(e,t,r){"use strict";t.a=function(e){return null!=e&&"object"==typeof e}},function(e,t,r){"use strict";r.d(t,"a",function(){return n});var n={e:{}}},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(r){var n=e.call(this,r?r.length+" errors occurred during unsubscription:\n "+r.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"")||this;return n.errors=r,n.name="UnsubscriptionError",Object.setPrototypeOf(n,t.prototype),n}return n.a(t,e),t}(Error)},function(e,t,r){"use strict";t.a=function(){for(var e=[],t=0;t=0};var n=r(14)},function(e,t,r){"use strict";r.d(t,"a",function(){return i}),t.b=function(){return i};var n=r(5),o=r(85),i=new n.a(o.a)},function(e,t,r){var n=r(46),o=r(316),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=[];for(var r in Object(e))i.call(e,r)&&"constructor"!=r&&t.push(r);return t}},function(e,t){e.exports=function(e,t){return function(r){return e(t(r))}}},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(t,r(11))},function(e,t){var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},function(e,t,r){var n=r(153),o=r(154),i=r(330),u=9007199254740991,s=4294967295,a=Math.min;e.exports=function(e,t){if((e=i(e))<1||e>u)return[];var r=s,c=a(e,s);t=o(t),e-=s;for(var l=n(c,t);++r1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(u=e.length>3&&"function"==typeof u?(i--,u):void 0,s&&o(r[0],r[1],s)&&(u=i<3?void 0:u,i=1),t=Object(t);++n2?t[2]:void 0;for(c&&i(t[0],t[1],c)&&(n=1);++r0&&void 0!==arguments[0]?arguments[0]:{};C(this,t);var r=T(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.rack=E.NetworkRack,r.file=!0===e.file,r}return M(t,w.Request),o(t,[{key:"toPlainObject",value:function(){return Object.assign(i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"toPlainObject",this).call(this),{file:this.file})}}]),t}(),R=t.AuthType={All:"All",App:"App",Basic:"Basic",Default:"Default",Master:"Master",None:"None",Session:"Session",Client:"Client"};Object.freeze(R);var N={all:function(e){return N.session(e).catch(function(){return N.basic(e)})},app:function(e){return e.appKey&&e.appSecret?u.default.resolve({scheme:"Basic",username:e.appKey,password:e.appSecret}):u.default.reject(new Error("Missing client appKey and/or appSecret. Use Kinvey.initialize() to set the appKey and appSecret for the client."))},basic:function(e){return N.master(e).catch(function(){return N.app(e)})},client:function(e,t){return e.appKey&&e.appSecret?(t||(t=e.appKey),u.default.resolve({scheme:"Basic",username:t,password:e.appSecret})):u.default.reject(new Error("Missing client appKey and/or appSecret Use Kinvey.initialize() to set the appKey and appSecret for the client."))},master:function(e){return e.appKey&&e.masterSecret?u.default.resolve({scheme:"Basic",username:e.appKey,password:e.masterSecret}):u.default.reject(new Error("Missing client appKey and/or masterSecret. Use Kinvey.initialize() to set the appKey and masterSecret for the client."))},none:function(){return u.default.resolve(null)},session:function(e){var t=e.getActiveUser();return(0,_.isDefined)(t)?(0,h.default)(t._kmd)&&(0,_.isDefined)(t._kmd.authtoken)?u.default.resolve({scheme:"Kinvey",credentials:t._kmd.authtoken}):u.default.reject(new m.NoActiveUserError("The active user does not have a valid auth token.")):u.default.reject(new m.NoActiveUserError("There is not an active user. Please login a user and retry the request."))}};function q(e){var t=(0,j.getLiveService)(e.client),r=u.default.resolve();return t.isInitialized()&&(r=t.fullUninitialization()),r.then(function(){return e.client.setActiveUser(null)}).catch(function(e){return k.Log.error(e),null}).then(function(){return S.DataStore.clearCache({client:e.client})}).catch(function(e){return k.Log.error(e),null})}var D=t.Properties=function(e){function t(){return C(this,t),T(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return M(t,O.Headers),t}();t.KinveyRequest=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};C(this,t);var r=T(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return e=(0,c.default)({skipBL:!1,trace:!1},e),r.authType=e.authType||R.None,r.query=e.query,r.aggregation=e.aggregation,r.properties=e.properties||new D,r.skipBL=!0===e.skipBL,r.trace=!0===e.trace,r.clientId=e.clientId,r.kinveyFileTTL=e.kinveyFileTTL,r.kinveyFileTLS=e.kinveyFileTLS,r}return M(t,A),o(t,[{key:"getAuthorizationHeader",value:function(e,t){var r=u.default.resolve(void 0);if(e)switch(e){case R.All:r=N.all(t);break;case R.App:r=N.app(t);break;case R.Basic:r=N.basic(t);break;case R.Client:r=N.client(t,this.clientId);break;case R.Master:r=N.master(t);break;case R.None:r=N.none(t);break;case R.Session:r=N.session(t);break;default:r=N.session(t).catch(function(e){return N.master(t).catch(function(){throw e})})}return r.then(function(e){if((0,_.isDefined)(e)){var t=e.credentials;return e.username&&(t=s.Buffer.from(e.username+":"+e.password).toString("base64")),e.scheme+" "+t}})}},{key:"execute",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.getAuthorizationHeader(this.authType,this.client).then(function(t){(0,_.isDefined)(t)?e.headers.set("Authorization",t):e.headers.remove("Authorization")}).then(function(){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"execute",e).call(e)}).then(function(e){if(e instanceof P.KinveyResponse==!1&&(e=new P.KinveyResponse({statusCode:e.statusCode,headers:e.headers,data:e.data})),!1===r&&!1===e.isSuccess())throw e.error;return e}).catch(function(o){if(o instanceof m.InvalidCredentialsError){if(n){if(I.paused)return I.add(function(){return e.execute(r,!1).catch(function(){return u.default.reject(o)})});I.pause();var i=e.client.getActiveUser(),s=(0,_.isDefined)(i)&&(0,_.isDefined)(i._socialIdentity)?i._socialIdentity:{},a=Object.keys(s).find(function(e){return"kinveyAuth"===s[e].identity}),c=s[a];if((0,_.isDefined)(c))return new t({method:w.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},authType:R.Client,url:p.default.format({protocol:e.client.micProtocol,host:e.client.micHost,pathname:"/oauth/token"}),body:{grant_type:"refresh_token",client_id:c.client_id,redirect_uri:c.redirect_uri,refresh_token:c.refresh_token},properties:e.properties,timeout:e.timeout,clientId:c.client_id}).execute().then(function(e){return e.data}).then(function(t){return t.identity=c.identity,t.client_id=c.client_id,t.redirect_uri=c.redirect_uri,t.protocol=e.client.micProtocol,t.host=e.client.micHost,t}).then(function(r){var n={};return s[r.identity]=r,n._socialIdentity=s,new t({method:w.RequestMethod.POST,authType:R.App,url:p.default.format({protocol:e.client.apiProtocol,host:e.client.apiHost,pathname:"/user/"+e.client.appKey+"/login"}),properties:e.properties,body:n,timeout:e.timeout,client:e.client}).execute().then(function(e){return e.data}).then(function(t){return t._socialIdentity[r.identity]=(0,l.default)(t._socialIdentity[r.identity],r),e.client.setActiveUser(t)})}).catch(function(){return q(e).then(function(){return I.start(),u.default.reject(o)})}).then(function(){return I.start(),e.execute(r,!1)});I.start()}return q(e).then(function(){return u.default.reject(o)})}return u.default.reject(o)})}},{key:"appVersion",get:function(){return this.client.appVersion}},{key:"query",get:function(){return this._query},set:function(e){if((0,_.isDefined)(e)&&!(e instanceof b.Query))throw new m.KinveyError("Invalid query. It must be an instance of the Query class.");this._query=e}},{key:"aggregation",get:function(){return this._aggregation},set:function(e){if((0,_.isDefined)(e)&&!(e instanceof g.Aggregation))throw new m.KinveyError("Invalid aggregation. It must be an instance of the Aggregation class.");(0,_.isDefined)(e)&&(this.body=e.toPlainObject()),this._aggregation=e}},{key:"headers",get:function(){var e=i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"headers",this);if(e.has("Accept")||e.set("Accept","application/json; charset=utf-8"),e.has("Content-Type")||e.set("Content-Type","application/json; charset=utf-8"),e.has("X-Kinvey-Api-Version")||e.set("X-Kinvey-Api-Version",4),!0===this.skipBL?e.set("X-Kinvey-Skip-Business-Logic",!0):e.remove("X-Kinvey-Skip-Business-Logic"),!0===this.trace?(e.set("X-Kinvey-Include-Headers-In-Response","X-Kinvey-Request-Id"),e.set("X-Kinvey-ResponseWrapper",!0)):(e.remove("X-Kinvey-Include-Headers-In-Response"),e.remove("X-Kinvey-ResponseWrapper")),this.appVersion?e.set("X-Kinvey-Client-App-Version",this.appVersion):e.remove("X-Kinvey-Client-App-Version"),this.properties){var r=this.properties.toString();if((0,f.default)(r))e.remove("X-Kinvey-Custom-Request-Properties");else{var n=function(e){if(e){var t=0,r=e.length;e=String(e||"");for(var n=0;n=2e3)throw new Error("The custom properties are "+n+" bytes.It must be less then 2000 bytes.","Please remove some custom properties.");e.set("X-Kinvey-Custom-Request-Properties",r)}}else e.remove("X-Kinvey-Custom-Request-Properties");return e},set:function(e){n(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"headers",e,this)}},{key:"url",get:function(){var e=i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",this),r={kinveyfile_ttl:this.kinveyFileTTL,kinveyfile_tls:this.kinveyFileTLS};return this.query&&(r=Object.assign({},r,this.query.toQueryString())),(0,f.default)(r)?e:(0,_.appendQuery)(e,a.default.stringify(r))},set:function(e){n(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",e,this)}},{key:"properties",get:function(){return this._properties},set:function(e){e&&e instanceof D==!1&&(e=new D(e)),this._properties=e}}],[{key:"execute",value:function(e,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=(0,c.default)({method:w.RequestMethod.GET,authType:R.Default},e);r=r||v.Client.sharedInstance(),!o.url&&(0,d.default)(o.pathname)&&r&&(o.url=p.default.format({protocol:r.apiProtocol,host:r.apiHost,pathname:o.pathname}));var i=new t(o).execute();return n&&(i=i.then(function(e){return e.data})),i}}]),t}()},function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),i=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?r+=t.charAt(n):i<128?r+=o[i]:i<2048?r+=o[192|i>>6]+o[128|63&i]:i<55296||i>=57344?r+=o[224|i>>12]+o[128|i>>6&63]+o[128|63&i]:(n+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(n)),r+=o[240|i>>18]+o[128|i>>12&63]+o[128|i>>6&63]+o[128|63&i])}return r},isBuffer:function(e){return null!==e&&void 0!==e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,r,o){if(!r)return t;if("object"!=typeof r){if(Array.isArray(t))t.push(r);else{if("object"!=typeof t)return[t,r];(o.plainObjects||o.allowPrototypes||!n.call(Object.prototype,r))&&(t[r]=!0)}return t}if("object"!=typeof t)return[t].concat(r);var u=t;return Array.isArray(t)&&!Array.isArray(r)&&(u=i(t,o)),Array.isArray(t)&&Array.isArray(r)?(r.forEach(function(r,i){n.call(t,i)?t[i]&&"object"==typeof t[i]?t[i]=e(t[i],r,o):t.push(r):t[i]=r}),t):Object.keys(r).reduce(function(t,i){var u=r[i];return n.call(t,i)?t[i]=e(t[i],u,o):t[i]=u,t},u)}}},function(e,t,r){"use strict";var n=String.prototype.replace,o=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return n.call(e,o,"+")},RFC3986:function(e){return e}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Request=t.RequestMethod=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=(0,u.default)({followRedirect:!0},t),this.id=(0,f.randomString)(),this.client=t.client,this.method=t.method||y.GET,this.headers=t.headers||new p.Headers,this.url=t.url||"",this.body=t.body||t.data,this.timeout=(0,f.isDefined)(t.timeout)?t.timeout:this.client.defaultTimeout,this.followRedirect=!0===t.followRedirect,this.cache=!0===t.cache}return n(e,[{key:"execute",value:function(){return!1===(0,f.isDefined)(this.rack)?(Log.error("Unable to execute the request. Please provide a rack to execute the request."),o.default.reject(new l.KinveyError("Unable to execute the request. Please provide a rack to execute the request."))):this.rack.execute(this.toPlainObject()).then(function(e){if(!1===(0,f.isDefined)(e))throw new l.NoResponseError;return e instanceof h.Response==!1&&(e=new h.Response({statusCode:e.statusCode,headers:e.headers,data:e.data})),e})}},{key:"cancel",value:function(){return this.rack.cancel()}},{key:"toPlainObject",value:function(){return{id:this.id,method:this.method,headers:this.headers.toPlainObject(),url:this.url,body:this.body,timeout:this.timeout,followRedirect:this.followRedirect,encryptionKey:this.client.encryptionKey}}},{key:"client",get:function(){return this._client||c.Client.sharedInstance()},set:function(e){if(e&&e instanceof c.Client==!1)throw new l.KinveyError("client must be an instance of the Client class.");this._client=e}},{key:"method",get:function(){return this._method},set:function(e){switch((0,s.default)(e)||(e=String(e)),e=e.toUpperCase()){case y.GET:case y.POST:case y.PATCH:case y.PUT:case y.DELETE:this._method=e;break;default:throw new l.KinveyError("Invalid request method. Only GET, POST, PATCH, PUT, and DELETE are allowed.")}}},{key:"headers",get:function(){return this._headers},set:function(e){e instanceof p.Headers||(e=new p.Headers(e)),this._headers=e}},{key:"url",get:function(){return!0===this.cache?(0,f.appendQuery)(this._url,i.default.stringify({_:Math.random().toString(36).substr(2)})):this._url},set:function(e){this._url=e}},{key:"data",get:function(){return this.body},set:function(e){this.body=e}},{key:"timeout",get:function(){return this._timeout},set:function(e){if(e=parseInt(e,10),!1===(0,a.default)(e)||isNaN(e))throw new l.KinveyError("Invalid timeout. Timeout must be a number.");this._timeout=e}},{key:"followRedirect",get:function(){return this._followRedirect},set:function(e){this._followRedirect=!!e}},{key:"cache",get:function(){return this._cache},set:function(e){this._cache=!!e}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkRack=t.Rack=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"Rack";p(this,t);var r=d(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.middlewares=[],r.canceled=!1,r.activeMiddleware=void 0,r}return y(t,f.Middleware),n(t,[{key:"use",value:function(e){if((0,c.isDefined)(e)){if(e instanceof f.Middleware)return void this.middlewares.push(e);throw new Error("Unable to use the middleware. It must be an instance of Middleware.")}}},{key:"reset",value:function(){this.middlewares=[]}},{key:"execute",value:function(e){var t=this;return!1===(0,c.isDefined)(e)?i.default.reject(new Error("Request is undefined. Please provide a valid request.")):(0,u.default)((0,a.default)(this.middlewares),function(r,n){return r.then(function(r){var o=r.request,u=r.response;return t.canceled?i.default.reject(new Error("Cancelled")):(t.activeMiddleware=n,n.handle(o||e,u))})},i.default.resolve({request:e})).then(function(e){var r=e.response;return!0===t.canceled?i.default.reject(new Error("Cancelled")):(t.canceled=!1,t.activeMiddleware=void 0,r)}).catch(function(e){throw t.canceled=!1,t.activeMiddleware=void 0,e})}},{key:"cancel",value:function(){return this.canceled=!0,(0,c.isDefined)(this.activeMiddleware)&&(0,s.default)(this.activeMiddleware.cancel)?this.activeMiddleware.cancel():i.default.resolve()}},{key:"handle",value:function(e){return this.execute(e)}},{key:"generateTree",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"generateTree",this).call(this,e);return(0,a.default)(this.middlewares).forEach(function(t){r.nodes.push(t.generateTree(e+1))}),r}}]),t}(),b=new(function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Network Rack";p(this,t);var r=d(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.use(new f.SerializeMiddleware),r.use(new f.HttpMiddleware),r.use(new f.ParseMiddleware),r}return y(t,v),n(t,[{key:"useHttpMiddleware",value:function(e){this.reset(),this.use(new f.SerializeMiddleware),this.use(e),this.use(new f.ParseMiddleware)}},{key:"execute",value:function(e){return l.Log.debug("Executing network request",e),o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"execute",this).call(this,e).then(function(t){return l.Log.debug("Received response for network request: "+e.id,t),t}).catch(function(t){throw l.Log.error("Received error for network request id: "+e.id,t),t})}}]),t}());t.NetworkRack=b},function(e,t,r){var n=r(409),o=r(18);e.exports=function e(t,r,i,u,s){return t===r||(null==t||null==r||!o(t)&&!o(r)?t!=t&&r!=r:n(t,r,i,u,e,s))}},function(e,t,r){var n=r(410),o=r(413),i=r(414),u=1,s=2;e.exports=function(e,t,r,a,c,l){var f=r&u,h=e.length,p=t.length;if(h!=p&&!(f&&p>h))return!1;var d=l.get(e);if(d&&l.get(t))return d==t;var y=-1,v=!0,b=r&s?new n:void 0;for(l.set(e,t),l.set(t,e);++y2&&void 0!==arguments[2]?arguments[2]:{},s=void 0,a=o.useDeltaSet;return(0,p.wrapInObservable)(function(f){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processRead",n).call(n,e,r,o).then(function(t){return s=t,f.next(s),n._ensureCountBeforeRead(e,"fetch the entities",r)}).then(function(){return a?(0,y.deltaSet)(e,r,o).catch(function(t){if(t instanceof l.InvalidCachedQuery)return a=!1,(0,v.getCachedQuery)(e,r).then(function(e){return(0,v.deleteCachedQuery)(e)}).catch(function(e){if(e instanceof l.NotFoundError)return null;throw e}).then(function(){return n._networkRepository.read(e,r,Object.assign(o,{dataOnly:!1}))});throw t}):n._networkRepository.read(e,r,Object.assign(o,{dataOnly:!1}))}).then(function(t){return(0,v.getCachedQuery)(e,r).then(function(e){return e&&t.headers?(e.lastRequest=t.headers.requestStart,(0,v.updateCachedQuery)(e)):null}).then(function(){return t.data?t.data:t})}).then(function(l){if(a){var f=[];if(l.deleted.length>0){var h=new c.Query;h.contains("_id",l.deleted.map(function(e){return e._id})),f.push(n._deleteEntitiesOffline(e,h,l.deleted))}return l.changed.length>0&&f.push(n._replaceOfflineEntities(e,l.changed,l.changed)),u.Promise.all(f).then(function(){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processRead",n).call(n,e,r,o)})}return n._replaceOfflineEntities(e,s,l).then(function(){return l})}).then(function(e){return f.next(e),e})})}},{key:"_processReadById",value:function(e,r,n){var o=this,u=void 0;return(0,p.wrapInObservable)(function(s){var a=(new c.Query).equalTo("_id",r);return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processReadById",o).call(o,e,r,n).catch(function(e){return o._catchNotFoundError(e)}).then(function(t){return s.next(t),u=t,o._ensureCountBeforeRead(e,"find the entity",a)}).then(function(){return o._networkRepository.readById(e,r,n)}).then(function(t){return s.next(t),o._replaceOfflineEntities(e,u,(0,h.ensureArray)(t))})})}},{key:"_processUpdate",value:function(e,r,n){var o=this;return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processUpdate",this).call(this,e,r,n).then(function(){return o._networkRepository.update(e,r,n)}).then(function(t){return o._getRepository().then(function(r){return r.update(e,t,n)}).then(function(){return o._syncManager.removeSyncItemForEntityId(e,t._id)}).then(function(){return t})})}},{key:"_processCount",value:function(e,r,n){var o=this;return(0,p.wrapInObservable)(function(u){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processCount",o).call(o,e,r,n).then(function(t){return u.next(t),o._networkRepository.count(e,r,n)}).then(function(e){return u.next(e)})})}},{key:"_processGroup",value:function(e,r,n){var o=this;return(0,p.wrapInObservable)(function(u){return i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"_processGroup",o).call(o,e,r,n).catch(function(){return[]}).then(function(t){return u.next(t),o._networkRepository.group(e,r,n)}).then(function(e){return u.next(e)})})}},{key:"_replaceNetworkEntityOffline",value:function(e,t,r){return this._getRepository().then(function(n){var o=u.Promise.resolve();return t&&(o=n.deleteById(e,t)),o.then(function(){return n.create(e,r)})})}},{key:"_replaceOfflineEntities",value:function(e,t,r){var n=this,o=u.Promise.resolve(),i=(0,h.ensureArray)(t);if(t&&(0,d.isNotEmpty)(i)){var s=(new c.Query).contains("_id",i.map(function(e){return e._id}));o=this._getRepository().then(function(t){return t.delete(e,s)})}return o.then(function(){return n._getRepository()}).then(function(t){return t.create(e,r)})}},{key:"_attemptDeleteByIdOverNetwork",value:function(e,t,r){var n=this;return new u.Promise(function(o){return n._networkRepository.deleteById(e,t,r).then(function(){return o(!0)}).catch(function(e){e instanceof l.NotFoundError?o(!0):o(!1)})})}},{key:"_attemptDeleteOverNetwork",value:function(e,t,r){var n=this;return new u.Promise(function(o){n._networkRepository.delete(e,t,r).then(function(){return o(!0)}).catch(function(){return o(!1)})})}},{key:"_deleteEntitiesOffline",value:function(e,t,r,n){var o=this;return this._getRepository().then(function(r){return r.delete(e,t,n)}).then(function(t){return o._syncManager.removeSyncItemsForIds(e,r.map(function(e){return e._id})).then(function(){return t})})}},{key:"_ensureCountBeforeRead",value:function(e,t,r){return this._syncManager.getSyncItemCountByEntityQuery(e,r).then(function(e){return 0===e?e:u.Promise.reject((0,d.getEntitiesPendingPushError)(e,t))})}},{key:"_catchNotFoundError",value:function(e){if(!(e instanceof l.NotFoundError))return u.Promise.reject(e)}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.StorageProvider={Memory:"Memory",WebSQL:"WebSQL",IndexedDB:"IndexedDB",LocalStorage:"LocalStorage",SessionStorage:"SessionStorage",SQLite:"SQLite"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(187);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(451);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InmemoryOfflineRepository=void 0;var n,o=function(){function e(e,t){for(var r=0;r0?this._saveAll(e,o):i.Promise.resolve()}},{key:"_delete",value:function(e,t){var r=this;return this._readAll(e).then(function(n){var o=(0,l.applyQueryToDataset)(n,t);return r._deleteMatchingEntitiesFromPersistance(e,n,o).then(function(){return o.length})})}},{key:"_deleteById",value:function(e,t){var r=this;return this._readAll(e).then(function(n){var o=n.findIndex(function(e){return e._id===t});return o>-1?(n.splice(o,1),r._saveAll(e,n).then(function(){return 1})):i.Promise.resolve(0)})}},{key:"_getAllCollections",value:function(){var e=this;return this._persister.getKeys().then(function(t){var r=[];return(t=t||[]).forEach(function(t){e._keyBelongsToApp(t)&&r.push(e._getCollectionFromKey(t))}),r})}},{key:"_update",value:function(e,t){var r=this,n=(0,f.ensureArray)(t),o=(0,s.default)(n,"_id"),i=n.length;return this._readAll(e).then(function(t){return t.forEach(function(e,r){i>0&&o[e._id]&&(t[r]=o[e._id],delete o[e._id],i-=1)}),i>0&&Object.keys(o).forEach(function(e){t.push(o[e])}),r._saveAll(e,t)})}},{key:"_readAll",value:function(e){var t=this._formCollectionKey(e);return this._persister.read(t).then(function(e){return e||[]})}},{key:"_saveAll",value:function(e,t){var r=this._formCollectionKey(e);return this._persister.write(r,t)}},{key:"_deleteAll",value:function(e){var t=this._getAppKey(),r=this._formCollectionKey(e);return r!==t+"."+f.activeUserKey?this._persister.delete(r):i.Promise.resolve()}},{key:"_enqueueCrudOperation",value:function(e,t){var r=this._formCollectionKey(e);return this._queue.enqueue(r,t)}},{key:"_keyBelongsToApp",value:function(e){var t=this._getAppKey();return 0===e.indexOf(t)}},{key:"_getCollectionFromKey",value:function(e){var t=this._getAppKey();return e.substring((t+".").length)}},{key:"_clearCollections",value:function(e){var t=this,r=(0,f.ensureArray)(e).map(function(e){return t._enqueueCrudOperation(e,function(){return t._deleteAll(e)})});return i.Promise.all(r).then(function(){return!0})}},{key:"_create",value:function(e,t){var r=this;return this._readAll(e).then(function(n){return n=n.concat(t),r._saveAll(e,n)})}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OfflineRepository=void 0;var n=function(){function e(e,t){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:{},n=this._buildRequestConfig(e,i.RequestMethod.GET,null,t,null,null,r);return this._makeHttpRequest(n,r.dataOnly)}},{key:"readById",value:function(e,t,r){var n=this._buildRequestConfig(e,i.RequestMethod.GET,null,null,t,null,r);return this._makeHttpRequest(n)}},{key:"create",value:function(e,t,r){return this._processBatch(e,i.RequestMethod.POST,t,r)}},{key:"update",value:function(e,t,r){return this._processBatch(e,i.RequestMethod.PUT,t,r)}},{key:"deleteById",value:function(e,t,r){var n=this._buildRequestConfig(e,i.RequestMethod.DELETE,null,null,t,null,r);return this._makeHttpRequest(n).then(function(e){return e.count})}},{key:"delete",value:function(e,t,r){var n=this._buildRequestConfig(e,i.RequestMethod.DELETE,null,t,null,null,r);return this._makeHttpRequest(n).then(function(e){return e.count})}},{key:"count",value:function(e,t,r){var n=this._buildRequestConfig(e,i.RequestMethod.GET,null,t,null,"_count",null,r);return this._makeHttpRequest(n,r.dataOnly).then(function(e){return!1===r.dataOnly?e:e.count})}},{key:"group",value:function(e,t,r){var n=this._buildRequestConfig(e,i.RequestMethod.POST,null,t,null,"_group",null,r);return this._makeHttpRequest(n)}},{key:"_processBatch",value:function(e,t,r,n){var u=this,s=!Array.isArray(r),c=(0,a.ensureArray)(r).map(function(r){var o=t===i.RequestMethod.PUT?r._id:null,s=u._buildRequestConfig(e,t,r,null,o,null,n);return u._makeHttpRequest(s)});return o.Promise.all(c).then(function(e){return s?e&&e[0]:e})}},{key:"_makeHttpRequest",value:function(e,t){return i.KinveyRequest.execute(e,null,t)}},{key:"_buildRequestConfig",value:function(e,t,r,n,o,i,s){s=s||{};var a={method:t,pathname:(0,c.buildCollectionUrl)(e,o,i),timeout:s.timeout,properties:s.properties,trace:s.trace,skipBL:s.skipBL,kinveyFileTTL:s.kinveyFileTTL,kinveyFileTLS:s.kinveyFileTLS};return r&&(a.body=r),n instanceof u.Aggregation?a.aggregation=n:a.query=n,a}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataProcessor=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:[];return t._processSyncItems(e,r)}).then(function(r){return t._markPushEnd(e),r}).catch(function(e){return t._markPushEnd(),i.Promise.reject(e)}))}},{key:"pull",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return i.Promise.resolve().then(function(){if(!(0,v.isNonemptyString)(e))throw new c.KinveyError("Invalid or missing collection name")}).then(function(){return n.useDeltaSet?(0,b.deltaSet)(e,t,n).then(function(r){return(0,g.getCachedQuery)(e,t).then(function(e){return e?(e.lastRequest=r.headers.requestStart,(0,g.updateCachedQuery)(e)):null}).then(function(){return r.data})}).then(function(t){if(t.deleted.length>0){var n=new y.Query;return n.contains("_id",t.deleted.map(function(e){return e._id})),r._deleteOfflineEntities(e,n).then(function(){return t})}return t}).then(function(t){return t.changed.length>0?r._getOfflineRepo().then(function(r){return r.update(e,t.changed)}).then(function(){return t.changed.length}):0}):n.autoPagination?r._paginatedPull(e,t,n):r._fetchItemsFromServer(e,t,n).then(function(r){return(0,g.getCachedQuery)(e,t).then(function(e){return e&&r.headers?(e.lastRequest=r.headers.requestStart,(0,g.updateCachedQuery)(e)):null}).then(function(){return r.data?r.data:r})}).then(function(n){return r._replaceOfflineEntities(e,t,n).then(function(e){return e.length})})}).catch(function(o){if(o instanceof c.InvalidCachedQuery)return(0,g.getCachedQuery)(e,t).then(function(e){return(0,g.deleteCachedQuery)(e)}).catch(function(e){if(e instanceof c.NotFoundError)return null;throw e}).then(function(){return r.pull(e,t,Object.assign(n,{useDeltaSet:!1}))});throw o})}},{key:"getSyncItemCount",value:function(e){return(0,v.isNonemptyString)(e)?this._syncStateManager.getSyncItemCount(e):i.Promise.reject(new c.KinveyError("Invalid or missing collection name"))}},{key:"getSyncItemCountByEntityQuery",value:function(e,t){var r=this;return t?this._getOfflineRepo().then(function(r){return r.read(e,t)}).then(function(t){var n=t.map(function(e){return e._id});return r._syncStateManager.getSyncItemCount(e,n)}):this._syncStateManager.getSyncItemCount(e)}},{key:"getSyncEntities",value:function(e,t){var r=this;return this._getOfflineRepo().then(function(r){return r.read(e,t)}).then(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return r._syncStateManager.getSyncItems(e,t.map(function(e){return e._id}))})}},{key:"clearSync",value:function(e,t){var r=this;return t?this._getEntityIdsForQuery(e,t).then(function(t){return r._syncStateManager.removeSyncItemsForIds(e,t)}):this._syncStateManager.removeAllSyncItems(e)}},{key:"addCreateEvent",value:function(e,t){return this._addEvent(e,t,f.SyncOperation.Create)}},{key:"addDeleteEvent",value:function(e,t){return this._addEvent(e,t,f.SyncOperation.Delete)}},{key:"addUpdateEvent",value:function(e,t){return this._addEvent(e,t,f.SyncOperation.Update)}},{key:"removeSyncItemForEntityId",value:function(e,t){return this._syncStateManager.removeSyncItemForEntityId(e,t)}},{key:"removeSyncItemsForIds",value:function(e,t){return this._syncStateManager.removeSyncItemsForIds(e,t)}},{key:"_deleteOfflineEntities",value:function(e,t){return this._getOfflineRepo().then(function(r){return r.delete(e,t)})}},{key:"_replaceOfflineEntities",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return t&&(t.hasSkip()||t.hasLimit())?this._getOfflineRepo().then(function(t){return t.update(e,n)}):this._deleteOfflineEntities(e,t).then(function(){return r._getOfflineRepo()}).then(function(t){return t.update(e,n)})}},{key:"_getPushOpResult",value:function(e,t){var r={_id:e,operation:t};return t!==f.SyncOperation.Delete&&(r.entity=null),r}},{key:"_sanitizeOfflineEntity",value:function(e){var t=(0,s.default)(e);return delete t._id,t._kmd&&delete t._kmd.local,t}},{key:"_replaceOfflineEntityWithNetwork",value:function(e,t,r){var n=void 0;return this._getOfflineRepo().then(function(r){return(n=r).deleteById(e,t)}).then(function(){return n.create(e,r)})}},{key:"_pushCreate",value:function(e,t){var r=this,n=t;t._kmd&&t._kmd.local&&(n=this._sanitizeOfflineEntity(t));var o=this._getPushOpResult(t._id,f.SyncOperation.Create);return this._networkRepo.create(e,n).then(function(n){return o.entity=n,r._replaceOfflineEntityWithNetwork(e,t._id,n)}).then(function(){return o}).catch(function(e){return o.error=e,o})}},{key:"_pushDelete",value:function(e,t){var r=this._getPushOpResult(t,f.SyncOperation.Delete);return this._networkRepo.deleteById(e,t).then(function(){return r}).catch(function(e){return r.error=e,r})}},{key:"_pushUpdate",value:function(e,t){var r=this,n=this._getPushOpResult(t._id,f.SyncOperation.Update);return this._networkRepo.update(e,t).then(function(e){return n.entity=e,r._getOfflineRepo()}).then(function(t){return t.update(e,n.entity)}).then(function(){return n}).catch(function(e){return n.entity=t,n.error=e,n})}},{key:"_handlePushOp",value:function(e,t,r){var n=t.state,o=t.entityId,i=n.operation;switch(i){case f.SyncOperation.Create:return this._pushCreate(e,r);case f.SyncOperation.Delete:return this._pushDelete(e,o);case f.SyncOperation.Update:return this._pushUpdate(e,r);default:var u=this._getPushOpResult(o,i);return u.error=new c.SyncError("Unexpected sync operation: "+i),u}}},{key:"_pushItem",value:function(e,t){var r=this,n=t.entityId,o=t.state;return this._getOfflineRepo().then(function(t){return t.readById(e,n)}).catch(function(t){return t instanceof c.NotFoundError?o.operation!==f.SyncOperation.Delete?r._syncStateManager.removeSyncItemForEntityId(e,n).then(function(){return i.Promise.reject(t)}):null:i.Promise.reject(t)}).then(function(n){return r._handlePushOp(e,t,n)})}},{key:"_processSyncItem",value:function(e,t){var r=this;return this._pushItem(e,t).then(function(e){return e.error?e:r._syncStateManager.removeSyncItemForEntityId(t.collection,t.entityId).then(function(){return e})}).catch(function(e){var n=r._getPushOpResult(t.entityId,t.state.operation);return n.error=e,n})}},{key:"_processSyncItems",value:function(e,t){var r=this,n=[];return(0,v.forEachAsync)(t,function(t){return r._processSyncItem(e,t).then(function(e){return n.push(e)})},w).then(function(){return n})}},{key:"_fetchItemsFromServer",value:function(e,t,r){return this._networkRepo.read(e,t,Object.assign(r,{dataOnly:!1}))}},{key:"_getOfflineRepo",value:function(){return this._offlineRepoPromise||(this._offlineRepoPromise=d.repositoryProvider.getOfflineRepository()),this._offlineRepoPromise}},{key:"_pushIsInProgress",value:function(e){return!!O[e]}},{key:"_markPushStart",value:function(e){this._pushIsInProgress(e)?a.Log.debug("Marking push start, when push already started"):O[e]=!0}},{key:"_markPushEnd",value:function(e){this._pushIsInProgress(e)?delete O[e]:a.Log.debug("Marking push end, when push is NOT started")}},{key:"_getEntityIdsForQuery",value:function(e,t){return this._getOfflineRepo().then(function(r){return r.read(e,t)}).then(function(e){return e.map(function(e){return e._id})})}},{key:"_addEvent",value:function(e,t,r){var n=this._validateCrudEventEntities(t);return n||this._setState(e,t,r).then(function(){return t})}},{key:"_validateCrudEventEntities",value:function(e){if(!e||(0,p.isEmpty)(e))return i.Promise.reject(new c.SyncError("Invalid or missing entity/entities array."));var t=(0,v.ensureArray)(e).find(function(e){return!e._id});if(t){return i.Promise.reject(new c.SyncError("An entity is missing an _id. All entities must have an _id in order to be added to the sync table.",t))}return null}},{key:"_setState",value:function(e,t,r){switch(r){case f.SyncOperation.Create:return this._syncStateManager.addCreateEvent(e,t);case f.SyncOperation.Update:return this._syncStateManager.addUpdateEvent(e,t);case f.SyncOperation.Delete:return this._syncStateManager.addDeleteEvent(e,t);default:return i.Promise.reject(new c.SyncError("Invalid sync event name"))}}},{key:"_getInternalPullQuery",value:function(e,t){var r,n,o,i=e=e||{},u=i.filter,s=i.sort,a=i.fields,c=new y.Query({filter:u,sort:s,fields:a});return c.limit=t,s&&!(0,p.isEmpty)(s)||(c.sort=(r={},n=h.defaultPullSortField,o=1,n in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,r)),c}},{key:"_fetchAndUpdateEntities",value:function(e,t,r){var n=this;return this._networkRepo.read(e,t,r).then(function(t){return n._getOfflineRepo().then(function(r){return r.update(e,t)})})}},{key:"_executePaginationQueries",value:function(e,t,r){var n=this,o=0;return(0,v.forEachAsync)(t,function(t){return n._fetchAndUpdateEntities(e,t,r).then(function(e){o+=e.length})},m).then(function(){return o})}},{key:"_getExpectedEntityCount",value:function(e,t){var r=new y.Query({filter:t.filter});return this._networkRepo.count(e,r,{dataOnly:!1}).then(function(e){return{lastRequest:e.headers?e.headers.requestStart:void 0,count:e.data?e.data.count:e}})}},{key:"_paginatedPull",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=void 0;return t=t||new y.Query,this._getExpectedEntityCount(e,t).then(function(i){var u=i.lastRequest,s=i.count;return o=r._getInternalPullQuery(t,s),r._deleteOfflineEntities(e).then(function(){var t=n.autoPagination&&n.autoPagination.pageSize||h.maxEntityLimit,i=(0,v.splitQueryIntoPages)(o,t,s);return r._executePaginationQueries(e,i,n)}).then(function(r){return(0,g.getCachedQuery)(e,t).then(function(e){return e?(e.lastRequest=u,(0,g.updateCachedQuery)(e)):null}).then(function(){return r})})})}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(195);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(460);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.platformName={nativeScript:"NativeScript",html5:"HTML5",nodeJs:"nodejs",phoneGap:"PhoneGap"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.SyncOperation={Create:"POST",Update:"PUT",Delete:"DELETE"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.syncCollectionName="kinvey_sync",t.maxEntityLimit=1e4,t.defaultPullSortField="_kmd.ect"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncStateManager=void 0;var n,o=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:[],r=this._getEntitiesFilter(e,t);return this._deleteSyncItems(e,r)}},{key:"removeAllSyncItems",value:function(e){var t=this._getCollectionFilter(e);return this._deleteSyncItems(e,t)}},{key:"_getRepository",value:function(){return this._repoPromise||(this._repoPromise=l.repositoryProvider.getOfflineRepository()),this._repoPromise}},{key:"_deleteSyncItems",value:function(e,t){var r=this;return this._getRepository().then(function(n){return n.delete(r._getSyncCollectionName(e),t)})}},{key:"_getSyncItemsByEntityIds",value:function(e){var t=(new a.Query).contains("entityId",e);return this._getRepository().then(function(e){return e.read(f.syncCollectionName,t)})}},{key:"_getUpdatedSyncItem",value:function(e,t){var r=(0,s.default)(e);return r._id=t._id,r}},{key:"_upsertSyncItems",value:function(e,t,r){var n=this;r||(r=t.map(function(e){return e.entityId}));var o=(new a.Query).contains("entityId",r);return this._getRepository().then(function(t){return t.delete(n._getSyncCollectionName(e),o).then(function(){return t})}).then(function(r){return r.create(n._getSyncCollectionName(e),t)})}},{key:"_getEntitiesFilter",value:function(e,t){var r=this._getCollectionFilter(e);return t&&r.and().contains("entityId",(0,h.ensureArray)(t)),r}},{key:"_getCollectionFilter",value:function(e){var t=new a.Query;return t.equalTo("collection",e),(0,p.collectionHasTag)(e)&&t.or().equalTo("collection",(0,p.stripTagFromCollectionName)(e)),t}},{key:"_buildSyncItem",value:function(e,t,r){return{_id:(0,p.generateEntityId)(),collection:e,entityId:r,state:{operation:t}}}},{key:"_buildSyncItemsForEntities",value:function(e,t,r){var n=this;return(0,h.ensureArray)(t).map(function(t){return n._buildSyncItem(e,r,t._id)})}},{key:"_groupSyncItemDataForDeleteEvent",value:function(e,t){var r=this,n=[],o=[],i=[];return(0,h.ensureArray)(t).forEach(function(t){if((0,p.isLocalEntity)(t))n.push(t._id);else{var u=r._buildSyncItem(e,c.SyncOperation.Delete,t._id);o.push(u),i.push(t._id)}}),{localEntityIds:n,syncItemsToUpsert:o,syncItemsToUpsertIds:i}}},{key:"_createSyncItems",value:function(e,t){var r=this;return this._getRepository().then(function(n){return n.create(r._getSyncCollectionName(e),t)})}},{key:"_getSyncCollectionName",value:function(e){var t=(0,p.getTagFromCollectionName)(e);return(0,p.formTaggedCollectionName)(f.syncCollectionName,t)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncStore=void 0;var n=r(95),o=r(52);t.SyncStore=function(e){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=r||o.processorFactory.getOfflineProcessor();return function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i,n))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,n.CacheStore),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=t.SocialIdentity={Kinvey:"kinvey",MobileIdentityConnect:"kinveyAuth"};Object.freeze(n)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Acl=void 0;var n=function(){function e(e,t){for(var r=0;r=t?t-1:r}var _=t.FileStore=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,[{key:"find",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={tls:!0===(r=(0,u.default)({tls:!0},r)).tls};return(0,a.default)(r.ttl)&&(n.ttl_in_seconds=parseInt(r.ttl,10)),h.KinveyObservable.create(function(o){return!(0,d.isDefined)(e)||e instanceof y.Query?new l.KinveyRequest({method:l.RequestMethod.GET,authType:l.AuthType.Default,url:c.default.format({protocol:t.client.apiProtocol,host:t.client.apiHost,pathname:t.pathname,query:n}),properties:r.properties,query:e,timeout:r.timeout,client:t.client}).execute().then(function(e){return e.data}).then(function(e){return o.next(e)}).then(function(){return o.complete()}).catch(function(e){return o.error(e)}):o.error(new f.KinveyError("Invalid query. It must be an instance of the Query class."))}).toPromise().then(function(e){return!0===r.download?o.default.all((0,i.default)(e,function(e){return t.downloadByUrl(e._downloadURL,r)})):e})}},{key:"findById",value:function(e,t){return this.download(e,t)}},{key:"download",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={tls:!0===(r=(0,u.default)({tls:!0},r)).tls};return(0,d.isDefined)(e)?((0,a.default)(r.ttl)&&(n.ttl_in_seconds=parseInt(r.ttl,10)),h.KinveyObservable.create(function(o){return!1===(0,d.isDefined)(e)?(o.next(void 0),o.complete()):new l.KinveyRequest({method:l.RequestMethod.GET,authType:l.AuthType.Default,url:c.default.format({protocol:t.client.apiProtocol,host:t.client.apiHost,pathname:t.pathname+"/"+e,query:n}),properties:r.properties,timeout:r.timeout,client:t.client}).execute().then(function(e){return e.data}).then(function(e){return o.next(e)}).then(function(){return o.complete()}).catch(function(e){return o.error(e)})}).toPromise().then(function(e){return!0===r.stream?e:(r.mimeType=e.mimeType,t.downloadByUrl(e._downloadURL,r))})):o.default.reject(new f.KinveyError("A valid id is required to find a file by id."))}},{key:"downloadByUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new l.NetworkRequest({method:l.RequestMethod.GET,url:e,timeout:t.timeout,file:!0}).execute().then(function(e){return e.data})}},{key:"stream",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.stream=!0,this.download(e,t)}},{key:"upload",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r=this.transformMetadata(e,r);var i=null;return this.saveFileMetadata(n,r).then(function(e){return i=e.data,t.makeStatusCheckRequest(e.data._uploadURL,e.data._requiredHeaders,r,n.timeout)}).then(function(u){if(p.Log.debug("File upload status check response",u),!u.isSuccess())return o.default.reject(u.error);if(200===u.statusCode||201===u.statusCode)return u;if(308!==u.statusCode){var s=new f.KinveyError("Unexpected response for upload file status check request.",!1,u.statusCode,u.headers.get("X-Kinvey-Request-ID"));return o.default.reject(s)}var a={start:g(u.headers.get("range"),r.size),timeout:n.timeout,maxBackoff:n.maxBackoff,headers:i._requiredHeaders};return t.retriableUpload(i._uploadURL,e,r,a)}).then(function(){return delete i._expiresAt,delete i._requiredHeaders,delete i._uploadURL,i._data=e,i})}},{key:"transformMetadata",value:function(e,t){var r=(0,u.default)({filename:e._filename||e.name,public:!1,size:e.size||e.length,mimeType:e.mimeType||e.type||"application/octet-stream"},t);return r._filename=t.filename,delete r.filename,r._public=t.public,delete r.public,r}},{key:"saveFileMetadata",value:function(e,t){if(t.size<=0)return o.default.reject(new f.KinveyError("Unable to create a file with a size of 0.",t));var r=(0,d.isDefined)(t._id);return new l.KinveyRequest({method:r?l.RequestMethod.PUT:l.RequestMethod.POST,authType:l.AuthType.Default,headers:{"X-Kinvey-Content-Type":t.mimeType},url:c.default.format({protocol:this.client.apiProtocol,host:this.client.apiHost,pathname:r?this.pathname+"/"+t._id:this.pathname}),properties:e.properties,timeout:e.timeout,body:t,client:this.client}).execute()}},{key:"makeStatusCheckRequest",value:function(e,t,r,n){var o=new l.Headers(t);return o.set("content-type",r.mimeType),o.set("content-range","bytes */"+r.size),new l.NetworkRequest({method:l.RequestMethod.PUT,url:e,timeout:n,headers:o}).execute()}},{key:"retriableUpload",value:function(e,t,r,n){var i=this;return n=(0,u.default)({count:0,start:0,maxBackoff:32e3},n),p.Log.debug("Start file upload"),p.Log.debug("File upload headers",n.headers),p.Log.debug("File upload upload url",c.default),p.Log.debug("File upload file",t),p.Log.debug("File upload metadata",r),p.Log.debug("File upload options",n),this.makeUploadRequest(e,t,r,n).then(function(e){if(p.Log.debug("File upload response",e),e.isClientError())return o.default.reject(e.error);if(!e.isSuccess()&&!e.isServerError()&&308!==e.statusCode){var t=new f.KinveyError("Unexpected response for upload file request.",!1,e.statusCode,e.headers.get("X-Kinvey-Request-ID"));return o.default.reject(t)}return e}).then(function(e){var t,i,u=0;return e.isServerError()?(p.Log.debug("File upload server error. Probably network congestion.",e.statusCode,e.data),(u=Math.pow(2,n.count)+(t=1,i=1001,Math.floor(Math.random()*(i-t))+t))>=n.maxBackoff?o.default.reject(e.error):(p.Log.debug("File upload will try again in "+u+" seconds."),new o.default(function(e){setTimeout(function(){n.count+=1,e(!0)},u)}))):308===e.statusCode?(p.Log.debug("File upload was incomplete (statusCode 308). Trying to upload the remainder of file."),n.start=g(e.headers.get("range"),r.size),new o.default(function(e){setTimeout(function(){n.count=0,e(!0)},u)})):new o.default(function(e){setTimeout(function(){e(!1)},u)})}).then(function(o){return o?i.retriableUpload(e,t,r,n):null})}},{key:"makeUploadRequest",value:function(e,t,r,n){var o=new l.Headers(n.headers);return o.set("content-type",r.mimeType),o.set("content-range","bytes "+n.start+"-"+(r.size-1)+"/"+r.size),new l.NetworkRequest({method:l.RequestMethod.PUT,url:e,headers:o,body:(0,s.default)(t.slice)?t.slice(n.start):t,timeout:n.timeout}).execute()}},{key:"create",value:function(e,t,r){return this.upload(e,t,r)}},{key:"update",value:function(e,t,r){return this.upload(e,t,r)}},{key:"removeById",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h.KinveyObservable.create(function(n){try{return!1===(0,d.isDefined)(e)?(n.next(void 0),n.complete()):new l.KinveyRequest({method:l.RequestMethod.DELETE,authType:l.AuthType.Default,url:c.default.format({protocol:t.client.apiProtocol,host:t.client.apiHost,pathname:t.pathname+"/"+e}),properties:r.properties,timeout:r.timeout}).execute().then(function(e){return e.data}).then(function(e){return n.next(e)}).then(function(){return n.complete()}).catch(function(e){return n.error(e)})}catch(e){return n.error(e)}}).toPromise()}},{key:"remove",value:function(){throw new f.KinveyError("Please use removeById() to remove files one by one.")}},{key:"client",get:function(){return(0,d.isDefined)(this._clientInstance)||(this._clientInstance=v.Client.sharedInstance()),this._clientInstance}},{key:"pathname",get:function(){return"/blob/"+this.client.appKey}}]),e}();t.Files=new _},function(e,t,r){var n=r(205);e.exports=function(e){return Object(n(e))}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t){var r={}.hasOwnProperty;e.exports=function(e,t){return r.call(e,t)}},function(e,t,r){var n=r(208),o=r(205);e.exports=function(e){return n(o(e))}},function(e,t,r){var n=r(209);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==n(e)?e.split(""):Object(e)}},function(e,t){var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t,r){var n=r(211),o=Math.min;e.exports=function(e){return e>0?o(n(e),9007199254740991):0}},function(e,t){var r=Math.ceil,n=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?n:r)(e)}},function(e,t,r){var n=r(54),o=n["__core-js_shared__"]||(n["__core-js_shared__"]={});e.exports=function(e){return o[e]||(o[e]={})}},function(e,t,r){var n=r(495);e.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,o){return e.call(t,r,n,o)}}return function(){return e.apply(t,arguments)}}},function(e,t,r){var n=r(213),o=r(208),i=r(204),u=r(210),s=r(498);e.exports=function(e,t){var r=1==e,a=2==e,c=3==e,l=4==e,f=6==e,h=5==e||f,p=t||s;return function(t,s,d){for(var y,v,b=i(t),g=o(b),_=n(s,d,3),m=u(g.length),w=0,O=r?p(t,m):a?p(t,0):void 0;m>w;w++)if((h||w in g)&&(v=_(y=g[w],w,b),e))if(r)O[w]=v;else if(v)switch(e){case 3:return!0;case 5:return y;case 6:return w;case 2:O.push(y)}else if(l)return!1;return f?-1:c||l?l:O}}},function(e,t,r){var n=r(212)("wks"),o=r(118),i=r(54).Symbol,u="function"==typeof i;(e.exports=function(e){return n[e]||(n[e]=u&&i[e]||(u?i:o)("Symbol."+e))}).store=n},function(e,t,r){var n=r(215)("unscopables"),o=Array.prototype;void 0==o[n]&&r(120)(o,n,{}),e.exports=function(e){o[n][e]=!0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Html5Client=void 0;var n,o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cookieOptions=Object.assign({path:"/"},t),s=t.prefix||s}return n(e,[{key:"getItem",value:function(e){var t=u.default.parse(document.cookie);return t&&t.hasOwnProperty(s+e)?t[s+e]:null}},{key:"setItem",value:function(e,t){return document.cookie=u.default.serialize(s+e,t,this.cookieOptions),t}},{key:"removeItem",value:function(e){var t=Object.assign({},this.cookieOptions,{maxAge:-1});return document.cookie=u.default.serialize(s+e,"",t),null}},{key:"clear",value:function(){var e=u.default.parse(document.cookie);for(var t in e)0===t.indexOf(s)&&this.removeItem(t.substr(s.length));return null}}]),e}();t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Kinvey=void 0;var n=r(220);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(n);t.Kinvey=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritesToCollectionDisallowedError=t.UserAlreadyExistsError=t.TimeoutError=t.SyncError=t.StaleRequestError=t.ServerError=t.QueryError=t.PopupError=t.ParameterValueOutOfRangeError=t.NotFoundError=t.NoResponseError=t.NetworkConnectionError=t.NoActiveUserError=t.MobileIdentityConnectError=t.MissingRequestParameterError=t.MissingRequestHeaderError=t.MissingQueryError=t.KinveyInternalErrorStop=t.KinveyInternalErrorRetry=t.KinveyError=t.JSONParseError=t.InvalidQuerySyntaxError=t.InvalidIdentifierError=t.InvalidCredentialsError=t.InsufficientCredentialsError=t.IndirectCollectionAccessDisallowedError=t.IncompleteRequestBodyError=t.FeatureUnavailableError=t.DuplicateEndUsersError=t.CORSDisabledError=t.BLError=t.BadRequestError=t.AppProblemError=t.APIVersionNotImplementedError=t.APIVersionNotAvailableError=t.ActiveUserError=t.User=t.Query=t.Metadata=t.Log=t.LiveService=t.SyncOperation=t.DataStoreType=t.DataStore=t.CustomEndpoint=t.AuthorizationGrant=t.Aggregation=t.Acl=t.ping=t.setAppVersion=t.getAppVersion=t.client=void 0;var n=r(221);Object.defineProperty(t,"client",{enumerable:!0,get:function(){return n.client}}),Object.defineProperty(t,"getAppVersion",{enumerable:!0,get:function(){return n.getAppVersion}}),Object.defineProperty(t,"setAppVersion",{enumerable:!0,get:function(){return n.setAppVersion}}),Object.defineProperty(t,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(t,"Acl",{enumerable:!0,get:function(){return n.Acl}}),Object.defineProperty(t,"Aggregation",{enumerable:!0,get:function(){return n.Aggregation}}),Object.defineProperty(t,"AuthorizationGrant",{enumerable:!0,get:function(){return n.AuthorizationGrant}}),Object.defineProperty(t,"CustomEndpoint",{enumerable:!0,get:function(){return n.CustomEndpoint}}),Object.defineProperty(t,"DataStore",{enumerable:!0,get:function(){return n.DataStore}}),Object.defineProperty(t,"DataStoreType",{enumerable:!0,get:function(){return n.DataStoreType}}),Object.defineProperty(t,"SyncOperation",{enumerable:!0,get:function(){return n.SyncOperation}}),Object.defineProperty(t,"LiveService",{enumerable:!0,get:function(){return n.LiveService}}),Object.defineProperty(t,"Log",{enumerable:!0,get:function(){return n.Log}}),Object.defineProperty(t,"Metadata",{enumerable:!0,get:function(){return n.Metadata}}),Object.defineProperty(t,"Query",{enumerable:!0,get:function(){return n.Query}}),Object.defineProperty(t,"User",{enumerable:!0,get:function(){return n.User}}),Object.defineProperty(t,"ActiveUserError",{enumerable:!0,get:function(){return n.ActiveUserError}}),Object.defineProperty(t,"APIVersionNotAvailableError",{enumerable:!0,get:function(){return n.APIVersionNotAvailableError}}),Object.defineProperty(t,"APIVersionNotImplementedError",{enumerable:!0,get:function(){return n.APIVersionNotImplementedError}}),Object.defineProperty(t,"AppProblemError",{enumerable:!0,get:function(){return n.AppProblemError}}),Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return n.BadRequestError}}),Object.defineProperty(t,"BLError",{enumerable:!0,get:function(){return n.BLError}}),Object.defineProperty(t,"CORSDisabledError",{enumerable:!0,get:function(){return n.CORSDisabledError}}),Object.defineProperty(t,"DuplicateEndUsersError",{enumerable:!0,get:function(){return n.DuplicateEndUsersError}}),Object.defineProperty(t,"FeatureUnavailableError",{enumerable:!0,get:function(){return n.FeatureUnavailableError}}),Object.defineProperty(t,"IncompleteRequestBodyError",{enumerable:!0,get:function(){return n.IncompleteRequestBodyError}}),Object.defineProperty(t,"IndirectCollectionAccessDisallowedError",{enumerable:!0,get:function(){return n.IndirectCollectionAccessDisallowedError}}),Object.defineProperty(t,"InsufficientCredentialsError",{enumerable:!0,get:function(){return n.InsufficientCredentialsError}}),Object.defineProperty(t,"InvalidCredentialsError",{enumerable:!0,get:function(){return n.InvalidCredentialsError}}),Object.defineProperty(t,"InvalidIdentifierError",{enumerable:!0,get:function(){return n.InvalidIdentifierError}}),Object.defineProperty(t,"InvalidQuerySyntaxError",{enumerable:!0,get:function(){return n.InvalidQuerySyntaxError}}),Object.defineProperty(t,"JSONParseError",{enumerable:!0,get:function(){return n.JSONParseError}}),Object.defineProperty(t,"KinveyError",{enumerable:!0,get:function(){return n.KinveyError}}),Object.defineProperty(t,"KinveyInternalErrorRetry",{enumerable:!0,get:function(){return n.KinveyInternalErrorRetry}}),Object.defineProperty(t,"KinveyInternalErrorStop",{enumerable:!0,get:function(){return n.KinveyInternalErrorStop}}),Object.defineProperty(t,"MissingQueryError",{enumerable:!0,get:function(){return n.MissingQueryError}}),Object.defineProperty(t,"MissingRequestHeaderError",{enumerable:!0,get:function(){return n.MissingRequestHeaderError}}),Object.defineProperty(t,"MissingRequestParameterError",{enumerable:!0,get:function(){return n.MissingRequestParameterError}}),Object.defineProperty(t,"MobileIdentityConnectError",{enumerable:!0,get:function(){return n.MobileIdentityConnectError}}),Object.defineProperty(t,"NoActiveUserError",{enumerable:!0,get:function(){return n.NoActiveUserError}}),Object.defineProperty(t,"NetworkConnectionError",{enumerable:!0,get:function(){return n.NetworkConnectionError}}),Object.defineProperty(t,"NoResponseError",{enumerable:!0,get:function(){return n.NoResponseError}}),Object.defineProperty(t,"NotFoundError",{enumerable:!0,get:function(){return n.NotFoundError}}),Object.defineProperty(t,"ParameterValueOutOfRangeError",{enumerable:!0,get:function(){return n.ParameterValueOutOfRangeError}}),Object.defineProperty(t,"PopupError",{enumerable:!0,get:function(){return n.PopupError}}),Object.defineProperty(t,"QueryError",{enumerable:!0,get:function(){return n.QueryError}}),Object.defineProperty(t,"ServerError",{enumerable:!0,get:function(){return n.ServerError}}),Object.defineProperty(t,"StaleRequestError",{enumerable:!0,get:function(){return n.StaleRequestError}}),Object.defineProperty(t,"SyncError",{enumerable:!0,get:function(){return n.SyncError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return n.TimeoutError}}),Object.defineProperty(t,"UserAlreadyExistsError",{enumerable:!0,get:function(){return n.UserAlreadyExistsError}}),Object.defineProperty(t,"WritesToCollectionDisallowedError",{enumerable:!0,get:function(){return n.WritesToCollectionDisallowedError}});var o=r(503);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i,u=r(10),s=r(519),a=r(117),c=r(528),l=r(529),f=(i=l)&&i.__esModule?i:{default:i},h=r(194);(0,h.setPlatformConfig)(h.platformName.html5),u.NetworkRack.useHttpMiddleware(new s.Html5HttpMiddleware(f.default)),a.MobileIdentityConnect.usePopupClass(c.Popup)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritesToCollectionDisallowedError=t.UserAlreadyExistsError=t.TimeoutError=t.SyncError=t.StaleRequestError=t.ServerError=t.QueryError=t.PopupError=t.ParameterValueOutOfRangeError=t.NotFoundError=t.NoResponseError=t.NetworkConnectionError=t.NoActiveUserError=t.MobileIdentityConnectError=t.MissingRequestParameterError=t.MissingRequestHeaderError=t.MissingQueryError=t.KinveyInternalErrorStop=t.KinveyInternalErrorRetry=t.KinveyError=t.JSONParseError=t.InvalidQuerySyntaxError=t.InvalidIdentifierError=t.InvalidCredentialsError=t.InsufficientCredentialsError=t.IndirectCollectionAccessDisallowedError=t.IncompleteRequestBodyError=t.FeatureUnavailableError=t.DuplicateEndUsersError=t.CORSDisabledError=t.BLError=t.BadRequestError=t.AppProblemError=t.APIVersionNotImplementedError=t.APIVersionNotAvailableError=t.ActiveUserError=t.User=t.KinveyRequest=t.AuthType=t.RequestMethod=t.Properties=t.Query=t.Metadata=t.Log=t.Files=t.LiveService=t.SyncOperation=t.DataStoreType=t.DataStore=t.CustomEndpoint=t.Client=t.AuthorizationGrant=t.Aggregation=t.Acl=t.ping=t.initialize=t.init=t.setAppVersion=t.getAppVersion=t.client=t.DataAccess=void 0;var n=r(222);Object.defineProperty(t,"client",{enumerable:!0,get:function(){return n.client}}),Object.defineProperty(t,"getAppVersion",{enumerable:!0,get:function(){return n.getAppVersion}}),Object.defineProperty(t,"setAppVersion",{enumerable:!0,get:function(){return n.setAppVersion}}),Object.defineProperty(t,"init",{enumerable:!0,get:function(){return n.init}}),Object.defineProperty(t,"initialize",{enumerable:!0,get:function(){return n.initialize}}),Object.defineProperty(t,"ping",{enumerable:!0,get:function(){return n.ping}});var o=r(201);Object.defineProperty(t,"Acl",{enumerable:!0,get:function(){return o.Acl}});var i=r(67);Object.defineProperty(t,"Aggregation",{enumerable:!0,get:function(){return i.Aggregation}});var u=r(117);Object.defineProperty(t,"AuthorizationGrant",{enumerable:!0,get:function(){return u.AuthorizationGrant}});var s=r(7);Object.defineProperty(t,"Client",{enumerable:!0,get:function(){return s.Client}});var a=r(473);Object.defineProperty(t,"CustomEndpoint",{enumerable:!0,get:function(){return a.CustomEndpoint}});var c=r(22);Object.defineProperty(t,"DataStore",{enumerable:!0,get:function(){return c.DataStore}}),Object.defineProperty(t,"DataStoreType",{enumerable:!0,get:function(){return c.DataStoreType}}),Object.defineProperty(t,"SyncOperation",{enumerable:!0,get:function(){return c.SyncOperation}});var l=r(73);Object.defineProperty(t,"LiveService",{enumerable:!0,get:function(){return l.LiveServiceFacade}});var f=r(203);Object.defineProperty(t,"Files",{enumerable:!0,get:function(){return f.Files}});var h=r(19);Object.defineProperty(t,"Log",{enumerable:!0,get:function(){return h.Log}});var p=r(202);Object.defineProperty(t,"Metadata",{enumerable:!0,get:function(){return p.Metadata}});var d=r(16);Object.defineProperty(t,"Query",{enumerable:!0,get:function(){return d.Query}});var y=r(10);Object.defineProperty(t,"Properties",{enumerable:!0,get:function(){return y.Properties}}),Object.defineProperty(t,"RequestMethod",{enumerable:!0,get:function(){return y.RequestMethod}});var v=r(172);Object.defineProperty(t,"AuthType",{enumerable:!0,get:function(){return v.AuthType}}),Object.defineProperty(t,"KinveyRequest",{enumerable:!0,get:function(){return v.KinveyRequest}});var b=r(116);Object.defineProperty(t,"User",{enumerable:!0,get:function(){return b.User}});var g=r(1);Object.defineProperty(t,"ActiveUserError",{enumerable:!0,get:function(){return g.ActiveUserError}}),Object.defineProperty(t,"APIVersionNotAvailableError",{enumerable:!0,get:function(){return g.APIVersionNotAvailableError}}),Object.defineProperty(t,"APIVersionNotImplementedError",{enumerable:!0,get:function(){return g.APIVersionNotImplementedError}}),Object.defineProperty(t,"AppProblemError",{enumerable:!0,get:function(){return g.AppProblemError}}),Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return g.BadRequestError}}),Object.defineProperty(t,"BLError",{enumerable:!0,get:function(){return g.BLError}}),Object.defineProperty(t,"CORSDisabledError",{enumerable:!0,get:function(){return g.CORSDisabledError}}),Object.defineProperty(t,"DuplicateEndUsersError",{enumerable:!0,get:function(){return g.DuplicateEndUsersError}}),Object.defineProperty(t,"FeatureUnavailableError",{enumerable:!0,get:function(){return g.FeatureUnavailableError}}),Object.defineProperty(t,"IncompleteRequestBodyError",{enumerable:!0,get:function(){return g.IncompleteRequestBodyError}}),Object.defineProperty(t,"IndirectCollectionAccessDisallowedError",{enumerable:!0,get:function(){return g.IndirectCollectionAccessDisallowedError}}),Object.defineProperty(t,"InsufficientCredentialsError",{enumerable:!0,get:function(){return g.InsufficientCredentialsError}}),Object.defineProperty(t,"InvalidCredentialsError",{enumerable:!0,get:function(){return g.InvalidCredentialsError}}),Object.defineProperty(t,"InvalidIdentifierError",{enumerable:!0,get:function(){return g.InvalidIdentifierError}}),Object.defineProperty(t,"InvalidQuerySyntaxError",{enumerable:!0,get:function(){return g.InvalidQuerySyntaxError}}),Object.defineProperty(t,"JSONParseError",{enumerable:!0,get:function(){return g.JSONParseError}}),Object.defineProperty(t,"KinveyError",{enumerable:!0,get:function(){return g.KinveyError}}),Object.defineProperty(t,"KinveyInternalErrorRetry",{enumerable:!0,get:function(){return g.KinveyInternalErrorRetry}}),Object.defineProperty(t,"KinveyInternalErrorStop",{enumerable:!0,get:function(){return g.KinveyInternalErrorStop}}),Object.defineProperty(t,"MissingQueryError",{enumerable:!0,get:function(){return g.MissingQueryError}}),Object.defineProperty(t,"MissingRequestHeaderError",{enumerable:!0,get:function(){return g.MissingRequestHeaderError}}),Object.defineProperty(t,"MissingRequestParameterError",{enumerable:!0,get:function(){return g.MissingRequestParameterError}}),Object.defineProperty(t,"MobileIdentityConnectError",{enumerable:!0,get:function(){return g.MobileIdentityConnectError}}),Object.defineProperty(t,"NoActiveUserError",{enumerable:!0,get:function(){return g.NoActiveUserError}}),Object.defineProperty(t,"NetworkConnectionError",{enumerable:!0,get:function(){return g.NetworkConnectionError}}),Object.defineProperty(t,"NoResponseError",{enumerable:!0,get:function(){return g.NoResponseError}}),Object.defineProperty(t,"NotFoundError",{enumerable:!0,get:function(){return g.NotFoundError}}),Object.defineProperty(t,"ParameterValueOutOfRangeError",{enumerable:!0,get:function(){return g.ParameterValueOutOfRangeError}}),Object.defineProperty(t,"PopupError",{enumerable:!0,get:function(){return g.PopupError}}),Object.defineProperty(t,"QueryError",{enumerable:!0,get:function(){return g.QueryError}}),Object.defineProperty(t,"ServerError",{enumerable:!0,get:function(){return g.ServerError}}),Object.defineProperty(t,"StaleRequestError",{enumerable:!0,get:function(){return g.StaleRequestError}}),Object.defineProperty(t,"SyncError",{enumerable:!0,get:function(){return g.SyncError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return g.TimeoutError}}),Object.defineProperty(t,"UserAlreadyExistsError",{enumerable:!0,get:function(){return g.UserAlreadyExistsError}}),Object.defineProperty(t,"WritesToCollectionDisallowedError",{enumerable:!0,get:function(){return g.WritesToCollectionDisallowedError}}),r(476);t.DataAccess={Repository:c.Repository,NetworkRepository:c.NetworkRepository,OfflineRepository:c.OfflineRepository,InmemoryOfflineRepository:c.InmemoryOfflineRepository,KeyValueStoreOfflineRepository:c.KeyValueStoreOfflineRepository,KeyValuePersister:c.KeyValuePersister,KeyValueStorePersister:c.KeyValueStorePersister,MemoryKeyValuePersister:c.MemoryKeyValuePersister,BrowserKeyValuePersister:c.BrowserKeyValuePersister,SqlKeyValueStorePersister:c.SqlKeyValueStorePersister,IndexedDbKeyValueStorePersister:c.IndexedDbKeyValueStorePersister,repositoryProvider:c.repositoryProvider}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.client=void 0,t.getAppVersion=function(){var e=f();if(e)return e.appVersion;return},t.setAppVersion=function(e){var t=f();t&&(t.appVersion=e)},t.init=h,t.initialize=function(e){try{var t=h(e);return i.default.resolve(c.User.getActiveUser(t))}catch(e){return i.default.reject(e)}},t.ping=function(){var e=f();return new l.KinveyRequest({method:l.RequestMethod.GET,authType:l.AuthType.All,url:e.apiHostname+"/appdata/"+e.appKey}).execute().then(function(e){return e.data})};var n,o=r(2),i=(n=o)&&n.__esModule?n:{default:n},u=r(1),s=r(3),a=r(7),c=r(116),l=r(10);function f(){return a.Client.sharedInstance()}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!1===(0,s.isDefined)(e.appKey))throw new u.KinveyError("No App Key was provided. Unable to create a new Client without an App Key.");if(!1===(0,s.isDefined)(e.appSecret)&&!1===(0,s.isDefined)(e.masterSecret))throw new u.KinveyError("No App Secret or Master Secret was provided. Unable to create a new Client without an App Secret.");return a.Client.init(e)}t.client=f},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:u}catch(e){n=u}}();var a,c=[],l=!1,f=-1;function h(){l&&a&&(l=!1,a.length?c=a.concat(c):f=-1,c.length&&p())}function p(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(a=c,c=[];++f1)for(var r=1;r1)this.connection=null;else{var r=this.connection,n=e._connection;this.connection=null,!n||r&&n!==r||n.unsubscribe()}}else this.connection=null},t}(o.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return c});var n=r(4),o=r(13),i=r(8),u=r(5),s=r(32);o.a;var a=function(e){function t(t,r,n){var o=e.call(this,r)||this;return o.key=t,o.group=r,o.parent=n,o}return n.a(t,e),t.prototype._next=function(e){this.complete()},t.prototype._unsubscribe=function(){var e=this.parent,t=this.key;this.key=this.parent=null,e&&e.removeGroup(t)},t}(o.a),c=function(e){function t(t,r,n){var o=e.call(this)||this;return o.key=t,o.groupSubject=r,o.refCountSubscription=n,o}return n.a(t,e),t.prototype._subscribe=function(e){var t=new i.a,r=this.refCountSubscription,n=this.groupSubject;return r&&!r.closed&&t.add(new l(r)),t.add(n.subscribe(e)),t},t}(u.a),l=function(e){function t(t){var r=e.call(this)||this;return r.parent=t,t.count++,r}return n.a(t,e),t.prototype.unsubscribe=function(){var t=this.parent;t.closed||this.closed||(e.prototype.unsubscribe.call(this),t.count-=1,0===t.count&&t.attemptedToUnsubscribe&&t.unsubscribe())},t}(i.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return u});var n=r(4),o=r(32),i=r(57),u=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return n.a(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return r&&!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new i.a;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(o.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return l});var n=r(4),o=r(32),i=r(133),u=r(8),s=r(276),a=r(57),c=r(132),l=function(e){function t(t,r,n){void 0===t&&(t=Number.POSITIVE_INFINITY),void 0===r&&(r=Number.POSITIVE_INFINITY);var o=e.call(this)||this;return o.scheduler=n,o._events=[],o._infiniteTimeWindow=!1,o._bufferSize=t<1?1:t,o._windowTime=r<1?1:r,r===Number.POSITIVE_INFINITY?(o._infiniteTimeWindow=!0,o.next=o.nextInfiniteTimeWindow):o.next=o.nextTimeWindow,o}return n.a(t,e),t.prototype.nextInfiniteTimeWindow=function(t){var r=this._events;r.push(t),r.length>this._bufferSize&&r.shift(),e.prototype.next.call(this,t)},t.prototype.nextTimeWindow=function(t){this._events.push(new f(this._getNow(),t)),this._trimBufferThenGetEvents(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){var t,r=this._infiniteTimeWindow,n=r?this._events:this._trimBufferThenGetEvents(),o=this.scheduler,i=n.length;if(this.closed)throw new a.a;if(this.isStopped||this.hasError?t=u.a.EMPTY:(this.observers.push(e),t=new c.a(this,e)),o&&e.add(e=new s.a(e,o)),r)for(var l=0;lt&&(i=Math.max(i,o-t)),i>0&&n.splice(0,i),n},t}(o.a),f=function(){return function(e,t){this.time=e,this.value=t}}()},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n}return n.a(t,e),t.prototype.schedule=function(t,r){return void 0===r&&(r=0),r>0?e.prototype.schedule.call(this,t,r):(this.delay=r,this.state=t,this.scheduler.flush(this),this)},t.prototype.execute=function(t,r){return r>0||this.closed?e.prototype.execute.call(this,t,r):this._execute(t,r)},t.prototype.requestAsyncId=function(t,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?e.prototype.requestAsyncId.call(this,t,r,n):t.flush(this)},t}(r(41).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(t,r){return e.call(this)||this}return n.a(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(r(8).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.a(t,e),t}(r(42).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return u});var n=r(4),o=r(13),i=r(135);var u=function(e){function t(t,r,n){void 0===n&&(n=0);var o=e.call(this,t)||this;return o.scheduler=r,o.delay=n,o}return n.a(t,e),t.dispatch=function(e){var t=e.notification,r=e.destination;t.observe(r),this.unsubscribe()},t.prototype.scheduleMessage=function(e){this.add(this.scheduler.schedule(t.dispatch,this.delay,new s(e,this.destination)))},t.prototype._next=function(e){this.scheduleMessage(i.a.createNext(e))},t.prototype._error=function(e){this.scheduleMessage(i.a.createError(e))},t.prototype._complete=function(){this.scheduleMessage(i.a.createComplete())},t}(o.a),s=function(){return function(e,t){this.notification=e,this.destination=t}}()},function(e,t,r){"use strict";t.a=function(e){var t=new n.a(function(t){t.next(e),t.complete()});return t._isScalar=!0,t.value=e,t};var n=r(5)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(279),o=new(r(281).a)(n.a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=r(4),o=r(280),i=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n}return n.a(t,e),t.prototype.requestAsyncId=function(t,r,n){return void 0===n&&(n=0),null!==n&&n>0?e.prototype.requestAsyncId.call(this,t,r,n):(t.actions.push(this),t.scheduled||(t.scheduled=o.a.setImmediate(t.flush.bind(t,null))))},t.prototype.recycleAsyncId=function(t,r,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,r,n);0===t.actions.length&&(o.a.clearImmediate(r),t.scheduled=void 0)},t}(r(41).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return i});var n=1,o={};var i={setImmediate:function(e){var t=n++;return o[t]=e,Promise.resolve().then(function(){return function(e){var t=o[e];t&&t()}(t)}),t},clearImmediate:function(e){delete o[e]}}},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.a(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,r=this.actions,n=-1,o=r.length;e=e||r.shift();do{if(t=e.execute(e.state,e.delay))break}while(++n0?e.prototype.requestAsyncId.call(this,t,r,n):(t.actions.push(this),t.scheduled||(t.scheduled=requestAnimationFrame(function(){return t.flush(null)})))},t.prototype.recycleAsyncId=function(t,r,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return e.prototype.recycleAsyncId.call(this,t,r,n);0===t.actions.length&&(cancelAnimationFrame(r),t.scheduled=void 0)},t}(r(41).a)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n.a(t,e),t.prototype.flush=function(e){this.active=!0,this.scheduled=void 0;var t,r=this.actions,n=-1,o=r.length;e=e||r.shift();do{if(t=e.execute(e.state,e.delay))break}while(++nt.index?1:-1:e.delay>t.delay?1:-1},t}(o.a)},function(e,t,r){"use strict";t.a=function(e){return!!e&&(e instanceof n.a||"function"==typeof e.lift&&"function"==typeof e.subscribe)};var n=r(5)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){var r=e.call(this,"argument out of range")||this;return r.name="ArgumentOutOfRangeError",Object.setPrototypeOf(r,t.prototype),r}return n.a(t,e),t}(Error)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){var r=e.call(this,"no elements in sequence")||this;return r.name="EmptyError",Object.setPrototypeOf(r,t.prototype),r}return n.a(t,e),t}(Error)},function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(4),o=function(e){function t(){var r=e.call(this,"Timeout has occurred")||this;return r.name="TimeoutError",Object.setPrototypeOf(r,t.prototype),r}return n.a(t,e),t}(Error)},function(e,t,r){"use strict";t.a=function e(t,r,c){if(r){if(!Object(s.a)(r))return function(){for(var n=[],o=0;o0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},t}(i.a)},function(e,t,r){"use strict";t.a=function e(){var t=[];for(var r=0;r1?e.next(Array.prototype.slice.call(arguments)):e.next(t)},e,s)})};var n=r(5),o=r(14),i=r(55),u=r(34);Object.prototype.toString},function(e,t,r){"use strict";t.a=function e(t,r,s){if(s)return e(t,r).pipe(Object(u.a)(function(e){return Object(o.a)(e)?s.apply(void 0,e):s(e)}));return new n.a(function(e){var n,o=function(){for(var t=[],r=0;r1&&"number"==typeof e[e.length-1]&&(r=e.pop())):"number"==typeof a&&(r=e.pop());if(null===s&&1===e.length&&e[0]instanceof n.a)return e[0];return Object(i.a)(r)(Object(u.a)(e,s))};var n=r(5),o=r(25),i=r(144),u=r(33)},function(e,t,r){"use strict";t.a=function e(){var t=[];for(var r=0;r=t){n.complete();break}if(n.next(u++),n.closed)break}})};var n=r(5);function o(e){var t=e.start,r=e.index,n=e.count,o=e.subscriber;r>=n?o.complete():(o.next(t),o.closed||(e.index=r+1,e.start=t+1,this.schedule(e)))}},function(e,t,r){"use strict";t.a=function(e,t,r){void 0===e&&(e=0);var a=-1;Object(i.a)(t)?a=Number(t)<1?1:Number(t):Object(u.a)(t)&&(r=t);Object(u.a)(r)||(r=o.a);return new n.a(function(t){var n=Object(i.a)(e)?e:+e-r.now();return r.schedule(s,n,{index:0,period:a,subscriber:t})})};var n=r(5),o=r(88),i=r(146),u=r(25);function s(e){var t=e.index,r=e.period,n=e.subscriber;if(n.next(t),!n.closed){if(-1===r)return n.complete();e.index=t+1,this.schedule(e,r)}}},function(e,t,r){"use strict";t.a=function(e,t){return new n.a(function(r){var n,u;try{n=e()}catch(e){return void r.error(e)}try{u=t(n)}catch(e){return void r.error(e)}var s=u?Object(o.a)(u):i.a,a=s.subscribe(r);return function(){a.unsubscribe(),n&&n.unsubscribe()}})};var n=r(5),o=r(35),i=r(21)},function(e,t,r){"use strict";t.a=function(){for(var e=[],t=0;tthis.index},e.prototype.hasCompleted=function(){return this.array.length===this.index},e}(),d=function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.parent=r,o.observable=n,o.stillUnsubscribed=!0,o.buffer=[],o.isComplete=!1,o}return n.a(t,e),t.prototype[c.a]=function(){return this},t.prototype.next=function(){var e=this.buffer;return 0===e.length&&this.isComplete?{value:null,done:!0}:{value:e.shift(),done:!1}},t.prototype.hasValue=function(){return this.buffer.length>0},t.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},t.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},t.prototype.notifyNext=function(e,t,r,n,o){this.buffer.push(t),this.parent.checkIterators()},t.prototype.subscribe=function(e,t){return Object(a.a)(this,this.observable,this,t)},t}(s.a)},function(e,t,r){var n=r(149)(Object.keys,Object);e.exports=n},function(e,t,r){var n=r(28)(r(17),"DataView");e.exports=n},function(e,t,r){var n=r(29),o=r(321),i=r(12),u=r(151),s=/^\[object .+?Constructor\]$/,a=Function.prototype,c=Object.prototype,l=a.toString,f=c.hasOwnProperty,h=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(n(e)?h:s).test(u(e))}},function(e,t,r){var n=r(37),o=Object.prototype,i=o.hasOwnProperty,u=o.toString,s=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,s),r=e[s];try{e[s]=void 0;var n=!0}catch(e){}var o=u.call(e);return n&&(t?e[s]=r:delete e[s]),o}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,r){var n,o=r(322),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!i&&i in e}},function(e,t,r){var n=r(17)["__core-js_shared__"];e.exports=n},function(e,t){e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,r){var n=r(28)(r(17),"Promise");e.exports=n},function(e,t,r){var n=r(28)(r(17),"Set");e.exports=n},function(e,t,r){var n=r(28)(r(17),"WeakMap");e.exports=n},function(e,t,r){var n=r(26),o=r(18),i="[object Arguments]";e.exports=function(e){return o(e)&&n(e)==i}},function(e,t){e.exports=function(){return!1}},function(e,t,r){var n=r(26),o=r(91),i=r(18),u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u["[object Arguments]"]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u["[object Map]"]=u["[object Number]"]=u["[object Object]"]=u["[object RegExp]"]=u["[object Set]"]=u["[object String]"]=u["[object WeakMap]"]=!1,e.exports=function(e){return i(e)&&o(e.length)&&!!u[n(e)]}},function(e,t,r){var n=r(331);e.exports=function(e){var t=n(e),r=t%1;return t==t?r?t-r:t:0}},function(e,t,r){var n=r(332),o=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=n(e))===o||e===-o?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,r){var n=r(12),o=r(62),i=NaN,u=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return i;if(n(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=n(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(u,"");var r=a.test(e);return r||c.test(e)?l(e.slice(2),r?2:8):s.test(e)?i:+e}},function(e,t){e.exports=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}},function(e,t,r){var n=r(335),o=r(155),i=r(61),u=o?function(e,t){return o(e,"toString",{configurable:!0,enumerable:!1,value:n(t),writable:!0})}:i;e.exports=u},function(e,t){e.exports=function(e){return function(){return e}}},function(e,t){var r=800,n=16,o=Date.now;e.exports=function(e){var t=0,i=0;return function(){var u=o(),s=n-(u-i);if(i=u,s>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t){!function(){"use strict";function r(e){return"function"==typeof e}function n(e){return"[object Array]"===Object.prototype.toString.call(e)}function o(e){return e instanceof Date?e.getTime():n(e)?e.map(o):e&&"function"==typeof e.toJSON?e.toJSON():e}function i(e,t){return r(e.get)?e.get(t):e[t]}function u(e){return function(t,r){if(!n(r)||!r.length)return e(t,r);for(var o=0,u=r.length;o0}),$gte:u(function(e,t){return b.compare(o(t),e)>=0}),$lt:u(function(e,t){return b.compare(o(t),e)<0}),$lte:u(function(e,t){return b.compare(o(t),e)<=0}),$mod:u(function(e,t){return t%e[0]==e[1]}),$in:function(e,t){if(!(t instanceof Array)){var r=o(t);if(r===t&&"object"==typeof t)for(u=e.length;u--;)if(String(e[u])===String(t)&&"[object Object]"!==String(t))return!0;if(void 0===r)for(u=e.length;u--;)if(null==e[u])return!0;for(u=e.length;u--;){var n=s(v(i(e,u),void 0),t,u,e);if(n&&"[object Object]"!==String(n)&&"[object Object]"!==String(t))return!0}return!!~e.indexOf(r)}for(var u=t.length;u--;)if(~e.indexOf(o(i(t,u))))return!0;return!1},$nin:function(e,t,r,n){return!c.$in(e,t,r,n)},$not:function(e,t,r,n){return!s(e,t,r,n)},$type:function(e,t){return void 0!=t&&(t instanceof e||t.constructor==e)},$all:function(e,t,r,n){return c.$and(e,t,r,n)},$size:function(e,t){return!!t&&e===t.length},$or:function(e,t,r,n){for(var o=0,u=e.length;ot)return 1;if(e=0&&n<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(s=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),o.call(a,n,e),typeof console===t&&n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-l,O=Math.floor,E=String.fromCharCode;function P(e){throw new RangeError(m[e])}function k(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function j(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+k((e=e.replace(_,".")).split("."),t).join(".")}function S(e){for(var t,r,n=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(t+=E((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=E(e)}).join("")}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,r){var n=0;for(e=r?O(e/p):e>>1,e+=O(e/t);e>w*f>>1;n+=c)e=O(e/w);return O(n+(w+1)*e/(e+h))}function M(e){var t,r,n,o,i,u,s,h,p,b,g,_=[],m=e.length,w=0,E=y,k=d;for((r=e.lastIndexOf(v))<0&&(r=0),n=0;n=128&&P("not-basic"),_.push(e.charCodeAt(n));for(o=r>0?r+1:0;o=m&&P("invalid-input"),((h=(g=e.charCodeAt(o++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:c)>=c||h>O((a-w)/u))&&P("overflow"),w+=h*u,!(h<(p=s<=k?l:s>=k+f?f:s-k));s+=c)u>O(a/(b=c-p))&&P("overflow"),u*=b;k=T(w-i,t=_.length+1,0==i),O(w/t)>a-E&&P("overflow"),E+=O(w/t),w%=t,_.splice(w++,0,E)}return x(_)}function I(e){var t,r,n,o,i,u,s,h,p,b,g,_,m,w,k,j=[];for(_=(e=S(e)).length,t=y,r=0,i=d,u=0;u<_;++u)(g=e[u])<128&&j.push(E(g));for(n=o=j.length,o&&j.push(v);n<_;){for(s=a,u=0;u<_;++u)(g=e[u])>=t&&gO((a-r)/(m=n+1))&&P("overflow"),r+=(s-t)*m,t=s,u=0;u<_;++u)if((g=e[u])a&&P("overflow"),g==t){for(h=r,p=c;!(h<(b=p<=i?l:p>=i+f?f:p-i));p+=c)k=h-b,w=c-b,j.push(E(C(b+k%w,0))),h=O(k/w);j.push(E(C(h,0))),i=T(r,m,n==o),r=0,++n}++r,++t}return j.join("")}s={version:"1.4.1",ucs2:{decode:S,encode:x},decode:M,encode:I,toASCII:function(e){return j(e,function(e){return g.test(e)?"xn--"+I(e):e})},toUnicode:function(e){return j(e,function(e){return b.test(e)?M(e.slice(4).toLowerCase()):e})}},void 0===(o=function(){return s}.call(t,r,t,e))||(e.exports=o)}()}).call(t,r(60)(e),r(11))},function(e,t,r){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,r){"use strict";t.decode=t.parse=r(345),t.encode=t.stringify=r(346)},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,i){t=t||"&",r=r||"=";var u={};if("string"!=typeof e||0===e.length)return u;var s=/\+/g;e=e.split(t);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var c=e.length;a>0&&c>a&&(c=a);for(var l=0;l=0?(f=y.substr(0,v),h=y.substr(v+1)):(f=y,h=""),p=decodeURIComponent(f),d=decodeURIComponent(h),n(u,p)?o(u[p])?u[p].push(d):u[p]=[u[p],d]:u[p]=d}return u};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?i(u(e),function(u){var s=encodeURIComponent(n(u))+r;return o(e[u])?i(e[u],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[u]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n-1}},function(e,t,r){var n=r(70);e.exports=function(e,t){var r=this.__data__,o=n(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}},function(e,t,r){var n=r(69);e.exports=function(){this.__data__=new n,this.size=0}},function(e,t){e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},function(e,t){e.exports=function(e){return this.__data__.get(e)}},function(e,t){e.exports=function(e){return this.__data__.has(e)}},function(e,t,r){var n=r(69),o=r(90),i=r(100),u=200;e.exports=function(e,t){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|e}function d(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,o);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,o){var i,u=1,s=e.length,a=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;u=2,s/=2,a/=2,r/=2}function c(e,t){return 1===u?e[t]:e.readUInt16BE(t*u)}if(o){var l=-1;for(i=r;is&&(r=s-a),i=r;i>=0;i--){for(var f=!0,h=0;ho&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var u=0;u>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[o+1]))&&(a=(31&c)<<6|63&i)>127&&(l=a);break;case 3:i=e[o+1],u=e[o+2],128==(192&i)&&128==(192&u)&&(a=(15&c)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:i=e[o+1],u=e[o+2],s=e[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&c)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(l=a)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(e){var t=e.length;if(t<=j)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return S(this,t,r);case"latin1":case"binary":return x(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},a.prototype.compare=function(e,t,r,n,o){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var i=o-n,u=r-t,s=Math.min(i,u),c=this.slice(n,o),l=e.slice(t,r),f=0;fo)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return m(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return O(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var j=4096;function S(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;on)&&(r=n);for(var o="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function A(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o>>8*(n?o:1-o)}function R(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o>>8*(n?o:3-o)&255}function N(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function q(e,t,r,n,i){return i||N(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,i){return i||N(e,0,r,8),o.write(e,t,r,n,52,8),r+8}a.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(o*=256);)n+=this[e+--t]*o;return n},a.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),o.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),o.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):A(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):A(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=0,u=1,s=0;for(this[t]=255&e;++i>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);I(this,e,t,r,o-1,-o)}var i=r-1,u=1,s=0;for(this[t+i]=255&e;--i>=0&&(u*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/u>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):A(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):A(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return q(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return q(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function B(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(t,r(11))},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=c(e),n=r[0],u=r[1],s=new i(function(e,t,r){return 3*(t+r)/4-r}(0,n,u)),a=0,l=u>0?n-4:n,f=0;f>16&255,s[a++]=t>>8&255,s[a++]=255&t;2===u&&(t=o[e.charCodeAt(f)]<<2|o[e.charCodeAt(f+1)]>>4,s[a++]=255&t);1===u&&(t=o[e.charCodeAt(f)]<<10|o[e.charCodeAt(f+1)]<<4|o[e.charCodeAt(f+2)]>>2,s[a++]=t>>8&255,s[a++]=255&t);return s},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],u=0,s=r-o;us?s:u+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var o,i,u=[],s=t;s>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,o){var i,u,s=8*o-n-1,a=(1<>1,l=-7,f=r?o-1:0,h=r?-1:1,p=e[t+f];for(f+=h,i=p&(1<<-l)-1,p>>=-l,l+=s;l>0;i=256*i+e[t+f],f+=h,l-=8);for(u=i&(1<<-l)-1,i>>=-l,l+=n;l>0;u=256*u+e[t+f],f+=h,l-=8);if(0===i)i=1-c;else{if(i===a)return u?NaN:1/0*(p?-1:1);u+=Math.pow(2,n),i-=c}return(p?-1:1)*u*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var u,s,a,c=8*i-o-1,l=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,u=l):(u=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-u))<1&&(u--,a*=2),(t+=u+f>=1?h/a:h*Math.pow(2,1-f))*a>=2&&(u++,a/=2),u+f>=l?(s=0,u=l):u+f>=1?(s=(t*a-1)*Math.pow(2,o),u+=f):(s=t*Math.pow(2,f-1)*Math.pow(2,o),u=0));o>=8;e[r+p]=255&s,p+=d,s/=256,o-=8);for(u=u<0;e[r+p]=255&u,p+=d,u/=256,c-=8);e[r+p-d]|=128*y}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";var n=r(173),o=r(174),i={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},u=Date.prototype.toISOString,s={delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,serializeDate:function(e){return u.call(e)},skipNulls:!1,strictNullHandling:!1},a=function e(t,r,o,i,u,a,c,l,f,h,p,d){var y=t;if("function"==typeof c)y=c(r,y);else if(y instanceof Date)y=h(y);else if(null===y){if(i)return a&&!d?a(r,s.encoder):r;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||n.isBuffer(y))return a?[p(d?r:a(r,s.encoder))+"="+p(a(y,s.encoder))]:[p(r)+"="+p(String(y))];var v,b=[];if(void 0===y)return b;if(Array.isArray(c))v=c;else{var g=Object.keys(y);v=l?g.sort(l):g}for(var _=0;_0?S+j:""}},function(e,t,r){"use strict";var n=r(173),o=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:n.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},u=function(e,t,r){if(e){var n=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,u=/(\[[^[\]]*])/.exec(n),s=u?n.slice(0,u.index):n,a=[];if(s){if(!r.plainObjects&&o.call(Object.prototype,s)&&!r.allowPrototypes)return;a.push(s)}for(var c=0;null!==(u=i.exec(n))&&c=0;--o){var i,u=e[o];if("[]"===u)i=(i=[]).concat(n);else{i=r.plainObjects?Object.create(null):{};var s="["===u.charAt(0)&&"]"===u.charAt(u.length-1)?u.slice(1,-1):u,a=parseInt(s,10);!isNaN(a)&&u!==s&&String(a)===s&&a>=0&&r.parseArrays&&a<=r.arrayLimit?(i=[])[a]=n:i[s]=n}n=i}return n}(a,t,r)}};e.exports=function(e,t){var r=t?n.assign({},t):{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.ignoreQueryPrefix=!0===r.ignoreQueryPrefix,r.delimiter="string"==typeof r.delimiter||n.isRegExp(r.delimiter)?r.delimiter:i.delimiter,r.depth="number"==typeof r.depth?r.depth:i.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:i.arrayLimit,r.parseArrays=!1!==r.parseArrays,r.decoder="function"==typeof r.decoder?r.decoder:i.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:i.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:i.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:i.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:i.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:i.strictNullHandling,""===e||null===e||void 0===e)return r.plainObjects?Object.create(null):{};for(var s="string"==typeof e?function(e,t){for(var r={},n=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,u=t.parameterLimit===1/0?void 0:t.parameterLimit,s=n.split(t.delimiter,u),a=0;a=n.maxQueuedPromises?o(new Error("Queue limit reached")):(n.queue.push({promiseGenerator:r,resolve:e,reject:o,notify:i||t}),n._dequeue())})},r.prototype.getPendingLength=function(){return this.pendingPromises},r.prototype.getQueueLength=function(){return this.queue.length},r.prototype.pause=function(){this.paused=!0},r.prototype.start=function(){return this.paused=!1,this._dequeue()},r.prototype._dequeue=function(){var t=this;if(this.paused)return!1;if(this.pendingPromises>=this.maxPendingPromises)return!1;var r,n=this.queue.shift();if(!n)return this.options.onEmpty&&this.options.onEmpty(),!1;try{this.pendingPromises++,(r=n.promiseGenerator(),r&&"function"==typeof r.then?r:new e(function(e){e(r)})).then(function(e){t.pendingPromises--,n.resolve(e),t._dequeue()},function(e){t.pendingPromises--,n.reject(e),t._dequeue()},function(e){n.notify(e)})}catch(e){t.pendingPromises--,n.reject(e),t._dequeue()}return!0},r})},function(e,t,r){var n=r(406),o=r(68),i=r(106),u=r(432),s=r(6);e.exports=function(e,t,r){var a=s(e)?n:u,c=arguments.length<3;return a(e,i(t,4),r,c,o)}},function(e,t){e.exports=function(e,t,r,n){var o=-1,i=null==e?0:e.length;for(n&&i&&(r=e[++o]);++o0&&void 0!==arguments[0]?arguments[0]:"Http Middleware";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Middleware),o(t,[{key:"handle",value:function(){return u.default.reject(new s.KinveyError("Unable to send network request.","Please override the core HttpMiddleware."))}},{key:"cancel",value:function(){return u.default.resolve()}}]),t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=function(e,t){if(0===e.level)return e.value;for(var r="\r\n",n=t?s:i,c=1;c0){var n=t.nodes.length-1;t.nodes.forEach(function(t,i){o[t.level]=i===n,r+=e.generate(t,i===n)})}return r}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseMiddleware=void 0;var n,o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"Parse Middleware";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.Middleware),o(t,[{key:"handle",value:function(e,t){if((0,s.isDefined)(t)&&(0,s.isDefined)(t.data)){var r=t.headers["content-type"]||t.headers["Content-Type"];if(r&&0===r.indexOf("application/json"))try{t.data=JSON.parse(t.data)}catch(e){}}return u.default.resolve({response:t})}}]),t}()},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.SerializeMiddleware=void 0;var n,o=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"Serialize Middleware";return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,a.Middleware),o(r,[{key:"handle",value:function(t){if((0,s.isDefined)(t)&&(0,s.isDefined)(t.body)){var r=t.headers["content-type"]||t.headers["Content-Type"];if((0,s.isDefined)(r))if(0===r.indexOf("application/json"))t.body=JSON.stringify(t.body);else if(0===r.indexOf("application/x-www-form-urlencoded")){var n=t.body,o=[];Object.keys(n).forEach(function(t){o.push(e.encodeURIComponent(t)+"="+e.encodeURIComponent(n[t]))}),t.body=o.join("&")}}return u.default.resolve({request:t})}}]),r}()}).call(t,r(11))},function(e,t,r){var n;n=function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(1)),u=n(r(39)),s=n(r(40)),a=r(41),c=(r(5),function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=e.listenToBrowserNetworkEvents,n=void 0===r||r;e.db=s.default,e.sdkFamily="Web",e.networking=new u.default({del:a.del,get:a.get,post:a.post,sendBeacon:o});var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n&&(window.addEventListener("offline",function(){i.networkDownDetected()}),window.addEventListener("online",function(){i.networkUpDetected()})),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.default),t}());t.default=c,e.exports=t.default},function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var r=0;r>>2]|=(r[o>>>2]>>>24-o%4*8&255)<<24-(n+o)%4*8;else if(65535>>2]=r[o>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r=[],n=0;n>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},f=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,o=r.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var a=0;al;){var f;e:{f=c;for(var h=e.sqrt(f),p=2;p<=h;p++)if(!(f%p)){f=!1;break e}f=!0}f&&(8>l&&(u[l]=a(e.pow(c,.5))),s[l]=a(e.pow(c,1/3)),l++),c++}var d=[];i=i.SHA256=o.extend({_doReset:function(){this._hash=new n.init(u.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],o=r[1],i=r[2],u=r[3],a=r[4],c=r[5],l=r[6],f=r[7],h=0;64>h;h++){if(16>h)d[h]=0|e[t+h];else{var p=d[h-15],y=d[h-2];d[h]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+d[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+d[h-16]}p=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&l)+s[h]+d[h],y=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&o^n&i^o&i),f=l,l=c,c=a,a=u+p|0,u=i,i=o,o=n,n=p+y|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+u|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+l|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=e.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(i),t.HmacSHA256=o._createHmacHelper(i)}(Math),function(){var e=r,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(e,r){e=this._hasher=new e.init,"string"==typeof r&&(r=t.parse(r));var n=e.blockSize,o=4*n;r.sigBytes>o&&(r=e.finalize(r)),r.clamp();for(var i=this._oKey=r.clone(),u=this._iKey=r.clone(),s=i.words,a=u.words,c=0;c>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,u=0;4>u&&o+.75*u>>6*(3-u)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var r=e.length,n=this._map;(o=n.charAt(64))&&-1!=(o=e.indexOf(o))&&(r=o);for(var o=[],i=0,u=0;u>>6-u%4*2;o[i>>>2]|=(s|a)<<24-i%4*8,i++}return t.create(o,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){function t(e,t,r,n,o,i,u){return((e=e+(t&r|~t&n)+o+u)<>>32-i)+t}function n(e,t,r,n,o,i,u){return((e=e+(t&n|r&~n)+o+u)<>>32-i)+t}function o(e,t,r,n,o,i,u){return((e=e+(t^r^n)+o+u)<>>32-i)+t}function i(e,t,r,n,o,i,u){return((e=e+(r^(t|~n))+o+u)<>>32-i)+t}for(var u=r,s=(c=u.lib).WordArray,a=c.Hasher,c=u.algo,l=[],f=0;64>f;f++)l[f]=4294967296*e.abs(e.sin(f+1))|0;c=c.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,r){for(var u=0;16>u;u++){var s=e[f=r+u];e[f]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}u=this._hash.words;var a,c,f=e[r+0],h=(s=e[r+1],e[r+2]),p=e[r+3],d=e[r+4],y=e[r+5],v=e[r+6],b=e[r+7],g=e[r+8],_=e[r+9],m=e[r+10],w=e[r+11],O=e[r+12],E=e[r+13],P=e[r+14],k=e[r+15],j=u[0],S=i(S=i(S=i(S=i(S=o(S=o(S=o(S=o(S=n(S=n(S=n(S=n(S=t(S=t(S=t(S=t(S=u[1],c=t(c=u[2],a=t(a=u[3],j=t(j,S,c,a,f,7,l[0]),S,c,s,12,l[1]),j,S,h,17,l[2]),a,j,p,22,l[3]),c=t(c,a=t(a,j=t(j,S,c,a,d,7,l[4]),S,c,y,12,l[5]),j,S,v,17,l[6]),a,j,b,22,l[7]),c=t(c,a=t(a,j=t(j,S,c,a,g,7,l[8]),S,c,_,12,l[9]),j,S,m,17,l[10]),a,j,w,22,l[11]),c=t(c,a=t(a,j=t(j,S,c,a,O,7,l[12]),S,c,E,12,l[13]),j,S,P,17,l[14]),a,j,k,22,l[15]),c=n(c,a=n(a,j=n(j,S,c,a,s,5,l[16]),S,c,v,9,l[17]),j,S,w,14,l[18]),a,j,f,20,l[19]),c=n(c,a=n(a,j=n(j,S,c,a,y,5,l[20]),S,c,m,9,l[21]),j,S,k,14,l[22]),a,j,d,20,l[23]),c=n(c,a=n(a,j=n(j,S,c,a,_,5,l[24]),S,c,P,9,l[25]),j,S,p,14,l[26]),a,j,g,20,l[27]),c=n(c,a=n(a,j=n(j,S,c,a,E,5,l[28]),S,c,h,9,l[29]),j,S,b,14,l[30]),a,j,O,20,l[31]),c=o(c,a=o(a,j=o(j,S,c,a,y,4,l[32]),S,c,g,11,l[33]),j,S,w,16,l[34]),a,j,P,23,l[35]),c=o(c,a=o(a,j=o(j,S,c,a,s,4,l[36]),S,c,d,11,l[37]),j,S,b,16,l[38]),a,j,m,23,l[39]),c=o(c,a=o(a,j=o(j,S,c,a,E,4,l[40]),S,c,f,11,l[41]),j,S,p,16,l[42]),a,j,v,23,l[43]),c=o(c,a=o(a,j=o(j,S,c,a,_,4,l[44]),S,c,O,11,l[45]),j,S,k,16,l[46]),a,j,h,23,l[47]),c=i(c,a=i(a,j=i(j,S,c,a,f,6,l[48]),S,c,b,10,l[49]),j,S,P,15,l[50]),a,j,y,21,l[51]),c=i(c,a=i(a,j=i(j,S,c,a,O,6,l[52]),S,c,p,10,l[53]),j,S,m,15,l[54]),a,j,s,21,l[55]),c=i(c,a=i(a,j=i(j,S,c,a,g,6,l[56]),S,c,k,10,l[57]),j,S,v,15,l[58]),a,j,E,21,l[59]),c=i(c,a=i(a,j=i(j,S,c,a,d,6,l[60]),S,c,w,10,l[61]),j,S,h,15,l[62]),a,j,_,21,l[63]);u[0]=u[0]+j|0,u[1]=u[1]+S|0,u[2]=u[2]+c|0,u[3]=u[3]+a|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;r[o>>>5]|=128<<24-o%32;var i=e.floor(n/4294967296);for(r[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),r[14+(o+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(r.length+1),this._process(),r=(t=this._hash).words,n=0;4>n;n++)o=r[n],r[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),u.MD5=a._createHelper(c),u.HmacMD5=a._createHmacHelper(c)}(Math),function(){var e,t=r,n=(e=t.lib).Base,o=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=(s=this.cfg).hasher.create(),n=o.create(),i=n.words,u=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:c,padding:f}),reset:function(){a.reset.call(this);var e=(t=this.cfg).iv,t=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=t.createEncryptor;else r=t.createDecryptor,this._minBufferSize=1;this._mode=r.call(t,this,e&&e.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else t=this._process(!0),e.unpad(t);return t},blockSize:4});var h=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),p=(c=(d.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?o.create([1398893684,1701076831]).concat(e).concat(t):t).toString(u)},parse:function(e){var t=(e=u.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var r=o.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return h.create({ciphertext:e,salt:r})}},t.SerializableCipher=n.extend({cfg:n.extend({format:c}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var o=e.createEncryptor(r,n);return t=o.finalize(t),o=o.cfg,h.create({ciphertext:t,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),d=(d.kdf={}).OpenSSL={execute:function(e,t,r,n){return n||(n=o.random(8)),e=s.create({keySize:t+r}).compute(e,n),r=o.create(e.words.slice(t),4*r),e.sigBytes=4*t,h.create({key:e,iv:r,salt:n})}},y=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:d}),encrypt:function(e,t,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize),n.iv=r.iv,(e=p.encrypt.call(this,e,t,r.key,n)).mixIn(r),e},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),r=n.kdf.execute(r,e.keySize,e.ivSize,t.salt),n.iv=r.iv,p.decrypt.call(this,e,t,r.key,n)}})}(),function(){for(var e=r,t=e.lib.BlockCipher,n=e.algo,o=[],i=[],u=[],s=[],a=[],c=[],l=[],f=[],h=[],p=[],d=[],y=0;256>y;y++)d[y]=128>y?y<<1:y<<1^283;var v=0,b=0;for(y=0;256>y;y++){var g=(g=b^b<<1^b<<2^b<<3^b<<4)>>>8^255&g^99;o[v]=g,i[g]=v;var _=d[v],m=d[_],w=d[m],O=257*d[g]^16843008*g;u[v]=O<<24|O>>>8,s[v]=O<<16|O>>>16,a[v]=O<<8|O>>>24,c[v]=O,O=16843009*w^65537*m^257*_^16843008*v,l[g]=O<<24|O>>>8,f[g]=O<<16|O>>>16,h[g]=O<<8|O>>>24,p[g]=O,v?(v=_^d[d[d[w^_]]],b^=d[d[b]]):v=b=1}var E=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(r=this._key).words,t=r.sigBytes/4,r=4*((this._nRounds=t+6)+1),n=this._keySchedule=[],i=0;i>>24]<<24|o[u>>>16&255]<<16|o[u>>>8&255]<<8|o[255&u]):(u=o[(u=u<<8|u>>>24)>>>24]<<24|o[u>>>16&255]<<16|o[u>>>8&255]<<8|o[255&u],u^=E[i/t|0]<<24),n[i]=n[i-t]^u}for(e=this._invKeySchedule=[],t=0;tt||4>=i?u:l[o[u>>>24]]^f[o[u>>>16&255]]^h[o[u>>>8&255]]^p[o[255&u]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,u,s,a,c,o)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,f,h,p,i),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,o,i,u,s){for(var a=this._nRounds,c=e[t]^r[0],l=e[t+1]^r[1],f=e[t+2]^r[2],h=e[t+3]^r[3],p=4,d=1;d>>24]^o[l>>>16&255]^i[f>>>8&255]^u[255&h]^r[p++],v=n[l>>>24]^o[f>>>16&255]^i[h>>>8&255]^u[255&c]^r[p++],b=n[f>>>24]^o[h>>>16&255]^i[c>>>8&255]^u[255&l]^r[p++];h=n[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^u[255&f]^r[p++],c=y,l=v,f=b}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[f>>>8&255]<<8|s[255&h])^r[p++],v=(s[l>>>24]<<24|s[f>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^r[p++],b=(s[f>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^r[p++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&f])^r[p++],e[t]=y,e[t+1]=v,e[t+2]=b,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),r.mode.ECB=function(){var e=r.lib.BlockCipherMode.extend();return e.Encryptor=e.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),e.Decryptor=e.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),e}(),e.exports=r},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=u){var l={};l.category=a.default.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}o.forEach(function(e){var t=e.channel,n=e.subscriptionMatch,o=e.publishMetaData;if(t===n&&(n=null),c){if(r._dedupingManager.isDuplicate(e))return;r._dedupingManager.addEntry(e)}if(s.default.endsWith(e.channel,"-pnpres")){var i={channel:null,subscription:null};i.actualChannel=null!=n?t:null,i.subscribedChannel=null!=n?n:t,t&&(i.channel=t.substring(0,t.lastIndexOf("-pnpres"))),n&&(i.subscription=n.substring(0,n.lastIndexOf("-pnpres"))),i.action=e.payload.action,i.state=e.payload.data,i.timetoken=o.publishTimetoken,i.occupancy=e.payload.occupancy,i.uuid=e.payload.uuid,i.timestamp=e.payload.timestamp,e.payload.join&&(i.join=e.payload.join),e.payload.leave&&(i.leave=e.payload.leave),e.payload.timeout&&(i.timeout=e.payload.timeout),r._listenerManager.announcePresence(i)}else{var u={channel:null,subscription:null};u.actualChannel=null!=n?t:null,u.subscribedChannel=null!=n?n:t,u.channel=t,u.subscription=n,u.timetoken=o.publishTimetoken,u.publisher=e.issuingClientId,e.userMetadata&&(u.userMetadata=e.userMetadata),r._config.cipherKey?u.message=r._crypto.decrypt(e.payload):u.message=e.payload,r._listenerManager.announceMessage(u)}}),this._region=t.metadata.region,this._startSubscribeLoop()}}},{key:"_stopSubscribeLoop",value:function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)}}]),e}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))}},{key:"clearHistory",value:function(){this.hashHistory=[]}}]),e}();t.default=u,e.exports=t.default},function(e,t){"use strict";function r(e){return encodeURIComponent(e).replace(/[!~*'()]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function n(e){return function(e){var t=[];return Object.keys(e).forEach(function(e){return t.push(e)}),t}(e).sort()}e.exports={signPamFromParams:function(e){return n(e).map(function(t){return t+"="+r(e[t])}).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e=void 0,t=void 0;return{promise:new Promise(function(r,n){e=r,t=n}),reject:t,fulfill:e}},encodeString:r}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){return function(e,t){return e.type=t,e.error=!0,e}({message:e},"validationError")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=e.networking,n=e.config,c=null,l=null,f={};t.getOperation()===s.default.PNTimeOperation||t.getOperation()===s.default.PNChannelGroupsOperation?c=arguments.length<=2?void 0:arguments[2]:(f=arguments.length<=2?void 0:arguments[2],c=arguments.length<=3?void 0:arguments[3]),"undefined"==typeof Promise||c||(l=u.default.createPromise());var h=t.validateParams(e,f);if(!h){var p=t.prepareParams(e,f),d=function(e,t,r){return e.usePost&&e.usePost(t,r)?e.postURL(t,r):e.getURL(t,r)}(t,e,f),y=void 0,v={url:d,operation:t.getOperation(),timeout:t.getRequestTimeout(e)};p.uuid=n.UUID,p.pnsdk=function(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-"+e.sdkFamily;return e.partnerId&&(t+="-"+e.partnerId),t+"/"+e.getVersion()}(n),n.useInstanceId&&(p.instanceid=n.instanceId),n.useRequestId&&(p.requestid=i.default.createUUID()),t.isAuthSupported()&&n.getAuthKey()&&(p.auth=n.getAuthKey()),n.secretKey&&function(e,t,r){var n=e.config,o=e.crypto;r.timestamp=Math.floor((new Date).getTime()/1e3);var i=n.subscribeKey+"\n"+n.publishKey+"\n"+t+"\n";i+=u.default.signPamFromParams(r);var s=o.HMACSHA256(i);s=(s=s.replace(/\+/g,"-")).replace(/\//g,"_"),r.signature=s}(e,d,p);var b=function(r,n){if(r.error)c?c(r):l&&l.reject(new a("PubNub call failed, check status for details",r));else{var o=t.handleResponse(e,n,f);c?c(r,o):l&&l.fulfill(o)}};if(t.usePost&&t.usePost(e,f)){var g=t.postPayload(e,f);y=r.POST(p,g,v,b)}else y=t.useDelete&&t.useDelete()?r.DELETE(p,v,b):r.GET(p,v,b);return t.getOperation()===s.default.PNSubscribeOperation?y:l?l.promise:void 0}return c?c(o(h)):l?(l.reject(new a("Validation failed, check status for details",o(h))),l.promise):void 0};var i=n(r(3)),u=n((r(5),r(15))),s=n((n(r(2)),r(13))),a=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.name=n.constructor.name,n.status=r,n.message=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}();e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNAddChannelsToGroupOperation},t.validateParams=function(e,t){var r=t.channels,n=t.channelGroup,o=e.config;return n?r&&0!==r.length?o.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},t.getURL=function(e,t){var r=t.channelGroup;return"/v1/channel-registration/sub-key/"+e.config.subscribeKey+"/channel-group/"+i.default.encodeString(r)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.channels;return{add:(void 0===r?[]:r).join(",")}},t.handleResponse=function(){return{}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNRemoveChannelsFromGroupOperation},t.validateParams=function(e,t){var r=t.channels,n=t.channelGroup,o=e.config;return n?r&&0!==r.length?o.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},t.getURL=function(e,t){var r=t.channelGroup;return"/v1/channel-registration/sub-key/"+e.config.subscribeKey+"/channel-group/"+i.default.encodeString(r)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.channels;return{remove:(void 0===r?[]:r).join(",")}},t.handleResponse=function(){return{}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNRemoveGroupOperation},t.validateParams=function(e,t){var r=t.channelGroup,n=e.config;return r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},t.getURL=function(e,t){var r=t.channelGroup;return"/v1/channel-registration/sub-key/"+e.config.subscribeKey+"/channel-group/"+i.default.encodeString(r)+"/remove"},t.isAuthSupported=function(){return!0},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.prepareParams=function(){return{}},t.handleResponse=function(){return{}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNChannelGroupsOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e){return"/v1/channel-registration/sub-key/"+e.config.subscribeKey+"/channel-group"},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(){return{}},t.handleResponse=function(e,t){return{groups:t.payload.groups}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNChannelsForGroupOperation},t.validateParams=function(e,t){var r=t.channelGroup,n=e.config;return r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},t.getURL=function(e,t){var r=t.channelGroup;return"/v1/channel-registration/sub-key/"+e.config.subscribeKey+"/channel-group/"+i.default.encodeString(r)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(){return{}},t.handleResponse=function(e,t){return{channels:t.payload.channels}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNPushNotificationEnabledChannelsOperation},t.validateParams=function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,i=e.config;return r?n?o&&0!==o.length?i.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"},t.getURL=function(e,t){var r=t.device;return"/v1/push/sub-key/"+e.config.subscribeKey+"/devices/"+r},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.pushGateway,n=t.channels;return{type:r,add:(void 0===n?[]:n).join(",")}},t.handleResponse=function(){return{}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNPushNotificationEnabledChannelsOperation},t.validateParams=function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,i=e.config;return r?n?o&&0!==o.length?i.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"},t.getURL=function(e,t){var r=t.device;return"/v1/push/sub-key/"+e.config.subscribeKey+"/devices/"+r},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.pushGateway,n=t.channels;return{type:r,remove:(void 0===n?[]:n).join(",")}},t.handleResponse=function(){return{}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNPushNotificationEnabledChannelsOperation},t.validateParams=function(e,t){var r=t.device,n=t.pushGateway,o=e.config;return r?n?o.subscribeKey?void 0:"Missing Subscribe Key":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"},t.getURL=function(e,t){var r=t.device;return"/v1/push/sub-key/"+e.config.subscribeKey+"/devices/"+r},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){return{type:t.pushGateway}},t.handleResponse=function(e,t){return{channels:t}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNRemoveAllPushNotificationsOperation},t.validateParams=function(e,t){var r=t.device,n=t.pushGateway,o=e.config;return r?n?o.subscribeKey?void 0:"Missing Subscribe Key":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"},t.getURL=function(e,t){var r=t.device;return"/v1/push/sub-key/"+e.config.subscribeKey+"/devices/"+r+"/remove"},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){return{type:t.pushGateway}},t.handleResponse=function(){return{}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNUnsubscribeOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.channels,o=void 0===n?[]:n,u=o.length>0?o.join(","):",";return"/v2/presence/sub-key/"+r.subscribeKey+"/channel/"+i.default.encodeString(u)+"/leave"},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.channelGroups,n=void 0===r?[]:r,o={};return n.length>0&&(o["channel-group"]=n.join(",")),o},t.handleResponse=function(){return{}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNWhereNowOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.uuid,o=void 0===n?r.UUID:n;return"/v2/presence/sub-key/"+r.subscribeKey+"/uuid/"+o},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(){return{}},t.handleResponse=function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNHeartbeatOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.channels,o=void 0===n?[]:n,u=o.length>0?o.join(","):",";return"/v2/presence/sub-key/"+r.subscribeKey+"/channel/"+i.default.encodeString(u)+"/heartbeat"},t.isAuthSupported=function(){return!0},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.prepareParams=function(e,t){var r=t.channelGroups,n=void 0===r?[]:r,o=t.state,i=void 0===o?{}:o,u=e.config,s={};return n.length>0&&(s["channel-group"]=n.join(",")),s.state=JSON.stringify(i),s.heartbeat=u.getPresenceTimeout(),s},t.handleResponse=function(){return{}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNGetStateOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.uuid,o=void 0===n?r.UUID:n,u=t.channels,s=void 0===u?[]:u,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/"+r.subscribeKey+"/channel/"+i.default.encodeString(a)+"/uuid/"+o},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.channelGroups,n=void 0===r?[]:r,o={};return n.length>0&&(o["channel-group"]=n.join(",")),o},t.handleResponse=function(e,t,r){var n=r.channels,o=void 0===n?[]:n,i=r.channelGroups,u=void 0===i?[]:i,s={};return 1===o.length&&0===u.length?s[o[0]]=t.payload:s=t.payload,{channels:s}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNSetStateOperation},t.validateParams=function(e,t){var r=e.config,n=t.state,o=t.channels,i=void 0===o?[]:o,u=t.channelGroups,s=void 0===u?[]:u;return n?r.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},t.getURL=function(e,t){var r=e.config,n=t.channels,o=void 0===n?[]:n,u=o.length>0?o.join(","):",";return"/v2/presence/sub-key/"+r.subscribeKey+"/channel/"+i.default.encodeString(u)+"/uuid/"+r.UUID+"/data"},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.state,n=t.channelGroups,o=void 0===n?[]:n,i={};return i.state=JSON.stringify(r),o.length>0&&(i["channel-group"]=o.join(",")),i},t.handleResponse=function(e,t){return{state:t.payload}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNHereNowOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.channels,o=void 0===n?[]:n,u=t.channelGroups,s=void 0===u?[]:u,a="/v2/presence/sub-key/"+r.subscribeKey;if(o.length>0||s.length>0){var c=o.length>0?o.join(","):",";a+="/channel/"+i.default.encodeString(c)}return a},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.channelGroups,n=void 0===r?[]:r,o=t.includeUUIDs,i=void 0===o||o,u=t.includeState,s=void 0!==u&&u,a={};return i||(a.disable_uuids=1),s&&(a.state=1),n.length>0&&(a["channel-group"]=n.join(",")),a},t.handleResponse=function(e,t,r){var n=r.channels,o=void 0===n?[]:n,i=r.channelGroups,u=void 0===i?[]:i,s=r.includeUUIDs,a=void 0===s||s,c=r.includeState,l=void 0!==c&&c;return o.length>1||u.length>0||0===u.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach(function(r){var n=t.payload.channels[r],o=[];return e.channels[r]={occupants:o,name:r,occupancy:n.occupancy},a&&n.uuids.forEach(function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})}),e}),e}():function(){var e={},r=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:r,name:o[0],occupancy:t.occupancy},a&&t.uuids&&t.uuids.forEach(function(e){l?r.push({state:e.state,uuid:e.uuid}):r.push({state:null,uuid:e})}),e}()};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNAccessManagerAudit},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e){return"/v2/auth/audit/sub-key/"+e.config.subscribeKey},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!1},t.prepareParams=function(e,t){var r=t.channel,n=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,u={};return r&&(u.channel=r),n&&(u["channel-group"]=n),i.length>0&&(u.auth=i.join(",")),u},t.handleResponse=function(e,t){return t.payload};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return n.default.PNAccessManagerGrant},t.validateParams=function(e){var t=e.config;return t.subscribeKey?t.publishKey?t.secretKey?void 0:"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},t.getURL=function(e){return"/v2/auth/grant/sub-key/"+e.config.subscribeKey},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!1},t.prepareParams=function(e,t){var r=t.channels,n=void 0===r?[]:r,o=t.channelGroups,i=void 0===o?[]:o,u=t.ttl,s=t.read,a=void 0!==s&&s,c=t.write,l=void 0!==c&&c,f=t.manage,h=void 0!==f&&f,p=t.authKeys,d=void 0===p?[]:p,y={};return y.r=a?"1":"0",y.w=l?"1":"0",y.m=h?"1":"0",n.length>0&&(y.channel=n.join(",")),i.length>0&&(y["channel-group"]=i.join(",")),d.length>0&&(y.auth=d.join(",")),(u||0===u)&&(y.ttl=u),y},t.handleResponse=function(){return{}};var n=function(e){return e&&e.__esModule?e:{default:e}}((r(5),r(13)))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r=e.crypto,n=e.config,o=JSON.stringify(t);return n.cipherKey&&(o=r.encrypt(o),o=JSON.stringify(o)),o}Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getOperation=function(){return u.default.PNPublishOperation},t.validateParams=function(e,t){var r=e.config,n=t.message;return t.channel?n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},t.usePost=function(e,t){var r=t.sendByPost;return void 0!==r&&r},t.getURL=function(e,t){var r=e.config,n=t.channel,i=o(e,t.message);return"/publish/"+r.publishKey+"/"+r.subscribeKey+"/0/"+s.default.encodeString(n)+"/0/"+s.default.encodeString(i)},t.postURL=function(e,t){var r=e.config,n=t.channel;return"/publish/"+r.publishKey+"/"+r.subscribeKey+"/0/"+s.default.encodeString(n)+"/0"},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.postPayload=function(e,t){return o(e,t.message)},t.prepareParams=function(e,t){var r=t.meta,n=t.replicate,o=void 0===n||n,u=t.storeInHistory,s=t.ttl,a={};return null!=u&&(a.store=u?"1":"0"),s&&(a.ttl=s),!1===o&&(a.norep="true"),r&&"object"===(void 0===r?"undefined":i(r))&&(a.meta=JSON.stringify(r)),a},t.handleResponse=function(e,t){return{timetoken:t[2]}};var u=n((r(5),r(13))),s=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNHistoryOperation},t.validateParams=function(e,t){var r=t.channel,n=e.config;return r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},t.getURL=function(e,t){var r=t.channel;return"/v2/history/sub-key/"+e.config.subscribeKey+"/channel/"+i.default.encodeString(r)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.start,n=t.end,o=t.reverse,i=t.count,u=void 0===i?100:i,s=t.stringifiedTimeToken,a=void 0!==s&&s,c={include_token:"true"};return c.count=u,r&&(c.start=r),n&&(c.end=n),a&&(c.string_message_token="true"),null!=o&&(c.reverse=o.toString()),c},t.handleResponse=function(e,t){var r={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return t[0].forEach(function(t){var n={timetoken:t.timetoken,entry:function(e,t){var r=e.config,n=e.crypto;if(!r.cipherKey)return t;try{return n.decrypt(t)}catch(e){return t}}(e,t.message)};r.messages.push(n)}),r};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNDeleteMessagesOperation},t.validateParams=function(e,t){var r=t.channel,n=e.config;return r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},t.useDelete=function(){return!0},t.getURL=function(e,t){var r=t.channel;return"/v3/history/sub-key/"+e.config.subscribeKey+"/channel/"+i.default.encodeString(r)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.start,n=t.end,o={};return r&&(o.start=r),n&&(o.end=n),o},t.handleResponse=function(e,t){return t.payload};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNFetchMessagesOperation},t.validateParams=function(e,t){var r=t.channels,n=e.config;return r&&0!==r.length?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing channels"},t.getURL=function(e,t){var r=t.channels,n=void 0===r?[]:r,o=e.config,u=n.length>0?n.join(","):",";return"/v3/history/sub-key/"+o.subscribeKey+"/channel/"+i.default.encodeString(u)},t.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=t.start,n=t.end,o=t.count,i=t.stringifiedTimeToken,u=void 0!==i&&i,s={};return o&&(s.max=o),r&&(s.start=r),n&&(s.end=n),u&&(s.string_message_token="true"),s},t.handleResponse=function(e,t){var r={channels:{}};return Object.keys(t.channels||{}).forEach(function(n){r.channels[n]=[],(t.channels[n]||[]).forEach(function(t){var o={};o.channel=n,o.subscription=null,o.timetoken=t.timetoken,o.message=function(e,t){var r=e.config,n=e.crypto;if(!r.cipherKey)return t;try{return n.decrypt(t)}catch(e){return t}}(e,t.message),r.channels[n].push(o)})}),r};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getOperation=function(){return o.default.PNSubscribeOperation},t.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},t.getURL=function(e,t){var r=e.config,n=t.channels,o=void 0===n?[]:n,u=o.length>0?o.join(","):",";return"/v2/subscribe/"+r.subscribeKey+"/"+i.default.encodeString(u)+"/0"},t.getRequestTimeout=function(e){return e.config.getSubscribeTimeout()},t.isAuthSupported=function(){return!0},t.prepareParams=function(e,t){var r=e.config,n=t.channelGroups,o=void 0===n?[]:n,i=t.timetoken,u=t.filterExpression,s=t.region,a={heartbeat:r.getPresenceTimeout()};return o.length>0&&(a["channel-group"]=o.join(",")),u&&u.length>0&&(a["filter-expr"]=u),i&&(a.tt=i),s&&(a.tr=s),a},t.handleResponse=function(e,t){var r=[];t.m.forEach(function(e){var t={publishTimetoken:e.p.t,region:e.p.r},n={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};r.push(n)});var n={timetoken:t.t.t,region:t.t.r};return{messages:r,metadata:n}};var o=n((r(5),r(13))),i=n(r(15))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var r=0;r=this._maxSubDomain&&(this._currentSubDomain=1),e=this._currentSubDomain.toString(),this._providedFQDN.replace("pubsub","ps"+e)}},{key:"hasModule",value:function(e){return e in this._modules}},{key:"shiftStandardOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._standardOrigin=this.nextOrigin(e),this._standardOrigin}},{key:"getStandardOrigin",value:function(){return this._standardOrigin}},{key:"POST",value:function(e,t,r,n){return this._modules.post(e,t,r,n)}},{key:"GET",value:function(e,t,r){return this._modules.get(e,t,r)}},{key:"DELETE",value:function(e,t,r){return this._modules.del(e,t,r)}},{key:"_detectErrorCategory",value:function(e){if("ENOTFOUND"===e.code)return i.default.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return i.default.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return i.default.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return i.default.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return i.default.PNNetworkIssuesCategory;if(e.timeout)return i.default.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return i.default.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return i.default.PNBadRequestCategory;if(e.response.forbidden)return i.default.PNAccessDeniedCategory}return i.default.PNUnknownCategory}}]),e}());t.default=u,e.exports=t.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={get:function(e){try{return localStorage.getItem(e)}catch(e){return null}},set:function(e,t){try{return localStorage.setItem(e,t)}catch(e){return null}}},e.exports=t.default},function(e,t,r){"use strict";function n(e){var t=(new Date).getTime(),r=(new Date).toISOString(),n=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;n.log("<<<<<"),n.log("["+r+"]","\n",e.url,"\n",e.qs),n.log("-----"),e.on("response",function(r){var o=(new Date).getTime()-t,i=(new Date).toISOString();n.log(">>>>>>"),n.log("["+i+" / "+o+"]","\n",e.url,"\n",e.qs,"\n",r.text),n.log("-----")})}function o(e,t,r){var o=this;return this._config.logVerbosity&&(e=e.use(n)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e)),e.timeout(t.timeout).end(function(e,n){var i={};if(i.error=null!==e,i.operation=t.operation,n&&n.status&&(i.statusCode=n.status),e){if(e.response&&e.response.text&&!o._config.logVerbosity)try{i.errorData=JSON.parse(e.response.text)}catch(t){i.errorData=e}else i.errorData=e;return i.category=o._detectErrorCategory(e),r(i,null)}var u=JSON.parse(n.text);return u.error&&1===u.error&&u.status&&u.message&&u.service?(i.errorData=u,i.statusCode=u.status,i.error=!0,i.category=o._detectErrorCategory(i),r(i,null)):r(i,u)})}Object.defineProperty(t,"__esModule",{value:!0}),t.get=function(e,t,r){var n=i.default.get(this.getStandardOrigin()+t.url).query(e);return o.call(this,n,t,r)},t.post=function(e,t,r,n){var u=i.default.post(this.getStandardOrigin()+r.url).query(e).send(t);return o.call(this,u,r,n)},t.del=function(e,t,r){var n=i.default.delete(this.getStandardOrigin()+t.url).query(e);return o.call(this,n,t,r)};var i=function(e){return e&&e.__esModule?e:{default:e}}(r(42));r(5)},function(e,t,r){function n(){}function o(e){if(!d(e))return e;var t=[];for(var r in e)i(t,r,e[r]);return t.join("&")}function i(e,t,r){if(null!=r)if(Array.isArray(r))r.forEach(function(r){i(e,t,r)});else if(d(r))for(var n in r)i(e,t+"["+n+"]",r[n]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));else null===r&&e.push(encodeURIComponent(t))}function u(e){for(var t,r,n={},o=e.split("&"),i=0,u=o.length;i=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||b.serialize[o?o.split(";")[0]:""];!i&&s(o)&&(i=b.serialize["application/json"]),i&&(r=i(r))}for(var u in this.header)null!=this.header[u]&&this.header.hasOwnProperty(u)&&t.setRequestHeader(u,this.header[u]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},b.agent=function(){return new v},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(e){v.prototype[e.toLowerCase()]=function(t,r){var n=new b.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}}),v.prototype.del=v.prototype.delete,b.get=function(e,t,r){var n=b("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},b.head=function(e,t,r){var n=b("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},b.options=function(e,t,r){var n=b("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},b.del=l,b.delete=l,b.patch=function(e,t,r){var n=b("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},b.post=function(e,t,r){var n=b("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},b.put=function(e,t,r){var n=b("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n,o=0;o=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~i.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},n.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},n.prototype.then=function(e,t){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(e,t){r.end(function(r,n){r?t(r):e(n)})})}return this._fullfilledPromise.then(e,t)},n.prototype.catch=function(e){return this.then(void 0,e)},n.prototype.use=function(e){return e(this),this},n.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},n.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},n.prototype.get=function(e){return this._header[e.toLowerCase()]},n.prototype.getHeader=n.prototype.get,n.prototype.set=function(e,t){if(o(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},n.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},n.prototype.field=function(e,t){if(null===e||void 0===e)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()"),o(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var n in t)this.field(e,t[n]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},n.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)},n.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},n.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},n.prototype.redirects=function(e){return this._maxRedirects=e,this},n.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},n.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},n.prototype.send=function(e){var t=o(e),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()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&o(this._data))for(var n in e)this._data[n]=e[n];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},n.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},n.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},n.prototype._appendQueryString=function(){console.trace("Unsupported")},n.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},n.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},function(e,t){"use strict";e.exports=function(e){return null!==e&&"object"==typeof e}},function(e,t,r){"use strict";function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}var o=r(47);e.exports=n,n.prototype.get=function(e){return this.header[e.toLowerCase()]},n.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=o.type(t);var r=o.params(t);for(var n in r)this[n]=r[n];this.links={};try{e.link&&(this.links=o.parseLinks(e.link))}catch(e){}},n.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},function(e,t){"use strict";t.type=function(e){return e.split(/ *; */).shift()},t.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(e[n]=o),e},{})},t.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e},{})},t.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},function(e,t){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(e){r.prototype[e]=function(){return this._defaults.push({fn:e,arguments:arguments}),this}}),r.prototype._setDefaults=function(e){this._defaults.forEach(function(t){e[t.fn].apply(e,t.arguments)})},e.exports=r}])},e.exports=n()},function(e,t,r){e.exports=r(441)},function(e,t,r){var n=r(39),o=r(156),i=r(65),u=o(function(e,t){n(t,i(t),e)});e.exports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveServiceFacade=void 0;var n=r(7),o=r(110);function i(){var e=n.Client.sharedInstance();return(0,o.getLiveService)(e)}t.LiveServiceFacade={onConnectionStatusUpdates:function(e){i().onConnectionStatusUpdates(e)},offConnectionStatusUpdates:function(e){i().offConnectionStatusUpdates(e)},isInitialized:function(){return i().isInitialized()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:24,t="abcdef0123456789",r="",n=0,o=t.length;n=0},t.formTaggedCollectionName=function(e,t){if(t)return""+e+c+t;return e},t.stripTagFromCollectionName=function(e){return e.split(c)[0]},t.getTagFromCollectionName=function(e){return e.split(c)[1]};var o,i=r(36),u=(o=i)&&o.__esModule?o:{default:o},s=r(1),a=r(3);var c=t.dataStoreTagSeparator="."},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseQueueByKey=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._queuesByKey={},this._simultaneousOpsCount=t,this._maxQueueLength=r}return n(e,[{key:"enqueue",value:function(e,t){return this._queuesByKey[e]||(this._queuesByKey[e]=new o.PromiseQueue(this._simultaneousOpsCount,this._maxQueueLength)),this._queuesByKey[e].enqueue(t)}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeyValueStoreOfflineRepository=void 0;var n=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]&&arguments[3],l=s[this._databaseName],f='"'+t+'"',h=t===u.webSqlCollectionsMaster,p=Array.isArray(r);return r=p?r:[[r,n]],new o.Promise(function(n,o){try{l||(l=e.openDatabase(a._databaseName,1,"Kinvey Cache",u.webSqlDatabaseSize),s[a._databaseName]=l);var d=c||"function"!=typeof l.readTransaction;l[d?"transaction":"readTransaction"](function(e){c&&!h&&e.executeSql("CREATE TABLE IF NOT EXISTS "+f+" (key BLOB PRIMARY KEY NOT NULL, value BLOB NOT NULL)");var t=r.length,o=[];0===t?n(p?o:o.shift()):r.forEach(function(r){var i=r[0].replace("#{collection}",f);e.executeSql(i,r[1],function(e,r){var i=[];if(r.rows.length>0)for(var u=0,s=r.rows.length;u1&&void 0!==arguments[1]&&arguments[1],r=arguments[2],n=this,o=arguments[3],u=arguments.length>4&&void 0!==arguments[4]&&arguments[4],l=c[this._storeName];if((0,s.isDefined)(l))if("function"==typeof l.objectStoreNames.contains?l.objectStoreNames.contains(e):-1!==l.objectStoreNames.indexOf(e))try{var f=t?a.inedxedDbTransctionMode.readWrite:a.inedxedDbTransctionMode.readOnly,h=l.transaction(e,f);if((0,s.isDefined)(h))return r(h);throw new i.KinveyError("Unable to open a transaction for "+e+" collection on the "+this._storeName+" IndexedDB database.")}catch(e){return o(e)}else if(!1===t)return o(new i.NotFoundError("The "+e+" collection was not found on the "+this._storeName+" IndexedDB database."));if(!1===u&&this.inTransaction)return this.queue.push(function(){n._openTransaction(e,t,r,o)});this.inTransaction=!0;var p=void 0;try{p=this._openDb()}catch(e){o(e)}return p.onupgradeneeded=function(r){l=r.target.result,c[n._storeName]=l,!0===t&&l.createObjectStore(e,{keyPath:"_id"})},p.onsuccess=function(i){l=i.target.result,c[n._storeName]=l,l.onversionchange=function(){(0,s.isDefined)(l)&&(l.close(),l=null,c[n._storeName]=null)};var u=function(e){return function(t){if(e(t),n.inTransaction=!1,n.queue.length>0){var r=n.queue;n.queue=[],r.forEach(function(e){e.call(n)})}}};return n._openTransaction(e,t,u(r),u(o),!0)},p.onblocked=function(){},p.onerror=function(e){o(new Error("Unable to open the "+n._storeName+" IndexedDB database. "+e.target.error.message+"."))},p}},{key:"_upsertEntities",value:function(e,t){var r=this,n=!Array.isArray(t);return 0===(t=(0,s.ensureArray)(t)).length?o.Promise.resolve(null):new o.Promise(function(o,u){r._openTransaction(e,!0,function(s){var a=s.objectStore(e);t.forEach(function(e){a.put(e)}),s.oncomplete=function(){o(n?t[0]:t)},s.onerror=function(t){u(new i.KinveyError("An error occurred while saving the entities to the "+e+" collection on the "+r._storeName+" IndexedDB database. "+t.target.error.message+"."))}},u)})}},{key:"_getIndexedDbObj",value:function(){return e.indexedDB||e.webkitIndexedDB||e.mozIndexedDB||e.msIndexedDB}},{key:"_openDb",value:function(){var e=c[this._storeName],t=this._getIndexedDbObj();if((0,s.isDefined)(e)){var r=e.version+1;return e.close(),t.open(this._storeName,r)}return t.open(this._storeName)}},{key:"_getDb",value:function(){var e=this,t=c[this._storeName];return t?o.Promise.resolve(t):new o.Promise(function(t,r){var n=function(e){var r=e.target.result;t(r)},o=e._openDb();o.onupgradeneeded=n,o.onsuccess=n,o.onerror=function(e){return r(e)}})}}]),r}()}).call(t,r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserKeyValuePersister=void 0;var n=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:y.Cache,r=arguments[2],n=void 0,o=r&&"tag"in r;if(!1===(0,a.isDefined)(e)||!1===(0,u.default)(e))throw new s.KinveyError("A collection is required and must be a string.");if(o&&!(0,d.isValidDataStoreTag)(r.tag))throw new s.KinveyError("Please provide a valid data store tag.");switch(t){case y.Network:if(o)throw new s.KinveyError('The tagged option is not valid for data stores of type "Network"');var i=h.processorFactory.getNetworkProcessor();n=new c.NetworkStore(e,i,r);break;case y.Sync:var p=h.processorFactory.getOfflineProcessor();n=new f.SyncStore(e,p,r);break;case y.Cache:default:var v=h.processorFactory.getCacheOfflineDataProcessor();n=new l.CacheStore(e,v,r)}return n}},{key:"getInstance",value:function(e,t,r){return this.collection(e,t,r)}},{key:"clearCache",value:function(){return p.repositoryProvider.getOfflineRepository().then(function(e){return e.clear()}).then(function(){return null})}}]),e}();t.DataStore=v},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomString=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:18;return""+(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")+function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n2&&void 0!==arguments[2]?arguments[2]:{},f=n.default.parse(e,!0),h=(0,a.default)(t)?o.default.parse(t):t,p=(0,i.default)({},f.query,h);r=(0,i.default)({encodeComponents:!0,removeNull:!1},r),f.query=null;var d=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n=arguments[2];var o=[];var i=!1;(0,u.default)(t)&&(0,l.isDefined)(n)&&(i=!0);Object.keys(t).forEach(function(u){var a=void 0,c=t[u],f=n?n+"["+(i?"":u)+"]":u;if(!1===(0,l.isDefined)(c)){if(!0===r.removeNull)return;a=!0===r.encodeComponents?encodeURIComponent(f):f}else a=(0,s.default)(c)?e(c,r,f):r.encodeComponents?encodeURIComponent(f)+"="+encodeURIComponent(c):f+"="+c;o.push(a)});return o.join("&")}(p,r);return f.search=(0,l.isDefined)(d)&&!1===(0,c.default)(d)?"?"+d:null,n.default.format(f)};var n=f(r(23)),o=f(r(104)),i=f(r(15)),u=f(r(6)),s=f(r(49)),a=f(r(9)),c=f(r(36)),l=r(123);function f(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.User=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=t,this.client=r.client||l.Client.sharedInstance()}return n(e,[{key:"isActive",value:function(){var t=e.getActiveUser(this.client);return!(!(0,v.isDefined)(t)||t._id!==this._id)}},{key:"isEmailVerified",value:function(){return"confirmed"===this.metadata.emailVerification}},{key:"login",value:function(t,r){var n=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=t,l=this.isActive(),p=e.getActiveUser(this.client);return!0===l?o.default.reject(new h.ActiveUserError("This user is already the active user.")):(0,v.isDefined)(p)?o.default.reject(new h.ActiveUserError("An active user already exists. Please logout the active user before you login.")):((0,s.default)(a)?u=r||{}:a={username:t,password:r},(0,v.isDefined)(a.username)&&(a.username=String(a.username).trim()),(0,v.isDefined)(a.password)&&(a.password=String(a.password).trim()),(0,v.isDefined)(a.username)&&""!==a.username&&(0,v.isDefined)(a.password)&&""!==a.password||(0,v.isDefined)(a._socialIdentity)?new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.App,url:c.default.format({protocol:this.client.apiProtocol,host:this.client.apiHost,pathname:this.pathname+"/login"}),body:a,properties:u.properties,timeout:u.timeout,client:this.client}).execute().then(function(e){return e.data}).then(function(e){(0,v.isDefined)(a._socialIdentity)&&(0,v.isDefined)(e._socialIdentity)&&(Object.keys(e._socialIdentity).forEach(function(t){e._socialIdentity[t]=(0,i.default)({},a._socialIdentity[t],e._socialIdentity[t])}),e._socialIdentity=(0,i.default)({},a._socialIdentity,e._socialIdentity));return delete e.password,n.client.setActiveUser(e)}).then(function(e){return n.data=e,n}):o.default.reject(new h.KinveyError("Username and/or password missing. Please provide both a username and password to login.")))}},{key:"loginWithMIC",value:function(t,r){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=this.isActive(),s=e.getActiveUser(this.client);return u?o.default.reject(new h.ActiveUserError("This user is already the active user.")):(0,v.isDefined)(s)?o.default.reject(new h.ActiveUserError("An active user already exists. Please logout the active user before you login.")):new d.MobileIdentityConnect({client:this.client}).login(t,r,i).then(function(e){return n.connectIdentity(d.MobileIdentityConnect.identity,e,i)})}},{key:"connectIdentity",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=this.isActive(),i={},u=i._socialIdentity||{};return u[e]=t,i._socialIdentity=u,o?this.update(i,n):this.login(i,n).catch(function(o){if(o instanceof h.NotFoundError)return r.signup(i,n).then(function(){return r.connectIdentity(e,t,n)});throw o})}},{key:"disconnectIdentity",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=o.default.resolve();return e===d.MobileIdentityConnect.identity&&(n=d.MobileIdentityConnect.logout(this,r)),n.catch(function(e){y.Log.error(e)}).then(function(){var n=t.data,o=n._socialIdentity||{};return delete o[e],n._socialIdentity=o,t.data=n,t._id?t.update(n,r):t}).then(function(){return t})}},{key:"logout",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.Session,url:c.default.format({protocol:this.client.apiProtocol,host:this.client.apiHost,pathname:this.pathname+"/_logout"}),properties:t.properties,timeout:t.timeout,client:this.client});return this.unregisterFromLiveService().then(function(){return r.execute()}).catch(function(e){return y.Log.error(e),null}).then(function(){return e.client.setActiveUser(null)}).catch(function(e){return y.Log.error(e),null}).then(function(){return p.DataStore.clearCache({client:e.client})}).catch(function(e){return y.Log.error(e),null}).then(function(){return e})}},{key:"signup",value:function(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e.getActiveUser(this.client);if(!0===(n=(0,i.default)({state:!0},n)).state&&(0,v.isDefined)(o))throw new h.ActiveUserError("An active user already exists. Please logout the active user before you login.");return t instanceof e&&(t=t.data),t=(0,i.default)(this.data,t),new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.App,url:c.default.format({protocol:this.client.apiProtocol,host:this.client.apiHost,pathname:this.pathname}),body:(0,a.default)(t)?null:t,properties:n.properties,timeout:n.timeout,client:this.client}).execute().then(function(e){return e.data}).then(function(e){return!0===n.state?r.client.setActiveUser(e):e}).then(function(e){return r.data=e,r})}},{key:"signupWithIdentity",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={_socialIdentity:{}};return n._socialIdentity[e]=t,this.signup(n,r)}},{key:"update",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e=(0,i.default)(this.data,e),(new m.UserStore).update(e,r).then(function(e){return delete e.password,t.isActive()?(e._socialIdentity&&(e._socialIdentity=(0,w.mergeSocialIdentity)(t._socialIdentity,e._socialIdentity)),t.client.setActiveUser(e)):e}).then(function(e){return t.data=e,t})}},{key:"me",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new f.KinveyRequest({method:f.RequestMethod.GET,authType:f.AuthType.Session,url:c.default.format({protocol:this.client.apiProtocol,host:this.client.apiHost,pathname:this.pathname+"/_me"}),properties:t.properties,timeout:t.timeout}).execute().then(function(e){return e.data}).then(function(t){return delete t.password,e.isActive()?(t._socialIdentity&&(t._socialIdentity=(0,w.mergeSocialIdentity)(e._socialIdentity,t._socialIdentity)),e.client.setActiveUser(t)):t}).then(function(t){return e.data=t,e})}},{key:"registerForLiveService",value:function(){var e=(0,_.getLiveService)(this.client),t=o.default.resolve();return e.isInitialized()||(t=e.fullInitialization(this)),t}},{key:"unregisterFromLiveService",value:function(){var e=(0,_.getLiveService)(this.client),t=o.default.resolve();return e.isInitialized()&&(t=e.fullUninitialization()),t}},{key:"_id",get:function(){return this.data._id}},{key:"_acl",get:function(){return new b.Acl(this.data)}},{key:"metadata",get:function(){return new g.Metadata(this.data)}},{key:"_kmd",get:function(){return this.metadata}},{key:"_socialIdentity",get:function(){return this.data._socialIdentity}},{key:"authtoken",get:function(){return this.metadata.authtoken}},{key:"username",get:function(){return this.data.username}},{key:"email",get:function(){return this.data.email}},{key:"pathname",get:function(){return"/user/"+this.client.appKey}}],[{key:"login",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new e({},n).login(t,r,n)}},{key:"loginWithMIC",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new this({},r).loginWithMIC(e,t,r)}},{key:"connectIdentity",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new this({},r).connectIdentity(e,t,r)}},{key:"logout",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.getActiveUser(t.client);return(0,v.isDefined)(r)?r.logout(t):o.default.resolve(null)}},{key:"signup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new this({},t).signup(e,t)}},{key:"signupWithIdentity",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new this({},r).signupWithIdentity(e,t,r)}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.getActiveUser(r.client);return(0,v.isDefined)(n)?n.update(t,r):o.default.resolve(null)}},{key:"registerForLiveService",value:function(){var t=e.getActiveUser();return t?t.registerForLiveService():o.default.reject(new h.ActiveUserError("There is no active user"))}},{key:"unregisterFromLiveService",value:function(){var t=e.getActiveUser();return t?t.unregisterFromLiveService():o.default.reject(new h.ActiveUserError("There is no active user"))}},{key:"me",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.getActiveUser(t.client);return r?r.me(t):o.default.resolve(null)}},{key:"getActiveUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l.Client.sharedInstance(),t=e.getActiveUser();return(0,v.isDefined)(t)?new this(t,{client:e}):null}},{key:"verifyEmail",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return o.default.reject(new h.KinveyError("A username was not provided.","Please provide a username for the user that you would like to verify their email."));if(!(0,u.default)(e))return o.default.reject(new h.KinveyError("The provided username is not a string."));var r=t.client||l.Client.sharedInstance();return new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.App,url:c.default.format({protocol:r.apiProtocol,host:r.apiHost,pathname:"/rpc/"+r.appKey+"/"+e+"/user-email-verification-initiate"}),properties:t.properties,timeout:t.timeout,client:r}).execute().then(function(e){return e.data})}},{key:"forgotUsername",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return o.default.reject(new h.KinveyError("An email was not provided.","Please provide an email for the user that you would like to retrieve their username."));if(!(0,u.default)(e))return o.default.reject(new h.KinveyError("The provided email is not a string."));var r=t.client||l.Client.sharedInstance();return new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.App,url:c.default.format({protocol:r.apiProtocol,host:r.apiHost,pathname:"/rpc/"+r.appKey+"/user-forgot-username"}),properties:t.properties,data:{email:e},timeout:t.timeout,client:r}).execute().then(function(e){return e.data})}},{key:"resetPassword",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return o.default.reject(new h.KinveyError("A username was not provided.","Please provide a username for the user that you would like to verify their email."));if(!(0,u.default)(e))return o.default.reject(new h.KinveyError("The provided username is not a string."));var r=t.client||l.Client.sharedInstance();return new f.KinveyRequest({method:f.RequestMethod.POST,authType:f.AuthType.App,url:c.default.format({protocol:r.apiProtocol,host:r.apiHost,pathname:"/rpc/"+r.appKey+"/"+e+"/user-password-reset-initiate"}),properties:t.properties,timeout:t.timeout,client:r}).execute().then(function(e){return e.data})}},{key:"lookup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new m.UserStore).lookup(e,t)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new m.UserStore).exists(e,t)}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new m.UserStore).removeById(e,t)}},{key:"restore",value:function(){return o.default.reject(new h.KinveyError("This function requires a master secret to be provided for your application. We strongly advise not to do this."))}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MobileIdentityConnect=t.AuthorizationGrant=void 0;var n=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:v.AuthorizationCodeLoginPage,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!(0,i.default)(e))return o.default.reject(new c.KinveyError("A redirectUri is required and must be a string."));var s=this.client.appKey;return(0,i.default)(u.micId)&&(s=s+"."+u.micId),o.default.resolve().then(function(){if(!n||n===v.AuthorizationCodeLoginPage)return r.requestCodeWithPopup(s,e,u);if(n===v.AuthorizationCodeAPI)return r.requestTempLoginUrl(s,e,u).then(function(t){return r.requestCodeWithUrl(t,s,e,u)});throw new c.KinveyError("The authorization grant "+n+" is unsupported. Please use a supported authorization grant.")}).then(function(t){return r.requestToken(t,s,e,u)}).then(function(n){return n.identity=t.identity,n.client_id=s,n.redirect_uri=e,n.protocol=r.client.micProtocol,n.host=r.client.micHost,n})}},{key:"refresh",value:function(e,r,n){var i=this,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return o.default.resolve().then(function(){return i.refreshToken(e,r,n,u)}).then(function(e){return e.identity=t.identity,e.client_id=r,e.redirect_uri=n,e.protocol=i.client.micProtocol,e.host=i.client.micHost,e})}},{key:"requestTempLoginUrl",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new a.KinveyRequest({method:a.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},url:u.default.format({protocol:this.client.micProtocol,host:this.client.micHost,pathname:this._getMicPath(r)}),properties:r.properties,body:{client_id:e,redirect_uri:t,response_type:"code"}}).execute().then(function(e){return e.data.temp_login_uri})}},{key:"parseCode",value:function(e){if("string"==typeof e)return u.default.parse(e,!0).query.code}},{key:"requestCodeWithPopup",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o.default.resolve().then(function(){return(new y).open(u.default.format({protocol:r.client.micProtocol,host:r.client.micHost,pathname:r._getMicPath(n),query:{client_id:e,redirect_uri:t,response_type:"code",scope:"openid"}}))}).then(function(e){return new o.default(function(r,n){var o=!1,i=function(i){try{if(i.url&&0===i.url.toLowerCase().indexOf(t.toLowerCase())&&!1===o){var s=u.default.parse(i.url,!0).query||{};o=!0,e.removeAllListeners(),e.close(),s.code?r(s.code):s.error?n(new c.KinveyError(s.error,s.error_description)):n(new c.KinveyError("The redirect uri did not contain a code or error."))}}catch(e){}};e.on("loadstart",i),e.on("loadstop",i),e.on("error",function(i){try{if(i.url&&0===i.url.toLowerCase().indexOf(t.toLowerCase())&&!1===o){var s=u.default.parse(i.url,!0).query||{};o=!0,e.removeAllListeners(),e.close(),s.code?r(s.code):s.error?n(new c.KinveyError(s.error,s.error_description)):n(new c.KinveyError("The redirect uri did not contain a code or error."))}else!1===o&&(e.removeAllListeners(),e.close(),n(new c.KinveyError(i.message,"",i.code)))}catch(e){}}),e.on("exit",function(){!1===o&&(e.removeAllListeners(),n(new c.KinveyError("Login has been cancelled.")))})})})}},{key:"requestCodeWithUrl",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return o.default.resolve().then(function(){return new a.KinveyRequest({method:a.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},url:e,properties:i.properties,body:{client_id:t,redirect_uri:r,response_type:"code",username:i.username,password:i.password,scope:"openid"},followRedirect:!1}).execute()}).then(function(e){var t=e.headers.get("location");if(t)return n.parseCode(t);throw new c.MobileIdentityConnectError("Unable to authorize user with username "+i.username+".","A location header was not provided with a code to exchange for an auth token.")})}},{key:"requestToken",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new a.KinveyRequest({method:a.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},authType:a.AuthType.Client,url:u.default.format({protocol:this.client.micProtocol,host:this.client.micHost,pathname:"/oauth/token"}),properties:n.properties,body:{grant_type:"authorization_code",client_id:t,redirect_uri:r,code:e},clientId:t}).execute().then(function(e){return e.data})}},{key:"refreshToken",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new a.KinveyRequest({method:a.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},authType:a.AuthType.Client,url:u.default.format({protocol:this.client.micProtocol,host:this.client.micHost,pathname:"/oauth/token"}),body:{grant_type:"refresh_token",client_id:t,redirect_uri:r,refresh_token:e},clientId:t,properties:n.properties,timeout:n.timeout}).execute().then(function(e){return e.data})}},{key:"logout",value:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];return o.default.resolve()}},{key:"identity",get:function(){return p.SocialIdentity.MobileIdentityConnect}}],[{key:"isSupported",value:function(){return!0}},{key:"usePopupClass",value:function(e){(0,l.isDefined)(e)&&(y=e)}},{key:"identity",get:function(){return p.SocialIdentity.MobileIdentityConnect}}]),t}()},function(e,t,r){var n,o,i;i=function(){return function(){var e=arguments;"object"==typeof arguments[0]&&(e=arguments[0],arguments[1]);var t,r=[].slice.call(e,0).join("/");return t=(t=(t=function(e,t){return e.substr(0,t.length)===t}(t=r,"file://")?t.replace(/(\/{0,3})\/*/g,"$1"):(t=t.replace(/:\//g,"://")).replace(/([^:\s\%\3\A])\/+/g,"$1/")).replace(/\/(\?|&|#[^!])/g,"$1")).replace(/(\?.+)\?/g,"$1&")}},void 0!==e&&e.exports?e.exports=i():void 0===(o="function"==typeof(n=i)?n.call(t,r,t,e):n)||(e.exports=o)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Popup=void 0;var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.client=t.client||o.Client.sharedInstance()}return n(e,[{key:"isSupported",value:function(){return!1}},{key:"isOnline",value:function(e){var t=(new Date).getTime()/1e3;return e&&e.access_token&&e.expires>t}},{key:"identity",get:function(){throw new i.KinveyError("A subclass must override this property.")}}],[{key:"isSupported",value:function(){return!1}},{key:"identity",get:function(){throw new i.KinveyError("A subclass must override this property.")}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserStore=void 0;var n=function(){function e(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};if((0,h.isDefined)(e)&&!(e instanceof p.Query)){return(0,f.wrapInObservable)(o.default.reject(new l.KinveyError("Invalid query. It must be an instance of the Query class.")))}var r=new c.KinveyRequest({method:c.RequestMethod.POST,authType:c.AuthType.Default,url:s.default.format({protocol:this._client.apiProtocol,host:this._client.apiHost,pathname:this.pathname+"/_lookup"}),properties:t.properties,body:(0,h.isDefined)(e)?e.toPlainObject().filter:null,timeout:t.timeout,client:this._client}).execute().then(function(e){return e.data});return(0,f.wrapInObservable)(r)}},{key:"create",value:function(){return o.default.reject(new l.KinveyError("Please use `User.signup()` to create a user."))}},{key:"update",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?(0,i.default)(e)?o.default.reject(new l.KinveyError("Only one user can be updated at one time.",e)):e._id?!1===(0,h.isDefined)(e)?o.default.resolve(null):new c.KinveyRequest({method:c.RequestMethod.PUT,authType:c.AuthType.Default,url:s.default.format({protocol:this._client.apiProtocol,host:this._client.apiHost,pathname:this.pathname+"/"+e._id}),properties:t.properties,data:e,timeout:t.timeout,client:this._client}).execute().then(function(e){return e.data}):o.default.reject(new l.KinveyError("User must have an _id.")):o.default.reject(new l.KinveyError("No user was provided to be updated."))}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new c.KinveyRequest({method:c.RequestMethod.POST,authType:c.AuthType.App,url:s.default.format({protocol:this._client.apiProtocol,host:this._client.apiHost,pathname:"/rpc/"+this._client.appKey+"/check-username-exists"}),properties:t.properties,data:{username:e},timeout:t.timeout,client:this._client}).execute().then(function(e){return e.data}).then(function(){return!0===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).usernameExists})}},{key:"removeById",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return f.KinveyObservable.create(function(n){return!1===(0,h.isDefined)(e)?n.error(new l.KinveyError("An id was not provided.","Please provide a valid id for a user that you would like to remove.")):!1===(0,u.default)(e)?n.error(new l.KinveyError("The id provided is not a string.","Please provide a valid id for a user that you would like to remove.")):new c.KinveyRequest({method:c.RequestMethod.DELETE,authType:c.AuthType.Default,url:s.default.format({protocol:t._client.apiProtocol,host:t._client.apiHost,pathname:t.pathname+"/"+e,query:!0===r.hard?{hard:!0}:void 0}),properties:r.properties,timeout:r.timeout}).execute().then(function(e){return e.data}).then(function(e){return n.next(e)}).then(function(){return n.complete()}).catch(function(e){return n.error(e)})}).toPromise()}},{key:"pathname",get:function(){return"/user/"+this._client.appKey}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeSocialIdentity=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=JSON.parse(JSON.stringify(e)),n=JSON.parse(JSON.stringify(t));return Object.keys(n).reduce(function(e,t){return e[t]=Object.assign(n[t],r[t]),e},n)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CustomEndpoint=void 0;var n=function(){function e(e,t){for(var r=0;r2&&void 0!==arguments[2]?arguments[2]:{},n=r.client||a.Client.sharedInstance();return e?(0,i.default)(e)?new c.KinveyRequest({method:c.RequestMethod.POST,authType:c.AuthType.Default,url:u.default.format({protocol:n.apiProtocol,host:n.apiHost,pathname:"/rpc/"+n.appKey+"/custom/"+e}),properties:r.properties,body:t,timeout:r.timeout,client:n}).execute().then(function(e){return e.data}):o.default.reject(new s.KinveyError("The endpoint argument must be a string.")):o.default.reject(new s.KinveyError("An endpoint argument is required."))}}]),e}()},function(e,t,r){var n=r(109),o=r(106),i=r(475),u=r(6);e.exports=function(e,t){return(u(e)?n:i)(e,o(t,3))}},function(e,t,r){var n=r(68),o=r(30);e.exports=function(e,t){var r=-1,i=o(e)?Array(e.length):[];return n(e,function(e,n,o){i[++r]=t(e,n,o)}),i}},function(e,t,r){"use strict";r(477),r(478),r(496),r(501)},function(e,t,r){"use strict";function n(e){return e!=e}Object.defineProperty(t,"__esModule",{value:!0}),t.isNaN=n,Number.isNaN=Number.isNaN||n},function(e,t,r){"use strict";r(479),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),n=1;na;)n(s,r=t[a++])&&(~i(c,r)||c.push(r));return c}},function(e,t,r){var n=r(207),o=r(210),i=r(484);e.exports=function(e){return function(t,r,u){var s,a=n(t),c=o(a.length),l=i(u,c);if(e&&r!=r){for(;c>l;)if((s=a[l++])!=s)return!0}else for(;c>l;l++)if((e||l in a)&&a[l]===r)return e||l||0;return!e&&-1}}},function(e,t,r){var n=r(211),o=Math.max,i=Math.min;e.exports=function(e,t){return(e=n(e))<0?o(e+t,0):i(e,t)}},function(e,t,r){var n=r(212)("keys"),o=r(118);e.exports=function(e){return n[e]||(n[e]=o(e))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,r){var n=r(119),o=r(40),i=r(122);e.exports=function(e,t){var r=(o.Object||{})[e]||Object[e],u={};u[e]=t(r),n(n.S+n.F*i(function(){r(1)}),"Object",u)}},function(e,t,r){var n=r(489),o=r(490),i=r(492),u=Object.defineProperty;t.f=r(121)?Object.defineProperty:function(e,t,r){if(n(e),t=i(t,!0),n(r),o)try{return u(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t,r){var n=r(82);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t,r){e.exports=!r(121)&&!r(122)(function(){return 7!=Object.defineProperty(r(491)("div"),"a",{get:function(){return 7}}).a})},function(e,t,r){var n=r(82),o=r(54).document,i=n(o)&&n(o.createElement);e.exports=function(e){return i?o.createElement(e):{}}},function(e,t,r){var n=r(82);e.exports=function(e,t){if(!n(e))return e;var r,o;if(t&&"function"==typeof(r=e.toString)&&!n(o=r.call(e)))return o;if("function"==typeof(r=e.valueOf)&&!n(o=r.call(e)))return o;if(!t&&"function"==typeof(r=e.toString)&&!n(o=r.call(e)))return o;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,r){var n=r(54),o=r(120),i=r(206),u=r(118)("src"),s=Function.toString,a=(""+s).split("toString");r(40).inspectSource=function(e){return s.call(e)},(e.exports=function(e,t,r,s){var c="function"==typeof r;c&&(i(r,"name")||o(r,"name",t)),e[t]!==r&&(c&&(i(r,u)||o(r,u,e[t]?""+e[t]:a.join(String(t)))),e===n?e[t]=r:s?e[t]?e[t]=r:o(e,t,r):(delete e[t],o(e,t,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||s.call(this)})},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,r){r(497),e.exports=r(40).Array.find},function(e,t,r){"use strict";var n=r(119),o=r(214)(5),i=!0;"find"in[]&&Array(1).find(function(){i=!1}),n(n.P+n.F*i,"Array",{find:function(e){return o(this,e,arguments.length>1?arguments[1]:void 0)}}),r(216)("find")},function(e,t,r){var n=r(499);e.exports=function(e,t){return new(n(e))(t)}},function(e,t,r){var n=r(82),o=r(500),i=r(215)("species");e.exports=function(e){var t;return o(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!o(t.prototype)||(t=void 0),n(t)&&null===(t=t[i])&&(t=void 0)),void 0===t?Array:t}},function(e,t,r){var n=r(209);e.exports=Array.isArray||function(e){return"Array"==n(e)}},function(e,t,r){r(502),e.exports=r(40).Array.findIndex},function(e,t,r){"use strict";var n=r(119),o=r(214)(6),i="findIndex",u=!0;i in[]&&Array(1)[i](function(){u=!1}),n(n.P+n.F*u,"Array",{findIndex:function(e){return o(this,e,arguments.length>1?arguments[1]:void 0)}}),r(216)(i)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StorageProvider=t.Files=void 0;var n=r(504);Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var o=r(509);Object.defineProperty(t,"Files",{enumerable:!0,get:function(){return o.Files}});var i,u=r(510),s=(i=u)&&i.__esModule?i:{default:i},a=r(22);r(518);var c=a.repositoryProvider.getSupportedStorages();t.StorageProvider=(0,s.default)(a.StorageProvider,c)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=h,t.initialize=function(e){try{var t=h(e),r=a.User.getActiveUser(t);return(0,u.isDefined)(r)?i.default.resolve(r):l.repositoryProvider.getOfflineRepository().then(function(e){return e.read(f)}).then(function(e){return e.length>0?e[0]:null}).then(function(e){return(0,u.isDefined)(e)?(0,u.isDefined)(e.data)?t.setActiveUser(e.data):t.setActiveUser(e):e}).then(function(){return a.User.getActiveUser(t)})}catch(e){return i.default.reject(e)}};var n,o=r(2),i=(n=o)&&n.__esModule?n:{default:n},u=r(3),s=r(1),a=r(116),c=r(217),l=r(22);var f="kinvey_active_user";function h(e){if(!(0,u.isDefined)(e.appKey))throw new s.KinveyError("No App Key was provided. Unable to create a new Client without an App Key.");if(!(0,u.isDefined)(e.appSecret)&&!(0,u.isDefined)(e.masterSecret))throw new s.KinveyError("No App Secret or Master Secret was provided. Unable to create a new Client without an App Secret.");return c.Html5Client.init(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryStorage=t.CookieStorage=t.isSupported=t.storage=void 0;var n=u(r(506)),o=u(r(218)),i=u(r(508));function u(e){return e&&e.__esModule?e:{default:e}}var s=null;(0,n.default)("localStorage")?t.storage=s=window.localStorage:(0,n.default)("sessionStorage")?t.storage=s=window.sessionStorage:(0,n.default)("cookieStorage")?t.storage=s=new o.default:t.storage=s=new i.default,t.default=s,t.storage=s,t.isSupported=n.default,t.CookieStorage=o.default,t.MemoryStorage=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"localStorage",t=String(e).replace(/storage$/i,"").toLowerCase();if("local"===t)return i("localStorage");if("session"===t)return i("sessionStorage");if("cookie"===t)return(0,n.hasCookies)();if("memory"===t)return!0;throw new Error("Storage method `"+e+"` is not available.\n Please use one of the following: localStorage, sessionStorage, cookieStorage, memoryStorage.")};var n=r(218),o="__test";function i(e){try{var t=window[e];return t.setItem(o,"1"),t.removeItem(o),!0}catch(e){return!1}}},function(e,t,r){"use strict";t.parse=function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var r={},o=t||{},u=e.split(i),a=o.decode||n,c=0;c1&&void 0!==arguments[1]?arguments[1]:{},o=arguments[2];return t instanceof e.Blob||(0,u.default)(t)?(n=Object.assign({size:t.size||t.length},n),function e(t,r,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in o)return o.value;var u=o.get;return void 0!==u?u.call(n):void 0}(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"upload",this).call(this,t,n,o)):Promise.reject(new a.KinveyError("File must be an instance of a Blob or the content of the file as a string."))}}]),r}();t.Files=new c}).call(t,r(11))},function(e,t,r){var n=r(511),o=r(514)(function(e,t){return null==e?{}:n(e,t)});e.exports=o},function(e,t,r){var n=r(512),o=r(181);e.exports=function(e,t){return n(e,t,function(t,r){return o(e,r)})}},function(e,t,r){var n=r(107),o=r(513),i=r(75);e.exports=function(e,t,r){for(var u=-1,s=t.length,a={};++u0&&i(l)?r>1?e(l,r-1,i,u,s):n(s,l):u||(s[s.length]=l)}return s}},function(e,t,r){var n=r(37),o=r(58),i=r(6),u=n?n.isConcatSpreadable:void 0;e.exports=function(e){return i(e)||o(e)||!!(u&&e&&e[u])}},function(e,t,r){"use strict";(function(e){var t,n=r(217),o=r(22);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=(i(t={},o.StorageProvider.WebSQL,function(e){var t=new o.WebSqlSqlModule(n.Html5Client.sharedInstance().appKey),r=new o.SqlKeyValueStorePersister(t);return new o.KeyValueStoreOfflineRepository(r,e)}),i(t,o.StorageProvider.IndexedDB,function(e){var t=new o.IndexedDbKeyValueStorePersister;return new o.KeyValueStoreOfflineRepository(t,e)}),i(t,o.StorageProvider.LocalStorage,function(t){var r=new o.BrowserKeyValuePersister(e.localStorage);return new o.InmemoryOfflineRepository(r,t)}),i(t,o.StorageProvider.SessionStorage,function(t){var r=new o.BrowserKeyValuePersister(e.sessionStorage);return new o.InmemoryOfflineRepository(r,t)}),t);o.repositoryProvider.setSupportedRepoBuilders(u)}).call(t,r(11))},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.Html5HttpMiddleware=void 0;var n=function(){function e(e,t){for(var r=0;r0&&(l=setTimeout(function(){if(!s){s=!0,c.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),c.setRequestHeader)for(u in d)d.hasOwnProperty(u)&&c.setRequestHeader(u,d[u]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(c.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(c),c.send(p||null),c}e.exports=a,a.XMLHttpRequest=n.XMLHttpRequest||function(){},a.XDomainRequest="withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:n.XDomainRequest,function(e,t){for(var r=0;r=3&&(u=r),"[object Array]"===o.call(e)?function(e,t,r){for(var n=0,o=e.length;n0&&void 0!==arguments[0]?arguments[0]:"/",n=this,o=e.open(r,"_blank","toolbar=no,location=no");if(!o)throw new Error("The popup was blocked.");var i=e.setInterval(function(){if(o.closed)e.clearInterval(i),t.emit("exit");else try{var r={url:o.location.href};t.emit("loadstart",r),t.emit("load",r)}catch(r){r.code!==e.DOMException.SECURITY_ERR&&-1!==r.message.indexOf("Permission Denied")&&t.emit("error",r)}},100);return{on:function(){return n.on.apply(n,arguments)},close:function(){return o&&!o.closed&&o.close(),this},removeAllListeners:function(){return n.removeAllListeners.apply(n,arguments)}}}}],[{key:"open",value:function(e){return(new r).open(e)}}]),r}()}).call(t,r(11))},function(e,t){e.exports={private:!0,version:"3.12.2",name:"kinvey-html5-sdk",description:"Kinvey JavaScript SDK for HTML5 applications.",author:"Kinvey, Inc.",homepage:"http://www.kinvey.com",license:"Apache-2.0",main:"kinvey-html5-sdk.min.js",scripts:{prebuild:"rm -rf dist",build:"webpack --config webpack.config.js",release:"npm run build -- --env.uglify && ./scripts/push.sh",postrelease:"rm -rf tmp",s3:"npm run build -- --env.uglify --env.s3"},files:["kinvey-html5-sdk.min.js","kinvey-html5-sdk.min.js.map"]}}])});
//# sourceMappingURL=kinvey-html5-sdk-3.12.2.min.js.map