var amplitude=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n>6|192):(t+=String.fromCharCode(i>>12|224),t+=String.fromCharCode(i>>6&63|128)),t+=String.fromCharCode(63&i|128))}return t},w=function(e){for(var t,n,i="",o=0,r=0;o>2,r=(3&t)<<4|(n=e.charCodeAt(c++))>>4,s=(15&n)<<2|(i=e.charCodeAt(c++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),u=u+E._keyStr.charAt(o)+E._keyStr.charAt(r)+E._keyStr.charAt(s)+E._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return E._decode(e)},_decode:function(e){var t,n,i,o,r,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");u>4,n=(15&o)<<4|(r=E._keyStr.indexOf(e.charAt(u++)))>>2,i=(3&r)<<6|(s=E._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==r&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(i));return a=w(a)}},I=Object.prototype.toString;function b(e){switch(I.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!=e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)?"buffer":t(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))}function S(e,t,n){return b(e)===n||(q.error("Invalid "+t+" input type. Expected "+n+" but received "+b(e)),!1)}function T(e){var t=b(e);if("object"!==t)return q.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>y.MAX_PROPERTY_KEYS)return q.error("Error: too many properties (more than 1000), ignoring"),{};var n,i,o,r={};for(var s in e){Object.prototype.hasOwnProperty.call(e,s)&&("string"!==(i=b(n=s))&&(n=String(n),q.warn("WARNING: Non-string property key, received type "+i+', coercing to string "'+n+'"')),null!==(o=G(n,e[s]))&&(r[n]=o))}return r}function N(){for(var e="",t=0;t<22;++t)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(Math.floor(64*Math.random()));return e}function O(e){try{for(var t=document.cookie.split(";"),n=null,i=0;iy.MAX_STRING_LENGTH?e.substring(0,y.MAX_STRING_LENGTH):e},L=["nan","function","arguments","regexp","element"],G=function e(t,n){var i=b(n);if(-1!==L.indexOf(i))q.warn('WARNING: Property key "'+t+'" with invalid value type '+i+", ignoring"),n=null;else if("undefined"===i)n=null;else if("error"===i)n=String(n),q.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===i){for(var o=[],r=0;r>16)+(t>>16)+(n>>16)<<16|65535&n}function a(e,t,n,i,o,r){return p((s=p(p(t,e),p(i,r)))<<(a=o)|s>>>32-a,n);var s,a}function d(e,t,n,i,o,r,s){return a(t&n|~t&i,e,t,o,r,s)}function h(e,t,n,i,o,r,s){return a(t&i|n&~i,e,t,o,r,s)}function f(e,t,n,i,o,r,s){return a(t^n^i,e,t,o,r,s)}function v(e,t,n,i,o,r,s){return a(n^(t|~i),e,t,o,r,s)}function u(e,t){var n,i,o,r;e[t>>5]|=128<>>9<<4)]=t;for(var s=1732584193,a=-271733879,u=-1732584194,c=271733878,l=0;l>5]>>>i%32&255);return t}function l(e){var t=[];for(t[(e.length>>2)-1]=void 0,i=0;i>5]|=(255&e.charCodeAt(i/8))<>>4&15)+n.charAt(15&t);return i}function n(e){return unescape(encodeURIComponent(e))}function o(e){return c(u(l(t=n(e)),8*t.length));var t}function r(e,t){return function(e,t){var n,i,o=l(e),r=[],s=[];for(r[15]=s[15]=void 0,16r.options.sessionTimeout)||(r.options.unsetParamsReferrerOnNewSession&&r._unsetUTMParams(),r._newSession=!0,r._sessionId=t,r.options.saveParamsReferrerOncePerSession&&r._trackParamsAndReferrer()),r.options.saveParamsReferrerOncePerSession||r._trackParamsAndReferrer(),r.options.saveEvents&&(De(r._unsentEvents),De(r._unsentIdentifys)),r._lastEventTime=t,qe(r),r._pendingReadStorage=!1,r._sendEventsIfReady();for(var n=0;ni.length;--o){var r=n.slice(n.length-o).join(".");ee.set(this._cookieName,null,{domain:"."+r})}ee.set(this._cookieName,null,{})}},Ae.prototype._getInitialDeviceId=function(e,t){if(e)return e;if(this.options.deviceIdFromUrlParam){var n=this._getDeviceIdFromUrlParam(this._getUrlParams());if(n)return n}return this.options.deviceId?this.options.deviceId:t||N()};var De=function(e){for(var t=0;t=this.options.eventUploadThreshold||this.options.transport===y.TRANSPORT_BEACON?(this.sendEvents(),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1))},Ae.prototype.clearStorage=function(){return this._metadataStorage.clear()},Ae.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Ae.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var xe=function(e){var t,n;e._useOldCookie?"object"!==b(t=e.cookieStorage.get(e._oldCookiename))||je(e,t):"object"===b(n=e._metadataStorage.load())&&je(e,n)},Ue=function(e){var t=e.cookieStorage.get(e._oldCookiename);"object"===b(t)&&(je(e,t),qe(e))},je=function(e,t){t.deviceId&&(e.options.deviceId=t.deviceId),t.userId&&(e.options.userId=t.userId),null!==t.optOut&&void 0!==t.optOut&&!1!==t.optOut&&(e.options.optOut=t.optOut),t.sessionId&&(e._sessionId=parseInt(t.sessionId,10)),t.lastEventTime&&(e._lastEventTime=parseInt(t.lastEventTime,10)),t.eventId&&(e._eventId=parseInt(t.eventId,10)),t.identifyId&&(e._identifyId=parseInt(t.identifyId,10)),t.sequenceNumber&&(e._sequenceNumber=parseInt(t.sequenceNumber,10))},qe=function(e){var t={deviceId:e.options.deviceId,userId:e.options.userId,optOut:e.options.optOut,sessionId:e._sessionId,lastEventTime:e._lastEventTime,eventId:e._eventId,identifyId:e._identifyId,sequenceNumber:e._sequenceNumber};e._useOldCookie?e.cookieStorage.set(e.options.cookieName+e._storageSuffix,t):e._metadataStorage.save(t)};Ae.prototype._initUtmData=function(e,t){e=e||this._getUrlParams(),t=t||this.cookieStorage.get("__utmz");var n=le(t,e);return Me(this,n),n},Ae.prototype._unsetUTMParams=function(){var e=new pe;e.unset(y.REFERRER),e.unset(y.UTM_SOURCE),e.unset(y.UTM_MEDIUM),e.unset(y.UTM_CAMPAIGN),e.unset(y.UTM_TERM),e.unset(y.UTM_CONTENT),this.identify(e)};var Me=function(e,t){if("object"===b(t)&&0!==Object.keys(t).length){var n=new pe;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n.setOnce("initial_"+i,t[i]),n.set(i,t[i]));e.identify(n)}};Ae.prototype._getReferrer=function(){return document.referrer},Ae.prototype._getUrlParams=function(){return location.search},Ae.prototype._saveGclid=function(e){var t=X("gclid",e);if(!z(t)){var n={gclid:t};return Me(this,n),n}},Ae.prototype._saveFbclid=function(e){var t=X("fbclid",e);if(!z(t)){var n={fbclid:t};return Me(this,n),n}},Ae.prototype._getDeviceIdFromUrlParam=function(e){return X(y.AMP_DEVICE_ID_PARAM,e)},Ae.prototype._getReferringDomain=function(e){if(z(e))return null;var t=e.split("/");return 3<=t.length?t[2]:null},Ae.prototype._saveReferrer=function(e){if(!z(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};return Me(this,t),t}},Ae.prototype.saveEvents=function(){try{var e=JSON.stringify(this._unsentEvents.map(function(e){return e.event}));this._setInStorage(ce,this.options.unsentKey,e)}catch(e){}try{var t=JSON.stringify(this._unsentIdentifys.map(function(e){return e.event}));this._setInStorage(ce,this.options.unsentIdentifyKey,t)}catch(e){}},Ae.prototype.setDomain=function(e){if(this._shouldDeferCall())return this._q.push(["setDomain"].concat(Array.prototype.slice.call(arguments,0)));if(H(e,"domain","string"))try{this.cookieStorage.options({expirationDays:this.options.cookieExpiration,secure:this.options.secureCookie,domain:e,sameSite:this.options.sameSiteCookie}),this.options.domain=this.cookieStorage.options().domain,xe(this),qe(this)}catch(e){B.error(e)}},Ae.prototype.setUserId=function(e){if(this._shouldDeferCall())return this._q.push(["setUserId"].concat(Array.prototype.slice.call(arguments,0)));try{this.options.userId=null!=e&&""+e||null,qe(this)}catch(e){B.error(e)}},Ae.prototype.setGroup=function(e,t){if(this._shouldDeferCall())return this._q.push(["setGroup"].concat(Array.prototype.slice.call(arguments,0)));var n,i;this._apiKeySet("setGroup()")&&H(e,"groupType","string")&&!z(e)&&((n={})[e]=t,i=(new pe).set(e,t),this._logEvent(y.IDENTIFY_EVENT,null,null,i.userPropertiesOperations,n,null,null,null))},Ae.prototype.setOptOut=function(e){if(this._shouldDeferCall())return this._q.push(["setOptOut"].concat(Array.prototype.slice.call(arguments,0)));if(H(e,"enable","boolean"))try{this.options.optOut=e,qe(this)}catch(e){B.error(e)}},Ae.prototype.setSessionId=function(e){if(H(e,"sessionId","number"))try{this._sessionId=e,qe(this)}catch(e){B.error(e)}},Ae.prototype.resetSessionId=function(){this.setSessionId((new Date).getTime())},Ae.prototype.regenerateDeviceId=function(){if(this._shouldDeferCall())return this._q.push(["regenerateDeviceId"].concat(Array.prototype.slice.call(arguments,0)));this.setDeviceId(N())},Ae.prototype.setDeviceId=function(e){if(this._shouldDeferCall())return this._q.push(["setDeviceId"].concat(Array.prototype.slice.call(arguments,0)));if(Q(e))try{z(e)||(this.options.deviceId=""+e,qe(this))}catch(e){B.error(e)}},Ae.prototype.setTransport=function(e){if(this._shouldDeferCall())return this._q.push(["setTransport"].concat(Array.prototype.slice.call(arguments,0)));J(e)&&(this.options.transport=e)},Ae.prototype.setUserProperties=function(e){if(this._shouldDeferCall())return this._q.push(["setUserProperties"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("setUserProperties()")&&H(e,"userProperties","object")){var t=W(Y(e));if(0!==Object.keys(t).length){var n=new pe;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.set(i,t[i]);this.identify(n)}}},Ae.prototype.clearUserProperties=function(){if(this._shouldDeferCall())return this._q.push(["clearUserProperties"].concat(Array.prototype.slice.call(arguments,0)));var e;this._apiKeySet("clearUserProperties()")&&((e=new pe).clearAll(),this.identify(e))};function Ve(e,t){for(var n=0;nthis.options.sessionTimeout)||(this._sessionId=p),this._lastEventTime=p,qe(this);var d=this._ua.browser.name,h=this._ua.browser.major,f=this._ua.os.name;i=i||{};var v=_({},this._apiPropertiesTrackingOptions);n=_({},n||{},v),t=t||{},o=o||{},r=r||{};var g={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:p,event_id:c,session_id:this._sessionId||-1,event_type:e,version_name:this.options.versionName||null,platform:Le(this,"platform")?this.options.platform:null,os_name:Le(this,"os_name")&&d||null,os_version:Le(this,"os_version")&&h||null,device_model:Le(this,"device_model")&&f||null,language:Le(this,"language")?this.options.language:null,api_properties:n,event_properties:W(Y(t)),user_properties:W(Y(i)),uuid:function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}(),library:{name:"amplitude-js",version:Re},sequence_number:l,groups:W($(o)),group_properties:W(Y(r)),user_agent:this._userAgent};return e===y.IDENTIFY_EVENT||e===y.GROUP_IDENTIFY_EVENT?(this._unsentIdentifys.push({event:g,callback:a,errorCallback:u}),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push({event:g,callback:a,errorCallback:u}),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(),c}catch(e){B.error(e)}else Ke(a,u,0,"No request sent",{reason:"Missing eventType"})};var Le=function(e,t){return!!e.options.trackingOptions[t]},Ge=function(e){for(var t=["city","country","dma","ip_address","region"],n={},i=0;ithis.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount).forEach(function(e){Ke(e.callback,e.errorCallback,0,"No request sent",{reason:"Event dropped because options.savedMaxCount exceeded. User may be offline or have a content blocker"})})},Ae.prototype.logEvent=function(e,t,n,i){return this._shouldDeferCall()?this._q.push(["logEvent"].concat(Array.prototype.slice.call(arguments,0))):this.logEventWithTimestamp(e,t,null,n,i)},Ae.prototype.logEventWithTimestamp=function(e,t,n,i,o){return this._shouldDeferCall()?this._q.push(["logEventWithTimestamp"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logEvent()")?H(e,"eventType","string")?z(e)?(Ke(i,o,0,"No request sent",{reason:"Missing eventType"}),-1):this._logEvent(e,t,null,null,null,null,n,i,o):(Ke(i,o,0,"No request sent",{reason:"Invalid type for eventType"}),-1):(Ke(i,o,0,"No request sent",{reason:"API key not set"}),-1)},Ae.prototype.logEventWithGroups=function(e,t,n,i,o){return this._shouldDeferCall()?this._q.push(["logEventWithGroups"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logEventWithGroups()")?H(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,null,i,o):(Ke(event.callback,event.errorCallback,0,"No request sent",{reason:"Invalid type for eventType"}),-1):(Ke(event.callback,event.errorCallback,0,"No request sent",{reason:"API key not set"}),-1)};function Fe(e){return!isNaN(parseFloat(e))&&isFinite(e)}var Ke=function(e,t,n,i,o){"function"===b(e)&&e(n,i,o),"function"===b(t)&&t(n,i,o)};Ae.prototype.logRevenueV2=function(e){if(this._shouldDeferCall())return this._q.push(["logRevenueV2"].concat(Array.prototype.slice.call(arguments,0)));if(this._apiKeySet("logRevenueV2()"))if("object"===b(e)&&Object.prototype.hasOwnProperty.call(e,"_q")&&(e=Ve(new Oe,e)),e instanceof Oe){if(e&&e._isValidRevenue())return this.logEvent(y.REVENUE_EVENT,e._toJSONObject())}else B.error("Invalid revenue input type. Expected Revenue object but saw "+b(e))},Ae.prototype.logRevenue=function(e,t,n){return this._shouldDeferCall()?this._q.push(["logRevenue"].concat(Array.prototype.slice.call(arguments,0))):this._apiKeySet("logRevenue()")&&Fe(e)&&(void 0===t||Fe(t))?this._logEvent(y.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null,null):-1},Ae.prototype._logErrorsOnEvents=function(e,t,n,i){for(var o=["_unsentEvents","_unsentIdentifys"],r=0;rn?r.push(a):a.callback&&a.callback(i,o)}e[t]=r}};Ae.prototype.sendEvents=function(){if(this._apiKeySet("sendEvents()")){if(this.options.optOut)this.removeEvents(1/0,1/0,0,"No request sent",{reason:"Opt out is set to true"});else if(0!==this._unsentCount()){if(this.options.transport!==y.TRANSPORT_BEACON){if(this._sending)return;this._sending=!0}var n,e=(this.options.forceHttps||"https:"===window.location.protocol?"https":"http")+"://"+this.options.apiEndpoint,i=Math.min(this._unsentCount(),this.options.uploadBatchSize),t=this._mergeEventsAndIdentifys(i),o=t.maxEventId,r=t.maxIdentifyId,s=JSON.stringify(t.eventsToSend.map(function(e){return e.event})),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:y.API_VERSION,upload_time:a,checksum:_e(y.API_VERSION+this.options.apiKey+s+a)};this.options.transport!==y.TRANSPORT_BEACON?new Te(e,u,(n=this).options.headers).send(function(e,t){n._sending=!1;try{200===e&&"success"===t?(n.removeEvents(o,r,e,t),n.options.saveEvents&&n.saveEvents(),n._sendEventsIfReady()):(n._logErrorsOnEvents(o,r,e,t),413===e&&(1===n.options.uploadBatchSize&&n.removeEvents(o,r,e,t),n.options.uploadBatchSize=Math.ceil(i/2),n.sendEvents()))}catch(e){}}):navigator.sendBeacon(e,new URLSearchParams(u))?(this.removeEvents(o,r,200,"success"),this.options.saveEvents&&this.saveEvents()):this._logErrorsOnEvents(o,r,0,"")}}else this.removeEvents(1/0,1/0,0,"No request sent",{reason:"API key not set"})},Ae.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,i=-1,o=0,r=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){B.error("Merging Events and Identifys, less events and identifys than expected");break}a||!u&&(!("sequence_number"in this._unsentEvents[n].event)||this._unsentEvents[n].event.sequence_number