@amplitude/analytics-browser 2.34.0 → 2.34.1-feat-zoning-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cjs/config.d.ts +1 -1
- package/lib/cjs/config.d.ts.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/config.d.ts +1 -1
- package/lib/esm/config.d.ts.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
- package/lib/scripts/amplitude-bookmarklet.html +1 -1
- package/lib/scripts/amplitude-gtm-min.js +1 -1
- package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
- package/lib/scripts/amplitude-gtm-min.js.map +1 -1
- package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -1
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/amplitude-snippet-instructions.html +1 -1
- package/lib/scripts/amplitude-snippet-min.js +1 -1
- package/lib/scripts/config.d.ts +1 -1
- package/lib/scripts/config.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/lib/scripts/version.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n,r,i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function s(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})}function a(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function l(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(n||(n={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(r||(r={}));var d,f="AMP",v="".concat(f,"_unsent"),p="$default_instance",h="https://api2.amplitude.com/2/httpapi",g="dclid",m="fbclid",y="gbraid",b="gclid",w="ko_click_id",E="li_fat_id",S="msclkid",T="rdt_cid",k="ttclid",_="twclid",I="wbraid",P={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},O=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],A=["authorization","cookie","set-cookie"],C=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!x(t,n))return!1}return!0},x=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)i=i&&C(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return C(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},R=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return i({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(d.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(d.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(d.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(d.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(d.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(d.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(d.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(d.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(d.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[d.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[d.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===d.ADD?"number"==typeof n:e===d.UNSET||e===d.REMOVE||x(t,n)))},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(d||(d={}));var D,L=[d.CLEAR_ALL,d.UNSET,d.SET,d.SET_ONCE,d.ADD,d.APPEND,d.PREPEND,d.PREINSERT,d.POSTINSERT,d.REMOVE];!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(D||(D={}));var N,j=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=D.Unknown),{event:e,code:t,message:n}},M=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},U=l([],c(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),q=function(e){var t,n=M();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,q)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,l([],c(r.entries()),!1).map(function(e){var t=c(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(U[r]):U[r]}).join("")},F=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,r;return s(this,void 0,void 0,function(){return a(this,function(i){switch(i.label){case 0:return this.plugins.some(function(t){return t.name===e.name})?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=q(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}})})},e.prototype.deregister=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i;return a(this,function(o){switch(o.label){case 0:return r=this.plugins.findIndex(function(t){return t.name===e}),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}})})},e.prototype.reset=function(e){this.applying=!1,this.plugins.map(function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)}),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(n){t.queue.push([e,n]),t.scheduleApply(0)})},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout(function(){t.apply(t.queue.shift()).then(function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)})},e))},e.prototype.apply=function(e){return s(this,void 0,void 0,function(){var t,n,r,o,s,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k;return a(this,function(a){switch(a.label){case 0:if(!e)return[2];t=c(e,1),n=t[0],r=c(e,2),o=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),s=this.plugins.filter(function(e){return"before"===e.type}),a.label=1;case 1:a.trys.push([1,6,7,8]),l=u(s),d=l.next(),a.label=2;case 2:return d.done?[3,5]:(g=d.value).execute?[4,g.execute(i({},n))]:[3,4];case 3:if(null===(m=a.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),o({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),a.label=4;case 4:return d=l.next(),[3,2];case 5:return[3,8];case 6:return f=a.sent(),E={error:f},[3,8];case 7:try{d&&!d.done&&(S=l.return)&&S.call(l)}finally{if(E)throw E.error}return[7];case 8:v=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),a.label=9;case 9:a.trys.push([9,14,15,16]),p=u(v),h=p.next(),a.label=10;case 10:return h.done?[3,13]:(g=h.value).execute?[4,g.execute(i({},n))]:[3,12];case 11:if(null===(m=a.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),o({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),a.label=12;case 12:return h=p.next(),[3,10];case 13:return[3,16];case 14:return y=a.sent(),T={error:y},[3,16];case 15:try{h&&!h.done&&(k=p.return)&&k.call(p)}finally{if(T)throw T.error}return[7];case 16:return b=this.plugins.filter(function(e){return"destination"===e.type}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),w=b.map(function(e){var t=i({},n);return e.execute(t).catch(function(e){return j(t,0,String(e))})}),Promise.all(w).then(function(e){var t=c(e,1)[0]||j(n,100,"Event not tracked, no destination plugins on the instance");o(t)}),[2]}})})},e.prototype.flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r=this;return a(this,function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return r.apply(e)}))];case 1:return i.sent(),t=this.plugins.filter(function(e){return"destination"===e.type}),n=t.map(function(e){return e.flush&&e.flush()}),[4,Promise.all(n)];case 2:return i.sent(),[2]}})})},e.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)})},e}(),B=function(e,t){return i(i({},t),{event_type:r.IDENTIFY,user_properties:e.getUserProperties()})},H=function(e){return{promise:e||Promise.resolve()}},V=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new F(this),this.name=e}return e.prototype._init=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}})})},e.prototype.runQueuedFunctions=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o,s,c,l;return a(this,function(a){switch(a.label){case 0:t=this[e],this[e]=[],a.label=1;case 1:a.trys.push([1,8,9,10]),n=u(t),r=n.next(),a.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return a.sent(),[3,6];case 4:return[4,o];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return s=a.sent(),c={error:s},[3,10];case 9:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:a.sent(),a.label=12;case 12:return[2]}})})},e.prototype.track=function(e,t,n){var r=function(e,t,n){return i(i(i({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return H(this.dispatch(r))},e.prototype.identify=function(e,t){var n=B(e,t);return H(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,o){var s=function(e,t,n,o){var s;return i(i({},o),{event_type:r.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(s={},s[e]=t,s)})}(e,t,n,o);return H(this.dispatch(s))},e.prototype.setGroup=function(e,t,n){var o=function(e,t,n){var o,s=new R;return s.set(e,t),i(i({},n),{event_type:r.IDENTIFY,user_properties:s.getUserProperties(),groups:(o={},o[e]=t,o)})}(e,t,n);return H(this.dispatch(o))},e.prototype.revenue=function(e,t){var n=function(e,t){return i(i({},t),{event_type:r.REVENUE,event_properties:e.getEventProperties()})}(e,t);return H(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),H())},e.prototype._addPlugin=function(e){return H(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),H())},e.prototype._removePlugin=function(e){return H(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(j(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return s(this,void 0,void 0,function(){var t=this;return a(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))})]})})},e.prototype.getOperationAppliedUserProperties=function(e){var t={};if(void 0===e)return t;var r={};return Object.keys(e).forEach(function(t){Object.values(n).includes(t)||(r[t]=e[t])}),L.forEach(function(r){if(Object.keys(e).includes(r)){var i=e[r];switch(r){case n.CLEAR_ALL:Object.keys(t).forEach(function(e){delete t[e]});break;case n.UNSET:Object.keys(i).forEach(function(e){delete t[e]});break;case n.SET:Object.assign(t,i)}}}),Object.assign(t,r),t},e.prototype.process=function(e){return s(this,void 0,void 0,function(){var t,n,i,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),this.config.optOut?[2,j(e,0,"Event skipped due to optOut config")]:(e.event_type===r.IDENTIFY&&(t=this.getOperationAppliedUserProperties(e.user_properties),this.timeline.onIdentityChanged({userProperties:t})),[4,this.timeline.push(e)]);case 1:return 200===(o=s.sent()).code?this.config.loggerProvider.log(o.message):100===o.code?this.config.loggerProvider.warn(o.message):this.config.loggerProvider.error(o.message),[2,o];case 2:return n=s.sent(),i=String(n),this.config.loggerProvider.error(i),[2,o=j(e,0,i)];case 3:return[2]}})})},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.timeline.onOptOutChanged(e),this.config.optOut=Boolean(e))},e.prototype.flush=function(){return H(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find(function(t){return t.name===e});if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter(function(t){return t instanceof e})},e}(),z=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){return C(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?i({},this.properties):{};return e[N.REVENUE_PRODUCT_ID]=this.productId,e[N.REVENUE_QUANTITY]=this.quantity,e[N.REVENUE_PRICE]=this.price,e[N.REVENUE_TYPE]=this.revenueType,e[N.REVENUE_CURRENCY]=this.currency,e[N.REVENUE]=this.revenue,e[N.RECEIPT]=this.receipt,e[N.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(N||(N={}));var J;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(J||(J={}));var $="Amplitude Logger ",K=function(){function e(){this.logLevel=J.None}return e.prototype.disable=function(){this.logLevel=J.None},e.prototype.enable=function(e){void 0===e&&(e=J.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Verbose||console.log("".concat($,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Warn||console.warn("".concat($,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Error||console.error("".concat($,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Debug||console.log("".concat($,"[Debug]: ").concat(e.join(" ")))},e}(),W=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:p,logLevel:J.Warn,loggerProvider:new K,offline:!1,optOut:!1,serverUrl:h,serverZone:"US",useBatch:!1}},G=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=W();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=Y(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),Q=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":h},Y=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=W().serverZone),void 0===n&&(n=W().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:W().serverZone;return{serverZone:r,serverUrl:Q(r,n)}},X=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function Z(e){return e>=200&&e<300}var ee=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},te=function(e){return function(){var t=i({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ne=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=u(t.split(".")),o=i.next();!o.done;o=i.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},re=function(e,t){return function(){var n,r,i={};try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=ne(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ie=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n(),u=a.logger,c=a.logLevel;if(c&&c<J.Debug||!c||!u)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:ee(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),u.debug(JSON.stringify(l,null,2))}):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),u.debug(JSON.stringify(l,null,2))),d}};function oe(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var se=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return s(this,void 0,void 0,function(){var n,r=this;return a(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(v,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map(function(e){return r.execute(e)})).catch(),[2,Promise.resolve(void 0)]}})})},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=q()),new Promise(function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter(function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)})},e.prototype.scheduleEvents=function(e){var t=this;e.forEach(function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)})},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout(function(){t.queue=t.queue.map(function(e){return e.timeout=0,e}),t.flush(!0)},e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),s(this,void 0,void 0,function(){var t,n,r=this;return a(this,function(i){switch(i.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):n.push(e)}),o=t,u=this.config.flushQueueSize,c=Math.max(u,1),[4,o.reduce(function(e,t,n){var r=Math.floor(n/c);return e[r]||(e[r]=[]),e[r].push(t),e},[]).reduce(function(t,n){return s(r,void 0,void 0,function(){return a(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}})})},Promise.resolve())]);case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var o,u,c})})},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),s(this,void 0,void 0,function(){var r,i,s,u,c;return a(this,function(a){switch(a.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,o(t,["extra"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new X,a.label=1;case 1:return a.trys.push([1,3,,4]),i=Y(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(i,r)];case 2:return null===(s=a.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(s,e),[3,4]):("body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(oe(s))):this.fulfillRequest(e,s.statusCode,s.status),[2]);case 3:return u=a.sent(),c=(l=u)instanceof Error?l.message:String(l),this.config.loggerProvider.error(c),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:c,stack_trace:ee()}),this.handleResponse({status:D.Failed,statusCode:0},e),[3,4];case 4:return[2]}var l})})},e.prototype.handleResponse=function(e,t){var n;Z(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map(function(e){return e.event.event_type}),code:e.statusCode,status:e.status,body:oe(e),stack_trace:ee()});var r=e.status;switch(r){case D.Success:this.handleSuccessResponse(e,t);break;case D.Invalid:this.handleInvalidResponse(e,t);break;case D.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case D.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=l(l(l(l([],c(Object.values(e.body.eventsWithInvalidFields)),!1),c(Object.values(e.body.eventsWithMissingFields)),!1),c(Object.values(e.body.eventsWithInvalidIdLengths)),!1),c(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter(function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)});o.length>0&&this.config.loggerProvider.warn(oe(e));var s=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(s)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(oe(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),a=new Set(i),u=new Set(o),c=t.filter(function(t,r){if(!(t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)))return u.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)});c.length>0&&this.config.loggerProvider.warn(oe(e));var l=this.removeEventsExceedFlushMaxRetries(c);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map(function(e){return e.timeout=e.attempts*t.retryTimeout,e}),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;Z(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map(function(e){return e.event.event_type}),code:t,message:n,stack_trace:ee()})),this.removeEvents(e),e.forEach(function(e){return e.callback(j(e.event,t,n))})},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(e){return e.event});this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(t){return!e.some(function(e){return e.event.insert_id===t.event.insert_id})}),this.saveEvents()},e}(),ae=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:ue(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),ue=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},ce=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(t){e(t)}),this.queue=[])},e}(),le=function(){return le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},le.apply(this,arguments)};function de(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function fe(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var ve=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=de(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next()){if(s.value===i)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(!a||!u){var c=Object.keys(e).sort(),l=Object.keys(t).sort();if(!ve(c,l))return!1;var d=!0;return Object.keys(e).forEach(function(n){ve(e[n],t[n])||(d=!1)}),d}for(var f=0;f<e.length;f++)if(!ve(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var pe=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=le({},this.identity.userProperties),n=le(le({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,s,a,u=n.userProperties||{};try{for(var c=de(Object.entries(e)),l=c.next();!l.done;l=c.next()){var d=fe(l.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var p=(i=void 0,de(Object.entries(v))),h=p.next();!h.done;h=p.next()){var g=fe(h.value,2),m=g[0],y=g[1];u[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(s=void 0,de(Object.keys(v))),w=b.next();!w.done;w=b.next()){delete u[m=w.value]}}catch(e){s={error:e}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return le({},this.identity)},e.prototype.setIdentity=function(e){var t=le({},this.identity);this.identity=le({},e),ve(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,ge=function(){function e(){this.identityStore=new pe,this.eventBridge=new ce,this.applicationContextProvider=new ae}return e.getInstance=function(t){return he.analyticsConnectorInstances||(he.analyticsConnectorInstances={}),he.analyticsConnectorInstances[t]||(he.analyticsConnectorInstances[t]=new e),he.analyticsConnectorInstances[t]},e}(),me=function(e){return void 0===e&&(e=p),ge.getInstance(e)},ye=function(){function e(){this.name="identity",this.type="before",this.identityStore=me().identityStore}return e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return e.instanceName&&(this.identityStore=me(e.instanceName).identityStore),[2]})})},e}(),be=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},we=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[f,t,e.substring(0,n)].filter(Boolean).join("_")},Ee=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},Se=function(){var e,t=M();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce(function(e,t){var n=t.split("=",2),r=Te(n[0]),i=Te(n[1]);return i?(e[r]=i,e):e},{}):{}},Te=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},ke=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},_e=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Ie=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},Pe=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}})})},e.prototype.set=function(e,t){return s(this,void 0,void 0,function(){return a(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),Oe=function(){function e(e,t){void 0===t&&(t={}),this.options=i({},e),this.config=t}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:if(!M())return[2,!1];e.testValue=String(Date.now()),t=i(i({},this.options),{expirationDays:.003}),n=new e(t),r="AMP_TEST_".concat(q().substring(0,8)),o.label=1;case 1:return o.trys.push([1,4,5,7]),[4,n.set(r,e.testValue)];case 2:return o.sent(),[4,n.get(r)];case 3:return[2,o.sent()===e.testValue];case 4:return o.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return o.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t,n;return a(this,function(r){switch(r.label){case 0:return[4,this.getRaw(e)];case 1:if(!(t=r.sent()))return[2,void 0];try{return void 0===(n=Ae(t))?(console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)),[2,void 0]):[2,JSON.parse(n)]}catch(n){return console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t)),[2,void 0]}return[2]}})})},e.prototype.getRaw=function(e){var t,n,r,i;return s(this,void 0,void 0,function(){var o,s,c,l,d,f,v,p,h,g,m,y,b=this;return a(this,function(a){switch(a.label){case 0:o=M(),s=o,a.label=1;case 1:return a.trys.push([1,4,,5]),(c=null==s?void 0:s.cookieStore)?[4,c.getAll(e)]:[3,3];case 2:if(l=a.sent()){l.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:l.map(function(e){return e.domain})}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(d=u(l),f=d.next();!f.done;f=d.next())if(v=f.value,Ce(v.domain,this.options.domain))return[2,v.value]}catch(e){m={error:e}}finally{try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(m)throw m.error}}}a.label=3;case 3:return[3,5];case 4:return a.sent(),[3,5];case 5:return p=(null!==(i=null===(r=null==o?void 0:o.document)||void 0===r?void 0:r.cookie.split("; "))&&void 0!==i?i:[]).filter(function(t){return 0===t.indexOf(e+"=")}),h=void 0,"function"==typeof(g=this.config.duplicateResolverFn)&&p.length>1&&(h=p.find(function(t){var n;try{var r=g(t.substring(e.length+1));return r||null===(n=b.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),r}catch(e){return!1}})),h||(h=p[0]),h?[2,h.substring(e.length+1)]:[2,void 0]}})})},e.prototype.set=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i,o,s,u,c,l;return a(this,function(a){try{r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=void 0,(i=null!==t?r:-1)&&((s=new Date).setTime(s.getTime()+24*i*60*60*1e3),o=s),u="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t)))),o&&(u+="; expires=".concat(o.toUTCString())),u+="; path=/",this.options.domain&&(u+="; domain=".concat(this.options.domain)),this.options.secure&&(u+="; Secure"),this.options.sameSite&&(u+="; SameSite=".concat(this.options.sameSite)),(c=M())&&(c.document.cookie=u)}catch(t){l=t instanceof Error?t.message:String(t),console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}return[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2]})})},e}(),Ae=function(e){var t;return null!==(t=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}}(e))&&void 0!==t?t:function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}}(e)},Ce=function(e,t){if(!e||!t)return!1;var n=e.startsWith(".")?e.substring(1):e,r=t.startsWith(".")?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},xe=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[f,t,e.substring(0,n)].filter(Boolean).join("_")},Re=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r;return a(this,function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},e.prototype.getRaw=function(e){var t;return s(this,void 0,void 0,function(){return a(this,function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var n;return s(this,void 0,void 0,function(){return a(this,function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return s(this,void 0,void 0,function(){return a(this,function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return s(this,void 0,void 0,function(){return a(this,function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]})})},e}(),De="tags",Le="counters",Ne="histograms",je="events",Me="internal",Ue="last_flush_timestamp",qe=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=M())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},e.prototype.openDB=function(){var e=this;return new Promise(function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},r.onsuccess=function(){var n=r.result;n.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},n.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),n.close()},t(n)},r.onupgradeneeded=function(t){var n=t.target.result;e.createTables(n)}})},e.prototype.createTables=function(e){(e.objectStoreNames.contains(De)||e.createObjectStore(De,{keyPath:"key"}),e.objectStoreNames.contains(Le)||e.createObjectStore(Le,{keyPath:"key"}),e.objectStoreNames.contains(Ne)||e.createObjectStore(Ne,{keyPath:"key"}),e.objectStoreNames.contains(je))||e.createObjectStore(je,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Me)||e.createObjectStore(Me,{keyPath:"key"})},e.prototype.setTags=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([De],"readwrite"),r=n.objectStore(De),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Le],"readwrite"),r=n.objectStore(Le),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e=s.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Ne],"readwrite"),r=n.objectStore(Ne),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e,t=s.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([je],"readwrite"),r=n.objectStore(je),[2,new Promise(function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach(function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}})},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return s(this,void 0,void 0,function(){var n,r,i,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=s.sent(),r=n.transaction([Me],"readwrite"),i=r.objectStore(Me),[2,new Promise(function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var s=i.put({key:e,value:t});s.onsuccess=function(){return n()},s.onerror=function(){return o(new Error("Failed to set internal value"))}})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return s(this,void 0,void 0,function(){var t,n,r,i;return a(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Me],"readonly"),r=n.objectStore(Me),[2,new Promise(function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}})];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Ue)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}})})},e.prototype.setLastFlushTimestamp=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Ue,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}})})},e.prototype.clearTable=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(new Error("Failed to clear table ".concat(t)))}})},e.prototype.getAllAndClear=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=a.sent(),t=e.transaction([De,Le,Ne,je],"readwrite"),[4,Promise.all([this.getAllFromStore(t,De),this.getAllFromStore(t,Le),this.getAllFromStore(t,Ne),this.getAllFromStore(t,je)])];case 2:return n=c.apply(void 0,[a.sent(),4]),r=n[0],i=n[1],o=n[2],s=n[3],[4,Promise.all([this.clearTable(t,Le),this.clearTable(t,Ne),this.clearTable(t,je)])];case 3:return a.sent(),[2,{tags:r,counters:i,histogramStats:o,events:s}];case 4:return u=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",u),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(new Error("Failed to get all from ".concat(t)))}})},e}(),Fe=function(e){var t,n=null==(t=M())?void 0:t.__AMPLITUDE_SCRIPT_URL__;if(n)return e.filename&&e.filename.includes(n)?"filename":e.stack&&e.stack.includes(n)?"stack":void 0},Be=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},He=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},Ve=3e5,ze=1e4,Je=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=i({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Ie(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,qe.isSupported()?this.storage=new qe(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=M();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",i({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Fe({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})},!0),t.addEventListener("unhandledrejection",function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Be(i),s=Fe({filename:o,stack:i});s&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:He(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:s}})},!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=ze?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=ze?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=ze)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout(function(){e.saveAllDataToStorage().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)}).finally(function(){e.saveTimer=null})},1e3)),this.flushTimer||(this.flushTimer=setTimeout(function(){e._flush().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)}).finally(function(){e.flushTimer=null})},Ve))},e.prototype.saveAllDataToStorage=function(){return s(this,void 0,void 0,function(){var e,t,n,r;return a(this,function(o){switch(o.label){case 0:return this.storage?(e=i({},this.inMemoryTags),t=i({},this.inMemoryCounters),n=i({},this.inMemoryHistograms),r=l([],c(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])]):[2];case 1:return o.sent(),[2]}})})},e.prototype._flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,u,c,l;return a(this,function(a){switch(a.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return a.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=a.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={},n.forEach(function(e){s[e.key]=e.value}),u={},r.forEach(function(e){u[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),c=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(s).length&&0===Object.keys(u).length&&0===c.length?[2]:(l={tags:o,histogram:u,counters:s,events:c},this.fetch(l),[2])}})})},e.prototype.fetch=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!M())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}})})},e.prototype.initializeFlushInterval=function(){return s(this,void 0,void 0,function(){var e,t,n;return a(this,function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(Ve),[2]):(n=e-t)>=Ve?(this._flush(),[2]):(this._setFlushTimer(Ve-n),[2])}})})},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout(function(){t._flush().catch(function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)}).finally(function(){t.flushTimer=null})},e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=Ie(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),$e=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,s,a,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S;if("object"!=typeof e)return null;var T=e.code||0,k=this.buildStatus(T);switch(k){case D.Success:return{status:k,statusCode:T,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case D.Invalid:return{status:k,statusCode:T,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(c=e.eps_threshold)&&void 0!==c?c:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(v=e.throttled_devices)&&void 0!==v?v:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case D.PayloadTooLarge:return{status:k,statusCode:T,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case D.RateLimit:return{status:k,statusCode:T,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(E=e.exceeded_daily_quota_users)&&void 0!==E?E:{},throttledEvents:null!==(S=e.throttled_events)&&void 0!==S?S:[]}};case D.Timeout:default:return{status:k,statusCode:T}}},e.prototype.buildStatus=function(e){return Z(e)?D.Success:429===e?D.RateLimit:413===e?D.PayloadTooLarge:408===e?D.Timeout:e>=400&&e<500?D.Invalid:e>=500?D.Failed:D.Unknown},e}(),Ke=function(e){function n(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n,r,o;return a(this,function(s){switch(s.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:i({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}})})},n}($e),We=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),Ge=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new We(e,t)}return e.prototype.subscribe=function(e,t,n){var r=q(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return s(this,void 0,void 0,function(){var e,t=this;return a(this,function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.fetchPromise=this.fetch().then(function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null})),this.fetchPromise},e.prototype.subscribeAll=function(e){return s(this,void 0,void 0,function(){var t,n,r,i=this;return a(this,function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return s(this,void 0,void 0,function(){var n,r;return a(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),s(this,void 0,void 0,function(){var n,r,i,o,s,u,c=this;return a(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,u,l,d;return a(this,function(a){switch(a.label){case 0:i=new AbortController,s=setTimeout(function(){return i.abort()},t),a.label=1;case 1:return a.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:i.signal})];case 2:return(u=a.sent()).ok?[3,4]:[4,u.text()];case 3:return l=a.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(u.status,": ").concat(l)),[3,6];case 4:return[4,u.json()];case 5:return[2,{value:{remoteConfig:a.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=a.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(s),[7];case 9:return r<e-1?[4,new Promise(function(e){return setTimeout(e,c.getJitterDelay(n))})]:[3,11];case 10:a.sent(),a.label=11;case 11:return[2]}})},o=this,s=0,l.label=1;case 1:return s<e?[5,i(s)]:[3,4];case 2:if("object"==typeof(u=l.sent()))return[2,u.value];l.label=3;case 3:return s++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),Qe=M(),Ye=null==Qe?void 0:Qe.console,Xe={},Ze={},et=!1;var tt,nt={addListener:function(e,t){var n,r=(n=e,!!Ye&&"function"==typeof Ye[n]&&(Ze[n]||(Ze[n]=Ye[n],Ye[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(Xe[n]&&!et){et=!0;var r=Xe[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return et=!1,Ze[n].apply(Ye,e)}),!0));if(!r)return new Error("Console override failed");Xe[e]?Xe[e].push(t):Xe[e]=[t]},removeListener:function(e){var t,n;try{for(var r=u(Object.values(Xe)),i=r.next();!i.done;i=r.next())for(var o=i.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=u(Object.entries(Ze)),r=n.next();!r.done;r=n.next()){var i=c(r.value,2),o=i[0],s=i[1];s&&(Ye[o]=s)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}Ze={},Xe={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(tt||(tt={}));var rt=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],it="data-amp-track-",ot=["div","span","h1","h2","h3","h4","h5","h6"],st=l(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],c(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),at=st,ut=st,ct=["*"];function lt(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function dt(e,t,n){e&&ft({json:e,allowlist:t.map(vt),excludelist:n.map(vt),ancestors:[]})}function ft(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,s=e.excludelist,a=e.ancestors,d=e.parentObject,f=e.targetKey;i||(i=r);var v=Object.keys(i);try{for(var p=u(v),h=p.next();!h.done;h=p.next()){var g=h.value,m=l(l([],c(a),!1),[g],!1);lt(i[g])?ht(m,o)&&!ht(m,s)||delete i[g]:ft({json:r,targetObject:i[g],allowlist:o,excludelist:s,ancestors:m,parentObject:i,targetKey:g})}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}0===Object.keys(i).length&&d&&f&&delete d[f]}function vt(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function pt(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=0),r===t.length)return n===e.length;if(n===e.length){for(;r<t.length&&"**"===t[r];)r++;return r===t.length}var i=t[r];if("**"===i){if(r+1===t.length)return!0;for(var o=n;o<=e.length;o++)if(pt(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&pt(e,t,n+1,r+1)}function ht(e,t){return t.some(function(t){return pt(e,t)})}var gt=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach(function(e){var t=c(e,2),n=t[0],r=t[1];i[n]=r});else if(r instanceof Headers)r.forEach(function(e,t){i[t]=e});else if("object"==typeof r&&null!==r)try{for(var o=u(Object.entries(r)),s=o.next();!s.done;s=o.next()){var a=c(s.value,2),l=a[0],d=a[1];i[l]=d}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kt(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=M();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=yt(t,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){return 0===e.length?[2,null]:[2,St(this.body,e,t)]})})},e}(),mt=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),kt(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return yt(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){return 0===e.length?[2,null]:[2,St(this.body,e,t)]})})},e}();function yt(e,t){var n,r,i,o=M(),s=null==o?void 0:o.TextEncoder;if(s){var a;if("string"==typeof e)a=e,i=(new s).encode(a).length;else if(e instanceof Blob)i=(a=e).size;else if(e instanceof URLSearchParams)a=e,i=(new s).encode(a.toString()).length;else if(ArrayBuffer.isView(e))i=(a=e).byteLength;else if(e instanceof ArrayBuffer)i=(a=e).byteLength;else if(e instanceof FormData){var l=e,d=0,f=0;try{for(var v=u(l.entries()),p=v.next();!p.done;p=v.next()){var h=c(p.value,2),g=h[0],m=h[1];if(d+=g.length,"string"==typeof m)d+=(new s).encode(m).length;else{if(!(m instanceof Blob))return;d+=m.size}if(++f>=t)return}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(n)throw n.error}}i=d}else if(e instanceof ReadableStream)return void(a=e);return i}}var bt,wt=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,function(e,t){r[t]=e}),kt(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise(function(e){return setTimeout(function(){return e(null)},500)}),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}})})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,St(n.sent(),e,t)]}})})},e}(),Et=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var t,n;if(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=c(s.value.split(": "),2),l=a[0],d=a[1];l&&d&&(r[l]=d)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kt(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){var n;return a(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?(dt(n,e,t),[2,n]):[2,null]})})},e}();function St(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return dt(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(bt||(bt={}));var Tt="[REDACTED]",kt=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?bt.REMOVE:s,d=l([],c(A),!1),f={},v=function(t){var n=t.toLowerCase();d.find(function(e){return e.toLowerCase()===n})?a===bt.REDACT&&(f[t]=Tt):o.find(function(e){return e.toLowerCase()===n})?f[t]=e[t]:a===bt.REDACT&&(f[t]=Tt)};try{for(var p=u(Object.keys(e)),h=p.next();!h.done;h=p.next()){v(h.value)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}return f},_t=function(){function e(e,t,n,r,i,o,s,a,u,c,l){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=u,this.error=c,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(l([],c(O),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(l([],c(O),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter(function(e){var t=c(e,2);return t[0],void 0!==t[1]}))},e}();var It=function(e,t){void 0===t&&(t=q()),this.callback=e,this.id=t},Pt=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=M();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=M();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,s,a,u,c,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,v=null===(a=null===(s=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===s?void 0:s.prototype)||void 0===a?void 0:a.send,p=null===(l=null===(c=null===(u=this.globalScope)||void 0===u?void 0:u.XMLHttpRequest)||void 0===c?void 0:c.prototype)||void 0===l?void 0:l.setRequestHeader;f&&v&&p&&this.observeXhr(f,v,p);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach(function(n){var r;try{n.callback(e)}catch(e){null===(r=t.logger)||void 0===r||r.debug("an unexpected error occurred while triggering event callbacks",e)}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,s){var a;if(void 0!==o&&void 0!==s){var u,c,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?u=null===(a=null==t?void 0:t.toString)||void 0===a?void 0:a.call(t):(u=t.url,d=t.method),u)try{var f=new URL(u);u="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(c=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},c=0);var v=Math.floor(performance.now()-s),p=Math.floor(o+v),h=new _t(e,d,o,o,u,n,c,v,r,l,p);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return s(t,void 0,void 0,function(){var t,i,o,s,u,c;return a(this,function(a){switch(a.label){case 0:try{t=this.getTimestamps()}catch(e){null===(u=this.logger)||void 0===u||u.debug("an unexpected error occurred while retrieving timestamps",e)}a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=a.sent(),[3,4];case 3:return s=a.sent(),o=s,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new gt(r):void 0,i?new wt(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while handling fetch",e)}if(i)return[2,i];throw o}})})})},e.createXhrJsonParser=function(e,t){return function(){var n,r;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&(null===(r=t.logger)||void 0===r||r.error("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var o=this.globalScope.XMLHttpRequest.prototype,s=this;o.open=function(){for(var e,n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=c(r,2),u=a[0],l=a[1];try{this.$$AmplitudeAnalyticsEvent=i({method:u,url:null===(e=null==l?void 0:l.toString)||void 0===e?void 0:e.call(l),headers:{}},s.getTimestamps())}catch(e){null===(n=s.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr open",e)}return t.apply(this,r)},o.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,o=e.createXhrJsonParser(this,s),a=t[0],u=i.$$AmplitudeAnalyticsEvent;return i.addEventListener("loadend",function(){var e;try{var t=i.getAllResponseHeaders(),n=i.getResponseHeader("content-length"),r=new Et(i.status,t,n?parseInt(n,10):void 0,o),c=i.$$AmplitudeAnalyticsEvent.headers,l=new mt(a,c);u.status=i.status,s.handleNetworkRequestEvent("xhr",{url:u.url,method:u.method},l,r,void 0,u.startTime,u.durationStart)}catch(t){null===(e=s.logger)||void 0===e||e.error("an unexpected error occurred while handling xhr send",t)}}),n.apply(i,t)},o.setRequestHeader=function(e,t){var n;try{this.$$AmplitudeAnalyticsEvent.headers[e]=t}catch(e){null===(n=s.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr setRequestHeader",e)}r.apply(this,[e,t])}}},e}(),Ot=new Pt,At=function(){function e(){}return e.prototype.parse=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,i(i(i(i({},P),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=Se();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=Se();return(e={})[g]=t[g],e[m]=t[m],e[y]=t[y],e[b]=t[b],e[w]=t[w],e[E]=t[E],e[S]=t[S],e[T]=t[T],e[k]=t[k],e[_]=t[_],e[I]=t[I],e},e}(),Ct="data-amp-mask",xt="*****",Rt=/\b(?:\d[ -]*?){13,16}\b/,Dt=/(\d{3}-?\d{2}-?\d{4})/g,Lt=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Nt=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(Rt,xt)).replace(Dt,xt)).replace(Lt,xt);try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,xt)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},jt=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(Ct)?xt:e?e(document.title):document.title};function Mt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ut(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function qt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ft(e,t,n){return t&&qt(e.prototype,t),n&&qt(e,n),e}var Bt=function(){return"function"==typeof Symbol},Ht=function(e){return Bt()&&Boolean(Symbol[e])},Vt=function(e){return Ht(e)?Symbol[e]:"@@"+e};Bt()&&!Ht("observable")&&(Symbol.observable=Symbol("observable"));var zt=Vt("iterator"),Jt=Vt("observable"),$t=Vt("species");function Kt(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function Wt(e){var t=e.constructor;return void 0!==t&&null===(t=t[$t])&&(t=void 0),void 0!==t?t:on}function Gt(e){return e instanceof on}function Qt(e){Qt.log?Qt.log(e):setTimeout(function(){throw e})}function Yt(e){Promise.resolve().then(function(){try{e()}catch(e){Qt(e)}})}function Xt(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=Kt(t,"unsubscribe");n&&n.call(t)}}catch(e){Qt(e)}}function Zt(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function en(e,t,n){e._state="running";var r=e._observer;try{var i=Kt(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(Zt(e),!i)throw n;i.call(r,n);break;case"complete":Zt(e),i&&i.call(r)}}catch(e){Qt(e)}"closed"===e._state?Xt(e):"running"===e._state&&(e._state="ready")}function tn(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void Yt(function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(en(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)})):void en(e,t,n);e._queue.push({type:t,value:n})}}var nn=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new rn(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(Zt(this),Xt(this))},Ft(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),rn=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){tn(this._subscription,"next",e)},t.error=function(e){tn(this._subscription,"error",e)},t.complete=function(){tn(this._subscription,"complete")},Ft(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),on=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new nn(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}})},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Wt(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Wt(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Wt(this),r=arguments.length>1,i=!1,o=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var s=!i;if(i=!0,!s||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})})},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=Wt(this);return new i(function(t){var r,o=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}})},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Wt(this);return new n(function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),s()}});i.push(o)},error:function(e){r.error(e)},complete:function(){s()}});function s(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),o.unsubscribe()}})},t[Jt]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=Kt(t,Jt);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Gt(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(Ht("iterator")&&(r=Kt(t,zt)))return new n(function(e){Yt(function(){if(!e.closed){for(var n,i=Mt(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){Yt(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)(function(e){Yt(function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}})})},Ft(e,null,[{key:$t,get:function(){return this}}]),e}();function sn(e,t){return new on(function(n){e.subscribe({next:function(e){t(e).then(function(e){return n.next(e)}).catch(function(e){return n.error(e)})},error:function(e){n.error(e)},complete:function(){n.complete()}})})}function an(e,t){return new on(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=u(i),o=n.next();!o.done;o=n.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return s(e),s(t),o})}function un(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new on(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.next)||void 0===i||i.call(a,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var s=u(t),a=s.next();!a.done;a=s.next()){var c=a.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.complete)||void 0===i||i.call(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}})}Bt()&&Object.defineProperty(on,Symbol("extensions"),{value:{symbol:Jt,hostReportError:Qt},configurable:!0});var cn=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},ln=function(e){return cn(e,"attribution")},dn=function(e){return cn(e,"formInteractions")},fn=function(e){return cn(e,"pageViews")},vn=function(e){return cn(e,"sessions")},pn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},hn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},gn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},mn=function(e){if(hn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},yn=function(e){if(gn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},bn=function(e){var t;if(pn(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),i(i({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map(function(t){var n,r,o;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var s=JSON.stringify(t.hosts),a=JSON.stringify(t.urls);return null===(o=e.loggerProvider)||void 0===o||o.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(s,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),i(i({},t),{hosts:void 0})}return t})})}},wn=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return fn(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},En=function(e,t){Sn(e,t)},Sn=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,s=r.resolve,a=e&&e[i];if("function"==typeof a){var u=a.apply(e,o);"function"==typeof s&&s(null==u?void 0:u.promise)}}return e},Tn=function(e){return e&&void 0!==e._q},kn="2.34.0",_n="amplitude-ts",In=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(_n,"/").concat(kn),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t,n,r,o,s;return a(this,function(a){return t=(new Date).getTime(),n=null!==(o=this.config.lastEventId)&&void 0!==o?o:-1,r=null!==(s=e.event_id)&&void 0!==s?s:n+1,this.config.lastEventId=r,e.time||(this.config.lastEventTime=t),[2,i(i(i(i(i(i(i(i({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:t},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Ee()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:q(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:r,library:this.library,user_agent:this.userAgent})]})})},e}(),Pn=1e3,On=function(e){function n(t){var n,r,i,o=this;try{i=null===(n=M())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return t(n,e),n.prototype.set=function(t,n){return s(this,void 0,void 0,function(){var r,i;return a(this,function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>Pn?(r=n.length-Pn,[4,e.prototype.set.call(this,t,n.slice(0,Pn))]):[3,2];case 1:return o.sent(),null===(i=this.loggerProvider)||void 0===i||i.error("Failed to save ".concat(r," events because the queue length exceeded ").concat(Pn,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},n}(Re),An=function(e){function n(){var t;return e.call(this,null===(t=M())||void 0===t?void 0:t.sessionStorage)||this}return t(n,e),n}(Re),Cn=function(e){function n(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n=this;return a(this,function(r){return[2,new Promise(function(r,o){var s,a;"undefined"==typeof XMLHttpRequest&&o(new Error("XHRTransport is not supported."));var l=new XMLHttpRequest;l.open("POST",e,!0),l.onreadystatechange=function(){if(l.readyState===n.state.done){var e=l.responseText;try{r(n.buildResponse(JSON.parse(e)))}catch(e){r(n.buildResponse({code:l.status}))}}};var d=i({"Content-Type":"application/json",Accept:"*/*"},n.customHeaders);try{for(var f=u(Object.entries(d)),v=f.next();!v.done;v=f.next()){var p=c(v.value,2),h=p[0],g=p[1];l.setRequestHeader(h,g)}}catch(e){s={error:e}}finally{try{v&&!v.done&&(a=f.return)&&a.call(f)}finally{if(s)throw s.error}}l.send(JSON.stringify(t))})]})})},n}($e),xn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n=this;return a(this,function(r){return[2,new Promise(function(r,i){var o=M();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);return r(o.navigator.sendBeacon(e,JSON.stringify(t))?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}})]})})},n}($e),Rn=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return s(void 0,l([e,t],c(n),!1),void 0,function(e,t,n){var r,i,o,s,u,l,d,v,p;return void 0===n&&(n=!0),a(this,function(a){switch(a.label){case 0:return r=function(e){return"".concat(f.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=a.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:a.sent(),a.label=3;case 3:return o=c(i.split("."),6),s=o[0],u=o[1],l=o[2],d=o[3],v=o[4],p=o[5],[2,{deviceId:s,userId:Ln(u),sessionId:Dn(d),lastEventId:Dn(p),lastEventTime:Dn(v),optOut:Boolean(l)}]}})})},Dn=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Ln=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Nn="[Amplitude]",jn="".concat(Nn," Form Started"),Mn="".concat(Nn," Form Submitted"),Un="".concat(Nn," File Downloaded"),qn="session_start",Fn="session_end",Bn="".concat(Nn," File Extension"),Hn="".concat(Nn," File Name"),Vn="".concat(Nn," Link ID"),zn="".concat(Nn," Link Text"),Jn="".concat(Nn," Link URL"),$n="".concat(Nn," Form ID"),Kn="".concat(Nn," Form Name"),Wn="".concat(Nn," Form Destination"),Gn="cookie",Qn=function(e){function n(t,n,r,i,o,s,a,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I,P,O,A,C,x,R,D,L,N,j,M,U,q,F){var B;void 0===r&&(r=new Pe),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===c&&(c=5),void 0===l&&(l=30),void 0===d&&(d=Gn),void 0===g&&(g=new K),void 0===m&&(m=J.Warn),void 0===b&&(b=!1),void 0===w&&(w=!1),void 0===T&&(T=""),void 0===k&&(k="US"),void 0===I&&(I=18e5),void 0===P&&(P=new On({loggerProvider:g})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===A&&(A="fetch"),void 0===C&&(C=!1),void 0===x&&(x=!0),void 0===M&&(M=!0),void 0===U&&(U=0);var H=e.call(this,{apiKey:t,storageProvider:P,transportProvider:Zn(A)})||this;H.apiKey=t,H.appVersion=n,H.cookieOptions=i,H.defaultTracking=o,H.autocapture=s,H.flushIntervalMillis=u,H.flushMaxRetries=c,H.flushQueueSize=l,H.identityStorage=d,H.ingestionMetadata=f,H.instanceName=v,H.loggerProvider=g,H.logLevel=m,H.minIdLength=y,H.offline=b,H.partnerId=E,H.plan=S,H.serverUrl=T,H.serverZone=k,H.sessionTimeout=I,H.storageProvider=P,H.trackingOptions=O,H.transport=A,H.useBatch=C,H.fetchRemoteConfig=x,H.networkTrackingOptions=N,H.identify=j,H.enableDiagnostics=M,H.diagnosticsSampleRate=U,H.diagnosticsClient=q,H.remoteConfig=F,H.version=kn,H._optOut=!1,H._cookieStorage=r,H.deviceId=a,H.lastEventId=p,H.lastEventTime=h,H.optOut=w,H.sessionId=_,H.pageCounter=D,H.userId=R,H.debugLogsEnabled=L,H.loggerProvider.enable(L?J.Debug:H.logLevel),H.networkTrackingOptions=N,H.identify=j,H.enableDiagnostics=M,H.diagnosticsSampleRate=U,H.diagnosticsClient=q;var V=null!==(B=null==F?void 0:F.fetchRemoteConfig)&&void 0!==B?B:x;return H.remoteConfig=H.remoteConfig||{},H.remoteConfig.fetchRemoteConfig=V,H.fetchRemoteConfig=V,H}return t(n,e),Object.defineProperty(n.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),n.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof Oe&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(we(this.apiKey),e)},n}(G),Yn=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return s(void 0,l([e],c(t),!1),void 0,function(e,t,n,r,o){var s,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I,P,O,A,C,x,R,D,L,N,j,M,U,F,B,H,V,z,J,$,K,W,G,Q,Y,X,Z,ee,te,ne,re;return void 0===t&&(t={}),a(this,function(a){switch(a.label){case 0:return s=t.identityStorage||Gn,O={},s===Gn?[3,1]:(c="",[3,5]);case 1:return null===(C=null===(A=t.cookieOptions)||void 0===A?void 0:A.domain)||void 0===C?[3,2]:(l=C,[3,4]);case 2:return[4,er()];case 3:l=a.sent(),a.label=4;case 4:c=l,a.label=5;case 5:return u=i.apply(void 0,[(O.domain=c,O.expiration=365,O.sameSite="Lax",O.secure=!1,O.upgrade=!0,O),t.cookieOptions]),d={duplicateResolverFn:function(e){var t=Ae(e);if(!t)return!1;var n=JSON.parse(t);return Ce(n.cookieDomain,u.domain)},diagnosticsClient:r},f=Xn(t.identityStorage,u,d),[4,Rn(e,f,null===(R=null===(x=t.cookieOptions)||void 0===x?void 0:x.upgrade)||void 0===R||R)];case 6:return v=a.sent(),[4,f.get(we(e))];case 7:return p=a.sent(),h=Se(),g=h.ampTimestamp?Number(h.ampTimestamp):void 0,m=!g||Date.now()<g,y=null!==(M=null!==(j=null!==(N=null!==(D=t.deviceId)&&void 0!==D?D:m?null!==(L=h.ampDeviceId)&&void 0!==L?L:h.deviceId:void 0)&&void 0!==N?N:null==p?void 0:p.deviceId)&&void 0!==j?j:v.deviceId)&&void 0!==M?M:q(),b=null!==(U=null==p?void 0:p.lastEventId)&&void 0!==U?U:v.lastEventId,w=null!==(F=null==p?void 0:p.lastEventTime)&&void 0!==F?F:v.lastEventTime,E=null!==(H=null!==(B=t.optOut)&&void 0!==B?B:null==p?void 0:p.optOut)&&void 0!==H?H:v.optOut,S=null!==(V=null==p?void 0:p.sessionId)&&void 0!==V?V:v.sessionId,T=null!==(J=null!==(z=t.userId)&&void 0!==z?z:null==p?void 0:p.userId)&&void 0!==J?J:v.userId,n.previousSessionDeviceId=null!==($=null==p?void 0:p.deviceId)&&void 0!==$?$:v.deviceId,n.previousSessionUserId=null!==(K=null==p?void 0:p.userId)&&void 0!==K?K:v.userId,k={ipAddress:null===(G=null===(W=t.trackingOptions)||void 0===W?void 0:W.ipAddress)||void 0===G||G,language:null===(Y=null===(Q=t.trackingOptions)||void 0===Q?void 0:Q.language)||void 0===Y||Y,platform:null===(Z=null===(X=t.trackingOptions)||void 0===X?void 0:X.platform)||void 0===Z||Z},_=null==p?void 0:p.pageCounter,I=null==p?void 0:p.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(P=new Qn(e,t.appVersion,f,u,t.defaultTracking,t.autocapture,y,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,s,t.ingestionMetadata,t.instanceName,b,w,null!==(ee=null==o?void 0:o.loggerProvider)&&void 0!==ee?ee:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,E,t.partnerId,t.plan,t.serverUrl,null!==(te=null==o?void 0:o.serverZone)&&void 0!==te?te:t.serverZone,S,t.sessionTimeout,t.storageProvider,k,t.transport,t.useBatch,t.fetchRemoteConfig,T,_,I,t.networkTrackingOptions,t.identify,null!==(ne=null==o?void 0:o.enableDiagnostics)&&void 0!==ne?ne:t.enableDiagnostics,null!==(re=null==o?void 0:o.diagnosticsSampleRate)&&void 0!==re?re:n._diagnosticsSampleRate,r,t.remoteConfig)).storageProvider.isEnabled()];case 8:return a.sent()||(P.loggerProvider.warn("Storage provider ".concat(P.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),P.storageProvider=new Pe),[2,P]}})})},Xn=function(e,t,n){switch(void 0===e&&(e=Gn),void 0===t&&(t={}),e){case"localStorage":return new On;case"sessionStorage":return new An;case"none":return new Pe;default:return new Oe(i(i({},t),{expirationDays:t.expiration}),n)}},Zn=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0;return"xhr"===t?new Cn(n):"beacon"===t?new xn:new Ke(n)},er=function(e){return s(void 0,void 0,void 0,function(){var t,n,r,i,o,s,u,c;return a(this,function(a){switch(a.label){case 0:return[4,(new Oe).isEnabled()];case 1:if(!a.sent()||!e&&("undefined"==typeof location||!location.hostname))return[2,""];for(t=null!=e?e:location.hostname,n=t.split("."),r=[],i=q(),o="AMP_TLDTEST_".concat(i.substring(0,8)),s=n.length-2;s>=0;--s)r.push(n.slice(s).join("."));s=0,a.label=2;case 2:return s<r.length?(u=r[s],[4,(c=new Oe({domain:"."+u,expirationDays:.003})).set(o,1)]):[3,7];case 3:return a.sent(),[4,c.get(o)];case 4:return a.sent()?[4,c.remove(o)]:[3,6];case 5:return a.sent(),[2,"."+u];case 6:return s++,[3,2];case 7:return[2,""]}})})},tr=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},nr=function(e){var t;void 0===e&&(e={});var n,r=M(),o=void 0,u=!1,l=e.trackOn,d=e.trackHistoryChanges,f=e.eventType,v=void 0===f?"[Amplitude] Page Viewed":f,p=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==o||o.error("Malformed URI sequence: ",e)}return t},h=function(){return s(void 0,void 0,void 0,function(){var e,t,n;return a(this,function(r){switch(r.label){case 0:return e=p("undefined"!=typeof location&&location.href||""),n={event_type:v},t=[{}],[4,rr()];case 1:return[2,(n.event_properties=i.apply(void 0,[i.apply(void 0,t.concat([r.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":e,"[Amplitude] Page Path":"undefined"!=typeof location&&p(location.pathname)||"","[Amplitude] Page Title":jt(Nt),"[Amplitude] Page URL":e.split("?")[0]}]),n)]}})})},g=function(){return void 0===l||"function"==typeof l&&l()},m="undefined"!=typeof location?location.href:null,y=function(){return s(void 0,void 0,void 0,function(){var e,n,r,i;return a(this,function(s){switch(s.label){case 0:return e=location.href,n=or(d,e,m||"")&&g(),m=e,n?(null==o||o.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return i=(r=t).track,[4,h()];case 2:i.apply(r,[s.sent()]),s.label=3;case 3:s.label=4;case 4:return[2]}})})},b=function(){y()},w={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,i){return s(void 0,void 0,void 0,function(){var s,l;return a(this,function(a){switch(a.label){case 0:return t=i,n=e,(o=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),u=!0,r&&(r.addEventListener("popstate",b),r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),u&&y()}})),g()?(o.log("Tracking page view event"),l=(s=t).track,[4,h()]):[3,2];case 1:l.apply(s,[a.sent()]),a.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t;return a(this,function(r){switch(r.label){case 0:return"attribution"===l&&ir(e)?(null==o||o.log("Enriching campaign event to page view event with campaign parameters"),[4,h()]):[3,2];case 1:t=r.sent(),e.event_type=t.event_type,e.event_properties=i(i({},e.event_properties),t.event_properties),r.label=2;case 2:return n&&e.event_type===v&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=i(i({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){return r&&(r.removeEventListener("popstate",b),u=!1),[2]})})}};return w},rr=function(){return s(void 0,void 0,void 0,function(){var e;return a(this,function(t){switch(t.label){case 0:return e=tr,[4,(new At).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},ir=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,r=t[n.SET]||{},i=t[n.UNSET]||{},o=l(l([],c(Object.keys(r)),!1),c(Object.keys(i)),!1);return Object.keys(P).every(function(e){return o.includes(e)})}return!1},or=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},sr=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return s(void 0,void 0,void 0,function(){var o,s;return a(this,function(a){return t=function(e){if(dn(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions}(n),o=function(){if(i){if("undefined"!=typeof document){var o=function(e){var o=!1;r(e,"change",function(){var t,n=ur(e);o||i.track(jn,((t={})[$n]=ar(e.id),t[Kn]=ar(e.name),t[Wn]=n,t)),o=!0}),r(e,"submit",function(r){var s,a,u=ur(e);if(o||i.track(jn,((s={})[$n]=ar(e.id),s[Kn]=ar(e.name),s[Wn]=u,s)),o=!0,void 0!==(null==t?void 0:t.shouldTrackSubmit))if("function"==typeof t.shouldTrackSubmit&&"undefined"!=typeof SubmitEvent&&r instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(r))return}catch(e){n.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else n.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(Mn,((a={})[$n]=ar(e.id),a[Kn]=ar(e.name),a[Wn]=u,a)),o=!1})};Array.from(document.getElementsByTagName("form")).forEach(o),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"FORM"===e.nodeName&&o(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(o)})})})).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?o():(s=M())?s.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(t){return null==e||e.disconnect(),n.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),n=[],[2]})})}}},ar=function(e){if("string"==typeof e)return e},ur=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},cr=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return s(void 0,void 0,void 0,function(){var i,o;return a(this,function(s){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),s=null==i?void 0:i[1];s&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",function(){var t;s&&r.track(Un,((t={})[Bn]=s,t[Hn]=n.pathname,t[Vn]=e.id,t[zn]=e.text,t[Jn]=e.href,t))})},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)})})})).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=M())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(n){return null==e||e.disconnect(),t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),t=[],[2]})})}}},lr=!1,dr=function(){var e=M(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return s(void 0,void 0,void 0,function(){return a(this,function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis)}),n("offline",function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0}),[2])})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(n){return t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[],[2]})})}}};function fr(e){var t,n,r,i,o,s,a,d,f,v,p;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var h=Object.keys(e);try{for(var g=u(h),m=g.next();!m.done;m=g.next()){var y=m.value;try{var b=e[y];"boolean"==typeof(null==b?void 0:b.enabled)&&(b.enabled?(delete b.enabled,0===Object.keys(b).length&&(e[y]=!0)):e[y]=!1),fr(b)}catch(e){}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}try{if(null===(f=null===(d=null===(a=e.autocapture)||void 0===a?void 0:a.networkTracking)||void 0===d?void 0:d.captureRules)||void 0===f?void 0:f.length)try{for(var w=u(e.autocapture.networkTracking.captureRules),E=w.next();!E.done;E=w.next()){var S=E.value;try{for(var T=(o=void 0,u(["responseHeaders","requestHeaders"])),k=T.next();!k.done;k=T.next()){var _=k.value,I=null!==(v=S[_])&&void 0!==v?v:{},P=I.captureSafeHeaders,A=I.allowlist;(P||A)&&(void 0===A||Array.isArray(A)?S[_]=l(l([],c(P?O:[]),!1),c(null!=A?A:[]),!1):delete S[_])}}catch(e){o={error:e}}finally{try{k&&!k.done&&(s=T.return)&&s.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{E&&!E.done&&(i=w.return)&&i.call(w)}finally{if(r)throw r.error}}}catch(e){}var C=null===(p=e.autocapture)||void 0===p?void 0:p.frustrationInteractions;C&&(C.rageClick&&(C.rageClicks=C.rageClick,delete C.rageClick),C.deadClick&&(C.deadClicks=C.deadClick,delete C.deadClick))}}function vr(e,t,n){var r,i,o=[];try{for(var s=u(null!=t?t:[]),a=s.next();!a.done;a=s.next()){var c=a.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return e.concat(o)}function pr(e,t){var n,r,o,s,a,c,l;if(e){fr(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var d=e;if(d&&"autocapture"in d){if("boolean"==typeof d.autocapture&&(t.autocapture=d.autocapture),"object"==typeof d.autocapture&&null!==d.autocapture){var f=i({},d.autocapture);if(void 0===t.autocapture&&(t.autocapture=d.autocapture),"object"==typeof d.autocapture.elementInteractions&&null!==d.autocapture.elementInteractions&&(null===(o=d.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===o?void 0:o.length)){f.elementInteractions=i({},d.autocapture.elementInteractions);var v=f.elementInteractions,p=null!==(s=v.pageUrlAllowlist)&&void 0!==s?s:[],h=d.autocapture.elementInteractions.pageUrlAllowlistRegex;v.pageUrlAllowlist=vr(p,h,t),delete v.pageUrlAllowlistRegex}if("object"==typeof d.autocapture.networkTracking&&null!==d.autocapture.networkTracking&&(null===(a=d.autocapture.networkTracking.captureRules)||void 0===a?void 0:a.length)){f.networkTracking=i({},d.autocapture.networkTracking);var g=null!==(c=f.networkTracking.captureRules)&&void 0!==c?c:[];try{for(var m=u(g),y=m.next();!y.done;y=m.next()){var b=y.value;b.urls=vr(null!==(l=b.urls)&&void 0!==l?l:[],b.urlsRegex,t),delete b.urlsRegex}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=i({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},f)),"object"==typeof t.autocapture&&(t.autocapture=i(i({},t.autocapture),f))}t.defaultTracking=t.autocapture}t.loggerProvider.debug("Browser config after remote config update:",JSON.stringify(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var hr="1.19.0",gr="[Amplitude] Element Clicked",mr="[Amplitude] Element Tag",yr="[Amplitude] Element Text",br="[Amplitude] Page URL",wr="https://app.amplitude.com",Er={US:wr,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},Sr="data-amp-mask-attributes",Tr=["input","select","textarea"],kr=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},_r=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,s,a=e.pageUrlAllowlist,u=e.pageUrlExcludelist,c=e.shouldTrackEventResolver,l=null===(s=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===s?void 0:s.call(o);if(!l)return!1;if(c)return c(r,i);if(!ke(window.location.href,a))return!1;if(u&&u.length>0&&ke(window.location.href,u))return!1;var d=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof d)switch(d.toLowerCase()){case"hidden":case"password":return!1}var f=kr(i,r);if(n&&f)return!0;if(t){var v=t.some(function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))});if(!v)return!1}switch(l){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!f||"click"===r}}},Ir=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},Pr=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t},{})},Or=function(e,t){return e?t.some(function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)})?e:Or(null==e?void 0:e.parentElement,t):null};var Ar,Cr=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Ar||(Ar={}));var xr=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Sr,Ct]),Rr=["type"],Dr=["svg","path","g"],Lr=["password","hidden"];function Nr(e,t){var n,r,i,o,s,a;if(null===e)return null;var c=String(e.tagName).toLowerCase(),l={tag:c},d=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);d.length&&(l.index=d.indexOf(e),l.indexOfType=d.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var f=null===(a=null===(s=e.previousElementSibling)||void 0===s?void 0:s.tagName)||void 0===a?void 0:a.toLowerCase();f&&(l.prevSib=String(f));var v=e.getAttribute("id");v&&(l.id=String(v));var p=Array.from(e.classList);p.length&&(l.classes=p);var h={},g=Array.from(e.attributes).filter(function(e){return!xr.has(e.name)}),m=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!Tr.includes(i)&&!o}(e);if(!Lr.includes(String(e.getAttribute("type")))&&!Dr.includes(c))try{for(var y=u(g),b=y.next();!b.done;b=y.next()){var w=b.value;m&&!Rr.includes(w.name)||(t.has(w.name)?h[w.name]=xt:h[w.name]=String(w.value).substring(0,128))}}catch(e){n={error:e}}finally{try{b&&!b.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}return Object.keys(h).length&&(l.attrs=h),l}var jr=function(e,t,n){e.forEach(function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}})},Mr=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Nt(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,s,a=performance.now();if(!e)return[];for(var d=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),f=new Map,v=d.length-1;v>=0;v--){var p=d[v];if(p){var h=Ir(p.getAttribute(Sr)),g=v===d.length-1?[]:null!==(r=f.get(d[v+1]))&&void 0!==r?r:new Set,m=new Set(l(l([],c(g),!1),c(h),!1));f.set(p,m)}}s=d.map(function(e){var t;return Nr(e,null!==(t=f.get(e))&&void 0!==t?t:new Set)});var y=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=c(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))})};try{for(var b=u(s),w=b.next();!w.done;w=b.next())y(w.value)}catch(e){t={error:e}}finally{try{w&&!w.done&&(n=b.return)&&n.call(b)}finally{if(t)throw t.error}}var E=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",E-a),s},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getEventProperties=function(e,t,n){var r,i,s,a,u,l,d=null===(s=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===s?void 0:s.call(i),f="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},v=o.getHierarchy(t),p=null===(a=v[0])||void 0===a?void 0:a.attrs,h=o.getNearestLabel(t),g=(u=null!=p?p:{},l=n,Object.entries(u).reduce(function(e,t){var n=c(t,2),r=n[0],i=n[1];if(r.startsWith(l)){var o=r.replace(l,"");o&&(e[o]=i||"")}return e},{})),m=((r={})["[Amplitude] Element Hierarchy"]=v,r[mr]=d,r[yr]=o.getText(t),r["[Amplitude] Element Position Left"]=null==f.left?null:Math.round(f.left),r["[Amplitude] Element Position Top"]=null==f.top?null:Math.round(f.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Parent Label"]=h,r[br]=_e(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=jt(o.replaceSensitiveString),r["[Amplitude] Viewport Height"]=window.innerHeight,r["[Amplitude] Viewport Width"]=window.innerWidth,r);if(m["[Amplitude] Element ID"]=t.getAttribute("id")||"",m["[Amplitude] Element Class"]=t.getAttribute("class"),m["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===d&&"click"===e&&t instanceof HTMLAnchorElement){var y=t.href.substring(0,128);m["[Amplitude] Element Href"]=o.replaceSensitiveString(y)}return Pr(m)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var s=o.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(s)&&null!==s.event.target){if(i&&kr(s.event.target,s.type))return s.closestTrackedAncestor=s.event.target,s.targetElementProperties=o.getEventProperties(s.type,s.closestTrackedAncestor,r),s;var a=Or(s.event.target,n);return a&&(s.closestTrackedAncestor=a,s.targetElementProperties=o.getEventProperties(s.type,a,r)),s}return s},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getText=function(e){if(null!==e.closest("[".concat(Ct,"]")))return xt;var t="";if(e.querySelector("[".concat(Ct,"], [contenteditable]"))){var n=e.cloneNode(!0);n.querySelectorAll("[".concat(Ct,"], [contenteditable]")).forEach(function(e){e.innerText=xt}),t=n.innerText||""}else t=e.innerText||"";return o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),s=((t={})[mr]=i,t[yr]=o.getText(e),t[br]=window.location.href.split("?")[0],t);return Pr(s)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var s=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],a=[];try{for(var d=u(s),f=d.next();!f.done;f=d.next()){var v=f.value;if(a.length>=25)break;if(v instanceof RegExp)a.push(v);else if("pattern"in v&&"string"==typeof v.pattern)try{a.push(new RegExp(v.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=a},Ur=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?wr:t,r=this;this.endpoint=wr,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise(function(t,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),(null==n?void 0:n.timeout)>0&&setTimeout(function(){s(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{dataExtractor:new Mr({})}:e,r=n.logger,i=n.endpoint,o=n.isElementSelectable,s=n.cssSelectorAllowlist,a=n.actionClickAllowlist,u=n.dataExtractor;this.logger=r,i&&this.endpoint===wr&&(this.endpoint=i);var c=null;window.addEventListener("message",function(e){var n,r,i,l,d;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var f,v=null==e?void 0:e.data,p=null==v?void 0:v.action;if(p)if("id"in v)null===(l=null===(i=t.logger)||void 0===i?void 0:i.debug)||void 0===l||l.call(i,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(v);else if("ping"===p)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===p){var h=null==v?void 0:v.data;(f="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise(function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=f,r.addEventListener("load",function(){e({status:!0})},{once:!0}),r.addEventListener("error",function(){t({status:!1,message:"Failed to load the script ".concat(f)})}),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}})).then(function(){var e;c=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:u.getEventTagProps,isElementSelectable:function(e){return!o||o((null==h?void 0:h.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:t,cssSelectorAllowlist:s,actionClickAllowlist:a,extractDataFromDataSource:u.extractDataFromDataSource,dataExtractor:u,diagnostics:{autocapture:{version:hr}}}),t.notify({action:"selector-loaded"})}).catch(function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")})}else"close-visual-tagging-selector"===p&&(null===(d=null==c?void 0:c.close)||void 0===d||d.call(c))}}),this.notify({action:"page-loaded"})},e}();var qr,Fr=M(),Br=function(){return new on(function(e){var t=new MutationObserver(function(t){e.next(t)});return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}})},Hr=function(e){return void 0===e&&(e="click"),new on(function(t){var n=function(e){t.next(e)};return Fr.document.addEventListener(e,n,{capture:!0}),function(){Fr.document.removeEventListener(e,n,{capture:!0})}})},Vr=function(){var e=an(new on(function(e){var t=function(t){var n={kind:"error"};t.error instanceof Error?n=i(i({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(n.message=t.error),e.next(n)};return Fr.addEventListener("error",t),function(){Fr.removeEventListener("error",t)}}),new on(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return Fr.addEventListener("unhandledrejection",t),function(){Fr.removeEventListener("unhandledrejection",t)}}));return an(e,new on(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return nt.addListener("error",t),function(){nt.removeListener(t)}}))},zr={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Jr=function(e){var t,n,r,i,o=Object.values(zr).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var s=u(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{try{for(var l=(r=void 0,u(c.definition)),d=l.next();!d.done;d=l.next()){var f=d.value,v=zr[f.event_type];v&&o[v].add(c.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},$r=function(e){var t,n,r,i,o=new Map;try{for(var s=u(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{for(var l=(r=void 0,u(c.conditions)),d=l.next();!d.done;d=l.next()){var f=d.value;if("LABELED_EVENT"===f.type){var v=f.match.eventId,p=o.get(v);p||(p=[],o.set(v,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},Kr=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return zr[t.event_type]===e.type&&t.filters.every(function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)})})})},Wr=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=function(e,t){var n,r,i,o,s=new Set;try{for(var a=u(e),c=a.next();!c.done;c=a.next()){var l=c.value,d=t.get(l.id);if(d)try{for(var f=(i=void 0,u(d)),v=f.next();!v.done;v=f.next()){var p=v.value;s.add(p)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return Array.from(s)}(Kr(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=s.value;jr(a.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}();!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable"}(qr||(qr={}));var Gr=function(e,t){var n,r,o,d,f,v,p,h;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",hr);var g=e.dataAttributePrefix,m=void 0===g?it:g,y=e.visualTaggingOptions,b=void 0===y?{enabled:!0,messenger:new Ur}:y;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:rt,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:ot,e.debounceTime=null!==(o=e.debounceTime)&&void 0!==o?o:0,e.pageUrlExcludelist=null===(d=e.pageUrlExcludelist)||void 0===d?void 0:d.reduce(function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e},[]);var w="@amplitude/plugin-autocapture-browser",E=[],S=new Mr(e,t),T=Jr(Object.values(null!==(v=null===(f=e.pageActions)||void 0===f?void 0:f.labeledEvents)&&void 0!==v?v:{})),k=$r(null!==(h=null===(p=e.pageActions)||void 0===p?void 0:p.triggers)&&void 0!==h?h:[]),_=function(e,t,n,r){return new Wr(e,t,n,r)}(T,k,S,e);return{name:w,type:"enrichment",setup:function(t,n){return s(void 0,void 0,void 0,function(){var r,o,s,u,d,f,v,p,h,g;return a(this,function(a){return"undefined"==typeof document||(t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(t){!function(t){var n,r;t&&(e.pageActions=i(i({},e.pageActions),t),T=Jr(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),k=$r(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),_.update(T,k,e))}(t)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),r=_r(e,e.cssSelectorAllowlist),o=_r(e,e.actionClickAllowlist),s=function(){var t,n,r=un(Hr().map(function(t){return S.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,m)})),i=un(new on(function(t){var n,r=function(n){var r=S.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,m);t.next(r)};return null===(n=M())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=M())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=un(new on(function(t){var n=function(n){var r=S.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,m);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=un(Br().map(function(t){return S.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,m)}));return(t={})[qr.ChangeObservable]=i,t[qr.ClickObservable]=r,t[qr.MutationObservable]=o,t[qr.NavigateObservable]=n,t}(),u=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(Cr).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(gr,e.targetElementProperties)})}({allObservables:s,amplitude:n,shouldTrackEvent:r,evaluateTriggers:_.evaluate.bind(_)}),E.push(u),d=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(Cr).filter(function(e){return i("change",e.closestTrackedAncestor)}).map(function(e){return o(e)}).subscribe(function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))})}({allObservables:s,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return S.getEventProperties.apply(S,l(l([],c(e),!1),[m],!1))},amplitude:n,shouldTrackEvent:r,evaluateTriggers:_.evaluate.bind(_)}),E.push(d),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,s=e.shouldTrackActionClick,a=n.clickObservable,u=n.mutationObservable,c=n.navigateObservable,l=a.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=Or(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(Cr).filter(function(e){return s("click",e.closestTrackedAncestor)}),d=c?an(u,c):u,f=an(l,d),v=null,p=null;return sn(f,function(e){if(v&&(clearTimeout(v),v=null),"click"===e.type)return p=e,v=setTimeout(function(){v=null,p=null},500),Promise.resolve(null);if(p){var t=p;return p=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==t||t.track(gr,i("click",e.closestTrackedAncestor)))})}({allObservables:s,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return S.getEventProperties.apply(S,l(l([],c(e),!1),[m],!1))},amplitude:n,shouldTrackEvent:r,shouldTrackActionClick:o}),f&&E.push(f),null===(h=null==t?void 0:t.loggerProvider)||void 0===h||h.log("".concat(w," has been successfully added.")),window.opener&&b.enabled&&(v=e.cssSelectorAllowlist,p=e.actionClickAllowlist,null===(g=b.messenger)||void 0===g||g.setup(i(i({dataExtractor:S,logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:Er[t.serverZone]}),{isElementSelectable:_r(e,l(l([],c(v),!1),c(p),!1)),cssSelectorAllowlist:v,actionClickAllowlist:p})))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,r;return a(this,function(i){try{for(e=u(E),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]})})}}},Qr=["mutation","navigate"];function Yr(e,t){var n,r,i,o,s=t.event,a=s.pageX,u=s.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:u,u),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:u,u),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:a,a),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Xr(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:i({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function Zr(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,u=r.selectionObservable,c=[],l={},d=null;function f(e){c=[],l={},e&&(Yr(l,e),c.push(e))}var v=sn(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return s(t,void 0,void 0,function(){var t;return a(this,function(n){return Yr(l,e),t=null,0===c.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(c,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(c,e)||l.isOutOfBounds?(d&&(t=Xr(c)),f(e)):c.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),c.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(Xr(c))},1e3)}})]:[2,null]})})}),p=null==u?void 0:u.subscribe(function(){f()}),h=v.subscribe(function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){h.unsubscribe(),null==p||p.unsubscribe()}}}function ei(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var ti,ni,ri=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],o=!1!==e.errorClicks;e.errorClicks||(o=!1);var d=!1!==e.deadClicks&&null!==e.deadClicks,f=!1!==e.rageClicks&&null!==e.rageClicks,v=ei(e,"rageClicks",ct,f),p=ei(e,"deadClicks",at,d),h=ei(e,"errorClicks",ut,o),g=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:it,m=new Mr(e),y=l([],c(new Set(l(l(l([],c(v),!1),c(p),!1),c(h),!1))),!1);return{name:n,type:"enrichment",setup:function(t,u){return s(void 0,void 0,void 0,function(){var s,c,l,b,w,E,S,T;return a(this,function(a){return"undefined"==typeof document||(s=function(){var e,t,n=un(Hr("pointerdown").map(function(e){return m.addAdditionalEventProperties(e,"click",y,g,!0)})),r=un(Vr().map(function(e){return m.addTypeAndTimestamp(e,"error")})),o=un(Br().map(function(e){return m.addAdditionalEventProperties(e,"mutation",y,g)}));window.navigation&&(t=un(new on(function(e){var t=function(t){e.next(i(i({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return m.addAdditionalEventProperties(e,"navigate",y,g)})));var s=un(new on(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}}));return(e={})[qr.ClickObservable]=n,e[qr.MutationObservable]=o,e[qr.NavigateObservable]=t,e[qr.BrowserErrorObservable]=r,e[qr.SelectionObservable]=s,e}(),f&&(c=_r(e,v),l=Zr({allObservables:s,amplitude:u,shouldTrackRageClick:c}),r.push(l)),d&&(b=_r(e,p),w=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,o=e.shouldTrackDeadClick,s=n.clickObservable,a=n.mutationObservable,u=n.navigateObservable,c=s.filter(function(e){return Cr(e)&&o("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Ar.LEFT_OR_TOUCH_CONTACT}),l=u?an(a,u):a,d=an(c,l),f=null;return sn(d,function(e){return f&&Qr.includes(e.type)?(clearTimeout(f),f=null,Promise.resolve(null)):"click"===e.type?f?Promise.resolve(null):new Promise(function(t){f=setTimeout(function(){t(e),f=null},3e3)}):Promise.resolve(null)}).subscribe(function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",i(i({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}})}({amplitude:u,allObservables:s,getEventProperties:function(e,t){return m.getEventProperties(e,t,g)},shouldTrackDeadClick:b}),r.push(w)),o&&(E=_r(e,h),S=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,o=n.clickObservable,s=n.browserErrorObservable,a=o.filter(function(e){return Cr(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Ar.LEFT_OR_TOUCH_CONTACT}),u=null,c=null,l=function(){null!==u&&(clearTimeout(u),u=null),c=null};return an(a,s).subscribe(function(e){var n;if("click"===e.type)return l(),c=e,void(u=setTimeout(l,2e3));"error"===e.type&&c&&(t.track("[Amplitude] Error Click",i(((n={})["[Amplitude] Kind"]=e.event.kind,n["[Amplitude] Message"]=e.event.message,n["[Amplitude] Stack"]=e.event.stack,n["[Amplitude] Filename"]=e.event.filename,n["[Amplitude] Line Number"]=e.event.lineNumber,n["[Amplitude] Column Number"]=e.event.columnNumber,n),c.targetElementProperties)),l())})}({amplitude:u,allObservables:s,shouldTrackErrorClick:E}),r.push(S)),null===(T=null==t?void 0:t.loggerProvider)||void 0===T||T.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,i;return a(this,function(o){try{for(e=u(r),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]})})}}},ii="[Amplitude] Network Request",oi="500-599";function si(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function ai(e,t){var n,r,i=t.split(",");try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=c(s.value.split("-").map(Number),2),l=a[0],d=a[1];if(e===l&&void 0===d)return!0;if(e>=l&&e<=d)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function ui(e){var t;if(e)try{var n=null===(t=M())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),s=r.href,a=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:r.href,host:a}}catch(e){return}}function ci(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return l([],c(O),!1);if(void 0===e){return}}}function li(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function di(e,t){var n;void 0===t&&(t={});var r=ui(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(si(o,"*.amplitude.com")||si(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find(function(e){return si(o,e)}))return!1;if(!t.captureRules&&void 0!==e.status&&!ai(e.status,oi))return!1;if(t.captureRules&&(l([],c(t.captureRules),!1).reverse().find(function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find(function(e){return si(t,e)}))&&(!r||!e.urls||ke(r,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return!((n||0===n)&&!ai(n,e.statusCodeRange||oi))}(t,o,e.status,e.url,e.method),i){var n=ci(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var s=ci(t.requestHeaders);if(e.requestWrapper&&s){var a=e.requestWrapper.headers(s);a&&(e.requestHeaders=a)}e.responseWrapper&&t.responseBody&&!li(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!li(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i}),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find(function(e){return e.event_type===ii}))return!0}catch(e){}return!1}(o,e.requestWrapper)}function fi(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return di(e.event,n)}).subscribe(function(e){var t,n,o,u=e.event,l=ui(u.url);if(l){var d=null===(n=u.responseWrapper)||void 0===n?void 0:n.bodySize,f=null===(o=u.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){s(this,void 0,void 0,function(){var i,o,s;return a(this,function(a){switch(a.label){case 0:return t.requestBodyJson||t.responseBodyJson?[4,Promise.all([t.requestBodyJson,t.responseBodyJson])]:[3,2];case 1:if(i=c.apply(void 0,[a.sent(),2]),o=i[0],s=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(s)try{e["[Amplitude] Response Body"]=JSON.stringify(s)}catch(e){null==r||r.debug("Failed to stringify response body")}a.label=2;case 2:return null==n||n.track(ii,e),[2]}})})}(((t={})["[Amplitude] URL"]=l.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=l.query,t["[Amplitude] URL Fragment"]=l.fragment,t["[Amplitude] Request Method"]=u.method,t["[Amplitude] Status Code"]=u.status,t["[Amplitude] Start Time"]=u.startTime,t["[Amplitude] Completion Time"]=u.endTime,t["[Amplitude] Duration"]=u.duration,t["[Amplitude] Request Body Size"]=f,t["[Amplitude] Response Body Size"]=d,t["[Amplitude] Request Type"]=u.type,t["[Amplitude] Request Headers"]=u.requestHeaders,t["[Amplitude] Response Headers"]=u.responseHeaders,t),u,r,i)}})}!function(e){e.NetworkObservable="networkObservable"}(ti||(ti={}));var vi=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new on(function(e){var n=new It(function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)});return Ot.subscribe(n,t),function(){Ot.unsubscribe(n)}});return(e={})[ti.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var s;return a(this,function(a){return"undefined"==typeof document||(s=r(),t=null==i?void 0:i.loggerProvider,ni=fi({allObservables:s,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){return ni.unsubscribe(),[2]})})}}};let pi=-1;const hi=e=>{addEventListener("pageshow",t=>{t.persisted&&(pi=t.timeStamp,e(t))},!0)},gi=(e,t,n,r)=>{let i,o;return s=>{t.value>=0&&(s||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},mi=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},yi=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},bi=()=>{const e=yi();return e?.activationStart??0},wi=(e,t=-1)=>{const n=yi();let r="navigate";return pi>=0?r="back-forward-cache":n&&(document.prerendering||bi()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},Ei=new WeakMap;function Si(e,t){return Ei.get(e)||Ei.set(e,new t),Ei.get(e)}class Ti{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}const ki=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver(e=>{Promise.resolve().then(()=>{t(e.getEntries())})});return r.observe({type:e,buffered:!0,...n}),r}}catch{}},_i=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let Ii=-1;const Pi=new Set,Oi=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,Ai=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Pi)e();isFinite(Ii)||(Ii="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",Ai,!0))}},Ci=()=>{if(Ii<0){const e=bi(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime;Ii=t??Oi(),addEventListener("visibilitychange",Ai,!0),addEventListener("prerenderingchange",Ai,!0),hi(()=>{setTimeout(()=>{Ii=Oi()})})}return{get firstHiddenTime(){return Ii},onHidden(e){Pi.add(e)}}},xi=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},Ri=[1800,3e3],Di=(e,t={})=>{xi(()=>{const n=Ci();let r,i=wi("FCP");const o=ki("paint",e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-bi(),0),i.entries.push(t),r(!0)))});o&&(r=gi(e,i,Ri,t.reportAllChanges),hi(n=>{i=wi("FCP"),r=gi(e,i,Ri,t.reportAllChanges),mi(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Li=[.1,.25];let Ni=0,ji=1/0,Mi=0;const Ui=e=>{for(const t of e)t.interactionId&&(ji=Math.min(ji,t.interactionId),Mi=Math.max(Mi,t.interactionId),Ni=Mi?(Mi-ji)/7+1:0)};let qi;const Fi=()=>qi?Ni:performance.interactionCount??0;let Bi=0;class Hi{u=[];l=new Map;m;p;v(){Bi=Fi(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((Fi()-Bi)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort((e,t)=>t.P-e.P),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const Vi=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=_i(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},zi=[200,500],Ji=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=Ci();xi(()=>{"interactionCount"in performance||qi||(qi=ki("event",Ui,{type:"event",buffered:!0,durationThreshold:0}));let r,i=wi("INP");const o=Si(t,Hi),s=e=>{Vi(()=>{for(const t of e)o.h(t);const t=o.L();t&&t.P!==i.value&&(i.value=t.P,i.entries=t.entries,r())})},a=ki("event",s,{durationThreshold:t.durationThreshold??40});r=gi(e,i,zi,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),hi(()=>{o.v(),i=wi("INP"),r=gi(e,i,zi,t.reportAllChanges)}))})};class $i{m;h(e){this.m?.(e)}}const Ki=[2500,4e3],Wi=[800,1800],Gi=e=>{document.prerendering?xi(()=>Gi(e)):"complete"!==document.readyState?addEventListener("load",()=>Gi(e),!0):setTimeout(e)};function Qi(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function Yi(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(Qi(e)),navigationStart:Math.floor(performance.timeOrigin)}}var Xi,Zi=function(){var e=null,t=M(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return s(void 0,void 0,void 0,function(){var o,s;return a(this,function(a){return void 0===n||(o=_e((null==r?void 0:r.href)||"",t.loggerProvider),s={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":_e((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":_e(o.split("?")[0],t.loggerProvider)},((e,t={})=>{xi(()=>{const n=Ci();let r,i=wi("LCP");const o=Si(t,$i),s=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-bi(),0),i.entries=[t],r())},a=ki("largest-contentful-paint",s);if(a){r=gi(e,i,Ki,t.reportAllChanges);const n=_i(()=>{s(a.takeRecords()),a.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(Vi(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});hi(n=>{i=wi("LCP"),r=gi(e,i,Ki,t.reportAllChanges),mi(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(function(e){s["[Amplitude] LCP"]=Yi(e)}),Di(function(e){s["[Amplitude] FCP"]=Yi(e)}),Ji(function(e){s["[Amplitude] INP"]=Yi(e)}),((e,t={})=>{const n=Ci();Di(_i(()=>{let r,i=wi("CLS",0);const o=Si(t,Ti),s=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},a=ki("layout-shift",s);a&&(r=gi(e,i,Li,t.reportAllChanges),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),hi(()=>{o.i=0,i=wi("CLS",0),r=gi(e,i,Li,t.reportAllChanges),mi(()=>r())}),setTimeout(r))}))})(function(e){s["[Amplitude] CLS"]=Yi(e)}),((e,t={})=>{let n=wi("TTFB"),r=gi(e,n,Wi,t.reportAllChanges);Gi(()=>{const i=yi();i&&(n.value=Math.max(i.responseStart-bi(),0),n.entries=[i],r(!0),hi(()=>{n=wi("TTFB",0),r=gi(e,n,Wi,t.reportAllChanges),r(!0)}))})})(function(e){s["[Amplitude] TTFB"]=Yi(e)}),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",s),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},eo=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},to=function(e,t,n,r,i){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=o(e,["referrer","referring_domain"]),u=t||{};u.referrer;var c=u.referring_domain,l=o(u,["referrer","referring_domain"]);if(no(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every(function(e){return!e})}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var d=JSON.stringify(a)!==JSON.stringify(l),f=eo(s||"")!==eo(c||""),v=!t||d||f;return v?r.debug("This is a new campaign. An $identify event will be sent."):r.debug("This is not a new campaign because it's the same as the previous one."),v},no=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some(function(e){return e instanceof RegExp?e.test(t):e===t})},ro=function(){function e(e,t){var n,r,o;this.shouldTrackNewCampaign=!1,this.options=i({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=null===(n=t.cookieOptions)||void 0===n?void 0:n.domain,o=r,o?(o.startsWith(".")&&(o=o.substring(1)),[new RegExp("".concat(o.replace(".","\\."),"$"))]):[])},e),this.storage=t.cookieStorage,this.storageKey=xe(t.apiKey,"MKTG"),this.webExpStorageKey=xe(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=P,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:return[4,this.fetchCampaign()];case 1:return t=c.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||be(this.sessionTimeout,this.lastEventTime),to(this.currentCampaign,this.previousCampaign,this.options,this.logger,e)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return s(this,void 0,void 0,function(){var e;return a(this,function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new At).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,o,s=(t=this.currentCampaign,n=this.options,r=i(i({},P),t),o=Object.entries(r).reduce(function(e,t){var r,i=c(t,2),o=i[0],s=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=s?s:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),s?e.set(o,s):e.unset(o)},new R),B(o));return e&&(s.event_id=e),s},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),io="AMP_CURRENT_PAGE",oo="AMP_PREVIOUS_PAGE",so="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(Xi||(Xi={}));var ao=new Set([r.IDENTIFY,r.GROUP_IDENTIFY,r.REVENUE]),uo=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=M(),o=void 0,u=!1,l=void 0,d=!1,f=!1,v=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=_e(e,l);t=new URL(n).hostname}catch(e){null==l||l.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return Xi.Direct;var i=n.some(function(e){return-1!==t.indexOf(e)}),o=n.some(function(e){return-1!==r.indexOf(e)});return t===r||o&&i?Xi.Internal:Xi.External},p=function(){s(void 0,void 0,void 0,function(){var e,t,n,r,i;return a(this,function(s){switch(s.label){case 0:return o&&u?[4,o.get(so)]:[3,3];case 1:return e=s.sent(),t=_e("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[io])||"",r=void 0,r=t===n?(null==e?void 0:e[oo])||"":n||document.referrer||"",[4,o.set(so,(i={},i[io]=t,i[oo]=r,i))];case 2:s.sent(),s.label=3;case 3:return[2]}})})},h={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return(l=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),f=!0,r?[4,(o=new Re(r.sessionStorage)).isEnabled()]:[3,2];case 1:u=t.sent(),r.addEventListener("popstate",p),d||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),f&&p()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),f&&p()}}),d=!0),t.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,n,r,s,c;return a(this,function(a){switch(a.label){case 0:return t=_e("undefined"!=typeof location&&location.href||""),o&&u?[4,o.get(so)]:[3,5];case 1:return(null==(n=a.sent())?void 0:n[io])?[3,3]:[4,o.set(so,(c={},c[io]=t,c[oo]=document.referrer||"",c))];case 2:a.sent(),a.label=3;case 3:return[4,o.get(so)];case 4:if(r=a.sent(),s="",r&&(s=r[oo]||""),ao.has(e.event_type))return[2,e];e.event_properties=i(i({},e.event_properties||{}),{"[Amplitude] Page Domain":co(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":co(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":co(e,"[Amplitude] Page Path","undefined"!=typeof location&&_e(location.pathname)||""),"[Amplitude] Page Title":co(e,"[Amplitude] Page Title",jt(Nt)),"[Amplitude] Page URL":co(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":s,"[Amplitude] Previous Page Type":v(s)}),a.label=5;case 5:return[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",p),f=!1),o&&u?[4,o.set(so,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}};return h};function co(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var lo=function(e){function n(){var t=e.apply(this,l([],c(arguments),!1))||this;return t._diagnosticsSampleRate=0,t}return t(n,e),n.prototype.init=function(e,t,n){var r,o;return void 0===e&&(e=""),arguments.length>2?(r=t,o=n):"string"==typeof t?(r=t,o=void 0):(r=null==t?void 0:t.userId,o=t),H(this._init(i(i({},o),{userId:r,apiKey:e})))},n.prototype._init=function(t){return s(this,void 0,void 0,function(){var n,r,s,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I=this;return a(this,function(a){switch(a.label){case 0:return this.initializing?[2]:(this.initializing=!0,n=function(e){var t,n;return void 0===e&&(e={}),!0===(null===(t=e.remoteConfig)||void 0===t?void 0:t.fetchRemoteConfig)||!1!==(null===(n=e.remoteConfig)||void 0===n?void 0:n.fetchRemoteConfig)&&!1!==e.fetchRemoteConfig}(t),r=null!==(b=t.loggerProvider)&&void 0!==b?b:new K,s=null!==(w=t.serverZone)&&void 0!==w?w:"US",c=this._diagnosticsSampleRate,l=null===(E=t.enableDiagnostics)||void 0===E||E,n?(u=new Ge(t.apiKey,r,s,null===(S=t.remoteConfig)||void 0===S?void 0:S.serverUrl),[4,new Promise(function(e){null==u||u.subscribe("configs.diagnostics.browserSDK","all",function(t,n,i){if(r.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:i},null,2)),t){var o=t.sampleRate;"number"!=typeof o||isNaN(o)||(c=o);var s=t.enabled;"boolean"==typeof s&&(l=s)}e()})})]):[3,2]);case 1:a.sent(),a.label=2;case 2:return(d=new Je(t.apiKey,r,s,{enabled:l,sampleRate:c})).setTag("library","".concat(_n,"/").concat(kn)),"undefined"!=typeof navigator&&d.setTag("user_agent",navigator.userAgent),[4,Yn(t.apiKey,t,this,d,{loggerProvider:r,serverZone:s,enableDiagnostics:l,diagnosticsSampleRate:c})];case 3:return f=a.sent(),n&&u?[4,new Promise(function(e){null==u||u.subscribe("configs.analyticsSDK.browserSDK","all",function(t,n,r){f.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&pr(t,f),e()})})]:[3,5];case 4:a.sent(),a.label=5;case 5:return[4,e.prototype._init.call(this,f)];case 6:return a.sent(),this.logBrowserOptions(f),this.config.remoteConfigClient=u,ln(this.config.defaultTracking)?(O=this.config,v=ln(O.defaultTracking)&&O.defaultTracking&&"object"==typeof O.defaultTracking&&O.defaultTracking.attribution&&"object"==typeof O.defaultTracking.attribution?i({},O.defaultTracking.attribution):{},this.webAttribution=new ro(v,this.config),[4,this.webAttribution.init()]):[3,8];case 7:a.sent(),a.label=8;case 8:return p=Se(),h=p.ampTimestamp?Number(p.ampTimestamp):void 0,g=!h||Date.now()<h,m=g&&!Number.isNaN(Number(p.ampSessionId))?Number(p.ampSessionId):void 0,this.setSessionId(null!==(_=null!==(k=null!==(T=t.sessionId)&&void 0!==T?T:m)&&void 0!==k?k:this.config.sessionId)&&void 0!==_?_:Date.now()),(y=me(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(dr()).promise];case 9:a.sent(),a.label=10;case 10:return[4,this.add(new se({diagnosticsClient:d})).promise];case 11:return a.sent(),[4,this.add(new In).promise];case 12:return a.sent(),[4,this.add(new ye).promise];case 13:return a.sent(),function(e){lr||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),lr=!0)}(this.config),P=this.config.defaultTracking,cn(P,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(cr()).promise]):[3,15];case 14:a.sent(),a.label=15;case 15:return dn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(sr()).promise]):[3,17];case 16:a.sent(),a.label=17;case 17:return fn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(nr(wn(this.config))).promise]):[3,19];case 18:a.sent(),a.label=19;case 19:return hn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Gr(mn(this.config),{diagnosticsClient:d})).promise]):[3,21];case 20:a.sent(),a.label=21;case 21:return gn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(ri(yn(this.config))).promise]):[3,23];case 22:a.sent(),a.label=23;case 23:return pn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(vi(bn(this.config))).promise]):[3,25];case 24:a.sent(),a.label=25;case 25:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(Zi()).promise]):[3,27];case 26:a.sent(),a.label=27;case 27:return function(e){return cn(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(uo()).promise]):[3,29];case 28:a.sent(),a.label=29;case 29:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 30:return a.sent(),y.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=o(t,["time"]),i="number"==typeof n?{time:n}:void 0;I.track(e.eventType,r,i)}),[2]}var P,O})})},n.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},n.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){me(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},n.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},n.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){me(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},n.prototype.reset=function(){this.setDeviceId(q()),this.setUserId(void 0),this.timeline.onReset()},n.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},n.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},n.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},n.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),H(Promise.resolve());if(e===this.config.sessionId)return H(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,vn(this.config.defaultTracking)&&(r&&i&&n.push(this.track(Fn,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(B(this.config.identify)).promise),vn(this.config.defaultTracking)&&n.push(this.track(qn,void 0,{event_id:s?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,H(Promise.all(n))},n.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},n.prototype.setTransport=function(e){this.config?this.config.transportProvider=Zn(e):this.q.push(this.setTransport.bind(this,e))},n.prototype.identify=function(t,n){if(Tn(t)){var r=t._q;t._q=[],t=Sn(new R,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},n.prototype.groupIdentify=function(t,n,r,i){if(Tn(r)){var o=r._q;r._q=[],r=Sn(new R,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},n.prototype.revenue=function(t,n){if(Tn(t)){var r=t._q;t._q=[],t=Sn(new z,r)}return e.prototype.revenue.call(this,t,n)},n.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},n.prototype.process=function(t){return s(this,void 0,void 0,function(){var n,i,o;return a(this,function(s){return n=Date.now(),i=be(this.config.sessionTimeout,this.config.lastEventTime),o=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===qn||t.event_type===Fn||t.session_id&&t.session_id!==this.getSessionId()||(i||o?(this.setSessionId(n),o&&this.config.loggerProvider.log("Created a new session for new campaign.")):i||this.trackCampaignEventIfNeeded()),t.event_type===r.IDENTIFY&&t.user_properties&&(this.userProperties=this.getOperationAppliedUserProperties(t.user_properties)),[2,e.prototype.process.call(this,t)]})})},n.prototype.logBrowserOptions=function(e){try{var t=i(i({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",JSON.stringify(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},n.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},n}(V),fo=function(){var e=new lo;return{init:ie(e.init.bind(e),"init",te(e),re(e,["config"])),add:ie(e.add.bind(e),"add",te(e),re(e,["config.apiKey","timeline.plugins"])),remove:ie(e.remove.bind(e),"remove",te(e),re(e,["config.apiKey","timeline.plugins"])),track:ie(e.track.bind(e),"track",te(e),re(e,["config.apiKey","timeline.queue.length"])),logEvent:ie(e.logEvent.bind(e),"logEvent",te(e),re(e,["config.apiKey","timeline.queue.length"])),identify:ie(e.identify.bind(e),"identify",te(e),re(e,["config.apiKey","timeline.queue.length"])),groupIdentify:ie(e.groupIdentify.bind(e),"groupIdentify",te(e),re(e,["config.apiKey","timeline.queue.length"])),setGroup:ie(e.setGroup.bind(e),"setGroup",te(e),re(e,["config.apiKey","timeline.queue.length"])),revenue:ie(e.revenue.bind(e),"revenue",te(e),re(e,["config.apiKey","timeline.queue.length"])),flush:ie(e.flush.bind(e),"flush",te(e),re(e,["config.apiKey","timeline.queue.length"])),getUserId:ie(e.getUserId.bind(e),"getUserId",te(e),re(e,["config","config.userId"])),setUserId:ie(e.setUserId.bind(e),"setUserId",te(e),re(e,["config","config.userId"])),getDeviceId:ie(e.getDeviceId.bind(e),"getDeviceId",te(e),re(e,["config","config.deviceId"])),setDeviceId:ie(e.setDeviceId.bind(e),"setDeviceId",te(e),re(e,["config","config.deviceId"])),reset:ie(e.reset.bind(e),"reset",te(e),re(e,["config","config.userId","config.deviceId"])),getSessionId:ie(e.getSessionId.bind(e),"getSessionId",te(e),re(e,["config"])),setSessionId:ie(e.setSessionId.bind(e),"setSessionId",te(e),re(e,["config"])),extendSession:ie(e.extendSession.bind(e),"extendSession",te(e),re(e,["config"])),setOptOut:ie(e.setOptOut.bind(e),"setOptOut",te(e),re(e,["config"])),setTransport:ie(e.setTransport.bind(e),"setTransport",te(e),re(e,["config"])),getIdentity:ie(e.getIdentity.bind(e),"getIdentity",te(e),re(e,["config"])),getOptOut:ie(e.getOptOut.bind(e),"getOptOut",te(e),re(e,["config"])),_setDiagnosticsSampleRate:ie(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",te(e),re(e,["config"]))}},vo=fo(),po=Object.freeze({__proto__:null,get IdentifyOperation(){return n},get SpecialEventType(){return r},get RevenueProperty(){return N},get LogLevel(){return J},get ServerZone(){return tt},OfflineDisabled:null,DEFAULT_CSS_SELECTOR_ALLOWLIST:rt,DEFAULT_DATA_ATTRIBUTE_PREFIX:it,DEFAULT_ACTION_CLICK_ALLOWLIST:ot}),ho=vo.add,go=vo.extendSession,mo=vo.flush,yo=vo.getDeviceId,bo=vo.getIdentity,wo=vo.getOptOut,Eo=vo.getSessionId,So=vo.getUserId,To=vo.groupIdentify,ko=vo.identify,_o=vo.init,Io=vo.logEvent,Po=vo.remove,Oo=vo.reset,Ao=vo.revenue,Co=vo.setDeviceId,xo=vo.setGroup,Ro=vo.setOptOut,Do=vo.setSessionId,Lo=vo.setTransport,No=vo.setUserId,jo=vo.track,Mo=vo._setDiagnosticsSampleRate,Uo=Object.freeze({__proto__:null,add:ho,extendSession:go,flush:mo,getDeviceId:yo,getIdentity:bo,getOptOut:wo,getSessionId:Eo,getUserId:So,groupIdentify:To,identify:ko,init:_o,logEvent:Io,remove:Po,reset:Oo,revenue:Ao,setDeviceId:Co,setGroup:xo,setOptOut:Ro,setSessionId:Do,setTransport:Lo,setUserId:No,track:jo,_setDiagnosticsSampleRate:Mo,createInstance:fo,AmplitudeBrowser:lo,runQueuedFunctions:En,Revenue:z,Identify:R,Types:po});!function(){var e=M();if(e){var t=function(e){var t=fo(),n=M();return n&&n.amplitudeGTM&&n.amplitudeGTM._iq&&e&&(n.amplitudeGTM._iq[e]=t),t};if(e.amplitudeGTM=Object.assign(e.amplitudeGTM||{},Uo,{createInstance:t}),e.amplitudeGTM.invoked){var n=e.amplitudeGTM._q;e.amplitudeGTM._q=[],En(Uo,n);for(var r=Object.keys(e.amplitudeGTM._iq)||[],i=0;i<r.length;i++){var o=r[i],s=Object.assign(e.amplitudeGTM._iq[o],t(o)),a=s._q;s._q=[],En(s,a)}}}else console.error("[Amplitude] Error: GlobalScope is not defined")}()}();
|
|
1
|
+
!function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n,r,i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function s(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})}function a(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function l(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(n||(n={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(r||(r={}));var d,f="AMP",v="".concat(f,"_unsent"),p="$default_instance",h="https://api2.amplitude.com/2/httpapi",g="dclid",m="fbclid",y="gbraid",b="gclid",w="ko_click_id",E="li_fat_id",S="msclkid",T="rdt_cid",k="ttclid",_="twclid",I="wbraid",P={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},O=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],x=["authorization","cookie","set-cookie"],A=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!C(t,n))return!1}return!0},C=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)i=i&&A(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return A(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},R=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return i({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(d.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(d.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(d.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(d.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(d.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(d.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(d.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(d.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(d.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[d.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[d.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===d.ADD?"number"==typeof n:e===d.UNSET||e===d.REMOVE||C(t,n)))},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(d||(d={}));var D,L=[d.CLEAR_ALL,d.UNSET,d.SET,d.SET_ONCE,d.ADD,d.APPEND,d.PREPEND,d.PREINSERT,d.POSTINSERT,d.REMOVE];!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(D||(D={}));var N,j=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=D.Unknown),{event:e,code:t,message:n}},M=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},U=l([],c(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),q=function(e){var t,n=M();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,q)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,l([],c(r.entries()),!1).map(function(e){var t=c(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(U[r]):U[r]}).join("")},F=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,r;return s(this,void 0,void 0,function(){return a(this,function(i){switch(i.label){case 0:return this.plugins.some(function(t){return t.name===e.name})?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=q(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}})})},e.prototype.deregister=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i;return a(this,function(o){switch(o.label){case 0:return r=this.plugins.findIndex(function(t){return t.name===e}),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}})})},e.prototype.reset=function(e){this.applying=!1,this.plugins.map(function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)}),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(n){t.queue.push([e,n]),t.scheduleApply(0)})},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout(function(){t.apply(t.queue.shift()).then(function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)})},e))},e.prototype.apply=function(e){return s(this,void 0,void 0,function(){var t,n,r,o,s,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k;return a(this,function(a){switch(a.label){case 0:if(!e)return[2];t=c(e,1),n=t[0],r=c(e,2),o=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),s=this.plugins.filter(function(e){return"before"===e.type}),a.label=1;case 1:a.trys.push([1,6,7,8]),l=u(s),d=l.next(),a.label=2;case 2:return d.done?[3,5]:(g=d.value).execute?[4,g.execute(i({},n))]:[3,4];case 3:if(null===(m=a.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),o({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),a.label=4;case 4:return d=l.next(),[3,2];case 5:return[3,8];case 6:return f=a.sent(),E={error:f},[3,8];case 7:try{d&&!d.done&&(S=l.return)&&S.call(l)}finally{if(E)throw E.error}return[7];case 8:v=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),a.label=9;case 9:a.trys.push([9,14,15,16]),p=u(v),h=p.next(),a.label=10;case 10:return h.done?[3,13]:(g=h.value).execute?[4,g.execute(i({},n))]:[3,12];case 11:if(null===(m=a.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),o({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(g.name),"', event: ").concat(JSON.stringify(n))),a.label=12;case 12:return h=p.next(),[3,10];case 13:return[3,16];case 14:return y=a.sent(),T={error:y},[3,16];case 15:try{h&&!h.done&&(k=p.return)&&k.call(p)}finally{if(T)throw T.error}return[7];case 16:return b=this.plugins.filter(function(e){return"destination"===e.type}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),w=b.map(function(e){var t=i({},n);return e.execute(t).catch(function(e){return j(t,0,String(e))})}),Promise.all(w).then(function(e){var t=c(e,1)[0]||j(n,100,"Event not tracked, no destination plugins on the instance");o(t)}),[2]}})})},e.prototype.flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r=this;return a(this,function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return r.apply(e)}))];case 1:return i.sent(),t=this.plugins.filter(function(e){return"destination"===e.type}),n=t.map(function(e){return e.flush&&e.flush()}),[4,Promise.all(n)];case 2:return i.sent(),[2]}})})},e.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)})},e}(),B=function(e,t){return i(i({},t),{event_type:r.IDENTIFY,user_properties:e.getUserProperties()})},H=function(e){return{promise:e||Promise.resolve()}},V=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new F(this),this.name=e}return e.prototype._init=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}})})},e.prototype.runQueuedFunctions=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o,s,c,l;return a(this,function(a){switch(a.label){case 0:t=this[e],this[e]=[],a.label=1;case 1:a.trys.push([1,8,9,10]),n=u(t),r=n.next(),a.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return a.sent(),[3,6];case 4:return[4,o];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return s=a.sent(),c={error:s},[3,10];case 9:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:a.sent(),a.label=12;case 12:return[2]}})})},e.prototype.track=function(e,t,n){var r=function(e,t,n){return i(i(i({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return H(this.dispatch(r))},e.prototype.identify=function(e,t){var n=B(e,t);return H(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,o){var s=function(e,t,n,o){var s;return i(i({},o),{event_type:r.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(s={},s[e]=t,s)})}(e,t,n,o);return H(this.dispatch(s))},e.prototype.setGroup=function(e,t,n){var o=function(e,t,n){var o,s=new R;return s.set(e,t),i(i({},n),{event_type:r.IDENTIFY,user_properties:s.getUserProperties(),groups:(o={},o[e]=t,o)})}(e,t,n);return H(this.dispatch(o))},e.prototype.revenue=function(e,t){var n=function(e,t){return i(i({},t),{event_type:r.REVENUE,event_properties:e.getEventProperties()})}(e,t);return H(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),H())},e.prototype._addPlugin=function(e){return H(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),H())},e.prototype._removePlugin=function(e){return H(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(j(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return s(this,void 0,void 0,function(){var t=this;return a(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))})]})})},e.prototype.getOperationAppliedUserProperties=function(e){var t={};if(void 0===e)return t;var r={};return Object.keys(e).forEach(function(t){Object.values(n).includes(t)||(r[t]=e[t])}),L.forEach(function(r){if(Object.keys(e).includes(r)){var i=e[r];switch(r){case n.CLEAR_ALL:Object.keys(t).forEach(function(e){delete t[e]});break;case n.UNSET:Object.keys(i).forEach(function(e){delete t[e]});break;case n.SET:Object.assign(t,i)}}}),Object.assign(t,r),t},e.prototype.process=function(e){return s(this,void 0,void 0,function(){var t,n,i,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),this.config.optOut?[2,j(e,0,"Event skipped due to optOut config")]:(e.event_type===r.IDENTIFY&&(t=this.getOperationAppliedUserProperties(e.user_properties),this.timeline.onIdentityChanged({userProperties:t})),[4,this.timeline.push(e)]);case 1:return 200===(o=s.sent()).code?this.config.loggerProvider.log(o.message):100===o.code?this.config.loggerProvider.warn(o.message):this.config.loggerProvider.error(o.message),[2,o];case 2:return n=s.sent(),i=String(n),this.config.loggerProvider.error(i),[2,o=j(e,0,i)];case 3:return[2]}})})},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.timeline.onOptOutChanged(e),this.config.optOut=Boolean(e))},e.prototype.flush=function(){return H(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find(function(t){return t.name===e});if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter(function(t){return t instanceof e})},e}(),z=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){return A(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?i({},this.properties):{};return e[N.REVENUE_PRODUCT_ID]=this.productId,e[N.REVENUE_QUANTITY]=this.quantity,e[N.REVENUE_PRICE]=this.price,e[N.REVENUE_TYPE]=this.revenueType,e[N.REVENUE_CURRENCY]=this.currency,e[N.REVENUE]=this.revenue,e[N.RECEIPT]=this.receipt,e[N.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(N||(N={}));var J;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(J||(J={}));var $="Amplitude Logger ",W=function(){function e(){this.logLevel=J.None}return e.prototype.disable=function(){this.logLevel=J.None},e.prototype.enable=function(e){void 0===e&&(e=J.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Verbose||console.log("".concat($,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Warn||console.warn("".concat($,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Error||console.error("".concat($,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<J.Debug||console.log("".concat($,"[Debug]: ").concat(e.join(" ")))},e}(),K=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:p,logLevel:J.Warn,loggerProvider:new W,offline:!1,optOut:!1,serverUrl:h,serverZone:"US",useBatch:!1}},G=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=K();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=X(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),Y=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":h},X=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=K().serverZone),void 0===n&&(n=K().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:K().serverZone;return{serverZone:r,serverUrl:Y(r,n)}},Q=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function Z(e){return e>=200&&e<300}var ee=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},te=function(e){return function(){var t=i({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ne=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=u(t.split(".")),o=i.next();!o.done;o=i.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},re=function(e,t){return function(){var n,r,i={};try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=ne(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ie=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n(),u=a.logger,c=a.logLevel;if(c&&c<J.Debug||!c||!u)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:ee(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),u.debug(JSON.stringify(l,null,2))}):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),u.debug(JSON.stringify(l,null,2))),d}};function oe(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var se=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return s(this,void 0,void 0,function(){var n,r=this;return a(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(v,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map(function(e){return r.execute(e)})).catch(),[2,Promise.resolve(void 0)]}})})},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=q()),new Promise(function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter(function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)})},e.prototype.scheduleEvents=function(e){var t=this;e.forEach(function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)})},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout(function(){t.queue=t.queue.map(function(e){return e.timeout=0,e}),t.flush(!0)},e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),s(this,void 0,void 0,function(){var t,n,r=this;return a(this,function(i){switch(i.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):n.push(e)}),o=t,u=this.config.flushQueueSize,c=Math.max(u,1),[4,o.reduce(function(e,t,n){var r=Math.floor(n/c);return e[r]||(e[r]=[]),e[r].push(t),e},[]).reduce(function(t,n){return s(r,void 0,void 0,function(){return a(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}})})},Promise.resolve())]);case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var o,u,c})})},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),s(this,void 0,void 0,function(){var r,i,s,u,c;return a(this,function(a){switch(a.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,o(t,["extra"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new Q,a.label=1;case 1:return a.trys.push([1,3,,4]),i=X(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(i,r)];case 2:return null===(s=a.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(s,e),[3,4]):("body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(oe(s))):this.fulfillRequest(e,s.statusCode,s.status),[2]);case 3:return u=a.sent(),c=(l=u)instanceof Error?l.message:String(l),this.config.loggerProvider.error(c),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:c,stack_trace:ee()}),this.handleResponse({status:D.Failed,statusCode:0},e),[3,4];case 4:return[2]}var l})})},e.prototype.handleResponse=function(e,t){var n;Z(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map(function(e){return e.event.event_type}),code:e.statusCode,status:e.status,body:oe(e),stack_trace:ee()});var r=e.status;switch(r){case D.Success:this.handleSuccessResponse(e,t);break;case D.Invalid:this.handleInvalidResponse(e,t);break;case D.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case D.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=l(l(l(l([],c(Object.values(e.body.eventsWithInvalidFields)),!1),c(Object.values(e.body.eventsWithMissingFields)),!1),c(Object.values(e.body.eventsWithInvalidIdLengths)),!1),c(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter(function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)});o.length>0&&this.config.loggerProvider.warn(oe(e));var s=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(s)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(oe(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),a=new Set(i),u=new Set(o),c=t.filter(function(t,r){if(!(t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)))return u.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)});c.length>0&&this.config.loggerProvider.warn(oe(e));var l=this.removeEventsExceedFlushMaxRetries(c);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map(function(e){return e.timeout=e.attempts*t.retryTimeout,e}),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;Z(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map(function(e){return e.event.event_type}),code:t,message:n,stack_trace:ee()})),this.removeEvents(e),e.forEach(function(e){return e.callback(j(e.event,t,n))})},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(e){return e.event});this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(t){return!e.some(function(e){return e.event.insert_id===t.event.insert_id})}),this.saveEvents()},e}(),ae=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:ue(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),ue=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},ce=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(t){e(t)}),this.queue=[])},e}(),le=function(){return le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},le.apply(this,arguments)};function de(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function fe(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var ve=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=de(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next()){if(s.value===i)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(!a||!u){var c=Object.keys(e).sort(),l=Object.keys(t).sort();if(!ve(c,l))return!1;var d=!0;return Object.keys(e).forEach(function(n){ve(e[n],t[n])||(d=!1)}),d}for(var f=0;f<e.length;f++)if(!ve(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var pe=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=le({},this.identity.userProperties),n=le(le({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,s,a,u=n.userProperties||{};try{for(var c=de(Object.entries(e)),l=c.next();!l.done;l=c.next()){var d=fe(l.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var p=(i=void 0,de(Object.entries(v))),h=p.next();!h.done;h=p.next()){var g=fe(h.value,2),m=g[0],y=g[1];u[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(s=void 0,de(Object.keys(v))),w=b.next();!w.done;w=b.next()){delete u[m=w.value]}}catch(e){s={error:e}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return le({},this.identity)},e.prototype.setIdentity=function(e){var t=le({},this.identity);this.identity=le({},e),ve(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,ge=function(){function e(){this.identityStore=new pe,this.eventBridge=new ce,this.applicationContextProvider=new ae}return e.getInstance=function(t){return he.analyticsConnectorInstances||(he.analyticsConnectorInstances={}),he.analyticsConnectorInstances[t]||(he.analyticsConnectorInstances[t]=new e),he.analyticsConnectorInstances[t]},e}(),me=function(e){return void 0===e&&(e=p),ge.getInstance(e)},ye=function(){function e(){this.name="identity",this.type="before",this.identityStore=me().identityStore}return e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return e.instanceName&&(this.identityStore=me(e.instanceName).identityStore),[2]})})},e}(),be=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},we=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[f,t,e.substring(0,n)].filter(Boolean).join("_")},Ee=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},Se=function(){var e,t=M();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce(function(e,t){var n=t.split("=",2),r=Te(n[0]),i=Te(n[1]);return i?(e[r]=i,e):e},{}):{}},Te=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},ke=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},_e=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Ie=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},Pe=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}})})},e.prototype.set=function(e,t){return s(this,void 0,void 0,function(){return a(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),Oe=function(){function e(e,t){void 0===t&&(t={}),this.options=i({},e),this.config=t}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:if(!M())return[2,!1];e.testValue=String(Date.now()),t=i(i({},this.options),{expirationDays:.003}),n=new e(t),r="AMP_TEST_".concat(q().substring(0,8)),o.label=1;case 1:return o.trys.push([1,4,5,7]),[4,n.set(r,e.testValue)];case 2:return o.sent(),[4,n.get(r)];case 3:return[2,o.sent()===e.testValue];case 4:return o.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return o.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t,n;return a(this,function(r){switch(r.label){case 0:return[4,this.getRaw(e)];case 1:if(!(t=r.sent()))return[2,void 0];try{return void 0===(n=xe(t))?(console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)),[2,void 0]):[2,JSON.parse(n)]}catch(n){return console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t)),[2,void 0]}return[2]}})})},e.prototype.getRaw=function(e){var t,n,r,i;return s(this,void 0,void 0,function(){var o,s,c,l,d,f,v,p,h,g,m,y,b=this;return a(this,function(a){switch(a.label){case 0:o=M(),s=o,a.label=1;case 1:return a.trys.push([1,4,,5]),(c=null==s?void 0:s.cookieStore)?[4,c.getAll(e)]:[3,3];case 2:if(l=a.sent()){l.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:l.map(function(e){return e.domain})}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(d=u(l),f=d.next();!f.done;f=d.next())if(v=f.value,Ae(v.domain,this.options.domain))return[2,v.value]}catch(e){m={error:e}}finally{try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(m)throw m.error}}}a.label=3;case 3:return[3,5];case 4:return a.sent(),[3,5];case 5:return p=(null!==(i=null===(r=null==o?void 0:o.document)||void 0===r?void 0:r.cookie.split("; "))&&void 0!==i?i:[]).filter(function(t){return 0===t.indexOf(e+"=")}),h=void 0,"function"==typeof(g=this.config.duplicateResolverFn)&&p.length>1&&(h=p.find(function(t){var n;try{var r=g(t.substring(e.length+1));return r||null===(n=b.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),r}catch(e){return!1}})),h||(h=p[0]),h?[2,h.substring(e.length+1)]:[2,void 0]}})})},e.prototype.set=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i,o,s,u,c,l;return a(this,function(a){try{r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=void 0,(i=null!==t?r:-1)&&((s=new Date).setTime(s.getTime()+24*i*60*60*1e3),o=s),u="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t)))),o&&(u+="; expires=".concat(o.toUTCString())),u+="; path=/",this.options.domain&&(u+="; domain=".concat(this.options.domain)),this.options.secure&&(u+="; Secure"),this.options.sameSite&&(u+="; SameSite=".concat(this.options.sameSite)),(c=M())&&(c.document.cookie=u)}catch(t){l=t instanceof Error?t.message:String(t),console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}return[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2]})})},e}(),xe=function(e){var t;return null!==(t=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}}(e))&&void 0!==t?t:function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}}(e)},Ae=function(e,t){if(!e||!t)return!1;var n=e.startsWith(".")?e.substring(1):e,r=t.startsWith(".")?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},Ce=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[f,t,e.substring(0,n)].filter(Boolean).join("_")},Re=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r;return a(this,function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},e.prototype.getRaw=function(e){var t;return s(this,void 0,void 0,function(){return a(this,function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var n;return s(this,void 0,void 0,function(){return a(this,function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return s(this,void 0,void 0,function(){return a(this,function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return s(this,void 0,void 0,function(){return a(this,function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]})})},e}(),De="tags",Le="counters",Ne="histograms",je="events",Me="internal",Ue="last_flush_timestamp",qe=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=M())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},e.prototype.openDB=function(){var e=this;return new Promise(function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},r.onsuccess=function(){var n=r.result;n.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},n.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),n.close()},t(n)},r.onupgradeneeded=function(t){var n=t.target.result;e.createTables(n)}})},e.prototype.createTables=function(e){(e.objectStoreNames.contains(De)||e.createObjectStore(De,{keyPath:"key"}),e.objectStoreNames.contains(Le)||e.createObjectStore(Le,{keyPath:"key"}),e.objectStoreNames.contains(Ne)||e.createObjectStore(Ne,{keyPath:"key"}),e.objectStoreNames.contains(je))||e.createObjectStore(je,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Me)||e.createObjectStore(Me,{keyPath:"key"})},e.prototype.setTags=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([De],"readwrite"),r=n.objectStore(De),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Le],"readwrite"),r=n.objectStore(Le),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e=s.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Ne],"readwrite"),r=n.objectStore(Ne),[2,new Promise(function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach(function(e){var t=c(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e,t=s.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}})})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([je],"readwrite"),r=n.objectStore(je),[2,new Promise(function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach(function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}})},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}})];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return s(this,void 0,void 0,function(){var n,r,i,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=s.sent(),r=n.transaction([Me],"readwrite"),i=r.objectStore(Me),[2,new Promise(function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var s=i.put({key:e,value:t});s.onsuccess=function(){return n()},s.onerror=function(){return o(new Error("Failed to set internal value"))}})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return s(this,void 0,void 0,function(){var t,n,r,i;return a(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Me],"readonly"),r=n.objectStore(Me),[2,new Promise(function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}})];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Ue)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}})})},e.prototype.setLastFlushTimestamp=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Ue,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}})})},e.prototype.clearTable=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(new Error("Failed to clear table ".concat(t)))}})},e.prototype.getAllAndClear=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=a.sent(),t=e.transaction([De,Le,Ne,je],"readwrite"),[4,Promise.all([this.getAllFromStore(t,De),this.getAllFromStore(t,Le),this.getAllFromStore(t,Ne),this.getAllFromStore(t,je)])];case 2:return n=c.apply(void 0,[a.sent(),4]),r=n[0],i=n[1],o=n[2],s=n[3],[4,Promise.all([this.clearTable(t,Le),this.clearTable(t,Ne),this.clearTable(t,je)])];case 3:return a.sent(),[2,{tags:r,counters:i,histogramStats:o,events:s}];case 4:return u=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",u),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(new Error("Failed to get all from ".concat(t)))}})},e}(),Fe=function(e){var t,n=null==(t=M())?void 0:t.__AMPLITUDE_SCRIPT_URL__;if(n)return e.filename&&e.filename.includes(n)?"filename":e.stack&&e.stack.includes(n)?"stack":void 0},Be=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},He=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},Ve=3e5,ze=1e4,Je=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=i({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Ie(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,qe.isSupported()?this.storage=new qe(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=M();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",i({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Fe({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})},!0),t.addEventListener("unhandledrejection",function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Be(i),s=Fe({filename:o,stack:i});s&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:He(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:s}})},!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=ze?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=ze?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=ze)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout(function(){e.saveAllDataToStorage().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)}).finally(function(){e.saveTimer=null})},1e3)),this.flushTimer||(this.flushTimer=setTimeout(function(){e._flush().catch(function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)}).finally(function(){e.flushTimer=null})},Ve))},e.prototype.saveAllDataToStorage=function(){return s(this,void 0,void 0,function(){var e,t,n,r;return a(this,function(o){switch(o.label){case 0:return this.storage?(e=i({},this.inMemoryTags),t=i({},this.inMemoryCounters),n=i({},this.inMemoryHistograms),r=l([],c(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])]):[2];case 1:return o.sent(),[2]}})})},e.prototype._flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,u,c,l;return a(this,function(a){switch(a.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return a.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=a.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={},n.forEach(function(e){s[e.key]=e.value}),u={},r.forEach(function(e){u[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),c=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(s).length&&0===Object.keys(u).length&&0===c.length?[2]:(l={tags:o,histogram:u,counters:s,events:c},this.fetch(l),[2])}})})},e.prototype.fetch=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!M())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}})})},e.prototype.initializeFlushInterval=function(){return s(this,void 0,void 0,function(){var e,t,n;return a(this,function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(Ve),[2]):(n=e-t)>=Ve?(this._flush(),[2]):(this._setFlushTimer(Ve-n),[2])}})})},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout(function(){t._flush().catch(function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)}).finally(function(){t.flushTimer=null})},e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=Ie(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),$e=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,s,a,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S;if("object"!=typeof e)return null;var T=e.code||0,k=this.buildStatus(T);switch(k){case D.Success:return{status:k,statusCode:T,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case D.Invalid:return{status:k,statusCode:T,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(c=e.eps_threshold)&&void 0!==c?c:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(v=e.throttled_devices)&&void 0!==v?v:{},throttledEvents:null!==(p=e.throttled_events)&&void 0!==p?p:[]}};case D.PayloadTooLarge:return{status:k,statusCode:T,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case D.RateLimit:return{status:k,statusCode:T,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(E=e.exceeded_daily_quota_users)&&void 0!==E?E:{},throttledEvents:null!==(S=e.throttled_events)&&void 0!==S?S:[]}};case D.Timeout:default:return{status:k,statusCode:T}}},e.prototype.buildStatus=function(e){return Z(e)?D.Success:429===e?D.RateLimit:413===e?D.PayloadTooLarge:408===e?D.Timeout:e>=400&&e<500?D.Invalid:e>=500?D.Failed:D.Unknown},e}(),We=function(e){function n(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n,r,o;return a(this,function(s){switch(s.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:i({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}})})},n}($e),Ke=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),Ge=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new Ke(e,t)}return e.prototype.subscribe=function(e,t,n){var r=q(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return s(this,void 0,void 0,function(){var e,t=this;return a(this,function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.fetchPromise=this.fetch().then(function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null})),this.fetchPromise},e.prototype.subscribeAll=function(e){return s(this,void 0,void 0,function(){var t,n,r,i=this;return a(this,function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return s(this,void 0,void 0,function(){var n,r;return a(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),s(this,void 0,void 0,function(){var n,r,i,o,s,u,c=this;return a(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,u,l,d;return a(this,function(a){switch(a.label){case 0:i=new AbortController,s=setTimeout(function(){return i.abort()},t),a.label=1;case 1:return a.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:i.signal})];case 2:return(u=a.sent()).ok?[3,4]:[4,u.text()];case 3:return l=a.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(u.status,": ").concat(l)),[3,6];case 4:return[4,u.json()];case 5:return[2,{value:{remoteConfig:a.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=a.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(s),[7];case 9:return r<e-1?[4,new Promise(function(e){return setTimeout(e,c.getJitterDelay(n))})]:[3,11];case 10:a.sent(),a.label=11;case 11:return[2]}})},o=this,s=0,l.label=1;case 1:return s<e?[5,i(s)]:[3,4];case 2:if("object"==typeof(u=l.sent()))return[2,u.value];l.label=3;case 3:return s++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),Ye=M(),Xe=null==Ye?void 0:Ye.console,Qe={},Ze={},et=!1;var tt,nt={addListener:function(e,t){var n,r=(n=e,!!Xe&&"function"==typeof Xe[n]&&(Ze[n]||(Ze[n]=Xe[n],Xe[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(Qe[n]&&!et){et=!0;var r=Qe[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return et=!1,Ze[n].apply(Xe,e)}),!0));if(!r)return new Error("Console override failed");Qe[e]?Qe[e].push(t):Qe[e]=[t]},removeListener:function(e){var t,n;try{for(var r=u(Object.values(Qe)),i=r.next();!i.done;i=r.next())for(var o=i.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=u(Object.entries(Ze)),r=n.next();!r.done;r=n.next()){var i=c(r.value,2),o=i[0],s=i[1];s&&(Xe[o]=s)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}Ze={},Qe={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(tt||(tt={}));var rt=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],it="data-amp-track-",ot=["div","span","h1","h2","h3","h4","h5","h6"],st=l(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],c(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),at=st,ut=st,ct=["*"];function lt(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function dt(e,t,n){e&&ft({json:e,allowlist:t.map(vt),excludelist:n.map(vt),ancestors:[]})}function ft(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,s=e.excludelist,a=e.ancestors,d=e.parentObject,f=e.targetKey;i||(i=r);var v=Object.keys(i);try{for(var p=u(v),h=p.next();!h.done;h=p.next()){var g=h.value,m=l(l([],c(a),!1),[g],!1);lt(i[g])?ht(m,o)&&!ht(m,s)||delete i[g]:ft({json:r,targetObject:i[g],allowlist:o,excludelist:s,ancestors:m,parentObject:i,targetKey:g})}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}0===Object.keys(i).length&&d&&f&&delete d[f]}function vt(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function pt(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=0),r===t.length)return n===e.length;if(n===e.length){for(;r<t.length&&"**"===t[r];)r++;return r===t.length}var i=t[r];if("**"===i){if(r+1===t.length)return!0;for(var o=n;o<=e.length;o++)if(pt(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&pt(e,t,n+1,r+1)}function ht(e,t){return t.some(function(t){return pt(e,t)})}var gt=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach(function(e){var t=c(e,2),n=t[0],r=t[1];i[n]=r});else if(r instanceof Headers)r.forEach(function(e,t){i[t]=e});else if("object"==typeof r&&null!==r)try{for(var o=u(Object.entries(r)),s=o.next();!s.done;s=o.next()){var a=c(s.value,2),l=a[0],d=a[1];i[l]=d}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kt(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=M();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=yt(t,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){return 0===e.length?[2,null]:[2,St(this.body,e,t)]})})},e}(),mt=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),kt(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return yt(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){return 0===e.length?[2,null]:[2,St(this.body,e,t)]})})},e}();function yt(e,t){var n,r,i,o=M(),s=null==o?void 0:o.TextEncoder;if(s){var a;if("string"==typeof e)a=e,i=(new s).encode(a).length;else if(e instanceof Blob)i=(a=e).size;else if(e instanceof URLSearchParams)a=e,i=(new s).encode(a.toString()).length;else if(ArrayBuffer.isView(e))i=(a=e).byteLength;else if(e instanceof ArrayBuffer)i=(a=e).byteLength;else if(e instanceof FormData){var l=e,d=0,f=0;try{for(var v=u(l.entries()),p=v.next();!p.done;p=v.next()){var h=c(p.value,2),g=h[0],m=h[1];if(d+=g.length,"string"==typeof m)d+=(new s).encode(m).length;else{if(!(m instanceof Blob))return;d+=m.size}if(++f>=t)return}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(n)throw n.error}}i=d}else if(e instanceof ReadableStream)return void(a=e);return i}}var bt,wt=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,function(e,t){r[t]=e}),kt(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise(function(e){return setTimeout(function(){return e(null)},500)}),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}})})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,St(n.sent(),e,t)]}})})},e}(),Et=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var t,n;if(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=c(s.value.split(": "),2),l=a[0],d=a[1];l&&d&&(r[l]=d)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return kt(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),s(this,void 0,void 0,function(){var n;return a(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?(dt(n,e,t),[2,n]):[2,null]})})},e}();function St(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return dt(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(bt||(bt={}));var Tt="[REDACTED]",kt=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?bt.REMOVE:s,d=l([],c(x),!1),f={},v=function(t){var n=t.toLowerCase();d.find(function(e){return e.toLowerCase()===n})?a===bt.REDACT&&(f[t]=Tt):o.find(function(e){return e.toLowerCase()===n})?f[t]=e[t]:a===bt.REDACT&&(f[t]=Tt)};try{for(var p=u(Object.keys(e)),h=p.next();!h.done;h=p.next()){v(h.value)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}return f},_t=function(){function e(e,t,n,r,i,o,s,a,u,c,l){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=u,this.error=c,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(l([],c(O),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(l([],c(O),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter(function(e){var t=c(e,2);return t[0],void 0!==t[1]}))},e}();var It=function(e,t){void 0===t&&(t=q()),this.callback=e,this.id=t},Pt=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=M();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=M();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,s,a,u,c,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,v=null===(a=null===(s=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===s?void 0:s.prototype)||void 0===a?void 0:a.send,p=null===(l=null===(c=null===(u=this.globalScope)||void 0===u?void 0:u.XMLHttpRequest)||void 0===c?void 0:c.prototype)||void 0===l?void 0:l.setRequestHeader;f&&v&&p&&this.observeXhr(f,v,p);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach(function(n){var r;try{n.callback(e)}catch(e){null===(r=t.logger)||void 0===r||r.debug("an unexpected error occurred while triggering event callbacks",e)}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,s){var a;if(void 0!==o&&void 0!==s){var u,c,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?u=null===(a=null==t?void 0:t.toString)||void 0===a?void 0:a.call(t):(u=t.url,d=t.method),u)try{var f=new URL(u);u="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(c=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},c=0);var v=Math.floor(performance.now()-s),p=Math.floor(o+v),h=new _t(e,d,o,o,u,n,c,v,r,l,p);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return s(t,void 0,void 0,function(){var t,i,o,s,u,c;return a(this,function(a){switch(a.label){case 0:try{t=this.getTimestamps()}catch(e){null===(u=this.logger)||void 0===u||u.debug("an unexpected error occurred while retrieving timestamps",e)}a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=a.sent(),[3,4];case 3:return s=a.sent(),o=s,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new gt(r):void 0,i?new wt(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){null===(c=this.logger)||void 0===c||c.debug("an unexpected error occurred while handling fetch",e)}if(i)return[2,i];throw o}})})})},e.createXhrJsonParser=function(e,t){return function(){var n,r;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&(null===(r=t.logger)||void 0===r||r.error("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var o=this.globalScope.XMLHttpRequest.prototype,s=this;o.open=function(){for(var e,n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=c(r,2),u=a[0],l=a[1];try{this.$$AmplitudeAnalyticsEvent=i({method:u,url:null===(e=null==l?void 0:l.toString)||void 0===e?void 0:e.call(l),headers:{}},s.getTimestamps())}catch(e){null===(n=s.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr open",e)}return t.apply(this,r)},o.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,o=e.createXhrJsonParser(this,s),a=t[0],u=i.$$AmplitudeAnalyticsEvent;return i.addEventListener("loadend",function(){var e;try{var t=i.getAllResponseHeaders(),n=i.getResponseHeader("content-length"),r=new Et(i.status,t,n?parseInt(n,10):void 0,o),c=i.$$AmplitudeAnalyticsEvent.headers,l=new mt(a,c);u.status=i.status,s.handleNetworkRequestEvent("xhr",{url:u.url,method:u.method},l,r,void 0,u.startTime,u.durationStart)}catch(t){null===(e=s.logger)||void 0===e||e.error("an unexpected error occurred while handling xhr send",t)}}),n.apply(i,t)},o.setRequestHeader=function(e,t){var n;try{this.$$AmplitudeAnalyticsEvent.headers[e]=t}catch(e){null===(n=s.logger)||void 0===n||n.error("an unexpected error occurred while calling xhr setRequestHeader",e)}r.apply(this,[e,t])}}},e}(),Ot=new Pt,xt=function(){function e(){}return e.prototype.parse=function(){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,i(i(i(i({},P),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=Se();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=Se();return(e={})[g]=t[g],e[m]=t[m],e[y]=t[y],e[b]=t[b],e[w]=t[w],e[E]=t[E],e[S]=t[S],e[T]=t[T],e[k]=t[k],e[_]=t[_],e[I]=t[I],e},e}(),At="data-amp-mask",Ct="*****",Rt=/\b(?:\d[ -]*?){13,16}\b/,Dt=/(\d{3}-?\d{2}-?\d{4})/g,Lt=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Nt=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(Rt,Ct)).replace(Dt,Ct)).replace(Lt,Ct);try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,Ct)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},jt=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(At)?Ct:e?e(document.title):document.title};function Mt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ut(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function qt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ft(e,t,n){return t&&qt(e.prototype,t),n&&qt(e,n),e}var Bt=function(){return"function"==typeof Symbol},Ht=function(e){return Bt()&&Boolean(Symbol[e])},Vt=function(e){return Ht(e)?Symbol[e]:"@@"+e};Bt()&&!Ht("observable")&&(Symbol.observable=Symbol("observable"));var zt=Vt("iterator"),Jt=Vt("observable"),$t=Vt("species");function Wt(e,t){var n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function Kt(e){var t=e.constructor;return void 0!==t&&null===(t=t[$t])&&(t=void 0),void 0!==t?t:on}function Gt(e){return e instanceof on}function Yt(e){Yt.log?Yt.log(e):setTimeout(function(){throw e})}function Xt(e){Promise.resolve().then(function(){try{e()}catch(e){Yt(e)}})}function Qt(e){var t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{var n=Wt(t,"unsubscribe");n&&n.call(t)}}catch(e){Yt(e)}}function Zt(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function en(e,t,n){e._state="running";var r=e._observer;try{var i=Wt(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(Zt(e),!i)throw n;i.call(r,n);break;case"complete":Zt(e),i&&i.call(r)}}catch(e){Yt(e)}"closed"===e._state?Qt(e):"running"===e._state&&(e._state="ready")}function tn(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void Xt(function(){return function(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(en(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)})):void en(e,t,n);e._queue.push({type:t,value:n})}}var nn=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";var n=new rn(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}return e.prototype.unsubscribe=function(){"closed"!==this._state&&(Zt(this),Qt(this))},Ft(e,[{key:"closed",get:function(){return"closed"===this._state}}]),e}(),rn=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){tn(this._subscription,"next",e)},t.error=function(e){tn(this._subscription,"error",e)},t.complete=function(){tn(this._subscription,"complete")},Ft(e,[{key:"closed",get:function(){return"closed"===this._subscription._state}}]),e}(),on=function(){function e(t){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new nn(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if("function"==typeof e)var i=t.subscribe({next:function(t){try{e(t,o)}catch(e){r(e),i.unsubscribe()}},error:r,complete:n});else r(new TypeError(e+" is not a function"));function o(){i.unsubscribe(),n()}})},t.map=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Kt(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(Kt(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Kt(this),r=arguments.length>1,i=!1,o=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var s=!i;if(i=!0,!s||r)try{o=e(o,t)}catch(e){return n.error(e)}else o=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(o),n.complete()}})})},t.concat=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=Kt(this);return new i(function(t){var r,o=0;return function e(s){r=s.subscribe({next:function(e){t.next(e)},error:function(e){t.error(e)},complete:function(){o===n.length?(r=void 0,t.complete()):e(i.from(n[o++]))}})}(e),function(){r&&(r.unsubscribe(),r=void 0)}})},t.flatMap=function(e){var t=this;if("function"!=typeof e)throw new TypeError(e+" is not a function");var n=Kt(this);return new n(function(r){var i=[],o=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var o=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(o);e>=0&&i.splice(e,1),s()}});i.push(o)},error:function(e){r.error(e)},complete:function(){s()}});function s(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),o.unsubscribe()}})},t[Jt]=function(){return this},e.from=function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=Wt(t,Jt);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Gt(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(Ht("iterator")&&(r=Wt(t,zt)))return new n(function(e){Xt(function(){if(!e.closed){for(var n,i=Mt(r.call(t));!(n=i()).done;){var o=n.value;if(e.next(o),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){Xt(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw new TypeError(t+" is not observable")},e.of=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new("function"==typeof this?this:e)(function(e){Xt(function(){if(!e.closed){for(var t=0;t<n.length;++t)if(e.next(n[t]),e.closed)return;e.complete()}})})},Ft(e,null,[{key:$t,get:function(){return this}}]),e}();function sn(e,t){return new on(function(n){e.subscribe({next:function(e){t(e).then(function(e){return n.next(e)}).catch(function(e){return n.error(e)})},error:function(e){n.error(e)},complete:function(){n.complete()}})})}function an(e,t){return new on(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=u(i),o=n.next();!o.done;o=n.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return s(e),s(t),o})}function un(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new on(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.next)||void 0===i||i.call(a,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var s=u(t),a=s.next();!a.done;a=s.next()){var c=a.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=u(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.complete)||void 0===i||i.call(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}})}Bt()&&Object.defineProperty(on,Symbol("extensions"),{value:{symbol:Jt,hostReportError:Yt},configurable:!0});var cn=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},ln=function(e){return cn(e,"attribution")},dn=function(e){return cn(e,"formInteractions")},fn=function(e){return cn(e,"pageViews")},vn=function(e){return cn(e,"sessions")},pn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},hn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},gn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},mn=function(e){if(hn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},yn=function(e){if(gn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},bn=function(e){var t;if(pn(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),i(i({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map(function(t){var n,r,o;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var s=JSON.stringify(t.hosts),a=JSON.stringify(t.urls);return null===(o=e.loggerProvider)||void 0===o||o.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(s,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),i(i({},t),{hosts:void 0})}return t})})}},wn=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return fn(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},En=function(e,t){Sn(e,t)},Sn=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,s=r.resolve,a=e&&e[i];if("function"==typeof a){var u=a.apply(e,o);"function"==typeof s&&s(null==u?void 0:u.promise)}}return e},Tn=function(e){return e&&void 0!==e._q},kn="2.34.1-feat-zoning-alpha.0",_n="amplitude-ts",In=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(_n,"/").concat(kn),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t,n,r,o,s;return a(this,function(a){return t=(new Date).getTime(),n=null!==(o=this.config.lastEventId)&&void 0!==o?o:-1,r=null!==(s=e.event_id)&&void 0!==s?s:n+1,this.config.lastEventId=r,e.time||(this.config.lastEventTime=t),[2,i(i(i(i(i(i(i(i({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:t},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Ee()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:q(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:r,library:this.library,user_agent:this.userAgent})]})})},e}(),Pn=1e3,On=function(e){function n(t){var n,r,i,o=this;try{i=null===(n=M())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return t(n,e),n.prototype.set=function(t,n){return s(this,void 0,void 0,function(){var r,i;return a(this,function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>Pn?(r=n.length-Pn,[4,e.prototype.set.call(this,t,n.slice(0,Pn))]):[3,2];case 1:return o.sent(),null===(i=this.loggerProvider)||void 0===i||i.error("Failed to save ".concat(r," events because the queue length exceeded ").concat(Pn,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},n}(Re),xn=function(e){function n(){var t;return e.call(this,null===(t=M())||void 0===t?void 0:t.sessionStorage)||this}return t(n,e),n}(Re),An=function(e){function n(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n=this;return a(this,function(r){return[2,new Promise(function(r,o){var s,a;"undefined"==typeof XMLHttpRequest&&o(new Error("XHRTransport is not supported."));var l=new XMLHttpRequest;l.open("POST",e,!0),l.onreadystatechange=function(){if(l.readyState===n.state.done){var e=l.responseText;try{r(n.buildResponse(JSON.parse(e)))}catch(e){r(n.buildResponse({code:l.status}))}}};var d=i({"Content-Type":"application/json",Accept:"*/*"},n.customHeaders);try{for(var f=u(Object.entries(d)),v=f.next();!v.done;v=f.next()){var p=c(v.value,2),h=p[0],g=p[1];l.setRequestHeader(h,g)}}catch(e){s={error:e}}finally{try{v&&!v.done&&(a=f.return)&&a.call(f)}finally{if(s)throw s.error}}l.send(JSON.stringify(t))})]})})},n}($e),Cn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,function(){var n=this;return a(this,function(r){return[2,new Promise(function(r,i){var o=M();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);return r(o.navigator.sendBeacon(e,JSON.stringify(t))?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}})]})})},n}($e),Rn=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return s(void 0,l([e,t],c(n),!1),void 0,function(e,t,n){var r,i,o,s,u,l,d,v,p;return void 0===n&&(n=!0),a(this,function(a){switch(a.label){case 0:return r=function(e){return"".concat(f.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=a.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:a.sent(),a.label=3;case 3:return o=c(i.split("."),6),s=o[0],u=o[1],l=o[2],d=o[3],v=o[4],p=o[5],[2,{deviceId:s,userId:Ln(u),sessionId:Dn(d),lastEventId:Dn(p),lastEventTime:Dn(v),optOut:Boolean(l)}]}})})},Dn=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Ln=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Nn="[Amplitude]",jn="".concat(Nn," Form Started"),Mn="".concat(Nn," Form Submitted"),Un="".concat(Nn," File Downloaded"),qn="session_start",Fn="session_end",Bn="".concat(Nn," File Extension"),Hn="".concat(Nn," File Name"),Vn="".concat(Nn," Link ID"),zn="".concat(Nn," Link Text"),Jn="".concat(Nn," Link URL"),$n="".concat(Nn," Form ID"),Wn="".concat(Nn," Form Name"),Kn="".concat(Nn," Form Destination"),Gn="cookie",Yn=function(e){function n(t,n,r,i,o,s,a,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I,P,O,x,A,C,R,D,L,N,j,M,U,q,F){var B;void 0===r&&(r=new Pe),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===c&&(c=5),void 0===l&&(l=30),void 0===d&&(d=Gn),void 0===g&&(g=new W),void 0===m&&(m=J.Warn),void 0===b&&(b=!1),void 0===w&&(w=!1),void 0===T&&(T=""),void 0===k&&(k="US"),void 0===I&&(I=18e5),void 0===P&&(P=new On({loggerProvider:g})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===x&&(x="fetch"),void 0===A&&(A=!1),void 0===C&&(C=!0),void 0===M&&(M=!0),void 0===U&&(U=0);var H=e.call(this,{apiKey:t,storageProvider:P,transportProvider:Zn(x)})||this;H.apiKey=t,H.appVersion=n,H.cookieOptions=i,H.defaultTracking=o,H.autocapture=s,H.flushIntervalMillis=u,H.flushMaxRetries=c,H.flushQueueSize=l,H.identityStorage=d,H.ingestionMetadata=f,H.instanceName=v,H.loggerProvider=g,H.logLevel=m,H.minIdLength=y,H.offline=b,H.partnerId=E,H.plan=S,H.serverUrl=T,H.serverZone=k,H.sessionTimeout=I,H.storageProvider=P,H.trackingOptions=O,H.transport=x,H.useBatch=A,H.fetchRemoteConfig=C,H.networkTrackingOptions=N,H.identify=j,H.enableDiagnostics=M,H.diagnosticsSampleRate=U,H.diagnosticsClient=q,H.remoteConfig=F,H.version=kn,H._optOut=!1,H._cookieStorage=r,H.deviceId=a,H.lastEventId=p,H.lastEventTime=h,H.optOut=w,H.sessionId=_,H.pageCounter=D,H.userId=R,H.debugLogsEnabled=L,H.loggerProvider.enable(L?J.Debug:H.logLevel),H.networkTrackingOptions=N,H.identify=j,H.enableDiagnostics=M,H.diagnosticsSampleRate=U,H.diagnosticsClient=q;var V=null!==(B=null==F?void 0:F.fetchRemoteConfig)&&void 0!==B?B:C;return H.remoteConfig=H.remoteConfig||{},H.remoteConfig.fetchRemoteConfig=V,H.fetchRemoteConfig=V,H}return t(n,e),Object.defineProperty(n.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),n.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof Oe&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(we(this.apiKey),e)},n}(G),Xn=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return s(void 0,l([e],c(t),!1),void 0,function(e,t,n,r,o){var s,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I,P,O,x,A,C,R,D,L,N,j,M,U,F,B,H,V,z,J,$,W,K,G,Y,X,Q,Z,ee,te,ne,re;return void 0===t&&(t={}),a(this,function(a){switch(a.label){case 0:return s=t.identityStorage||Gn,O={},s===Gn?[3,1]:(c="",[3,5]);case 1:return null===(A=null===(x=t.cookieOptions)||void 0===x?void 0:x.domain)||void 0===A?[3,2]:(l=A,[3,4]);case 2:return[4,er()];case 3:l=a.sent(),a.label=4;case 4:c=l,a.label=5;case 5:return u=i.apply(void 0,[(O.domain=c,O.expiration=365,O.sameSite="Lax",O.secure=!1,O.upgrade=!0,O),t.cookieOptions]),d={duplicateResolverFn:function(e){var t=xe(e);if(!t)return!1;var n=JSON.parse(t);return Ae(n.cookieDomain,u.domain)},diagnosticsClient:r},f=Qn(t.identityStorage,u,d),[4,Rn(e,f,null===(R=null===(C=t.cookieOptions)||void 0===C?void 0:C.upgrade)||void 0===R||R)];case 6:return v=a.sent(),[4,f.get(we(e))];case 7:return p=a.sent(),h=Se(),g=h.ampTimestamp?Number(h.ampTimestamp):void 0,m=!g||Date.now()<g,y=null!==(M=null!==(j=null!==(N=null!==(D=t.deviceId)&&void 0!==D?D:m?null!==(L=h.ampDeviceId)&&void 0!==L?L:h.deviceId:void 0)&&void 0!==N?N:null==p?void 0:p.deviceId)&&void 0!==j?j:v.deviceId)&&void 0!==M?M:q(),b=null!==(U=null==p?void 0:p.lastEventId)&&void 0!==U?U:v.lastEventId,w=null!==(F=null==p?void 0:p.lastEventTime)&&void 0!==F?F:v.lastEventTime,E=null!==(H=null!==(B=t.optOut)&&void 0!==B?B:null==p?void 0:p.optOut)&&void 0!==H?H:v.optOut,S=null!==(V=null==p?void 0:p.sessionId)&&void 0!==V?V:v.sessionId,T=null!==(J=null!==(z=t.userId)&&void 0!==z?z:null==p?void 0:p.userId)&&void 0!==J?J:v.userId,n.previousSessionDeviceId=null!==($=null==p?void 0:p.deviceId)&&void 0!==$?$:v.deviceId,n.previousSessionUserId=null!==(W=null==p?void 0:p.userId)&&void 0!==W?W:v.userId,k={ipAddress:null===(G=null===(K=t.trackingOptions)||void 0===K?void 0:K.ipAddress)||void 0===G||G,language:null===(X=null===(Y=t.trackingOptions)||void 0===Y?void 0:Y.language)||void 0===X||X,platform:null===(Z=null===(Q=t.trackingOptions)||void 0===Q?void 0:Q.platform)||void 0===Z||Z},_=null==p?void 0:p.pageCounter,I=null==p?void 0:p.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(P=new Yn(e,t.appVersion,f,u,t.defaultTracking,t.autocapture,y,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,s,t.ingestionMetadata,t.instanceName,b,w,null!==(ee=null==o?void 0:o.loggerProvider)&&void 0!==ee?ee:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,E,t.partnerId,t.plan,t.serverUrl,null!==(te=null==o?void 0:o.serverZone)&&void 0!==te?te:t.serverZone,S,t.sessionTimeout,t.storageProvider,k,t.transport,t.useBatch,t.fetchRemoteConfig,T,_,I,t.networkTrackingOptions,t.identify,null!==(ne=null==o?void 0:o.enableDiagnostics)&&void 0!==ne?ne:t.enableDiagnostics,null!==(re=null==o?void 0:o.diagnosticsSampleRate)&&void 0!==re?re:n._diagnosticsSampleRate,r,t.remoteConfig)).storageProvider.isEnabled()];case 8:return a.sent()||(P.loggerProvider.warn("Storage provider ".concat(P.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),P.storageProvider=new Pe),[2,P]}})})},Qn=function(e,t,n){switch(void 0===e&&(e=Gn),void 0===t&&(t={}),e){case"localStorage":return new On;case"sessionStorage":return new xn;case"none":return new Pe;default:return new Oe(i(i({},t),{expirationDays:t.expiration}),n)}},Zn=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0;return"xhr"===t?new An(n):"beacon"===t?new Cn:new We(n)},er=function(e){return s(void 0,void 0,void 0,function(){var t,n,r,i,o,s,u,c;return a(this,function(a){switch(a.label){case 0:return[4,(new Oe).isEnabled()];case 1:if(!a.sent()||!e&&("undefined"==typeof location||!location.hostname))return[2,""];for(t=null!=e?e:location.hostname,n=t.split("."),r=[],i=q(),o="AMP_TLDTEST_".concat(i.substring(0,8)),s=n.length-2;s>=0;--s)r.push(n.slice(s).join("."));s=0,a.label=2;case 2:return s<r.length?(u=r[s],[4,(c=new Oe({domain:"."+u,expirationDays:.003})).set(o,1)]):[3,7];case 3:return a.sent(),[4,c.get(o)];case 4:return a.sent()?[4,c.remove(o)]:[3,6];case 5:return a.sent(),[2,"."+u];case 6:return s++,[3,2];case 7:return[2,""]}})})},tr=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},nr="AMP_PAGE_VIEW",rr=function(e){var t;void 0===e&&(e={});var n,r,o=M(),u=void 0,l=!1,d=e.trackOn,f=e.trackHistoryChanges,v=e.eventType,p=void 0===v?"[Amplitude] Page Viewed":v,h=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==u||u.error("Malformed URI sequence: ",e)}return t},g=function(e){return s(void 0,void 0,void 0,function(){var t,n,r;return a(this,function(o){switch(o.label){case 0:return t=h("undefined"!=typeof location&&location.href||""),r={event_type:p},n=[{}],[4,ir()];case 1:return[2,(r.event_properties=i.apply(void 0,[i.apply(void 0,n.concat([o.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":t,"[Amplitude] Page Path":"undefined"!=typeof location&&h(location.pathname)||"","[Amplitude] Page Title":jt(Nt),"[Amplitude] Page URL":t.split("?")[0],"[Amplitude] Page View ID":e}]),r)]}})})},m=function(){return void 0===d||"function"==typeof d&&d()},y="undefined"!=typeof location?location.href:null,b=function(){s(void 0,void 0,void 0,function(){var e,n,i,o,s;return a(this,function(a){switch(a.label){case 0:return e=location.href,n=sr(f,e,y||"")&&m(),y=e,n?(i=void 0,r&&(i=q(),r.set(nr,{pageViewId:i})),null==u||u.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return s=(o=t).track,[4,g(i)];case 2:s.apply(o,[a.sent()]),a.label=3;case 3:a.label=4;case 4:return[2]}})})},w={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,i){return s(void 0,void 0,void 0,function(){var s,d,f;return a(this,function(a){switch(a.label){case 0:return t=i,n=e,(u=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),l=!0,o&&(r=new Re(o.sessionStorage),o.addEventListener("popstate",b),o.history.pushState=new Proxy(o.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),l&&b()}})),m()?(u.log("Tracking page view event"),s=void 0,r&&(s=q(),r.set(nr,{pageViewId:s})),f=(d=t).track,[4,g(s)]):[3,2];case 1:f.apply(d,[a.sent()]),a.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,o,s;return a(this,function(a){switch(a.label){case 0:return"attribution"===d&&or(e)?(null==u||u.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,r?[4,r.get(nr)]:[3,2]):[3,4];case 1:o=a.sent(),t=null==o?void 0:o.pageViewId,a.label=2;case 2:return[4,g(t)];case 3:s=a.sent(),e.event_type=s.event_type,e.event_properties=i(i({},e.event_properties),s.event_properties),a.label=4;case 4:return n&&e.event_type===p&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=i(i({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){return o&&(o.removeEventListener("popstate",b),l=!1),[2]})})}};return w},ir=function(){return s(void 0,void 0,void 0,function(){var e;return a(this,function(t){switch(t.label){case 0:return e=tr,[4,(new xt).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},or=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,r=t[n.SET]||{},i=t[n.UNSET]||{},o=l(l([],c(Object.keys(r)),!1),c(Object.keys(i)),!1);return Object.keys(P).every(function(e){return o.includes(e)})}return!1},sr=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},ar=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return s(void 0,void 0,void 0,function(){var o,s;return a(this,function(a){return t=function(e){if(dn(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions}(n),o=function(){if(i){if("undefined"!=typeof document){var o=function(e){var o=!1;r(e,"change",function(){var t,n=cr(e);o||i.track(jn,((t={})[$n]=ur(e.id),t[Wn]=ur(e.name),t[Kn]=n,t)),o=!0}),r(e,"submit",function(r){var s,a,u=cr(e);if(o||i.track(jn,((s={})[$n]=ur(e.id),s[Wn]=ur(e.name),s[Kn]=u,s)),o=!0,void 0!==(null==t?void 0:t.shouldTrackSubmit))if("function"==typeof t.shouldTrackSubmit&&"undefined"!=typeof SubmitEvent&&r instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(r))return}catch(e){n.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else n.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(Mn,((a={})[$n]=ur(e.id),a[Wn]=ur(e.name),a[Kn]=u,a)),o=!1})};Array.from(document.getElementsByTagName("form")).forEach(o),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"FORM"===e.nodeName&&o(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(o)})})})).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?o():(s=M())?s.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(t){return null==e||e.disconnect(),n.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),n=[],[2]})})}}},ur=function(e){if("string"==typeof e)return e},cr=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},lr=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return s(void 0,void 0,void 0,function(){var i,o;return a(this,function(s){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),s=null==i?void 0:i[1];s&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",function(){var t;s&&r.track(Un,((t={})[Bn]=s,t[Hn]=n.pathname,t[Vn]=e.id,t[zn]=e.text,t[Jn]=e.href,t))})},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)})})})).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=M())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(n){return null==e||e.disconnect(),t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),t=[],[2]})})}}},dr=!1,fr=function(){var e=M(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return s(void 0,void 0,void 0,function(){return a(this,function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis)}),n("offline",function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0}),[2])})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(n){return t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[],[2]})})}}};function vr(e){var t,n,r,i,o,s,a,d,f,v,p;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var h=Object.keys(e);try{for(var g=u(h),m=g.next();!m.done;m=g.next()){var y=m.value;try{var b=e[y];"boolean"==typeof(null==b?void 0:b.enabled)&&(b.enabled?(delete b.enabled,0===Object.keys(b).length&&(e[y]=!0)):e[y]=!1),vr(b)}catch(e){}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}try{if(null===(f=null===(d=null===(a=e.autocapture)||void 0===a?void 0:a.networkTracking)||void 0===d?void 0:d.captureRules)||void 0===f?void 0:f.length)try{for(var w=u(e.autocapture.networkTracking.captureRules),E=w.next();!E.done;E=w.next()){var S=E.value;try{for(var T=(o=void 0,u(["responseHeaders","requestHeaders"])),k=T.next();!k.done;k=T.next()){var _=k.value,I=null!==(v=S[_])&&void 0!==v?v:{},P=I.captureSafeHeaders,x=I.allowlist;(P||x)&&(void 0===x||Array.isArray(x)?S[_]=l(l([],c(P?O:[]),!1),c(null!=x?x:[]),!1):delete S[_])}}catch(e){o={error:e}}finally{try{k&&!k.done&&(s=T.return)&&s.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{E&&!E.done&&(i=w.return)&&i.call(w)}finally{if(r)throw r.error}}}catch(e){}var A=null===(p=e.autocapture)||void 0===p?void 0:p.frustrationInteractions;A&&(A.rageClick&&(A.rageClicks=A.rageClick,delete A.rageClick),A.deadClick&&(A.deadClicks=A.deadClick,delete A.deadClick))}}function pr(e,t,n){var r,i,o=[];try{for(var s=u(null!=t?t:[]),a=s.next();!a.done;a=s.next()){var c=a.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return e.concat(o)}function hr(e,t){var n,r,o,s,a,c,l;if(e){vr(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var d=e;if(d&&"autocapture"in d){if("boolean"==typeof d.autocapture&&(t.autocapture=d.autocapture),"object"==typeof d.autocapture&&null!==d.autocapture){var f=i({},d.autocapture);if(void 0===t.autocapture&&(t.autocapture=d.autocapture),"object"==typeof d.autocapture.elementInteractions&&null!==d.autocapture.elementInteractions&&(null===(o=d.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===o?void 0:o.length)){f.elementInteractions=i({},d.autocapture.elementInteractions);var v=f.elementInteractions,p=null!==(s=v.pageUrlAllowlist)&&void 0!==s?s:[],h=d.autocapture.elementInteractions.pageUrlAllowlistRegex;v.pageUrlAllowlist=pr(p,h,t),delete v.pageUrlAllowlistRegex}if("object"==typeof d.autocapture.networkTracking&&null!==d.autocapture.networkTracking&&(null===(a=d.autocapture.networkTracking.captureRules)||void 0===a?void 0:a.length)){f.networkTracking=i({},d.autocapture.networkTracking);var g=null!==(c=f.networkTracking.captureRules)&&void 0!==c?c:[];try{for(var m=u(g),y=m.next();!y.done;y=m.next()){var b=y.value;b.urls=pr(null!==(l=b.urls)&&void 0!==l?l:[],b.urlsRegex,t),delete b.urlsRegex}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=i({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},f)),"object"==typeof t.autocapture&&(t.autocapture=i(i({},t.autocapture),f))}t.defaultTracking=t.autocapture}t.loggerProvider.debug("Browser config after remote config update:",JSON.stringify(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var gr="1.20.0-feat-zoning-alpha.0",mr="[Amplitude] Element Clicked",yr="[Amplitude] Element Tag",br="[Amplitude] Element Text",wr="[Amplitude] Page URL",Er="[Amplitude] Viewport Height",Sr="[Amplitude] Viewport Width",Tr="[Amplitude] Page View ID",kr="https://app.amplitude.com",_r={US:kr,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},Ir="data-amp-mask-attributes",Pr=["input","select","textarea"],Or=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},xr=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,s,a=e.pageUrlAllowlist,u=e.pageUrlExcludelist,c=e.shouldTrackEventResolver,l=null===(s=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===s?void 0:s.call(o);if(!l)return!1;if(c)return c(r,i);if(!ke(window.location.href,a))return!1;if(u&&u.length>0&&ke(window.location.href,u))return!1;var d=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof d)switch(d.toLowerCase()){case"hidden":case"password":return!1}var f=Or(i,r);if(n&&f)return!0;if(t){var v=t.some(function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))});if(!v)return!1}switch(l){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!f||"click"===r}}},Ar=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},Cr=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t},{})},Rr=function(){var e;try{var t=M(),n=null===(e=null==t?void 0:t.sessionStorage)||void 0===e?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},Dr=function(e,t){return e?t.some(function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)})?e:Dr(null==e?void 0:e.parentElement,t):null},Lr=function(e){return new Promise(function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",function(){t({status:!0})},{once:!0}),i.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(e)})}),null===(r=document.head)||void 0===r||r.appendChild(i)}catch(e){n(e)}})};var Nr,jr=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Nr||(Nr={}));var Mr=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Ir,At]),Ur=["type"],qr=["svg","path","g"],Fr=["password","hidden"];function Br(e,t){var n,r,i,o,s,a;if(null===e)return null;var c=String(e.tagName).toLowerCase(),l={tag:c},d=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);d.length&&(l.index=d.indexOf(e),l.indexOfType=d.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var f=null===(a=null===(s=e.previousElementSibling)||void 0===s?void 0:s.tagName)||void 0===a?void 0:a.toLowerCase();f&&(l.prevSib=String(f));var v=e.getAttribute("id");v&&(l.id=String(v));var p=Array.from(e.classList);p.length&&(l.classes=p);var h={},g=Array.from(e.attributes).filter(function(e){return!Mr.has(e.name)}),m=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!Pr.includes(i)&&!o}(e);if(!Fr.includes(String(e.getAttribute("type")))&&!qr.includes(c))try{for(var y=u(g),b=y.next();!b.done;b=y.next()){var w=b.value;m&&!Ur.includes(w.name)||(t.has(w.name)?h[w.name]=Ct:h[w.name]=String(w.value).substring(0,128))}}catch(e){n={error:e}}finally{try{b&&!b.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}return Object.keys(h).length&&(l.attrs=h),l}var Hr=function(e,t,n){e.forEach(function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}})},Vr=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),zr=function(e,t,n){var r,i;if(e.nodeType!==Node.ELEMENT_NODE)return null;var o=e.getAttribute("id");if(t){if(o)return new Vr(d(o),!0);var s=e.tagName.toLowerCase();if("body"===s||"head"===s||"html"===s)return new Vr(s,!0)}var a=e.tagName.toLowerCase();if(o)return new Vr(a+d(o),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new Vr(a,!0);function l(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]}function d(e){return"#"+CSS.escape(e)}for(var f=l(e),v=!1,p=!1,h=-1,g=-1,m=c.children,y=0;m&&(-1===h||!p)&&y<m.length;++y){var b=m[y];if(b.nodeType===Node.ELEMENT_NODE)if(g+=1,b!==e){if(!p&&b.tagName.toLowerCase()===a){v=!0;var w=new Set(f);if(w.size)for(var E=l(b),S=0;S<E.length;++S){var T=E[S];if(w.has(T)&&(w.delete(T),!w.size)){p=!0;break}}else p=!0}}else h=g}var k=a;if(n&&"input"===a.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(k+="[type="+CSS.escape(e.getAttribute("type")||"")+"]"),p)k+=":nth-child("+String(h+1)+")";else if(v)try{for(var _=u(f),I=_.next();!I.done;I=_.next()){var P=I.value;k+="."+CSS.escape(P.slice(1))}}catch(e){r={error:e}}finally{try{I&&!I.done&&(i=_.return)&&i.call(_)}finally{if(r)throw r.error}}return new Vr(k,!1)},Jr=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Nt(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,s,a=performance.now();if(!e)return[];for(var d=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),f=new Map,v=d.length-1;v>=0;v--){var p=d[v];if(p){var h=Ar(p.getAttribute(Ir)),g=v===d.length-1?[]:null!==(r=f.get(d[v+1]))&&void 0!==r?r:new Set,m=new Set(l(l([],c(g),!1),c(h),!1));f.set(p,m)}}s=d.map(function(e){var t;return Br(e,null!==(t=f.get(e))&&void 0!==t?t:new Set)});var y=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=c(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))})};try{for(var b=u(s),w=b.next();!w.done;w=b.next())y(w.value)}catch(e){t={error:e}}finally{try{w&&!w.done&&(n=b.return)&&n.call(b)}finally{if(t)throw t.error}}var E=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",E-a),s},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=zr(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e),i=performance.now();return null===(t=o.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.getEventProperties=function(e,t,n){var r,i,s,a,u,l,d=null===(s=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===s?void 0:s.call(i),f="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},v=o.getHierarchy(t),p=null===(a=v[0])||void 0===a?void 0:a.attrs,h=o.getNearestLabel(t),g=(u=null!=p?p:{},l=n,Object.entries(u).reduce(function(e,t){var n=c(t,2),r=n[0],i=n[1];if(r.startsWith(l)){var o=r.replace(l,"");o&&(e[o]=i||"")}return e},{})),m=((r={})["[Amplitude] Element Hierarchy"]=v,r[yr]=d,r[br]=o.getText(t),r["[Amplitude] Element Position Left"]=null==f.left?null:Math.round(f.left),r["[Amplitude] Element Position Top"]=null==f.top?null:Math.round(f.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Path"]=o.getElementPath(t),r["[Amplitude] Element Parent Label"]=h,r[wr]=_e(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=jt(o.replaceSensitiveString),r[Er]=window.innerHeight,r[Sr]=window.innerWidth,r),y=Rr();if(y&&(m[Tr]=y),m["[Amplitude] Element ID"]=t.getAttribute("id")||"",m["[Amplitude] Element Class"]=t.getAttribute("class"),m["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===d&&"click"===e&&t instanceof HTMLAnchorElement){var b=t.href.substring(0,128);m["[Amplitude] Element Href"]=o.replaceSensitiveString(b)}return Cr(m)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var s=o.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(s)&&null!==s.event.target){if(i&&Or(s.event.target,s.type))return s.closestTrackedAncestor=s.event.target,s.targetElementProperties=o.getEventProperties(s.type,s.closestTrackedAncestor,r),s;var a=Dr(s.event.target,n);return a&&(s.closestTrackedAncestor=a,s.targetElementProperties=o.getEventProperties(s.type,a,r)),s}return s},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getText=function(e){if(null!==e.closest("[".concat(At,"]")))return Ct;var t="";if(e.querySelector("[".concat(At,"], [contenteditable]"))){var n=e.cloneNode(!0);n.querySelectorAll("[".concat(At,"], [contenteditable]")).forEach(function(e){e.innerText=Ct}),t=n.innerText||""}else t=e.innerText||"";return o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),s=((t={})[yr]=i,t[br]=o.getText(e),t[wr]=window.location.href.split("?")[0],t);return Cr(s)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var s=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],a=[];try{for(var d=u(s),f=d.next();!f.done;f=d.next()){var v=f.value;if(a.length>=25)break;if(v instanceof RegExp)a.push(v);else if("pattern"in v&&"string"==typeof v.pattern)try{a.push(new RegExp(v.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=a},$r=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?kr:t,r=this;this.endpoint=kr,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.onBackgroundCapture=function(e,t){var n,i;"background-capture-complete"===e&&(null===(i=null===(n=r.logger)||void 0===n?void 0:n.debug)||void 0===i||i.call(n,"Background capture complete"),r.notify({action:"background-capture-complete",data:t}))},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise(function(t,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),(null==n?void 0:n.timeout)>0&&setTimeout(function(){s(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{dataExtractor:new Jr({})}:e,o=i.logger,s=i.endpoint,a=i.isElementSelectable,u=i.cssSelectorAllowlist,c=i.actionClickAllowlist,l=i.dataExtractor;this.logger=o,s&&this.endpoint===kr&&(this.endpoint=s);var d=null,f=null;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),window.addEventListener("message",function(e){var t,n,i,o,s,v,p,h;if(null===(n=null===(t=r.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var g=null==e?void 0:e.data,m=null==g?void 0:g.action;if(m)if("id"in g)null===(o=null===(i=r.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(g);else if("ping"===m)r.notify({action:"pong"});else if("initialize-visual-tagging-selector"===m){var y=null==g?void 0:g.data;Lr("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var e;d=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:l.getEventTagProps,isElementSelectable:function(e){return!a||a((null==y?void 0:y.actionType)||"click",e)},onTrack:r.onTrack,onSelect:r.onSelect,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:r,cssSelectorAllowlist:u,actionClickAllowlist:c,extractDataFromDataSource:l.extractDataFromDataSource,dataExtractor:l,diagnostics:{autocapture:{version:gr}}}),r.notify({action:"selector-loaded"})}).catch(function(){var e;null===(e=r.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")})}else"initialize-background-capture"===m?(null===(v=null===(s=r.logger)||void 0===s?void 0:s.debug)||void 0===v||v.call(s,"Initializing background capture (external script)"),Lr(new URL("https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.1.js.gz",r.endpoint).toString()).then(function(){var e,t,n;null===(t=null===(e=r.logger)||void 0===e?void 0:e.debug)||void 0===t||t.call(e,"Background capture script loaded (external)"),f=null===(n=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===n?void 0:n.call(window,{messenger:r,onBackgroundCapture:r.onBackgroundCapture}),r.notify({action:"background-capture-loaded"})}).catch(function(){var e;null===(e=r.logger)||void 0===e||e.warn("Failed to initialize background capture")})):"close-visual-tagging-selector"===m?null===(p=null==d?void 0:d.close)||void 0===p||p.call(d):"close-background-capture"===m&&(null===(h=null==f?void 0:f.close)||void 0===h||h.call(f))}}),this.notify({action:"page-loaded"})},e}();var Wr,Kr=M(),Gr=function(){return new on(function(e){var t=new MutationObserver(function(t){e.next(t)});return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}})},Yr=function(e){return void 0===e&&(e="click"),new on(function(t){var n,r=function(e){t.next(e)};return null===(n=M())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=M())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}})},Xr=function(){var e=an(new on(function(e){var t=function(t){var n={kind:"error"};t.error instanceof Error?n=i(i({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(n.message=t.error),e.next(n)};return Kr.addEventListener("error",t),function(){Kr.removeEventListener("error",t)}}),new on(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return Kr.addEventListener("unhandledrejection",t),function(){Kr.removeEventListener("unhandledrejection",t)}}));return an(e,new on(function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return nt.addListener("error",t),function(){nt.removeListener(t)}}))},Qr={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Zr=function(e){var t,n,r,i,o=Object.values(Qr).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var s=u(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{try{for(var l=(r=void 0,u(c.definition)),d=l.next();!d.done;d=l.next()){var f=d.value,v=Qr[f.event_type];v&&o[v].add(c.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},ei=function(e){var t,n,r,i,o=new Map;try{for(var s=u(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{for(var l=(r=void 0,u(c.conditions)),d=l.next();!d.done;d=l.next()){var f=d.value;if("LABELED_EVENT"===f.type){var v=f.match.eventId,p=o.get(v);p||(p=[],o.set(v,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},ti=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return Qr[t.event_type]===e.type&&t.filters.every(function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)})})})},ni=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=function(e,t){var n,r,i,o,s=new Set;try{for(var a=u(e),c=a.next();!c.done;c=a.next()){var l=c.value,d=t.get(l.id);if(d)try{for(var f=(i=void 0,u(d)),v=f.next();!v.done;v=f.next()){var p=v.value;s.add(p)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return Array.from(s)}(ti(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=s.value;Hr(a.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}();!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable"}(Wr||(Wr={}));var ri=function(e,t){var n,r,o,d,f,v,p,h,g;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",gr);var m=e.dataAttributePrefix,y=void 0===m?it:m,b=e.visualTaggingOptions,w=void 0===b?{enabled:!0,messenger:new $r}:b,E=e.backgroundCaptureOptions,S=void 0===E?{enabled:!0,messenger:new $r}:E;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:rt,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:ot,e.debounceTime=null!==(o=e.debounceTime)&&void 0!==o?o:0,e.exposureDuration=null!==(d=e.exposureDuration)&&void 0!==d?d:150,e.pageUrlExcludelist=null===(f=e.pageUrlExcludelist)||void 0===f?void 0:f.reduce(function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e},[]);var T,k="@amplitude/plugin-autocapture-browser",_=[],I=new Jr(e,t),P=new Set,O=new Set,x=function(){var t,n,r=un(Yr().map(function(t){return I.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,y)})),i=un(new on(function(t){var n,r=function(n){var r=I.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,y);t.next(r)};return null===(n=M())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=M())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=un(new on(function(t){var n=function(n){var r=I.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,y);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=un(Gr().map(function(t){return I.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,y)})),s=new on(function(e){var t,n=function(t){e.next(t)};return null===(t=M())||void 0===t||t.window.addEventListener("scroll",n),function(){var e;null===(e=M())||void 0===e||e.window.removeEventListener("scroll",n)}}),a=function(e,t){return new on(function(n){var r,i=M();if(!(null==i?void 0:i.IntersectionObserver))return console.log("IntersectionObserver not supported"),function(){};var o=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:"0px",threshold:1}),s=t.join(",");return(null!==(r=null==i?void 0:i.document.querySelectorAll(s))&&void 0!==r?r:[]).forEach(function(e){o.observe(e)}),e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){return e instanceof Element&&o.observe(e)})})}),function(){o.disconnect()}})}(o,e.cssSelectorAllowlist);return(t={})[Wr.ChangeObservable]=i,t[Wr.ClickObservable]=r,t[Wr.MutationObservable]=o,t[Wr.NavigateObservable]=n,t[Wr.ScrollObservable]=s,t[Wr.ExposureObservable]=a,t},A=Zr(Object.values(null!==(p=null===(v=e.pageActions)||void 0===v?void 0:v.labeledEvents)&&void 0!==p?p:{})),C=ei(null!==(g=null===(h=e.pageActions)||void 0===h?void 0:h.triggers)&&void 0!==g?g:[]),R=function(e,t,n,r){return new ni(e,t,n,r)}(A,C,I,e);return{name:k,type:"enrichment",setup:function(t,n){return s(void 0,void 0,void 0,function(){var r,o,s,u,d,f,v,p,h,g,m,b,E,D,L,N,j,U,q,F,B,H;return a(this,function(a){return"undefined"==typeof document||(r=!1,o={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(t){!function(t){var n,r;t&&(e.pageActions=i(i({},e.pageActions),t),A=Zr(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),C=ei(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),R.update(A,C,e))}(t)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),s=xr(e,e.cssSelectorAllowlist),u=xr(e,e.actionClickAllowlist),d=x(),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(jr).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(mr,e.targetElementProperties)})}({allObservables:d,amplitude:n,shouldTrackEvent:s,evaluateTriggers:R.evaluate.bind(R)}),_.push(f),v=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(jr).filter(function(e){return i("change",e.closestTrackedAncestor)}).map(function(e){return o(e)}).subscribe(function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))})}({allObservables:d,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return I.getEventProperties.apply(I,l(l([],c(e),!1),[y],!1))},amplitude:n,shouldTrackEvent:s,evaluateTriggers:R.evaluate.bind(R)}),_.push(v),p=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,s=e.shouldTrackActionClick,a=n.clickObservable,u=n.mutationObservable,c=n.navigateObservable,l=a.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=Dr(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(jr).filter(function(e){return s("click",e.closestTrackedAncestor)}),d=c?an(u,c):u,f=an(l,d),v=null,p=null;return sn(f,function(e){if(v&&(clearTimeout(v),v=null),"click"===e.type)return p=e,v=setTimeout(function(){v=null,p=null},500),Promise.resolve(null);if(p){var t=p;return p=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==t||t.track(mr,i("click",e.closestTrackedAncestor)))})}({allObservables:d,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return I.getEventProperties.apply(I,l(l([],c(e),!1),[y],!1))},amplitude:n,shouldTrackEvent:s,shouldTrackActionClick:u}),p&&_.push(p),h=function(e){e.amplitude;var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe(function(){var e,t,r,i,o=M(),s=Math.floor(null!==(t=null!==(e=null==o?void 0:o.scrollX)&&void 0!==e?e:null==o?void 0:o.pageXOffset)&&void 0!==t?t:0),a=Math.floor(null!==(i=null!==(r=null==o?void 0:o.scrollY)&&void 0!==r?r:null==o?void 0:o.pageYOffset)&&void 0!==i?i:0);n.maxX=Math.max(n.maxX,s),n.maxY=Math.max(n.maxY,a)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:d,amplitude:n}),_.push(h),g={},m=M(),b=function(e){e&&r||(setTimeout(function(){r=!1},100),r=!0,function(e){var t,n,r,i,o=e.amplitude,s=e.scrollTracker,a=e.currentElementExposed,u=e.elementExposedForPage,c=e.exposureTracker,l=e.isPageEnd,d=e.lastScroll,f=s.getState(),v=M(),p=null!==(n=null==v?void 0:v.innerWidth)&&void 0!==n?n:0,h=null!==(r=null==v?void 0:v.innerHeight)&&void 0!==r?r:0,g=((t={})[wr]=null===(i=null==v?void 0:v.location)||void 0===i?void 0:i.href,t["[Amplitude] Max Page X"]=f.maxX+p,t["[Amplitude] Max Page Y"]=f.maxY+h,t[Er]=h,t[Sr]=p,t["[Amplitude] Element Exposed"]=Array.from(a),t),m=Rr();m&&(g[Tr]=m),0===a.size&&f.maxX===d.maxX&&f.maxY===d.maxY||(null==o||o.track("[Amplitude] Viewport Content Updated",g),d={maxX:f.maxX,maxY:f.maxY},a.clear(),l&&(s.reset(),u.clear(),null==c||c.reset()))}({amplitude:n,scrollTracker:h,currentElementExposed:O,elementExposedForPage:P,exposureTracker:g.exposure,isPageEnd:e,lastScroll:o}))},E=function(e){!function(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}(e,P,O,b)},g.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,s=new Map,a=new Map,u=t.exposureObservable.subscribe(function(e){var t=e,i=t.target;if(t.isIntersecting){if(!s.get(i)){var u=setTimeout(function(){s.set(i,!0);var e=r.getElementPath(i);n(e),a.set(i,null)},o);a.set(i,u)}}else!t.isIntersecting&&t.intersectionRatio<1&&(u=a.get(i))&&(clearTimeout(u),a.set(i,null))});return{unsubscribe:function(){u.unsubscribe()},reset:function(){a.forEach(function(e){e&&clearTimeout(e)}),a.clear(),s.clear()}}}({allObservables:d,onExposure:E,dataExtractor:I,exposureDuration:e.exposureDuration}),g.exposure&&_.push(g.exposure),D=function(){console.log("amp: beforeUnload"),b(!0)},null==m||m.addEventListener("beforeunload",D),T=function(){null==m||m.removeEventListener("beforeunload",D)},_.push({unsubscribe:function(){return T()}}),(L=d[Wr.NavigateObservable])?_.push(L.subscribe(function(){console.log("amp: navigate"),b(!0)})):m&&(N=function(){console.log("amp: popstate"),b(!0)},m.addEventListener("popstate",N),j=m.history.pushState,m.history&&j&&(m.history.pushState=new Proxy(j,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];console.log("amp: pushState"),e.apply(t,[i,o,s]),b(!0)}})),_.push({unsubscribe:function(){m.removeEventListener("popstate",N),m.history&&j&&(m.history.pushState=j)}})),null===(F=null==t?void 0:t.loggerProvider)||void 0===F||F.log("".concat(k," has been successfully added.")),window.opener&&w.enabled&&(U=e.cssSelectorAllowlist,q=e.actionClickAllowlist,null===(B=w.messenger)||void 0===B||B.setup(i(i({dataExtractor:I,logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:_r[t.serverZone]}),{isElementSelectable:xr(e,l(l([],c(U),!1),c(q),!1)),cssSelectorAllowlist:U,actionClickAllowlist:q}))),window.opener&&S.enabled&&!w.messenger&&(null===(H=S.messenger)||void 0===H||H.setup({dataExtractor:I,logger:null==t?void 0:t.loggerProvider}))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,r;return a(this,function(i){try{for(e=u(_),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]})})}}},ii=["mutation","navigate"];function oi(e,t){var n,r,i,o,s=t.event,a=s.pageX,u=s.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:u,u),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:u,u),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:a,a),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function si(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:i({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map(function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}}),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function ai(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,u=r.selectionObservable,c=[],l={},d=null;function f(e){c=[],l={},e&&(oi(l,e),c.push(e))}var v=sn(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return s(t,void 0,void 0,function(){var t;return a(this,function(n){return oi(l,e),t=null,0===c.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(c,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(c,e)||l.isOutOfBounds?(d&&(t=si(c)),f(e)):c.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),c.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(si(c))},1e3)}})]:[2,null]})})}),p=null==u?void 0:u.subscribe(function(){f()}),h=v.subscribe(function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){h.unsubscribe(),null==p||p.unsubscribe()}}}function ui(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var ci,li,di=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],o=!1!==e.errorClicks;e.errorClicks||(o=!1);var d=!1!==e.deadClicks&&null!==e.deadClicks,f=!1!==e.rageClicks&&null!==e.rageClicks,v=ui(e,"rageClicks",ct,f),p=ui(e,"deadClicks",at,d),h=ui(e,"errorClicks",ut,o),g=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:it,m=new Jr(e),y=l([],c(new Set(l(l(l([],c(v),!1),c(p),!1),c(h),!1))),!1);return{name:n,type:"enrichment",setup:function(t,u){return s(void 0,void 0,void 0,function(){var s,c,l,b,w,E,S,T;return a(this,function(a){return"undefined"==typeof document||(s=function(){var e,t,n=un(Yr("pointerdown").map(function(e){return m.addAdditionalEventProperties(e,"click",y,g,!0)})),r=un(Xr().map(function(e){return m.addTypeAndTimestamp(e,"error")})),o=un(Gr().map(function(e){return m.addAdditionalEventProperties(e,"mutation",y,g)}));window.navigation&&(t=un(new on(function(e){var t=function(t){e.next(i(i({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return m.addAdditionalEventProperties(e,"navigate",y,g)})));var s=un(new on(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}}));return(e={})[Wr.ClickObservable]=n,e[Wr.MutationObservable]=o,e[Wr.NavigateObservable]=t,e[Wr.BrowserErrorObservable]=r,e[Wr.SelectionObservable]=s,e}(),f&&(c=xr(e,v),l=ai({allObservables:s,amplitude:u,shouldTrackRageClick:c}),r.push(l)),d&&(b=xr(e,p),w=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,o=e.shouldTrackDeadClick,s=n.clickObservable,a=n.mutationObservable,u=n.navigateObservable,c=s.filter(function(e){return jr(e)&&o("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Nr.LEFT_OR_TOUCH_CONTACT}),l=u?an(a,u):a,d=an(c,l),f=null;return sn(d,function(e){return f&&ii.includes(e.type)?(clearTimeout(f),f=null,Promise.resolve(null)):"click"===e.type?f?Promise.resolve(null):new Promise(function(t){f=setTimeout(function(){t(e),f=null},3e3)}):Promise.resolve(null)}).subscribe(function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",i(i({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}})}({amplitude:u,allObservables:s,getEventProperties:function(e,t){return m.getEventProperties(e,t,g)},shouldTrackDeadClick:b}),r.push(w)),o&&(E=xr(e,h),S=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,o=n.clickObservable,s=n.browserErrorObservable,a=o.filter(function(e){return jr(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Nr.LEFT_OR_TOUCH_CONTACT}),u=null,c=null,l=function(){null!==u&&(clearTimeout(u),u=null),c=null};return an(a,s).subscribe(function(e){var n;if("click"===e.type)return l(),c=e,void(u=setTimeout(l,2e3));"error"===e.type&&c&&(t.track("[Amplitude] Error Click",i(((n={})["[Amplitude] Kind"]=e.event.kind,n["[Amplitude] Message"]=e.event.message,n["[Amplitude] Stack"]=e.event.stack,n["[Amplitude] Filename"]=e.event.filename,n["[Amplitude] Line Number"]=e.event.lineNumber,n["[Amplitude] Column Number"]=e.event.columnNumber,n),c.targetElementProperties)),l())})}({amplitude:u,allObservables:s,shouldTrackErrorClick:E}),r.push(S)),null===(T=null==t?void 0:t.loggerProvider)||void 0===T||T.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,i;return a(this,function(o){try{for(e=u(r),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]})})}}},fi="[Amplitude] Network Request",vi="500-599";function pi(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function hi(e,t){var n,r,i=t.split(",");try{for(var o=u(i),s=o.next();!s.done;s=o.next()){var a=c(s.value.split("-").map(Number),2),l=a[0],d=a[1];if(e===l&&void 0===d)return!0;if(e>=l&&e<=d)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function gi(e){var t;if(e)try{var n=null===(t=M())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),s=r.href,a=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:r.href,host:a}}catch(e){return}}function mi(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return l([],c(O),!1);if(void 0===e){return}}}function yi(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function bi(e,t){var n;void 0===t&&(t={});var r=gi(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(pi(o,"*.amplitude.com")||pi(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find(function(e){return pi(o,e)}))return!1;if(!t.captureRules&&void 0!==e.status&&!hi(e.status,vi))return!1;if(t.captureRules&&(l([],c(t.captureRules),!1).reverse().find(function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find(function(e){return pi(t,e)}))&&(!r||!e.urls||ke(r,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return!((n||0===n)&&!hi(n,e.statusCodeRange||vi))}(t,o,e.status,e.url,e.method),i){var n=mi(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var s=mi(t.requestHeaders);if(e.requestWrapper&&s){var a=e.requestWrapper.headers(s);a&&(e.requestHeaders=a)}e.responseWrapper&&t.responseBody&&!yi(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!yi(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i}),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find(function(e){return e.event_type===fi}))return!0}catch(e){}return!1}(o,e.requestWrapper)}function wi(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return bi(e.event,n)}).subscribe(function(e){var t,n,o,u=e.event,l=gi(u.url);if(l){var d=null===(n=u.responseWrapper)||void 0===n?void 0:n.bodySize,f=null===(o=u.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){s(this,void 0,void 0,function(){var i,o,s;return a(this,function(a){switch(a.label){case 0:return t.requestBodyJson||t.responseBodyJson?[4,Promise.all([t.requestBodyJson,t.responseBodyJson])]:[3,2];case 1:if(i=c.apply(void 0,[a.sent(),2]),o=i[0],s=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(s)try{e["[Amplitude] Response Body"]=JSON.stringify(s)}catch(e){null==r||r.debug("Failed to stringify response body")}a.label=2;case 2:return null==n||n.track(fi,e),[2]}})})}(((t={})["[Amplitude] URL"]=l.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=l.query,t["[Amplitude] URL Fragment"]=l.fragment,t["[Amplitude] Request Method"]=u.method,t["[Amplitude] Status Code"]=u.status,t["[Amplitude] Start Time"]=u.startTime,t["[Amplitude] Completion Time"]=u.endTime,t["[Amplitude] Duration"]=u.duration,t["[Amplitude] Request Body Size"]=f,t["[Amplitude] Response Body Size"]=d,t["[Amplitude] Request Type"]=u.type,t["[Amplitude] Request Headers"]=u.requestHeaders,t["[Amplitude] Response Headers"]=u.responseHeaders,t),u,r,i)}})}!function(e){e.NetworkObservable="networkObservable"}(ci||(ci={}));var Ei=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new on(function(e){var n=new It(function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)});return Ot.subscribe(n,t),function(){Ot.unsubscribe(n)}});return(e={})[ci.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var s;return a(this,function(a){return"undefined"==typeof document||(s=r(),t=null==i?void 0:i.loggerProvider,li=wi({allObservables:s,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){return li.unsubscribe(),[2]})})}}};let Si=-1;const Ti=e=>{addEventListener("pageshow",t=>{t.persisted&&(Si=t.timeStamp,e(t))},!0)},ki=(e,t,n,r)=>{let i,o;return s=>{t.value>=0&&(s||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},_i=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},Ii=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Pi=()=>{const e=Ii();return e?.activationStart??0},Oi=(e,t=-1)=>{const n=Ii();let r="navigate";return Si>=0?r="back-forward-cache":n&&(document.prerendering||Pi()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},xi=new WeakMap;function Ai(e,t){return xi.get(e)||xi.set(e,new t),xi.get(e)}class Ci{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}const Ri=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver(e=>{Promise.resolve().then(()=>{t(e.getEntries())})});return r.observe({type:e,buffered:!0,...n}),r}}catch{}},Di=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let Li=-1;const Ni=new Set,ji=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,Mi=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Ni)e();isFinite(Li)||(Li="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",Mi,!0))}},Ui=()=>{if(Li<0){const e=Pi(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime;Li=t??ji(),addEventListener("visibilitychange",Mi,!0),addEventListener("prerenderingchange",Mi,!0),Ti(()=>{setTimeout(()=>{Li=ji()})})}return{get firstHiddenTime(){return Li},onHidden(e){Ni.add(e)}}},qi=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},Fi=[1800,3e3],Bi=(e,t={})=>{qi(()=>{const n=Ui();let r,i=Oi("FCP");const o=Ri("paint",e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Pi(),0),i.entries.push(t),r(!0)))});o&&(r=ki(e,i,Fi,t.reportAllChanges),Ti(n=>{i=Oi("FCP"),r=ki(e,i,Fi,t.reportAllChanges),_i(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Hi=[.1,.25];let Vi=0,zi=1/0,Ji=0;const $i=e=>{for(const t of e)t.interactionId&&(zi=Math.min(zi,t.interactionId),Ji=Math.max(Ji,t.interactionId),Vi=Ji?(Ji-zi)/7+1:0)};let Wi;const Ki=()=>Wi?Vi:performance.interactionCount??0;let Gi=0;class Yi{u=[];l=new Map;m;p;v(){Gi=Ki(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((Ki()-Gi)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort((e,t)=>t.P-e.P),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const Xi=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=Di(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},Qi=[200,500],Zi=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=Ui();qi(()=>{"interactionCount"in performance||Wi||(Wi=Ri("event",$i,{type:"event",buffered:!0,durationThreshold:0}));let r,i=Oi("INP");const o=Ai(t,Yi),s=e=>{Xi(()=>{for(const t of e)o.h(t);const t=o.L();t&&t.P!==i.value&&(i.value=t.P,i.entries=t.entries,r())})},a=Ri("event",s,{durationThreshold:t.durationThreshold??40});r=ki(e,i,Qi,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),Ti(()=>{o.v(),i=Oi("INP"),r=ki(e,i,Qi,t.reportAllChanges)}))})};class eo{m;h(e){this.m?.(e)}}const to=[2500,4e3],no=[800,1800],ro=e=>{document.prerendering?qi(()=>ro(e)):"complete"!==document.readyState?addEventListener("load",()=>ro(e),!0):setTimeout(e)};function io(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function oo(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(io(e)),navigationStart:Math.floor(performance.timeOrigin)}}var so,ao=function(){var e=null,t=M(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return s(void 0,void 0,void 0,function(){var o,s;return a(this,function(a){return void 0===n||(o=_e((null==r?void 0:r.href)||"",t.loggerProvider),s={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":_e((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":_e(o.split("?")[0],t.loggerProvider)},((e,t={})=>{qi(()=>{const n=Ui();let r,i=Oi("LCP");const o=Ai(t,eo),s=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Pi(),0),i.entries=[t],r())},a=Ri("largest-contentful-paint",s);if(a){r=ki(e,i,to,t.reportAllChanges);const n=Di(()=>{s(a.takeRecords()),a.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(Xi(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});Ti(n=>{i=Oi("LCP"),r=ki(e,i,to,t.reportAllChanges),_i(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(function(e){s["[Amplitude] LCP"]=oo(e)}),Bi(function(e){s["[Amplitude] FCP"]=oo(e)}),Zi(function(e){s["[Amplitude] INP"]=oo(e)}),((e,t={})=>{const n=Ui();Bi(Di(()=>{let r,i=Oi("CLS",0);const o=Ai(t,Ci),s=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},a=Ri("layout-shift",s);a&&(r=ki(e,i,Hi,t.reportAllChanges),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),Ti(()=>{o.i=0,i=Oi("CLS",0),r=ki(e,i,Hi,t.reportAllChanges),_i(()=>r())}),setTimeout(r))}))})(function(e){s["[Amplitude] CLS"]=oo(e)}),((e,t={})=>{let n=Oi("TTFB"),r=ki(e,n,no,t.reportAllChanges);ro(()=>{const i=Ii();i&&(n.value=Math.max(i.responseStart-Pi(),0),n.entries=[i],r(!0),Ti(()=>{n=Oi("TTFB",0),r=ki(e,n,no,t.reportAllChanges),r(!0)}))})})(function(e){s["[Amplitude] TTFB"]=oo(e)}),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",s),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return a(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},uo=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},co=function(e,t,n,r,i){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=o(e,["referrer","referring_domain"]),u=t||{};u.referrer;var c=u.referring_domain,l=o(u,["referrer","referring_domain"]);if(lo(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every(function(e){return!e})}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var d=JSON.stringify(a)!==JSON.stringify(l),f=uo(s||"")!==uo(c||""),v=!t||d||f;return v?r.debug("This is a new campaign. An $identify event will be sent."):r.debug("This is not a new campaign because it's the same as the previous one."),v},lo=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some(function(e){return e instanceof RegExp?e.test(t):e===t})},fo=function(){function e(e,t){var n,r,o;this.shouldTrackNewCampaign=!1,this.options=i({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=null===(n=t.cookieOptions)||void 0===n?void 0:n.domain,o=r,o?(o.startsWith(".")&&(o=o.substring(1)),[new RegExp("".concat(o.replace(".","\\."),"$"))]):[])},e),this.storage=t.cookieStorage,this.storageKey=Ce(t.apiKey,"MKTG"),this.webExpStorageKey=Ce(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=P,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return s(this,void 0,void 0,function(){var e,t;return a(this,function(n){switch(n.label){case 0:return[4,this.fetchCampaign()];case 1:return t=c.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||be(this.sessionTimeout,this.lastEventTime),co(this.currentCampaign,this.previousCampaign,this.options,this.logger,e)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return s(this,void 0,void 0,function(){var e;return a(this,function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new xt).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,o,s=(t=this.currentCampaign,n=this.options,r=i(i({},P),t),o=Object.entries(r).reduce(function(e,t){var r,i=c(t,2),o=i[0],s=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=s?s:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),s?e.set(o,s):e.unset(o)},new R),B(o));return e&&(s.event_id=e),s},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),vo="AMP_CURRENT_PAGE",po="AMP_PREVIOUS_PAGE",ho="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(so||(so={}));var go=new Set([r.IDENTIFY,r.GROUP_IDENTIFY,r.REVENUE]),mo=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=M(),o=void 0,u=!1,l=void 0,d=!1,f=!1,v=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=_e(e,l);t=new URL(n).hostname}catch(e){null==l||l.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return so.Direct;var i=n.some(function(e){return-1!==t.indexOf(e)}),o=n.some(function(e){return-1!==r.indexOf(e)});return t===r||o&&i?so.Internal:so.External},p=function(){s(void 0,void 0,void 0,function(){var e,t,n,r,i;return a(this,function(s){switch(s.label){case 0:return o&&u?[4,o.get(ho)]:[3,3];case 1:return e=s.sent(),t=_e("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[vo])||"",r=void 0,r=t===n?(null==e?void 0:e[po])||"":n||document.referrer||"",[4,o.set(ho,(i={},i[vo]=t,i[po]=r,i))];case 2:s.sent(),s.label=3;case 3:return[2]}})})},h={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return(l=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),f=!0,r?[4,(o=new Re(r.sessionStorage)).isEnabled()]:[3,2];case 1:u=t.sent(),r.addEventListener("popstate",p),d||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),f&&p()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),f&&p()}}),d=!0),t.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,n,r,s,c;return a(this,function(a){switch(a.label){case 0:return t=_e("undefined"!=typeof location&&location.href||""),o&&u?[4,o.get(ho)]:[3,5];case 1:return(null==(n=a.sent())?void 0:n[vo])?[3,3]:[4,o.set(ho,(c={},c[vo]=t,c[po]=document.referrer||"",c))];case 2:a.sent(),a.label=3;case 3:return[4,o.get(ho)];case 4:if(r=a.sent(),s="",r&&(s=r[po]||""),go.has(e.event_type))return[2,e];e.event_properties=i(i({},e.event_properties||{}),{"[Amplitude] Page Domain":yo(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":yo(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":yo(e,"[Amplitude] Page Path","undefined"!=typeof location&&_e(location.pathname)||""),"[Amplitude] Page Title":yo(e,"[Amplitude] Page Title",jt(Nt)),"[Amplitude] Page URL":yo(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":s,"[Amplitude] Previous Page Type":v(s)}),a.label=5;case 5:return[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",p),f=!1),o&&u?[4,o.set(ho,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}};return h};function yo(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var bo=function(e){function n(){var t=e.apply(this,l([],c(arguments),!1))||this;return t._diagnosticsSampleRate=0,t}return t(n,e),n.prototype.init=function(e,t,n){var r,o;return void 0===e&&(e=""),arguments.length>2?(r=t,o=n):"string"==typeof t?(r=t,o=void 0):(r=null==t?void 0:t.userId,o=t),H(this._init(i(i({},o),{userId:r,apiKey:e})))},n.prototype._init=function(t){return s(this,void 0,void 0,function(){var n,r,s,u,c,l,d,f,v,p,h,g,m,y,b,w,E,S,T,k,_,I=this;return a(this,function(a){switch(a.label){case 0:return this.initializing?[2]:(this.initializing=!0,n=function(e){var t,n;return void 0===e&&(e={}),!0===(null===(t=e.remoteConfig)||void 0===t?void 0:t.fetchRemoteConfig)||!1!==(null===(n=e.remoteConfig)||void 0===n?void 0:n.fetchRemoteConfig)&&!1!==e.fetchRemoteConfig}(t),r=null!==(b=t.loggerProvider)&&void 0!==b?b:new W,s=null!==(w=t.serverZone)&&void 0!==w?w:"US",c=this._diagnosticsSampleRate,l=null===(E=t.enableDiagnostics)||void 0===E||E,n?(u=new Ge(t.apiKey,r,s,null===(S=t.remoteConfig)||void 0===S?void 0:S.serverUrl),[4,new Promise(function(e){null==u||u.subscribe("configs.diagnostics.browserSDK","all",function(t,n,i){if(r.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:i},null,2)),t){var o=t.sampleRate;"number"!=typeof o||isNaN(o)||(c=o);var s=t.enabled;"boolean"==typeof s&&(l=s)}e()})})]):[3,2]);case 1:a.sent(),a.label=2;case 2:return(d=new Je(t.apiKey,r,s,{enabled:l,sampleRate:c})).setTag("library","".concat(_n,"/").concat(kn)),"undefined"!=typeof navigator&&d.setTag("user_agent",navigator.userAgent),[4,Xn(t.apiKey,t,this,d,{loggerProvider:r,serverZone:s,enableDiagnostics:l,diagnosticsSampleRate:c})];case 3:return f=a.sent(),n&&u?[4,new Promise(function(e){null==u||u.subscribe("configs.analyticsSDK.browserSDK","all",function(t,n,r){f.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&hr(t,f),e()})})]:[3,5];case 4:a.sent(),a.label=5;case 5:return[4,e.prototype._init.call(this,f)];case 6:return a.sent(),this.logBrowserOptions(f),this.config.remoteConfigClient=u,ln(this.config.defaultTracking)?(O=this.config,v=ln(O.defaultTracking)&&O.defaultTracking&&"object"==typeof O.defaultTracking&&O.defaultTracking.attribution&&"object"==typeof O.defaultTracking.attribution?i({},O.defaultTracking.attribution):{},this.webAttribution=new fo(v,this.config),[4,this.webAttribution.init()]):[3,8];case 7:a.sent(),a.label=8;case 8:return p=Se(),h=p.ampTimestamp?Number(p.ampTimestamp):void 0,g=!h||Date.now()<h,m=g&&!Number.isNaN(Number(p.ampSessionId))?Number(p.ampSessionId):void 0,this.setSessionId(null!==(_=null!==(k=null!==(T=t.sessionId)&&void 0!==T?T:m)&&void 0!==k?k:this.config.sessionId)&&void 0!==_?_:Date.now()),(y=me(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(fr()).promise];case 9:a.sent(),a.label=10;case 10:return[4,this.add(new se({diagnosticsClient:d})).promise];case 11:return a.sent(),[4,this.add(new In).promise];case 12:return a.sent(),[4,this.add(new ye).promise];case 13:return a.sent(),function(e){dr||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),dr=!0)}(this.config),P=this.config.defaultTracking,cn(P,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(lr()).promise]):[3,15];case 14:a.sent(),a.label=15;case 15:return dn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(ar()).promise]):[3,17];case 16:a.sent(),a.label=17;case 17:return fn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(rr(wn(this.config))).promise]):[3,19];case 18:a.sent(),a.label=19;case 19:return hn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(ri(mn(this.config),{diagnosticsClient:d})).promise]):[3,21];case 20:a.sent(),a.label=21;case 21:return gn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(di(yn(this.config))).promise]):[3,23];case 22:a.sent(),a.label=23;case 23:return pn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(Ei(bn(this.config))).promise]):[3,25];case 24:a.sent(),a.label=25;case 25:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(ao()).promise]):[3,27];case 26:a.sent(),a.label=27;case 27:return function(e){return cn(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(mo()).promise]):[3,29];case 28:a.sent(),a.label=29;case 29:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 30:return a.sent(),y.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=o(t,["time"]),i="number"==typeof n?{time:n}:void 0;I.track(e.eventType,r,i)}),[2]}var P,O})})},n.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},n.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){me(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},n.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},n.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){me(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},n.prototype.reset=function(){this.setDeviceId(q()),this.setUserId(void 0),this.timeline.onReset()},n.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},n.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},n.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},n.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),H(Promise.resolve());if(e===this.config.sessionId)return H(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,vn(this.config.defaultTracking)&&(r&&i&&n.push(this.track(Fn,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(B(this.config.identify)).promise),vn(this.config.defaultTracking)&&n.push(this.track(qn,void 0,{event_id:s?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,H(Promise.all(n))},n.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},n.prototype.setTransport=function(e){this.config?this.config.transportProvider=Zn(e):this.q.push(this.setTransport.bind(this,e))},n.prototype.identify=function(t,n){if(Tn(t)){var r=t._q;t._q=[],t=Sn(new R,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},n.prototype.groupIdentify=function(t,n,r,i){if(Tn(r)){var o=r._q;r._q=[],r=Sn(new R,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},n.prototype.revenue=function(t,n){if(Tn(t)){var r=t._q;t._q=[],t=Sn(new z,r)}return e.prototype.revenue.call(this,t,n)},n.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},n.prototype.process=function(t){return s(this,void 0,void 0,function(){var n,i,o;return a(this,function(s){return n=Date.now(),i=be(this.config.sessionTimeout,this.config.lastEventTime),o=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===qn||t.event_type===Fn||t.session_id&&t.session_id!==this.getSessionId()||(i||o?(this.setSessionId(n),o&&this.config.loggerProvider.log("Created a new session for new campaign.")):i||this.trackCampaignEventIfNeeded()),t.event_type===r.IDENTIFY&&t.user_properties&&(this.userProperties=this.getOperationAppliedUserProperties(t.user_properties)),[2,e.prototype.process.call(this,t)]})})},n.prototype.logBrowserOptions=function(e){try{var t=i(i({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",JSON.stringify(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},n.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},n}(V),wo=function(){var e=new bo;return{init:ie(e.init.bind(e),"init",te(e),re(e,["config"])),add:ie(e.add.bind(e),"add",te(e),re(e,["config.apiKey","timeline.plugins"])),remove:ie(e.remove.bind(e),"remove",te(e),re(e,["config.apiKey","timeline.plugins"])),track:ie(e.track.bind(e),"track",te(e),re(e,["config.apiKey","timeline.queue.length"])),logEvent:ie(e.logEvent.bind(e),"logEvent",te(e),re(e,["config.apiKey","timeline.queue.length"])),identify:ie(e.identify.bind(e),"identify",te(e),re(e,["config.apiKey","timeline.queue.length"])),groupIdentify:ie(e.groupIdentify.bind(e),"groupIdentify",te(e),re(e,["config.apiKey","timeline.queue.length"])),setGroup:ie(e.setGroup.bind(e),"setGroup",te(e),re(e,["config.apiKey","timeline.queue.length"])),revenue:ie(e.revenue.bind(e),"revenue",te(e),re(e,["config.apiKey","timeline.queue.length"])),flush:ie(e.flush.bind(e),"flush",te(e),re(e,["config.apiKey","timeline.queue.length"])),getUserId:ie(e.getUserId.bind(e),"getUserId",te(e),re(e,["config","config.userId"])),setUserId:ie(e.setUserId.bind(e),"setUserId",te(e),re(e,["config","config.userId"])),getDeviceId:ie(e.getDeviceId.bind(e),"getDeviceId",te(e),re(e,["config","config.deviceId"])),setDeviceId:ie(e.setDeviceId.bind(e),"setDeviceId",te(e),re(e,["config","config.deviceId"])),reset:ie(e.reset.bind(e),"reset",te(e),re(e,["config","config.userId","config.deviceId"])),getSessionId:ie(e.getSessionId.bind(e),"getSessionId",te(e),re(e,["config"])),setSessionId:ie(e.setSessionId.bind(e),"setSessionId",te(e),re(e,["config"])),extendSession:ie(e.extendSession.bind(e),"extendSession",te(e),re(e,["config"])),setOptOut:ie(e.setOptOut.bind(e),"setOptOut",te(e),re(e,["config"])),setTransport:ie(e.setTransport.bind(e),"setTransport",te(e),re(e,["config"])),getIdentity:ie(e.getIdentity.bind(e),"getIdentity",te(e),re(e,["config"])),getOptOut:ie(e.getOptOut.bind(e),"getOptOut",te(e),re(e,["config"])),_setDiagnosticsSampleRate:ie(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",te(e),re(e,["config"]))}},Eo=wo(),So=Object.freeze({__proto__:null,get IdentifyOperation(){return n},get SpecialEventType(){return r},get RevenueProperty(){return N},get LogLevel(){return J},get ServerZone(){return tt},OfflineDisabled:null,DEFAULT_CSS_SELECTOR_ALLOWLIST:rt,DEFAULT_DATA_ATTRIBUTE_PREFIX:it,DEFAULT_ACTION_CLICK_ALLOWLIST:ot}),To=Eo.add,ko=Eo.extendSession,_o=Eo.flush,Io=Eo.getDeviceId,Po=Eo.getIdentity,Oo=Eo.getOptOut,xo=Eo.getSessionId,Ao=Eo.getUserId,Co=Eo.groupIdentify,Ro=Eo.identify,Do=Eo.init,Lo=Eo.logEvent,No=Eo.remove,jo=Eo.reset,Mo=Eo.revenue,Uo=Eo.setDeviceId,qo=Eo.setGroup,Fo=Eo.setOptOut,Bo=Eo.setSessionId,Ho=Eo.setTransport,Vo=Eo.setUserId,zo=Eo.track,Jo=Eo._setDiagnosticsSampleRate,$o=Object.freeze({__proto__:null,add:To,extendSession:ko,flush:_o,getDeviceId:Io,getIdentity:Po,getOptOut:Oo,getSessionId:xo,getUserId:Ao,groupIdentify:Co,identify:Ro,init:Do,logEvent:Lo,remove:No,reset:jo,revenue:Mo,setDeviceId:Uo,setGroup:qo,setOptOut:Fo,setSessionId:Bo,setTransport:Ho,setUserId:Vo,track:zo,_setDiagnosticsSampleRate:Jo,createInstance:wo,AmplitudeBrowser:bo,runQueuedFunctions:En,Revenue:z,Identify:R,Types:So});!function(){var e=M();if(e){var t=function(e){var t=wo(),n=M();return n&&n.amplitudeGTM&&n.amplitudeGTM._iq&&e&&(n.amplitudeGTM._iq[e]=t),t};if(e.amplitudeGTM=Object.assign(e.amplitudeGTM||{},$o,{createInstance:t}),e.amplitudeGTM.invoked){var n=e.amplitudeGTM._q;e.amplitudeGTM._q=[],En($o,n);for(var r=Object.keys(e.amplitudeGTM._iq)||[],i=0;i<r.length;i++){var o=r[i],s=Object.assign(e.amplitudeGTM._iq[o],t(o)),a=s._q;s._q=[],En(s,a)}}}else console.error("[Amplitude] Error: GlobalScope is not defined")}()}();
|
|
2
2
|
//# sourceMappingURL=amplitude-gtm-min.js.map
|