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 p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i>6|192):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128)),t+=String.fromCharCode(63&n|128))}return t},c=function(e){for(var t,i,n="",o=0,r=0;o>2,r=(3&t)<<4|(i=e.charCodeAt(c++))>>4,s=(15&i)<<2|(n=e.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),u=u+f._keyStr.charAt(o)+f._keyStr.charAt(r)+f._keyStr.charAt(s)+f._keyStr.charAt(a);return u},decode:function(e){try{if(h.btoa&&h.atob)return decodeURIComponent(escape(h.atob(e)))}catch(e){}return f._decode(e)},_decode:function(e){var t,i,n,o,r,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9+/=]/g,"");u>4,i=(15&o)<<4|(r=f._keyStr.indexOf(e.charAt(u++)))>>2,n=(3&r)<<6|(s=f._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==r&&(a+=String.fromCharCode(i)),64!==s&&(a+=String.fromCharCode(n));return a=c(a)}},r=Object.prototype.toString;function _(e){switch(r.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 a(e,t,i){return _(e)===i||(O.error("Invalid "+t+" input type. Expected "+i+" but received "+_(e)),!1)}function u(e){var t=_(e);if("object"!==t)return O.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>w.MAX_PROPERTY_KEYS)return O.error("Error: too many properties (more than 1000), ignoring"),{};var i,n,o,r={};for(var s in e){Object.prototype.hasOwnProperty.call(e,s)&&("string"!==(n=_(i=s))&&(i=String(i),O.warn("WARNING: Non-string property key, received type "+n+', coercing to string "'+i+'"')),null!==(o=R(i,e[s]))&&(r[i]=o))}return r}function v(){for(var e="",t=0;t<22;++t)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(Math.floor(64*Math.random()));return e}function b(e){try{for(var t=document.cookie.split(";"),i=null,n=0;nw.MAX_STRING_LENGTH?e.substring(0,w.MAX_STRING_LENGTH):e},C=["nan","function","arguments","regexp","element"],R=function e(t,i){var n=_(i);if(-1!==C.indexOf(n))O.warn('WARNING: Property key "'+t+'" with invalid value type '+n+", ignoring"),i=null;else if("undefined"===n)i=null;else if("error"===n)i=String(i),O.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+i);else if("array"===n){for(var o=[],r=0;r>16)+(t>>16)+(i>>16)<<16|65535&i}function a(e,t,i,n,o,r){return p((s=p(p(t,e),p(n,r)))<<(a=o)|s>>>32-a,i);var s,a}function d(e,t,i,n,o,r,s){return a(t&i|~t&n,e,t,o,r,s)}function h(e,t,i,n,o,r,s){return a(t&n|i&~n,e,t,o,r,s)}function f(e,t,i,n,o,r,s){return a(t^i^n,e,t,o,r,s)}function v(e,t,i,n,o,r,s){return a(i^(t|~n),e,t,o,r,s)}function u(e,t){var i,n,o,r;e[t>>5]|=128<>>9<<4)]=t;for(var s=1732584193,a=-271733879,u=-1732584194,c=271733878,l=0;l>5]>>>n%32&255);return t}function l(e){var t=[];for(t[(e.length>>2)-1]=void 0,n=0;n>5]|=(255&e.charCodeAt(n/8))<>>4&15)+i.charAt(15&t);return n}function i(e){return unescape(encodeURIComponent(e))}function o(e){return c(u(l(t=i(e)),8*t.length));var t}function r(e,t){return function(e,t){var i,n,o=l(e),r=[],s=[];for(r[15]=s[15]=void 0,16s.options.sessionTimeout||s.options.sessionId;i&&(s.options.unsetParamsReferrerOnNewSession&&s._unsetUTMParams(),s._newSession=!0,s._sessionId=s.options.sessionId||t,s.options.sessionId=void 0,s.options.saveParamsReferrerOncePerSession&&s._trackParamsAndReferrer()),s.options.saveParamsReferrerOncePerSession||s._trackParamsAndReferrer(),s.options.saveEvents&&(Ce(s._unsentEvents),Ce(s._unsentIdentifys)),s._lastEventTime=t,qe(s),s._pendingReadStorage=!1,s._sendEventsIfReady();for(var n=0;nn.length;--o){var r=i.slice(i.length-o).join(".");W.set(this._cookieName,null,{domain:"."+r})}W.set(this._cookieName,null,{})}},Ie.prototype._getInitialDeviceId=function(e,t){if(e)return e;if(this.options.deviceIdFromUrlParam){var i=this._getDeviceIdFromUrlParam(this._getUrlParams());if(i)return i}return this.options.deviceId?this.options.deviceId:t||v()};var Ce=function(e){for(var t=0;t=this.options.eventUploadThreshold||this.options.transport===w.TRANSPORT_BEACON?(this.sendEvents(),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1))},Ie.prototype.clearStorage=function(){return this._metadataStorage.clear()},Ie.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Ie.prototype._setInStorage=function(e,t,i){e.setItem(t+this._storageSuffix,i)};var Ue=function(e){var t,i;e._useOldCookie?"object"!==_(t=e.cookieStorage.get(e._oldCookiename))||Pe(e,t):"object"===_(i=e._metadataStorage.load())&&Pe(e,i)},De=function(e){var t=e.cookieStorage.get(e._oldCookiename);"object"===_(t)&&(Pe(e,t),qe(e))},Pe=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)};Ie.prototype._initUtmData=function(e,t){e=e||this._getUrlParams(),t=t||this.cookieStorage.get("__utmz");var i=oe(t,e);return je(this,i),i},Ie.prototype._unsetUTMParams=function(){var e=new re;e.unset(w.REFERRER),e.unset(w.UTM_SOURCE),e.unset(w.UTM_MEDIUM),e.unset(w.UTM_CAMPAIGN),e.unset(w.UTM_TERM),e.unset(w.UTM_CONTENT),this.identify(e)};var je=function(e,t){if("object"===_(t)&&0!==Object.keys(t).length){var i=new re;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i.setOnce("initial_"+n,t[n]),i.set(n,t[n]));e.identify(i)}};Ie.prototype._getReferrer=function(){return"undefined"!=typeof document?document.referrer:""},Ie.prototype._getUrlParams=function(){return h.location.search},Ie.prototype._saveGclid=function(e){var t=M("gclid",e);if(!q(t)){var i={gclid:t};return je(this,i),i}},Ie.prototype._saveFbclid=function(e){var t=M("fbclid",e);if(!q(t)){var i={fbclid:t};return je(this,i),i}},Ie.prototype._getDeviceIdFromUrlParam=function(e){return M(w.AMP_DEVICE_ID_PARAM,e)},Ie.prototype._getReferringDomain=function(e){if(q(e))return null;var t=e.split("/");return 3<=t.length?t[2]:null},Ie.prototype._saveReferrer=function(e){if(!q(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};return je(this,t),t}},Ie.prototype.saveEvents=function(){try{var e=JSON.stringify(this._unsentEvents.map(function(e){return e.event}));this._setInStorage(ne,this.options.unsentKey,e)}catch(e){}try{var t=JSON.stringify(this._unsentIdentifys.map(function(e){return e.event}));this._setInStorage(ne,this.options.unsentIdentifyKey,t)}catch(e){}},Ie.prototype.setDomain=function(e){if(this._shouldDeferCall())return this._q.push(["setDomain"].concat(Array.prototype.slice.call(arguments,0)));if(L(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,Ue(this),qe(this)}catch(e){P.error(e)}},Ie.prototype.setUserId=function(e,t){var i=1this.options.sessionTimeout)||(this._sessionId=d,this._runNewSessionStartCallbacks()),this._lastEventTime=d,qe(this);var h=this._ua.browser.name,f=this._ua.browser.major,v=this._ua.device.model||this._ua.os.name,b=this._ua.device.vendor;n=n||{};var g=y({},this._apiPropertiesTrackingOptions);i=y({},i||{},g),t=t||{},o=o||{},r=r||{};var m={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:d,event_id:l,session_id:this._sessionId||-1,event_type:e,version_name:this.options.versionName||null,platform:Ve(this,"platform")?this.options.platform:null,os_name:Ve(this,"os_name")&&h||null,os_version:Ve(this,"os_version")&&f||null,device_model:Ve(this,"device_model")&&v||null,device_manufacturer:Ve(this,"device_manufacturer")&&b||null,language:Ve(this,"language")?this.options.language:null,api_properties:i,event_properties:G(F(t)),user_properties:G(F(n)),uuid:function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}(),library:this.options.library,sequence_number:p,groups:G(V(o)),group_properties:G(F(r)),user_agent:this._userAgent};return Ge(this)&&(m.plan={branch:this.options.plan.branch||void 0,source:this.options.plan.source||void 0,version:this.options.plan.version||void 0,versionId:this.options.plan.versionId||void 0}),e===w.IDENTIFY_EVENT||e===w.GROUP_IDENTIFY_EVENT?(this._unsentIdentifys.push({event:m,callback:a,errorCallback:u}),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push({event:m,callback:a,errorCallback:u}),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(),e===w.IDENTIFY_EVENT&&this._connector&&this._connector.identityStore.editIdentity().updateUserProperties(G(F(n))).commit(),l}catch(e){P.error(e)}else ze(a,u,0,"No request sent",{reason:"Missing eventType"})};var Ge=function(e){return e.options.plan&&(e.options.plan.source||e.options.plan.branch||e.options.plan.version||e.options.plan.versionId)},Ve=function(e,t){return!!e.options.trackingOptions[t]},Le=function(e){for(var t=["city","country","dma","ip_address","region"],i={},n=0;nthis.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount).forEach(function(e){ze(e.callback,e.errorCallback,0,"No request sent",{reason:"Event dropped because options.savedMaxCount exceeded. User may be offline or have a content blocker"})})},Ie.prototype.logEvent=function(e,t,i,n,o){var r=4i?r.push(a):a.callback&&a.callback(n,o)}e[t]=r}};Ie.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!==w.TRANSPORT_BEACON){if(this._sending)return;this._sending=!0}var e=(this.options.forceHttps||"https:"===h.location.protocol?"https":"http")+"://"+this.options.apiEndpoint,i=Math.min(this._unsentCount(),this.options.uploadBatchSize),t=this._mergeEventsAndIdentifys(i),n=t.maxEventId,o=t.maxIdentifyId,r=JSON.stringify(t.eventsToSend.map(function(e){return e.event})),s=(new Date).getTime(),a={client:this.options.apiKey,e:r,v:w.API_VERSION,upload_time:s,checksum:pe(w.API_VERSION+this.options.apiKey+r+s)};if(this.options.transport!==w.TRANSPORT_BEACON){var u=this;try{new ye(e,a,this.options.headers).send(function(e,t){u._sending=!1;try{200===e&&"success"===t?(u.removeEvents(n,o,e,t),u.options.saveEvents&&u.saveEvents(),u._sendEventsIfReady()):(u._logErrorsOnEvents(n,o,e,t),413===e&&(1===u.options.uploadBatchSize&&u.removeEvents(n,o,e,t),u.options.uploadBatchSize=Math.ceil(i/2),u.sendEvents()))}catch(e){}})}catch(e){var c="Request failed to send";P.error(c),u._logErrorsOnEvents(n,o,0,c),u.removeEvents(n,o,0,c,{reason:e.message})}}else{navigator.sendBeacon(e,new URLSearchParams(a))?(this.removeEvents(n,o,200,"success"),this.options.saveEvents&&this.saveEvents()):this._logErrorsOnEvents(n,o,0,"")}}}else this.removeEvents(1/0,1/0,0,"No request sent",{reason:"API key not set"})},Ie.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],i=0,n=-1,o=0,r=-1;t.length=this._unsentIdentifys.length,u=i>=this._unsentEvents.length;if(u&&a){P.error("Merging Events and Identifys, less events and identifys than expected");break}a||!u&&(!("sequence_number"in this._unsentEvents[i].event)||this._unsentEvents[i].event.sequence_number