1?n[o-1]:void 0,u=o>2?n[2]:void 0;for(a=e.length>3&&"function"==typeof a?(o--,a):void 0,u&&i(n[0],n[1],u)&&(a=o<3?void 0:a,o=1),t=Object(t);++r=l){var v=t?null:s(e);if(v)return c(v);h=!1,f=u,y=new o}else y=t?[]:d;e:for(;++r",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(h),y=["'"].concat(d),v=["%","/","?",";","#"].concat(y),m=["/","?","#"],b={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_=n(231);r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=r!==-1&&r127?"x":A[C];if(!R.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var I=T.slice(0,E),M=T.slice(E+1),N=A.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);N&&(I.push(N[1]),M.unshift(N[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=I.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),P||(this.hostname=s.toASCII(this.hostname));var D=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+D,this.href+=this.host,P&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!b[h])for(var E=0,S=y.length;E0)&&n.host.split("@");k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!E.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var x=E.slice(-1)[0],P=(n.host||e.host||E.length>1)&&("."===x||".."===x)||""===x,T=0,S=E.length;S>=0;S--)x=E[S],"."===x?E.splice(S,1):".."===x?(E.splice(S,1),T++):T&&(E.splice(S,1),T--);if(!_&&!O)for(;T--;T)E.unshift("..");!_||""===E[0]||E[0]&&"/"===E[0].charAt(0)||E.unshift(""),P&&"/"!==E.join("/").substr(-1)&&E.push("");var A=""===E[0]||E[0]&&"/"===E[0].charAt(0);if(j){n.hostname=n.host=A?"":E.length?E.shift():"";var k=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");k&&(n.auth=k.shift(),n.host=n.hostname=k.shift())}return _=_||n.host&&E.length,_&&!A&&E.unshift(""),E.length?n.pathname=E.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=f.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){var r;(function(e,o){!function(i){function a(e){throw RangeError(C[e])}function u(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function s(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(R,"."),r+u(e.split("."),t).join(".")}function c(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(e-=65536,t+=M(e>>>10&1023|55296),e=56320|1023&e),t+=M(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:_}function p(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?I(e/k):e>>1,e+=I(e/t);e>q*E>>1;r+=_)e=I(e/q);return I(r+(q+1)*e/(e+j))}function d(e){var t,n,r,o,i,u,s,c,p,d,y=[],v=e.length,m=0,b=P,g=x;for(n=e.lastIndexOf(T),n<0&&(n=0),r=0;r=128&&a("not-basic"),y.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=v&&a("invalid-input"),c=f(e.charCodeAt(o++)),(c>=_||c>I((w-m)/u))&&a("overflow"),m+=c*u,p=s<=g?O:s>=g+E?E:s-g,!(cI(w/d)&&a("overflow"),u*=d;t=y.length+1,g=h(m-i,t,0==i),I(m/t)>w-b&&a("overflow"),b+=I(m/t),m%=t,y.splice(m++,0,b)}return l(y)}function y(e){var t,n,r,o,i,u,s,l,f,d,y,v,m,b,g,j=[];for(e=c(e),v=e.length,t=P,n=0,i=x,u=0;u=t&&yI((w-n)/m)&&a("overflow"),n+=(s-t)*m,t=s,u=0;uw&&a("overflow"),y==t){for(l=n,f=_;d=f<=i?O:f>=i+E?E:f-i,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},q=_-O,I=Math.floor,M=String.fromCharCode;g={version:"1.3.2",ucs2:{decode:c,encode:l},decode:d,encode:y,toASCII:m,toUnicode:v},void 0!==(r=function(){return g}.call(t,n,t,e))&&(e.exports=r)}()}).call(t,n(155)(e),function(){return this}())},function(e,t){"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,n){"use strict";t.decode=t.parse=n(232),t.encode=t.stringify=n(233)},function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,o){t=t||"&",r=r||"=";var i={};if("string"!=typeof e||0===e.length)return i;e=e.split(t);var a=1e3;o&&"number"==typeof o.maxKeys&&(a=o.maxKeys);var u=e.length;a>0&&u>a&&(u=a);for(var s=0;s=0?(c=h.substr(0,d),l=h.substr(d+1)):(c=h,l=""),f=decodeURIComponent(c),p=decodeURIComponent(l),n(i,f)?Array.isArray(i[f])?i[f].push(p):i[f]=[i[f],p]:i[f]=p}return i}},function(e,t){"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,o){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(o){var i=encodeURIComponent(n(o))+r;return Array.isArray(e[o])?e[o].map(function(e){return i+encodeURIComponent(n(e))}).join(t):i+encodeURIComponent(n(e[o]))}).join(t):o?encodeURIComponent(n(o))+r+encodeURIComponent(n(e)):""}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Storage=t.StatusCode=t.SerializeMiddleware=t.Response=t.RequestMethod=t.Rack=t.Properties=t.ParseMiddleware=t.NetworkRequest=t.NetworkRack=t.Middleware=t.MemoryAdapter=t.KinveyResponse=t.KinveyRequest=t.HttpMiddleware=t.Headers=t.DeltaFetchRequest=t.CacheRequest=t.CacheRack=t.CacheMiddleware=t.AuthType=void 0;var o=n(235),i=r(o),a=n(320),u=r(a),s=n(294),c=r(s),l=n(322),f=r(l),p=n(285),h=r(p),d=n(293),y=r(d),v=n(296),m=r(v),b=n(301),g=r(b);t.AuthType=l.AuthType,t.CacheMiddleware=b.CacheMiddleware,t.CacheRack=v.CacheRack,t.CacheRequest=i.default,t.DeltaFetchRequest=u.default,t.Headers=c.default,t.HttpMiddleware=b.HttpMiddleware,t.KinveyRequest=l.KinveyRequest,t.KinveyResponse=d.KinveyResponse,t.MemoryAdapter=b.MemoryAdapter,t.Middleware=g.default,t.NetworkRack=v.NetworkRack,t.NetworkRequest=f.default,t.ParseMiddleware=b.ParseMiddleware,t.Properties=l.Properties,t.Rack=m.default,t.RequestMethod=p.RequestMethod,t.Response=y.default,t.SerializeMiddleware=b.SerializeMiddleware,t.StatusCode=d.StatusCode,t.Storage=b.Storage,t.default=h.default},function(e,t,n){(function(e,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 u(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)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.aggregation=e.aggregation,n.query=e.query,n.rack=C.CacheRack,n}return u(t,e),s(t,[{key:"execute",value:function(){var e=this;return l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"execute",this).call(this).then(function(t){if(t instanceof R.KinveyResponse||(t=new R.KinveyResponse({statusCode:t.statusCode,headers:t.headers,data:t.data})),!t.isSuccess())throw t.error;return(0,T.isDefined)(e.query)&&(0,T.isDefined)(t.data)&&(t.data=e.query.process(t.data)),(0,T.isDefined)(e.aggregation)&&(0,T.isDefined)(t.data)&&(t.data=e.aggregation.process(t.data)),t})}},{key:"toPlainObject",value:function(){var e=l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"toPlainObject",this).call(this);return e.appKey=this.appKey,e.collection=this.collection,e.entityId=this.entityId,e.encryptionKey=this.client?this.client.encryptionKey:void 0,e}},{key:"body",get:function(){return this._body},set:function(e){this._body=(0,w.default)(e)}},{key:"query",get:function(){return this._query},set:function(e){if((0,T.isDefined)(e)&&!(e instanceof k.default))throw new E.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,T.isDefined)(e)&&!(e instanceof P.default))throw new E.KinveyError("Invalid aggregation. It must be an instance of the Aggregation class.");this._aggregation=e}},{key:"url",get:function(){return l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",this)},set:function(e){c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",e,this);var n=r.escape(v.default.parse(e).pathname),o=new d.default("(/:namespace)(/)(:appKey)(/)(:collection)(/)(:entityId)(/)"),i=o.match(n)||{},a=i.appKey,u=i.collection,s=i.entityId;this.appKey=a,this.collection=u,this.entityId=s}}],[{key:"loadActiveUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance();return new t({method:S.RequestMethod.GET,url:v.default.format({protocol:e.protocol,host:e.host,pathname:"/"+q+"/"+e.appKey+"/"+I})}).execute().then(function(e){return e.data}).then(function(e){return e.length>0?e[0]:null}).then(function(n){if((0,T.isDefined)(n)===!1){var r=t.loadActiveUserLegacy(e);return t.setActiveUser(e,r)}return n}).then(function(t){return M[e.appKey]=t,t})}},{key:"loadActiveUserLegacy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance(),n=t.getActiveUserLegacy(e);return M[e.appKey]=n,n}},{key:"getActiveUser",value:function(){return M[(arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance()).appKey]}},{key:"getActiveUserLegacy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance();try{return b.default.get(e.appKey+"kinvey_user")}catch(e){return null}}},{key:"setActiveUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance(),n=arguments[1],r=p.default.resolve(null),o=t.getActiveUser(e);if((0,T.isDefined)(o)){t.setActiveUserLegacy(e,null),M[e.appKey]=null;r=new t({method:S.RequestMethod.DELETE,url:v.default.format({protocol:e.protocol,host:e.host,pathname:"/"+q+"/"+e.appKey+"/"+I+"/"+o._id})}).execute().then(function(e){return e.data}).catch(function(e){if(e instanceof E.NotFoundError)return null;throw e})}return r.then(function(){return(0,T.isDefined)(n)===!1?null:(delete n.password,M[e.appKey]=n,t.setActiveUserLegacy(e,n),new t({method:S.RequestMethod.POST,url:v.default.format({protocol:e.protocol,host:e.host,pathname:"/"+q+"/"+e.appKey+"/"+I}),body:n}).execute().then(function(e){return e.data}))}).then(function(){return n})}},{key:"setActiveUserLegacy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.default.sharedInstance(),t=arguments[1];try{return b.default.remove(e.appKey+"kinvey_user"),(0,T.isDefined)(t)&&b.default.set(e.appKey+"kinvey_user",t),!0}catch(e){return!1}}}]),t}(A.default);t.default=N}).call(t,n(47),function(){return this}())},function(e,t,n){var r,o,i,a=[].slice;!function(a,u){null!=n(237)?(o=[],r=u,!(void 0!==(i="function"==typeof r?r.apply(t,o):r)&&(e.exports=i))):void 0!==t&&null!==t?e.exports=u():a.UrlPattern=u()}(this,function(){var e,t,n,r,o,i,u,s,c,l,f,p,h,d,y;return c=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},u=function(e,t){var n,r,o;for(o=[],n=-1,r=e.length;++ni))return a=Array.isArray(u)?u[o]:u,r&&(n[t]=o+1),a;if(r)throw new Error("too few values provided for key `"+t+"`")}else if(r)throw new Error("no values provided for key `"+t+"`")},n=function(e,t,r){var o,i;if(Array.isArray(e)){for(o=-1,i=e.length;++o1?n.splice(n.indexOf(t),1):a[e]=[]}var a={},u=!1;e.exports={on:o,off:i}}).call(t,function(){return this}())},function(e,t,n){function r(e){return o(e,i|a)}var o=n(242),i=1,a=4;e.exports=r},function(e,t,n){function r(e,t,n,R,C,q){var I,M=t&E,N=t&j,D=t&k;if(n&&(I=C?n(e,R,C,q):n(e)),void 0!==I)return I;if(!_(e))return e;var U=g(e);if(U){if(I=v(e),!M)return l(e,I)}else{var L=y(e),K=L==P||L==T;if(w(e))return c(e,M);if(L==S||L==x||K&&!C){if(I=N||K?{}:b(e),!M)return N?p(e,s(I,e)):f(e,u(I,e))}else{if(!A[L])return C?e:{};I=m(e,L,r,M)}}q||(q=new o);var F=q.get(e);if(F)return F;q.set(e,I);var B=D?N?d:h:N?keysIn:O,H=U?void 0:B(e);return i(H||e,function(o,i){H&&(i=o,o=e[i]),a(I,i,r(o,t,n,i,e,q))}),I}var o=n(131),i=n(243),a=n(205),u=n(244),s=n(245),c=n(249),l=n(250),f=n(251),p=n(252),h=n(146),d=n(255),y=n(167),v=n(256),m=n(257),b=n(268),g=n(127),w=n(154),_=n(86),O=n(151),E=1,j=2,k=4,x="[object Arguments]",P="[object Function]",T="[object GeneratorFunction]",S="[object Object]",A={};A[x]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object DataView]"]=A["[object Boolean]"]=A["[object Date]"]=A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Map]"]=A["[object Number]"]=A[S]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object Symbol]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Error]"]=A[P]=A["[object WeakMap]"]=!1,e.exports=r},function(e,t){function n(e,t){for(var n=-1,r=null==e?0:e.length;++n0&&void 0!==arguments[0]?arguments[0]:{};if(o(this,e),t=(0,c.default)({apiHostname:"https://baas.kinvey.com",micHostname:"https://auth.kinvey.com",liveServiceHostname:"https://kls.kinvey.com"},t),t.apiHostname&&(0,f.default)(t.apiHostname)){var n=u.default.parse(t.apiHostname);t.apiProtocol=n.protocol||"https:",t.apiHost=n.host}if(t.micHostname&&(0,f.default)(t.micHostname)){var r=u.default.parse(t.micHostname);t.micProtocol=r.protocol||"https:",t.micHost=r.host}if(t.liveServiceHostname&&(0,f.default)(t.liveServiceHostname)){var i=u.default.parse(t.liveServiceHostname);t.liveServiceProtocol=i.protocol||"https:",t.liveServiceHost=i.host}this.apiProtocol=t.apiProtocol,this.apiHost=t.apiHost,this.micProtocol=t.micProtocol,this.micHost=t.micHost,this.liveServiceProtocol=t.liveServiceProtocol,this.liveServiceHost=t.liveServiceHost,this.appKey=t.appKey,this.appSecret=t.appSecret,this.masterSecret=t.masterSecret,this.encryptionKey=t.encryptionKey,this.appVersion=t.appVersion,this.defaultTimeout=(0,y.isDefined)(t.defaultTimeout)?t.defaultTimeout:m}return i(e,[{key:"toPlainObject",value:function(){return{apiHostname:this.apiHostname,apiProtocol:this.apiProtocol,apiHost:this.apiHost,micHostname:this.micHostname,micProtocol:this.micProtocol,micHost:this.micHost,liveServiceHostname:this.liveServiceHostname,liveServiceHost:this.liveServiceHost,liveServiceProtocol:this.liveServiceProtocol,appKey:this.appKey,appSecret:this.appSecret,masterSecret:this.masterSecret,encryptionKey:this.encryptionKey,appVersion:this.appVersion}}},{key:"activeUser",get:function(){return v.CacheRequest.getActiveUser(this)}},{key:"apiHostname",get:function(){return u.default.format({protocol:this.apiProtocol,host:this.apiHost})}},{key:"baseUrl",get:function(){return this.apiHostname}},{key:"protocol",get:function(){return this.apiProtocol}},{key:"host",get:function(){return this.apiHost}},{key:"micHostname",get:function(){return u.default.format({protocol:this.micProtocol,host:this.micHost})}},{key:"liveServiceHostname",get:function(){return u.default.format({protocol:this.liveServiceProtocol,host:this.liveServiceHost})}},{key:"appVersion",get:function(){return this._appVersion},set:function(e){e&&!(0,f.default)(e)&&(e=String(e)),this._appVersion=e}},{key:"defaultTimeout",get:function(){return this._defaultTimeout},set:function(e){if(e=parseInt(e,10),(0,h.default)(e)===!1||isNaN(e))throw new d.KinveyError("Invalid timeout. Timeout must be a number.");e<0&&(y.Log.info("Default timeout is less than 0. Setting default timeout to "+m+"ms."),e=m),this._defaultTimeout=e}}],[{key:"init",value:function(t){var n=new e(t);return b=n,v.CacheRequest.loadActiveUserLegacy(n),n}},{key:"initialize",value:function(t){var n=new e(t);return b=n,v.CacheRequest.loadActiveUser(n).then(function(){return n})}},{key:"sharedInstance",value:function(){if(!b)throw new d.KinveyError("You have not initialized the library. Please call Kinvey.init() to initialize the library.");return b}}]),e}();t.default=g}).call(t,n(47))},function(e,t,n){function r(e){return"string"==typeof e||!i(e)&&a(e)&&o(e)==u}var o=n(80),i=n(127),a=n(126),u="[object String]";e.exports=r},function(e,t,n){function r(e){return"number"==typeof e||i(e)&&o(e)==a}var o=n(80),i=n(126),a="[object Number]";e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:0;if((0,m.default)(t)&&(t=parseFloat(t)),(0,m.default)(n)&&(n=parseFloat(n)),!(0,y.default)(t))throw new a.QueryError("divisor must be a number");if(!(0,y.default)(n))throw new a.QueryError("remainder must be a number");return this.addFilter(e,"$mod",[t,n])}},{key:"matches",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if((0,_.default)(t)||(t=new RegExp(t)),(t.ignoreCase||n.ignoreCase)&&n.ignoreCase!==!1)throw new a.QueryError("ignoreCase flag is not supported.");if(0!==t.source.indexOf("^"))throw new a.QueryError("regExp must have `^` at the beginning of the expression to make it an anchored expression.");var r=[];(t.multiline||n.multiline)&&n.multiline!==!1&&r.push("m"),n.extended&&r.push("x"),n.dotMatchesAll&&r.push("s");var o=this.addFilter(e,"$regex",t.source);return r.length&&this.addFilter(e,"$options",r.join("")),o}},{key:"near",value:function(e,t,n){if(!(0,h.default)(t)||!(0,y.default)(t[0])||!(0,y.default)(t[1]))throw new a.QueryError("coord must be a [number, number]");var r=this.addFilter(e,"$nearSphere",[t[0],t[1]]);return(0,y.default)(n)&&this.addFilter(e,"$maxDistance",n),r}},{key:"withinBox",value:function(e,t,n){if(!(0,h.default)(t)||!(0,y.default)(t[0])||!(0,y.default)(t[1]))throw new a.QueryError("bottomLeftCoord must be a [number, number]");if(!(0,h.default)(n)||!(0,y.default)(n[0])||!(0,y.default)(n[1]))throw new a.QueryError("upperRightCoord must be a [number, number]");t[0]=parseFloat(t[0]),t[1]=parseFloat(t[1]),n[0]=parseFloat(n[0]),n[1]=parseFloat(n[1]);var r=[[t[0],t[1]],[n[0],n[1]]];return this.addFilter(e,"$within",{$box:r})}},{key:"withinPolygon",value:function(e,t){if(!(0,h.default)(t)||t.length>3)throw new a.QueryError("coords must be [[number, number]]");return t=t.map(function(e){if(!e[0]||!e[1])throw new a.QueryError("coords argument must be [number, number]");return[parseFloat(e[0]),parseFloat(e[1])]}),this.addFilter(e,"$within",{$polygon:t})}},{key:"size",value:function(e,t){if((0,m.default)(t)&&(t=parseFloat(t)),!(0,y.default)(t))throw new a.QueryError("size must be a number");return this.addFilter(e,"$size",t)}},{key:"ascending",value:function(e){return(0,u.isDefined)(this._parent)?this._parent.ascending(e):this.sort[e]=1,this}},{key:"descending",value:function(e){return(0,u.isDefined)(this._parent)?this._parent.descending(e):this.sort[e]=-1,this}},{key:"addFilter",value:function(e,t,n){return(0,g.default)(this.filter[e])||(this.filter[e]={}),(0,u.isDefined)(t)&&(0,u.isDefined)(n)?this.filter[e][t]=n:this.filter[e]=t,this}},{key:"join",value:function(t,n){var r=this,o=this,i={};n=n.map(function(t){if(!(t instanceof e)){if(!(0,g.default)(t))throw new a.QueryError("query argument must be of type: Kinvey.Query[] or Object[].");t=new e(t)}return t.toJSON().filter}),0===n.length&&(o=new e,n=[o.toJSON().filter],o.parent=this);var u=Object.keys(this.filter);return(0,k.default)(u,function(e){i[e]=r.filter[e],delete r.filter[e]}),this.filter[t]=[i].concat(n),o}},{key:"process",value:function(e){if(this.isSupportedOffline()===!1){var t="This query is not able to run locally. The following filters are not supported locally:";throw(0,k.default)(A,function(e){t=t+" "+e}),new a.QueryError(t)}if(!(0,h.default)(e))throw new a.QueryError("data argument must be of type: Array.");var n=this.toJSON();return e=(0,c.default)(n.filter,e),(0,h.default)(n.fields)&&n.fields.length>0&&(e=e.map(function(e){var t=Object.keys(e);return(0,k.default)(t,function(t){n.fields.indexOf(t)===-1&&delete e[t]}),e})),(0,u.isDefined)(n.sort)&&e.sort(function(e,t){for(var r in n.sort)if(n.sort.hasOwnProperty(r)){var o=(0,u.nested)(e,r),i=(0,u.nested)(t,r);if((0,u.isDefined)(o)&&(0,u.isDefined)(i)===!1)return-1;if((0,u.isDefined)(i)&&(0,u.isDefined)(o)===!1)return 1;if(o!==i){var a=n.sort[r];return(o0?e.slice(n.skip,n.skip+n.limit):e.slice(n.skip):e}},{key:"toPlainObject",value:function(){return(0,u.isDefined)(this._parent)?this._parent.toPlainObject():{fields:this.fields,filter:this.filter,sort:this.sort,skip:this.skip,limit:this.limit}}},{key:"toJSON",value:function(){return this.toPlainObject()}},{key:"toQueryString",value:function(){var e={};(0,E.default)(this.filter)||(e.query=this.filter),(0,E.default)(this.fields)||(e.fields=this.fields.join(",")),(0,y.default)(this.limit)&&(e.limit=this.limit),(0,y.default)(this.skip)&&this.skip>0&&(e.skip=this.skip),(0,E.default)(this.sort)||(e.sort=this.sort);var t=Object.keys(e);return(0,k.default)(t,function(t){e[t]=(0,m.default)(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||[],!(0,h.default)(e))throw new a.QueryError("fields must be an Array");(0,u.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,g.default)(e))throw new a.QueryError("sort must an Object");(0,u.isDefined)(this._parent)?this._parent.sort(e):this._sort=e||{}}},{key:"limit",get:function(){return this._limit},set:function(e){if((0,m.default)(e)&&(e=parseFloat(e)),(0,u.isDefined)(e)&&!(0,y.default)(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(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if((0,m.default)(e)&&(e=parseFloat(e)),!(0,y.default)(e))throw new a.QueryError("skip must be a number");(0,u.isDefined)(this._parent)?this._parent.skip(e):this._skip=e}}]),e}();t.default=R},function(e,t){!function(){"use strict";function t(e){return"function"==typeof e}function n(e){return"[object Array]"===Object.prototype.toString.call(e)}function r(e){return e instanceof Date?e.getTime():e instanceof Array?e.map(r):e}function o(e,t){return e.get?e.get(t):e[t]}function i(e){return function(t,r){if(!n(r)||!r.length)return e(t,r);for(var i=0,a=r.length;i0}),$gte:i(function(e,t){return d.compare(r(t),e)>=0}),$lt:i(function(e,t){return d.compare(r(t),e)<0}),$lte:i(function(e,t){return d.compare(r(t),e)<=0}),$mod:i(function(e,t){return t%e[0]==e[1]}),$in:function(e,t){if(!(t instanceof Array))return!!~e.indexOf(r(t));for(var n=t.length;n--;)if(~e.indexOf(r(o(t,n))))return!0;return!1},$nin:function(e,t){return!y.$in(e,t)},$not:function(e,t){return!a(e,t)},$type:function(e,t){return void 0!=t&&(t instanceof e||t.constructor==e)},$all:function(e,t){return y.$and(e,t)},$size:function(e,t){return!!t&&e===t.length},$nor:function(e,t){for(var n=0,r=e.length;nt)return 1;if(e0&&void 0!==arguments[0]?arguments[0]:[],t=this.toJSON(),n=Object.keys(t.key),r=t.reduceFn.replace(/function[\s\S]*?\([\s\S]*?\)/,"");if(t.reduce=new Function(["doc","out"],r),this.query&&(e=this.query.process(e)),n.length>0){var o=[];return n.forEach(function(n){var r={};e.forEach(function(e){var o=e[n],i=(0,g.isDefined)(r[o])?r[o]:(0,m.default)(t.initial),a=t.reduce(e,i);(0,g.isDefined)(a)&&(i=a),r[o]=i}),Object.keys(r).forEach(function(e){var t={};t[n]=e,t=(0,u.default)({},t,r[e]),o.push(t)})}),o}var i=(0,m.default)(t.initial);return(0,c.default)(e,function(e){var n=t.reduce(e,i);(0,g.isDefined)(n)&&(i=n)}),[i]}},{key:"toJSON",value:function(){return{key:this.key,initial:this.initial,reduce:this.reduceFn,reduceFn:this.reduceFn,condition:this.query?this.query.toJSON().filter:{},query:this.query?this.query.toJSON():null}}},{key:"initial",get:function(){return(0,m.default)(this._initial)},set:function(e){if(!(0,h.default)(e))throw new b.KinveyError("initial must be an Object.");this._initial=e}},{key:"query",get:function(){return this._query},set:function(e){if((0,g.isDefined)(e)&&!(e instanceof w.Query))throw new b.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,y.default)(e)&&(e=e.toString()),!(0,f.default)(e))throw new b.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 n=new e;return n.by(t),n.initial={count:0},n.reduceFn="function(doc, out) { out.count += 1; return out;}",n}},{key:"sum",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var n=new e;return n.initial={sum:0},n.reduceFn='function(doc, out) { out.sum += doc["'+t+'"]; return out;}',n}},{key:"min",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var n=new e;return n.initial={min:1/0},n.reduceFn='function(doc, out) { out.min = Math.min(out.min, doc["'+t+'"]); return out;}',n}},{key:"max",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var n=new e;return n.initial={max:-(1/0)},n.reduceFn='function(doc, out) { out.max = Math.max(out.max, doc["'+t+'"]); return out;}',n}},{key:"average",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace("'","\\'");var n=new e;return n.initial={count:0,average:0},n.reduceFn='function(doc, out) { out.average = (out.average * out.count + doc["'+t+'"]) / (out.count + 1); out.count += 1; return out;}',n}}]),e}();t.default=_},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.RequestMethod=void 0;var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),t=(0,h.default)({followRedirect:!0},t),this.client=t.client,this.method=t.method||x.GET,this.headers=t.headers||new k.default,this.url=t.url||"",this.body=t.body||t.data,this.timeout=(0,_.isDefined)(t.timeout)?t.timeout:this.client.defaultTimeout,this.followRedirect=t.followRedirect===!0,this.cache=t.cache===!0,this.executing=!1}return i(e,[{key:"isExecuting",value:function(){return!!this.executing}},{key:"execute",value:function(){return this.rack?this.rack.execute(this.toPlainObject()).then(function(e){if(!e)throw new w.NoResponseError;return e instanceof E.default||(e=new E.default({statusCode:e.statusCode,headers:e.headers,data:e.data})),e}):u.default.reject(new w.KinveyError("Unable to execute the request. Please provide a rack to execute the request."))}},{key:"cancel",value:function(){return this.rack.cancel()}},{key:"toPlainObject",value:function(){return{method:this.method,headers:this.headers.toPlainObject(),url:this.url,body:this.body,timeout:this.timeout,followRedirect:this.followRedirect}}},{key:"client",get:function(){return this._client||g.default.sharedInstance()},set:function(e){if(e&&!(e instanceof g.default))throw new w.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,y.default)(e)||(e=String(e)),e=e.toUpperCase()){case x.GET:case x.POST:case x.PATCH:case x.PUT:case x.DELETE:this._method=e;break;default:throw new w.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 k.default||(e=new k.default(e)),this._headers=e}},{key:"url",get:function(){return this.cache===!0?(0,f.default)(this._url,c.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),(0,m.default)(e)===!1||isNaN(e))throw new w.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}();t.default=P},function(e,t,n){"use strict";var r=n(287),o=n(290),i=n(289);e.exports={formats:i,parse:o,stringify:r}},function(e,t,n){"use strict";var r=n(288),o=n(289),i={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},a=Date.prototype.toISOString,u={delimiter:"&",encode:!0,encoder:r.encode,encodeValuesOnly:!1,serializeDate:function(e){return a.call(e)},skipNulls:!1,strictNullHandling:!1},s=function e(t,n,o,i,a,u,s,c,l,f,p,h){var d=t;if("function"==typeof s)d=s(n,d);else if(d instanceof Date)d=f(d);else if(null===d){if(i)return u&&!h?u(n):n;d=""}if("string"==typeof d||"number"==typeof d||"boolean"==typeof d||r.isBuffer(d)){if(u){return[p(h?n:u(n))+"="+p(u(d))]}return[p(n)+"="+p(String(d))]}var y=[];if(void 0===d)return y;var v;if(Array.isArray(s))v=s;else{var m=Object.keys(d);v=c?m.sort(c):m}for(var b=0;b=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?n+=t.charAt(o):i<128?n+=r[i]:i<2048?n+=r[192|i>>6]+r[128|63&i]:i<55296||i>=57344?n+=r[224|i>>12]+r[128|i>>6&63]+r[128|63&i]:(o+=1,i=65536+((1023&i)<<10|1023&t.charCodeAt(o)),n+=r[240|i>>18]+r[128|i>>12&63]+r[128|i>>6&63]+r[128|63&i])}return n},t.compact=function(e,n){if("object"!=typeof e||null===e)return e;var r=n||[],o=r.indexOf(e);if(o!==-1)return r[o];if(r.push(e),Array.isArray(e)){for(var i=[],a=0;a=0&&n.parseArrays&&a<=n.arrayLimit?(r=[],r[a]=u(e,t,n)):r[i]=u(e,t,n)}return r},s=function(e,t,n){if(e){var r=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,s=i.exec(r),c=s?r.slice(0,s.index):r,l=[];if(c){if(!n.plainObjects&&o.call(Object.prototype,c)&&!n.allowPrototypes)return;l.push(c)}for(var f=0;null!==(s=a.exec(r))&&f0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),t=(0,l.default)({statusCode:d.Empty,headers:new h.default,data:null},t),this.statusCode=t.statusCode,this.headers=t.headers,this.data=t.data}return s(e,[{key:"isSuccess",value:function(){return this.statusCode>=200&&this.statusCode<300||this.statusCode===d.MovedPermanently||this.statusCode===d.Found||this.statusCode===d.NotModified||this.statusCode===d.TemporaryRedirect||this.statusCode===d.PermanentRedirect}},{key:"headers",get:function(){return this._headers},set:function(e){e instanceof h.default||(e=new h.default(e)),this._headers=e}},{key:"error",get:function(){if(this.isSuccess())return null;var e=this.data||{},t=e.message||e.description,n=e.debug,r=this.statusCode,o=this.headers.get("X-Kinvey-Request-ID");return r===d.Unauthorized?new f.InsufficientCredentialsError(t,n,r,o):r===d.NotFound?new f.NotFoundError(t,n,r,o):r===d.ServerError?new f.ServerError(t,n,r,o):new f.KinveyError(t,n,r,o)}}]),e}();t.default=y;t.KinveyResponse=function(e){function t(){return a(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),s(t,[{key:"error",get:function(){if(this.isSuccess())return null;var e=this.data||{},n=e.name||e.error,r=e.message||e.description,o=e.debug,i=this.statusCode,a=this.headers.get("X-Kinvey-Request-ID"),s=void 0
;if("APIVersionNotAvailable"===n)s=new f.APIVersionNotAvailableError(r,o,i,a);else if("APIVersionNotImplemented"===n)s=new f.APIVersionNotImplementedError(r,o,i,a);else if("AppProblem"===n)s=new f.AppProblemError(r,o,i,a);else if("AppProblem"===n)s=new f.AppProblemError(r,o,i,a);else if("BadRequest"===n)s=new f.BadRequestError(r,o,i,a);else if("BLInternalError"===n||"BLRuntimeError"===n||"BLSyntaxError"===n||"BLTimeoutError"===n||"BLViolationError"===n)s=new f.BLError(r,o,i,a);else if("CORSDisabled"===n)s=new f.CORSDisabledError(r,o,i,a);else if("DuplicateEndUsers"===n)s=new f.DuplicateEndUsersError(r,o,i,a);else if("FeatureUnavailable"===n)s=new f.FeatureUnavailableError(r,o,i,a);else if("IncompleteRequestBody"===n)s=new f.IncompleteRequestBodyError(r,o,i,a);else if("IndirectCollectionAccessDisallowed"===n)s=new f.IndirectCollectionAccessDisallowedError(r,o,i,a);else if("InsufficientCredentials"===n)s=new f.InsufficientCredentialsError(r,o,i,a);else if("InvalidCredentials"===n)s=new f.InvalidCredentialsError(r,o,i,a);else if("InvalidIdentifier"===n)s=new f.InvalidIdentifierError(r,o,i,a);else if("InvalidQuerySyntax"===n)s=new f.InvalidQuerySyntaxError(r,o,i,a);else if("JSONParseError"===n)s=new f.JSONParseError(r,o,i,a);else if("KinveyInternalErrorRetry"===n)s=new f.KinveyInternalErrorRetry(r,o,i,a);else if("KinveyInternalErrorStop"===n)s=new f.KinveyInternalErrorStop(r,o,i,a);else if("MissingQuery"===n)s=new f.MissingQueryError(r,o,i,a);else if("MissingRequestHeader"===n)s=new f.MissingRequestHeaderError(r,o,i,a);else if("MissingRequestParameter"===n)s=new f.MissingRequestParameterError(r,o,i,a);else if("EntityNotFound"===n||"CollectionNotFound"===n||"AppNotFound"===n||"UserNotFound"===n||"BlobNotFound"===n||"DocumentNotFound"===n)s=new f.NotFoundError(r,o,i,a);else if("ParameterValueOutOfRange"===n)s=new f.ParameterValueOutOfRangeError(r,o,i,a);else if("ServerError"===n)s=new f.ServerError(r,o,i,a);else if("StaleRequest"===n)s=new f.StaleRequestError(r,o,i,a);else if("UserAlreadyExists"===n)s=new f.UserAlreadyExistsError(r,o,i,a);else{if("WritesToCollectionDisallowed"!==n)return u(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"error",this);s=new f.WritesToCollectionDisallowedError(r,o,i,a)}return s}}]),t}(y)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),this.headers={},this.addAll(t)}return i(e,[{key:"get",value:function(e){if(e){(0,c.default)(e)||(e=String(e));return this.headers[e.toLowerCase()]}}},{key:"set",value:function(e,t){if(!(0,p.isDefined)(e)||!(0,p.isDefined)(t))throw new Error("A name and value must be provided to set a header.");(0,c.default)(e)||(e=String(e));var n=this.headers;return e=e.toLowerCase(),(0,c.default)(t)?n[e]=t:n[e]=JSON.stringify(t),this.headers=n,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,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(n instanceof e&&(n=n.toPlainObject()),!(0,f.default)(n))throw new Error("Headers argument must be an object.");var r=Object.keys(n);return(0,u.default)(r,function(e){try{t.set(e,n[e])}catch(e){}}),this}},{key:"remove",value:function(e){if(e){(0,c.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())}}]),e}();t.default=h},function(e,t,n){function r(e){if(!a(e)||o(e)!=u)return!1;var t=i(e);if(null===t)return!0;var n=f.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&l.call(n)==p}var o=n(80),i=n(254),a=n(126),u="[object Object]",s=Function.prototype,c=Object.prototype,l=s.toString,f=c.hasOwnProperty,p=l.call(Object);e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkRack=t.CacheRack=void 0;var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Rack";o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.middlewares=[],n.canceled=!1,n.activeMiddleware=void 0,n}return a(t,e),u(t,[{key:"use",value:function(e){if((0,y.isDefined)(e)){if(e instanceof g.default)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 void 0===e?l.default.reject(new Error("Request is undefined. Please provide a valid request.")):(0,p.default)((0,m.default)(this.middlewares),function(n,r){return n.then(function(n){var o=n.request,i=n.response;return t.canceled===!0?l.default.reject(new Error("Cancelled")):(t.activeMiddleware=r,r.handle(o||e,i))})},l.default.resolve({request:e})).then(function(e){var n=e.response;return t.canceled===!0?l.default.reject(new Error("Cancelled")):(t.canceled=!1,t.activeMiddleware=void 0,n)}).catch(function(e){throw t.canceled=!1,t.activeMiddleware=void 0,e})}},{key:"cancel",value:function(){return this.canceled=!0,void 0!==this.activeMiddleware&&(0,d.default)(this.activeMiddleware.cancel)?this.activeMiddleware.cancel():l.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,n=s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"generateTree",this).call(this,e);return(0,m.default)(this.middlewares).forEach(function(t){n.nodes.push(t.generateTree(e+1))}),n}}]),t}(g.default);t.default=w;var _=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Cache Rack";o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.use(new b.CacheMiddleware),n}return a(t,e),u(t,[{key:"useCacheMiddleware",value:function(e){this.reset(),this.use(e)}}]),t}(w),O=new _;t.CacheRack=O;var E=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Network Rack";o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.use(new b.SerializeMiddleware),n.use(new b.HttpMiddleware),n.use(new b.ParseMiddleware),n}return a(t,e),u(t,[{key:"useHttpMiddleware",value:function(e){this.reset(),this.use(new b.SerializeMiddleware),this.use(e),this.use(new b.ParseMiddleware)}}]),t}(w),j=new E;t.NetworkRack=j},function(e,t,n){function r(e,t,n){var r=s(e)?o:u,c=arguments.length<3;return r(e,a(t,4),n,c,i)}var o=n(262),i=n(214),a=n(128),u=n(298),s=n(127);e.exports=r},function(e,t){function n(e,t,n,r,o){return o(e,function(e,o,i){n=r?(r=!1,e):t(n,e,o,i)}),n}e.exports=n},function(e,t,n){function r(e){return null==e?[]:o(e,i(e))}var o=n(300),i=n(151);e.exports=r},function(e,t,n){function r(e,t){return o(t,function(t){return e[t]})}var o=n(118);e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Storage=t.SerializeMiddleware=t.ParseMiddleware=t.MemoryAdapter=t.HttpMiddleware=t.CacheMiddleware=void 0;var o=n(302),i=r(o),a=n(317),u=r(a),s=n(303),c=r(s),l=n(318),f=r(l),p=n(319),h=r(p),d=n(305),y=r(d);t.CacheMiddleware=i.default,t.HttpMiddleware=u.default,t.MemoryAdapter=d.MemoryAdapter,t.ParseMiddleware=f.default,t.SerializeMiddleware=h.default,t.Storage=y.default,t.default=c.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Cache Middleware";return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return a(t,e),u(t,[{key:"loadStorage",value:function(e){return new h.default(e)}},{key:"handle",value:function(e){var t=e.method,n=e.body,r=e.appKey,o=e.collection,i=e.entityId,a=this.loadStorage(r),u=void 0;return"GET"===t?u=i?a.findById(o,i):a.find(o):"POST"===t||"PUT"===t?u="_group"===i?a.find(o):a.save(o,n):"DELETE"===t&&(u=o&&i?a.removeById(o,i):o?a.remove(o,n):a.clear()),u.then(function(e){var n={statusCode:"POST"===t?201:200,data:e};return"POST"===t&&"_group"===i&&(n.statusCode=200),e&&!(0,c.default)(e)||(n.statusCode=204),n}).catch(function(e){return{statusCode:e.code||500}}).then(function(e){return{response:e}})}}]),t}(f.default);t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Middleware";o(this,e),this.name=t}return i(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 c.default.generate(e)}}]),e}();t.default=l},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(0===e.level)return e.value;for(var n="\r\n",r=t?s:a,o=1;o0&&void 0!==arguments[0]?arguments[0]:{},n=arguments[1],o=r(t,n);if(t.nodes.length>0){var a=t.nodes.length-1;t.nodes.forEach(function(t,n){i[t.level]=n===a,o+=e.generate(t,n===a)})}return o}}]),e}();t.default=l},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryAdapter=void 0;var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:24,t="abcdef0123456789",n="",r=0,o=t.length;r0&&void 0!==arguments[0]?arguments[0]:[]})}},{key:"findById",value:function(e,t){return(0,f.default)(t)===!1?u.default.reject(new Error("id must be a string",t)):this.loadAdapter().then(function(n){return n.findById(e,t)})}},{key:"save",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return b.add(function(){var r=!1;return n?((0,h.default)(n)||(r=!0,n=[n]),n=n.map(function(e){var n=e._id,r=e._kmd||{};return(0,d.isDefined)(n)===!1&&(n=t.generateObjectId(),r.local=!0),e._id=n,e._kmd=r,e}),t.loadAdapter().then(function(t){return t.save(e,n)}).then(function(e){return r&&e.length>0?e[0]:e})):u.default.resolve(null)})}},{key:"remove",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return u.default.all(n.map(function(n){return void 0===n._id?u.default.reject("Unable to remove an entity because it does not have _id."):t.removeById(e,n._id)})).then(function(e){return e.reduce(function(e,t){return e.push(t),e},[])})}},{key:"removeById",value:function(e,t){var n=this;return b.add(function(){return(0,f.default)(t)?n.loadAdapter().then(function(n){return n.removeById(e,t)}):u.default.reject(new Error("id must be a string",t))})}},{key:"clear",value:function(){var e=this;return b.add(function(){return e.loadAdapter().then(function(e){return e.clear()})})}}]),e}();t.default=g},function(e,t,n){(function(t){e.exports=n(t.env.PROMISE_QUEUE_COVERAGE?307:308)}).call(t,n(47))},function(e,t){},function(e,t,n){var r,o;!function(i,a){"use strict";"object"==typeof e&&e.exports?e.exports=a():(r=a,void 0!==(o="function"==typeof r?r.call(t,n,t,e):r)&&(e.exports=o))}(0,function(){"use strict";function e(e,t){this.pendingPromises=0,this.maxPendingPromises=void 0!==e?e:1/0,this.maxQueuedPromises=void 0!==t?t:1/0,this.queue=[]}var t="undefined"!=typeof Promise?Promise:function(){return{then:function(){throw new Error("Queue.configure() before use Queue")}}},n=function(){},r=function(e){return e&&"function"==typeof e.then?e:new t(function(t){t(e)})};return e.configure=function(e){t=e},e.prototype.add=function(e){var r=this;return new t(function(t,o,i){if(r.queue.length>=r.maxQueuedPromises)return void o(new Error("Queue limit reached"));r.queue.push({promiseGenerator:e,resolve:t,reject:o,notify:i||n}),r._dequeue()})},e.prototype.getPendingLength=function(){return this.pendingPromises},e.prototype.getQueueLength=function(){return this.queue.length},e.prototype._dequeue=function(){var e=this;if(this.pendingPromises>=this.maxPendingPromises)return!1;var t=this.queue.shift();if(!t)return!1;try{this.pendingPromises++,r(t.promiseGenerator()).then(function(n){e.pendingPromises--,t.resolve(n),e._dequeue()},function(n){e.pendingPromises--,t.reject(n),e._dequeue()},function(e){t.notify(e)})}catch(n){e.pendingPromises--,t.reject(n),e._dequeue()}return!0},e})},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n-1?u[s?t[c]:c]:void 0}}var o=n(128),i=n(166),a=n(151);e.exports=r},function(e,t,n){function r(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var s=null==n?0:a(n);return s<0&&(s=u(r+s,0)),o(e,i(t,3),s)}var o=n(114),i=n(128),a=n(314),u=Math.max;e.exports=r},function(e,t,n){function r(e){var t=o(e),n=t%1;return t===t?n?t-n:t:0}var o=n(315);e.exports=r},function(e,t,n){function r(e){if(!e)return 0===e?e:0;if((e=o(e))===i||e===-i){return(e<0?-1:1)*a}return e===e?e:0}var o=n(316),i=1/0,a=1.7976931348623157e308;e.exports=r},function(e,t,n){function r(e){if("number"==typeof e)return e;if(i(e))return a;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(u,"");var n=c.test(e);return n||l.test(e)?f(e.slice(2),n?2:8):s.test(e)?a:+e}var o=n(86),i=n(180),a=NaN,u=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,f=parseInt;e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Http Middleware";return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return a(t,e),u(t,[{key:"handle",value:function(){return c.default.reject(new l.KinveyError("Unable to send network request.","Please override the core HttpMiddleware."))}},{key:"cancel",value:function(){return c.default.resolve()}}]),t}(p.default);t.default=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Parse Middleware";return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return a(t,e),u(t,[{key:"handle",value:function(e,t){if(t&&t.data){var n=t.headers["content-type"]||t.headers["Content-Type"];if(n&&0===n.indexOf("application/json"))try{t.data=JSON.parse(t.data)}catch(e){}}return c.default.resolve({response:t})}}]),t}(f.default);t.default=p},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"Serialize Middleware";return o(this,n),i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e))}return a(n,t),u(n,[{key:"handle",value:function(t){if(void 0!==t&&void 0!==t.body){var n=t.headers["content-type"]||t.headers["Content-Type"];if(void 0!==n)if(0===n.indexOf("application/json"))t.body=JSON.stringify(t.body);else if(0===n.indexOf("application/x-www-form-urlencoded")){var r=t.body,o=[];Object.keys(r).forEach(function(t){o.push(e.encodeURIComponent(t)+"="+e.encodeURIComponent(r[t]))}),t.body=o.join("&")}}return c.default.resolve({request:t})}}]),n}(f.default);t.default=p}).call(t,function(){return this}())},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0){var n=(0,h.default)(t,"_id"),r=new S.default((0,m.default)(e.query,"toJSON",e.query));return r.fields=["_id","_kmd.lmt"],new R.KinveyRequest({method:A.RequestMethod.GET,url:e.url,headers:e.headers,authType:e.authType,query:r,timeout:e.timeout,client:e.client,properties:e.properties,skipBL:e.skipBL,trace:e.trace,followRedirect:e.followRedirect,cache:e.cache}).execute().then(function(e){return e.data}).then(function(t){var r=(0,h.default)(t,"_id"),o=r,i=Object.keys(n);(0,_.default)(i,function(e){var t=n[e],i=r[e];i&&(0,P.isDefined)(i._kmd)&&(0,P.isDefined)(t._kmd)&&i._kmd.lmt===t._kmd.lmt?delete o[e]:delete n[e]});for(var a=Object.keys(o),u=[],s=0;s200+s?200:a.length);c.contains("_id",l);var p=new R.KinveyRequest({method:A.RequestMethod.GET,url:e.url,headers:e.headers,authType:e.authType,query:c,timeout:e.timeout,client:e.client,properties:e.properties,skipBL:e.skipBL,trace:e.trace,followRedirect:e.followRedirect,cache:e.cache}),d=p.execute();u.push(d),s+=200}return f.default.all(u)}).then(function(t){var r=(0,y.default)(t,function(e,t){if(t.isSuccess()){var n=e.headers;n.addAll(t.headers),e.headers=n,e.data=e.data.concat(t.data)}return e},new M.default({statusCode:I.StatusCode.Ok,data:[]}));if(r.data=r.data.concat((0,g.default)(n)),e.query){var o=new S.default((0,m.default)(e.query,"toJSON",e.query));o.skip=0,o.limit=0,r.data=o.process(r.data)}return r})}return new R.KinveyRequest({method:A.RequestMethod.GET,url:e.url,headers:e.headers,authType:e.authType,query:e.query,timeout:e.timeout,client:e.client,properties:e.properties,skipBL:e.skipBL,trace:e.trace,followRedirect:e.followRedirect,cache:e.cache}).execute()})}},{key:"method",get:function(){return c(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"method",this)},set:function(e){switch((0,k.default)(e)||(e=String(e)),e=e.toUpperCase()){case A.RequestMethod.GET:s(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"method",e,this);break;case A.RequestMethod.POST:case A.RequestMethod.PATCH:case A.RequestMethod.PUT:case A.RequestMethod.DELETE:default:throw new x.KinveyError("Invalid request Method. Only RequestMethod.GET is allowed.")}}}]),t}(R.KinveyRequest);t.default=N},function(e,t,n){function r(e,t,n){t=o(t,e);var r=-1,u=t.length;for(u||(u=1,e=void 0);++r0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.rack=K.NetworkRack,n}return u(t,e),t}(I.default);t.default=z;var V={All:"All",App:"App",Basic:"Basic",Default:"Default",Master:"Master",None:"None",Session:"Session"};Object.freeze(V),t.AuthType=V;var Y={all:function(e){return Y.session(e).catch(function(){return Y.basic(e)})},app:function(e){return e.appKey&&e.appSecret?h.default.resolve({scheme:"Basic",username:e.appKey,password:e.appSecret}):h.default.reject(new Error("Missing client appKey and/or appSecret. Use Kinvey.init() to set the appKey and appSecret for the client."))},basic:function(e){return Y.master(e).catch(function(){return Y.app(e)})},master:function(e){return e.appKey&&e.masterSecret?h.default.resolve({scheme:"Basic",username:e.appKey,password:e.masterSecret}):h.default.reject(new Error("Missing client appKey and/or appSecret. Use Kinvey.init() to set the appKey and appSecret for the client."))},none:function(){return h.default.resolve(null)},session:function(e){var t=N.default.getActiveUser(e);return(0,A.isDefined)(t)?h.default.resolve({scheme:"Kinvey",credentials:t._kmd.authtoken}):h.default.reject(new R.NoActiveUserError("There is not an active user. Please login a user and retry the request."))}},G=t.Properties=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),t}(U.default);t.KinveyRequest=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return e=(0,_.default)({skipBL:!1,trace:!1},e),n.authType=e.authType||V.None,n.query=e.query,n.aggregation=e.aggregation,n.properties=e.properties||new G,n.skipBL=e.skipBL===!0,n.trace=e.trace===!0,n}return u(t,e),c(t,[{key:"getAuthorizationHeader",value:function(){var e=this,t=h.default.resolve(void 0);if(this.authType)switch(this.authType){case V.All:t=Y.all(this.client);break;case V.App:t=Y.app(this.client);break;case V.Basic:t=Y.basic(this.client);break;case V.Master:t=Y.master(this.client);break;case V.None:t=Y.none(this.client);break;case V.Session:t=Y.session(this.client);break;default:t=Y.session(this.client).catch(function(t){return Y.master(e.client).catch(function(){throw t})})}return t.then(function(e){if((0,A.isDefined)(e)){var t=e.credentials;return e.username&&(t=new r(e.username+":"+e.password).toString("base64")),e.scheme+" "+t}})}},{key:"execute",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.getAuthorizationHeader().then(function(t){(0,A.isDefined)(t)?e.headers.set("Authorization",t):e.headers.remove("Authorization")}).then(function(){return f(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"execute",e).call(e)}).then(function(e){if(e instanceof L.KinveyResponse||(e=new L.KinveyResponse({statusCode:e.statusCode,headers:e.headers,data:e.data})),n===!1&&e.isSuccess()===!1)throw e.error;return e}).catch(function(o){if(o instanceof R.InvalidCredentialsError&&r===!0){var i=N.default.getActiveUser(e.client);if(!(0,A.isDefined)(i))throw o;var a=(0,A.isDefined)(i._socialIdentity)?i._socialIdentity:{},u=Object.keys(a).find(function(e){return a[e].identity===C.SocialIdentity.MobileIdentityConnect}),s=a[u];if((0,A.isDefined)(s)&&s.identity===C.SocialIdentity.MobileIdentityConnect){return new t({method:q.RequestMethod.POST,headers:{"Content-Type":"application/x-www-form-urlencoded"},authType:V.App,url:y.default.format({protocol:s.protocol||e.client.micProtocol,host:s.host||e.client.micHost,pathname:F}),body:{grant_type:"refresh_token",client_id:s.client_id,redirect_uri:s.redirect_uri,refresh_token:s.refresh_token},timeout:e.timeout,properties:e.properties}).execute(!1,!1).then(function(e){return e.data}).then(function(n){var r={};return r._socialIdentity={},r._socialIdentity[s.identity]=n,new t({method:q.RequestMethod.POST,authType:V.App,url:y.default.format({protocol:e.client.protocol,host:e.client.host,pathname:"/"+B+"/"+e.client.appKey+"/login"}),properties:e.properties,body:r,timeout:e.timeout,client:e.client}).execute(!1,!1).then(function(e){return e.data})}).then(function(t){return t._socialIdentity[s.identity]=(0,E.default)(t._socialIdentity[s.identity],s),N.default.setActiveUser(e.client,t)}).then(function(){return e.execute(n,!1)}).catch(function(){throw o})}throw o}throw o})}},{key:"appVersion",get:function(){return this.client.appVersion}},{key:"query",get:function(){return this._query},set:function(e){if((0,A.isDefined)(e)&&!(e instanceof P.default))throw new R.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,A.isDefined)(e)&&!(e instanceof S.default))throw new R.KinveyError("Invalid aggregation. It must be an instance of the Aggregation class.");(0,A.isDefined)(e)&&(this.body=e.toJSON()),this._aggregation=e}},{key:"headers",get:function(){var e=f(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",H),this.skipBL===!0?e.set("X-Kinvey-Skip-Business-Logic",!0):e.remove("X-Kinvey-Skip-Business-Logic"),this.trace===!0?(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 n=this.properties.toString();if((0,k.default)(n))e.remove("X-Kinvey-Custom-Request-Properties");else{var r=s(n);if(r>=$)throw new Error("The custom properties are "+r+" bytes.It must be less then "+$+" bytes.","Please remove some custom properties.");e.set("X-Kinvey-Custom-Request-Properties",n)}}else e.remove("X-Kinvey-Custom-Request-Properties");return e},set:function(e){l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"headers",e,this)}},{key:"url",get:function(){var e=f(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",this),n=this.query?this.query.toQueryString():{};return(0,k.default)(n)?e:(0,g.default)(e,m.default.stringify(n))},set:function(e){l(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"url",e,this)}},{key:"properties",get:function(){return this._properties},set:function(e){!e||e instanceof G||(e=new G(e)),this._properties=e}}]),t}(z)}).call(t,n(47),n(323).Buffer)},function(e,t,n){(function(e){/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh
* @license MIT
*/
"use strict";function r(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),i.alloc(+e)}function v(e,t){if(i.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 n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Y(e).length;default:if(r)return $(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return R(this,t,n);case"base64":return P(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function b(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:w(e,t,n,r,o);if("number"==typeof t)return t&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):w(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function w(e,t,n,r,o){function i(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,u=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,u/=2,s/=2,n/=2}var c;if(o){var l=-1;for(c=n;cu&&(n=u-s),c=n;c>=0;c--){for(var f=!0,p=0;po&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a239?4:i>223?3:i>191?2:1;if(o+u<=n){var s,c,l,f;switch(u){case 1:i<128&&(a=i);break;case 2:s=e[o+1],128==(192&s)&&(f=(31&i)<<6|63&s)>127&&(a=f);break;case 3:s=e[o+1],c=e[o+2],128==(192&s)&&128==(192&c)&&(f=(15&i)<<12|(63&s)<<6|63&c)>2047&&(f<55296||f>57343)&&(a=f);break;case 4:s=e[o+1],c=e[o+2],l=e[o+3],128==(192&s)&&128==(192&c)&&128==(192&l)&&(f=(15&i)<<18|(63&s)<<12|(63&c)<<6|63&l)>65535&&f<1114112&&(a=f)}}null===a?(a=65533,u=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),o+=u}return S(r)}function S(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,n,r,o,a){if(!i.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 N(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function D(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function U(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,o){return o||U(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),W.write(e,t,n,r,23,4),n+4}function K(e,t,n,r,o){return o||U(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),W.write(e,t,n,r,52,8),n+8}function F(e){if(e=B(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function B(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function $(e,t){t=t||1/0;for(var n,r=e.length,o=null,i=[],a=0;a55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function z(e){for(var t=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function Y(e){return Q.toByteArray(F(e))}function G(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function J(e){return e!==e}var Q=n(324),W=n(325),X=n(326);t.Buffer=i,t.SlowBuffer=y,t.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=r(),i.poolSize=8192,i._augment=function(e){return e.__proto__=i.prototype,e},i.from=function(e,t,n){return a(null,e,t,n)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(e,t,n){return s(null,e,t,n)},i.allocUnsafe=function(e){return c(null,e)},i.allocUnsafeSlow=function(e){return c(null,e)},i.isBuffer=function(e){return!(null==e||!e._isBuffer)},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,a=Math.min(n,r);o0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},i.prototype.compare=function(e,t,n,r,o){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var a=o-r,u=n-t,s=Math.min(a,u),c=this.slice(r,o),l=e.slice(t,n),f=0;fo)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return O(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return j(this,e,t,n);case"base64":return k(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;i.prototype.slice=function(e,t){var n=this.length;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);)r+=this[e+--t]*o;return r},i.prototype.readUInt8=function(e,t){return t||I(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return t||I(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return t||I(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=this[e],o=1,i=0;++i=o&&(r-=Math.pow(2,8*t)),r},i.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},i.prototype.readInt8=function(e,t){return t||I(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},i.prototype.readInt16LE=function(e,t){t||I(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){t||I(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return t||I(e,4,this.length),W.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return t||I(e,4,this.length),W.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return t||I(e,8,this.length),W.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return t||I(e,8,this.length),W.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){M(this,e,t,n,Math.pow(2,8*n)-1,0)}var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},i.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,1,255,0),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},i.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);M(this,e,t,n,o-1,-o)}var i=0,a=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+n},i.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);M(this,e,t,n,o-1,-o)}var i=n-1,a=1,u=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/a>>0)-u&255;return t+n},i.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,1,127,-128),i.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),i.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},i.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return K(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return K(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(a<1e3||!i.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function r(e){return 3*e.length/4-n(e)}function o(e){var t,r,o,i,a,u,s=e.length;a=n(e),u=new l(3*s/4-a),o=a>0?s-4:s;var f=0;for(t=0,r=0;t>16&255,u[f++]=i>>8&255,u[f++]=255&i;return 2===a?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,u[f++]=255&i):1===a&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,u[f++]=i>>8&255,u[f++]=255&i),u}function i(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function a(e,t,n){for(var r,o=[],a=t;ac?c:u+16383));return 1===r?(t=e[n-1],o+=s[t>>2],o+=s[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=s[t>>10],o+=s[t>>4&63],o+=s[t<<2&63],o+="="),i.push(o),i.join("")}t.byteLength=r,t.toByteArray=o,t.fromByteArray=u;for(var s=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,h=f.length;p>1,l=-7,f=n?o-1:0,p=n?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-l)-1,h>>=-l,l+=u;l>0;i=256*i+e[t+f],f+=p,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=r;l>0;a=256*a+e[t+f],f+=p,l-=8);if(0===i)i=1-c;else{if(i===s)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),i-=c}return(h?-1:1)*a*Math.pow(2,i-r)},t.write=function(e,t,n,r,o,i){var a,u,s,c=8*i-o-1,l=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),t+=a+f>=1?p/s:p*Math.pow(2,1-f),t*s>=2&&(a++,s/=2),a+f>=l?(u=0,a=l):a+f>=1?(u=(t*s-1)*Math.pow(2,o),a+=f):(u=t*Math.pow(2,f-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&u,h+=d,u/=256,o-=8);for(a=a<0;e[n+h]=255&a,h+=d,a/=256,c-=8);e[n+h-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){var r=n(196),o=n(328),i=n(194),a=n(329),u=i(function(e){return e.push(void 0,a),r(o,void 0,e)});e.exports=u},function(e,t,n){var r=n(207),o=n(208),i=n(246),a=o(function(e,t,n,o){r(t,i(t),e,o)});e.exports=a},function(e,t,n){function r(e,t,n,r){return void 0===e||o(e,i[n])&&!a.call(r,n)?t:e}var o=n(99),i=Object.prototype,a=i.hasOwnProperty;e.exports=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(331);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(332);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(370);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})});var a=n(371);Object.keys(a).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}})});var u=n(372);Object.keys(u).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}})});var s=n(374);Object.keys(s).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return s[e]}})})},function(e,t,n){(function(e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={Facebook:"facebook",Google:"google",Kinvey:e&&e.env&&e.env.KINVEY_IDENTITY||"kinvey"||"kinvey",LinkedIn:"linkedin",MobileIdentityConnect:e&&e.env&&e.env.KINVEY_MIC_IDENTITY||"kinveyAuth"||"kinveyAuth",Windows:"windows"};Object.freeze(n),t.SocialIdentity=n}).call(t,n(47))},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0}),t.Facebook=void 0;var u=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(r=(0,f.default)({force:!1,scope:"public_profile"},r),!this.isSupported())return c.default.reject(new v.KinveyError("Unable to login with "+this.identity+". It is not supported on this platform."));var o=this.session;return o&&this.isOnline(o)?c.default.resolve(o):t?new c.default(function(o,i){function a(e){var t=e.url;try{t&&0===t.indexOf(c)&&f===!1&&(f=!0,p.removeAllListeners(),p.close(),d(t))}catch(e){}}function u(e){var t=e.url;try{t&&0===t.indexOf(c)&&f===!1?(f=!0,p.removeAllListeners(),p.close(),d(t)):f===!1&&(p.removeAllListeners(),p.close(),i(new v.KinveyError(e.message,"",e.code)))}catch(e){}}function s(){f===!1&&(p.removeAllListeners(),i(new v.KinveyError("Facebook login has been cancelled.")))}var c=r.redirectUri||e.location.href,l=(0,m.randomString)(),f=!1,p=new g.default,d=function(e){var r=y.default.parse(e),a=r.hash,u=h.default.parse(a.substring(1)),s=u.access_token,c=u.expires_in,f=u.error,p=u.error_description,d=u.error_reason,v=u.state,m=parseInt(c,10),b=(new Date).getTime()/1e3+(m||31536e3);if(v===l)if(s){var g={access_token:s,expires_in:m,expires:b,client_id:t};n.session=g,o(g)}else f?(n.session=null,i({reason:d,error:f,description:p})):(n.session=null,i({reason:"not_authorized",error:"access_denied",description:"Your app is not authorized."}));else n.session=null,i({reason:"state_mismatch",error:"access_denied",description:"The state did not match."})};return p.on("loadstart",a),p.on("loadstop",a),p.on("error",u),p.on("exit",s),p.open(y.default.format({protocol:"https:",host:"www.facebook.com",pathname:"/dialog/oauth",query:{client_id:t,redirect_uri:c,response_type:"token",scope:r.scope,auth_type:r.force===!0?"rerequest":null,state:l}})),p}):c.default.reject(new v.KinveyError("Unable to login with "+this.identity+". No client id was provided."))}},{key:"logout",value:function(){return this.session=null,c.default.resolve()}},{key:"identity",get:function(){return O.SocialIdentity.Facebook}}],[{key:"identity",get:function(){return O.SocialIdentity.Facebook}}]),n}(_.default)}).call(t,function(){return this}())},function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 a(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:"/",r=void 0,o=void 0,i=void 0,a=function(e){t.emit("loadstart",e)},u=function(e){t.emit("loadstop",e)},s=function(e){t.emit("error",e)},c=function(){clearInterval(r),i.close(),t.popupWindow=null,i&&(0,p.default)(i.removeEventListener)&&(i.removeEventListener("loadstart",o.loadStopCallback),i.removeEventListener("loadstop",o.loadStopCallback),i.removeEventListener("loaderror",o.loadErrorCallback),i.removeEventListener("exit",o.exitCallback)),t.emit("exit")};if(o={loadStartCallback:(0,l.default)(a,this),loadStopCallback:(0,l.default)(u,this),loadErrorCallback:(0,l.default)(s,this),exitCallback:(0,l.default)(c,this)},!(i=e.open(n,"_blank","toolbar=no,location=no")))throw new Error("The popup was blocked.");return(0,p.default)(i.addEventListener)&&(i.addEventListener("loadstart",o.loadStartCallback),i.addEventListener("loadstop",o.loadStopCallback),i.addEventListener("loaderror",o.loadErrorCallback),i.addEventListener("exit",o.exitCallback)),r=setInterval(function(){if(i.closed)o.exitCallback();else try{o.loadStopCallback({url:i.location.href})}catch(e){}},100),this.popupWindow=i,this}},{key:"close",value:function(){return this.popupWindow&&this.popupWindow.close(),this}}]),n}(s.EventEmitter);t.default=h}).call(t,function(){return this}())},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,o,u,s,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(n=this._events[e],a(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:u=Array.prototype.slice.call(arguments,1),n.apply(this,u)}else if(i(n))for(u=Array.prototype.slice.call(arguments,1),c=n.slice(),o=c.length,s=0;s0&&this._events[e].length>o&&(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},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}
if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,o,a,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],a=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(u=a;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){o=u;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;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=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){var r=n(194),o=n(336),i=n(361),a=n(363),u=r(function(e,t,n){var r=1;if(n.length){var s=a(n,i(u));r|=32}return o(e,r,t,n,s)});u.placeholder={},e.exports=u},function(e,t,n){function r(e,t,n,r,O,E,j,k){var x=t&v;if(!x&&"function"!=typeof e)throw new TypeError(d);var P=r?r.length:0;if(P||(t&=~(g|w),r=O=void 0),j=void 0===j?j:_(h(j),0),k=void 0===k?k:h(k),P-=O?O.length:0,t&w){var T=r,S=O;r=O=void 0}var A=x?void 0:c(e),R=[e,t,n,r,O,T,S,E,j,k];if(A&&l(R,A),e=R[0],t=R[1],n=R[2],r=R[3],O=R[4],k=R[9]=void 0===R[9]?x?0:e.length:_(R[9]-P,0),!k&&t&(m|b)&&(t&=~(m|b)),t&&t!=y)C=t==m||t==b?a(e,t,k):t!=g&&t!=(y|g)||O.length?u.apply(void 0,R):s(e,t,n,r);else var C=i(e,t,n);return p((A?o:f)(C,R),e,t)}var o=n(337),i=n(339),a=n(341),u=n(342),s=n(364),c=n(350),l=n(365),f=n(356),p=n(357),h=n(314),d="Expected a function",y=1,v=2,m=8,b=16,g=32,w=64,_=Math.max;e.exports=r},function(e,t,n){var r=n(190),o=n(338),i=o?function(e,t){return o.set(e,t),e}:r;e.exports=i},function(e,t,n){var r=n(171),o=r&&new r;e.exports=o},function(e,t,n){function r(e,t,n){function r(){return(this&&this!==i&&this instanceof r?s:e).apply(u?n:this,arguments)}var u=t&a,s=o(e);return r}var o=n(340),i=n(82),a=1;e.exports=r},function(e,t,n){function r(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=o(e.prototype),r=e.apply(n,t);return i(r)?r:n}}var o=n(269),i=n(86);e.exports=r},function(e,t,n){function r(e,t,n){function r(){for(var i=arguments.length,p=Array(i),h=i,d=s(r);h--;)p[h]=arguments[h];var y=i<3&&p[0]!==d&&p[i-1]!==d?[]:c(p,d);return(i-=y.length)1&&d.reverse(),P&&j1?"& ":"")+t[o],t=t.join(n>2?", ":" "),e.replace(r,"{\n/* [wrapped with "+t+"] */\n")}var r=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;e.exports=n},function(e,t,n){function r(e,t){return o(a,function(n){var r="_."+n[0];t&n[1]&&!i(e,r)&&e.push(r)}),e.sort()}var o=n(243),i=n(112),a=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]];e.exports=r},function(e,t){function n(e){return e.placeholder}e.exports=n},function(e,t,n){function r(e,t){for(var n=e.length,r=a(t.length,n),u=o(e);r--;){var s=t[r];e[r]=i(s,n)?u[s]:void 0}return e}var o=n(250),i=n(157),a=Math.min;e.exports=r},function(e,t){function n(e,t){for(var n=-1,o=e.length,i=0,a=[];++n0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.client=e.client||h.default.sharedInstance()}return i(t,[{key:"isSupported",value:function(){return!!y}},{key:"isOnline",value:function(e){var t=(new Date).getTime()/1e3;return e&&e.access_token&&e.expires>t}},{key:"login",value:function(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r=(0,f.default)({redirectUri:e.location.href,scope:null,force:null},r),!this.isSupported())return u.default.reject(new d.KinveyError("Unable to login with "+this.identity+". It is not supported on this platform."));var o=this.session;if(o&&this.isOnline(o))return u.default.resolve(o);if(!t)return u.default.reject(new d.KinveyError("Unable to login with "+this.identity+". No client id was provided."));var i={};return i[this.identity]=t,y.init(i),y(this.identity).login({redirect_uri:r.redirectUri,scope:r.scope,force:r.force}).then(function(){return o=y(n.identity).getAuthResponse(),o.clientId=t,n.session=o,o})}},{key:"logout",value:function(){var e=this,t=u.default.resolve();if(this.isSupported()){var n={};n[this.identity]=this.session.clientId,y.init(n),t=y(this.identity).logout()}return t.then(function(){e.session=null})}},{key:"identity",get:function(){throw new d.KinveyError("A subclass must override this property.")}},{key:"session",get:function(){return c.default.get(""+this.client.appKey+this.identity)},set:function(e){e?c.default.set(""+this.client.appKey+this.identity,e):c.default.remove(""+this.client.appKey+this.identity)}}],[{key:"isSupported",value:function(){return!!y}},{key:"login",value:function(e,t){return new this(t).login(e,t)}},{key:"logout",value:function(e,t){return(new this).logout(e,t)}},{key:"identity",get:function(){throw new d.KinveyError("A subclass must override this property.")}}]),t}();t.default=v}).call(t,function(){return this}())},function(e,t,n){var r;(function(o,i){Object.create||(Object.create=function(){function e(){}return function(t){if(1!=arguments.length)throw new Error("Object.create implementation only accepts one parameter.");return e.prototype=t,new e}}()),Object.keys||(Object.keys=function(e,t,n){n=[];for(t in e)n.hasOwnProperty.call(e,t)&&n.push(t);return n}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;t>>0;if("function"!=typeof e)throw new TypeError;for(var r=arguments.length>=2?arguments[1]:void 0,o=0;o(new Date).getTime()/1e3){if(0===i.diff((v.scope||"").split(/[,\s]+/),(c.qs.state.scope||"").split(/[,\s]+/)).length)return s.fulfill({unchanged:!0,network:c.network,authResponse:v}),s}if("page"===f.display&&f.page_uri&&(c.qs.state.page_uri=i.url(f.page_uri).href),"login"in p&&"function"==typeof p.login&&p.login(c),(!/\btoken\b/.test(y)||parseInt(p.oauth.version,10)<2||"none"===f.display&&p.oauth.grant&&v&&v.refresh_token)&&(c.qs.state.oauth=p.oauth,c.qs.state.oauth_proxy=f.oauth_proxy),c.qs.state=encodeURIComponent(JSON.stringify(c.qs.state)),1===parseInt(p.oauth.version,10)?r=i.qs(f.oauth_proxy,c.qs,t):"none"===f.display&&p.oauth.grant&&v&&v.refresh_token?(c.qs.refresh_token=v.refresh_token,r=i.qs(f.oauth_proxy,c.qs,t)):r=i.qs(p.oauth.auth,c.qs,t),e("auth.init",c),"none"===f.display)i.iframe(r,d);else if("popup"===f.display)var g=i.popup(r,d,f.popup),w=setInterval(function(){if((!g||g.closed)&&(clearInterval(w),!s.state)){var e=u("cancelled","Login has been cancelled");g||(e=u("blocked","Popup was blocked")),e.network=c.network,s.reject(e)}},100);else window.location=r;return s.proxy},logout:function(){function e(e,t){a.emit(e,t)}var t=this,n=t.utils,r=n.error,o=n.Promise(),i=n.args({name:"s",options:"o",callback:"f"},arguments);if(i.options=i.options||{},o.proxy.then(i.callback,i.callback),o.proxy.then(e.bind(this,"auth.logout auth"),e.bind(this,"error")),i.name=i.name||this.settings.default_service,i.authResponse=n.store(i.name),!i.name||i.name in t.services)if(i.name&&i.authResponse){var u=function(e){n.store(i.name,null),o.fulfill(a.utils.merge({network:i.name},e||{}))},s={};if(i.options.force){var c=t.services[i.name].logout;if(c)if("function"==typeof c&&(c=c(u,i)),"string"==typeof c)n.iframe(c),s.force=null,s.message="Logout success on providers site was indeterminate";else if(void 0===c)return o.proxy}u(s)}else o.reject(r("invalid_session","There was no session to remove"));else o.reject(r("invalid_network","The network was unrecognized"));return o.proxy},getAuthResponse:function(e){return e=e||this.settings.default_service,e&&e in this.services?this.utils.store(e)||null:null},events:{}}),a.utils.extend(a.utils,{error:function(e,t){return{error:{code:e,message:t}}},qs:function(e,t,n){if(t){n=n||encodeURIComponent;for(var r in t){var o="([\\?\\&])"+r+"=[^\\&]*",i=new RegExp(o);e.match(i)&&(e=e.replace(i,"$1"+r+"="+n(t[r])),delete t[r])}}return this.isEmpty(t)?e:e+(e.indexOf("?")>-1?"&":"?")+this.param(t,n)},param:function(e,t){var n,r,o={};if("string"==typeof e){if(t=t||decodeURIComponent,r=e.replace(/^[\#\?]/,"").match(/([^=\/\&]+)=([^\&]+)/g))for(var i=0;i-1&&"string"===o||e[i].indexOf("o")>-1&&"object"===o||e[i].indexOf("i")>-1&&"number"===o||e[i].indexOf("a")>-1&&"object"===o||e[i].indexOf("f")>-1&&"function"===o))n[i]=t[r++];else if("string"==typeof e[i]&&e[i].indexOf("!")>-1)return!1;return n},url:function(e){if(e){if(window.URL&&URL instanceof Function&&0!==URL.length)return new URL(e,window.location);var t=document.createElement("a");return t.href=e,t.cloneNode(!1)}return window.location},diff:function(e,t){return t.filter(function(t){return e.indexOf(t)===-1})},diffKey:function(e,t){if(e||!t){var n={};for(var r in e)r in t||(n[r]=e[r]);return n}return e},unique:function(e){return Array.isArray(e)?e.filter(function(t,n){return e.indexOf(t)===n}):[]},isEmpty:function(e){if(!e)return!0;if(Array.isArray(e))return!e.length;if("object"==typeof e)for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},Promise:function(){var e=function(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.6",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))};e.prototype={fulfill:function(e){return t(this,1,"fulfillValue",e)},reject:function(e){return t(this,2,"rejectReason",e)},then:function(t,r){var o=this,i=new e;return o.onFulfilled.push(a(t,i,"fulfill")),o.onRejected.push(a(r,i,"reject")),n(o),i.proxy}};var t=function(e,t,r,o){return 0===e.state&&(e.state=t,e[r]=o,n(e)),e},n=function(e){1===e.state?r(e,"onFulfilled",e.fulfillValue):2===e.state&&r(e,"onRejected",e.rejectReason)},r=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var a=function(){for(var e=0;e-1)for(var o=0;o=400:"object"==typeof e&&"error"in e)?o.reject(e):o.fulfill(e));if(e===!0?e={success:!0}:e||(e={}),"delete"===i.method&&(e=!e||n.isEmpty(e)?{success:!0}:e),c.wrap&&(i.path in c.wrap||"default"in c.wrap)){var r=i.path in c.wrap?i.path:"default",a=((new Date).getTime(),c.wrap[r](e,t,i));a&&(e=a)}e&&"paging"in e&&e.paging.next&&("?"===e.paging.next[0]?e.paging.next=i.path+e.paging.next:e.paging.next+="#"+i.path),!e||"error"in e?o.reject(e):o.fulfill(e)})}var t=this,n=t.utils,r=n.error,o=n.Promise(),i=n.args({path:"s!",query:"o",method:"s",data:"o",timeout:"i",callback:"f"},arguments);i.method=(i.method||"get").toLowerCase(),i.headers=i.headers||{},i.query=i.query||{},"get"!==i.method&&"delete"!==i.method||(n.extend(i.query,i.data),i.data={});var a=i.data=i.data||{};if(o.then(i.callback,i.callback),!i.path)return o.reject(r("invalid_path","Missing the path parameter from the request"));i.path=i.path.replace(/^\/+/,"");var u=(i.path.split(/[\/\:]/,2)||[])[0].toLowerCase();if(u in t.services){i.network=u;var s=new RegExp("^"+u+":?/?");i.path=i.path.replace(s,"")}i.network=t.settings.default_service=i.network||t.settings.default_service;var c=t.services[i.network];if(!c)return o.reject(r("invalid_network","Could not match the service requested: "+i.network));if(i.method in c&&i.path in c[i.method]&&c[i.method][i.path]===!1)return o.reject(r("invalid_path","The provided path is not available on the selected network"));i.oauth_proxy||(i.oauth_proxy=t.settings.oauth_proxy),"proxy"in i||(i.proxy=i.oauth_proxy&&c.oauth&&1===parseInt(c.oauth.version,10)),"timeout"in i||(i.timeout=t.settings.timeout),"formatResponse"in i||(i.formatResponse=!0),i.authResponse=t.getAuthResponse(i.network),i.authResponse&&i.authResponse.access_token&&(i.query.access_token=i.authResponse.access_token);var l,f=i.path;i.options=n.clone(i.query),i.data=n.clone(a);var p=c[{delete:"del"}[i.method]||i.method]||{};if("get"===i.method){var h=f.split(/[\?#]/)[1];h&&(n.extend(i.query,n.param(h)),f=f.replace(/\?.*?(#|$)/,"$1"))}return(l=f.match(/#(.+)/,""))?(f=f.split("#")[0],i.path=l[1]):f in p?(i.path=f,f=p[f]):"default"in p&&(f=p.default),i.redirect_uri=t.settings.redirect_uri,i.xhr=c.xhr,i.jsonp=c.jsonp,i.form=c.form,"function"==typeof f?f(i,e):e(f),o.proxy},a.utils.extend(a.utils,{request:function(e,t){function n(e,t){var n;e.authResponse&&e.authResponse.oauth&&1===parseInt(e.authResponse.oauth.version,10)&&(n=e.query.access_token,delete e.query.access_token,e.proxy=!0),!e.data||"get"!==e.method&&"delete"!==e.method||(r.extend(e.query,e.data),e.data=null);var o=r.qs(e.url,e.query);e.proxy&&(o=r.qs(e.oauth_proxy,{path:o,access_token:n||"",then:e.proxy_response_type||("get"===e.method.toLowerCase()?"redirect":"proxy"),method:e.method.toLowerCase(),suppress_response_codes:!0})),t(o)}var r=this,o=r.error;if(r.isEmpty(e.data)||"FileList"in window||!r.hasBinary(e.data)||(e.xhr=!1,e.jsonp=!1),this.request_cors(function(){return void 0===e.xhr||e.xhr&&("function"!=typeof e.xhr||e.xhr(e,e.query))}))return void n(e,function(n){var o=r.xhr(e.method,n,e.headers,e.data,t);o.onprogress=e.onprogress||null,o.upload&&e.onuploadprogress&&(o.upload.onprogress=e.onuploadprogress)});var i=e.query;if(e.query=r.clone(e.query),e.callbackID=r.globalEvent(),e.jsonp!==!1){if(e.query.callback=e.callbackID,"function"==typeof e.jsonp&&e.jsonp(e,e.query),"get"===e.method)return void n(e,function(n){r.jsonp(n,t,e.callbackID,e.timeout)});e.query=i}if(e.form!==!1){e.query.redirect_uri=e.redirect_uri,e.query.state=JSON.stringify({callback:e.callbackID});var a;if("function"==typeof e.form&&(a=e.form(e,e.query)),"post"===e.method&&a!==!1)return void n(e,function(n){r.post(n,e.data,a,t,e.callbackID,e.timeout)})}t(o("invalid_request","There was no mechanism for handling this request"))},request_cors:function(e){return"withCredentials"in new XMLHttpRequest&&e()},domInstance:function(e,t){var n="HTML"+(e||"").replace(/^[a-z]/,function(e){return e.toUpperCase()})+"Element";return!!t&&(window[n]?t instanceof window[n]:window.Element?t instanceof window.Element&&(!e||t.tagName&&t.tagName.toLowerCase()===e):!(t instanceof Object||t instanceof Array||t instanceof String||t instanceof Number)&&t.tagName&&t.tagName.toLowerCase()===e)},clone:function(e){if(null===e||"object"!=typeof e||e instanceof Date||"nodeName"in e||this.isBinary(e)||"function"==typeof FormData&&e instanceof FormData)return e;if(Array.isArray(e))return e.map(this.clone.bind(this));var t={};for(var n in e)t[n]=this.clone(e[n]);return t},xhr:function(e,t,n,r,o){function i(e){for(var t,n={},r=/([a-z\-]+):\s?(.*);?/gi;t=r.exec(e);)n[t[1]]=t[2];return n}var a=new XMLHttpRequest,u=this.error,s=!1;"blob"===e&&(s=e,e="GET"),e=e.toUpperCase(),a.onload=function(t){var n=a.response;try{n=JSON.parse(a.responseText)}catch(e){401===a.status&&(n=u("access_denied",a.statusText))}var r=i(a.getAllResponseHeaders());r.statusCode=a.status,o(n||("GET"===e?u("empty_response","Could not get resource"):{}),r)},a.onerror=function(e){var t=a.responseText;try{t=JSON.parse(a.responseText)}catch(e){}o(t||u("access_denied","Could not get resource"))};var c;if("GET"===e||"DELETE"===e)r=null;else if(r&&"string"!=typeof r&&!(r instanceof FormData)&&!(r instanceof File)&&!(r instanceof Blob)){var l=new FormData;for(c in r)r.hasOwnProperty(c)&&(r[c]instanceof HTMLInputElement?"files"in r[c]&&r[c].files.length>0&&l.append(c,r[c].files[0]):r[c]instanceof Blob?l.append(c,r[c],r.name):l.append(c,r[c]));r=l}if(a.open(e,t,!0),s&&("responseType"in a?a.responseType=s:a.overrideMimeType("text/plain; charset=x-user-defined")),n)for(c in n)a.setRequestHeader(c,n[c]);return a.send(r),a},jsonp:function(e,t,n,r){var o,i=this,a=i.error,u=0,s=document.getElementsByTagName("head")[0],c=a("server_error","server_error"),l=function(){u++||window.setTimeout(function(){t(c),s.removeChild(f)},0)};n=i.globalEvent(function(e){return c=e,!0},n),e=e.replace(new RegExp("=\\?(&|$)"),"="+n+"$1");var f=i.append("script",{id:n,name:n,src:e,async:!0,onload:l,onerror:l,onreadystatechange:function(){/loaded|complete/i.test(this.readyState)&&l()}});window.navigator.userAgent.toLowerCase().indexOf("opera")>-1&&(o=i.append("script",{text:"document.getElementById('"+n+"').onerror();"}),f.async=!1),r&&window.setTimeout(function(){c=a("timeout","timeout"),l()},r),s.appendChild(f),o&&s.appendChild(o)},post:function(e,t,n,r,o,i){var a,u=this,s=u.error,c=document,l=null,f=[],p=0,h=null,d=0,y=function(e){d++||r(e)};u.globalEvent(y,o);var v;try{v=c.createElement('