@amplitude/analytics-browser 2.46.0-video-analytics-2.0 → 2.46.0-video-analytics-4.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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/browser-client.js +1 -1
  3. package/lib/cjs/browser-client.js.map +1 -1
  4. package/lib/cjs/config.d.ts +3 -4
  5. package/lib/cjs/config.d.ts.map +1 -1
  6. package/lib/cjs/config.js +5 -6
  7. package/lib/cjs/config.js.map +1 -1
  8. package/lib/cjs/version.d.ts +1 -1
  9. package/lib/cjs/version.js +1 -1
  10. package/lib/cjs/version.js.map +1 -1
  11. package/lib/cjs/video-capture/video-capture.d.ts.map +1 -1
  12. package/lib/cjs/video-capture/video-capture.js +36 -10
  13. package/lib/cjs/video-capture/video-capture.js.map +1 -1
  14. package/lib/esm/browser-client.js +1 -1
  15. package/lib/esm/browser-client.js.map +1 -1
  16. package/lib/esm/config.d.ts +3 -4
  17. package/lib/esm/config.d.ts.map +1 -1
  18. package/lib/esm/config.js +5 -6
  19. package/lib/esm/config.js.map +1 -1
  20. package/lib/esm/version.d.ts +1 -1
  21. package/lib/esm/version.js +1 -1
  22. package/lib/esm/version.js.map +1 -1
  23. package/lib/esm/video-capture/video-capture.d.ts.map +1 -1
  24. package/lib/esm/video-capture/video-capture.js +37 -11
  25. package/lib/esm/video-capture/video-capture.js.map +1 -1
  26. package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
  27. package/lib/scripts/amplitude-bookmarklet.html +1 -1
  28. package/lib/scripts/amplitude-gtm-min.js +1 -1
  29. package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
  30. package/lib/scripts/amplitude-gtm-min.js.map +1 -1
  31. package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
  32. package/lib/scripts/amplitude-min.js +1 -1
  33. package/lib/scripts/amplitude-min.js.gz +0 -0
  34. package/lib/scripts/amplitude-min.js.map +1 -1
  35. package/lib/scripts/amplitude-min.umd.js +1 -1
  36. package/lib/scripts/amplitude-min.umd.js.gz +0 -0
  37. package/lib/scripts/amplitude-snippet-instructions.html +1 -1
  38. package/lib/scripts/amplitude-snippet-min.js +1 -1
  39. package/lib/scripts/config.d.ts +3 -4
  40. package/lib/scripts/config.d.ts.map +1 -1
  41. package/lib/scripts/version.d.ts +1 -1
  42. package/lib/scripts/video-capture/video-capture.d.ts.map +1 -1
  43. package/package.json +9 -9
@@ -1,2 +1,2 @@
1
- !function(){"use strict";function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var t=function(e,n){return t=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])},t(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,i,o=function(){return o=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},o.apply(this,arguments)};function a(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 a(e){try{u(r.next(e))}catch(e){o(e)}}function s(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(a,s)}u((r=r.apply(e,t||[])).next())})}function u(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function l(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),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}function d(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"}(r||(r={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(i||(i={}));var f,v="AMP",p="".concat(v,"_unsent"),h="$default_instance",g="https://api2.amplitude.com/2/httpapi",m="https://api.eu.amplitude.com/2/httpapi",y="https://api2.amplitude.com/batch",b="https://api.eu.amplitude.com/batch",w="dclid",E="fbclid",S="gbraid",k="gclid",T="ko_click_id",x="li_fat_id",P="msclkid",_="rdt_cid",I="ttclid",A="twclid",O="wbraid",C={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},R=["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"],D=["authorization","cookie","set-cookie"],L=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!N(t,n))return!1}return!0},N=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if("object"==typeof s)i=i&&L(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return L(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},M=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return o({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(f.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(f.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(f.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(f.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(f.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(f.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(f.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(f.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(f.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[f.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[f.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===f.ADD?"number"==typeof n:e===f.UNSET||e===f.REMOVE||N(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"}(f||(f={}));var j,U=[f.CLEAR_ALL,f.UNSET,f.SET,f.SET_ONCE,f.ADD,f.APPEND,f.PREPEND,f.PREINSERT,f.POSTINSERT,f.REMOVE],F="Event skipped due to empty event type";!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"}(j||(j={}));var q=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=j.Unknown),{event:e,code:t,message:n}},B=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},H=d([],c(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),z=function(e){var t,n=B();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,z)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,d([],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(H[r]):H[r]}).join("")},V={},W={get exports(){return V},set exports(e){V=e}},$=Object.prototype.hasOwnProperty;function K(e){return"[Throws: "+(e?e.message:"?")+"]"}function G(e){var t=[];return function e(n){if(null===n||"object"!=typeof n)return n;if(-1!==t.indexOf(n))return"[Circular]";if(t.push(n),"function"==typeof n.toJSON)try{var r=e(n.toJSON());return t.pop(),r}catch(e){return K(e)}if(Array.isArray(n)){var i=n.map(e);return t.pop(),i}var o=Object.keys(n).reduce(function(t,r){return t[r]=e(function(e,t){if($.call(e,t))try{return e[t]}catch(e){return K(e)}return e[t]}(n,r)),t},{});return t.pop(),o}(e)}W.exports=function(e,t,n){return JSON.stringify(G(e),t,n)};var J,Y=V.ensureProperties=G,X=V||e({__proto__:null,ensureProperties:Y,get default(){return V}},[V]),Q=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return s(this,void 0,void 0,function(){var i;return u(this,function(o){switch(o.label){case 0:return void 0===e.name&&(e.name=z(),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."))),i=e.name,this.pluginStatus.has(i)?(this.loggerProvider.warn("Plugin with name ".concat(i," already exists, skipping registration")),[2]):(e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",this.pluginStatus.set(i,"locked"),[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return o.sent(),"locked"!==this.pluginStatus.get(i)?[2]:(this.plugins.push(e),this.pluginStatus.set(i,"installed"),[2])}})})},e.prototype.deregister=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i;return u(this,function(o){switch(o.label){case 0:return this.pluginStatus.delete(e),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._clearOptOutListeners(),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.pluginStatus.clear(),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,i,a,s,d,f,v,p,h,g,m,y,b,w,E,S,k,T;return u(this,function(u){switch(u.label){case 0:if(!e)return[2];t=c(e,1),n=t[0],r=c(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),a=this.plugins.filter(function(e){return"before"===e.type}),u.label=1;case 1:u.trys.push([1,6,7,8]),s=l(a),d=s.next(),u.label=2;case 2:return d.done?[3,5]:(g=d.value).execute?[4,g.execute(o({},n))]:[3,4];case 3:if(null===(m=u.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(g.name),"', event: ").concat(X(n))),i({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(g.name),"', event: ").concat(X(n))),u.label=4;case 4:return d=s.next(),[3,2];case 5:return[3,8];case 6:return f=u.sent(),E={error:f},[3,8];case 7:try{d&&!d.done&&(S=s.return)&&S.call(s)}finally{if(E)throw E.error}return[7];case 8:v=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),u.label=9;case 9:u.trys.push([9,14,15,16]),p=l(v),h=p.next(),u.label=10;case 10:return h.done?[3,13]:(g=h.value).execute?[4,g.execute(o({},n))]:[3,12];case 11:if(null===(m=u.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(g.name),"', event: ").concat(X(n))),i({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(g.name),"', event: ").concat(X(n))),u.label=12;case 12:return h=p.next(),[3,10];case 13:return[3,16];case 14:return y=u.sent(),k={error:y},[3,16];case 15:try{h&&!h.done&&(T=p.return)&&T.call(p)}finally{if(k)throw k.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(X(n))),w=b.map(function(e){var t=o({},n);return e.execute(t).catch(function(e){return q(t,0,String(e))})}),Promise.all(w).then(function(e){var t=c(e,1)[0]||q(n,100,"Event not tracked, no destination plugins on the instance");i(t)}),[2]}})})},e.prototype.flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r=this;return u(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.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},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)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o,a,s;return u(this,function(u){switch(u.label){case 0:u.trys.push([0,7,8,9]),t=l(this._optOutListeners),n=t.next(),u.label=1;case 1:if(n.done)return[3,6];r=n.value,u.label=2;case 2:return u.trys.push([2,4,,5]),[4,r(e)];case 3:return u.sent(),[3,5];case 4:return i=u.sent(),this.loggerProvider.error("Error calling optOut listener",i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return o=u.sent(),a={error:o},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(a)throw a.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)})},e}(),Z=function(e,t){return o(o({},t),{event_type:i.IDENTIFY,user_properties:e.getUserProperties()})},ee=function(e){return{promise:e||Promise.resolve()}},te=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 Q(this),this.name=e}return e.prototype._init=function(e){return s(this,void 0,void 0,function(){var t=this;return u(this,function(n){switch(n.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q",function(){return t.isReady=!0})];case 1:return n.sent(),[2]}})})},e.prototype.runQueuedFunctions=function(e,t){return s(this,void 0,void 0,function(){var n,r,i,o,a,s,c,d;return u(this,function(u){switch(u.label){case 0:n=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),r=l(n),i=r.next(),u.label=2;case 2:return i.done?[3,7]:(o=i.value,(a=o())&&"promise"in a?[4,a.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,a];case 5:u.sent(),u.label=6;case 6:return i=r.next(),[3,2];case 7:return[3,10];case 8:return s=u.sent(),c={error:s},[3,10];case 9:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(c)throw c.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e,t)]:[3,12];case 11:return u.sent(),[3,13];case 12:null==t||t(),u.label=13;case 13:return[2]}})})},e.prototype.track=function(e,t,n){var r=function(e,t,n){return o(o(o({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),ee(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Z(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),ee(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var a=function(e,t,n,r){var a;return o(o({},r),{event_type:i.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(a={},a[e]=t,a)})}(e,t,n,r);return ee(this.dispatch(a))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,a=new M;return a.set(e,t),o(o({},n),{event_type:i.IDENTIFY,user_properties:a.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),ee(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return o(o({},t),{event_type:i.REVENUE,event_properties:e.getEventProperties()})}(e,t);return ee(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),ee())},e.prototype._addPlugin=function(e){return ee(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)),ee())},e.prototype._removePlugin=function(e){return ee(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(q(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 u(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,n=null!==(t=this.userProperties)&&void 0!==t?t:{},i=o({},n);if(void 0===e)return i;var a={};return Object.keys(e).forEach(function(t){Object.values(r).includes(t)||(a[t]=e[t])}),U.forEach(function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case r.CLEAR_ALL:Object.keys(i).forEach(function(e){delete i[e]});break;case r.UNSET:Object.keys(n).forEach(function(e){delete i[e]});break;case r.SET:Object.assign(i,n)}}}),Object.assign(i,a),i},e.prototype.process=function(e){return s(this,void 0,void 0,function(){var t,n,r,o;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),this.config.optOut?[2,q(e,0,"Event skipped due to optOut config")]:"string"!=typeof(t=e.event_type)||0===t.trim().length?(this.config.loggerProvider.error(F),[2,q(e,0,F)]):(e.event_type===i.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]);case 1:return 200===(o=a.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=a.sent(),r=String(n),this.config.loggerProvider.error(r),[2,o=q(e,0,r)];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.config.optOut=Boolean(e),this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return ee(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}(),ne=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){try{var t=JSON.parse(JSON.stringify(e));L(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?o({},this.properties):{};return e[J.REVENUE_PRODUCT_ID]=this.productId,e[J.REVENUE_QUANTITY]=this.quantity,e[J.REVENUE_PRICE]=this.price,e[J.REVENUE_TYPE]=this.revenueType,e[J.REVENUE_CURRENCY]=this.currency,e[J.REVENUE]=this.revenue,e[J.RECEIPT]=this.receipt,e[J.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"}(J||(J={}));var re;!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"}(re||(re={}));var ie="Amplitude Logger ",oe=function(){function e(){this.logLevel=re.None}return e.prototype.disable=function(){this.logLevel=re.None},e.prototype.enable=function(e){void 0===e&&(e=re.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Verbose||console.log("".concat(ie,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Warn||console.warn("".concat(ie,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Error||console.error("".concat(ie,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Debug||console.log("".concat(ie,"[Debug]: ").concat(e.join(" ")))},e}(),ae=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:h,logLevel:re.Warn,loggerProvider:new oe,offline:!1,optOut:!1,serverUrl:g,serverZone:"US",useBatch:!1}},se=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=ae();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.delayedEventsServerUrl=e.delayedEventsServerUrl,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 a=le(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=a.serverZone,this.serverUrl=a.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),ue=function(e,t){return"EU"===e?t?b:m:t?y:g},le=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=ae().serverZone),void 0===n&&(n=ae().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:ae().serverZone;return{serverZone:r,serverUrl:ue(r,n)}},ce=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function de(e){return e>=200&&e<300}var fe=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},ve=function(e){return function(){var t=o({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},pe=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=l(t.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(!(a in e))return;e=e[a]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},he=function(e,t){return function(){var n,r,i={};try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=pe(e,s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ge=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=n(),u=s.logger,l=s.logLevel;if(l&&l<re.Debug||!l||!u)return e.apply(i,o);var c={type:"invoke public method",name:t,args:o,stacktrace:fe(1),time:{start:(new Date).toISOString()},states:{}};r&&c.states&&(c.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=(new Date).toISOString()),u.debug(JSON.stringify(c,null,2))}):(r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=(new Date).toISOString()),u.debug(JSON.stringify(c,null,2))),d}},me=new Set([g,m,y,b]);function ye(e){return void 0!==e.delay&&null!==e.delay}function be(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var we=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.inFlightDelayedEvents={},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 u(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(p,"_").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=z()),new Promise(function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};ye(e)&&t.removeStaleDelayedEvents(e),t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeStaleDelayedEvents=function(e){var t=this;try{this.queue=this.queue.filter(function(n){var r,i=n.event;if(!ye(i))return!0;if(!(i.delay.id===e.delay.id&&i.insert_id===e.insert_id))return!0;var a=t.inFlightDelayedEvents[e.delay.id];return a&&(e.delay=o(o({},e.delay),{skipRemoval:!0})),!(!a||(null===(r=i.delay)||void 0===r?void 0:r.skipRemoval))||(n.callback(q(i,0,"Stale event overwritten")),!1)})}catch(e){}},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,i,o,a,l=this;return u(this,function(c){switch(c.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={},r=[],this.queue.forEach(function(e){var i;if(0!==e.timeout)r.push(e);else if(null===(i=e.event.delay)||void 0===i?void 0:i.id){var o=e.event.delay;n[o.id]=n[o.id]||[],n[o.id].push(e)}else t.push(e)}),d=t,f=this.config.flushQueueSize,v=Math.max(f,1),i=d.reduce(function(e,t,n){var r=Math.floor(n/v);return e[r]||(e[r]=[]),e[r].push(t),e},[]),o=i.reduce(function(t,n){return s(l,void 0,void 0,function(){return u(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()),a=[o],Object.keys(n).length>0&&a.push(this.sendDelayedEvents(n,e)),[4,Promise.all(a)]);case 1:return c.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var d,f,v})})},e.prototype.sendDelayedEvents=function(e,t){var n,r,i=this,o=[];try{var a=function(e,n){d.inFlightDelayedEvents[e]=!0;var r=d.send(n,t,!0);o.push(r),r.finally(function(){delete i.inFlightDelayedEvents[e]})},d=this;try{for(var f=l(Object.entries(e)),v=f.next();!v.done;v=f.next()){var p=c(v.value,2);a(p[0],p[1])}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}catch(e){}return o.reduce(function(e,t){return s(i,void 0,void 0,function(){return u(this,function(n){switch(n.label){case 0:return[4,e];case 1:return n.sent(),[4,t];case 2:return[2,n.sent()]}})})},Promise.resolve())},e.prototype.translatePayloadToDelayedPayload=function(e,t){var n,r,i=[],o=[],a=[],s=[];t.forEach(function(t,n){t.event.delay.timeout?(i.push(e.events[n]),a.push(t)):(o.push(e.events[n]),s.push(t))}),t.splice.apply(t,d(d([0,t.length],c(a),!1),c(s),!1)),e.timeout=null!==(r=null===(n=a[0])||void 0===n?void 0:n.event.delay.timeout)&&void 0!==r?r:0,e.id=t[0].event.delay.id,e.events=i,e.instant_events=o},e.prototype.send=function(e,t,n){var r;return void 0===t&&(t=!0),s(this,void 0,void 0,function(){var i,o,s,l,c,d;return u(this,function(u){switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];i={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,t.delay,a(t,["extra","delay"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:n?void 0:this.config.requestMetadata},n||(this.config.requestMetadata=new ce),u.label=1;case 1:return u.trys.push([1,3,,4]),o=le(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,s=function(e,t){return void 0===t&&(t=!1),!!me.has(e)||t}(o,this.config.enableRequestBodyCompression),n&&(o=this.config.delayedEventsServerUrl||"".concat(o,"/delayed"),this.translatePayloadToDelayedPayload(i,e),s=!1),[4,this.config.transportProvider.send(o,i,s)];case 2:return null===(l=u.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(l,e),[3,4]):("body"in l?this.fulfillRequest(e,l.statusCode,"".concat(l.status,": ").concat(be(l))):this.fulfillRequest(e,l.statusCode,l.status),[2]);case 3:return c=u.sent(),d=(f=c)instanceof Error?f.message:String(f),this.config.loggerProvider.error(d),null===(r=this.diagnosticsClient)||void 0===r||r.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:d,stack_trace:fe()}),this.handleResponse({status:j.Failed,statusCode:0},e),[3,4];case 4:return[2]}var f})})},e.prototype.handleResponse=function(e,t){var n;de(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:be(e),stack_trace:fe()});var r=e.status;switch(r){case j.Success:this.handleSuccessResponse(e,t);break;case j.Invalid:this.handleInvalidResponse(e,t);break;case j.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case j.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=d(d(d(d([],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(be(e));var a=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(a)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(be(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,a=new Set(r),s=new Set(i),u=new Set(o),l=t.filter(function(t,r){if(!(t.event.user_id&&a.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)))return u.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)});l.length>0&&this.config.loggerProvider.warn(be(e));var c=this.removeEventsExceedFlushMaxRetries(l);this.scheduleEvents(c)},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;de(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:fe()})),this.removeEvents(e),e.forEach(function(e){return e.callback(q(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){var t=new Set(e.map(function(e){return e.event.insert_id}));this.queue=this.queue.filter(function(t){return!e.some(function(e){var n;return e.event.insert_id===t.event.insert_id&&!(null===(n=t.event.delay)||void 0===n?void 0:n.skipRemoval)})}),this.queue.forEach(function(e){var n;(null===(n=e.event.delay)||void 0===n?void 0:n.skipRemoval)&&t.has(e.event.insert_id)&&delete e.event.delay.skipRemoval}),this.saveEvents()},e}(),Ee=function(){function e(e,t,n,r){this.client=e,this.pulse=t,this.delayTimeout=n,this.logger=r,this.interval=null,this.resetPromise=null,this.events=new Map,this.delayId=z()}return e.prototype.heartbeat=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,c,d=this;return u(this,function(u){switch(u.label){case 0:if(0===this.events.size)return this.stop(),[2,[]];e=[],t=function(t){var r=t.event_type,i=t.event_properties,o=a(t,["event_type","event_properties"]),s=n.client.track(r,i,o).promise;if(n.isInstantEvent(t)){var u=t.insert_id;s.finally(function(){return d.events.delete(u)})}e.push(s)},n=this;try{for(r=l(this.events.values()),i=r.next();!i.done;i=r.next())o=i.value,t(o)}catch(e){s={error:e}}finally{try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(s)throw s.error}}return[4,Promise.all(e)];case 1:return[2,u.sent()]}})})},e.prototype.resetHeartbeat=function(){return s(this,void 0,void 0,function(){var e=this;return u(this,function(t){switch(t.label){case 0:return this.resetPromise?[4,this.resetPromise]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return this.interval&&clearInterval(this.interval),this.interval=setInterval(function(){e.heartbeat()},this.pulse),this.resetPromise=new Promise(function(t){setTimeout(function(){t(e.heartbeat())},0)}),this.resetPromise.finally(function(){return e.resetPromise=null}),[4,this.resetPromise]}})})},e.prototype.isInstantEvent=function(e){return Boolean(e.insert_id&&!e.delay.timeout)},e.prototype.checkEventSizeLimit=function(e){var t;return!(JSON.stringify(d([],c(this.events.values()),!1)).length>4e4)||(null===(t=this.logger)||void 0===t||t.warn("Heartbeat: events size limit reached, rejecting event with id=".concat(e.insert_id)),e.insert_id&&this.events.delete(e.insert_id),!1)},e.prototype.track=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e.insert_id?(this.events.set(e.insert_id,o(o({},e),{delay:e.delay||{id:this.delayId,timeout:this.delayTimeout}})),this.checkEventSizeLimit(e)?[4,this.resetHeartbeat()]:[2]):[2,new Error("insert_id is required on events tracked with heartbeat")];case 1:return[2,t.sent().find(function(t){return t.event.insert_id===e.insert_id})]}})})},e.prototype.trackNoDelay=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){return e.delay={id:this.delayId},[2,this.track(e)]})})},e.prototype.update=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){return e.insert_id&&this.events.has(e.insert_id)&&(t=this.events.get(e.insert_id),this.events.set(e.insert_id,o(o({},e),{delay:{id:this.delayId,timeout:this.delayTimeout}})),!this.checkEventSizeLimit(e)&&t)?(this.events.set(e.insert_id,t),[2]):[2]})})},e.prototype.stop=function(){this.interval&&clearInterval(this.interval),this.interval=null,this.events.clear()},e}(),Se=new Map;var ke=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:Te(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),Te=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},xe=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}(),Pe=function(){return Pe=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},Pe.apply(this,arguments)};function _e(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 Ie(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}"function"==typeof SuppressedError&&SuppressedError;var Ae=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=_e(["string","number","boolean","undefined"]),a=o.next();!a.done;a=o.next()){if(a.value===i)return e===t}}catch(e){n={error:e}}finally{try{a&&!a.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 s=Array.isArray(e),u=Array.isArray(t);if(s!==u)return!1;if(!s||!u){var l=Object.keys(e).sort(),c=Object.keys(t).sort();if(!Ae(l,c))return!1;var d=!0;return Object.keys(e).forEach(function(n){Ae(e[n],t[n])||(d=!1)}),d}for(var f=0;f<e.length;f++)if(!Ae(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 Oe=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=Pe({},this.identity.userProperties),n=Pe(Pe({},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,a,s,u=n.userProperties||{};try{for(var l=_e(Object.entries(e)),c=l.next();!c.done;c=l.next()){var d=Ie(c.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var p=(i=void 0,_e(Object.entries(v))),h=p.next();!h.done;h=p.next()){var g=Ie(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=(a=void 0,_e(Object.keys(v))),w=b.next();!w.done;w=b.next()){delete u[m=w.value]}}catch(e){a={error:e}}finally{try{w&&!w.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return Pe({},this.identity)},e.prototype.setIdentity=function(e){var t=Pe({},this.identity);this.identity=Pe({},e),Ae(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}(),Ce="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,Re=function(){function e(){this.identityStore=new Oe,this.eventBridge=new xe,this.applicationContextProvider=new ke}return e.getInstance=function(t){return Ce.analyticsConnectorInstances||(Ce.analyticsConnectorInstances={}),Ce.analyticsConnectorInstances[t]||(Ce.analyticsConnectorInstances[t]=new e),Ce.analyticsConnectorInstances[t]},e}(),De=function(e){return void 0===e&&(e=h),Re.getInstance(e)},Le=function(){function e(){this.name="identity",this.type="before",this.identityStore=De().identityStore}return e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t;return u(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 u(this,function(t){return e.instanceName&&(this.identityStore=De(e.instanceName).identityStore),[2]})})},e}(),Ne=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},Me=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[v,t,e.substring(0,n)].filter(Boolean).join("_")},je=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:""},Ue=function(){var e,t=B();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=Fe(n[0]),i=Fe(n[1]);return i?(e[r]=i,e):e},{}):{}},Fe=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},qe=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},Be=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},He=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},ze=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Ve=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){return u(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 u(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 u(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),We=function(){function e(e,t){void 0===t&&(t={}),this.options=o({},e),this.config=t}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r,i,a=this;return u(this,function(s){switch(s.label){case 0:return t="AMP_TEST",n=o({},this.options),r=new e(n),i=String(Date.now()),[4,r.transaction(t,function(e){var n,r;try{e.set(i);var o=e.get()===i;return!o&&a.config.diagnosticsClient&&(null===(n=a.config.diagnosticsClient)||void 0===n||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:i,sync:!0})),o}catch(e){if(a.config.diagnosticsClient){var s=e instanceof Error?e.message:String(e);null===(r=a.config.diagnosticsClient)||void 0===r||r.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:i,error:s,sync:!0})}return!1}finally{e.set(null)}})];case 1:return[2,s.sent()]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}})})},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=$e(t);return void 0===n?void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)):JSON.parse(n)}catch(n){return void console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t))}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return s(this,void 0,void 0,function(){var r,i,o,a,s,c,d,f,v;return u(this,function(u){switch(u.label){case 0:r=B(),i=r,u.label=1;case 1:return u.trys.push([1,4,,5]),(o=null==i?void 0:i.cookieStore)?[4,o.getAll(e)]:[3,3];case 2:if(a=u.sent()){a.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:a.map(function(e){return e.domain})}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(s=l(a),c=s.next();!c.done;c=s.next())if(d=c.value,Ke(d.domain,this.options.domain))return[2,d.value]}catch(e){f={error:e}}finally{try{c&&!c.done&&(v=s.return)&&v.call(s)}finally{if(f)throw f.error}}}u.label=3;case 3:return[3,5];case 4:return u.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t,n,r=this,i=B(),o=(null!==(n=null===(t=null==i?void 0:i.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[]).filter(function(t){return 0===t.indexOf(e+"=")}),a=void 0,s=this.config.duplicateResolverFn;if("function"==typeof s&&o.length>1&&(a=o.find(function(t){var n;try{var i=s(t.substring(e.length+1));return i||null===(n=r.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}})),a||(a=o[0]),a)return a.substring(e.length+1)},e.prototype.set=function(e,t){return s(this,void 0,void 0,function(){return u(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){var n;try{var r=B();if(!r||!r.document||"function"!=typeof r.btoa||"function"!=typeof r.encodeURIComponent)return;var i=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=null!==t?i:-1,a=void 0;if(o){var s=new Date;s.setTime(s.getTime()+24*o*60*60*1e3),a=s}var u="".concat(e,"=").concat(r.btoa(r.encodeURIComponent(JSON.stringify(t))));a&&(u+="; expires=".concat(a.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)),r.document.cookie=u}catch(t){var l=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return u(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 u(this,function(e){return[2]})})},e.isDomainWritable=function(t){return s(this,void 0,void 0,function(){var n,r;return u(this,function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];n="AMP_TLDTEST",r=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.transaction(n,function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}})];case 2:return[2,!!i.sent()];case 3:return i.sent(),[2,!1];case 4:return[2]}})})},e.prototype.transaction=function(e,t){return s(this,void 0,void 0,function(){var n,r,i=this;return u(this,function(o){switch(o.label){case 0:if(n=function(){var e,t=B();return null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.locks}(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,r()];case 4:return[2]}})})},e.cachedTlds={},e}(),$e=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)},Ke=function(e,t){if(""===e&&""===t)return!0;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()},Ge=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[v,t,e.substring(0,n)].filter(Boolean).join("_")},Je=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 u(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 u(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 u(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 u(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 u(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 u(this,function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]})})},e}(),Ye="tags",Xe="counters",Qe="histograms",Ze="events",et="internal",tt="last_flush_timestamp",nt=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=B())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return s(this,void 0,void 0,function(){return u(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(){var t=r.result;t?e.createTables(t):e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.")}})},e.prototype.createTables=function(e){(e.objectStoreNames.contains(Ye)||e.createObjectStore(Ye,{keyPath:"key"}),e.objectStoreNames.contains(Xe)||e.createObjectStore(Xe,{keyPath:"key"}),e.objectStoreNames.contains(Qe)||e.createObjectStore(Qe,{keyPath:"key"}),e.objectStoreNames.contains(Ze))||e.createObjectStore(Ze,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(et)||e.createObjectStore(et,{keyPath:"key"})},e.prototype.setTags=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Ye],"readwrite"),r=n.objectStore(Ye),[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=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Xe],"readwrite"),r=n.objectStore(Xe),[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],a=r.get(n);a.onsuccess=function(){var e=a.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)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}})})];case 2:return i=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Qe],"readwrite"),r=n.objectStore(Qe),[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],a=r.get(n);a.onsuccess=function(){var e,t=a.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)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}})})];case 2:return i=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Ze],"readwrite"),r=n.objectStore(Ze),[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=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=a.sent(),r=n.transaction([et],"readwrite"),i=r.objectStore(et),[2,new Promise(function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var a=i.put({key:e,value:t});a.onsuccess=function(){return n()},a.onerror=function(){return o(new Error("Failed to set internal value"))}})];case 2:return o=a.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 u(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([et],"readonly"),r=n.objectStore(et),[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 u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(tt)];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 u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(tt,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,a,s;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=u.sent(),t=e.transaction([Ye,Xe,Qe,Ze],"readwrite"),[4,Promise.all([this.getAllFromStore(t,Ye),this.getAllFromStore(t,Xe),this.getAllFromStore(t,Qe),this.getAllFromStore(t,Ze)])];case 2:return n=c.apply(void 0,[u.sent(),4]),r=n[0],i=n[1],o=n[2],a=n[3],[4,Promise.all([this.clearTable(t,Xe),this.clearTable(t,Qe),this.clearTable(t,Ze)])];case 3:return u.sent(),[2,{tags:r,counters:i,histogramStats:o,events:a}];case 4:return s=u.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",s),[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}(),rt="__AMPLITUDE_SCRIPT_URL__",it=function(){var e=B();if(!e)return[];var t=e[rt];return Array.isArray(t)?t:"string"==typeof t?[t]:[]},ot=function(e){var t,n,r=it();if(0!==r.length)try{for(var i=l(r),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.filename&&e.filename.includes(a))return"filename";if(e.stack&&e.stack.includes(a))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},at=function(e){var t,n;try{var r=new URL(e,null===(n=null===(t=B())||void 0===t?void 0:t.location)||void 0===n?void 0:n.origin);return r.origin+r.pathname}catch(e){return}},st=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},ut=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},lt=3e5,ct=1e4,dt=function(){function e(e,t,n,r,i){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=o({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=He(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,i?this.storage=i:nt.isSupported()?this.storage=new nt(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=B();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",o({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=ot({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=st(i),a=ot({filename:o,stack:i});a&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:ut(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})},!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>=ct?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>=ct?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>=ct)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})},lt))},e.prototype.saveAllDataToStorage=function(){return s(this,void 0,void 0,function(){var e,t,n,r;return u(this,function(i){switch(i.label){case 0:return this.storage?(e=o({},this.inMemoryTags),t=o({},this.inMemoryCounters),n=o({},this.inMemoryHistograms),r=d([],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 i.sent(),[2]}})})},e.prototype._flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,a,s,l,c;return u(this,function(u){switch(u.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return u.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=u.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}),a={},n.forEach(function(e){a[e.key]=e.value}),s={},r.forEach(function(e){s[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),l=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(a).length&&0===Object.keys(s).length&&0===l.length?[2]:(c={tags:o,histogram:s,counters:a,events:l},this.fetch(c),[2])}})})},e.prototype.fetch=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!B())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 u(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(lt),[2]):(n=e-t)>=lt?(this._flush(),[2]):(this._setFlushTimer(lt-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=He(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),ft=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,a,s,u,l,c,d,f,v,p,h,g,m,y,b,w,E,S;if("object"!=typeof e)return null;var k=e.code||0,T=this.buildStatus(k);switch(T){case j.Success:return{status:T,statusCode:k,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 j.Invalid:return{status:T,statusCode:k,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(s=e.events_with_missing_fields)&&void 0!==s?s:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l:0,exceededDailyQuotaDevices:null!==(c=e.exceeded_daily_quota_devices)&&void 0!==c?c:{},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 j.PayloadTooLarge:return{status:T,statusCode:k,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case j.RateLimit:return{status:T,statusCode:k,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 j.Timeout:default:return{status:T,statusCode:k}}},e.prototype.buildStatus=function(e){return de(e)?j.Success:429===e?j.RateLimit:413===e?j.PayloadTooLarge:408===e?j.Timeout:e>=400&&e<500?j.Invalid:e>=500?j.Failed:j.Unknown},e}();function vt(){return"undefined"!=typeof CompressionStream}function pt(e){return s(this,void 0,void 0,function(){var t,n;return u(this,function(r){switch(r.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),n=new Blob([e]).stream().pipeThrough(new t("gzip")),[4,new Response(n).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}})})}var ht=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}();var gt=401,mt=403,yt=429,bt=function(){function e(e,t,n,r,i){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,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 ht(e,t),this.customFetch=i}return e.prototype.subscribe=function(e,t,n){var r=z(),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 u(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.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null}),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 u(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 u(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,a,s,l=this;return u(this,function(c){switch(c.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,s,c,d,f,v,p,h;return u(this,function(u){switch(u.label){case 0:i=!0,a=new AbortController,s=setTimeout(function(){return a.abort()},t),u.label=1;case 1:return u.trys.push([1,10,11,12]),c=o.getUrlParams(),d={Accept:"*/*"},o.customFetch?[4,(g=o.customFetch({url:c,method:"GET",headers:d,signal:a.signal}),m=a.signal,new Promise(function(e,t){var n=function(){var e=new Error("Remote config custom fetch aborted by timeout");e.name="AbortError",t(e)};m.addEventListener("abort",n,{once:!0}),g.then(function(t){m.removeEventListener("abort",n),e(t)},function(e){m.removeEventListener("abort",n),t(e)})}))]:[3,3];case 2:return v=u.sent(),[3,5];case 3:return[4,fetch(c,{method:"GET",headers:d,signal:a.signal})];case 4:v=u.sent(),u.label=5;case 5:return(f=v).ok||f.status>=200&&f.status<300?[3,7]:[4,f.text()];case 6:return p=u.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(f.status,": ").concat(p)),f.status===gt||f.status===mt?(o.logger.error("Remote config client fetch failed with ".concat(f.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):f.status>=400&&f.status<500&&f.status!==yt&&(i=!1),[3,9];case 7:return[4,f.json()];case 8:return[2,{value:{remoteConfig:u.sent(),lastFetch:new Date}}];case 9:return[3,12];case 10:return(h=u.sent())instanceof Error&&"AbortError"===h.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: "),h),[3,12];case 11:return clearTimeout(s),[7];case 12:return i?r<e-1?[4,new Promise(function(e){return setTimeout(e,l.getJitterDelay(n))})]:[3,14]:[2,"break"];case 13:u.sent(),u.label=14;case 14:return[2]}var g,m})},o=this,a=0,c.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(s=c.sent()))return[2,s.value];if("break"===s)return[3,4];c.label=3;case 3:return a++,[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}(),wt=B(),Et=null==wt?void 0:wt.console,St={},kt={},Tt=!1;var xt,Pt={addListener:function(e,t){var n,r=(n=e,!!Et&&"function"==typeof Et[n]&&(kt[n]||(kt[n]=Et[n],Et[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(St[n]&&!Tt){Tt=!0;var r=St[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return Tt=!1,kt[n].apply(Et,e)}),!0));if(!r)return new Error("Console override failed");St[e]?St[e].push(t):St[e]=[t]},removeListener:function(e){var t,n;try{for(var r=l(Object.values(St)),i=r.next();!i.done;i=r.next())for(var o=i.value,a=o.length-1;a>=0;a--)if(o[a]===e){o.splice(a,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=l(Object.entries(kt)),r=n.next();!r.done;r=n.next()){var i=c(r.value,2),o=i[0],a=i[1];a&&(Et[o]=a)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}kt={},St={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(xt||(xt={}));var _t=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],It="data-amp-track-",At=["div","span","h1","h2","h3","h4","h5","h6"],Ot=d(['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),Ct=Ot,Rt=Ot,Dt=["*"];function Lt(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function Nt(e,t,n){e&&Mt({json:e,allowlist:t.map(jt),excludelist:n.map(jt),ancestors:[]})}function Mt(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,a=e.excludelist,s=e.ancestors,u=e.parentObject,f=e.targetKey;i||(i=r);var v=Object.keys(i);try{for(var p=l(v),h=p.next();!h.done;h=p.next()){var g=h.value,m=d(d([],c(s),!1),[g],!1);Lt(i[g])?Ft(m,o)&&!Ft(m,a)||delete i[g]:Mt({json:r,targetObject:i[g],allowlist:o,excludelist:a,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&&u&&f&&delete u[f]}function jt(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function Ut(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(Ut(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&Ut(e,t,n+1,r+1)}function Ft(e,t){return t.some(function(t){return Ut(e,t)})}var qt=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=l(Object.entries(r)),a=o.next();!a.done;a=o.next()){var s=c(a.value,2),u=s[0],d=s[1];i[u]=d}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Gt(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=B();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=Ht(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 u(this,function(n){return 0===e.length?[2,null]:[2,$t(this.body,e,t)]})})},e}(),Bt=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),Gt(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return Ht(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 u(this,function(n){return 0===e.length?[2,null]:[2,$t(this.body,e,t)]})})},e}();function Ht(e,t){var n,r,i,o=B(),a=null==o?void 0:o.TextEncoder;if(a&&null!=e){var s;if("string"==typeof e)s=e,i=(new a).encode(s).length;else if("undefined"!=typeof Blob&&e instanceof Blob)i=(s=e).size;else if("undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams)s=e,i=(new a).encode(s.toString()).length;else if(ArrayBuffer.isView(e))i=(s=e).byteLength;else if(e instanceof ArrayBuffer)i=(s=e).byteLength;else if("undefined"!=typeof FormData&&e instanceof FormData){var u=e,d=0,f=0;try{for(var v=l(u.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 a).encode(m).length;else{if(!("undefined"!=typeof Blob&&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("undefined"!=typeof ReadableStream&&e instanceof ReadableStream)return void(s=e);return i}}var zt,Vt=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}),Gt(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 u(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 u(this,function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,$t(n.sent(),e,t)]}})})},e}(),Wt=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=l(i),a=o.next();!a.done;a=o.next()){var s=c(a.value.split(": "),2),u=s[0],d=s[1];u&&d&&(r[u]=d)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Gt(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 u(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?(Nt(n,e,t),[2,n]):[2,null]})})},e}();function $t(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return Nt(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(zt||(zt={}));var Kt="[REDACTED]",Gt=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,a=t.strategy,s=void 0===a?zt.REMOVE:a,u=d([],c(D),!1),f={},v=function(t){var n=t.toLowerCase();u.find(function(e){return e.toLowerCase()===n})?s===zt.REDACT&&(f[t]=Kt):o.find(function(e){return e.toLowerCase()===n})?f[t]=e[t]:s===zt.REDACT&&(f[t]=Kt)};try{for(var p=l(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},Jt=function(){function e(e,t,n,r,i,o,a,s,u,l,c){void 0===a&&(a=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=a,this.duration=s,this.responseWrapper=u,this.error=l,this.endTime=c}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(d([],c(R),!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(d([],c(R),!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 Yt=function(e,t){void 0===t&&(t=z()),this.callback=e,this.id=t};function Xt(e){try{e()}catch(e){}}var Qt=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=B();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=B();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,a,s,u,l,c,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===(s=null===(a=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===a?void 0:a.prototype)||void 0===s?void 0:s.send,p=null===(c=null===(l=null===(u=this.globalScope)||void 0===u?void 0:u.XMLHttpRequest)||void 0===l?void 0:l.prototype)||void 0===c?void 0:c.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){try{n.callback(e)}catch(e){Xt(function(){var n;null===(n=t.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,a){var s;if(void 0!==o&&void 0!==a){var u,l,c,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?u=null===(s=null==t?void 0:t.toString)||void 0===s?void 0:s.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&&(l=r.status),i&&(c={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},l=0);var v=Math.floor(performance.now()-a),p=Math.floor(o+v),h=new Jt(e,d,o,o,u,n,l,v,r,c,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,a,s=this;return u(this,function(u){switch(u.label){case 0:try{t=this.getTimestamps()}catch(e){Xt(function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)})}u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),o=a,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new qt(r):void 0,i?new Vt(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){Xt(function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.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;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&&Xt(function(){var n;return null===(n=t.logger)||void 0===n?void 0:n.debug("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 i=this.globalScope.XMLHttpRequest.prototype,a=this;i.open=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=c(n,2),s=i[0],u=i[1];try{this.$$AmplitudeAnalyticsEvent=o({method:s,url:null===(e=null==u?void 0:u.toString)||void 0===e?void 0:e.call(u),headers:{}},a.getTimestamps())}catch(e){Xt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr open",e)})}return t.apply(this,n)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,o=e.createXhrJsonParser(this,a),s=t[0],u=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),n=new Wt(i.status,e,t?parseInt(t,10):void 0,o),r=i.$$AmplitudeAnalyticsEvent.headers,l=new Bt(s,r);u.status=i.status,a.handleNetworkRequestEvent("xhr",{url:u.url,method:u.method},l,n,void 0,u.startTime,u.durationStart)}catch(e){Xt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling xhr send",e)})}}),n.apply(i,t)},i.setRequestHeader=function(e,t){try{var n=this.$$AmplitudeAnalyticsEvent;n&&(n.headers[e]=t)}catch(e){Xt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)})}r.apply(this,[e,t])}}},e}(),Zt=new Qt,en=function(){function e(){}return e.prototype.parse=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return[2,o(o(o(o({},C),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=Ue();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=Ue();return(e={})[w]=t[w],e[E]=t[E],e[S]=t[S],e[k]=t[k],e[T]=t[T],e[x]=t[x],e[P]=t[P],e[_]=t[_],e[I]=t[I],e[A]=t[A],e[O]=t[O],e},e}(),tn="data-amp-mask",nn="*****",rn=/\b(?:\d[ -]*?){13,16}\b/,on=/(\d{3}-?\d{2}-?\d{4})/g,an=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,sn=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(rn,nn)).replace(on,nn)).replace(an,nn);try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,nn)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},un=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(tn)?nn:e?e(document.title):document.title},ln={};Object.defineProperty(ln,"__esModule",{value:!0}),ln.Observable=void 0;const cn=e=>Boolean(Symbol[e]),dn=e=>cn(e)?Symbol[e]:"@@"+e,fn=dn("iterator"),vn=dn("observable"),pn=dn("species");function hn(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function gn(e){let t=e.constructor;return void 0!==t&&(t=t[pn],null===t&&(t=void 0)),void 0!==t?t:Tn}function mn(e){mn.log?mn.log(e):setTimeout(()=>{throw e})}function yn(e){Promise.resolve().then(()=>{try{e()}catch(e){mn(e)}})}function bn(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=hn(t,"unsubscribe");e&&e.call(t)}}catch(e){mn(e)}}function wn(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function En(e,t,n){e._state="running";let r=e._observer;try{let i=hn(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(wn(e),!i)throw n;i.call(r,n);break;case"complete":wn(e),i&&i.call(r)}}catch(e){mn(e)}"closed"===e._state?bn(e):"running"===e._state&&(e._state="ready")}function Sn(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 yn(()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let 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})}}class kn{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){Sn(n,"next",e)},error(e){Sn(n,"error",e)},complete(){Sn(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(wn(this),bn(this))}}class Tn{constructor(e){if(!(this instanceof Tn))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new kn(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(gn(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(gn(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=gn(this),n=arguments.length>1,r=!1,i=arguments[1];return new t(t=>this.subscribe({next(o){let a=!r;if(r=!0,!a||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=gn(this);return new t(n=>{let r,i=0;return function o(a){r=a.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=gn(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let a=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(a);e>=0&&r.splice(e,1),o()}});r.push(a)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[vn](){return this}static from(e){let t="function"==typeof this?this:Tn;if(null==e)throw new TypeError(e+" is not an object");let n=hn(e,vn);if(n){let r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return function(e){return e instanceof Tn}(r)&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(cn("iterator")&&(n=hn(e,fn),n))return new t(t=>{yn(()=>{if(!t.closed){for(let r of n.call(e))if(t.next(r),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{yn(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:Tn)(t=>{yn(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})})}static get[pn](){return this}}ln.Observable=Tn,Object.defineProperty(Tn,Symbol("extensions"),{value:{symbol:vn,hostReportError:mn},configurable:!0});var xn=ln.Observable;function Pn(e,t){return new xn(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 _n(e,t){return new xn(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=l(i),o=n.next();!o.done;o=n.next()){var a=o.value;try{a.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()},a=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 a(e),a(t),o})}function In(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new xn(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.next)||void 0===i||i.call(s,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var a=l(t),s=a.next();!s.done;s=a.next()){var u=s.value;null===(o=u.error)||void 0===o||o.call(u,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.complete)||void 0===i||i.call(s)}}catch(t){e={error:t}}finally{try{a&&!a.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)}})}var An,On="https://app.amplitude.com",Cn={US:On,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var Rn="__AMPLITUDE_MESSENGER_INSTANCE__",Dn="__AMPLITUDE_MESSENGER__",Ln=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?On:t;this[An]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,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,a){r.requestCallbacks[i]={resolve:t,reject:a},r.notify(o),n.timeout>0&&setTimeout(function(){a(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.registerActionHandler=function(e,t){var n,r,i,o;this.actionHandlers.has(e)&&(null===(o=null===(i=this.logger)||void 0===i?void 0:i.warn)||void 0===o||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var a=this.pendingMessages.get(e);if(a){this.pendingMessages.delete(e);try{for(var s=l(a),u=s.next();!u.done;u=s.next()){t(u.value)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return s(this,void 0,void 0,function(){var t,n,r;return u(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):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)}})}(e).then(function(){}),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,a=i.endpoint;o&&(this.logger=o),a&&this.endpoint===On&&(this.endpoint=a),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,a;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 s=e.data,u=null==s?void 0:s.action;if(u)if("id"in s&&s.id)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(s);else{if("ping"===u)return void r.notify({action:"pong"});var l=r.actionHandlers.get(u);if(l)l(s.data);else{var c=null!==(a=r.pendingMessages.get(u))&&void 0!==a?a:[];c.push(s.data),r.pendingMessages.set(u,c)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=B();(null==e?void 0:e[Dn])===this&&delete e[Dn]},e}();function Nn(e){var t,n=B(),r=null==n?void 0:n[Dn];if("object"==typeof(t=r)&&null!==t&&Rn in t&&!0===t[Rn])return r;var i=new Ln(e);return n&&(n[Dn]=i),i}An=Rn;var Mn="__AMPLITUDE_BACKGROUND_CAPTURE__";var jn={always:"always",ifEmptyCampaign:"ifEmptyCampaign"};function Un(e,t){var n=0;if(Number.isFinite(e)&&Number.isFinite(t)&&t>0){var r=e/t*100;n=Math.min(100,Math.max(0,r))}return n}function Fn(e,t){var n=e.currentTime,r=e.duration;return o({duration:r,start_time:n,last_position:n,percent_completed:Un(n,r)},void 0!==t?{stop_reason:t}:{})}function qn(e){return{mux_playback_id:e.getAttribute("playback-id"),mux_video_id:e.getAttribute("metadata-video-id"),mux_video_title:e.getAttribute("metadata-video-title")}}function Bn(e,t,n,r){return s(this,void 0,void 0,function(){var i,a,s,l,d;return u(this,function(u){switch(u.label){case 0:return[4,Promise.all([new Promise(function(t){return e.getDuration(t)}),new Promise(function(t){return e.getCurrentTime(t)})])];case 1:if(i=c.apply(void 0,[u.sent(),2]),a=i[0],s=i[1],l={},"mux"===n){d=void 0;try{d=new URL(t.getAttribute("src")),l.mux_video_title=d.searchParams.get("metadata-video-title"),l.mux_video_id=d.searchParams.get("metadata-video-id"),l.mux_playback_id=d.pathname.split("/").pop()}catch(e){}}return[2,o(o({duration:a,start_time:s,last_position:s,percent_completed:Un(s,a)},void 0!==r?{stop_reason:r}:{}),l)]}})})}function Hn(e,t,n){void 0===n&&(n=null);var r=[],i=function(){var i=e.elem,o=!1,a=function(){Bn(e,i,n).then(function(e){t.onPlay(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'play' handler: ".concat(e))})};e.on("play",a),r.push(function(){return e.off("play",a)});var l=function(){Bn(e,i,n,"paused").then(function(e){t.onPause(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'pause' handler: ".concat(e))})};e.on("pause",l),r.push(function(){return e.off("pause",l)});var c=function(){Bn(e,i,n,"ended").then(function(e){t.onEnded(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'ended' handler: ".concat(e))})};e.on("ended",c),r.push(function(){return e.off("ended",c)});var d=function(){o=!0,Bn(e,i,n,"seeking").then(function(e){t.onSeeking(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'seeking' handler: ".concat(e))})};e.on("seeking",d),r.push(function(){return e.off("seeking",d)});var f=function(){o=!1,Bn(e,i,n).then(function(e){t.onSeeked(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'seeked' handler: ".concat(e))})};e.on("seeked",f),r.push(function(){return e.off("seeked",f)});var v=function(){(function(e){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){return e.getCurrentTime(t)})];case 1:return[2,{currentTime:t.sent()}]}})})})(e).then(function(e){var n={position:e.currentTime,isSeeking:o};t.onTimeUpdate(n)}).catch(function(e){t.onError("Error getting iframe metadata from 'timeupdate' handler: ".concat(e))})};e.on("timeupdate",v),r.push(function(){return e.off("timeupdate",v)})};return e.on("ready",i),function(){e.off("ready",i),r.forEach(function(e){return e()})}}var zn=function(){function e(e){var t=e.videoEl,n=e.onStateChange,r=e.vendor,i=e.isEmbedded,a=this;this.state={playbackState:"paused"},this.waitingInterval=null,this.handler={onPlay:function(e){a.updatePlaybackState("playing",e)},onPause:function(e){a.updatePlaybackState("paused",e)},onEnded:function(e){a.updatePlaybackState("ended",e)},onSeeking:function(){var e=o(o({},a.state),{isSeeking:!0});a.updateState(e)},onSeeked:function(e){var t=o(o({},a.state),{isSeeking:!1,position:e.last_position});a.updateState(t)},onError:function(e){a.updateStateWithError(e)},onTimeUpdate:function(e){a.updateTime(e)}},this.onStateChange=n,this.untrack=i?Hn(t,this.handler,r):function(e,t,n){var r=function(){var r=o(o({},Fn(e)),"mux"===n?qn(e):{});t.onPlay(r)};e.addEventListener("play",r);var i=function(){var r=o(o({},Fn(e,"paused")),"mux"===n?qn(e):{});t.onPause(r)};e.addEventListener("pause",i);var a=function(){var r=o(o({},Fn(e,"ended")),"mux"===n?qn(e):{});t.onEnded(r)};e.addEventListener("ended",a);var s=function(){var r=o(o({},Fn(e,"seeking")),"mux"===n?qn(e):{});t.onSeeking(r)};e.addEventListener("seeking",s);var u=function(){var r=o(o({},Fn(e)),"mux"===n?qn(e):{});t.onSeeked(r)};e.addEventListener("seeked",u);var l=function(){var n=e,r={position:e.currentTime,isSeeking:!!n.seeking};t.onTimeUpdate(r)};return e.addEventListener("timeupdate",l),function(){e.removeEventListener("play",r),e.removeEventListener("pause",i),e.removeEventListener("ended",a),e.removeEventListener("seeking",s),e.removeEventListener("seeked",u),e.removeEventListener("timeupdate",l)}}(t,this.handler,r)}return e.prototype.stateChangeHandler=function(e,t){try{this.onStateChange(e,t)}catch(e){}},e.prototype.updateStateWithError=function(e){this.clearWaitingInterval();var t=this.state,n=o(o({},t),{playbackState:"error",errorMessage:e});this.updateState(n)},e.prototype.updatePlaybackState=function(e,t){var n=this,r=o(o({},this.state),{playbackState:e,lastEvent:t,position:t.last_position});if(this.updateState(r),this.clearWaitingInterval(),"playing"===e){var i=this.state.position;this.waitingInterval=setInterval(function(){var e=n.state.position;"playing"===n.state.playbackState&&"number"==typeof i&&i===e&&n.updateState(o(o({},n.state),{playbackState:"waiting"})),i=e},1e3)}},e.prototype.clearWaitingInterval=function(){this.waitingInterval&&(clearInterval(this.waitingInterval),this.waitingInterval=null)},e.prototype.updateTime=function(e){var t,n,r=this.state.lastEvent,i="waiting"===this.state.playbackState,a="playing"===this.state.playbackState;if(r&&(a||i)){var s=e.isSeeking||this.state.isSeeking,u=null!==(t=this.state.position)&&void 0!==t?t:0,l=e.position;if(s)this.state=o(o({},this.state),{position:l});else{var c=l-u,d=o(o({},this.state),{playbackState:"playing",position:l,watchTime:(null!==(n=this.state.watchTime)&&void 0!==n?n:0)+c});this.updateState(d)}}},e.prototype.updateState=function(e){var t=this.state;this.state=e,this.stateChangeHandler(t,e)},e.prototype.destroy=function(){this.clearWaitingInterval(),this.untrack()},e}();function Vn(e,t,n){var r,i,o=[];try{for(var a=l(null!=t?t:[]),s=a.next();!s.done;s=a.next()){var u=s.value;try{o.push(new RegExp(u))}catch(e){n.warn("Invalid regex pattern: ".concat(u),e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e.concat(o)}function Wn(e){var t,n,r,i,o,a,s,u,f,v,p,h;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var g=Object.keys(e);try{for(var m=l(g),y=m.next();!y.done;y=m.next()){var b=y.value;try{var w=e[b];"boolean"==typeof(null==w?void 0:w.enabled)&&(w.enabled?(delete w.enabled,0===Object.keys(w).length&&(e[b]=!0)):e[b]=!1),Wn(w)}catch(e){}}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}try{if(null===(f=null===(u=null===(s=e.autocapture)||void 0===s?void 0:s.networkTracking)||void 0===u?void 0:u.captureRules)||void 0===f?void 0:f.length)try{for(var E=l(e.autocapture.networkTracking.captureRules),S=E.next();!S.done;S=E.next()){var k=S.value;try{for(var T=(o=void 0,l(["responseHeaders","requestHeaders"])),x=T.next();!x.done;x=T.next()){var P=x.value,_=null!==(v=k[P])&&void 0!==v?v:{},I=_.captureSafeHeaders,A=_.allowlist;(I||A)&&(void 0===A||Array.isArray(A)?k[P]=d(d([],c(I?R:[]),!1),c(null!=A?A:[]),!1):delete k[P])}}catch(e){o={error:e}}finally{try{x&&!x.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{S&&!S.done&&(i=E.return)&&i.call(E)}finally{if(r)throw r.error}}}catch(e){}var O=null===(p=e.autocapture)||void 0===p?void 0:p.frustrationInteractions;O&&(O.rageClick&&(O.rageClicks=O.rageClick,delete O.rageClick),O.deadClick&&(O.deadClicks=O.deadClick,delete O.deadClick));try{var C=null===(h=e.autocapture)||void 0===h?void 0:h.elementInteractions;if(C&&"object"==typeof C&&(!0===C.viewportContentUpdated&&(C.viewportContentUpdated={}),!1===C.viewportContentUpdated&&(C.viewportContentUpdated={enabled:!1}),void 0!==C.exposureDuration)){var D=C.viewportContentUpdated;void 0===D?C.viewportContentUpdated={exposureDuration:C.exposureDuration}:"object"==typeof D&&void 0===D.exposureDuration&&!1!==D.enabled&&(D.exposureDuration=C.exposureDuration),delete C.exposureDuration}}catch(e){}}}var $n=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])&&(!function(){var e,t,n=B();return"string"==typeof(null===(t=null===(e=null==n?void 0:n.chrome)||void 0===e?void 0:e.runtime)||void 0===t?void 0:t.id)}()||!!(null==e?void 0:e[t]))},Kn=function(e){return $n(e,"attribution")},Gn=function(e){return $n(e,"formInteractions")},Jn=function(e){return $n(e,"pageViews")},Yn=function(e){return $n(e,"sessions")},Xn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},Qn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},Zn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},er=function(e){if("object"==typeof e.autocapture){var t=e.autocapture.performanceTracking;return!0===t?{mainThreadBlock:!0}:"object"==typeof t&&null!==t?t:void 0}},tr=function(e){if(Qn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},nr=function(e){if(Zn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},rr=function(e){if(Xn(e.autocapture)){var t=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?t=e.autocapture.networkTracking:e.networkTrackingOptions&&(t=e.networkTrackingOptions),o(o({},t),{captureRules:(n=null==t?void 0:t.captureRules,r=e.loggerProvider,null==n?void 0:n.map(function(e){var t,n;if((null===(t=e.urls)||void 0===t?void 0:t.length)&&(null===(n=e.hosts)||void 0===n?void 0:n.length)){var i=JSON.stringify(e.hosts),a=JSON.stringify(e.urls);return null==r||r.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(i,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),o(o({},e),{hosts:void 0})}return e}))})}var n,r},ir=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return Jn(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}},or=function(e,t){ar(e,t)},ar=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,a=r.resolve,s=e&&e[i];if("function"==typeof s){var u=s.apply(e,o);"function"==typeof a&&a(null==u?void 0:u.promise)}}return e},sr=function(e){return e&&void 0!==e._q};var ur="2.46.0-video-analytics-2.0",lr="amplitude-ts-sdk-script",cr=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(lr,"/").concat(ur),"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){var t,n;return s(this,void 0,void 0,function(){var r,i,a;return u(this,function(s){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,a=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=a,e.time||(this.config.lastEventTime=r),[2,o(o(o(o(o(o(o(o({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:je()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:z(),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:a,library:this.library,user_agent:this.userAgent})]})})},e}(),dr=1e3,fr=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=B())||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 n(t,e),t.prototype.set=function(t,n){var r;return s(this,void 0,void 0,function(){var i;return u(this,function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>dr?(i=n.length-dr,[4,e.prototype.set.call(this,t,n.slice(0,dr))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(dr,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},t}(Je),vr=function(e){function t(){var t;return e.call(this,null===(t=B())||void 0===t?void 0:t.sessionStorage)||this}return n(t,e),t}(Je),pr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return n(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),s(this,void 0,void 0,function(){var r=this;return u(this,function(i){return[2,new Promise(function(i,a){"undefined"==typeof XMLHttpRequest&&a(new Error("XHRTransport is not supported."));var d=new XMLHttpRequest;d.open("POST",e,!0),d.onreadystatechange=function(){if(d.readyState===r.state.done){var e=d.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch(e){i(r.buildResponse({code:d.status}))}}};var f={"Content-Type":"application/json",Accept:"*/*"},v=JSON.stringify(t),p=n&&v.length>=2048&&vt(),h=function(e){var t,n;f=o(o({},r.customHeaders),f);try{for(var i=l(Object.entries(f)),a=i.next();!a.done;a=i.next()){var s=c(a.value,2),u=s[0],v=s[1];d.setRequestHeader(u,v)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}d.send(e)};s(r,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return p?[4,pt(v)]:[3,2];case 1:return(e=t.sent())?(f["Content-Encoding"]="gzip",h(e)):h(v),[3,3];case 2:h(v),t.label=3;case 3:return[2]}})}).catch(a)})]})})},t}(ft),hr=function(e){function t(t,n,r){void 0===t&&(t={});var i=e.call(this)||this;return i.customHeaders=t,i.enableKeepalive=!1!==n,i.referrerPolicy=r,i}return n(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),s(this,void 0,void 0,function(){var r,i,a,s,l,c,d,f,v;return u(this,function(u){switch(u.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return r=JSON.stringify(t),i=n&&r.length>=2048&&vt(),a=r,s={"Content-Type":"application/json",Accept:"*/*"},i?[4,pt(r)]:[3,2];case 1:(l=u.sent())&&(s["Content-Encoding"]="gzip",a=l),u.label=2;case 2:return s=o(o({},this.customHeaders),s),c="string"==typeof a?a.length:a.byteLength,d={headers:s,body:a,method:"POST",keepalive:this.enableKeepalive&&c<=16384},this.referrerPolicy&&(d.referrerPolicy=this.referrerPolicy),[4,fetch(e,d)];case 3:return[4,(f=u.sent()).text()];case 4:v=u.sent();try{return[2,this.buildResponse(JSON.parse(v))]}catch(e){return[2,this.buildResponse({code:f.status})]}return[2]}})})},t}(ft),gr=function(e){function t(){return e.call(this)||this}return n(t,e),t.prototype.send=function(e,t,n){return s(this,void 0,void 0,function(){var n=this;return u(this,function(r){return[2,new Promise(function(r,i){var o=B();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var a=JSON.stringify(t);return r(o.navigator.sendBeacon(e,a)?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:a.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(ft),mr=function(e,t,n){return void 0===n&&(n=!0),s(void 0,void 0,void 0,function(){var r,i,o,a,s,l,d,f,p;return u(this,function(u){switch(u.label){case 0:return r=function(e){return"".concat(v.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=u.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:u.sent(),u.label=3;case 3:return o=c(i.split("."),6),a=o[0],s=o[1],l=o[2],d=o[3],f=o[4],p=o[5],[2,{deviceId:a,userId:br(s),sessionId:yr(d),lastEventId:yr(p),lastEventTime:yr(f),optOut:Boolean(l)}]}})})},yr=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},br=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},wr="[Amplitude]",Er="".concat(wr," Form Started"),Sr="".concat(wr," Form Submitted"),kr="".concat(wr," File Downloaded"),Tr="".concat(wr," Content Started"),xr="".concat(wr," Content Stopped"),Pr="session_start",_r="session_end",Ir="".concat(wr," File Extension"),Ar="".concat(wr," File Name"),Or="".concat(wr," Link ID"),Cr="".concat(wr," Link Text"),Rr="".concat(wr," Link URL"),Dr="".concat(wr," Form ID"),Lr="".concat(wr," Form Name"),Nr="".concat(wr," Form Destination"),Mr="cookie",jr="US",Ur=Object.freeze({__proto__:null,get IdentifyOperation(){return r},get SpecialEventType(){return i},get RevenueProperty(){return J},get LogLevel(){return re},get ServerZone(){return xt},OfflineDisabled:null,DEFAULT_CSS_SELECTOR_ALLOWLIST:_t,DEFAULT_DATA_ATTRIBUTE_PREFIX:It,DEFAULT_ACTION_CLICK_ALLOWLIST:At,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:jn}),Fr=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},qr=function(e,t,n,r,i,s){void 0===i&&(i=!0),e.referrer;var u=e.referring_domain,l=a(e,["referrer","referring_domain"]),c=t||{};c.referrer;var d,f=c.referring_domain,v=a(c,["referrer","referring_domain"]),p=n.excludeInternalReferrers;if(p){var h=Hr(p,r);if(!(h instanceof TypeError)&&e.referring_domain&&$r(e.referring_domain,s)){if("always"===h)return zr(h,e.referring_domain,r),!1;if("ifEmptyCampaign"===h&&(d=o(o({},e),{referring_domain:void 0,referrer:void 0}),Object.values(d).every(function(e){return!e})))return zr(h,e.referring_domain,r),!1}}if(Br(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 g=JSON.stringify(l)!==JSON.stringify(v),m=Fr(u||"")!==Fr(f||""),y=!t||g||m;return y?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."),y},Br=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})},Hr=function(e,t){if(!0===e)return jn.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(jn).includes(n))return n;if(void 0===n)return jn.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),new TypeError(r)};function zr(e,t,n){var r="This is not a new campaign because referring_domain=".concat(t," is on the same domain as the current page and it is configured to exclude internal referrers");"always"===e?n.debug(r):"ifEmptyCampaign"===e&&n.debug("".concat(r," with empty campaign parameters"))}var Vr=["ac.in","ac.jp","ac.kr","ac.th","ac.uk","ac.za","appspot.com","asn.au","azurewebsites.net","cloudfront.net","myshopify.com","blogspot.com","co.ca","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.ar","com.au","com.br","com.cn","com.hk","com.in","com.jp","com.kr","com.mx","com.pl","com.sg","com.tr","com.tw","ed.jp","edu.au","edu.br","edu.cn","edu.hk","edu.sg","edu.th","edu.tr","edu.tw","firebaseapp.com","fly.dev","gc.ca","geek.nz","github.io","gitlab.io","go.jp","go.kr","go.th","gob.ar","gob.mx","gov.au","gov.br","gov.cn","gov.hk","gov.in","gov.pl","gov.sg","gov.tr","gov.tw","gov.uk","gov.za","govt.nz","gr.jp","herokuapp.com","id.au","idv.hk","iwi.nz","lg.jp","ltd.uk","maori.nz","me.uk","mil.kr","ne.jp","ne.kr","net.au","net.br","net.cn","net.hk","net.in","net.nz","net.pl","net.sg","net.tr","net.tw","net.za","onrender.com","or.jp","or.kr","or.th","org.ar","org.au","org.br","org.cn","org.hk","org.in","org.mx","org.nz","org.pl","org.sg","org.tw","org.uk","org.za","pages.dev","pe.kr","plc.uk","re.kr","res.in","sch.uk","vercel.app","netlify.app","workers.dev"],Wr=function(e){var t,n,r=e||(null===(n=null===(t=B())||void 0===t?void 0:t.location)||void 0===n?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],a=i[i.length-2];return Vr.find(function(e){return r.endsWith(".".concat(e))})&&(o=i[i.length-2]+"."+i[i.length-1],a=i[i.length-3]),a?"".concat(a,".").concat(o):o},$r=function(e,t){var n=B();if(!n)return!1;var r,i,o,a=(t||"").trim()||Wr(n.location.hostname);return r=e,o=(i=a).startsWith(".")?i:".".concat(i),!!(r.startsWith(".")?r:".".concat(r)).endsWith(o)},Kr=function(e){function t(t,n,r,i,o,a,s,u,l,c,d,f,v,p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A,O,C,R,D,L,N,M,j,U,F,q,B,H,z,V,W){void 0===r&&(r=new Ve),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===l&&(l=5),void 0===c&&(c=30),void 0===d&&(d=Mr),void 0===g&&(g=new oe),void 0===m&&(m=re.Warn),void 0===b&&(b=!1),void 0===w&&(w=!1),void 0===k&&(k=""),void 0===x&&(x=jr),void 0===I&&(I=18e5),void 0===A&&(A=new fr({loggerProvider:g})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===C&&(C="fetch"),void 0===R&&(R=!1),void 0===D&&(D=!0),void 0===F&&(F=!0),void 0===q&&(q=0),void 0===V&&(V=!1);var $,K=this;(K=e.call(this,{apiKey:t,storageProvider:A,transportProvider:Yr(C)})||this).apiKey=t,K.appVersion=n,K.cookieOptions=i,K.defaultTracking=o,K.autocapture=a,K.flushIntervalMillis=u,K.flushMaxRetries=l,K.flushQueueSize=c,K.identityStorage=d,K.ingestionMetadata=f,K.instanceName=v,K.loggerProvider=g,K.logLevel=m,K.minIdLength=y,K.offline=b,K.partnerId=E,K.plan=S,K.serverUrl=k,K.delayedEventsServerUrl=T,K.serverZone=x,K.sessionTimeout=I,K.storageProvider=A,K.trackingOptions=O,K.transport=C,K.useBatch=R,K.fetchRemoteConfig=D,K.networkTrackingOptions=j,K.identify=U,K.enableDiagnostics=F,K.diagnosticsSampleRate=q,K.diagnosticsClient=B,K.remoteConfig=H,K.topLevelDomain=z,K.enableRequestBodyCompression=V,K.customEnrichment=W,K.version=ur,K._optOut=!1,K._cookieStorage=r,K.deviceId=s,K.lastEventId=p,K.lastEventTime=h,K.optOut=w,K.deferredSessionId=_,K.sessionId=P,K.pageCounter=N,K.userId=L,K.debugLogsEnabled=M,K.loggerProvider.enable(M?re.Debug:K.logLevel),K.networkTrackingOptions=j,K.identify=U,K.enableDiagnostics=F,K.diagnosticsSampleRate=q,K.diagnosticsClient=B;var G=null!==($=null==H?void 0:H.fetchRemoteConfig)&&void 0!==$?$:D;return K.remoteConfig=K.remoteConfig||{},K.remoteConfig.fetchRemoteConfig=G,K.fetchRemoteConfig=G,K.topLevelDomain=z||Wr(),K.delayedEventsServerUrl=function(e,t,n){return void 0===n&&(n=jr),t||(e?"".concat(e,"/delayed"):"EU"===n?"https://delayed-events.prod.eu-central-1.amplitude.com/2/httpapi/delayed":"https://delayed-events.prod.us-west-2.amplitude.com/2/httpapi/delayed")}(k,T,x),K}return n(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,void 0!==e&&void 0!==this._deferredSessionId&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof We&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(Me(this.apiKey),e)},t}(se),Gr=function(e,t,n,r,i){return void 0===t&&(t={}),s(void 0,void 0,void 0,function(){var a,s,l,c,d,f,v,p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A,O,C,R,D,L,N,M,j,U,F,q,B,H,V,W,$,K,G,J,Y,X,Q,Z,ee,te,ne,re,ie;return u(this,function(u){switch(u.label){case 0:return a=t.identityStorage||Mr,s="",a!==Mr||(null===(I=t.cookieOptions)||void 0===I?void 0:I.domain)||""===(null===(A=t.cookieOptions)||void 0===A?void 0:A.domain)?[3,2]:[4,Xr(void 0,r)];case 1:s=u.sent(),u.label=2;case 2:return l=o({domain:null!==(C=null===(O=t.cookieOptions)||void 0===O?void 0:O.domain)&&void 0!==C?C:s,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},t.cookieOptions),c={duplicateResolverFn:function(e){var t=$e(e);if(!t)return!1;var n=JSON.parse(t);return Ke(n.cookieDomain,l.domain)},diagnosticsClient:r},d=Jr(t.identityStorage,l,c),[4,mr(e,d,null===(D=null===(R=t.cookieOptions)||void 0===R?void 0:R.upgrade)||void 0===D||D)];case 3:return f=u.sent(),[4,d.get(Me(e))];case 4:return v=u.sent(),p=Ue(),h=p.ampTimestamp?Number(p.ampTimestamp):void 0,g=!h||Date.now()<h,m=null!==(U=null!==(j=null!==(M=null!==(L=t.deviceId)&&void 0!==L?L:g?null!==(N=p.ampDeviceId)&&void 0!==N?N:p.deviceId:void 0)&&void 0!==M?M:null==v?void 0:v.deviceId)&&void 0!==j?j:f.deviceId)&&void 0!==U?U:z(),y=null!==(F=null==v?void 0:v.lastEventId)&&void 0!==F?F:f.lastEventId,b=null!==(q=null==v?void 0:v.lastEventTime)&&void 0!==q?q:f.lastEventTime,w=null!==(H=null!==(B=t.optOut)&&void 0!==B?B:null==v?void 0:v.optOut)&&void 0!==H?H:f.optOut,E=null!==(V=null==v?void 0:v.sessionId)&&void 0!==V?V:f.sessionId,S=null==v?void 0:v.deferredSessionId,k=null!==($=null!==(W=t.userId)&&void 0!==W?W:null==v?void 0:v.userId)&&void 0!==$?$:f.userId,n.previousSessionDeviceId=null!==(K=null==v?void 0:v.deviceId)&&void 0!==K?K:f.deviceId,n.previousSessionUserId=null!==(G=null==v?void 0:v.userId)&&void 0!==G?G:f.userId,T={ipAddress:null===(Y=null===(J=t.trackingOptions)||void 0===J?void 0:J.ipAddress)||void 0===Y||Y,language:null===(Q=null===(X=t.trackingOptions)||void 0===X?void 0:X.language)||void 0===Q||Q,platform:null===(ee=null===(Z=t.trackingOptions)||void 0===Z?void 0:Z.platform)||void 0===ee||ee},x=null==v?void 0:v.pageCounter,P=null==v?void 0:v.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(_=new Kr(e,t.appVersion,d,l,t.defaultTracking,t.autocapture,m,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,a,t.ingestionMetadata,t.instanceName,y,b,null!==(te=null==i?void 0:i.loggerProvider)&&void 0!==te?te:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,w,t.partnerId,t.plan,t.serverUrl,t.delayedEventsServerUrl,null!==(ne=null==i?void 0:i.serverZone)&&void 0!==ne?ne:t.serverZone,E,S,t.sessionTimeout,t.storageProvider,T,t.transport,t.useBatch,t.fetchRemoteConfig,k,x,P,t.networkTrackingOptions,t.identify,null!==(re=null==i?void 0:i.enableDiagnostics)&&void 0!==re?re:t.enableDiagnostics,null!==(ie=null==i?void 0:i.diagnosticsSampleRate)&&void 0!==ie?ie:n._diagnosticsSampleRate,r,t.remoteConfig,s,t.enableRequestBodyCompression,t.customEnrichment)).storageProvider.isEnabled()];case 5:return u.sent()||(_.loggerProvider.warn("Storage provider ".concat(_.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),_.storageProvider=new Ve),[2,_]}})})},Jr=function(e,t,n){switch(void 0===e&&(e=Mr),void 0===t&&(t={}),e){case"localStorage":return new fr;case"sessionStorage":return new vr;case"none":return new Ve;default:return new We(o(o({},t),{expirationDays:t.expiration}),n)}},Yr=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0,r="object"==typeof e?e.enableKeepalive:void 0,i="object"==typeof e?e.referrerPolicy:void 0;return"xhr"===t?new pr(n):"beacon"===t?new gr:new hr(n,r,i)},Xr=function(e,t){return s(void 0,void 0,void 0,function(){var n,r,i,o,a,s,l;return u(this,function(u){switch(u.label){case 0:return[4,new We(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!u.sent()||!e&&("undefined"==typeof location||!location.hostname))return[2,""];if(n=null!=e?e:location.hostname,1===(r=n.split(".")).length)return[2,""];for(i=[],o=1,Vr.find(function(e){return n.endsWith(".".concat(e))})&&(o=2),a=r.length-o-1;a>=0;--a)i.push(r.slice(a).join("."));a=0,u.label=2;case 2:if(!(a<i.length))return[3,7];s=i[a],u.label=3;case 3:return u.trys.push([3,5,,6]),[4,We.isDomainWritable(s)];case 4:return u.sent()?[2,"."+s]:[3,6];case 5:return l=u.sent(),t&&t.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(s),error:l instanceof Error?l.message:String(l)}),[3,6];case 6:return a++,[3,2];case 7:return t&&t.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(n)}),[2,""]}})})},Qr="AMP_PAGE_VIEW",Zr=function(e){var t;void 0===e&&(e={});var n,r,i=B(),a=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==a||a.error("Malformed URI sequence: ",e)}return t},g=function(e){return s(void 0,void 0,void 0,function(){var t,n,r;return u(this,function(i){switch(i.label){case 0:return t=h("undefined"!=typeof location&&location.href||""),r={event_type:p},n=[{}],[4,ei()];case 1:return[2,(r.event_properties=o.apply(void 0,[o.apply(void 0,n.concat([i.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":un(sn),"[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 u(this,function(u){switch(u.label){case 0:return e=location.href,n=ni(f,e,y||"")&&m(),y=e,n?(i=void 0,r&&(i=z(),r.set(Qr,{pageViewId:i})),null==a||a.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,[u.sent()]),u.label=3;case 3:u.label=4;case 4:return[2]}})})},w={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,o){return s(void 0,void 0,void 0,function(){var s,d,f;return u(this,function(u){switch(u.label){case 0:if(t=o,n=e,(a=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),l=!0,i){try{r=new Je(i.sessionStorage)}catch(e){null==a||a.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",b),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),l&&b()}})}return m()?(a.log("Tracking page view event"),s=void 0,r&&(s=z(),r.set(Qr,{pageViewId:s})),f=(d=t).track,[4,g(s)]):[3,2];case 1:f.apply(d,[u.sent()]),u.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,i,s;return u(this,function(u){switch(u.label){case 0:return"attribution"===d&&ti(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,r?[4,r.get(Qr)]:[3,2]):[3,4];case 1:i=u.sent(),t=null==i?void 0:i.pageViewId,u.label=2;case 2:return[4,g(t)];case 3:s=u.sent(),e.event_type=s.event_type,e.event_properties=o(o({},e.event_properties),s.event_properties),u.label=4;case 4:return n&&e.event_type===p&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=o(o({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return i&&(i.removeEventListener("popstate",b),l=!1),[2]})})}};return w},ei=function(){return s(void 0,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return e=ze,[4,(new en).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},ti=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[r.SET]||{},i=t[r.UNSET]||{},o=d(d([],c(Object.keys(n)),!1),c(Object.keys(i)),!1);return Object.keys(C).every(function(e){return o.includes(e)})}return!1},ni=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},ri=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,a;return u(this,function(s){return t=function(e){if(Gn(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=new WeakSet,a=function(e){if(!o.has(e)){o.add(e);var a=!1;r(e,"change",function(){var t,n=oi(e);a||i.track(Er,((t={})[Dr]=ii(e.id),t[Lr]=ii(e.name),t[Nr]=n,t)),a=!0}),r(e,"submit",function(r){var o,s,u=oi(e);if(a||i.track(Er,((o={})[Dr]=ii(e.id),o[Lr]=ii(e.name),o[Nr]=u,o)),a=!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(Sr,((s={})[Dr]=ii(e.id),s[Lr]=ii(e.name),s[Nr]=u,s)),a=!1})}};Array.from(document.getElementsByTagName("form")).forEach(a),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){try{if("FORM"===e.nodeName&&a(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var t=e.querySelectorAll("form");null==t||t.forEach(a)}}catch(e){n.loggerProvider.warn("Failed to track form interactions for an added node: ".concat(String(e)))}})})})).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():(a=B())?a.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 u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(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]})})}}},ii=function(e){if("string"==typeof e)return e},oi=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},ai=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 u(this,function(a){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),a=null==i?void 0:i[1];a&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",function(){var t;a&&r.track(kr,((t={})[Ir]=a,t[Ar]=n.pathname,t[Or]=e.id,t[Cr]=e.text,t[Rr]=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){try{if("A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var t=e.querySelectorAll("a");null==t||t.forEach(i)}}catch(e){n.loggerProvider.warn("Failed to track file downloads for an added node: ".concat(String(e)))}})})})).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=B())?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 u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(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]})})}}},si=!1,ui=function(){var e=B(),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 u(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(){!1!==e.offline&&(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 u(this,function(n){return t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[],[2]})})}}};function li(e,t){var n,r;if(e){Wn(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",X(e));var i=e;if(i&&"autocapture"in i){if("boolean"==typeof i.autocapture&&(t.autocapture=i.autocapture),"object"==typeof i.autocapture&&null!==i.autocapture){var a=o({},i.autocapture);if(void 0===t.autocapture&&(t.autocapture=i.autocapture),"object"==typeof i.autocapture.elementInteractions&&null!==i.autocapture.elementInteractions&&(null===(n=i.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===n?void 0:n.length)){a.elementInteractions=o({},i.autocapture.elementInteractions);var s=a.elementInteractions,u=null!==(r=s.pageUrlAllowlist)&&void 0!==r?r:[],c=i.autocapture.elementInteractions.pageUrlAllowlistRegex;s.pageUrlAllowlist=Vn(u,c,t.loggerProvider),delete s.pageUrlAllowlistRegex}var d=function(e,t){var n,r,i,a,s;if("object"==typeof e&&null!==e&&(null===(i=e.captureRules)||void 0===i?void 0:i.length)){var u=o({},e),c=null!==(a=u.captureRules)&&void 0!==a?a:[];try{for(var d=l(c),f=d.next();!f.done;f=d.next()){var v=f.value;v.urls=Vn(null!==(s=v.urls)&&void 0!==s?s:[],v.urlsRegex,t),delete v.urlsRegex}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u}}(i.autocapture.networkTracking,t.loggerProvider);d&&(a.networkTracking=d),"boolean"==typeof t.autocapture&&(t.autocapture=o({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},a)),"object"==typeof t.autocapture&&(t.autocapture=o(o({},t.autocapture),a))}t.defaultTracking=t.autocapture}"customEnrichment"in i&&null!==i.customEnrichment&&!1!==t.customEnrichment&&(t.customEnrichment=i.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",X(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var ci="1.29.1-video-analytics-2.0",di="[Amplitude] Element Clicked",fi="[Amplitude] Element Tag",vi="[Amplitude] Element Text",pi="[Amplitude] Page URL",hi="[Amplitude] Viewport Height",gi="[Amplitude] Viewport Width",mi="[Amplitude] Page View ID",yi="data-amp-mask-attributes",bi="data-amp-internal-shadow";function wi(e,t){var n=e.getAttribute(t.explicitTrackingAttribute);if(null!==n&&""===n)return null;var r=e.getAttribute("id");return null===r||""===r?null:function(e,t){var n,r;if(null==e||""===e)return!1;try{for(var i=l(t),o=i.next();!o.done;o=i.next())if(o.value.test(e))return!1}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!0}(r,t.autogeneratedIdPatterns)?r:null}function Ei(e,t){return t.map(Si).join(" > ")}function Si(e){var t=e.tagName.toLowerCase(),n=e.parentElement;if(null===n)return t;var r=function(e,t){for(var n=0,r=0;r<t.children.length;r++){var i=t.children[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}(e,n);return"".concat(t,":nth-of-type(").concat(r,")")}var ki=":scope > ";function Ti(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}function xi(e){var t,n=e.getRootNode();return Ti(n)?n:null!==(t=e.ownerDocument)&&void 0!==t?t:document}function Pi(e,t){var n,r,i,o;return u(this,function(a){switch(a.label){case 0:n=e,r=0,i=0,a.label=1;case 1:return null!==n&&i<1024?(i+=1,[4,n]):[3,3];case 2:return a.sent(),n.parentElement?(n=n.parentElement,[3,1]):r<t&&"function"==typeof n.getRootNode&&(o=function(e){if(e.parentElement)return e.parentElement;var t=e.getRootNode();return Ti(t)?t.host:null}(n))&&o!==n?(r+=1,n=o,[3,1]):[3,3];case 3:return[2]}})}function _i(e,t){var n=[];if(t<=0)return n;for(var r=[[e,0]],i=0;r.length&&i<5e4;){i+=1;var o=c(r.pop(),2),a=o[0],s=o[1],u=a.shadowRoot;if(u&&s+1<=t){n.push({root:u,depth:s+1});for(var l=u.children,d=0;d<l.length;d++)r.push([l[d],s+1])}var f=a.children;for(d=0;d<f.length;d++)r.push([f[d],s])}return n}function Ii(e,t){for(var n=[],r=e,i=0;null!==r&&i<1024;){i+=1;var o=xi(r);n.push({root:o,target:r});var a=r.getRootNode();if(!Ti(a))break;r=a.host}var s=n.length-1,u=!1,l=n;return s>t&&(l=n.slice(s-t),u=!0),{segments:l.reverse(),truncated:u}}function Ai(e,t){var n=e.tagName.toLowerCase(),r=e.parentElement;if(null===r){var i=e.getRootNode();return t&&Ti(i)?"".concat(n,":nth-of-type(").concat(Oi(e,i.children),")"):n}return"".concat(n,":nth-of-type(").concat(Oi(e,r.children),")")}function Oi(e,t){for(var n=0,r=0;r<t.length;r++){var i=t[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}var Ci={name:"explicitTrackingAttribute",try:function(e,t){var n=t.config.explicitTrackingAttribute,r=e.getAttribute(n);return null===r||""===r?null:"[".concat(n,"=").concat(JSON.stringify(r),"]")}};function Ri(e){var t=globalThis.CSS;if(t&&"function"==typeof t.escape)return t.escape(e);for(var n=String(e),r=n.length,i="",o=0;o<r;o++){var a=n.charCodeAt(o);0!==a?a>=1&&a<=31||127===a||0===o&&a>=48&&a<=57||1===o&&a>=48&&a<=57&&45===n.charCodeAt(0)?i+="\\".concat(a.toString(16)," "):i+=0!==o||1!==r||45!==a?a>=128||45===a||95===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?n.charAt(o):"\\".concat(n.charAt(o)):"\\-":i+="�"}return i}function Di(e){return Ri(e)}var Li={name:"stableId",try:function(e,t){var n=wi(e,t.config);return null===n?null:"".concat(e.tagName.toLowerCase(),"#").concat(Di(n))}},Ni=!1,Mi=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:d([],c([/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/]),!1),unstableClassPatterns:d([],c([/^(p|m|px|py|mx|my|pt|pb|pl|pr|mt|mb|ml|mr)-\d+$/,/^(w|h|min-w|max-w|min-h|max-h)-/,/^(text|bg|border|ring|fill|stroke)-/,/^(hover|focus|active|disabled|group-hover):/,/^(sm|md|lg|xl|2xl):/,/^z-\d+$/,/^data-\[/,/^\[/,/^css-[a-z0-9]{6,}$/,/^[a-zA-Z]+_[a-zA-Z0-9]{3,}__[a-zA-Z0-9]{5,}$/,/^sc-[a-zA-Z0-9]{6,}$/,/^jsx-\d+$/,/^swiper-slide-(visible|fully-visible|active|prev|next|duplicate)$/,/^is-(active|open|selected|hovered|focused|expanded)$/,/^Mui[A-Z][a-zA-Z]+-(focused|selected|disabled|expanded|focusVisible|active|checked)$/,/^Mui-(selected|focused|disabled|expanded|focusVisible|active|checked)$/,/^data-state-/]),!1),maxAncestorWalkDepth:void 0,shadowDomEnabled:Ni,maxShadowDomDepth:1});function ji(e){var t;return o(o({},e),{shadowDomEnabled:null!==(t=e.shadowDomEnabled)&&void 0!==t?t:Ni,maxShadowDomDepth:Fi(e.maxShadowDomDepth)})}function Ui(e,t){if(!e)return qi();var n,r=qi();return"boolean"==typeof e.enabled&&(r.enabled=e.enabled),"string"==typeof e.explicitTrackingAttribute&&""!==e.explicitTrackingAttribute&&(r.explicitTrackingAttribute=e.explicitTrackingAttribute),Array.isArray(e.autogeneratedIdPatterns)&&(r.autogeneratedIdPatterns=function(e,t){var n,r,i=[];try{for(var o=l(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(s,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.autogeneratedIdPatterns,t)),Array.isArray(e.unstableClassPatterns)&&(r.unstableClassPatterns=function(e,t){var n,r,i=[];try{for(var o=l(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(s,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.unstableClassPatterns,t)),r.maxAncestorWalkDepth="number"!=typeof(n=e.maxAncestorWalkDepth)?void 0:Number.isFinite(n)?n<=0?void 0:Math.floor(n):void 0,"boolean"==typeof e.shadowDomEnabled&&(r.shadowDomEnabled=e.shadowDomEnabled),r.maxShadowDomDepth=Fi(e.maxShadowDomDepth),ji(r)}function Fi(e){return"number"==typeof e&&Number.isFinite(e)?Math.min(Math.max(Math.floor(e),1),10):1}function qi(){return{enabled:Mi.enabled,explicitTrackingAttribute:Mi.explicitTrackingAttribute,autogeneratedIdPatterns:d([],c(Mi.autogeneratedIdPatterns),!1),unstableClassPatterns:d([],c(Mi.unstableClassPatterns),!1),maxAncestorWalkDepth:Mi.maxAncestorWalkDepth,shadowDomEnabled:Mi.shadowDomEnabled,maxShadowDomDepth:Mi.maxShadowDomDepth}}var Bi=[Ci,Li];function Hi(e,t,n){var r,i,o,a,s;void 0===n&&(n={});var u=ji(t),c=null!==(o=n.strategies)&&void 0!==o?o:Bi,d=null!==(s=null!==(a=n.scope)&&void 0!==a?a:e.ownerDocument)&&void 0!==s?s:document,f={scope:d,config:u},v=function(e,t){var n=[],r=e;for(;null!==r&&(n.push(r),!(void 0!==t&&n.length>t));)r=r.parentElement;return n}(e,u.maxAncestorWalkDepth);try{for(var p=l(c),h=p.next();!h.done;h=p.next())for(var g=h.value,m=0;m<v.length;m++){var y=v[m],b=g.try(y,f);if(null!==b)if(0!==m){var w=Ei(0,v.slice(0,m).reverse()),E="".concat(b," > ").concat(w);if(zi(d,E,e,g.name,n.logger))return E}else if(zi(d,b,e,g.name,n.logger))return b}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}return null}function zi(e,t,n,r,i){var o;try{o=e.querySelectorAll(t)}catch(e){var a=e instanceof Error?e.message:String(e);return null==i||i.debug('@amplitude/element-selector: strategy "'.concat(r,'" emitted a malformed selector "').concat(t,'" (').concat(a,")")),!1}return 1===o.length&&o[0]===n}function Vi(e,t,n){var r;try{r=e.querySelectorAll(t)}catch(e){return!1}return 1===r.length&&r[0]===n}var Wi=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),$i=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 Wi(Gi(o),!0);var a=e.tagName.toLowerCase();if("body"===a||"head"===a||"html"===a)return new Wi(a,!0)}var s=e.tagName.toLowerCase();if(o)return new Wi(s+Gi(o),!0);var u=e.parentNode;if(!u||u.nodeType===Node.DOCUMENT_NODE)return new Wi(s,!0);for(var c=Ki(e),d=!1,f=!1,v=-1,p=-1,h=u.children,g=0;h&&(-1===v||!f)&&g<h.length;++g){var m=h[g];if(m.nodeType===Node.ELEMENT_NODE)if(p+=1,m!==e){if(!f&&m.tagName.toLowerCase()===s){d=!0;var y=new Set(c);if(y.size)for(var b=Ki(m),w=0;w<b.length;++w){var E=b[w];if(y.has(E)&&(y.delete(E),!y.size)){f=!0;break}}else f=!0}}else v=p}var S=s;if(n&&"input"===s.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(S+="[type="+Ri(e.getAttribute("type")||"")+"]"),f)S+=":nth-child("+String(v+1)+")";else if(d)try{for(var k=l(c),T=k.next();!T.done;T=k.next()){S+="."+Ri(T.value.slice(1))}}catch(e){r={error:e}}finally{try{T&&!T.done&&(i=k.return)&&i.call(k)}finally{if(r)throw r.error}}return new Wi(S,!1)},Ki=function(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]},Gi=function(e){return"#"+Ri(e)};function Ji(e,t){try{return function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=$i(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e)}catch(e){var n=e instanceof Error?e.message:String(e);return null==t||t.warn("@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ".concat(n)),""}}function Yi(e,t){void 0===t&&(t={});var n=ji(e),r=new Set,i=t.logger,o=function(e){return Ji(e,i)},a=function(e,r){var o;return null!==(o=Hi(e,n,{strategies:t.strategies,scope:r,logger:i}))&&void 0!==o?o:function(e,t,n){var r,i;void 0===n&&(n={});for(var o=ji(t),a=null!==(i=null!==(r=n.scope)&&void 0!==r?r:e.ownerDocument)&&void 0!==i?i:document,s=Ti(a),u=[],l=e,f=0,v=!(o.shadowDomEnabled&&s);null!==l&&!(v&&void 0!==o.maxAncestorWalkDepth&&f>o.maxAncestorWalkDepth);){var p=wi(l,o);if(null!==p){var h=d(["".concat(l.tagName.toLowerCase(),"#").concat(Di(p))],c(u),!1).join(" > ");if(Vi(a,h,e))return h}u.unshift(Ai(l,o.shadowDomEnabled)),l=l.parentElement,f+=1}var g=u.join(" > ");return o.shadowDomEnabled&&s&&null===l?"".concat(ki).concat(g):g}(e,n,{scope:r})},s=function(e,t){return function(e,t,n){return e&&n&&Ti(t)?"".concat(ki).concat(e):e}(o(e),t,function(e){for(var t=e;null!==t;t=t.parentElement)if(t.getAttribute("id"))return!1;return!0}(e))};return{generate:function(e){var r,u;try{return n.shadowDomEnabled?function(e,t){var r=Ii(e,n.maxShadowDomDepth),o=r.segments;return r.truncated&&(null==i||i.debug("@amplitude/element-selector: target is nested deeper than maxShadowDomDepth (".concat(n.maxShadowDomDepth,") — emitting a best-effort selector for the outermost in-budget shadow host"))),o.map(function(e){var n=e.target,r=e.root;return t(n,r)}).join(" >>> ")}(e,n.enabled?a:s):(n.enabled?a:o)(e,null!==(u=null!==(r=t.scope)&&void 0!==r?r:e.ownerDocument)&&void 0!==u?u:document)}catch(t){var l=t instanceof Error?t.message:String(t);return null==i||i.warn("@amplitude/element-selector: selector generation threw — falling back to legacy cssPath: ".concat(l)),Ji(e,i)}},getConfig:function(){return n},updateConfig:function(e){var t,o;n=ji(e);try{for(var a=l(r),s=a.next();!s.done;s=a.next()){var u=s.value;try{u(n)}catch(e){var c=e instanceof Error?e.message:String(e);null==i||i.warn("@amplitude/element-selector: onConfigChange subscriber threw — ".concat(c))}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}},onConfigChange:function(e){return r.add(e),function(){r.delete(e)}}}}var Xi,Qi,Zi=Object.freeze({enabled:!1,maxDepth:0}),eo=function(){var e=Zi,t=new Set;return{get:function(){return e},arm:function(n){return e.enabled||!n.enabled||(e=n,function(e){var n,r;try{for(var i=l(d([],c(t),!1)),o=i.next();!o.done;o=i.next()){var a=o.value;try{a(e)}catch(e){}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.clear()}(n)),e},onArm:function(n){if(e.enabled){var r=e;try{n(r)}catch(e){}return function(){}}return t.add(n),function(){t.delete(n)}}}},to=["input","select","textarea"],no=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&qe(window.location.href,n))&&!!qe(window.location.href,t)},ro=function(e,t){return function(n,r){var i,o,a=e.shouldTrackEventResolver,s=null===(o=null===(i=null==r?void 0:r.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===o?void 0:o.call(i);if(!s)return!1;if(a)return a(n,r);if(!no(e))return!1;var u=String(null==r?void 0:r.getAttribute("type"))||"";if("string"==typeof u)switch(u.toLowerCase()){case"hidden":case"password":return!1}if(t){var l=t.some(function(e){var t;return!!(null===(t=null==r?void 0:r.matches)||void 0===t?void 0:t.call(r,e))});if(!l)return!1}switch(s){case"input":case"select":case"textarea":return"change"===n||"click"===n;default:return"click"===n}}},io=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},oo=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},{})},ao=function(){var e;try{var t=B(),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){}},so=function(e,t,n){return void 0===n&&(n=Zi),n.enabled?lo(e,t,n.maxDepth):uo(e,t)},uo=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:uo(null==e?void 0:e.parentElement,t):null},lo=function(e,t,n){var r,i;if(!e)return null;var o=function(e){if(t.some(function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))return{value:e}};try{for(var a=l(Pi(e,n)),s=a.next();!s.done;s=a.next()){var u=o(s.value);if("object"==typeof u)return u.value}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return null},co=function(e,t,n){return void 0===n&&(n=Zi),n.enabled?vo(e,t,n.maxDepth):fo(e,t)},fo=function(e,t){var n=[];return t?(e.querySelectorAll(t).forEach(function(e){return n.push(e)}),n):n},vo=function(e,t,n){var r=fo(e,t),i=e instanceof Document?e.documentElement:e;return i?(_i(i,n).forEach(function(e){e.root.querySelectorAll(t).forEach(function(e){return r.push(e)})}),r):r},po=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};function ho(e){if(!e)return"";try{var t=new URL(e);return t.search="",Be(t.href)}catch(t){return Be(e)}}function go(e){var t,n;return void 0===e&&(e=B()),ho(null!==(n=null===(t=null==e?void 0:e.location)||void 0===t?void 0:t.href)&&void 0!==n?n:"")}!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Qi||(Qi={}));var mo="__AMPLITUDE_VISUAL_TAGGING__";var yo=B(),bo=function(e){return e.get()},wo={childList:!0,attributes:!0,characterData:!0,subtree:!0},Eo=function(e){return new xn(e?function(t){var n,r=new WeakSet,i=new WeakMap,o=function(e,t){r.has(e)||(r.add(e),Ti(e)&&i.set(e,t),s.observe(e,wo))},a=function(e,t,n){var r=n-t;r<=0||_i(e,r).forEach(function(e){var n=e.root,r=e.depth;return o(n,t+r)})},s=new MutationObserver(function(n){var r,o;t.next(n);try{var s=bo(e);if(!s.enabled)return;var u=function(e){var t=function(e){var t=e.getRootNode();if(!Ti(t))return 0;var n=i.get(t);return null!=n?n:0}(e.target);e.addedNodes.forEach(function(e){e instanceof Element&&a(e,t,s.maxDepth)})};try{for(var c=l(n),d=c.next();!d.done;d=c.next()){u(d.value)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}catch(e){}});if(document.body){var u=document.body;o(u,0),n=e.onArm(function(e){a(u,0,e.maxDepth)})}return function(){null==n||n(),s.disconnect()}}: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()}})},So=function(e){return void 0===e&&(e="click"),new xn(function(t){var n,r=function(e){t.next(e)};return null===(n=B())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=B())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}})},ko=function(){var e=_n(new xn(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=o(o({},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 yo.addEventListener("error",t),function(){yo.removeEventListener("error",t)}}),new xn(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return yo.addEventListener("unhandledrejection",t),function(){yo.removeEventListener("unhandledrejection",t)}}));return _n(e,new xn(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 Pt.addListener("error",t),function(){Pt.removeListener(t)}}))},To=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}})},xo={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Po=function(e){var t,n,r,i,o=Object.values(xo).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var u=s.value;try{try{for(var c=(r=void 0,l(u.definition)),d=c.next();!d.done;d=c.next()){var f=d.value,v=xo[f.event_type];v&&o[v].add(u.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==u?void 0:u.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},_o=function(e){var t,n,r,i,o=new Map;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var c=(r=void 0,l(u.conditions)),d=c.next();!d.done;d=c.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(u)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},Io=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return xo[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)})})})},Ao=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,a=new Set;try{for(var s=l(e),u=s.next();!u.done;u=s.next()){var c=u.value,d=t.get(c.id);if(d)try{for(var f=(i=void 0,l(d)),v=f.next();!v.done;v=f.next()){var p=v.value;a.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{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(a)}(Io(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var o=l(i),a=o.next();!a.done;a=o.next()){var s=a.value;To(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.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}(),Oo=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",yi,tn,bi]),Co=["type"],Ro=["svg","path","g"],Do=["password","hidden"];function Lo(e,t,n){var r,i,a,s,u;if(void 0===n&&(n=Zi),null===e)return null;var c=String(e.tagName).toLowerCase(),d={tag:c},f=Array.from(function(e,t){if(e.parentElement)return e.parentElement.children;var n=e.getRootNode();return t&&Ti(n)?n.children:[]}(e,n.enabled));f.length&&(d.index=f.indexOf(e),d.indexOfType=f.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var v=null===(u=null===(s=e.previousElementSibling)||void 0===s?void 0:s.tagName)||void 0===u?void 0:u.toLowerCase();v&&(d.prevSib=String(v));var p=e.getAttribute("id");p&&(d.id=String(p));var h=Array.from(e.classList);h.length&&(d.classes=h);var g={},m=Array.from(e.attributes).filter(function(e){return!Oo.has(e.name)}),y=!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!to.includes(i)&&!o}(e);if(!Do.includes(String(e.getAttribute("type")))&&!Ro.includes(c))try{for(var b=l(m),w=b.next();!w.done;w=b.next()){var E=w.value;y&&!Co.includes(E.name)||(t.has(E.name)?g[E.name]=nn:g[E.name]=String(E.value).substring(0,128))}}catch(e){r={error:e}}finally{try{w&&!w.done&&(i=b.return)&&i.call(b)}finally{if(r)throw r.error}}return Object.keys(g).length&&(d.attrs=g),e.shadowRoot&&(d.attrs=o(o({},d.attrs||{}),((a={})[bi]="true",a)),d.shadow=!0),d}function No(e,t){return void 0===t&&(t=Zi),e?t.enabled?function(e,t){var n,r,i=[];try{for(var o=l(Pi(e,t)),a=o.next();!a.done;a=o.next()){var s=a.value;if("HTML"===s.tagName)break;i.push(s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e,t.maxDepth):function(e){var t=[];t.push(e);var n=e.parentElement;for(;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e):[]}var Mo;var jo,Uo=function(e,t){var n,r,i,a=this;this.replaceSensitiveString=function(e){return sn(e,a.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,o,s=performance.now();if(!e)return[];for(var u=a.getShadowMode(),f=No(e,u),v=new Map,p=f.length-1;p>=0;p--){var h=f[p];if(h){var g=io(h.getAttribute(yi)),m=p===f.length-1?[]:null!==(r=v.get(f[p+1]))&&void 0!==r?r:new Set,y=new Set(d(d([],c(m),!1),c(g),!1));v.set(h,y)}}o=f.map(function(e){var t;return Lo(e,null!==(t=v.get(e))&&void 0!==t?t:new Set,u)});var b=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]=a.replaceSensitiveString(i))})};try{for(var w=l(o),E=w.next();!E.done;E=w.next())b(E.value)}catch(e){t={error:e}}finally{try{E&&!E.done&&(n=w.return)&&n.call(w)}finally{if(t)throw t.error}}var S=performance.now();return null===(i=a.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",S-s),o},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?a.getText(t):a.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=a.selectorEngine.generate(e),i=performance.now();return null===(t=a.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.updateSelectorConfig=function(e,t){var n;if(null!=e){var r="boolean"==typeof e.enabled,i="boolean"==typeof e.shadowDomEnabled;if(r||i){var s=Ui(e,t),u=a.selectorEngine.getConfig().enabled,l=a.shadowGate.get().enabled,c=a.shadowGate.arm(function(e){var t,n=null!==(t=e.maxShadowDomDepth)&&void 0!==t?t:1;return!e.shadowDomEnabled||n<=0?Zi:Object.freeze({enabled:!0,maxDepth:n})}(s));a.selectorEngine.updateConfig(o(o(o({},r?s:a.selectorEngine.getConfig()),{shadowDomEnabled:c.enabled}),c.enabled&&{maxShadowDomDepth:c.maxDepth})),r&&u!==s.enabled&&(null==t||t.debug(s.enabled?"@amplitude/element-selector: engine enabled — now emitting new element-selector element paths for autocapture events.":"@amplitude/element-selector: engine disabled — reverting to legacy cssPath for element paths.")),!l&&c.enabled&&(null===(n=a.diagnosticsClient)||void 0===n||n.setTag("plugin.autocapture.shadowDom","enabled:".concat(c.maxDepth)))}else null==t||t.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` or `shadowDomEnabled` flag — keeping current engine state.")}},this.getShadowMode=function(){return a.shadowGate.get()},this.getEventProperties=function(e,t,n){var r,i,o,s,u,l,d=null===(o=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===o?void 0:o.call(i),f="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},v=a.getHierarchy(t),p=null===(s=v[0])||void 0===s?void 0:s.attrs,h=a.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[fi]=d,r[vi]=a.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"]=a.getElementPath(t),r["[Amplitude] Element Parent Label"]=h,r[pi]=Be(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=un(a.replaceSensitiveString),r[hi]=window.innerHeight,r[gi]=window.innerWidth,r),y=ao();if(y&&(m[mi]=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"]=a.replaceSensitiveString(b)}return oo(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 o=a.addTypeAndTimestamp(e,t);try{if(function(e){return"click"===e.type||"change"===e.type}(o)&&null!==o.event.target){var s=a.getShadowMode(),u=function(e,t){var n,r;if(void 0===t&&(t=Zi),!t.enabled)return e.target;var i=null===(n=e.composedPath)||void 0===n?void 0:n.call(e),o=null!==(r=e.target)&&void 0!==r?r:null;if(!i||0===i.length)return o;var a=i[0];if(!(a instanceof Element))return null!=a?a:o;var s=Ii(a,t.maxDepth),u=s.segments;return s.truncated&&u.length>0?u[u.length-1].target:a}(o.event,s);if(i){var l=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}(u,o.type);if(l)return o.closestTrackedAncestor=u,o.targetElementProperties=a.getEventProperties(o.type,o.closestTrackedAncestor,r),o}var c=so(u,n,s);c&&(o.closestTrackedAncestor=c,o.targetElementProperties=a.getEventProperties(o.type,c,r))}}catch(e){}return o},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?a.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(tn,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",o=Array.from(e.childNodes);try{for(var s=l(o),u=s.next();!u.done;u=s.next()){var c=u.value;c.nodeType!==Node.TEXT_NODE?c instanceof Element&&(c.hasAttribute(tn)||c.hasAttribute("contenteditable")?i+=nn:i+=a.getTextWithMaskedDescendants(c)):i+=c.textContent||""}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},this.hasMaskedAncestor=function(e){var t=a.getShadowMode();return t.enabled?function(e,t){var n,r;return!!No(e,t).some(function(e){return e.hasAttribute(tn)})||null!==(r=null===(n=document.documentElement)||void 0===n?void 0:n.hasAttribute(tn))&&void 0!==r&&r}(e,t):function(e){return null!==e.closest("[".concat(tn,"]"))}(e)},this.getText=function(e){if(a.hasMaskedAncestor(e))return nn;var t="";return t=e.querySelector("[".concat(tn,"], [contenteditable]"))?a.getTextWithMaskedDescendants(e):e.innerText||"",a.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),o=((t={})[fi]=i,t[vi]=a.getText(e),t[pi]=window.location.href.split("?")[0],t);return oo(o)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient,this.selectorEngine=(Mo||(Mo=Yi(Ui())),Mo),this.shadowGate=(Xi||(Xi=eo()),Xi);var s=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],u=[];try{for(var f=l(s),v=f.next();!v.done;v=f.next()){var p=v.value;if(u.length>=25)break;if(p instanceof RegExp)u.push(p);else if("pattern"in p&&"string"==typeof p.pattern)try{u.push(new RegExp(p.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=u};function Fo(e,t){var n=e.remoteConfigClient;if(e.fetchRemoteConfig&&n){var r=n.subscribe("configs.analyticsSDK.browserSDK.autocapture.elementSelector","all",function(n,r){e.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(r),") ").concat(JSON.stringify(n))),t.updateSelectorConfig(n,e.loggerProvider)});return function(){n.unsubscribe(r)}}}function qo(e){var t,n,r,i,o,a=e.mutationObservable,s=e.onRescan,u=e.onFlush,l=e.exposureDuration,c=e.quietMs,d=void 0===c?150:c,f=e.maxWaitMs,v=void 0===f?4e3:f,p=!1,h=function(){t&&(clearTimeout(t),t=void 0),n&&(clearTimeout(n),n=void 0),r&&(clearTimeout(r),r=void 0)},g=function(){o&&(document.removeEventListener("DOMContentLoaded",o),o=void 0)},m=function(){p||("undefined"!=typeof document&&"loading"!==document.readyState?(p=!0,h(),g(),s(),r=setTimeout(function(){r=void 0,u()},l+50)):o||(o=function(){o=void 0,y()},document.addEventListener("DOMContentLoaded",o)))},y=function(){p||(t&&clearTimeout(t),t=setTimeout(m,d))},b=function(){h(),g(),p=!1,y(),n=setTimeout(m,v)};return{start:function(){i||(i=a.subscribe(function(){y()}),b())},reset:function(){b()},stop:function(){null==i||i.unsubscribe(),i=void 0,h(),g()}}}!function(e){e.ClickObservable="clickObservable",e.PointerDownObservable="pointerDownObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(jo||(jo={}));var Bo=function(e,t){var n,r,i,a,f,v,p,h,g,m,y,b;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",ci);var w=e.dataAttributePrefix,E=void 0===w?It:w,S=e.visualTaggingOptions,k=void 0===S?{enabled:!0}:S;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:_t,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:At,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0;var T=!1!==(null===(a=e.viewportContentUpdated)||void 0===a?void 0:a.enabled),x=null!==(p=null!==(v=null===(f=e.viewportContentUpdated)||void 0===f?void 0:f.exposureDuration)&&void 0!==v?v:e.exposureDuration)&&void 0!==p?p:150;e.viewportContentUpdated=o(o({},e.viewportContentUpdated),{exposureDuration:x}),e.pageUrlExcludelist=null===(h=e.pageUrlExcludelist)||void 0===h?void 0:h.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 P,_,I="@amplitude/plugin-autocapture-browser",A=[],O=new Uo(e,t),C=new Set,R=new Set,D=new Set,L=function(){var t,n,r=In(So().map(function(t){return O.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,E)})),i=In(new xn(function(t){var n,r=function(n){var r=O.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,E);t.next(r)};return null===(n=B())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=B())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=In(new xn(function(t){var n=function(n){var r=O.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,E);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=O.shadowGate,a=In(Eo(o).map(function(t){return O.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,E)})),s=new xn(function(e){var t,n=function(t){e.next(t)};return null===(t=B())||void 0===t||t.addEventListener("scroll",n),function(){var e;null===(e=B())||void 0===e||e.removeEventListener("scroll",n)}}),u=function(e,t,n,r){var i="function"==typeof n?n:void 0,o="function"==typeof n?r:n;return new xn(function(n){var r=B();if(!(null==r?void 0:r.IntersectionObserver))return function(){};var a=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:"0px",threshold:1}),s=t.join(","),u=function(e){e instanceof Element&&e.matches(s)&&a.observe(e),e.querySelectorAll(s).forEach(function(e){a.observe(e)})},l=function(e){if(o)try{co(e,s,bo(o)).forEach(function(e){a.observe(e)})}catch(e){}},c=function(){var e=null==r?void 0:r.document;if(e){var t=[];try{t=o&&bo(o).enabled?co(e,s,bo(o)):e.querySelectorAll(s)}catch(e){return}Array.from(t).forEach(function(e){a.unobserve(e),a.observe(e)})}};null==i||i(c),c();var d=null==o?void 0:o.onArm(function(){(null==r?void 0:r.document)&&l(r.document)}),f=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){if(e instanceof DocumentFragment)u(e);else if(e instanceof Element)if(o&&bo(o).enabled){try{e.matches(s)&&a.observe(e)}catch(e){}l(e)}else u(e)})})});return function(){null==i||i(void 0),null==d||d(),f.unsubscribe(),a.disconnect()}})}(a,e.cssSelectorAllowlist,function(e){_=e},o);return(t={})[jo.ChangeObservable]=i,t[jo.ClickObservable]=r,t[jo.MutationObservable]=a,t[jo.NavigateObservable]=n,t[jo.ScrollObservable]=s,t[jo.ExposureObservable]=u,t},N=Po(Object.values(null!==(m=null===(g=e.pageActions)||void 0===g?void 0:g.labeledEvents)&&void 0!==m?m:{})),M=_o(null!==(b=null===(y=e.pageActions)||void 0===y?void 0:y.triggers)&&void 0!==b?b:[]),j=function(e,t,n,r){return new Ao(e,t,n,r)}(N,M,O,e);return{name:I,type:"enrichment",setup:function(t,n){return s(void 0,void 0,void 0,function(){var r,i,a,s,l,f,v,p,h,g,m,y,b,w,S,U,F,q,H,z,V,W,$,K,G,J,Y;return u(this,function(u){return"undefined"==typeof document||(r=!1,t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(t){!function(t){var n,r;t&&(e.pageActions=o(o({},e.pageActions),t),N=Po(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),M=_o(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),j.update(N,M,e))}(t)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),(i=Fo(t,O))&&A.push({unsubscribe:i}),a=ro(e,e.cssSelectorAllowlist),s=ro(e,e.actionClickAllowlist),l=L(),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(po).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(di,e.targetElementProperties)})}({allObservables:l,amplitude:n,shouldTrackEvent:a,evaluateTriggers:j.evaluate.bind(j)}),A.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(po).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:l,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return O.getEventProperties.apply(O,d(d([],c(e),!1),[E],!1))},amplitude:n,shouldTrackEvent:a,evaluateTriggers:j.evaluate.bind(j)}),A.push(v),p=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,a=e.shouldTrackActionClick,s=n.clickObservable,u=n.mutationObservable,l=n.navigateObservable,c=s.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=so(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(po).filter(function(e){return a("click",e.closestTrackedAncestor)}),d=l?_n(u,l):u,f=_n(c,d),v=null,p=null;return Pn(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(di,i("click",e.closestTrackedAncestor)))})}({allObservables:l,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return O.getEventProperties.apply(O,d(d([],c(e),!1),[E],!1))},amplitude:n,shouldTrackEvent:a,shouldTrackActionClick:s}),p&&A.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=B(),a=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),s=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,a),n.maxY=Math.max(n.maxY,s)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:l,amplitude:n}),A.push(h),g=o({},h.getState()),m={},y=B(),w=function(e){e&&(null==b||b.reset()),e&&r||(e&&(r=!0,setTimeout(function(){r=!1},100)),function(e){var t,n,r,i=e.amplitude,o=e.scrollTracker,a=e.currentElementExposed,s=e.elementExposedForPage,u=e.elementExposedInSentEvents,l=e.exposureTracker,c=e.isPageEnd,d=e.lastScroll,f=o.getState(),v=B(),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=Array.from(a).filter(function(e){return!u.has(e)}),m=((t={})[pi]=go(v),t["[Amplitude] Max Page X"]=f.maxX+p,t["[Amplitude] Max Page Y"]=f.maxY+h,t[hi]=h,t[gi]=p,t["[Amplitude] Element Exposed"]=g,t),y=ao();y&&(m[mi]=y);var b=function(){o.reset();var e=o.getState();d.maxX=e.maxX,d.maxY=e.maxY,s.clear(),u.clear(),null==l||l.reset()};0!==g.length||f.maxX!==d.maxX||f.maxY!==d.maxY?(null==i||i.track("[Amplitude] Viewport Content Updated",m),d.maxX=f.maxX,d.maxY=f.maxY,g.forEach(function(e){u.add(e)}),a.clear(),c&&b()):c&&b()}({amplitude:n,scrollTracker:h,currentElementExposed:D,elementExposedForPage:C,elementExposedInSentEvents:R,exposureTracker:m.exposure,isPageEnd:e,lastScroll:g}))},S=go(y),U=function(){var e=go(y);e!==S&&(S=e,w(!0))},F=function(e,t){var n=go(y),r=function(e,t){var n;if(void 0===t&&(t=B()),null==e||""===e)return go(t);var r=(null===(n=null==t?void 0:t.location)||void 0===n?void 0:n.href)||"http://localhost/";try{return ho(new URL(e,r).href)}catch(e){return go(t)}}(t,y);n!==r?(S=r,w(!0),e()):e()},q=function(e){!function(e,t,n,r,i){if(!t.has(e)&&!n.has(e)){t.add(e),r.add(e);var o=Array.from(r);JSON.stringify(o).length>=18e3&&i(!1)}}(e,C,R,D,w)},T&&(m.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,a=new Map,s=new Map,u=t.exposureObservable.subscribe(function(e){var t=e,i=t.target;if(t.isIntersecting){if(!a.get(i)){var u=s.get(i);u&&clearTimeout(u);var l=setTimeout(function(){a.set(i,!0);var e=r.getElementPath(i);n(e),s.set(i,null)},o);s.set(i,l)}}else!t.isIntersecting&&t.intersectionRatio<1&&(l=s.get(i))&&(clearTimeout(l),s.set(i,null))});return{unsubscribe:function(){u.unsubscribe()},reset:function(){s.forEach(function(e){e&&clearTimeout(e)}),s.clear(),a.clear()}}}({allObservables:l,onExposure:q,dataExtractor:O,exposureDuration:x}),m.exposure&&A.push(m.exposure),b=qo({mutationObservable:l[jo.MutationObservable],onRescan:function(){var e,n;null===(n=null===(e=t.loggerProvider)||void 0===e?void 0:e.debug)||void 0===n||n.call(e,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — rescanning DOM"),null==_||_()},onFlush:function(){var e,n;null===(n=null===(e=t.loggerProvider)||void 0===e?void 0:e.debug)||void 0===n||n.call(e,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — flushing viewport content updated"),w(!1)},exposureDuration:x}),b.start(),A.push({unsubscribe:function(){null==b||b.stop()}}),H=function(){w(!0)},null==y||y.addEventListener("beforeunload",H),P=function(){null==y||y.removeEventListener("beforeunload",H)},A.push({unsubscribe:function(){return P()}}),(z=l[jo.NavigateObservable])?A.push(z.subscribe(function(e){var t,n,r=null===(n=null===(t=e.event)||void 0===t?void 0:t.destination)||void 0===n?void 0:n.url;if(r){var i=ho(r);if(i===S)return;return S=i,void w(!0)}U()})):y&&(V=function(){U()},y.addEventListener("popstate",V),W=y.history.pushState,$=y.history.replaceState,y.history&&W&&(y.history.pushState=new Proxy(W,{apply:function(e,t,n){F(function(){e.apply(t,n)},n[2])}})),y.history&&$&&(y.history.replaceState=new Proxy($,{apply:function(e,t,n){F(function(){e.apply(t,n)},n[2])}})),A.push({unsubscribe:function(){y.removeEventListener("popstate",V),y.history&&W&&(y.history.pushState=W),y.history&&$&&(y.history.replaceState=$)}}))),null===(Y=null==t?void 0:t.loggerProvider)||void 0===Y||Y.log("".concat(I," has been successfully added.")),window.opener&&k.enabled&&(K=e.cssSelectorAllowlist,G=e.actionClickAllowlist,function(e,t){var n=e;if(!0!==n[mo]){n[mo]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,a=t.actionClickAllowlist,s=null,u=function(t){e.notify({action:"element-selected",data:t})},l=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var n;s=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:l,onSelect:u,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:a,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:ci}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null===(e=null==s?void 0:s.close)||void 0===e||e.call(s)})}}(J=Nn(),{dataExtractor:O,isElementSelectable:ro(e,d(d([],c(K),!1),c(G),!1)),cssSelectorAllowlist:K,actionClickAllowlist:G}),function(e,t){var n,r=e;if(!0!==r[Mn]){r[Mn]=!0;var i=null!==(n=null==t?void 0:t.scriptUrl)&&void 0!==n?n:"https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",o=null,a=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){var t,n;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Initializing background capture (external script)");var r=new URL(i,e.endpoint).toString();e.loadScriptOnce(r).then(function(){var t,n,r;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),o=null===(r=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===r?void 0:r.call(window,{messenger:e,onBackgroundCapture:a}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null===(e=null==o?void 0:o.close)||void 0===e||e.call(o),o=null})}}(J),J.setup(o({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:Cn[t.serverZone]})))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,r;return u(this,function(i){try{for(e=l(A),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]})})}}},Ho=["mutation","navigate"];function zo(e,t){var n,r,i,o,a=t.event,s=a.pageX,u=a.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:s,s),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:s,s),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Vo(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:o({"[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 Wo(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.pointerDownObservable,a=r.selectionObservable,l=[],c={},d=null;function f(e){l=[],c={},e&&(zo(c,e),l.push(e))}var v=Pn(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return s(t,void 0,void 0,function(){var t;return u(this,function(n){return zo(c,e),t=null,0===l.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(l,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(l,e)||c.isOutOfBounds?(d&&(t=Vo(l)),f(e)):l.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),l.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(Vo(l))},1e3)}})]:[2,null]})})}),p=null==a?void 0:a.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()}}}var $o,Ko;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}($o||($o={})),function(e){e.X="x",e.Y="y"}(Ko||(Ko={}));function Go(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Jo(e){e.changes=[],e.startTime=void 0}function Yo(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var Xo=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new xn(function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},a=void 0,s=null;function u(){void 0!==a&&(e.next(a),a=void 0,null!==s&&clearTimeout(s),Jo(n),Jo(i))}return t.subscribe(function(e){null!==s&&clearTimeout(s),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Ko.X?n:i);var t=function(e,t){var n=void 0;if(Go(e)&&(n=e.startTime),Go(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(a=a||t,s=setTimeout(function(){u(),s=null},o)):u(),Yo(n),Yo(i),function(){null!==s&&(clearTimeout(s),s=null)}})})},Qo=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,a=e.thresholdMs,s=void 0===a?2e3:a,u=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new xn(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===$o.DECREASING&&e.next(Ko.X),r=$o.INCREASING):o.x<n.x&&(r===$o.INCREASING&&e.next(Ko.X),r=$o.DECREASING),o.y>n.y?(i===$o.DECREASING&&e.next(Ko.Y),i=$o.INCREASING):o.y<n.y&&(i===$o.INCREASING&&e.next(Ko.Y),i=$o.DECREASING),n=o):n=o})})}({allWindowObservables:r});return Xo({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:s}).subscribe(function(e){no(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function Zo(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 ea=4e3,ta=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var a=!1!==e.deadClicks&&null!==e.deadClicks,f=!1!==e.rageClicks&&null!==e.rageClicks,v=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(v=!1);var p=Zo(e,"rageClicks",Dt,f),h=Zo(e,"deadClicks",Ct,a),g=Zo(e,"errorClicks",Rt,i),m=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:It,y=new Uo(e),b=d([],c(new Set(d(d(d([],c(p),!1),c(h),!1),c(g),!1))),!1),w=function(){var e,t,n=function(e){return In(So(e).map(function(e){return y.addAdditionalEventProperties(e,"click",b,m,!0)}))},r=n("click"),i=n("pointerdown"),a=In(ko().map(function(e){return y.addTypeAndTimestamp(e,"error")})),s=In(Eo(y.shadowGate).map(function(e){return y.addAdditionalEventProperties(e,"mutation",b,m)}));window.navigation&&(t=In(new xn(function(e){var t=function(t){e.next(o(o({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return y.addAdditionalEventProperties(e,"navigate",b,m)})));var u=In(new xn(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)}})),l=In(new xn(function(e){var t=function(t){e.next(t)},n={capture:!0};return yo.document.addEventListener("mousemove",t,n),function(){yo.document.removeEventListener("mousemove",t,n)}}));return(e={})[jo.ClickObservable]=r,e[jo.PointerDownObservable]=i,e[jo.MutationObservable]=s,e[jo.NavigateObservable]=t,e[jo.BrowserErrorObservable]=a,e[jo.SelectionObservable]=u,e[jo.MouseMoveObservable]=l,e};return{name:n,type:"enrichment",setup:function(t,l){return s(void 0,void 0,void 0,function(){var s,c,d,b,E,S,k,T,x,P,_,I;return u(this,function(u){return"undefined"==typeof document||(s=w(),(c=Fo(t,y))&&r.push({unsubscribe:c}),f&&(d=ro(e,p),b=Wo({allObservables:s,amplitude:l,shouldTrackRageClick:d}),r.push(b)),a&&(E=ro(e,h),S=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,a=n.clickObservable,s=n.mutationObservable,u=n.navigateObservable,l=a.filter(function(e){return po(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Qi.LEFT_OR_TOUCH_CONTACT}),c=u?_n(s,u):s,d=_n(l,c),f=null;return Pn(d,function(e){return f&&Ho.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",o(o({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}})}({amplitude:l,allObservables:s,getEventProperties:function(e,t){return y.getEventProperties(e,t,m)},shouldTrackDeadClick:E}),r.push(S)),i&&(k=ro(e,g),T=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.pointerDownObservable,a=n.browserErrorObservable,s=i.filter(function(e){return po(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Qi.LEFT_OR_TOUCH_CONTACT}),u=null,l=null,c=function(){null!==u&&(clearTimeout(u),u=null),l=null};return _n(s,a).subscribe(function(e){var n;if("click"===e.type)return c(),l=e,void(u=setTimeout(c,2e3));"error"===e.type&&l&&(t.track("[Amplitude] Error Click",o(((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),l.targetElementProperties)),c())})}({amplitude:l,allObservables:s,shouldTrackErrorClick:k}),r.push(T)),v&&(x=void 0,P=void 0,"object"==typeof e.thrashedCursor&&(x=e.thrashedCursor.directionChanges,P=e.thrashedCursor.threshold,x&&x<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(x," is below the minimum of ").concat(5,", setting to ").concat(5)),x=5),P&&P>ea&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(P," is above the maximum of ").concat(ea,", setting to ").concat(ea)),P=ea)),_=Qo({amplitude:l,options:e,allObservables:s,directionChanges:x,thresholdMs:P}),r.push(_)),null===(I=null==t?void 0:t.loggerProvider)||void 0===I||I.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,i;return u(this,function(o){try{for(e=l(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]})})}}};function na(e,t){var n=e.startTime+e.duration;return t.filter(function(t){return t.startTime<n&&t.startTime+t.duration>e.startTime}).map(function(e){return e.name})}function ra(e,t){var n,r=na(e,t),i=null!==(n=e.scripts)&&void 0!==n?n:[],a=i.map(function(e){return e.sourceURL}).filter(Boolean),s=i.map(function(e){return e.sourceFunctionName}).filter(Boolean),u=i.map(function(e){return e.sourceCharPosition}).filter(function(e){return"number"==typeof e&&e>=0}),l=i.map(function(e){return e.invokerType}).filter(Boolean),c=i.map(function(e){return e.invoker}).filter(Boolean);return o(o(o(o(o(o(o({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.blockingDuration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),{"[Amplitude] Main Thread Block Render Start":e.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":e.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),a.length>0&&{"[Amplitude] Main Thread Block Script URLs":a}),s.length>0&&{"[Amplitude] Main Thread Block Script Functions":s}),u.length>0&&{"[Amplitude] Main Thread Block Script Positions":u}),l.length>0&&{"[Amplitude] Main Thread Block Invoker Types":l}),c.length>0&&{"[Amplitude] Main Thread Block Invokers":c})}function ia(e,t){var n,r=na(e,t),i=null!==(n=e.attribution)&&void 0!==n?n:[];return o(o({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.duration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(e){return e.name})})}function oa(e){var t=e.amplitude,n=e.options,r=e.durationThreshold,i=void 0===r?100:r,o=function(){if("undefined"==typeof PerformanceObserver)return null;try{var e=PerformanceObserver.supportedEntryTypes;if(e.includes("long-animation-frame"))return"long-animation-frame";if(e.includes("longtask"))return"longtask"}catch(e){}return null}();if(!o)return{unsubscribe:function(){}};var a=[],s=new PerformanceObserver(function(e){var t,n,r=performance.now();try{for(var i=l(e.getEntries()),o=i.next();!o.done;o=i.next()){var s=o.value;a.push(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}for(var u=r-1e4;a.length>0&&a[0].startTime<u;)a.shift()});try{s.observe({entryTypes:["measure"]})}catch(e){}var u=new PerformanceObserver(function(e){var r,s;try{for(var u=l(e.getEntries()),c=u.next();!c.done;c=u.next()){var d=c.value;if(!no(n))return;if(!(d.duration<i)){var f="long-animation-frame"===o?ra(d,a):ia(d,a);t.track("[Amplitude] Main Thread Block",f)}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}});try{u.observe({entryTypes:[o]})}catch(e){return s.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){u.disconnect(),s.disconnect()}}}var aa,sa,ua=function(e){void 0===e&&(e={});var t="@amplitude/plugin-performance-browser",n=[],r=!0===e.mainThreadBlock||"object"==typeof e.mainThreadBlock&&null!==e.mainThreadBlock;return{name:t,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var a,s,l;return u(this,function(u){return"undefined"==typeof document||(r&&(a=100,"object"==typeof e.mainThreadBlock&&void 0!==e.mainThreadBlock.durationThreshold&&(a=e.mainThreadBlock.durationThreshold),s=oa({amplitude:o,options:e,durationThreshold:a}),n.push(s)),null===(l=null==i?void 0:i.loggerProvider)||void 0===l||l.log("".concat(t," performance tracking has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,r,i;return u(this,function(o){try{for(e=l(n),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]})})}}},la="[Amplitude] Network Request",ca="500-599";function da(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function fa(e,t){var n,r,i=t.split(",");try{for(var o=l(i),a=o.next();!a.done;a=o.next()){var s=c(a.value.split("-").map(Number),2),u=s[0],d=s[1];if(e===u&&void 0===d)return!0;if(e>=u&&e<=d)return!0}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function va(e){var t;if(e)try{var n=null===(t=B())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),a=r.href,s=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:r.href,host:s}}catch(t){try{return function(e){var t,n=e.indexOf("#"),r=n>=0?e.slice(n+1):"",i=n>=0?e.slice(0,n):e,o=i.indexOf("?"),a=o>=0?i.slice(o+1):"",s=o>=0?i.slice(0,o):i,u=s.match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i);return{query:a,fragment:r,href:e,hrefWithoutQueryOrHash:s,host:null!==(t=null==u?void 0:u[1])&&void 0!==t?t:""}}(e)}catch(e){return}}}function pa(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return d([],c(R),!1);if(void 0===e){return}}}function ha(e){var t,n,r;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)&&!(null===(r=null==e?void 0:e.excludelist)||void 0===r?void 0:r.length)}function ga(e,t){var n;void 0===t&&(t={});var r=va(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(da(o,"*.amplitude.com")||da(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find(function(e){return da(o,e)}))return!1;if(!t.captureRules&&void 0!==e.status&&!fa(e.status,ca))return!1;if(t.captureRules&&(d([],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 da(t,e)}))&&(!r||!e.urls||qe(r,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return!((n||0===n)&&!fa(n,e.statusCodeRange||ca))}(t,o,e.status,e.url,e.method),i){var n=pa(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var a=pa(t.requestHeaders);if(e.requestWrapper&&a){var s=e.requestWrapper.headers(a);s&&(e.requestHeaders=s)}if(e.responseWrapper&&t.responseBody&&!ha(t.responseBody)){var u=t.responseBody.excludelist||t.responseBody.blocklist;e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,u)}if(e.requestWrapper&&t.requestBody&&!ha(t.requestBody)){u=t.requestBody.excludelist||t.requestBody.blocklist;e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,u)}}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===la}))return!0}catch(e){}return!1}(o,e.requestWrapper)}function ma(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return ga(e.event,n)}).subscribe(function(e){var t,n,o,a=e.event,l=va(a.url);if(l){var d=null===(n=a.responseWrapper)||void 0===n?void 0:n.bodySize,f=null===(o=a.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){s(this,void 0,void 0,function(){var i,o,a;return u(this,function(s){switch(s.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,[s.sent(),2]),o=i[0],a=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(a)try{e["[Amplitude] Response Body"]=JSON.stringify(a)}catch(e){null==r||r.debug("Failed to stringify response body")}s.label=2;case 2:return null==n||n.track(la,e),[2]}})})}(((t={})["[Amplitude] URL"]=l.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=l.query,t["[Amplitude] URL Fragment"]=l.fragment,t["[Amplitude] Request Method"]=a.method,t["[Amplitude] Status Code"]=a.status,t["[Amplitude] Start Time"]=a.startTime,t["[Amplitude] Completion Time"]=a.endTime,t["[Amplitude] Duration"]=a.duration,t["[Amplitude] Request Body Size"]=f,t["[Amplitude] Response Body Size"]=d,t["[Amplitude] Request Type"]=a.type,t["[Amplitude] Request Headers"]=a.requestHeaders,t["[Amplitude] Response Headers"]=a.responseHeaders,t),a,r,i)}})}!function(e){e.NetworkObservable="networkObservable"}(aa||(aa={}));var ya=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new xn(function(e){var n=new Yt(function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)});return Zt.subscribe(n,t),function(){Zt.unsubscribe(n)}});return(e={})[aa.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var a;return u(this,function(s){return"undefined"!=typeof document||function(){var e,t=B();return"ReactNative"===(null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.product)}()?(a=r(),t=null==i?void 0:i.loggerProvider,sa=ma({allObservables:a,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added.")),[2]):[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return sa.unsubscribe(),[2]})})}}};let ba=-1;const wa=e=>{addEventListener("pageshow",t=>{t.persisted&&(ba=t.timeStamp,e(t))},!0)},Ea=(e,t,n,r)=>{let i,o;return a=>{t.value>=0&&(a||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)))}},Sa=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},ka=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},Ta=()=>{const e=ka();return e?.activationStart??0},xa=(e,t=-1)=>{const n=ka();let r="navigate";return ba>=0?r="back-forward-cache":n&&(document.prerendering||Ta()>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}},Pa=new WeakMap;function _a(e,t){return Pa.get(e)||Pa.set(e,new t),Pa.get(e)}class Ia{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 Aa=(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{}},Oa=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let Ca=-1;const Ra=new Set,Da=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,La=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Ra)e();isFinite(Ca)||(Ca="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",La,!0))}},Na=()=>{if(Ca<0){const e=Ta(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime;Ca=t??Da(),addEventListener("visibilitychange",La,!0),addEventListener("prerenderingchange",La,!0),wa(()=>{setTimeout(()=>{Ca=Da()})})}return{get firstHiddenTime(){return Ca},onHidden(e){Ra.add(e)}}},Ma=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},ja=[1800,3e3],Ua=(e,t={})=>{Ma(()=>{const n=Na();let r,i=xa("FCP");const o=Aa("paint",e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Ta(),0),i.entries.push(t),r(!0)))});o&&(r=Ea(e,i,ja,t.reportAllChanges),wa(n=>{i=xa("FCP"),r=Ea(e,i,ja,t.reportAllChanges),Sa(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Fa=[.1,.25];let qa=0,Ba=1/0,Ha=0;const za=e=>{for(const t of e)t.interactionId&&(Ba=Math.min(Ba,t.interactionId),Ha=Math.max(Ha,t.interactionId),qa=Ha?(Ha-Ba)/7+1:0)};let Va;const Wa=()=>Va?qa:performance.interactionCount??0;let $a=0;class Ka{u=[];l=new Map;m;p;v(){$a=Wa(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((Wa()-$a)/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 Ga=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=Oa(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},Ja=[200,500],Ya=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=Na();Ma(()=>{"interactionCount"in performance||Va||(Va=Aa("event",za,{type:"event",buffered:!0,durationThreshold:0}));let r,i=xa("INP");const o=_a(t,Ka),a=e=>{Ga(()=>{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())})},s=Aa("event",a,{durationThreshold:t.durationThreshold??40});r=Ea(e,i,Ja,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{a(s.takeRecords()),r(!0)}),wa(()=>{o.v(),i=xa("INP"),r=Ea(e,i,Ja,t.reportAllChanges)}))})};class Xa{m;h(e){this.m?.(e)}}const Qa=[2500,4e3],Za=[800,1800],es=e=>{document.prerendering?Ma(()=>es(e)):"complete"!==document.readyState?addEventListener("load",()=>es(e),!0):setTimeout(e)};function ts(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function ns(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(ts(e)),navigationStart:Math.floor(performance.timeOrigin)}}var rs,is=function(){var e=null,t=B(),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,a;return u(this,function(s){return void 0===n||(o=Be((null==r?void 0:r.href)||"",t.loggerProvider),a={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":Be((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":Be(o.split("?")[0],t.loggerProvider)},((e,t={})=>{Ma(()=>{const n=Na();let r,i=xa("LCP");const o=_a(t,Xa),a=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-Ta(),0),i.entries=[t],r())},s=Aa("largest-contentful-paint",a);if(s){r=Ea(e,i,Qa,t.reportAllChanges);const n=Oa(()=>{a(s.takeRecords()),s.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(Ga(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});wa(n=>{i=xa("LCP"),r=Ea(e,i,Qa,t.reportAllChanges),Sa(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(function(e){a["[Amplitude] LCP"]=ns(e)}),Ua(function(e){a["[Amplitude] FCP"]=ns(e)}),Ya(function(e){a["[Amplitude] INP"]=ns(e)}),((e,t={})=>{const n=Na();Ua(Oa(()=>{let r,i=xa("CLS",0);const o=_a(t,Ia),a=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},s=Aa("layout-shift",a);s&&(r=Ea(e,i,Fa,t.reportAllChanges),n.onHidden(()=>{a(s.takeRecords()),r(!0)}),wa(()=>{o.i=0,i=xa("CLS",0),r=Ea(e,i,Fa,t.reportAllChanges),Sa(()=>r())}),setTimeout(r))}))})(function(e){a["[Amplitude] CLS"]=ns(e)}),((e,t={})=>{let n=xa("TTFB"),r=Ea(e,n,Za,t.reportAllChanges);es(()=>{const i=ka();i&&(n.value=Math.max(i.responseStart-Ta(),0),n.entries=[i],r(!0),wa(()=>{n=xa("TTFB",0),r=Ea(e,n,Za,t.reportAllChanges),r(!0)}))})})(function(e){a["[Amplitude] TTFB"]=ns(e)}),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},os=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=o({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=(null===(n=t.cookieOptions)||void 0===n?void 0:n.domain)||t.topLevelDomain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[]),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=Ge(t.apiKey,"MKTG"),this.webExpStorageKey=Ge(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=C,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return s(this,void 0,void 0,function(){var e,t;return u(this,function(n){switch(n.label){case 0:return this.options.optOut?[2]:[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||Ne(this.sessionTimeout,this.lastEventTime),qr(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(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 u(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 en).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,a=(t=this.currentCampaign,n=this.options,r=o(o({},C),t),i=Object.entries(r).reduce(function(e,t){var r,i=c(t,2),o=i[0],a=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=a?a:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),a?e.set(o,a):e.unset(o)},new M),Z(i));return e&&(a.event_id=e),a},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),as=new Set([i.IDENTIFY,i.GROUP_IDENTIFY]),ss=function(e){var t;void 0===e&&(e={});var n,r,i,a,l,c,d=null!==(t=e.fallbackAttributionEvent)&&void 0!==t&&t,f=B(),v={},p=!1,h=!1,g=function(){return s(void 0,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return[4,(new en).parse()];case 1:return e=t.sent(),v=ze(e),d&&(null==r||r.log("Tracking attribution fallback event."),null==n||n.track("[Amplitude] Attribution",v)),[2]}})})},m=function(){g()},y=function(e){return new Proxy(e,{apply:function(e,t,n){Reflect.apply(e,t,n),p&&m()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){return u(this,function(o){switch(o.label){case 0:return n=t,r=e.loggerProvider,p=!0,r.log("Installing event property attribution tracking."),[4,g()];case 1:if(o.sent(),!f)return[2];if(f.addEventListener("popstate",m),!h){if(i=Reflect.get(f.history,"pushState"),a=Reflect.get(f.history,"replaceState"),!i||!a)return[2];l=y(i),f.history.pushState=l,c=y(a),f.history.replaceState=c,h=!0}return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return as.has(e.event_type)||(e.event_properties=o(o({},v),e.event_properties)),[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t;return u(this,function(n){return f&&(f.removeEventListener("popstate",m),e=Reflect.get(f.history,"pushState"),t=Reflect.get(f.history,"replaceState"),h&&e===l&&i&&(f.history.pushState=i),h&&t===c&&a&&(f.history.replaceState=a)),p=!1,h=!1,i=void 0,a=void 0,l=void 0,c=void 0,v={},[2]})})}}},us="AMP_CURRENT_PAGE",ls="AMP_PREVIOUS_PAGE",cs="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(rs||(rs={}));var ds=new Set([i.IDENTIFY,i.GROUP_IDENTIFY,i.REVENUE]),fs=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=B(),i=void 0,a=!1,l=void 0,d=!1,f=!1,v=function(e){var t;try{var n=Be(e,l);t=new URL(n).hostname}catch(e){null==l||l.error("Could not parse URL: ",e)}return t},p=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?v(e):void 0;if(!r)return rs.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?rs.Internal:rs.External},h=function(){return s(void 0,void 0,void 0,function(){var e,t,n,r,o;return u(this,function(s){switch(s.label){case 0:return i&&a?[4,i.get(cs)]:[3,3];case 1:return e=s.sent(),t=Be("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[us])||"",r=void 0,r=t===n?(null==e?void 0:e[ls])||"":n||(document.referrer||""),[4,i.set(cs,(o={},o[us]=t,o[ls]=r,o))];case 2:s.sent(),s.label=3;case 3:return[2]}})})},g=function(){h()},m={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){var t,n,o,s,p,m,y,b;return u(this,function(u){switch(u.label){case 0:if((l=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),f=!0,!r)return[3,7];try{i=new Je(r.sessionStorage)}catch(e){null==l||l.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:return a=null!==(b=u.sent())&&void 0!==b&&b,i&&a?(t="undefined"!=typeof document&&document.referrer||"",n=t?v(t):void 0,o="undefined"!=typeof location&&location.hostname||"",s=Be("undefined"!=typeof location&&location.href||""),[4,i.get(cs)]):[3,6];case 2:return p=u.sent(),m=(null==p?void 0:p[us])||"",!!n&&n!==o&&m!==s?[4,i.set(cs,(y={},y[us]=s,y[ls]=t,y))]:[3,4];case 3:return u.sent(),[3,6];case 4:return[4,h()];case 5:u.sent(),u.label=6;case 6:r.addEventListener("popstate",g),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],a=r[2];e.apply(t,[i,o,a]),f&&g()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),f&&g()}}),d=!0),u.label=7;case 7:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,n,r;return u(this,function(s){switch(s.label){case 0:return t=Be("undefined"!=typeof location&&location.href||""),i&&a?[4,i.get(cs)]:[3,2];case 1:if(n=s.sent(),r=(null==n?void 0:n[ls])||"",ds.has(e.event_type))return[2,e];e.event_properties=o(o({},e.event_properties||{}),{"[Amplitude] Page Domain":vs(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":vs(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":vs(e,"[Amplitude] Page Path","undefined"!=typeof location&&Be(location.pathname)||""),"[Amplitude] Page Title":vs(e,"[Amplitude] Page Title",un(sn)),"[Amplitude] Page URL":vs(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":r,"[Amplitude] Previous Page Type":p(r)}),s.label=2;case 2:return[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",g),f=!1),i&&a?[4,i.set(cs,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}};return m};function vs(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var ps=function(){var e,t,n;function r(t){if(t)try{var n=new Function("return "+t)();if("function"==typeof n)return n;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}var i={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var o,a;return u(this,function(s){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null===(a=i.remoteConfig)||void 0===a?void 0:a.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(e){n=e&&function(e){return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body}(e)?r(e.body||""):r("")}),t=function(){var e;return null===(e=i.remoteConfigClient)||void 0===e?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(t){return s(void 0,void 0,void 0,function(){var r;return u(this,function(i){if(n)try{return[2,null!==(r=n(t))&&void 0!==r?r:null]}catch(n){return null==e||e.error("Could not execute custom enrichment function",n),[2,t]}return[2,t]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return t&&t(),[2]})})}};return i},hs="userProperty",gs="eventProperty",ms=function(e){return e===hs||e===gs},ys=[hs,gs],bs=function(e,t){return function(e){var t=d([],c(new Set((Array.isArray(e)?e:[e]).filter(ms))),!1);return t.length>0?t:d([],c(ys),!1)}(e.trackingMethod).includes(t)},ws=function(e){return bs(e,hs)},Es=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return n(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),ee(this._init(o(o({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,l,c,d,f,v;return s(this,void 0,void 0,function(){var p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A=this;return u(this,function(O){switch(O.label){case 0:return this.initializing?[2]:(this.initializing=!0,p=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),h=null!==(n=t.loggerProvider)&&void 0!==n?n:new oe,t.loggerProvider||h.enable(null!==(r=t.logLevel)&&void 0!==r?r:re.Warn),g=null!==(i=t.serverZone)&&void 0!==i?i:jr,y=this._diagnosticsSampleRate,b=null===(l=t.enableDiagnostics)||void 0===l||l,p?(m=new bt(t.apiKey,h,g,null===(c=t.remoteConfig)||void 0===c?void 0:c.serverUrl),[4,new Promise(function(e){null==m||m.subscribe("configs.diagnostics.browserSDK","all",function(t,n,r){if(h.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(y=i);var o=t.enabled;"boolean"==typeof o&&(b=o)}e()})})]):[3,2]);case 1:O.sent(),O.label=2;case 2:return(w=new dt(t.apiKey,h,g,{enabled:b,sampleRate:y})).setTag("library","".concat(lr,"/").concat(ur)),w.setTag("platform","Web"),w.setTag("web_environment",function(){var e=B();if(!e)return"unknown";var t=function(e){var t,n;return"string"==typeof(null===(n=null===(t=e.chrome)||void 0===t?void 0:t.runtime)||void 0===n?void 0:n.id)}(e);return function(e){var t=e.ServiceWorkerGlobalScope;return"function"==typeof t&&e instanceof t}(e)?t?"chrome_extension_service_worker":"service_worker":function(e){var t=e.WorkerGlobalScope;return"function"==typeof t&&e instanceof t}(e)?"web_worker":function(e){return void 0!==e.document}(e)?t?"chrome_extension":"browser":function(e){var t,n;return"string"==typeof(null===(n=null===(t=e.process)||void 0===t?void 0:t.versions)||void 0===n?void 0:n.node)}(e)?"node":"unknown"}()),"undefined"!=typeof navigator&&w.setTag("user_agent",navigator.userAgent),[4,Gr(t.apiKey,t,this,w,{loggerProvider:h,serverZone:g,enableDiagnostics:b,diagnosticsSampleRate:y})];case 3:return E=O.sent(),p&&m?[4,new Promise(function(e){null==m||m.subscribe("configs.analyticsSDK.browserSDK","all",function(t,n,r){E.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&li(t,E),e()})})]:[3,5];case 4:O.sent(),O.label=5;case 5:return[4,e.prototype._init.call(this,E)];case 6:return O.sent(),this.logBrowserOptions(E),this.config.remoteConfigClient=m,D=this.config,S=Kn(D.defaultTracking)&&D.defaultTracking&&"object"==typeof D.defaultTracking&&D.defaultTracking.attribution&&"object"==typeof D.defaultTracking.attribution?o({},D.defaultTracking.attribution):{},Kn(this.config.defaultTracking)&&ws(S)?(this.config.optOut&&this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e?[3,2]:(this.webAttribution=new os(S,this.config),[4,this.webAttribution.init()]);case 1:t.sent(),t.label=2;case 2:return[2]}})})}),this.webAttribution=new os(S,this.config),[4,this.webAttribution.init()]):[3,8];case 7:O.sent(),O.label=8;case 8:return k=Ue(),T=k.ampTimestamp?Number(k.ampTimestamp):void 0,x=!T||Date.now()<T,P=x&&!Number.isNaN(Number(k.ampSessionId))?Number(k.ampSessionId):void 0,-1!==(_=this.config.deferredSessionId)||this.config.optOut||(_=Date.now()),this.setSessionId(null!==(v=null!==(f=null!==(d=t.sessionId)&&void 0!==d?d:P)&&void 0!==f?f:_)&&void 0!==v?v:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),(I=De(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(ui()).promise];case 9:O.sent(),O.label=10;case 10:return[4,this.add(new we({diagnosticsClient:w})).promise];case 11:return O.sent(),[4,this.add(new cr).promise];case 12:return O.sent(),[4,this.add(new Le).promise];case 13:return O.sent(),function(e){si||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."),si=!0)}(this.config),R=this.config.defaultTracking,$n(R,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(ai()).promise]):[3,15];case 14:O.sent(),O.label=15;case 15:return Gn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(ri()).promise]):[3,17];case 16:O.sent(),O.label=17;case 17:return Jn(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Zr(ir(this.config))).promise]):[3,20];case 18:return O.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Zr(ir(this.config))).promise]);case 1:return t.sent(),[2]}})})}),O.label=20;case 20:return Kn(this.config.defaultTracking)&&function(e){return bs(e,gs)}(S)?(this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(ss(S)).promise]):[3,22];case 21:O.sent(),O.label=22;case 22:return Qn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Bo(tr(this.config),{diagnosticsClient:w})).promise]):[3,24];case 23:O.sent(),O.label=24;case 24:return Zn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(ta(nr(this.config))).promise]):[3,26];case 25:O.sent(),O.label=26;case 26:return Xn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(ya(rr(this.config))).promise]):[3,28];case 27:O.sent(),O.label=28;case 28: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(is()).promise]):[3,30];case 29:O.sent(),O.label=30;case 30:return function(e){return"object"==typeof e&&(!0===e.performanceTracking||"object"==typeof e.performanceTracking)}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(ua(er(this.config))).promise]):[3,32];case 31:O.sent(),O.label=32;case 32:return function(e){return $n(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(fs()).promise]):[3,34];case 33:O.sent(),O.label=34;case 34:return("boolean"==typeof(C=this.config.customEnrichment)?C:"object"==typeof C&&null!==C&&!1!==C.enabled)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(ps()).promise]):[3,36];case 35:O.sent(),O.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return O.sent(),I.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=a(t,["time"]),i="number"==typeof n?{time:n}:void 0;A.track(e.eventType,r,i)}),[2]}var C,R,D})})},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.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){De(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.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){De(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(z()),this.setUserId(void 0),this.timeline.onReset()},t.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}},t.prototype.setIdentity=function(e){var t,n,r;if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var i=new M,o=null!==(r=e.userProperties)&&void 0!==r?r:{};try{for(var a=l(Object.entries(o)),s=a.next();!s.done;s=a.next()){var u=c(s.value,2),d=u[0],f=u[1];i.set(d,f)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),ee(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,ee(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return ee(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,Yn(this.config.defaultTracking)&&(r&&i&&n.push(this.track(_r,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 a=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Z(this.config.identify)).promise),Yn(this.config.defaultTracking)&&n.push(this.track(Pr,void 0,{event_id:a?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,ee(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Yr(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(sr(t)){var r=t._q;t._q=[],t=ar(new M,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)},t.prototype.groupIdentify=function(t,n,r,i){if(sr(r)){var o=r._q;r._q=[],r=ar(new M,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(sr(t)){var r=t._q;t._q=[],t=ar(new ne,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!ws(this.webAttribution.options))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},t.prototype.process=function(t){return s(this,void 0,void 0,function(){var n,r,i;return u(this,function(o){return n=Date.now(),r=Ne(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===Pr||t.event_type===_r||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},t.prototype.logBrowserOptions=function(e){try{var t=o(o({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",X(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t}(te),Ss=function(){var e=new Es;return{init:ge(e.init.bind(e),"init",ve(e),he(e,["config"])),add:ge(e.add.bind(e),"add",ve(e),he(e,["config.apiKey","timeline.plugins"])),remove:ge(e.remove.bind(e),"remove",ve(e),he(e,["config.apiKey","timeline.plugins"])),track:ge(e.track.bind(e),"track",ve(e),he(e,["config.apiKey","timeline.queue.length"])),logEvent:ge(e.logEvent.bind(e),"logEvent",ve(e),he(e,["config.apiKey","timeline.queue.length"])),identify:ge(e.identify.bind(e),"identify",ve(e),he(e,["config.apiKey","timeline.queue.length"])),groupIdentify:ge(e.groupIdentify.bind(e),"groupIdentify",ve(e),he(e,["config.apiKey","timeline.queue.length"])),setGroup:ge(e.setGroup.bind(e),"setGroup",ve(e),he(e,["config.apiKey","timeline.queue.length"])),revenue:ge(e.revenue.bind(e),"revenue",ve(e),he(e,["config.apiKey","timeline.queue.length"])),flush:ge(e.flush.bind(e),"flush",ve(e),he(e,["config.apiKey","timeline.queue.length"])),getUserId:ge(e.getUserId.bind(e),"getUserId",ve(e),he(e,["config","config.userId"])),setUserId:ge(e.setUserId.bind(e),"setUserId",ve(e),he(e,["config","config.userId"])),getDeviceId:ge(e.getDeviceId.bind(e),"getDeviceId",ve(e),he(e,["config","config.deviceId"])),setDeviceId:ge(e.setDeviceId.bind(e),"setDeviceId",ve(e),he(e,["config","config.deviceId"])),reset:ge(e.reset.bind(e),"reset",ve(e),he(e,["config","config.userId","config.deviceId"])),getSessionId:ge(e.getSessionId.bind(e),"getSessionId",ve(e),he(e,["config"])),setSessionId:ge(e.setSessionId.bind(e),"setSessionId",ve(e),he(e,["config"])),extendSession:ge(e.extendSession.bind(e),"extendSession",ve(e),he(e,["config"])),setOptOut:ge(e.setOptOut.bind(e),"setOptOut",ve(e),he(e,["config"])),setTransport:ge(e.setTransport.bind(e),"setTransport",ve(e),he(e,["config"])),getIdentity:ge(e.getIdentity.bind(e),"getIdentity",ve(e),he(e,["config"])),setIdentity:ge(e.setIdentity.bind(e),"setIdentity",ve(e),he(e,["config","config.userId","config.deviceId"])),getOptOut:ge(e.getOptOut.bind(e),"getOptOut",ve(e),he(e,["config"])),_setDiagnosticsSampleRate:ge(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",ve(e),he(e,["config"]))}},ks=Ss(),Ts=new Set(["playing","waiting"]),xs=function(){function e(e){this.amplitude=e,this.videoEl=null,this.embeddedVideoPlayer=null,this.extraEventProperties={},this.stopEvent=null,this.listeners=[],this.onRemoveListeners=[],this.playId=null,this.playStartTime=null,this.heartbeat=function(e,t){var n=Se.get(e);if(n)return n;var r=new Ee(e,6e4,36e5,t);return Se.set(e,r),r}(this.amplitude)}return e.prototype.withVideoElement=function(e){return this.videoEl=e,this},e.prototype.withEmbeddedPlayer=function(e){return this.embeddedVideoPlayer=e,this},e.prototype.withVendor=function(e){return this.vendor=e,this},e.prototype.withExtraEventProperties=function(e){return this.extraEventProperties=e,this},e.prototype.captureVideoStarted=function(){var e=this;return this.listeners.push(function(t,n){var r,i;if(!Ts.has(t.playbackState)&&"playing"===n.playbackState){e.playId=z(),e.playStartTime=null!==(i=null===(r=n.lastEvent)||void 0===r?void 0:r.start_time)&&void 0!==i?i:0;var a=(new Date).getTime(),s={insert_id:z(),event_type:Tr,time:a,event_properties:o(o(o(o({},n.lastEvent),e.parseStartEventProperties(n)),e.extraEventProperties),{play_id:e.playId})};e.stopEvent=o(o({},s),{insert_id:z(),event_type:xr,time:a+1,event_properties:o(o(o(o({},n.lastEvent),e.parseStopEventProperties(n)),e.extraEventProperties),{stop_reason:"timeout",play_id:e.playId})}),e.heartbeat.trackNoDelay(s).catch(e.stop.bind(e)),e.heartbeat.track(e.stopEvent).catch(e.stop.bind(e))}}),this},e.prototype.captureVideoStopped=function(){var e=this;return this.listeners.push(function(t,n){e.stopEvent&&(e.stopEvent.event_properties=o(o(o({},e.stopEvent.event_properties),e.parseStopEventProperties(n)),e.extraEventProperties),e.stopEvent.time=(new Date).getTime(),e.heartbeat.update(e.stopEvent)),Ts.has(t.playbackState)&&!Ts.has(n.playbackState)&&e.flushStopEvent(n.playbackState)}),this},e.prototype.flushStopEvent=function(e){var t=this.stopEvent;t&&(this.stopEvent=null,this.playStartTime=null,t.event_properties=o(o({},t.event_properties),{stop_reason:e}),this.heartbeat.trackNoDelay(t).catch(this.stop.bind(this)))},e.prototype.start=function(){var e,t=this,n=null!==(e=this.videoEl)&&void 0!==e?e:this.embeddedVideoPlayer;if(!n)throw new Error("Video element not specified. Use withVideoElement() or withEmbeddedPlayer() to specify the video element.");if(this.videoEl&&this.embeddedVideoPlayer)throw new Error("Both video element and embedded video player specified. Use only one of withVideoElement() or withEmbeddedPlayer() to specify the video element.");var r=new zn({videoEl:n,onStateChange:function(e,n){t.listeners.forEach(function(t){return t(e,n)})},vendor:this.vendor,isEmbedded:!!this.embeddedVideoPlayer});return this.onRemoveListeners.push(function(){r.destroy()}),this},e.prototype.stop=function(){this.onRemoveListeners.forEach(function(e){return e()}),this.onRemoveListeners=[],this.flushStopEvent("untracked")},e.prototype.parseStartEventProperties=function(e){var t,n,r,i,o;return{duration:null!==(n=null===(t=e.lastEvent)||void 0===t?void 0:t.duration)&&void 0!==n?n:0,start_time:null!==(i=null===(r=e.lastEvent)||void 0===r?void 0:r.start_time)&&void 0!==i?i:0,position:null!==(o=e.position)&&void 0!==o?o:0,delivery_mode:this.getDeliveryMode()}},e.prototype.getDeliveryMode=function(){return this.videoEl instanceof HTMLAudioElement?"audio":"video"},e.prototype.parseStopEventProperties=function(e){var t,n,r,i,a,s,u;return o(o({},this.parseStartEventProperties(e)),{start_time:null!==(r=null!==(t=this.playStartTime)&&void 0!==t?t:null===(n=e.lastEvent)||void 0===n?void 0:n.start_time)&&void 0!==r?r:0,watch_duration:null!==(i=e.watchTime)&&void 0!==i?i:0,percent_completed:Ps(null!==(a=e.position)&&void 0!==a?a:0,null!==(u=null===(s=e.lastEvent)||void 0===s?void 0:s.duration)&&void 0!==u?u:0)})},e}();function Ps(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.min(100,Math.max(0,e/t*100))}var _s=ks.add,Is=ks.extendSession,As=ks.flush,Os=ks.getDeviceId,Cs=ks.getIdentity,Rs=ks.getOptOut,Ds=ks.getSessionId,Ls=ks.getUserId,Ns=ks.groupIdentify,Ms=ks.identify,js=ks.init,Us=ks.logEvent,Fs=ks.remove,qs=ks.reset,Bs=ks.revenue,Hs=ks.setDeviceId,zs=ks.setGroup,Vs=ks.setIdentity,Ws=ks.setOptOut,$s=ks.setSessionId,Ks=ks.setTransport,Gs=ks.setUserId,Js=ks.track,Ys=ks._setDiagnosticsSampleRate,Xs=Object.freeze({__proto__:null,add:_s,extendSession:Is,flush:As,getDeviceId:Os,getIdentity:Cs,getOptOut:Rs,getSessionId:Ds,getUserId:Ls,groupIdentify:Ns,identify:Ms,init:js,logEvent:Us,remove:Fs,reset:qs,revenue:Bs,setDeviceId:Hs,setGroup:zs,setIdentity:Vs,setOptOut:Ws,setSessionId:$s,setTransport:Ks,setUserId:Gs,track:Js,_setDiagnosticsSampleRate:Ys,createInstance:Ss,AmplitudeBrowser:Es,runQueuedFunctions:or,Revenue:ne,Identify:M,trackVideo:function(e,t,n){var r;void 0===n&&(n={});var i=new xs(e);t instanceof HTMLMediaElement?i.withVideoElement(t):i.withEmbeddedPlayer(t),n.vendor&&i.withVendor(n.vendor);var a=null!==(r=n.extraEventProperties)&&void 0!==r?r:{};try{i.withExtraEventProperties(o({view_session_id:z()},a)).captureVideoStarted().captureVideoStopped().start()}catch(e){return e}return function(){return i.stop()}},Types:Ur});!function(e){if(e.scriptUrl){var t=at(e.scriptUrl);t&&function(e){var t=B();if(t){var n=it();n.includes(e)||(n.push(e),t[rt]=n)}}(t)}}({scriptUrl:function(){if("undefined"==typeof document)return;var e=document.currentScript;if(null==e?void 0:e.src)return e.src;return}()}),function(){var e=B();if(e){var t=function(e){var t=Ss(),n=B();return n&&n.amplitude&&n.amplitude._iq&&e&&(n.amplitude._iq[e]=t),t};if(e.amplitude=Object.assign(e.amplitude||{},Xs,{createInstance:t}),e.amplitude.invoked){var n=e.amplitude._q;e.amplitude._q=[],or(Xs,n);for(var r=Object.keys(e.amplitude._iq)||[],i=0;i<r.length;i++){var o=r[i],a=Object.assign(e.amplitude._iq[o],t(o)),s=a._q;a._q=[],or(a,s)}}}else console.error("[Amplitude] Error: GlobalScope is not defined")}()}();
1
+ !function(){"use strict";function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var t=function(e,n){return t=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])},t(e,n)};function n(e,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=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,i,o=function(){return o=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},o.apply(this,arguments)};function a(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 a(e){try{u(r.next(e))}catch(e){o(e)}}function s(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(a,s)}u((r=r.apply(e,t||[])).next())})}function u(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function l(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),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}function d(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"}(r||(r={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(i||(i={}));var f,v="AMP",p="".concat(v,"_unsent"),h="$default_instance",g="https://api2.amplitude.com/2/httpapi",m="https://api.eu.amplitude.com/2/httpapi",y="https://api2.amplitude.com/batch",b="https://api.eu.amplitude.com/batch",w="dclid",E="fbclid",S="gbraid",k="gclid",T="ko_click_id",x="li_fat_id",P="msclkid",_="rdt_cid",I="ttclid",A="twclid",O="wbraid",C={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},R=["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"],D=["authorization","cookie","set-cookie"],L=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!N(t,n))return!1}return!0},N=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if("object"==typeof s)i=i&&L(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return L(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},M=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return o({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(f.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(f.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(f.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(f.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(f.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(f.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(f.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(f.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(f.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[f.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[f.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===f.ADD?"number"==typeof n:e===f.UNSET||e===f.REMOVE||N(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"}(f||(f={}));var j,U=[f.CLEAR_ALL,f.UNSET,f.SET,f.SET_ONCE,f.ADD,f.APPEND,f.PREPEND,f.PREINSERT,f.POSTINSERT,f.REMOVE],F="Event skipped due to empty event type";!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"}(j||(j={}));var q=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=j.Unknown),{event:e,code:t,message:n}},B=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},H=d([],c(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),z=function(e){var t,n=B();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,z)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,d([],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(H[r]):H[r]}).join("")},V={},W={get exports(){return V},set exports(e){V=e}},$=Object.prototype.hasOwnProperty;function K(e){return"[Throws: "+(e?e.message:"?")+"]"}function G(e){var t=[];return function e(n){if(null===n||"object"!=typeof n)return n;if(-1!==t.indexOf(n))return"[Circular]";if(t.push(n),"function"==typeof n.toJSON)try{var r=e(n.toJSON());return t.pop(),r}catch(e){return K(e)}if(Array.isArray(n)){var i=n.map(e);return t.pop(),i}var o=Object.keys(n).reduce(function(t,r){return t[r]=e(function(e,t){if($.call(e,t))try{return e[t]}catch(e){return K(e)}return e[t]}(n,r)),t},{});return t.pop(),o}(e)}W.exports=function(e,t,n){return JSON.stringify(G(e),t,n)};var J,Y=V.ensureProperties=G,X=V||e({__proto__:null,ensureProperties:Y,get default(){return V}},[V]),Q=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return s(this,void 0,void 0,function(){var i;return u(this,function(o){switch(o.label){case 0:return void 0===e.name&&(e.name=z(),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."))),i=e.name,this.pluginStatus.has(i)?(this.loggerProvider.warn("Plugin with name ".concat(i," already exists, skipping registration")),[2]):(e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",this.pluginStatus.set(i,"locked"),[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return o.sent(),"locked"!==this.pluginStatus.get(i)?[2]:(this.plugins.push(e),this.pluginStatus.set(i,"installed"),[2])}})})},e.prototype.deregister=function(e,t){var n;return s(this,void 0,void 0,function(){var r,i;return u(this,function(o){switch(o.label){case 0:return this.pluginStatus.delete(e),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._clearOptOutListeners(),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.pluginStatus.clear(),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,i,a,s,d,f,v,p,h,g,m,y,b,w,E,S,k,T;return u(this,function(u){switch(u.label){case 0:if(!e)return[2];t=c(e,1),n=t[0],r=c(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),a=this.plugins.filter(function(e){return"before"===e.type}),u.label=1;case 1:u.trys.push([1,6,7,8]),s=l(a),d=s.next(),u.label=2;case 2:return d.done?[3,5]:(g=d.value).execute?[4,g.execute(o({},n))]:[3,4];case 3:if(null===(m=u.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(g.name),"', event: ").concat(X(n))),i({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(g.name),"', event: ").concat(X(n))),u.label=4;case 4:return d=s.next(),[3,2];case 5:return[3,8];case 6:return f=u.sent(),E={error:f},[3,8];case 7:try{d&&!d.done&&(S=s.return)&&S.call(s)}finally{if(E)throw E.error}return[7];case 8:v=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),u.label=9;case 9:u.trys.push([9,14,15,16]),p=l(v),h=p.next(),u.label=10;case 10:return h.done?[3,13]:(g=h.value).execute?[4,g.execute(o({},n))]:[3,12];case 11:if(null===(m=u.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(g.name),"', event: ").concat(X(n))),i({event:n,code:0,message:""}),[2];n=m,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(g.name),"', event: ").concat(X(n))),u.label=12;case 12:return h=p.next(),[3,10];case 13:return[3,16];case 14:return y=u.sent(),k={error:y},[3,16];case 15:try{h&&!h.done&&(T=p.return)&&T.call(p)}finally{if(k)throw k.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(X(n))),w=b.map(function(e){var t=o({},n);return e.execute(t).catch(function(e){return q(t,0,String(e))})}),Promise.all(w).then(function(e){var t=c(e,1)[0]||q(n,100,"Event not tracked, no destination plugins on the instance");i(t)}),[2]}})})},e.prototype.flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r=this;return u(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.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},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)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o,a,s;return u(this,function(u){switch(u.label){case 0:u.trys.push([0,7,8,9]),t=l(this._optOutListeners),n=t.next(),u.label=1;case 1:if(n.done)return[3,6];r=n.value,u.label=2;case 2:return u.trys.push([2,4,,5]),[4,r(e)];case 3:return u.sent(),[3,5];case 4:return i=u.sent(),this.loggerProvider.error("Error calling optOut listener",i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return o=u.sent(),a={error:o},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(a)throw a.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)})},e}(),Z=function(e,t){return o(o({},t),{event_type:i.IDENTIFY,user_properties:e.getUserProperties()})},ee=function(e){return{promise:e||Promise.resolve()}},te=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 Q(this),this.name=e}return e.prototype._init=function(e){return s(this,void 0,void 0,function(){var t=this;return u(this,function(n){switch(n.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q",function(){return t.isReady=!0})];case 1:return n.sent(),[2]}})})},e.prototype.runQueuedFunctions=function(e,t){return s(this,void 0,void 0,function(){var n,r,i,o,a,s,c,d;return u(this,function(u){switch(u.label){case 0:n=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),r=l(n),i=r.next(),u.label=2;case 2:return i.done?[3,7]:(o=i.value,(a=o())&&"promise"in a?[4,a.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,a];case 5:u.sent(),u.label=6;case 6:return i=r.next(),[3,2];case 7:return[3,10];case 8:return s=u.sent(),c={error:s},[3,10];case 9:try{i&&!i.done&&(d=r.return)&&d.call(r)}finally{if(c)throw c.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e,t)]:[3,12];case 11:return u.sent(),[3,13];case 12:null==t||t(),u.label=13;case 13:return[2]}})})},e.prototype.track=function(e,t,n){var r=function(e,t,n){return o(o(o({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),ee(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Z(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),ee(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var a=function(e,t,n,r){var a;return o(o({},r),{event_type:i.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(a={},a[e]=t,a)})}(e,t,n,r);return ee(this.dispatch(a))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,a=new M;return a.set(e,t),o(o({},n),{event_type:i.IDENTIFY,user_properties:a.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),ee(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return o(o({},t),{event_type:i.REVENUE,event_properties:e.getEventProperties()})}(e,t);return ee(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),ee())},e.prototype._addPlugin=function(e){return ee(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)),ee())},e.prototype._removePlugin=function(e){return ee(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(q(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 u(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,n=null!==(t=this.userProperties)&&void 0!==t?t:{},i=o({},n);if(void 0===e)return i;var a={};return Object.keys(e).forEach(function(t){Object.values(r).includes(t)||(a[t]=e[t])}),U.forEach(function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case r.CLEAR_ALL:Object.keys(i).forEach(function(e){delete i[e]});break;case r.UNSET:Object.keys(n).forEach(function(e){delete i[e]});break;case r.SET:Object.assign(i,n)}}}),Object.assign(i,a),i},e.prototype.process=function(e){return s(this,void 0,void 0,function(){var t,n,r,o;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),this.config.optOut?[2,q(e,0,"Event skipped due to optOut config")]:"string"!=typeof(t=e.event_type)||0===t.trim().length?(this.config.loggerProvider.error(F),[2,q(e,0,F)]):(e.event_type===i.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]);case 1:return 200===(o=a.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=a.sent(),r=String(n),this.config.loggerProvider.error(r),[2,o=q(e,0,r)];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.config.optOut=Boolean(e),this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return ee(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}(),ne=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){try{var t=JSON.parse(JSON.stringify(e));L(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?o({},this.properties):{};return e[J.REVENUE_PRODUCT_ID]=this.productId,e[J.REVENUE_QUANTITY]=this.quantity,e[J.REVENUE_PRICE]=this.price,e[J.REVENUE_TYPE]=this.revenueType,e[J.REVENUE_CURRENCY]=this.currency,e[J.REVENUE]=this.revenue,e[J.RECEIPT]=this.receipt,e[J.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"}(J||(J={}));var re;!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"}(re||(re={}));var ie="Amplitude Logger ",oe=function(){function e(){this.logLevel=re.None}return e.prototype.disable=function(){this.logLevel=re.None},e.prototype.enable=function(e){void 0===e&&(e=re.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Verbose||console.log("".concat(ie,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Warn||console.warn("".concat(ie,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Error||console.error("".concat(ie,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<re.Debug||console.log("".concat(ie,"[Debug]: ").concat(e.join(" ")))},e}(),ae=function(e){return void 0===e||""===e?h:e},se=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:h,logLevel:re.Warn,loggerProvider:new oe,offline:!1,optOut:!1,serverUrl:g,serverZone:"US",useBatch:!1}},ue=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=se();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=ae(e.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.delayedEventsServerUrl=e.delayedEventsServerUrl,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 a=ce(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=a.serverZone,this.serverUrl=a.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),le=function(e,t){return"EU"===e?t?b:m:t?y:g},ce=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=se().serverZone),void 0===n&&(n=se().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:se().serverZone;return{serverZone:r,serverUrl:le(r,n)}},de=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function fe(e){return e>=200&&e<300}var ve=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},pe=function(e){return function(){var t=o({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},he=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=l(t.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(!(a in e))return;e=e[a]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},ge=function(e,t){return function(){var n,r,i={};try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=he(e,s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},me=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=n(),u=s.logger,l=s.logLevel;if(l&&l<re.Debug||!l||!u)return e.apply(i,o);var c={type:"invoke public method",name:t,args:o,stacktrace:ve(1),time:{start:(new Date).toISOString()},states:{}};r&&c.states&&(c.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=(new Date).toISOString()),u.debug(JSON.stringify(c,null,2))}):(r&&c.states&&(c.states.after=r()),c.time&&(c.time.end=(new Date).toISOString()),u.debug(JSON.stringify(c,null,2))),d}},ye=new Set([g,m,y,b]);function be(e){return void 0!==e.delay&&null!==e.delay}function we(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var Ee=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.inFlightDelayedEvents={},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 u(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(p,"_").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=z()),new Promise(function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};be(e)&&t.removeStaleDelayedEvents(e),t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeStaleDelayedEvents=function(e){var t=this;try{this.queue=this.queue.filter(function(n){var r,i=n.event;if(!be(i))return!0;if(!(i.delay.id===e.delay.id&&i.insert_id===e.insert_id))return!0;var a=t.inFlightDelayedEvents[e.delay.id];return a&&(e.delay=o(o({},e.delay),{skipRemoval:!0})),!(!a||(null===(r=i.delay)||void 0===r?void 0:r.skipRemoval))||(n.callback(q(i,0,"Stale event overwritten")),!1)})}catch(e){}},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,i,o,a,l=this;return u(this,function(c){switch(c.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={},r=[],this.queue.forEach(function(e){var i;if(0!==e.timeout)r.push(e);else if(null===(i=e.event.delay)||void 0===i?void 0:i.id){var o=e.event.delay;n[o.id]=n[o.id]||[],n[o.id].push(e)}else t.push(e)}),d=t,f=this.config.flushQueueSize,v=Math.max(f,1),i=d.reduce(function(e,t,n){var r=Math.floor(n/v);return e[r]||(e[r]=[]),e[r].push(t),e},[]),o=i.reduce(function(t,n){return s(l,void 0,void 0,function(){return u(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()),a=[o],Object.keys(n).length>0&&a.push(this.sendDelayedEvents(n,e)),[4,Promise.all(a)]);case 1:return c.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var d,f,v})})},e.prototype.sendDelayedEvents=function(e,t){var n,r,i=this,o=[];try{var a=function(e,n){d.inFlightDelayedEvents[e]=!0;var r=d.send(n,t,!0);o.push(r),r.finally(function(){delete i.inFlightDelayedEvents[e]})},d=this;try{for(var f=l(Object.entries(e)),v=f.next();!v.done;v=f.next()){var p=c(v.value,2);a(p[0],p[1])}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}catch(e){}return o.reduce(function(e,t){return s(i,void 0,void 0,function(){return u(this,function(n){switch(n.label){case 0:return[4,e];case 1:return n.sent(),[4,t];case 2:return[2,n.sent()]}})})},Promise.resolve())},e.prototype.translatePayloadToDelayedPayload=function(e,t){var n,r,i=[],o=[],a=[],s=[];t.forEach(function(t,n){t.event.delay.timeout?(i.push(e.events[n]),a.push(t)):(o.push(e.events[n]),s.push(t))}),t.splice.apply(t,d(d([0,t.length],c(a),!1),c(s),!1)),e.timeout=null!==(r=null===(n=a[0])||void 0===n?void 0:n.event.delay.timeout)&&void 0!==r?r:0,e.id=t[0].event.delay.id,e.events=i,e.instant_events=o},e.prototype.send=function(e,t,n){var r;return void 0===t&&(t=!0),s(this,void 0,void 0,function(){var i,o,s,l,c,d;return u(this,function(u){switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];i={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,t.delay,a(t,["extra","delay"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:n?void 0:this.config.requestMetadata},n||(this.config.requestMetadata=new de),u.label=1;case 1:return u.trys.push([1,3,,4]),o=ce(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,s=function(e,t){return void 0===t&&(t=!1),!!ye.has(e)||t}(o,this.config.enableRequestBodyCompression),n&&(o=this.config.delayedEventsServerUrl||"".concat(o,"/delayed"),this.translatePayloadToDelayedPayload(i,e),s=!1),[4,this.config.transportProvider.send(o,i,s)];case 2:return null===(l=u.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(l,e),[3,4]):("body"in l?this.fulfillRequest(e,l.statusCode,"".concat(l.status,": ").concat(we(l))):this.fulfillRequest(e,l.statusCode,l.status),[2]);case 3:return c=u.sent(),d=(f=c)instanceof Error?f.message:String(f),this.config.loggerProvider.error(d),null===(r=this.diagnosticsClient)||void 0===r||r.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:d,stack_trace:ve()}),this.handleResponse({status:j.Failed,statusCode:0},e),[3,4];case 4:return[2]}var f})})},e.prototype.handleResponse=function(e,t){var n;fe(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:we(e),stack_trace:ve()});var r=e.status;switch(r){case j.Success:this.handleSuccessResponse(e,t);break;case j.Invalid:this.handleInvalidResponse(e,t);break;case j.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case j.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=d(d(d(d([],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(we(e));var a=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(a)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(we(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,a=new Set(r),s=new Set(i),u=new Set(o),l=t.filter(function(t,r){if(!(t.event.user_id&&a.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)))return u.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)});l.length>0&&this.config.loggerProvider.warn(we(e));var c=this.removeEventsExceedFlushMaxRetries(l);this.scheduleEvents(c)},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;fe(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:ve()})),this.removeEvents(e),e.forEach(function(e){return e.callback(q(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){var t=new Set(e.map(function(e){return e.event.insert_id}));this.queue=this.queue.filter(function(t){return!e.some(function(e){var n;return e.event.insert_id===t.event.insert_id&&!(null===(n=t.event.delay)||void 0===n?void 0:n.skipRemoval)})}),this.queue.forEach(function(e){var n;(null===(n=e.event.delay)||void 0===n?void 0:n.skipRemoval)&&t.has(e.event.insert_id)&&delete e.event.delay.skipRemoval}),this.saveEvents()},e}(),Se=function(){function e(e,t,n,r){this.client=e,this.pulse=t,this.delayTimeout=n,this.logger=r,this.interval=null,this.resetPromise=null,this.events=new Map,this.delayId=z()}return e.prototype.heartbeat=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,s,c,d=this;return u(this,function(u){switch(u.label){case 0:if(0===this.events.size)return this.stop(),[2,[]];e=[],t=function(t){var r=t.event_type,i=t.event_properties,o=a(t,["event_type","event_properties"]),s=n.client.track(r,i,o).promise;if(n.isInstantEvent(t)){var u=t.insert_id;s.finally(function(){return d.events.delete(u)})}e.push(s)},n=this;try{for(r=l(this.events.values()),i=r.next();!i.done;i=r.next())o=i.value,t(o)}catch(e){s={error:e}}finally{try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(s)throw s.error}}return[4,Promise.all(e)];case 1:return[2,u.sent()]}})})},e.prototype.resetHeartbeat=function(){return s(this,void 0,void 0,function(){var e=this;return u(this,function(t){switch(t.label){case 0:return this.resetPromise?[4,this.resetPromise]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return this.interval&&clearInterval(this.interval),this.interval=setInterval(function(){e.heartbeat()},this.pulse),this.resetPromise=new Promise(function(t){setTimeout(function(){t(e.heartbeat())},0)}),this.resetPromise.finally(function(){return e.resetPromise=null}),[4,this.resetPromise]}})})},e.prototype.isInstantEvent=function(e){return Boolean(e.insert_id&&!e.delay.timeout)},e.prototype.checkEventSizeLimit=function(e){var t;return!(JSON.stringify(d([],c(this.events.values()),!1)).length>4e4)||(null===(t=this.logger)||void 0===t||t.warn("Heartbeat: events size limit reached, rejecting event with id=".concat(e.insert_id)),e.insert_id&&this.events.delete(e.insert_id),!1)},e.prototype.track=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e.insert_id?(this.events.set(e.insert_id,o(o({},e),{delay:e.delay||{id:this.delayId,timeout:this.delayTimeout}})),this.checkEventSizeLimit(e)?[4,this.resetHeartbeat()]:[2]):[2,new Error("insert_id is required on events tracked with heartbeat")];case 1:return[2,t.sent().find(function(t){return t.event.insert_id===e.insert_id})]}})})},e.prototype.trackNoDelay=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){return e.delay={id:this.delayId},[2,this.track(e)]})})},e.prototype.update=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){return e.insert_id&&this.events.has(e.insert_id)&&(t=this.events.get(e.insert_id),this.events.set(e.insert_id,o(o({},e),{delay:{id:this.delayId,timeout:this.delayTimeout}})),!this.checkEventSizeLimit(e)&&t)?(this.events.set(e.insert_id,t),[2]):[2]})})},e.prototype.stop=function(){this.interval&&clearInterval(this.interval),this.interval=null,this.events.clear()},e}(),ke=new Map;var Te=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:xe(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),xe=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},Pe=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}(),_e=function(){return _e=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},_e.apply(this,arguments)};function Ie(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 Ae(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.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 a}"function"==typeof SuppressedError&&SuppressedError;var Oe=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=Ie(["string","number","boolean","undefined"]),a=o.next();!a.done;a=o.next()){if(a.value===i)return e===t}}catch(e){n={error:e}}finally{try{a&&!a.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 s=Array.isArray(e),u=Array.isArray(t);if(s!==u)return!1;if(!s||!u){var l=Object.keys(e).sort(),c=Object.keys(t).sort();if(!Oe(l,c))return!1;var d=!0;return Object.keys(e).forEach(function(n){Oe(e[n],t[n])||(d=!1)}),d}for(var f=0;f<e.length;f++)if(!Oe(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 Ce=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=_e({},this.identity.userProperties),n=_e(_e({},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,a,s,u=n.userProperties||{};try{for(var l=Ie(Object.entries(e)),c=l.next();!c.done;c=l.next()){var d=Ae(c.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var p=(i=void 0,Ie(Object.entries(v))),h=p.next();!h.done;h=p.next()){var g=Ae(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=(a=void 0,Ie(Object.keys(v))),w=b.next();!w.done;w=b.next()){delete u[m=w.value]}}catch(e){a={error:e}}finally{try{w&&!w.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}break;case"$clearAll":u={}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(t)throw t.error}}return n.userProperties=u,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return _e({},this.identity)},e.prototype.setIdentity=function(e){var t=_e({},this.identity);this.identity=_e({},e),Oe(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}(),Re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,De=function(){function e(){this.identityStore=new Ce,this.eventBridge=new Pe,this.applicationContextProvider=new Te}return e.getInstance=function(t){return Re.analyticsConnectorInstances||(Re.analyticsConnectorInstances={}),Re.analyticsConnectorInstances[t]||(Re.analyticsConnectorInstances[t]=new e),Re.analyticsConnectorInstances[t]},e}(),Le=function(e){return De.getInstance(ae(e))},Ne=function(){function e(){this.name="identity",this.type="before",this.identityStore=Le().identityStore}return e.prototype.execute=function(e){return s(this,void 0,void 0,function(){var t;return u(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 u(this,function(t){return e.instanceName&&(this.identityStore=Le(e.instanceName).identityStore),[2]})})},e}(),Me=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},je=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[v,t,e.substring(0,n)].filter(Boolean).join("_")},Ue=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:""},Fe=function(){var e,t=B();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=qe(n[0]),i=qe(n[1]);return i?(e[r]=i,e):e},{}):{}},qe=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},Be=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},He=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},ze=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},Ve=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},We=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){return u(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 u(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 u(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return u(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),$e=function(){function e(e,t){void 0===t&&(t={}),this.options=o({},e),this.config=t}return e.prototype.isEnabled=function(){return s(this,void 0,void 0,function(){var t,n,r,i,a=this;return u(this,function(s){switch(s.label){case 0:return t="AMP_TEST",n=o({},this.options),r=new e(n),i=String(Date.now()),[4,r.transaction(t,function(e){var n,r;try{e.set(i);var o=e.get()===i;return!o&&a.config.diagnosticsClient&&(null===(n=a.config.diagnosticsClient)||void 0===n||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:i,sync:!0})),o}catch(e){if(a.config.diagnosticsClient){var s=e instanceof Error?e.message:String(e);null===(r=a.config.diagnosticsClient)||void 0===r||r.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:i,error:s,sync:!0})}return!1}finally{e.set(null)}})];case 1:return[2,s.sent()]}})})},e.prototype.get=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}})})},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=Ke(t);return void 0===n?void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)):JSON.parse(n)}catch(n){return void console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t))}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return s(this,void 0,void 0,function(){var r,i,o,a,s,c,d,f,v;return u(this,function(u){switch(u.label){case 0:r=B(),i=r,u.label=1;case 1:return u.trys.push([1,4,,5]),(o=null==i?void 0:i.cookieStore)?[4,o.getAll(e)]:[3,3];case 2:if(a=u.sent()){a.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:a.map(function(e){return e.domain})}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(s=l(a),c=s.next();!c.done;c=s.next())if(d=c.value,Ge(d.domain,this.options.domain))return[2,d.value]}catch(e){f={error:e}}finally{try{c&&!c.done&&(v=s.return)&&v.call(s)}finally{if(f)throw f.error}}}u.label=3;case 3:return[3,5];case 4:return u.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t,n,r=this,i=B(),o=(null!==(n=null===(t=null==i?void 0:i.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[]).filter(function(t){return 0===t.indexOf(e+"=")}),a=void 0,s=this.config.duplicateResolverFn;if("function"==typeof s&&o.length>1&&(a=o.find(function(t){var n;try{var i=s(t.substring(e.length+1));return i||null===(n=r.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}})),a||(a=o[0]),a)return a.substring(e.length+1)},e.prototype.set=function(e,t){return s(this,void 0,void 0,function(){return u(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){var n;try{var r=B();if(!r||!r.document||"function"!=typeof r.btoa||"function"!=typeof r.encodeURIComponent)return;var i=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,o=null!==t?i:-1,a=void 0;if(o){var s=new Date;s.setTime(s.getTime()+24*o*60*60*1e3),a=s}var u="".concat(e,"=").concat(r.btoa(r.encodeURIComponent(JSON.stringify(t))));a&&(u+="; expires=".concat(a.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)),r.document.cookie=u}catch(t){var l=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}},e.prototype.remove=function(e){return s(this,void 0,void 0,function(){return u(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 u(this,function(e){return[2]})})},e.isDomainWritable=function(t){return s(this,void 0,void 0,function(){var n,r;return u(this,function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];n="AMP_TLDTEST",r=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.transaction(n,function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}})];case 2:return[2,!!i.sent()];case 3:return i.sent(),[2,!1];case 4:return[2]}})})},e.prototype.transaction=function(e,t){return s(this,void 0,void 0,function(){var n,r,i=this;return u(this,function(o){switch(o.label){case 0:if(n=function(){var e,t=B();return null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.locks}(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,r()];case 4:return[2]}})})},e.cachedTlds={},e}(),Ke=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)},Ge=function(e,t){if(""===e&&""===t)return!0;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()},Je=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[v,t,e.substring(0,n)].filter(Boolean).join("_")},Ye=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 u(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 u(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 u(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 u(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 u(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 u(this,function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]})})},e}(),Xe="tags",Qe="counters",Ze="histograms",et="events",tt="internal",nt="last_flush_timestamp",rt=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=B())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return s(this,void 0,void 0,function(){return u(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(){var t=r.result;t?e.createTables(t):e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.")}})},e.prototype.createTables=function(e){(e.objectStoreNames.contains(Xe)||e.createObjectStore(Xe,{keyPath:"key"}),e.objectStoreNames.contains(Qe)||e.createObjectStore(Qe,{keyPath:"key"}),e.objectStoreNames.contains(Ze)||e.createObjectStore(Ze,{keyPath:"key"}),e.objectStoreNames.contains(et))||e.createObjectStore(et,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(tt)||e.createObjectStore(tt,{keyPath:"key"})},e.prototype.setTags=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,o=this;return u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Xe],"readwrite"),r=n.objectStore(Xe),[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=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Qe],"readwrite"),r=n.objectStore(Qe),[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],a=r.get(n);a.onsuccess=function(){var e=a.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)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}})})];case 2:return i=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Ze],"readwrite"),r=n.objectStore(Ze),[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],a=r.get(n);a.onsuccess=function(){var e,t=a.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)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}})})];case 2:return i=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([et],"readwrite"),r=n.objectStore(et),[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=a.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 u(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=a.sent(),r=n.transaction([tt],"readwrite"),i=r.objectStore(tt),[2,new Promise(function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var a=i.put({key:e,value:t});a.onsuccess=function(){return n()},a.onerror=function(){return o(new Error("Failed to set internal value"))}})];case 2:return o=a.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 u(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([tt],"readonly"),r=n.objectStore(tt),[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 u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(nt)];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 u(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(nt,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,a,s;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=u.sent(),t=e.transaction([Xe,Qe,Ze,et],"readwrite"),[4,Promise.all([this.getAllFromStore(t,Xe),this.getAllFromStore(t,Qe),this.getAllFromStore(t,Ze),this.getAllFromStore(t,et)])];case 2:return n=c.apply(void 0,[u.sent(),4]),r=n[0],i=n[1],o=n[2],a=n[3],[4,Promise.all([this.clearTable(t,Qe),this.clearTable(t,Ze),this.clearTable(t,et)])];case 3:return u.sent(),[2,{tags:r,counters:i,histogramStats:o,events:a}];case 4:return s=u.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",s),[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}(),it="__AMPLITUDE_SCRIPT_URL__",ot=function(){var e=B();if(!e)return[];var t=e[it];return Array.isArray(t)?t:"string"==typeof t?[t]:[]},at=function(e){var t,n,r=ot();if(0!==r.length)try{for(var i=l(r),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.filename&&e.filename.includes(a))return"filename";if(e.stack&&e.stack.includes(a))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},st=function(e){var t,n;try{var r=new URL(e,null===(n=null===(t=B())||void 0===t?void 0:t.location)||void 0===n?void 0:n.origin);return r.origin+r.pathname}catch(e){return}},ut=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},lt=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},ct=3e5,dt=1e4,ft=function(){function e(e,t,n,r,i){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=o({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=ze(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,i?this.storage=i:rt.isSupported()?this.storage=new rt(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=B();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",o({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=at({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=ut(i),a=at({filename:o,stack:i});a&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:lt(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})},!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>=dt?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>=dt?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>=dt)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})},ct))},e.prototype.saveAllDataToStorage=function(){return s(this,void 0,void 0,function(){var e,t,n,r;return u(this,function(i){switch(i.label){case 0:return this.storage?(e=o({},this.inMemoryTags),t=o({},this.inMemoryCounters),n=o({},this.inMemoryHistograms),r=d([],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 i.sent(),[2]}})})},e.prototype._flush=function(){return s(this,void 0,void 0,function(){var e,t,n,r,i,o,a,s,l,c;return u(this,function(u){switch(u.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return u.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=u.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}),a={},n.forEach(function(e){a[e.key]=e.value}),s={},r.forEach(function(e){s[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),l=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(a).length&&0===Object.keys(s).length&&0===l.length?[2]:(c={tags:o,histogram:s,counters:a,events:l},this.fetch(c),[2])}})})},e.prototype.fetch=function(e){return s(this,void 0,void 0,function(){var t;return u(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!B())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 u(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(ct),[2]):(n=e-t)>=ct?(this._flush(),[2]):(this._setFlushTimer(ct-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=ze(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),vt=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,a,s,u,l,c,d,f,v,p,h,g,m,y,b,w,E,S;if("object"!=typeof e)return null;var k=e.code||0,T=this.buildStatus(k);switch(T){case j.Success:return{status:T,statusCode:k,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 j.Invalid:return{status:T,statusCode:k,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(s=e.events_with_missing_fields)&&void 0!==s?s:{},eventsWithInvalidIdLengths:null!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l:0,exceededDailyQuotaDevices:null!==(c=e.exceeded_daily_quota_devices)&&void 0!==c?c:{},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 j.PayloadTooLarge:return{status:T,statusCode:k,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case j.RateLimit:return{status:T,statusCode:k,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 j.Timeout:default:return{status:T,statusCode:k}}},e.prototype.buildStatus=function(e){return fe(e)?j.Success:429===e?j.RateLimit:413===e?j.PayloadTooLarge:408===e?j.Timeout:e>=400&&e<500?j.Invalid:e>=500?j.Failed:j.Unknown},e}();function pt(){return"undefined"!=typeof CompressionStream}function ht(e){return s(this,void 0,void 0,function(){var t,n;return u(this,function(r){switch(r.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),n=new Blob([e]).stream().pipeThrough(new t("gzip")),[4,new Response(n).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}})})}var gt=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}();var mt=401,yt=403,bt=429,wt=function(){function e(t,n,r,i,o,a){void 0===r&&(r="US"),void 0===a&&(a=e.CONFIG_GROUP),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=t,this.serverUrl=i||("US"===r?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=n,this.storage=new gt(t,n),this.customFetch=o,this.configGroup=a}return e.prototype.subscribe=function(e,t,n){var r=z(),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 u(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.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null}),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 u(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 u(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,a,s,l=this;return u(this,function(c){switch(c.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,s,c,d,f,v,p,h;return u(this,function(u){switch(u.label){case 0:i=!0,a=new AbortController,s=setTimeout(function(){return a.abort()},t),u.label=1;case 1:return u.trys.push([1,10,11,12]),c=o.getUrlParams(),d={Accept:"*/*"},o.customFetch?[4,(g=o.customFetch({url:c,method:"GET",headers:d,signal:a.signal}),m=a.signal,new Promise(function(e,t){var n=function(){var e=new Error("Remote config custom fetch aborted by timeout");e.name="AbortError",t(e)};m.addEventListener("abort",n,{once:!0}),g.then(function(t){m.removeEventListener("abort",n),e(t)},function(e){m.removeEventListener("abort",n),t(e)})}))]:[3,3];case 2:return v=u.sent(),[3,5];case 3:return[4,fetch(c,{method:"GET",headers:d,signal:a.signal})];case 4:v=u.sent(),u.label=5;case 5:return(f=v).ok||f.status>=200&&f.status<300?[3,7]:[4,f.text()];case 6:return p=u.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(f.status,": ").concat(p)),f.status===mt||f.status===yt?(o.logger.error("Remote config client fetch failed with ".concat(f.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):f.status>=400&&f.status<500&&f.status!==bt&&(i=!1),[3,9];case 7:return[4,f.json()];case 8:return[2,{value:{remoteConfig:u.sent(),lastFetch:new Date}}];case 9:return[3,12];case 10:return(h=u.sent())instanceof Error&&"AbortError"===h.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: "),h),[3,12];case 11:return clearTimeout(s),[7];case 12:return i?r<e-1?[4,new Promise(function(e){return setTimeout(e,l.getJitterDelay(n))})]:[3,14]:[2,"break"];case 13:u.sent(),u.label=14;case 14:return[2]}var g,m})},o=this,a=0,c.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(s=c.sent()))return[2,s.value];if("break"===s)return[3,4];c.label=3;case 3:return a++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),t=new URLSearchParams;return t.append("config_group",this.configGroup),"".concat(this.serverUrl,"/").concat(e,"?").concat(t.toString())},e.CONFIG_GROUP="browser",e}(),Et=B(),St=null==Et?void 0:Et.console,kt={},Tt={},xt=!1;var Pt,_t={addListener:function(e,t){var n,r=(n=e,!!St&&"function"==typeof St[n]&&(Tt[n]||(Tt[n]=St[n],St[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(kt[n]&&!xt){xt=!0;var r=kt[n];r&&r.forEach(function(t){try{t(n,e)}catch(e){}})}}catch(e){}return xt=!1,Tt[n].apply(St,e)}),!0));if(!r)return new Error("Console override failed");kt[e]?kt[e].push(t):kt[e]=[t]},removeListener:function(e){var t,n;try{for(var r=l(Object.values(kt)),i=r.next();!i.done;i=r.next())for(var o=i.value,a=o.length-1;a>=0;a--)if(o[a]===e){o.splice(a,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=l(Object.entries(Tt)),r=n.next();!r.done;r=n.next()){var i=c(r.value,2),o=i[0],a=i[1];a&&(St[o]=a)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}Tt={},kt={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(Pt||(Pt={}));var It=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],At="data-amp-track-",Ot=["div","span","h1","h2","h3","h4","h5","h6"],Ct=d(['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),Rt=Ct,Dt=Ct,Lt=["*"];function Nt(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function Mt(e,t,n){e&&jt({json:e,allowlist:t.map(Ut),excludelist:n.map(Ut),ancestors:[]})}function jt(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,a=e.excludelist,s=e.ancestors,u=e.parentObject,f=e.targetKey;i||(i=r);var v=Object.keys(i);try{for(var p=l(v),h=p.next();!h.done;h=p.next()){var g=h.value,m=d(d([],c(s),!1),[g],!1);Nt(i[g])?qt(m,o)&&!qt(m,a)||delete i[g]:jt({json:r,targetObject:i[g],allowlist:o,excludelist:a,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&&u&&f&&delete u[f]}function Ut(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function Ft(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(Ft(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&Ft(e,t,n+1,r+1)}function qt(e,t){return t.some(function(t){return Ft(e,t)})}var Bt=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=l(Object.entries(r)),a=o.next();!a.done;a=o.next()){var s=c(a.value,2),u=s[0],d=s[1];i[u]=d}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Jt(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=B();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=zt(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 u(this,function(n){return 0===e.length?[2,null]:[2,Kt(this.body,e,t)]})})},e}(),Ht=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),Jt(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return zt(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 u(this,function(n){return 0===e.length?[2,null]:[2,Kt(this.body,e,t)]})})},e}();function zt(e,t){var n,r,i,o=B(),a=null==o?void 0:o.TextEncoder;if(a&&null!=e){var s;if("string"==typeof e)s=e,i=(new a).encode(s).length;else if("undefined"!=typeof Blob&&e instanceof Blob)i=(s=e).size;else if("undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams)s=e,i=(new a).encode(s.toString()).length;else if(ArrayBuffer.isView(e))i=(s=e).byteLength;else if(e instanceof ArrayBuffer)i=(s=e).byteLength;else if("undefined"!=typeof FormData&&e instanceof FormData){var u=e,d=0,f=0;try{for(var v=l(u.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 a).encode(m).length;else{if(!("undefined"!=typeof Blob&&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("undefined"!=typeof ReadableStream&&e instanceof ReadableStream)return void(s=e);return i}}var Vt,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}),Jt(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 u(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 u(this,function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,Kt(n.sent(),e,t)]}})})},e}(),$t=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=l(i),a=o.next();!a.done;a=o.next()){var s=c(a.value.split(": "),2),u=s[0],d=s[1];u&&d&&(r[u]=d)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Jt(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 u(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?(Mt(n,e,t),[2,n]):[2,null]})})},e}();function Kt(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return Mt(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(Vt||(Vt={}));var Gt="[REDACTED]",Jt=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,a=t.strategy,s=void 0===a?Vt.REMOVE:a,u=d([],c(D),!1),f={},v=function(t){var n=t.toLowerCase();u.find(function(e){return e.toLowerCase()===n})?s===Vt.REDACT&&(f[t]=Gt):o.find(function(e){return e.toLowerCase()===n})?f[t]=e[t]:s===Vt.REDACT&&(f[t]=Gt)};try{for(var p=l(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},Yt=function(){function e(e,t,n,r,i,o,a,s,u,l,c){void 0===a&&(a=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=a,this.duration=s,this.responseWrapper=u,this.error=l,this.endTime=c}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(d([],c(R),!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(d([],c(R),!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 Xt=function(e,t){void 0===t&&(t=z()),this.callback=e,this.id=t};function Qt(e){try{e()}catch(e){}}var Zt=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=B();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=B();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,a,s,u,l,c,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===(s=null===(a=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===a?void 0:a.prototype)||void 0===s?void 0:s.send,p=null===(c=null===(l=null===(u=this.globalScope)||void 0===u?void 0:u.XMLHttpRequest)||void 0===l?void 0:l.prototype)||void 0===c?void 0:c.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){try{n.callback(e)}catch(e){Qt(function(){var n;null===(n=t.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,a){var s;if(void 0!==o&&void 0!==a){var u,l,c,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?u=null===(s=null==t?void 0:t.toString)||void 0===s?void 0:s.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&&(l=r.status),i&&(c={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},l=0);var v=Math.floor(performance.now()-a),p=Math.floor(o+v),h=new Yt(e,d,o,o,u,n,l,v,r,c,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,a,s=this;return u(this,function(u){switch(u.label){case 0:try{t=this.getTimestamps()}catch(e){Qt(function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)})}u.label=1;case 1:return u.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),o=a,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new Bt(r):void 0,i?new Wt(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){Qt(function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.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;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&&Qt(function(){var n;return null===(n=t.logger)||void 0===n?void 0:n.debug("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 i=this.globalScope.XMLHttpRequest.prototype,a=this;i.open=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=c(n,2),s=i[0],u=i[1];try{this.$$AmplitudeAnalyticsEvent=o({method:s,url:null===(e=null==u?void 0:u.toString)||void 0===e?void 0:e.call(u),headers:{}},a.getTimestamps())}catch(e){Qt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr open",e)})}return t.apply(this,n)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,o=e.createXhrJsonParser(this,a),s=t[0],u=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),n=new $t(i.status,e,t?parseInt(t,10):void 0,o),r=i.$$AmplitudeAnalyticsEvent.headers,l=new Ht(s,r);u.status=i.status,a.handleNetworkRequestEvent("xhr",{url:u.url,method:u.method},l,n,void 0,u.startTime,u.durationStart)}catch(e){Qt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling xhr send",e)})}}),n.apply(i,t)},i.setRequestHeader=function(e,t){try{var n=this.$$AmplitudeAnalyticsEvent;n&&(n.headers[e]=t)}catch(e){Qt(function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)})}r.apply(this,[e,t])}}},e}(),en=new Zt,tn=function(){function e(){}return e.prototype.parse=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return[2,o(o(o(o({},C),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=Fe();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=Fe();return(e={})[w]=t[w],e[E]=t[E],e[S]=t[S],e[k]=t[k],e[T]=t[T],e[x]=t[x],e[P]=t[P],e[_]=t[_],e[I]=t[I],e[A]=t[A],e[O]=t[O],e},e}(),nn="data-amp-mask",rn="*****",on=/\b(?:\d[ -]*?){13,16}\b/,an=/(\d{3}-?\d{2}-?\d{4})/g,sn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,un=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(on,rn)).replace(an,rn)).replace(sn,rn);try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,rn)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},ln=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(nn)?rn:e?e(document.title):document.title},cn={};Object.defineProperty(cn,"__esModule",{value:!0}),cn.Observable=void 0;const dn=e=>Boolean(Symbol[e]),fn=e=>dn(e)?Symbol[e]:"@@"+e,vn=fn("iterator"),pn=fn("observable"),hn=fn("species");function gn(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function mn(e){let t=e.constructor;return void 0!==t&&(t=t[hn],null===t&&(t=void 0)),void 0!==t?t:xn}function yn(e){yn.log?yn.log(e):setTimeout(()=>{throw e})}function bn(e){Promise.resolve().then(()=>{try{e()}catch(e){yn(e)}})}function wn(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=gn(t,"unsubscribe");e&&e.call(t)}}catch(e){yn(e)}}function En(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function Sn(e,t,n){e._state="running";let r=e._observer;try{let i=gn(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(En(e),!i)throw n;i.call(r,n);break;case"complete":En(e),i&&i.call(r)}}catch(e){yn(e)}"closed"===e._state?wn(e):"running"===e._state&&(e._state="ready")}function kn(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 bn(()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(Sn(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e))):void Sn(e,t,n);e._queue.push({type:t,value:n})}}class Tn{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){kn(n,"next",e)},error(e){kn(n,"error",e)},complete(){kn(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(En(this),wn(this))}}class xn{constructor(e){if(!(this instanceof xn))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new Tn(e,this._subscriber)}forEach(e){return new Promise((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})})}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(mn(this))(t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(mn(this))(t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=mn(this),n=arguments.length>1,r=!1,i=arguments[1];return new t(t=>this.subscribe({next(o){let a=!r;if(r=!0,!a||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(...e){let t=mn(this);return new t(n=>{let r,i=0;return function o(a){r=a.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=mn(this);return new t(n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let a=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(a);e>=0&&r.splice(e,1),o()}});r.push(a)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[pn](){return this}static from(e){let t="function"==typeof this?this:xn;if(null==e)throw new TypeError(e+" is not an object");let n=gn(e,pn);if(n){let r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return function(e){return e instanceof xn}(r)&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(dn("iterator")&&(n=gn(e,vn),n))return new t(t=>{bn(()=>{if(!t.closed){for(let r of n.call(e))if(t.next(r),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{bn(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:xn)(t=>{bn(()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}})})}static get[hn](){return this}}cn.Observable=xn,Object.defineProperty(xn,Symbol("extensions"),{value:{symbol:pn,hostReportError:yn},configurable:!0});var Pn=cn.Observable;function _n(e,t){return new Pn(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 In(e,t){return new Pn(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=l(i),o=n.next();!o.done;o=n.next()){var a=o.value;try{a.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()},a=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 a(e),a(t),o})}function An(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new Pn(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.next)||void 0===i||i.call(s,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var a=l(t),s=a.next();!s.done;s=a.next()){var u=s.value;null===(o=u.error)||void 0===o||o.call(u,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=l(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.complete)||void 0===i||i.call(s)}}catch(t){e={error:t}}finally{try{a&&!a.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)}})}var On,Cn="https://app.amplitude.com",Rn={US:Cn,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var Dn="__AMPLITUDE_MESSENGER_INSTANCE__",Ln="__AMPLITUDE_MESSENGER__",Nn=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?Cn:t;this[On]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,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,a){r.requestCallbacks[i]={resolve:t,reject:a},r.notify(o),n.timeout>0&&setTimeout(function(){a(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.registerActionHandler=function(e,t){var n,r,i,o;this.actionHandlers.has(e)&&(null===(o=null===(i=this.logger)||void 0===i?void 0:i.warn)||void 0===o||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var a=this.pendingMessages.get(e);if(a){this.pendingMessages.delete(e);try{for(var s=l(a),u=s.next();!u.done;u=s.next()){t(u.value)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return s(this,void 0,void 0,function(){var t,n,r;return u(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):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)}})}(e).then(function(){}),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,a=i.endpoint;o&&(this.logger=o),a&&this.endpoint===Cn&&(this.endpoint=a),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,a;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 s=e.data,u=null==s?void 0:s.action;if(u)if("id"in s&&s.id)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(s);else{if("ping"===u)return void r.notify({action:"pong"});var l=r.actionHandlers.get(u);if(l)l(s.data);else{var c=null!==(a=r.pendingMessages.get(u))&&void 0!==a?a:[];c.push(s.data),r.pendingMessages.set(u,c)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=B();(null==e?void 0:e[Ln])===this&&delete e[Ln]},e}();function Mn(e){var t,n=B(),r=null==n?void 0:n[Ln];if("object"==typeof(t=r)&&null!==t&&Dn in t&&!0===t[Dn])return r;var i=new Nn(e);return n&&(n[Ln]=i),i}On=Dn;var jn="__AMPLITUDE_BACKGROUND_CAPTURE__";var Un={always:"always",ifEmptyCampaign:"ifEmptyCampaign"};function Fn(e,t){var n=0;if(Number.isFinite(e)&&Number.isFinite(t)&&t>0){var r=e/t*100;n=Math.min(100,Math.max(0,r))}return n}function qn(e,t){var n=e.currentTime,r=e.duration;return o({duration:r,start_time:n,last_position:n,percent_completed:Fn(n,r)},void 0!==t?{stop_reason:t}:{})}function Bn(e){return{mux_playback_id:e.getAttribute("playback-id"),mux_video_id:e.getAttribute("metadata-video-id"),mux_video_title:e.getAttribute("metadata-video-title")}}function Hn(e,t,n,r){return s(this,void 0,void 0,function(){var i,a,s,l,d;return u(this,function(u){switch(u.label){case 0:return[4,Promise.all([new Promise(function(t){return e.getDuration(t)}),new Promise(function(t){return e.getCurrentTime(t)})])];case 1:if(i=c.apply(void 0,[u.sent(),2]),a=i[0],s=i[1],l={},"mux"===n){d=void 0;try{d=new URL(t.getAttribute("src")),l.mux_video_title=d.searchParams.get("metadata-video-title"),l.mux_video_id=d.searchParams.get("metadata-video-id"),l.mux_playback_id=d.pathname.split("/").pop()}catch(e){}}return[2,o(o({duration:a,start_time:s,last_position:s,percent_completed:Fn(s,a)},void 0!==r?{stop_reason:r}:{}),l)]}})})}function zn(e,t,n){void 0===n&&(n=null);var r=[],i=function(){var i=e.elem,o=!1,a=function(){Hn(e,i,n).then(function(e){t.onPlay(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'play' handler: ".concat(e))})};e.on("play",a),r.push(function(){return e.off("play",a)});var l=function(){Hn(e,i,n,"ended").then(function(e){t.onEnded(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'ended' handler: ".concat(e))})};e.on("ended",l),r.push(function(){return e.off("ended",l)});var c=function(){Hn(e,i,n,"paused").then(function(e){t.onPause(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'pause' handler: ".concat(e))})};e.on("pause",c),r.push(function(){return e.off("pause",c)});var d=function(){o=!0,Hn(e,i,n,"seeking").then(function(e){t.onSeeking(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'seeking' handler: ".concat(e))})};e.on("seeking",d),r.push(function(){return e.off("seeking",d)});var f=function(){o=!1,Hn(e,i,n).then(function(e){t.onSeeked(e)}).catch(function(e){t.onError("Error getting iframe metadata from 'seeked' handler: ".concat(e))})};e.on("seeked",f),r.push(function(){return e.off("seeked",f)});var v=function(){(function(e){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t){return e.getCurrentTime(t)})];case 1:return[2,{currentTime:t.sent()}]}})})})(e).then(function(e){var n={position:e.currentTime,isSeeking:o};t.onTimeUpdate(n)}).catch(function(e){t.onError("Error getting iframe metadata from 'timeupdate' handler: ".concat(e))})};e.on("timeupdate",v),r.push(function(){return e.off("timeupdate",v)})};return e.on("ready",i),function(){e.off("ready",i),r.forEach(function(e){return e()})}}var Vn=function(){function e(e){var t=e.videoEl,n=e.onStateChange,r=e.vendor,i=e.isEmbedded,a=this;this.state={playbackState:"paused"},this.waitingInterval=null,this.handler={onPlay:function(e){a.updatePlaybackState("playing",e)},onPause:function(e){a.updatePlaybackState("paused",e)},onEnded:function(e){a.updatePlaybackState("ended",e)},onSeeking:function(){var e=o(o({},a.state),{isSeeking:!0});a.updateState(e)},onSeeked:function(e){var t=o(o({},a.state),{isSeeking:!1,position:e.last_position});a.updateState(t)},onError:function(e){a.updateStateWithError(e)},onTimeUpdate:function(e){a.updateTime(e)}},this.onStateChange=n,this.untrack=i?zn(t,this.handler,r):function(e,t,n){var r=!1,i=function(){r=!1;var i=o(o({},qn(e)),"mux"===n?Bn(e):{});t.onPlay(i)};e.addEventListener("play",i);var a=function(){if(!r){r=!0;var i=o(o({},qn(e,"ended")),"mux"===n?Bn(e):{});t.onEnded(i)}};e.addEventListener("ended",a);var s=function(){if(!0!==e.ended){var r=o(o({},qn(e,"paused")),"mux"===n?Bn(e):{});t.onPause(r)}else a()};e.addEventListener("pause",s);var u=function(){var r=o(o({},qn(e,"seeking")),"mux"===n?Bn(e):{});t.onSeeking(r)};e.addEventListener("seeking",u);var l=function(){var r=o(o({},qn(e)),"mux"===n?Bn(e):{});t.onSeeked(r)};e.addEventListener("seeked",l);var c=function(){var n;t.onError((n=e.error)?"Media element error (code ".concat(n.code,")").concat(n.message?": ".concat(n.message):""):"Media element error")};e.addEventListener("error",c);var d=function(){var n=e,r={position:e.currentTime,isSeeking:!!n.seeking};t.onTimeUpdate(r)};return e.addEventListener("timeupdate",d),function(){e.removeEventListener("play",i),e.removeEventListener("ended",a),e.removeEventListener("pause",s),e.removeEventListener("seeking",u),e.removeEventListener("seeked",l),e.removeEventListener("error",c),e.removeEventListener("timeupdate",d)}}(t,this.handler,r)}return e.prototype.stateChangeHandler=function(e,t){try{this.onStateChange(e,t)}catch(e){}},e.prototype.updateStateWithError=function(e){this.clearWaitingInterval();var t=this.state,n=o(o({},t),{playbackState:"error",errorMessage:e});this.updateState(n)},e.prototype.updatePlaybackState=function(e,t){var n=this,r=o(o({},this.state),{playbackState:e,errorMessage:void 0,lastEvent:t,position:t.last_position});if(this.updateState(r),this.clearWaitingInterval(),"playing"===e){var i=this.state.position;this.waitingInterval=setInterval(function(){var e=n.state.position;"playing"===n.state.playbackState&&"number"==typeof i&&i===e&&n.updateState(o(o({},n.state),{playbackState:"waiting"})),i=e},1e3)}},e.prototype.clearWaitingInterval=function(){this.waitingInterval&&(clearInterval(this.waitingInterval),this.waitingInterval=null)},e.prototype.updateTime=function(e){var t,n,r=this.state.lastEvent,i="waiting"===this.state.playbackState,a="playing"===this.state.playbackState;if(r&&(a||i)){var s=e.isSeeking||this.state.isSeeking,u=null!==(t=this.state.position)&&void 0!==t?t:0,l=e.position;if(s)this.state=o(o({},this.state),{position:l});else{var c=l-u,d=o(o({},this.state),{playbackState:"playing",position:l,watchTime:(null!==(n=this.state.watchTime)&&void 0!==n?n:0)+c});this.updateState(d)}}},e.prototype.updateState=function(e){var t=this.state;this.state=e,this.stateChangeHandler(t,e)},e.prototype.destroy=function(){this.clearWaitingInterval(),this.untrack()},e}();function Wn(e,t,n){var r,i,o=[];try{for(var a=l(null!=t?t:[]),s=a.next();!s.done;s=a.next()){var u=s.value;try{o.push(new RegExp(u))}catch(e){n.warn("Invalid regex pattern: ".concat(u),e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e.concat(o)}function $n(e){var t,n,r,i,o,a,s,u,f,v,p,h;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var g=Object.keys(e);try{for(var m=l(g),y=m.next();!y.done;y=m.next()){var b=y.value;try{var w=e[b];"boolean"==typeof(null==w?void 0:w.enabled)&&(w.enabled?(delete w.enabled,0===Object.keys(w).length&&(e[b]=!0)):e[b]=!1),$n(w)}catch(e){}}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}try{if(null===(f=null===(u=null===(s=e.autocapture)||void 0===s?void 0:s.networkTracking)||void 0===u?void 0:u.captureRules)||void 0===f?void 0:f.length)try{for(var E=l(e.autocapture.networkTracking.captureRules),S=E.next();!S.done;S=E.next()){var k=S.value;try{for(var T=(o=void 0,l(["responseHeaders","requestHeaders"])),x=T.next();!x.done;x=T.next()){var P=x.value,_=null!==(v=k[P])&&void 0!==v?v:{},I=_.captureSafeHeaders,A=_.allowlist;(I||A)&&(void 0===A||Array.isArray(A)?k[P]=d(d([],c(I?R:[]),!1),c(null!=A?A:[]),!1):delete k[P])}}catch(e){o={error:e}}finally{try{x&&!x.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{S&&!S.done&&(i=E.return)&&i.call(E)}finally{if(r)throw r.error}}}catch(e){}var O=null===(p=e.autocapture)||void 0===p?void 0:p.frustrationInteractions;O&&(O.rageClick&&(O.rageClicks=O.rageClick,delete O.rageClick),O.deadClick&&(O.deadClicks=O.deadClick,delete O.deadClick));try{var C=null===(h=e.autocapture)||void 0===h?void 0:h.elementInteractions;if(C&&"object"==typeof C&&(!0===C.viewportContentUpdated&&(C.viewportContentUpdated={}),!1===C.viewportContentUpdated&&(C.viewportContentUpdated={enabled:!1}),void 0!==C.exposureDuration)){var D=C.viewportContentUpdated;void 0===D?C.viewportContentUpdated={exposureDuration:C.exposureDuration}:"object"==typeof D&&void 0===D.exposureDuration&&!1!==D.enabled&&(D.exposureDuration=C.exposureDuration),delete C.exposureDuration}}catch(e){}}}var Kn=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])&&(!function(){var e,t,n=B();return"string"==typeof(null===(t=null===(e=null==n?void 0:n.chrome)||void 0===e?void 0:e.runtime)||void 0===t?void 0:t.id)}()||!!(null==e?void 0:e[t]))},Gn=function(e){return Kn(e,"attribution")},Jn=function(e){return Kn(e,"formInteractions")},Yn=function(e){return Kn(e,"pageViews")},Xn=function(e){return Kn(e,"sessions")},Qn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},Zn=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},er=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},tr=function(e){if("object"==typeof e.autocapture){var t=e.autocapture.performanceTracking;return!0===t?{mainThreadBlock:!0}:"object"==typeof t&&null!==t?t:void 0}},nr=function(e){if(Zn(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},rr=function(e){if(er(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},ir=function(e){if(Qn(e.autocapture)){var t=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?t=e.autocapture.networkTracking:e.networkTrackingOptions&&(t=e.networkTrackingOptions),o(o({},t),{captureRules:(n=null==t?void 0:t.captureRules,r=e.loggerProvider,null==n?void 0:n.map(function(e){var t,n;if((null===(t=e.urls)||void 0===t?void 0:t.length)&&(null===(n=e.hosts)||void 0===n?void 0:n.length)){var i=JSON.stringify(e.hosts),a=JSON.stringify(e.urls);return null==r||r.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(i,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),o(o({},e),{hosts:void 0})}return e}))})}var n,r},or=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return Yn(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}},ar=function(e,t){sr(e,t)},sr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,a=r.resolve,s=e&&e[i];if("function"==typeof s){var u=s.apply(e,o);"function"==typeof a&&a(null==u?void 0:u.promise)}}return e},ur=function(e){return e&&void 0!==e._q};var lr="2.46.0-video-analytics-4.0",cr="amplitude-ts-sdk-script",dr=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(cr,"/").concat(lr),"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){var t,n;return s(this,void 0,void 0,function(){var r,i,a;return u(this,function(s){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,a=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=a,e.time||(this.config.lastEventTime=r),[2,o(o(o(o(o(o(o(o({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Ue()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:z(),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:a,library:this.library,user_agent:this.userAgent})]})})},e}(),fr=1e3,vr=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=B())||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 n(t,e),t.prototype.set=function(t,n){var r;return s(this,void 0,void 0,function(){var i;return u(this,function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>fr?(i=n.length-fr,[4,e.prototype.set.call(this,t,n.slice(0,fr))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(fr,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},t}(Ye),pr=function(e){function t(){var t;return e.call(this,null===(t=B())||void 0===t?void 0:t.sessionStorage)||this}return n(t,e),t}(Ye),hr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return n(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),s(this,void 0,void 0,function(){var r=this;return u(this,function(i){return[2,new Promise(function(i,a){"undefined"==typeof XMLHttpRequest&&a(new Error("XHRTransport is not supported."));var d=new XMLHttpRequest;d.open("POST",e,!0),d.onreadystatechange=function(){if(d.readyState===r.state.done){var e=d.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch(e){i(r.buildResponse({code:d.status}))}}};var f={"Content-Type":"application/json",Accept:"*/*"},v=JSON.stringify(t),p=n&&v.length>=2048&&pt(),h=function(e){var t,n;f=o(o({},r.customHeaders),f);try{for(var i=l(Object.entries(f)),a=i.next();!a.done;a=i.next()){var s=c(a.value,2),u=s[0],v=s[1];d.setRequestHeader(u,v)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}d.send(e)};s(r,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return p?[4,ht(v)]:[3,2];case 1:return(e=t.sent())?(f["Content-Encoding"]="gzip",h(e)):h(v),[3,3];case 2:h(v),t.label=3;case 3:return[2]}})}).catch(a)})]})})},t}(vt),gr=function(e){function t(t,n,r){void 0===t&&(t={});var i=e.call(this)||this;return i.customHeaders=t,i.enableKeepalive=!1!==n,i.referrerPolicy=r,i}return n(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),s(this,void 0,void 0,function(){var r,i,a,s,l,c,d,f,v;return u(this,function(u){switch(u.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return r=JSON.stringify(t),i=n&&r.length>=2048&&pt(),a=r,s={"Content-Type":"application/json",Accept:"*/*"},i?[4,ht(r)]:[3,2];case 1:(l=u.sent())&&(s["Content-Encoding"]="gzip",a=l),u.label=2;case 2:return s=o(o({},this.customHeaders),s),c="string"==typeof a?a.length:a.byteLength,d={headers:s,body:a,method:"POST",keepalive:this.enableKeepalive&&c<=16384},this.referrerPolicy&&(d.referrerPolicy=this.referrerPolicy),[4,fetch(e,d)];case 3:return[4,(f=u.sent()).text()];case 4:v=u.sent();try{return[2,this.buildResponse(JSON.parse(v))]}catch(e){return[2,this.buildResponse({code:f.status})]}return[2]}})})},t}(vt),mr=function(e){function t(){return e.call(this)||this}return n(t,e),t.prototype.send=function(e,t,n){return s(this,void 0,void 0,function(){var n=this;return u(this,function(r){return[2,new Promise(function(r,i){var o=B();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var a=JSON.stringify(t);return r(o.navigator.sendBeacon(e,a)?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:a.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(vt),yr=function(e,t,n){return void 0===n&&(n=!0),s(void 0,void 0,void 0,function(){var r,i,o,a,s,l,d,f,p;return u(this,function(u){switch(u.label){case 0:return r=function(e){return"".concat(v.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=u.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:u.sent(),u.label=3;case 3:return o=c(i.split("."),6),a=o[0],s=o[1],l=o[2],d=o[3],f=o[4],p=o[5],[2,{deviceId:a,userId:wr(s),sessionId:br(d),lastEventId:br(p),lastEventTime:br(f),optOut:Boolean(l)}]}})})},br=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},wr=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Er="[Amplitude]",Sr="".concat(Er," Form Started"),kr="".concat(Er," Form Submitted"),Tr="".concat(Er," File Downloaded"),xr="".concat(Er," Content Started"),Pr="".concat(Er," Content Stopped"),_r="session_start",Ir="session_end",Ar="".concat(Er," File Extension"),Or="".concat(Er," File Name"),Cr="".concat(Er," Link ID"),Rr="".concat(Er," Link Text"),Dr="".concat(Er," Link URL"),Lr="".concat(Er," Form ID"),Nr="".concat(Er," Form Name"),Mr="".concat(Er," Form Destination"),jr="cookie",Ur="US",Fr=Object.freeze({__proto__:null,get IdentifyOperation(){return r},get SpecialEventType(){return i},get RevenueProperty(){return J},get LogLevel(){return re},get ServerZone(){return Pt},OfflineDisabled:null,DEFAULT_CSS_SELECTOR_ALLOWLIST:It,DEFAULT_DATA_ATTRIBUTE_PREFIX:At,DEFAULT_ACTION_CLICK_ALLOWLIST:Ot,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:Un}),qr=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},Br=function(e,t,n,r,i,s){void 0===i&&(i=!0),e.referrer;var u=e.referring_domain,l=a(e,["referrer","referring_domain"]),c=t||{};c.referrer;var d,f=c.referring_domain,v=a(c,["referrer","referring_domain"]),p=n.excludeInternalReferrers;if(p){var h=zr(p,r);if(!(h instanceof TypeError)&&e.referring_domain&&Kr(e.referring_domain,s)){if("always"===h)return Vr(h,e.referring_domain,r),!1;if("ifEmptyCampaign"===h&&(d=o(o({},e),{referring_domain:void 0,referrer:void 0}),Object.values(d).every(function(e){return!e})))return Vr(h,e.referring_domain,r),!1}}if(Hr(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 g=JSON.stringify(l)!==JSON.stringify(v),m=qr(u||"")!==qr(f||""),y=!t||g||m;return y?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."),y},Hr=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})},zr=function(e,t){if(!0===e)return Un.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(Un).includes(n))return n;if(void 0===n)return Un.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),new TypeError(r)};function Vr(e,t,n){var r="This is not a new campaign because referring_domain=".concat(t," is on the same domain as the current page and it is configured to exclude internal referrers");"always"===e?n.debug(r):"ifEmptyCampaign"===e&&n.debug("".concat(r," with empty campaign parameters"))}var Wr=["ac.in","ac.jp","ac.kr","ac.th","ac.uk","ac.za","appspot.com","asn.au","azurewebsites.net","cloudfront.net","myshopify.com","blogspot.com","co.ca","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.ar","com.au","com.br","com.cn","com.hk","com.in","com.jp","com.kr","com.mx","com.pl","com.sg","com.tr","com.tw","ed.jp","edu.au","edu.br","edu.cn","edu.hk","edu.sg","edu.th","edu.tr","edu.tw","firebaseapp.com","fly.dev","gc.ca","geek.nz","github.io","gitlab.io","go.jp","go.kr","go.th","gob.ar","gob.mx","gov.au","gov.br","gov.cn","gov.hk","gov.in","gov.pl","gov.sg","gov.tr","gov.tw","gov.uk","gov.za","govt.nz","gr.jp","herokuapp.com","id.au","idv.hk","iwi.nz","lg.jp","ltd.uk","maori.nz","me.uk","mil.kr","ne.jp","ne.kr","net.au","net.br","net.cn","net.hk","net.in","net.nz","net.pl","net.sg","net.tr","net.tw","net.za","onrender.com","or.jp","or.kr","or.th","org.ar","org.au","org.br","org.cn","org.hk","org.in","org.mx","org.nz","org.pl","org.sg","org.tw","org.uk","org.za","pages.dev","pe.kr","plc.uk","re.kr","res.in","sch.uk","vercel.app","netlify.app","workers.dev"],$r=function(e){var t,n,r=e||(null===(n=null===(t=B())||void 0===t?void 0:t.location)||void 0===n?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],a=i[i.length-2];return Wr.find(function(e){return r.endsWith(".".concat(e))})&&(o=i[i.length-2]+"."+i[i.length-1],a=i[i.length-3]),a?"".concat(a,".").concat(o):o},Kr=function(e,t){var n=B();if(!n)return!1;var r,i,o,a=(t||"").trim()||$r(n.location.hostname);return r=e,o=(i=a).startsWith(".")?i:".".concat(i),!!(r.startsWith(".")?r:".".concat(r)).endsWith(o)},Gr=function(e){function t(t,n,r,i,o,a,s,u,l,c,d,f,v,p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A,O,C,R,D,L,N,M,j,U,F,q,B,H,z,V,W){void 0===r&&(r=new We),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===u&&(u=1e3),void 0===l&&(l=5),void 0===c&&(c=30),void 0===d&&(d=jr),void 0===g&&(g=new oe),void 0===m&&(m=re.Warn),void 0===b&&(b=!1),void 0===w&&(w=!1),void 0===k&&(k=""),void 0===T&&(T=Ur),void 0===_&&(_=18e5),void 0===I&&(I=new vr({loggerProvider:g})),void 0===A&&(A={ipAddress:!0,language:!0,platform:!0}),void 0===O&&(O="fetch"),void 0===C&&(C=!1),void 0===R&&(R=!0),void 0===U&&(U=!0),void 0===F&&(F=0),void 0===z&&(z=!1);var $,K=this;(K=e.call(this,{apiKey:t,instanceName:v,storageProvider:I,transportProvider:Xr(O)})||this).apiKey=t,K.appVersion=n,K.cookieOptions=i,K.defaultTracking=o,K.autocapture=a,K.flushIntervalMillis=u,K.flushMaxRetries=l,K.flushQueueSize=c,K.identityStorage=d,K.ingestionMetadata=f,K.loggerProvider=g,K.logLevel=m,K.minIdLength=y,K.offline=b,K.partnerId=E,K.plan=S,K.serverUrl=k,K.serverZone=T,K.sessionTimeout=_,K.storageProvider=I,K.trackingOptions=A,K.transport=O,K.useBatch=C,K.fetchRemoteConfig=R,K.networkTrackingOptions=M,K.identify=j,K.enableDiagnostics=U,K.diagnosticsSampleRate=F,K.diagnosticsClient=q,K.remoteConfig=B,K.topLevelDomain=H,K.enableRequestBodyCompression=z,K.customEnrichment=V,K.delayedEventsServerUrl=W,K.version=lr,K._optOut=!1,K._cookieStorage=r,K.deviceId=s,K.lastEventId=p,K.lastEventTime=h,K.optOut=w,K.deferredSessionId=P,K.sessionId=x,K.pageCounter=L,K.userId=D,K.debugLogsEnabled=N,K.loggerProvider.enable(N?re.Debug:K.logLevel),K.networkTrackingOptions=M,K.identify=j,K.enableDiagnostics=U,K.diagnosticsSampleRate=F,K.diagnosticsClient=q;var G=null!==($=null==B?void 0:B.fetchRemoteConfig)&&void 0!==$?$:R;return K.remoteConfig=K.remoteConfig||{},K.remoteConfig.fetchRemoteConfig=G,K.fetchRemoteConfig=G,K.topLevelDomain=H||$r(),K.delayedEventsServerUrl=function(e,t,n){return void 0===n&&(n=Ur),t||(e?"".concat(e,"/delayed"):"EU"===n?"https://delayed-events.prod.eu-central-1.amplitude.com/2/httpapi/delayed":"https://delayed-events.prod.us-west-2.amplitude.com/2/httpapi/delayed")}(k,W,T),K}return n(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,void 0!==e&&void 0!==this._deferredSessionId&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof $e&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(je(this.apiKey),e)},t}(ue),Jr=function(e,t,n,r,i){return void 0===t&&(t={}),s(void 0,void 0,void 0,function(){var a,s,l,c,d,f,v,p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A,O,C,R,D,L,N,M,j,U,F,q,B,H,V,W,$,K,G,J,Y,X,Q,Z,ee,te,ne,re,ie;return u(this,function(u){switch(u.label){case 0:return a=t.identityStorage||jr,s="",a!==jr||(null===(I=t.cookieOptions)||void 0===I?void 0:I.domain)||""===(null===(A=t.cookieOptions)||void 0===A?void 0:A.domain)?[3,2]:[4,Qr(void 0,r)];case 1:s=u.sent(),u.label=2;case 2:return l=o({domain:null!==(C=null===(O=t.cookieOptions)||void 0===O?void 0:O.domain)&&void 0!==C?C:s,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},t.cookieOptions),c={duplicateResolverFn:function(e){var t=Ke(e);if(!t)return!1;var n=JSON.parse(t);return Ge(n.cookieDomain,l.domain)},diagnosticsClient:r},d=Yr(t.identityStorage,l,c),[4,yr(e,d,null===(D=null===(R=t.cookieOptions)||void 0===R?void 0:R.upgrade)||void 0===D||D)];case 3:return f=u.sent(),[4,d.get(je(e))];case 4:return v=u.sent(),p=Fe(),h=p.ampTimestamp?Number(p.ampTimestamp):void 0,g=!h||Date.now()<h,m=null!==(U=null!==(j=null!==(M=null!==(L=t.deviceId)&&void 0!==L?L:g?null!==(N=p.ampDeviceId)&&void 0!==N?N:p.deviceId:void 0)&&void 0!==M?M:null==v?void 0:v.deviceId)&&void 0!==j?j:f.deviceId)&&void 0!==U?U:z(),y=null!==(F=null==v?void 0:v.lastEventId)&&void 0!==F?F:f.lastEventId,b=null!==(q=null==v?void 0:v.lastEventTime)&&void 0!==q?q:f.lastEventTime,w=null!==(H=null!==(B=t.optOut)&&void 0!==B?B:null==v?void 0:v.optOut)&&void 0!==H?H:f.optOut,E=null!==(V=null==v?void 0:v.sessionId)&&void 0!==V?V:f.sessionId,S=null==v?void 0:v.deferredSessionId,k=null!==($=null!==(W=t.userId)&&void 0!==W?W:null==v?void 0:v.userId)&&void 0!==$?$:f.userId,n.previousSessionDeviceId=null!==(K=null==v?void 0:v.deviceId)&&void 0!==K?K:f.deviceId,n.previousSessionUserId=null!==(G=null==v?void 0:v.userId)&&void 0!==G?G:f.userId,T={ipAddress:null===(Y=null===(J=t.trackingOptions)||void 0===J?void 0:J.ipAddress)||void 0===Y||Y,language:null===(Q=null===(X=t.trackingOptions)||void 0===X?void 0:X.language)||void 0===Q||Q,platform:null===(ee=null===(Z=t.trackingOptions)||void 0===Z?void 0:Z.platform)||void 0===ee||ee},x=null==v?void 0:v.pageCounter,P=null==v?void 0:v.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(_=new Gr(e,t.appVersion,d,l,t.defaultTracking,t.autocapture,m,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,a,t.ingestionMetadata,t.instanceName,y,b,null!==(te=null==i?void 0:i.loggerProvider)&&void 0!==te?te:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,w,t.partnerId,t.plan,t.serverUrl,null!==(ne=null==i?void 0:i.serverZone)&&void 0!==ne?ne:t.serverZone,E,S,t.sessionTimeout,t.storageProvider,T,t.transport,t.useBatch,t.fetchRemoteConfig,k,x,P,t.networkTrackingOptions,t.identify,null!==(re=null==i?void 0:i.enableDiagnostics)&&void 0!==re?re:t.enableDiagnostics,null!==(ie=null==i?void 0:i.diagnosticsSampleRate)&&void 0!==ie?ie:n._diagnosticsSampleRate,r,t.remoteConfig,s,t.enableRequestBodyCompression,t.customEnrichment,t.delayedEventsServerUrl)).storageProvider.isEnabled()];case 5:return u.sent()||(_.loggerProvider.warn("Storage provider ".concat(_.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),_.storageProvider=new We),[2,_]}})})},Yr=function(e,t,n){switch(void 0===e&&(e=jr),void 0===t&&(t={}),e){case"localStorage":return new vr;case"sessionStorage":return new pr;case"none":return new We;default:return new $e(o(o({},t),{expirationDays:t.expiration}),n)}},Xr=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0,r="object"==typeof e?e.enableKeepalive:void 0,i="object"==typeof e?e.referrerPolicy:void 0;return"xhr"===t?new hr(n):"beacon"===t?new mr:new gr(n,r,i)},Qr=function(e,t){return s(void 0,void 0,void 0,function(){var n,r,i,o,a,s,l;return u(this,function(u){switch(u.label){case 0:return[4,new $e(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!u.sent()||!e&&("undefined"==typeof location||!location.hostname))return[2,""];if(n=null!=e?e:location.hostname,1===(r=n.split(".")).length)return[2,""];for(i=[],o=1,Wr.find(function(e){return n.endsWith(".".concat(e))})&&(o=2),a=r.length-o-1;a>=0;--a)i.push(r.slice(a).join("."));a=0,u.label=2;case 2:if(!(a<i.length))return[3,7];s=i[a],u.label=3;case 3:return u.trys.push([3,5,,6]),[4,$e.isDomainWritable(s)];case 4:return u.sent()?[2,"."+s]:[3,6];case 5:return l=u.sent(),t&&t.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(s),error:l instanceof Error?l.message:String(l)}),[3,6];case 6:return a++,[3,2];case 7:return t&&t.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(n)}),[2,""]}})})},Zr="AMP_PAGE_VIEW",ei=function(e){var t;void 0===e&&(e={});var n,r,i=B(),a=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==a||a.error("Malformed URI sequence: ",e)}return t},g=function(e){return s(void 0,void 0,void 0,function(){var t,n,r;return u(this,function(i){switch(i.label){case 0:return t=h("undefined"!=typeof location&&location.href||""),r={event_type:p},n=[{}],[4,ti()];case 1:return[2,(r.event_properties=o.apply(void 0,[o.apply(void 0,n.concat([i.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":ln(un),"[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 u(this,function(u){switch(u.label){case 0:return e=location.href,n=ri(f,e,y||"")&&m(),y=e,n?(i=void 0,r&&(i=z(),r.set(Zr,{pageViewId:i})),null==a||a.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,[u.sent()]),u.label=3;case 3:u.label=4;case 4:return[2]}})})},w={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,o){return s(void 0,void 0,void 0,function(){var s,d,f;return u(this,function(u){switch(u.label){case 0:if(t=o,n=e,(a=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),l=!0,i){try{r=new Ye(i.sessionStorage)}catch(e){null==a||a.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",b),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),l&&b()}})}return m()?(a.log("Tracking page view event"),s=void 0,r&&(s=z(),r.set(Zr,{pageViewId:s})),f=(d=t).track,[4,g(s)]):[3,2];case 1:f.apply(d,[u.sent()]),u.label=2;case 2:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,i,s;return u(this,function(u){switch(u.label){case 0:return"attribution"===d&&ni(e)?(null==a||a.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,r?[4,r.get(Zr)]:[3,2]):[3,4];case 1:i=u.sent(),t=null==i?void 0:i.pageViewId,u.label=2;case 2:return[4,g(t)];case 3:s=u.sent(),e.event_type=s.event_type,e.event_properties=o(o({},e.event_properties),s.event_properties),u.label=4;case 4:return n&&e.event_type===p&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=o(o({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return i&&(i.removeEventListener("popstate",b),l=!1),[2]})})}};return w},ti=function(){return s(void 0,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return e=Ve,[4,(new tn).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},ni=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[r.SET]||{},i=t[r.UNSET]||{},o=d(d([],c(Object.keys(n)),!1),c(Object.keys(i)),!1);return Object.keys(C).every(function(e){return o.includes(e)})}return!1},ri=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},ii=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,a;return u(this,function(s){return t=function(e){if(Jn(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=new WeakSet,a=function(e){if(!o.has(e)){o.add(e);var a=!1;r(e,"change",function(){var t,n=ai(e);a||i.track(Sr,((t={})[Lr]=oi(e.id),t[Nr]=oi(e.name),t[Mr]=n,t)),a=!0}),r(e,"submit",function(r){var o,s,u=ai(e);if(a||i.track(Sr,((o={})[Lr]=oi(e.id),o[Nr]=oi(e.name),o[Mr]=u,o)),a=!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(kr,((s={})[Lr]=oi(e.id),s[Nr]=oi(e.name),s[Mr]=u,s)),a=!1})}};Array.from(document.getElementsByTagName("form")).forEach(a),"undefined"!=typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){try{if("FORM"===e.nodeName&&a(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var t=e.querySelectorAll("form");null==t||t.forEach(a)}}catch(e){n.loggerProvider.warn("Failed to track form interactions for an added node: ".concat(String(e)))}})})})).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():(a=B())?a.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 u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(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]})})}}},oi=function(e){if("string"==typeof e)return e},ai=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},si=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 u(this,function(a){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),a=null==i?void 0:i[1];a&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",function(){var t;a&&r.track(Tr,((t={})[Ar]=a,t[Or]=n.pathname,t[Cr]=e.id,t[Rr]=e.text,t[Dr]=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){try{if("A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var t=e.querySelectorAll("a");null==t||t.forEach(i)}}catch(e){n.loggerProvider.warn("Failed to track file downloads for an added node: ".concat(String(e)))}})})})).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=B())?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 u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(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]})})}}},ui=!1,li=function(){var e=B(),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 u(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(){!1!==e.offline&&(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 u(this,function(n){return t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[],[2]})})}}};function ci(e,t){var n,r;if(e){$n(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",X(e));var i=e;if(i&&"autocapture"in i){if("boolean"==typeof i.autocapture&&(t.autocapture=i.autocapture),"object"==typeof i.autocapture&&null!==i.autocapture){var a=o({},i.autocapture);if(void 0===t.autocapture&&(t.autocapture=i.autocapture),"object"==typeof i.autocapture.elementInteractions&&null!==i.autocapture.elementInteractions&&(null===(n=i.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===n?void 0:n.length)){a.elementInteractions=o({},i.autocapture.elementInteractions);var s=a.elementInteractions,u=null!==(r=s.pageUrlAllowlist)&&void 0!==r?r:[],c=i.autocapture.elementInteractions.pageUrlAllowlistRegex;s.pageUrlAllowlist=Wn(u,c,t.loggerProvider),delete s.pageUrlAllowlistRegex}var d=function(e,t){var n,r,i,a,s;if("object"==typeof e&&null!==e&&(null===(i=e.captureRules)||void 0===i?void 0:i.length)){var u=o({},e),c=null!==(a=u.captureRules)&&void 0!==a?a:[];try{for(var d=l(c),f=d.next();!f.done;f=d.next()){var v=f.value;v.urls=Wn(null!==(s=v.urls)&&void 0!==s?s:[],v.urlsRegex,t),delete v.urlsRegex}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u}}(i.autocapture.networkTracking,t.loggerProvider);d&&(a.networkTracking=d),"boolean"==typeof t.autocapture&&(t.autocapture=o({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},a)),"object"==typeof t.autocapture&&(t.autocapture=o(o({},t.autocapture),a))}t.defaultTracking=t.autocapture}"customEnrichment"in i&&null!==i.customEnrichment&&!1!==t.customEnrichment&&(t.customEnrichment=i.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",X(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var di="1.29.2-video-analytics-4.0",fi="[Amplitude] Element Clicked",vi="[Amplitude] Element Tag",pi="[Amplitude] Element Text",hi="[Amplitude] Page URL",gi="[Amplitude] Viewport Height",mi="[Amplitude] Viewport Width",yi="[Amplitude] Page View ID",bi="data-amp-mask-attributes",wi="data-amp-internal-shadow";function Ei(e,t){var n=e.getAttribute(t.explicitTrackingAttribute);if(null!==n&&""===n)return null;var r=e.getAttribute("id");return null===r||""===r?null:function(e,t){var n,r;if(null==e||""===e)return!1;try{for(var i=l(t),o=i.next();!o.done;o=i.next())if(o.value.test(e))return!1}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return!0}(r,t.autogeneratedIdPatterns)?r:null}function Si(e,t){return t.map(ki).join(" > ")}function ki(e){var t=e.tagName.toLowerCase(),n=e.parentElement;if(null===n)return t;var r=function(e,t){for(var n=0,r=0;r<t.children.length;r++){var i=t.children[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}(e,n);return"".concat(t,":nth-of-type(").concat(r,")")}var Ti=":scope > ";function xi(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}function Pi(e){var t,n=e.getRootNode();return xi(n)?n:null!==(t=e.ownerDocument)&&void 0!==t?t:document}function _i(e,t){var n,r,i,o;return u(this,function(a){switch(a.label){case 0:n=e,r=0,i=0,a.label=1;case 1:return null!==n&&i<1024?(i+=1,[4,n]):[3,3];case 2:return a.sent(),n.parentElement?(n=n.parentElement,[3,1]):r<t&&"function"==typeof n.getRootNode&&(o=function(e){if(e.parentElement)return e.parentElement;var t=e.getRootNode();return xi(t)?t.host:null}(n))&&o!==n?(r+=1,n=o,[3,1]):[3,3];case 3:return[2]}})}function Ii(e,t){var n=[];if(t<=0)return n;for(var r=[[e,0]],i=0;r.length&&i<5e4;){i+=1;var o=c(r.pop(),2),a=o[0],s=o[1],u=a.shadowRoot;if(u&&s+1<=t){n.push({root:u,depth:s+1});for(var l=u.children,d=0;d<l.length;d++)r.push([l[d],s+1])}var f=a.children;for(d=0;d<f.length;d++)r.push([f[d],s])}return n}function Ai(e,t){for(var n=[],r=e,i=0;null!==r&&i<1024;){i+=1;var o=Pi(r);n.push({root:o,target:r});var a=r.getRootNode();if(!xi(a))break;r=a.host}var s=n.length-1,u=!1,l=n;return s>t&&(l=n.slice(s-t),u=!0),{segments:l.reverse(),truncated:u}}function Oi(e,t){var n=e.tagName.toLowerCase(),r=e.parentElement;if(null===r){var i=e.getRootNode();return t&&xi(i)?"".concat(n,":nth-of-type(").concat(Ci(e,i.children),")"):n}return"".concat(n,":nth-of-type(").concat(Ci(e,r.children),")")}function Ci(e,t){for(var n=0,r=0;r<t.length;r++){var i=t[r];if(i.tagName===e.tagName&&(n+=1,i===e))return n}return 1}var Ri={name:"explicitTrackingAttribute",try:function(e,t){var n=t.config.explicitTrackingAttribute,r=e.getAttribute(n);return null===r||""===r?null:"[".concat(n,"=").concat(JSON.stringify(r),"]")}};function Di(e){var t=globalThis.CSS;if(t&&"function"==typeof t.escape)return t.escape(e);for(var n=String(e),r=n.length,i="",o=0;o<r;o++){var a=n.charCodeAt(o);0!==a?a>=1&&a<=31||127===a||0===o&&a>=48&&a<=57||1===o&&a>=48&&a<=57&&45===n.charCodeAt(0)?i+="\\".concat(a.toString(16)," "):i+=0!==o||1!==r||45!==a?a>=128||45===a||95===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?n.charAt(o):"\\".concat(n.charAt(o)):"\\-":i+="�"}return i}function Li(e){return Di(e)}var Ni={name:"stableId",try:function(e,t){var n=Ei(e,t.config);return null===n?null:"".concat(e.tagName.toLowerCase(),"#").concat(Li(n))}},Mi=!1,ji=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:d([],c([/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/]),!1),unstableClassPatterns:d([],c([/^(p|m|px|py|mx|my|pt|pb|pl|pr|mt|mb|ml|mr)-\d+$/,/^(w|h|min-w|max-w|min-h|max-h)-/,/^(text|bg|border|ring|fill|stroke)-/,/^(hover|focus|active|disabled|group-hover):/,/^(sm|md|lg|xl|2xl):/,/^z-\d+$/,/^data-\[/,/^\[/,/^css-[a-z0-9]{6,}$/,/^[a-zA-Z]+_[a-zA-Z0-9]{3,}__[a-zA-Z0-9]{5,}$/,/^sc-[a-zA-Z0-9]{6,}$/,/^jsx-\d+$/,/^swiper-slide-(visible|fully-visible|active|prev|next|duplicate)$/,/^is-(active|open|selected|hovered|focused|expanded)$/,/^Mui[A-Z][a-zA-Z]+-(focused|selected|disabled|expanded|focusVisible|active|checked)$/,/^Mui-(selected|focused|disabled|expanded|focusVisible|active|checked)$/,/^data-state-/]),!1),maxAncestorWalkDepth:void 0,shadowDomEnabled:Mi,maxShadowDomDepth:1});function Ui(e){var t;return o(o({},e),{shadowDomEnabled:null!==(t=e.shadowDomEnabled)&&void 0!==t?t:Mi,maxShadowDomDepth:qi(e.maxShadowDomDepth)})}function Fi(e,t){if(!e)return Bi();var n,r=Bi();return"boolean"==typeof e.enabled&&(r.enabled=e.enabled),"string"==typeof e.explicitTrackingAttribute&&""!==e.explicitTrackingAttribute&&(r.explicitTrackingAttribute=e.explicitTrackingAttribute),Array.isArray(e.autogeneratedIdPatterns)&&(r.autogeneratedIdPatterns=function(e,t){var n,r,i=[];try{for(var o=l(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(s,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.autogeneratedIdPatterns,t)),Array.isArray(e.unstableClassPatterns)&&(r.unstableClassPatterns=function(e,t){var n,r,i=[];try{for(var o=l(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(e){var u=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(s,'" (').concat(u,")"))}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e.unstableClassPatterns,t)),r.maxAncestorWalkDepth="number"!=typeof(n=e.maxAncestorWalkDepth)?void 0:Number.isFinite(n)?n<=0?void 0:Math.floor(n):void 0,"boolean"==typeof e.shadowDomEnabled&&(r.shadowDomEnabled=e.shadowDomEnabled),r.maxShadowDomDepth=qi(e.maxShadowDomDepth),Ui(r)}function qi(e){return"number"==typeof e&&Number.isFinite(e)?Math.min(Math.max(Math.floor(e),1),10):1}function Bi(){return{enabled:ji.enabled,explicitTrackingAttribute:ji.explicitTrackingAttribute,autogeneratedIdPatterns:d([],c(ji.autogeneratedIdPatterns),!1),unstableClassPatterns:d([],c(ji.unstableClassPatterns),!1),maxAncestorWalkDepth:ji.maxAncestorWalkDepth,shadowDomEnabled:ji.shadowDomEnabled,maxShadowDomDepth:ji.maxShadowDomDepth}}var Hi=[Ri,Ni];function zi(e,t,n){var r,i,o,a,s;void 0===n&&(n={});var u=Ui(t),c=null!==(o=n.strategies)&&void 0!==o?o:Hi,d=null!==(s=null!==(a=n.scope)&&void 0!==a?a:e.ownerDocument)&&void 0!==s?s:document,f={scope:d,config:u},v=function(e,t){var n=[],r=e;for(;null!==r&&(n.push(r),!(void 0!==t&&n.length>t));)r=r.parentElement;return n}(e,u.maxAncestorWalkDepth);try{for(var p=l(c),h=p.next();!h.done;h=p.next())for(var g=h.value,m=0;m<v.length;m++){var y=v[m],b=g.try(y,f);if(null!==b)if(0!==m){var w=Si(0,v.slice(0,m).reverse()),E="".concat(b," > ").concat(w);if(Vi(d,E,e,g.name,n.logger))return E}else if(Vi(d,b,e,g.name,n.logger))return b}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}return null}function Vi(e,t,n,r,i){var o;try{o=e.querySelectorAll(t)}catch(e){var a=e instanceof Error?e.message:String(e);return null==i||i.debug('@amplitude/element-selector: strategy "'.concat(r,'" emitted a malformed selector "').concat(t,'" (').concat(a,")")),!1}return 1===o.length&&o[0]===n}function Wi(e,t,n){var r;try{r=e.querySelectorAll(t)}catch(e){return!1}return 1===r.length&&r[0]===n}var $i=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),Ki=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 $i(Ji(o),!0);var a=e.tagName.toLowerCase();if("body"===a||"head"===a||"html"===a)return new $i(a,!0)}var s=e.tagName.toLowerCase();if(o)return new $i(s+Ji(o),!0);var u=e.parentNode;if(!u||u.nodeType===Node.DOCUMENT_NODE)return new $i(s,!0);for(var c=Gi(e),d=!1,f=!1,v=-1,p=-1,h=u.children,g=0;h&&(-1===v||!f)&&g<h.length;++g){var m=h[g];if(m.nodeType===Node.ELEMENT_NODE)if(p+=1,m!==e){if(!f&&m.tagName.toLowerCase()===s){d=!0;var y=new Set(c);if(y.size)for(var b=Gi(m),w=0;w<b.length;++w){var E=b[w];if(y.has(E)&&(y.delete(E),!y.size)){f=!0;break}}else f=!0}}else v=p}var S=s;if(n&&"input"===s.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(S+="[type="+Di(e.getAttribute("type")||"")+"]"),f)S+=":nth-child("+String(v+1)+")";else if(d)try{for(var k=l(c),T=k.next();!T.done;T=k.next()){S+="."+Di(T.value.slice(1))}}catch(e){r={error:e}}finally{try{T&&!T.done&&(i=k.return)&&i.call(k)}finally{if(r)throw r.error}}return new $i(S,!1)},Gi=function(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]},Ji=function(e){return"#"+Di(e)};function Yi(e,t){try{return function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=Ki(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e)}catch(e){var n=e instanceof Error?e.message:String(e);return null==t||t.warn("@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ".concat(n)),""}}function Xi(e,t){void 0===t&&(t={});var n=Ui(e),r=new Set,i=t.logger,o=function(e){return Yi(e,i)},a=function(e,r){var o;return null!==(o=zi(e,n,{strategies:t.strategies,scope:r,logger:i}))&&void 0!==o?o:function(e,t,n){var r,i;void 0===n&&(n={});for(var o=Ui(t),a=null!==(i=null!==(r=n.scope)&&void 0!==r?r:e.ownerDocument)&&void 0!==i?i:document,s=xi(a),u=[],l=e,f=0,v=!(o.shadowDomEnabled&&s);null!==l&&!(v&&void 0!==o.maxAncestorWalkDepth&&f>o.maxAncestorWalkDepth);){var p=Ei(l,o);if(null!==p){var h=d(["".concat(l.tagName.toLowerCase(),"#").concat(Li(p))],c(u),!1).join(" > ");if(Wi(a,h,e))return h}u.unshift(Oi(l,o.shadowDomEnabled)),l=l.parentElement,f+=1}var g=u.join(" > ");return o.shadowDomEnabled&&s&&null===l?"".concat(Ti).concat(g):g}(e,n,{scope:r})},s=function(e,t){return function(e,t,n){return e&&n&&xi(t)?"".concat(Ti).concat(e):e}(o(e),t,function(e){for(var t=e;null!==t;t=t.parentElement)if(t.getAttribute("id"))return!1;return!0}(e))};return{generate:function(e){var r,u;try{return n.shadowDomEnabled?function(e,t){var r=Ai(e,n.maxShadowDomDepth),o=r.segments;return r.truncated&&(null==i||i.debug("@amplitude/element-selector: target is nested deeper than maxShadowDomDepth (".concat(n.maxShadowDomDepth,") — emitting a best-effort selector for the outermost in-budget shadow host"))),o.map(function(e){var n=e.target,r=e.root;return t(n,r)}).join(" >>> ")}(e,n.enabled?a:s):(n.enabled?a:o)(e,null!==(u=null!==(r=t.scope)&&void 0!==r?r:e.ownerDocument)&&void 0!==u?u:document)}catch(t){var l=t instanceof Error?t.message:String(t);return null==i||i.warn("@amplitude/element-selector: selector generation threw — falling back to legacy cssPath: ".concat(l)),Yi(e,i)}},getConfig:function(){return n},updateConfig:function(e){var t,o;n=Ui(e);try{for(var a=l(r),s=a.next();!s.done;s=a.next()){var u=s.value;try{u(n)}catch(e){var c=e instanceof Error?e.message:String(e);null==i||i.warn("@amplitude/element-selector: onConfigChange subscriber threw — ".concat(c))}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}},onConfigChange:function(e){return r.add(e),function(){r.delete(e)}}}}var Qi,Zi,eo=Object.freeze({enabled:!1,maxDepth:0}),to=function(){var e=eo,t=new Set;return{get:function(){return e},arm:function(n){return e.enabled||!n.enabled||(e=n,function(e){var n,r;try{for(var i=l(d([],c(t),!1)),o=i.next();!o.done;o=i.next()){var a=o.value;try{a(e)}catch(e){}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.clear()}(n)),e},onArm:function(n){if(e.enabled){var r=e;try{n(r)}catch(e){}return function(){}}return t.add(n),function(){t.delete(n)}}}},no=["input","select","textarea"],ro=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&Be(window.location.href,n))&&!!Be(window.location.href,t)},io=function(e,t){return function(n,r){var i,o,a=e.shouldTrackEventResolver,s=null===(o=null===(i=null==r?void 0:r.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===o?void 0:o.call(i);if(!s)return!1;if(a)return a(n,r);if(!ro(e))return!1;var u=String(null==r?void 0:r.getAttribute("type"))||"";if("string"==typeof u)switch(u.toLowerCase()){case"hidden":case"password":return!1}if(t){var l=t.some(function(e){var t;return!!(null===(t=null==r?void 0:r.matches)||void 0===t?void 0:t.call(r,e))});if(!l)return!1}switch(s){case"input":case"select":case"textarea":return"change"===n||"click"===n;default:return"click"===n}}},oo=function(e){return e?e.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[]},ao=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},{})},so=function(){var e;try{var t=B(),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){}},uo=function(e,t,n){return void 0===n&&(n=eo),n.enabled?co(e,t,n.maxDepth):lo(e,t)},lo=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:lo(null==e?void 0:e.parentElement,t):null},co=function(e,t,n){var r,i;if(!e)return null;var o=function(e){if(t.some(function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))return{value:e}};try{for(var a=l(_i(e,n)),s=a.next();!s.done;s=a.next()){var u=o(s.value);if("object"==typeof u)return u.value}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return null},fo=function(e,t,n){return void 0===n&&(n=eo),n.enabled?po(e,t,n.maxDepth):vo(e,t)},vo=function(e,t){var n=[];return t?(e.querySelectorAll(t).forEach(function(e){return n.push(e)}),n):n},po=function(e,t,n){var r=vo(e,t),i=e instanceof Document?e.documentElement:e;return i?(Ii(i,n).forEach(function(e){e.root.querySelectorAll(t).forEach(function(e){return r.push(e)})}),r):r},ho=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};function go(e){if(!e)return"";try{var t=new URL(e);return t.search="",He(t.href)}catch(t){return He(e)}}function mo(e){var t,n;return void 0===e&&(e=B()),go(null!==(n=null===(t=null==e?void 0:e.location)||void 0===t?void 0:t.href)&&void 0!==n?n:"")}!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Zi||(Zi={}));var yo="__AMPLITUDE_VISUAL_TAGGING__";var bo=B(),wo=function(e){return e.get()},Eo={childList:!0,attributes:!0,characterData:!0,subtree:!0},So=function(e){return new Pn(e?function(t){var n,r=new WeakSet,i=new WeakMap,o=function(e,t){r.has(e)||(r.add(e),xi(e)&&i.set(e,t),s.observe(e,Eo))},a=function(e,t,n){var r=n-t;r<=0||Ii(e,r).forEach(function(e){var n=e.root,r=e.depth;return o(n,t+r)})},s=new MutationObserver(function(n){var r,o;t.next(n);try{var s=wo(e);if(!s.enabled)return;var u=function(e){var t=function(e){var t=e.getRootNode();if(!xi(t))return 0;var n=i.get(t);return null!=n?n:0}(e.target);e.addedNodes.forEach(function(e){e instanceof Element&&a(e,t,s.maxDepth)})};try{for(var c=l(n),d=c.next();!d.done;d=c.next()){u(d.value)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}catch(e){}});if(document.body){var u=document.body;o(u,0),n=e.onArm(function(e){a(u,0,e.maxDepth)})}return function(){null==n||n(),s.disconnect()}}: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()}})},ko=function(e){return void 0===e&&(e="click"),new Pn(function(t){var n,r=function(e){t.next(e)};return null===(n=B())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=B())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}})},To=function(){var e=In(new Pn(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=o(o({},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 bo.addEventListener("error",t),function(){bo.removeEventListener("error",t)}}),new Pn(function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return bo.addEventListener("unhandledrejection",t),function(){bo.removeEventListener("unhandledrejection",t)}}));return In(e,new Pn(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 _t.addListener("error",t),function(){_t.removeListener(t)}}))},xo=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}})},Po={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},_o=function(e){var t,n,r,i,o=Object.values(Po).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var u=s.value;try{try{for(var c=(r=void 0,l(u.definition)),d=c.next();!d.done;d=c.next()){var f=d.value,v=Po[f.event_type];v&&o[v].add(u.id)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==u?void 0:u.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},Io=function(e){var t,n,r,i,o=new Map;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var c=(r=void 0,l(u.conditions)),d=c.next();!d.done;d=c.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(u)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},Ao=function(e,t){return t.filter(function(t){return t.definition.some(function(t){return Po[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)})})})},Oo=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,a=new Set;try{for(var s=l(e),u=s.next();!u.done;u=s.next()){var c=u.value,d=t.get(c.id);if(d)try{for(var f=(i=void 0,l(d)),v=f.next();!v.done;v=f.next()){var p=v.value;a.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{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(a)}(Ao(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return r.labeledEvents[e]})),this.labeledEventToTriggerMap);try{for(var o=l(i),a=o.next();!a.done;a=o.next()){var s=a.value;xo(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.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}(),Co=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",bi,nn,wi]),Ro=["type"],Do=["svg","path","g"],Lo=["password","hidden"];function No(e,t,n){var r,i,a,s,u;if(void 0===n&&(n=eo),null===e)return null;var c=String(e.tagName).toLowerCase(),d={tag:c},f=Array.from(function(e,t){if(e.parentElement)return e.parentElement.children;var n=e.getRootNode();return t&&xi(n)?n.children:[]}(e,n.enabled));f.length&&(d.index=f.indexOf(e),d.indexOfType=f.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var v=null===(u=null===(s=e.previousElementSibling)||void 0===s?void 0:s.tagName)||void 0===u?void 0:u.toLowerCase();v&&(d.prevSib=String(v));var p=e.getAttribute("id");p&&(d.id=String(p));var h=Array.from(e.classList);h.length&&(d.classes=h);var g={},m=Array.from(e.attributes).filter(function(e){return!Co.has(e.name)}),y=!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!no.includes(i)&&!o}(e);if(!Lo.includes(String(e.getAttribute("type")))&&!Do.includes(c))try{for(var b=l(m),w=b.next();!w.done;w=b.next()){var E=w.value;y&&!Ro.includes(E.name)||(t.has(E.name)?g[E.name]=rn:g[E.name]=String(E.value).substring(0,128))}}catch(e){r={error:e}}finally{try{w&&!w.done&&(i=b.return)&&i.call(b)}finally{if(r)throw r.error}}return Object.keys(g).length&&(d.attrs=g),e.shadowRoot&&(d.attrs=o(o({},d.attrs||{}),((a={})[wi]="true",a)),d.shadow=!0),d}function Mo(e,t){return void 0===t&&(t=eo),e?t.enabled?function(e,t){var n,r,i=[];try{for(var o=l(_i(e,t)),a=o.next();!a.done;a=o.next()){var s=a.value;if("HTML"===s.tagName)break;i.push(s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}(e,t.maxDepth):function(e){var t=[];t.push(e);var n=e.parentElement;for(;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e):[]}var jo;var Uo=function(e,t){var n,r,i,a=this;this.replaceSensitiveString=function(e){return un(e,a.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,o,s=performance.now();if(!e)return[];for(var u=a.getShadowMode(),f=Mo(e,u),v=new Map,p=f.length-1;p>=0;p--){var h=f[p];if(h){var g=oo(h.getAttribute(bi)),m=p===f.length-1?[]:null!==(r=v.get(f[p+1]))&&void 0!==r?r:new Set,y=new Set(d(d([],c(m),!1),c(g),!1));v.set(h,y)}}o=f.map(function(e){var t;return No(e,null!==(t=v.get(e))&&void 0!==t?t:new Set,u)});var b=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]=a.replaceSensitiveString(i))})};try{for(var w=l(o),E=w.next();!E.done;E=w.next())b(E.value)}catch(e){t={error:e}}finally{try{E&&!E.done&&(n=w.return)&&n.call(w)}finally{if(t)throw t.error}}var S=performance.now();return null===(i=a.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",S-s),o},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?a.getText(t):a.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=a.selectorEngine.generate(e),i=performance.now();return null===(t=a.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.updateSelectorConfig=function(e,t){var n;if(null!=e){var r="boolean"==typeof e.enabled,i="boolean"==typeof e.shadowDomEnabled;if(r||i){var s=Fi(e,t),u=a.selectorEngine.getConfig().enabled,l=a.shadowGate.get().enabled,c=a.shadowGate.arm(function(e){var t,n=null!==(t=e.maxShadowDomDepth)&&void 0!==t?t:1;return!e.shadowDomEnabled||n<=0?eo:Object.freeze({enabled:!0,maxDepth:n})}(s));a.selectorEngine.updateConfig(o(o(o({},r?s:a.selectorEngine.getConfig()),{shadowDomEnabled:c.enabled}),c.enabled&&{maxShadowDomDepth:c.maxDepth})),r&&u!==s.enabled&&(null==t||t.debug(s.enabled?"@amplitude/element-selector: engine enabled — now emitting new element-selector element paths for autocapture events.":"@amplitude/element-selector: engine disabled — reverting to legacy cssPath for element paths.")),!l&&c.enabled&&(null===(n=a.diagnosticsClient)||void 0===n||n.setTag("plugin.autocapture.shadowDom","enabled:".concat(c.maxDepth)))}else null==t||t.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` or `shadowDomEnabled` flag — keeping current engine state.")}},this.getShadowMode=function(){return a.shadowGate.get()},this.getEventProperties=function(e,t,n){var r,i,o,s,u,l,d=null===(o=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===o?void 0:o.call(i),f="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},v=a.getHierarchy(t),p=null===(s=v[0])||void 0===s?void 0:s.attrs,h=a.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[vi]=d,r[pi]=a.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"]=a.getElementPath(t),r["[Amplitude] Element Parent Label"]=h,r[hi]=He(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=ln(a.replaceSensitiveString),r[gi]=window.innerHeight,r[mi]=window.innerWidth,r),y=so();if(y&&(m[yi]=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"]=a.replaceSensitiveString(b)}return ao(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 o=a.addTypeAndTimestamp(e,t);try{if(function(e){return"click"===e.type||"change"===e.type}(o)&&null!==o.event.target){var s=a.getShadowMode(),u=function(e,t){var n,r;if(void 0===t&&(t=eo),!t.enabled)return e.target;var i=null===(n=e.composedPath)||void 0===n?void 0:n.call(e),o=null!==(r=e.target)&&void 0!==r?r:null;if(!i||0===i.length)return o;var a=i[0];if(!(a instanceof Element))return null!=a?a:o;var s=Ai(a,t.maxDepth),u=s.segments;return s.truncated&&u.length>0?u[u.length-1].target:a}(o.event,s);if(i){var l=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}(u,o.type);if(l)return o.closestTrackedAncestor=u,o.targetElementProperties=a.getEventProperties(o.type,o.closestTrackedAncestor,r),o}var c=uo(u,n,s);c&&(o.closestTrackedAncestor=c,o.targetElementProperties=a.getEventProperties(o.type,c,r))}}catch(e){}return o},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?a.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(nn,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",o=Array.from(e.childNodes);try{for(var s=l(o),u=s.next();!u.done;u=s.next()){var c=u.value;c.nodeType!==Node.TEXT_NODE?c instanceof Element&&(c.hasAttribute(nn)||c.hasAttribute("contenteditable")?i+=rn:i+=a.getTextWithMaskedDescendants(c)):i+=c.textContent||""}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},this.hasMaskedAncestor=function(e){var t=a.getShadowMode();return t.enabled?function(e,t){var n,r;return!!Mo(e,t).some(function(e){return e.hasAttribute(nn)})||null!==(r=null===(n=document.documentElement)||void 0===n?void 0:n.hasAttribute(nn))&&void 0!==r&&r}(e,t):function(e){return null!==e.closest("[".concat(nn,"]"))}(e)},this.getText=function(e){if(a.hasMaskedAncestor(e))return rn;var t="";return t=e.querySelector("[".concat(nn,"], [contenteditable]"))?a.getTextWithMaskedDescendants(e):e.innerText||"",a.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),o=((t={})[vi]=i,t[pi]=a.getText(e),t[hi]=window.location.href.split("?")[0],t);return ao(o)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient,this.selectorEngine=(jo||(jo=Xi(Fi())),jo),this.shadowGate=(Qi||(Qi=to()),Qi);var s=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],u=[];try{for(var f=l(s),v=f.next();!v.done;v=f.next()){var p=v.value;if(u.length>=25)break;if(p instanceof RegExp)u.push(p);else if("pattern"in p&&"string"==typeof p.pattern)try{u.push(new RegExp(p.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=u};function Fo(e,t){var n=e.remoteConfigClient;if(e.fetchRemoteConfig&&n){var r=n.subscribe("configs.analyticsSDK.browserSDK.autocapture.elementSelector","all",function(n,r){e.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(r),") ").concat(JSON.stringify(n))),t.updateSelectorConfig(n,e.loggerProvider)});return function(){n.unsubscribe(r)}}}var qo,Bo=function(e,t){return("fixed"===t||"absolute"===t)&&e instanceof HTMLElement?e.offsetParent:function(e){var t;return e.assignedSlot||e.parentElement||(null===(t=e.parentNode)||void 0===t?void 0:t.host)||null}(e)};function Ho(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,a=new Map,s=new Map,u=new Set,l=function(e){var t=s.get(e);t&&(clearTimeout(t),s.set(e,null))},c=function(e){if(function(e){var t=B(),n=t.document.documentElement.clientHeight||t.innerHeight,r=t.document.documentElement.clientWidth||t.innerWidth,i=e.getBoundingClientRect(),o=i.top+.5*i.height,a=Math.max(i.left,0),s=Math.min(i.right,r);if(o<-1||o>n+1||a>=s||i.width<=0)return!1;for(var u=Bo(e,t.getComputedStyle(e).position);u;){var l=t.getComputedStyle(u),c=l.overflowY&&"visible"!==l.overflowY,d=l.overflowX&&"visible"!==l.overflowX;if(c||d){var f=u.getBoundingClientRect();if(c&&(o<f.top-1||o>f.bottom+1))return!1;if(d&&(a=Math.max(a,f.left))>=(s=Math.min(s,f.right)))return!1}u=Bo(u,l.position)}return!0}(e)){if(!a.get(e)&&!s.get(e)){var t=setTimeout(function(){a.set(e,!0);var t=r.getElementPath(e);n(t),s.set(e,null)},o);s.set(e,t)}}else l(e)},d=t.exposureObservable,f=t.scrollObservable,v=d.subscribe(function(e){var t=e,n=t.target;t.isIntersecting?(u.add(n),c(n)):(u.delete(n),l(n))}),p=f.subscribe(function(){u.forEach(c)}),h=function(){s.forEach(function(e){e&&clearTimeout(e)}),s.clear(),a.clear()};return{unsubscribe:function(){v.unsubscribe(),p.unsubscribe(),h(),u.clear()},reset:function(){h(),u.forEach(c)}}}function zo(e){var t,n,r,i,o,a=e.mutationObservable,s=e.onRescan,u=e.onFlush,l=e.exposureDuration,c=e.quietMs,d=void 0===c?150:c,f=e.maxWaitMs,v=void 0===f?4e3:f,p=!1,h=function(){t&&(clearTimeout(t),t=void 0),n&&(clearTimeout(n),n=void 0),r&&(clearTimeout(r),r=void 0)},g=function(){o&&(document.removeEventListener("DOMContentLoaded",o),o=void 0)},m=function(){p||("undefined"!=typeof document&&"loading"!==document.readyState?(p=!0,h(),g(),s(),r=setTimeout(function(){r=void 0,u()},l+50)):o||(o=function(){o=void 0,y()},document.addEventListener("DOMContentLoaded",o)))},y=function(){p||(t&&clearTimeout(t),t=setTimeout(m,d))},b=function(){h(),g(),p=!1,y(),n=setTimeout(m,v)};return{start:function(){i||(i=a.subscribe(function(){y()}),b())},reset:function(){b()},stop:function(){null==i||i.unsubscribe(),i=void 0,h(),g()}}}!function(e){e.ClickObservable="clickObservable",e.PointerDownObservable="pointerDownObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(qo||(qo={}));var Vo=function(e,t){var n,r,i,a,f,v,p,h,g,m,y,b;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",di);var w=e.dataAttributePrefix,E=void 0===w?At:w,S=e.visualTaggingOptions,k=void 0===S?{enabled:!0}:S;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:It,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:Ot,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0;var T=!1!==(null===(a=e.viewportContentUpdated)||void 0===a?void 0:a.enabled),x=null!==(p=null!==(v=null===(f=e.viewportContentUpdated)||void 0===f?void 0:f.exposureDuration)&&void 0!==v?v:e.exposureDuration)&&void 0!==p?p:150;e.viewportContentUpdated=o(o({},e.viewportContentUpdated),{exposureDuration:x}),e.pageUrlExcludelist=null===(h=e.pageUrlExcludelist)||void 0===h?void 0:h.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 P,_,I="@amplitude/plugin-autocapture-browser",A=[],O=new Uo(e,t),C=new Set,R=new Set,D=new Set,L=function(){var t,n,r=An(ko().map(function(t){return O.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,E)})),i=An(new Pn(function(t){var n,r=function(n){var r=O.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,E);t.next(r)};return null===(n=B())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=B())||void 0===e?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=An(new Pn(function(t){var n=function(n){var r=O.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,E);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=O.shadowGate,a=An(So(o).map(function(t){return O.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,E)})),s=new Pn(function(e){var t,n,r=function(t){e.next(t)};return null===(t=B())||void 0===t||t.addEventListener("scroll",r,{capture:!0,passive:!0}),null===(n=B())||void 0===n||n.addEventListener("resize",r,{passive:!0}),function(){var e,t;null===(e=B())||void 0===e||e.removeEventListener("scroll",r,{capture:!0}),null===(t=B())||void 0===t||t.removeEventListener("resize",r)}}),u=function(e,t,n,r){var i="function"==typeof n?n:void 0,o="function"==typeof n?r:n;return new Pn(function(n){var r=B();if(!(null==r?void 0:r.IntersectionObserver))return function(){};var a=new IntersectionObserver(function(e){e.forEach(function(e){n.next(e)})},{root:null,rootMargin:"0px",threshold:0}),s=t.join(","),u=function(e){e instanceof Element&&e.matches(s)&&a.observe(e),e.querySelectorAll(s).forEach(function(e){a.observe(e)})},l=function(e){if(o)try{fo(e,s,wo(o)).forEach(function(e){a.observe(e)})}catch(e){}},c=function(){var e=null==r?void 0:r.document;if(e){var t=[];try{t=o&&wo(o).enabled?fo(e,s,wo(o)):e.querySelectorAll(s)}catch(e){return}Array.from(t).forEach(function(e){a.unobserve(e),a.observe(e)})}};null==i||i(c),c();var d=null==o?void 0:o.onArm(function(){(null==r?void 0:r.document)&&l(r.document)}),f=e.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){if(e instanceof DocumentFragment)u(e);else if(e instanceof Element)if(o&&wo(o).enabled){try{e.matches(s)&&a.observe(e)}catch(e){}l(e)}else u(e)})})});return function(){null==i||i(void 0),null==d||d(),f.unsubscribe(),a.disconnect()}})}(a,e.cssSelectorAllowlist,function(e){_=e},o);return(t={})[qo.ChangeObservable]=i,t[qo.ClickObservable]=r,t[qo.MutationObservable]=a,t[qo.NavigateObservable]=n,t[qo.ScrollObservable]=s,t[qo.ExposureObservable]=u,t},N=_o(Object.values(null!==(m=null===(g=e.pageActions)||void 0===g?void 0:g.labeledEvents)&&void 0!==m?m:{})),M=Io(null!==(b=null===(y=e.pageActions)||void 0===y?void 0:y.triggers)&&void 0!==b?b:[]),j=function(e,t,n,r){return new Oo(e,t,n,r)}(N,M,O,e);return{name:I,type:"enrichment",setup:function(t,n){return s(void 0,void 0,void 0,function(){var r,i,a,s,l,f,v,p,h,g,m,y,b,w,S,U,F,q,H,z,V,W,$,K,G,J,Y;return u(this,function(u){return"undefined"==typeof document||(r=!1,t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(t){!function(t){var n,r;t&&(e.pageActions=o(o({},e.pageActions),t),N=_o(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),M=Io(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),j.update(N,M,e))}(t)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),(i=Fo(t,O))&&A.push({unsubscribe:i}),a=io(e,e.cssSelectorAllowlist),s=io(e,e.actionClickAllowlist),l=L(),f=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(ho).filter(function(e){return r("click",e.closestTrackedAncestor)}).map(function(e){return i(e)}).subscribe(function(e){null==t||t.track(fi,e.targetElementProperties)})}({allObservables:l,amplitude:n,shouldTrackEvent:a,evaluateTriggers:j.evaluate.bind(j)}),A.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(ho).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:l,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return O.getEventProperties.apply(O,d(d([],c(e),!1),[E],!1))},amplitude:n,shouldTrackEvent:a,evaluateTriggers:j.evaluate.bind(j)}),A.push(v),p=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,a=e.shouldTrackActionClick,s=n.clickObservable,u=n.mutationObservable,l=n.navigateObservable,c=s.filter(function(e){return!o("click",e.closestTrackedAncestor)}).map(function(e){var t=uo(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e}).filter(ho).filter(function(e){return a("click",e.closestTrackedAncestor)}),d=l?In(u,l):u,f=In(c,d),v=null,p=null;return _n(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(fi,i("click",e.closestTrackedAncestor)))})}({allObservables:l,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return O.getEventProperties.apply(O,d(d([],c(e),!1),[E],!1))},amplitude:n,shouldTrackEvent:a,shouldTrackActionClick:s}),p&&A.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=B(),a=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),s=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,a),n.maxY=Math.max(n.maxY,s)});return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:l,amplitude:n}),A.push(h),g=o({},h.getState()),m={},y=B(),w=function(e){e&&(null==b||b.reset()),e&&r||(e&&(r=!0,setTimeout(function(){r=!1},100)),function(e){var t,n,r,i=e.amplitude,o=e.scrollTracker,a=e.currentElementExposed,s=e.elementExposedForPage,u=e.elementExposedInSentEvents,l=e.exposureTracker,c=e.isPageEnd,d=e.lastScroll,f=o.getState(),v=B(),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=Array.from(a).filter(function(e){return!u.has(e)}),m=((t={})[hi]=mo(v),t["[Amplitude] Max Page X"]=f.maxX+p,t["[Amplitude] Max Page Y"]=f.maxY+h,t[gi]=h,t[mi]=p,t["[Amplitude] Element Exposed"]=g,t),y=so();y&&(m[yi]=y);var b=function(){o.reset();var e=o.getState();d.maxX=e.maxX,d.maxY=e.maxY,s.clear(),u.clear(),null==l||l.reset()};0!==g.length||f.maxX!==d.maxX||f.maxY!==d.maxY?(null==i||i.track("[Amplitude] Viewport Content Updated",m),d.maxX=f.maxX,d.maxY=f.maxY,g.forEach(function(e){u.add(e)}),a.clear(),c&&b()):c&&b()}({amplitude:n,scrollTracker:h,currentElementExposed:D,elementExposedForPage:C,elementExposedInSentEvents:R,exposureTracker:m.exposure,isPageEnd:e,lastScroll:g}))},S=mo(y),U=function(){var e=mo(y);e!==S&&(S=e,w(!0))},F=function(e,t){var n=mo(y),r=function(e,t){var n;if(void 0===t&&(t=B()),null==e||""===e)return mo(t);var r=(null===(n=null==t?void 0:t.location)||void 0===n?void 0:n.href)||"http://localhost/";try{return go(new URL(e,r).href)}catch(e){return mo(t)}}(t,y);n!==r?(S=r,w(!0),e()):e()},q=function(e){!function(e,t,n,r,i){if(!t.has(e)&&!n.has(e)){t.add(e),r.add(e);var o=Array.from(r);JSON.stringify(o).length>=18e3&&i(!1)}}(e,C,R,D,w)},T&&(m.exposure=Ho({allObservables:l,onExposure:q,dataExtractor:O,exposureDuration:x}),m.exposure&&A.push(m.exposure),b=zo({mutationObservable:l[qo.MutationObservable],onRescan:function(){var e,n;null===(n=null===(e=t.loggerProvider)||void 0===e?void 0:e.debug)||void 0===n||n.call(e,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — rescanning DOM"),null==_||_()},onFlush:function(){var e,n;null===(n=null===(e=t.loggerProvider)||void 0===e?void 0:e.debug)||void 0===n||n.call(e,"@amplitude/plugin-autocapture-browser: initial exposure snapshot — flushing viewport content updated"),w(!1)},exposureDuration:x}),b.start(),A.push({unsubscribe:function(){null==b||b.stop()}}),H=function(){w(!0)},null==y||y.addEventListener("beforeunload",H),P=function(){null==y||y.removeEventListener("beforeunload",H)},A.push({unsubscribe:function(){return P()}}),(z=l[qo.NavigateObservable])?A.push(z.subscribe(function(e){var t,n,r=null===(n=null===(t=e.event)||void 0===t?void 0:t.destination)||void 0===n?void 0:n.url;if(r){var i=go(r);if(i===S)return;return S=i,void w(!0)}U()})):y&&(V=function(){U()},y.addEventListener("popstate",V),W=y.history.pushState,$=y.history.replaceState,y.history&&W&&(y.history.pushState=new Proxy(W,{apply:function(e,t,n){F(function(){e.apply(t,n)},n[2])}})),y.history&&$&&(y.history.replaceState=new Proxy($,{apply:function(e,t,n){F(function(){e.apply(t,n)},n[2])}})),A.push({unsubscribe:function(){y.removeEventListener("popstate",V),y.history&&W&&(y.history.pushState=W),y.history&&$&&(y.history.replaceState=$)}}))),null===(Y=null==t?void 0:t.loggerProvider)||void 0===Y||Y.log("".concat(I," has been successfully added.")),window.opener&&k.enabled&&(K=e.cssSelectorAllowlist,G=e.actionClickAllowlist,function(e,t){var n=e;if(!0!==n[yo]){n[yo]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,a=t.actionClickAllowlist,s=null,u=function(t){e.notify({action:"element-selected",data:t})},l=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var n;s=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:l,onSelect:u,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:a,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:di}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null===(e=null==s?void 0:s.close)||void 0===e||e.call(s)})}}(J=Mn(),{dataExtractor:O,isElementSelectable:io(e,d(d([],c(K),!1),c(G),!1)),cssSelectorAllowlist:K,actionClickAllowlist:G}),function(e,t){var n,r=e;if(!0!==r[jn]){r[jn]=!0;var i=null!==(n=null==t?void 0:t.scriptUrl)&&void 0!==n?n:"https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",o=null,a=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){var t,n;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Initializing background capture (external script)");var r=new URL(i,e.endpoint).toString();e.loadScriptOnce(r).then(function(){var t,n,r;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),o=null===(r=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===r?void 0:r.call(window,{messenger:e,onBackgroundCapture:a}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null===(e=null==o?void 0:o.close)||void 0===e||e.call(o),o=null})}}(J),J.setup(o({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:Rn[t.serverZone]})))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,r;return u(this,function(i){try{for(e=l(A),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]})})}}},Wo=["mutation","navigate"];function $o(e,t){var n,r,i,o,a=t.event,s=a.pageX,u=a.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:s,s),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:s,s),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Ko(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:o({"[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 Go(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.pointerDownObservable,a=r.selectionObservable,l=[],c={},d=null;function f(e){l=[],c={},e&&($o(c,e),l.push(e))}var v=_n(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return s(t,void 0,void 0,function(){var t;return u(this,function(n){return $o(c,e),t=null,0===l.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(l,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(l,e)||c.isOutOfBounds?(d&&(t=Ko(l)),f(e)):l.push(e),d&&(clearTimeout(d.timerId),d.resolve(t),d=null),l.length>=4?[2,new Promise(function(e){d={resolve:e,timerId:setTimeout(function(){e(Ko(l))},1e3)}})]:[2,null]})})}),p=null==a?void 0:a.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()}}}var Jo,Yo;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}(Jo||(Jo={})),function(e){e.X="x",e.Y="y"}(Yo||(Yo={}));function Xo(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Qo(e){e.changes=[],e.startTime=void 0}function Zo(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var ea=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new Pn(function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},a=void 0,s=null;function u(){void 0!==a&&(e.next(a),a=void 0,null!==s&&clearTimeout(s),Qo(n),Qo(i))}return t.subscribe(function(e){null!==s&&clearTimeout(s),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Yo.X?n:i);var t=function(e,t){var n=void 0;if(Xo(e)&&(n=e.startTime),Xo(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(a=a||t,s=setTimeout(function(){u(),s=null},o)):u(),Zo(n),Zo(i),function(){null!==s&&(clearTimeout(s),s=null)}})})},ta=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,a=e.thresholdMs,s=void 0===a?2e3:a,u=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new Pn(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===Jo.DECREASING&&e.next(Yo.X),r=Jo.INCREASING):o.x<n.x&&(r===Jo.INCREASING&&e.next(Yo.X),r=Jo.DECREASING),o.y>n.y?(i===Jo.DECREASING&&e.next(Yo.Y),i=Jo.INCREASING):o.y<n.y&&(i===Jo.INCREASING&&e.next(Yo.Y),i=Jo.DECREASING),n=o):n=o})})}({allWindowObservables:r});return ea({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:s}).subscribe(function(e){ro(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function na(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 ra=4e3,ia=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var a=!1!==e.deadClicks&&null!==e.deadClicks,f=!1!==e.rageClicks&&null!==e.rageClicks,v=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(v=!1);var p=na(e,"rageClicks",Lt,f),h=na(e,"deadClicks",Rt,a),g=na(e,"errorClicks",Dt,i),m=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:At,y=new Uo(e),b=d([],c(new Set(d(d(d([],c(p),!1),c(h),!1),c(g),!1))),!1),w=function(){var e,t,n=function(e){return An(ko(e).map(function(e){return y.addAdditionalEventProperties(e,"click",b,m,!0)}))},r=n("click"),i=n("pointerdown"),a=An(To().map(function(e){return y.addTypeAndTimestamp(e,"error")})),s=An(So(y.shadowGate).map(function(e){return y.addAdditionalEventProperties(e,"mutation",b,m)}));window.navigation&&(t=An(new Pn(function(e){var t=function(t){e.next(o(o({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return y.addAdditionalEventProperties(e,"navigate",b,m)})));var u=An(new Pn(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)}})),l=An(new Pn(function(e){var t=function(t){e.next(t)},n={capture:!0};return bo.document.addEventListener("mousemove",t,n),function(){bo.document.removeEventListener("mousemove",t,n)}}));return(e={})[qo.ClickObservable]=r,e[qo.PointerDownObservable]=i,e[qo.MutationObservable]=s,e[qo.NavigateObservable]=t,e[qo.BrowserErrorObservable]=a,e[qo.SelectionObservable]=u,e[qo.MouseMoveObservable]=l,e};return{name:n,type:"enrichment",setup:function(t,l){return s(void 0,void 0,void 0,function(){var s,c,d,b,E,S,k,T,x,P,_,I;return u(this,function(u){return"undefined"==typeof document||(s=w(),(c=Fo(t,y))&&r.push({unsubscribe:c}),f&&(d=io(e,p),b=Go({allObservables:s,amplitude:l,shouldTrackRageClick:d}),r.push(b)),a&&(E=io(e,h),S=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,a=n.clickObservable,s=n.mutationObservable,u=n.navigateObservable,l=a.filter(function(e){return ho(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Zi.LEFT_OR_TOUCH_CONTACT}),c=u?In(s,u):s,d=In(l,c),f=null;return _n(d,function(e){return f&&Wo.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",o(o({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}})}({amplitude:l,allObservables:s,getEventProperties:function(e,t){return y.getEventProperties(e,t,m)},shouldTrackDeadClick:E}),r.push(S)),i&&(k=io(e,g),T=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.pointerDownObservable,a=n.browserErrorObservable,s=i.filter(function(e){return ho(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Zi.LEFT_OR_TOUCH_CONTACT}),u=null,l=null,c=function(){null!==u&&(clearTimeout(u),u=null),l=null};return In(s,a).subscribe(function(e){var n;if("click"===e.type)return c(),l=e,void(u=setTimeout(c,2e3));"error"===e.type&&l&&(t.track("[Amplitude] Error Click",o(((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),l.targetElementProperties)),c())})}({amplitude:l,allObservables:s,shouldTrackErrorClick:k}),r.push(T)),v&&(x=void 0,P=void 0,"object"==typeof e.thrashedCursor&&(x=e.thrashedCursor.directionChanges,P=e.thrashedCursor.threshold,x&&x<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(x," is below the minimum of ").concat(5,", setting to ").concat(5)),x=5),P&&P>ra&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(P," is above the maximum of ").concat(ra,", setting to ").concat(ra)),P=ra)),_=ta({amplitude:l,options:e,allObservables:s,directionChanges:x,thresholdMs:P}),r.push(_)),null===(I=null==t?void 0:t.loggerProvider)||void 0===I||I.log("".concat(n," has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,n,i;return u(this,function(o){try{for(e=l(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]})})}}};function oa(e,t){var n=e.startTime+e.duration;return t.filter(function(t){return t.startTime<n&&t.startTime+t.duration>e.startTime}).map(function(e){return e.name})}function aa(e,t){var n,r=oa(e,t),i=null!==(n=e.scripts)&&void 0!==n?n:[],a=i.map(function(e){return e.sourceURL}).filter(Boolean),s=i.map(function(e){return e.sourceFunctionName}).filter(Boolean),u=i.map(function(e){return e.sourceCharPosition}).filter(function(e){return"number"==typeof e&&e>=0}),l=i.map(function(e){return e.invokerType}).filter(Boolean),c=i.map(function(e){return e.invoker}).filter(Boolean);return o(o(o(o(o(o(o({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.blockingDuration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),{"[Amplitude] Main Thread Block Render Start":e.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":e.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),a.length>0&&{"[Amplitude] Main Thread Block Script URLs":a}),s.length>0&&{"[Amplitude] Main Thread Block Script Functions":s}),u.length>0&&{"[Amplitude] Main Thread Block Script Positions":u}),l.length>0&&{"[Amplitude] Main Thread Block Invoker Types":l}),c.length>0&&{"[Amplitude] Main Thread Block Invokers":c})}function sa(e,t){var n,r=oa(e,t),i=null!==(n=e.attribution)&&void 0!==n?n:[];return o(o({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.duration,"[Amplitude] Main Thread Block Start Time":e.startTime},r.length>0&&{"[Amplitude] Main Thread Block Measures":r}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(e){return e.name})})}function ua(e){var t=e.amplitude,n=e.options,r=e.durationThreshold,i=void 0===r?100:r,o=function(){if("undefined"==typeof PerformanceObserver)return null;try{var e=PerformanceObserver.supportedEntryTypes;if(e.includes("long-animation-frame"))return"long-animation-frame";if(e.includes("longtask"))return"longtask"}catch(e){}return null}();if(!o)return{unsubscribe:function(){}};var a=[],s=new PerformanceObserver(function(e){var t,n,r=performance.now();try{for(var i=l(e.getEntries()),o=i.next();!o.done;o=i.next()){var s=o.value;a.push(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}for(var u=r-1e4;a.length>0&&a[0].startTime<u;)a.shift()});try{s.observe({entryTypes:["measure"]})}catch(e){}var u=new PerformanceObserver(function(e){var r,s;try{for(var u=l(e.getEntries()),c=u.next();!c.done;c=u.next()){var d=c.value;if(!ro(n))return;if(!(d.duration<i)){var f="long-animation-frame"===o?aa(d,a):sa(d,a);t.track("[Amplitude] Main Thread Block",f)}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}});try{u.observe({entryTypes:[o]})}catch(e){return s.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){u.disconnect(),s.disconnect()}}}var la,ca,da=function(e){void 0===e&&(e={});var t="@amplitude/plugin-performance-browser",n=[],r=!0===e.mainThreadBlock||"object"==typeof e.mainThreadBlock&&null!==e.mainThreadBlock;return{name:t,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var a,s,l;return u(this,function(u){return"undefined"==typeof document||(r&&(a=100,"object"==typeof e.mainThreadBlock&&void 0!==e.mainThreadBlock.durationThreshold&&(a=e.mainThreadBlock.durationThreshold),s=ua({amplitude:o,options:e,durationThreshold:a}),n.push(s)),null===(l=null==i?void 0:i.loggerProvider)||void 0===l||l.log("".concat(t," performance tracking has been successfully added."))),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t,r,i;return u(this,function(o){try{for(e=l(n),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]})})}}},fa="[Amplitude] Network Request",va="500-599";function pa(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function ha(e,t){var n,r,i=t.split(",");try{for(var o=l(i),a=o.next();!a.done;a=o.next()){var s=c(a.value.split("-").map(Number),2),u=s[0],d=s[1];if(e===u&&void 0===d)return!0;if(e>=u&&e<=d)return!0}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function ga(e){var t;if(e)try{var n=null===(t=B())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),a=r.href,s=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:r.href,host:s}}catch(t){try{return function(e){var t,n=e.indexOf("#"),r=n>=0?e.slice(n+1):"",i=n>=0?e.slice(0,n):e,o=i.indexOf("?"),a=o>=0?i.slice(o+1):"",s=o>=0?i.slice(0,o):i,u=s.match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i);return{query:a,fragment:r,href:e,hrefWithoutQueryOrHash:s,host:null!==(t=null==u?void 0:u[1])&&void 0!==t?t:""}}(e)}catch(e){return}}}function ma(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return d([],c(R),!1);if(void 0===e){return}}}function ya(e){var t,n,r;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)&&!(null===(r=null==e?void 0:e.excludelist)||void 0===r?void 0:r.length)}function ba(e,t){var n;void 0===t&&(t={});var r=ga(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(pa(o,"*.amplitude.com")||pa(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find(function(e){return pa(o,e)}))return!1;if(!t.captureRules&&void 0!==e.status&&!ha(e.status,va))return!1;if(t.captureRules&&(d([],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 pa(t,e)}))&&(!r||!e.urls||Be(r,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return!((n||0===n)&&!ha(n,e.statusCodeRange||va))}(t,o,e.status,e.url,e.method),i){var n=ma(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var a=ma(t.requestHeaders);if(e.requestWrapper&&a){var s=e.requestWrapper.headers(a);s&&(e.requestHeaders=s)}if(e.responseWrapper&&t.responseBody&&!ya(t.responseBody)){var u=t.responseBody.excludelist||t.responseBody.blocklist;e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,u)}if(e.requestWrapper&&t.requestBody&&!ya(t.requestBody)){u=t.requestBody.excludelist||t.requestBody.blocklist;e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,u)}}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===fa}))return!0}catch(e){}return!1}(o,e.requestWrapper)}function wa(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter(function(e){return ba(e.event,n)}).subscribe(function(e){var t,n,o,a=e.event,l=ga(a.url);if(l){var d=null===(n=a.responseWrapper)||void 0===n?void 0:n.bodySize,f=null===(o=a.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){s(this,void 0,void 0,function(){var i,o,a;return u(this,function(s){switch(s.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,[s.sent(),2]),o=i[0],a=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(a)try{e["[Amplitude] Response Body"]=JSON.stringify(a)}catch(e){null==r||r.debug("Failed to stringify response body")}s.label=2;case 2:return null==n||n.track(fa,e),[2]}})})}(((t={})["[Amplitude] URL"]=l.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=l.query,t["[Amplitude] URL Fragment"]=l.fragment,t["[Amplitude] Request Method"]=a.method,t["[Amplitude] Status Code"]=a.status,t["[Amplitude] Start Time"]=a.startTime,t["[Amplitude] Completion Time"]=a.endTime,t["[Amplitude] Duration"]=a.duration,t["[Amplitude] Request Body Size"]=f,t["[Amplitude] Response Body Size"]=d,t["[Amplitude] Request Type"]=a.type,t["[Amplitude] Request Headers"]=a.requestHeaders,t["[Amplitude] Response Headers"]=a.responseHeaders,t),a,r,i)}})}!function(e){e.NetworkObservable="networkObservable"}(la||(la={}));var Ea=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new Pn(function(e){var n=new Xt(function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)});return en.subscribe(n,t),function(){en.unsubscribe(n)}});return(e={})[la.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var a;return u(this,function(s){return"undefined"!=typeof document||function(){var e,t=B();return"ReactNative"===(null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.product)}()?(a=r(),t=null==i?void 0:i.loggerProvider,ca=wa({allObservables:a,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added.")),[2]):[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return ca.unsubscribe(),[2]})})}}};let Sa=-1;const ka=e=>{addEventListener("pageshow",t=>{t.persisted&&(Sa=t.timeStamp,e(t))},!0)},Ta=(e,t,n,r)=>{let i,o;return a=>{t.value>=0&&(a||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)))}},xa=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},Pa=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},_a=()=>{const e=Pa();return e?.activationStart??0},Ia=(e,t=-1)=>{const n=Pa();let r="navigate";return Sa>=0?r="back-forward-cache":n&&(document.prerendering||_a()>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}},Aa=new WeakMap;function Oa(e,t){return Aa.get(e)||Aa.set(e,new t),Aa.get(e)}class Ca{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 Ra=(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{}},Da=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let La=-1;const Na=new Set,Ma=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,ja=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of Na)e();isFinite(La)||(La="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",ja,!0))}},Ua=()=>{if(La<0){const e=_a(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime;La=t??Ma(),addEventListener("visibilitychange",ja,!0),addEventListener("prerenderingchange",ja,!0),ka(()=>{setTimeout(()=>{La=Ma()})})}return{get firstHiddenTime(){return La},onHidden(e){Na.add(e)}}},Fa=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},qa=[1800,3e3],Ba=(e,t={})=>{Fa(()=>{const n=Ua();let r,i=Ia("FCP");const o=Ra("paint",e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-_a(),0),i.entries.push(t),r(!0)))});o&&(r=Ta(e,i,qa,t.reportAllChanges),ka(n=>{i=Ia("FCP"),r=Ta(e,i,qa,t.reportAllChanges),xa(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Ha=[.1,.25];let za=0,Va=1/0,Wa=0;const $a=e=>{for(const t of e)t.interactionId&&(Va=Math.min(Va,t.interactionId),Wa=Math.max(Wa,t.interactionId),za=Wa?(Wa-Va)/7+1:0)};let Ka;const Ga=()=>Ka?za:performance.interactionCount??0;let Ja=0;class Ya{u=[];l=new Map;m;p;v(){Ja=Ga(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((Ga()-Ja)/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 Xa=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=Da(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},Qa=[200,500],Za=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=Ua();Fa(()=>{"interactionCount"in performance||Ka||(Ka=Ra("event",$a,{type:"event",buffered:!0,durationThreshold:0}));let r,i=Ia("INP");const o=Oa(t,Ya),a=e=>{Xa(()=>{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())})},s=Ra("event",a,{durationThreshold:t.durationThreshold??40});r=Ta(e,i,Qa,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{a(s.takeRecords()),r(!0)}),ka(()=>{o.v(),i=Ia("INP"),r=Ta(e,i,Qa,t.reportAllChanges)}))})};class es{m;h(e){this.m?.(e)}}const ts=[2500,4e3],ns=[800,1800],rs=e=>{document.prerendering?Fa(()=>rs(e)):"complete"!==document.readyState?addEventListener("load",()=>rs(e),!0):setTimeout(e)};function is(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function os(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(is(e)),navigationStart:Math.floor(performance.timeOrigin)}}var as,ss=function(){var e=null,t=B(),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,a;return u(this,function(s){return void 0===n||(o=He((null==r?void 0:r.href)||"",t.loggerProvider),a={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":He((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":He(o.split("?")[0],t.loggerProvider)},((e,t={})=>{Fa(()=>{const n=Ua();let r,i=Ia("LCP");const o=Oa(t,es),a=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-_a(),0),i.entries=[t],r())},s=Ra("largest-contentful-paint",a);if(s){r=Ta(e,i,ts,t.reportAllChanges);const n=Da(()=>{a(s.takeRecords()),s.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(Xa(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});ka(n=>{i=Ia("LCP"),r=Ta(e,i,ts,t.reportAllChanges),xa(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(function(e){a["[Amplitude] LCP"]=os(e)}),Ba(function(e){a["[Amplitude] FCP"]=os(e)}),Za(function(e){a["[Amplitude] INP"]=os(e)}),((e,t={})=>{const n=Ua();Ba(Da(()=>{let r,i=Ia("CLS",0);const o=Oa(t,Ca),a=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},s=Ra("layout-shift",a);s&&(r=Ta(e,i,Ha,t.reportAllChanges),n.onHidden(()=>{a(s.takeRecords()),r(!0)}),ka(()=>{o.i=0,i=Ia("CLS",0),r=Ta(e,i,Ha,t.reportAllChanges),xa(()=>r())}),setTimeout(r))}))})(function(e){a["[Amplitude] CLS"]=os(e)}),((e,t={})=>{let n=Ia("TTFB"),r=Ta(e,n,ns,t.reportAllChanges);rs(()=>{const i=Pa();i&&(n.value=Math.max(i.responseStart-_a(),0),n.entries=[i],r(!0),ka(()=>{n=Ia("TTFB",0),r=Ta(e,n,ns,t.reportAllChanges),r(!0)}))})})(function(e){a["[Amplitude] TTFB"]=os(e)}),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},us=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=o({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=(null===(n=t.cookieOptions)||void 0===n?void 0:n.domain)||t.topLevelDomain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[]),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=Je(t.apiKey,"MKTG"),this.webExpStorageKey=Je(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=C,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return s(this,void 0,void 0,function(){var e,t;return u(this,function(n){switch(n.label){case 0:return this.options.optOut?[2]:[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||Me(this.sessionTimeout,this.lastEventTime),Br(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(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 u(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 tn).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,a=(t=this.currentCampaign,n=this.options,r=o(o({},C),t),i=Object.entries(r).reduce(function(e,t){var r,i=c(t,2),o=i[0],a=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=a?a:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),a?e.set(o,a):e.unset(o)},new M),Z(i));return e&&(a.event_id=e),a},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),ls=new Set([i.IDENTIFY,i.GROUP_IDENTIFY]),cs=function(e){var t;void 0===e&&(e={});var n,r,i,a,l,c,d=null!==(t=e.fallbackAttributionEvent)&&void 0!==t&&t,f=B(),v={},p=!1,h=!1,g=function(){return s(void 0,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return[4,(new tn).parse()];case 1:return e=t.sent(),v=Ve(e),d&&(null==r||r.log("Tracking attribution fallback event."),null==n||n.track("[Amplitude] Attribution",v)),[2]}})})},m=function(){g()},y=function(e){return new Proxy(e,{apply:function(e,t,n){Reflect.apply(e,t,n),p&&m()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){return u(this,function(o){switch(o.label){case 0:return n=t,r=e.loggerProvider,p=!0,r.log("Installing event property attribution tracking."),[4,g()];case 1:if(o.sent(),!f)return[2];if(f.addEventListener("popstate",m),!h){if(i=Reflect.get(f.history,"pushState"),a=Reflect.get(f.history,"replaceState"),!i||!a)return[2];l=y(i),f.history.pushState=l,c=y(a),f.history.replaceState=c,h=!0}return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){return u(this,function(t){return ls.has(e.event_type)||(e.event_properties=o(o({},v),e.event_properties)),[2,e]})})},teardown:function(){return s(void 0,void 0,void 0,function(){var e,t;return u(this,function(n){return f&&(f.removeEventListener("popstate",m),e=Reflect.get(f.history,"pushState"),t=Reflect.get(f.history,"replaceState"),h&&e===l&&i&&(f.history.pushState=i),h&&t===c&&a&&(f.history.replaceState=a)),p=!1,h=!1,i=void 0,a=void 0,l=void 0,c=void 0,v={},[2]})})}}},ds="AMP_CURRENT_PAGE",fs="AMP_PREVIOUS_PAGE",vs="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(as||(as={}));var ps=new Set([i.IDENTIFY,i.GROUP_IDENTIFY,i.REVENUE]),hs=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=B(),i=void 0,a=!1,l=void 0,d=!1,f=!1,v=function(e){var t;try{var n=He(e,l);t=new URL(n).hostname}catch(e){null==l||l.error("Could not parse URL: ",e)}return t},p=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?v(e):void 0;if(!r)return as.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?as.Internal:as.External},h=function(){return s(void 0,void 0,void 0,function(){var e,t,n,r,o;return u(this,function(s){switch(s.label){case 0:return i&&a?[4,i.get(vs)]:[3,3];case 1:return e=s.sent(),t=He("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[ds])||"",r=void 0,r=t===n?(null==e?void 0:e[fs])||"":n||(document.referrer||""),[4,i.set(vs,(o={},o[ds]=t,o[fs]=r,o))];case 2:s.sent(),s.label=3;case 3:return[2]}})})},g=function(){h()},m={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return s(void 0,void 0,void 0,function(){var t,n,o,s,p,m,y,b;return u(this,function(u){switch(u.label){case 0:if((l=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),f=!0,!r)return[3,7];try{i=new Ye(r.sessionStorage)}catch(e){null==l||l.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:return a=null!==(b=u.sent())&&void 0!==b&&b,i&&a?(t="undefined"!=typeof document&&document.referrer||"",n=t?v(t):void 0,o="undefined"!=typeof location&&location.hostname||"",s=He("undefined"!=typeof location&&location.href||""),[4,i.get(vs)]):[3,6];case 2:return p=u.sent(),m=(null==p?void 0:p[ds])||"",!!n&&n!==o&&m!==s?[4,i.set(vs,(y={},y[ds]=s,y[fs]=t,y))]:[3,4];case 3:return u.sent(),[3,6];case 4:return[4,h()];case 5:u.sent(),u.label=6;case 6:r.addEventListener("popstate",g),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],a=r[2];e.apply(t,[i,o,a]),f&&g()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=c(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),f&&g()}}),d=!0),u.label=7;case 7:return[2]}})})},execute:function(e){return s(void 0,void 0,void 0,function(){var t,n,r;return u(this,function(s){switch(s.label){case 0:return t=He("undefined"!=typeof location&&location.href||""),i&&a?[4,i.get(vs)]:[3,2];case 1:if(n=s.sent(),r=(null==n?void 0:n[fs])||"",ps.has(e.event_type))return[2,e];e.event_properties=o(o({},e.event_properties||{}),{"[Amplitude] Page Domain":gs(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":gs(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":gs(e,"[Amplitude] Page Path","undefined"!=typeof location&&He(location.pathname)||""),"[Amplitude] Page Title":gs(e,"[Amplitude] Page Title",ln(un)),"[Amplitude] Page URL":gs(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":r,"[Amplitude] Previous Page Type":p(r)}),s.label=2;case 2:return[2,e]}})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",g),f=!1),i&&a?[4,i.set(vs,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}};return m};function gs(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var ms=function(){var e,t,n;function r(t){if(t)try{var n=new Function("return "+t)();if("function"==typeof n)return n;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}var i={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,function(){var o,a;return u(this,function(s){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null===(a=i.remoteConfig)||void 0===a?void 0:a.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(e){n=e&&function(e){return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body}(e)?r(e.body||""):r("")}),t=function(){var e;return null===(e=i.remoteConfigClient)||void 0===e?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(t){return s(void 0,void 0,void 0,function(){var r;return u(this,function(i){if(n)try{return[2,null!==(r=n(t))&&void 0!==r?r:null]}catch(n){return null==e||e.error("Could not execute custom enrichment function",n),[2,t]}return[2,t]})})},teardown:function(){return s(void 0,void 0,void 0,function(){return u(this,function(e){return t&&t(),[2]})})}};return i},ys="userProperty",bs="eventProperty",ws=function(e){return e===ys||e===bs},Es=[ys,bs],Ss=function(e,t){return function(e){var t=d([],c(new Set((Array.isArray(e)?e:[e]).filter(ws))),!1);return t.length>0?t:d([],c(Es),!1)}(e.trackingMethod).includes(t)},ks=function(e){return Ss(e,ys)},Ts=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return n(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),ee(this._init(o(o({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,l,c,d,f,v;return s(this,void 0,void 0,function(){var p,h,g,m,y,b,w,E,S,k,T,x,P,_,I,A=this;return u(this,function(O){switch(O.label){case 0:return this.initializing?[2]:(this.initializing=!0,p=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),h=null!==(n=t.loggerProvider)&&void 0!==n?n:new oe,t.loggerProvider||h.enable(null!==(r=t.logLevel)&&void 0!==r?r:re.Warn),g=null!==(i=t.serverZone)&&void 0!==i?i:Ur,y=this._diagnosticsSampleRate,b=null===(l=t.enableDiagnostics)||void 0===l||l,p?(m=new wt(t.apiKey,h,g,null===(c=t.remoteConfig)||void 0===c?void 0:c.serverUrl),[4,new Promise(function(e){null==m||m.subscribe("configs.diagnostics.browserSDK","all",function(t,n,r){if(h.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(y=i);var o=t.enabled;"boolean"==typeof o&&(b=o)}e()})})]):[3,2]);case 1:O.sent(),O.label=2;case 2:return(w=new ft(t.apiKey,h,g,{enabled:b,sampleRate:y})).setTag("library","".concat(cr,"/").concat(lr)),w.setTag("platform","Web"),w.setTag("web_environment",function(){var e=B();if(!e)return"unknown";var t=function(e){var t,n;return"string"==typeof(null===(n=null===(t=e.chrome)||void 0===t?void 0:t.runtime)||void 0===n?void 0:n.id)}(e);return function(e){var t=e.ServiceWorkerGlobalScope;return"function"==typeof t&&e instanceof t}(e)?t?"chrome_extension_service_worker":"service_worker":function(e){var t=e.WorkerGlobalScope;return"function"==typeof t&&e instanceof t}(e)?"web_worker":function(e){return void 0!==e.document}(e)?t?"chrome_extension":"browser":function(e){var t,n;return"string"==typeof(null===(n=null===(t=e.process)||void 0===t?void 0:t.versions)||void 0===n?void 0:n.node)}(e)?"node":"unknown"}()),"undefined"!=typeof navigator&&w.setTag("user_agent",navigator.userAgent),[4,Jr(t.apiKey,t,this,w,{loggerProvider:h,serverZone:g,enableDiagnostics:b,diagnosticsSampleRate:y})];case 3:return E=O.sent(),p&&m?[4,new Promise(function(e){null==m||m.subscribe("configs.analyticsSDK.browserSDK","all",function(t,n,r){E.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&ci(t,E),e()})})]:[3,5];case 4:O.sent(),O.label=5;case 5:return[4,e.prototype._init.call(this,E)];case 6:return O.sent(),this.logBrowserOptions(E),this.config.remoteConfigClient=m,D=this.config,S=Gn(D.defaultTracking)&&D.defaultTracking&&"object"==typeof D.defaultTracking&&D.defaultTracking.attribution&&"object"==typeof D.defaultTracking.attribution?o({},D.defaultTracking.attribution):{},Gn(this.config.defaultTracking)&&ks(S)?(this.config.optOut&&this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e?[3,2]:(this.webAttribution=new us(S,this.config),[4,this.webAttribution.init()]);case 1:t.sent(),t.label=2;case 2:return[2]}})})}),this.webAttribution=new us(S,this.config),[4,this.webAttribution.init()]):[3,8];case 7:O.sent(),O.label=8;case 8:return k=Fe(),T=k.ampTimestamp?Number(k.ampTimestamp):void 0,x=!T||Date.now()<T,P=x&&!Number.isNaN(Number(k.ampSessionId))?Number(k.ampSessionId):void 0,-1!==(_=this.config.deferredSessionId)||this.config.optOut||(_=Date.now()),this.setSessionId(null!==(v=null!==(f=null!==(d=t.sessionId)&&void 0!==d?d:P)&&void 0!==f?f:_)&&void 0!==v?v:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),(I=Le(this.config.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(li()).promise];case 9:O.sent(),O.label=10;case 10:return[4,this.add(new Ee({diagnosticsClient:w})).promise];case 11:return O.sent(),[4,this.add(new dr).promise];case 12:return O.sent(),[4,this.add(new Ne).promise];case 13:return O.sent(),function(e){ui||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."),ui=!0)}(this.config),R=this.config.defaultTracking,Kn(R,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(si()).promise]):[3,15];case 14:O.sent(),O.label=15;case 15:return Jn(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(ii()).promise]):[3,17];case 16:O.sent(),O.label=17;case 17:return Yn(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(ei(or(this.config))).promise]):[3,20];case 18:return O.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return s(A,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(ei(or(this.config))).promise]);case 1:return t.sent(),[2]}})})}),O.label=20;case 20:return Gn(this.config.defaultTracking)&&function(e){return Ss(e,bs)}(S)?(this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(cs(S)).promise]):[3,22];case 21:O.sent(),O.label=22;case 22:return Zn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Vo(nr(this.config),{diagnosticsClient:w})).promise]):[3,24];case 23:O.sent(),O.label=24;case 24:return er(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(ia(rr(this.config))).promise]):[3,26];case 25:O.sent(),O.label=26;case 26:return Qn(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(Ea(ir(this.config))).promise]):[3,28];case 27:O.sent(),O.label=28;case 28: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(ss()).promise]):[3,30];case 29:O.sent(),O.label=30;case 30:return function(e){return"object"==typeof e&&(!0===e.performanceTracking||"object"==typeof e.performanceTracking)}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(da(tr(this.config))).promise]):[3,32];case 31:O.sent(),O.label=32;case 32:return function(e){return Kn(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(hs()).promise]):[3,34];case 33:O.sent(),O.label=34;case 34:return("boolean"==typeof(C=this.config.customEnrichment)?C:"object"==typeof C&&null!==C&&!1!==C.enabled)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(ms()).promise]):[3,36];case 35:O.sent(),O.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return O.sent(),I.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},n=t.time,r=a(t,["time"]),i="number"==typeof n?{time:n}:void 0;A.track(e.eventType,r,i)}),[2]}var C,R,D})})},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.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){Le(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.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){Le(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(z()),this.setUserId(void 0),this.timeline.onReset()},t.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}},t.prototype.setIdentity=function(e){var t,n,r;if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var i=new M,o=null!==(r=e.userProperties)&&void 0!==r?r:{};try{for(var a=l(Object.entries(o)),s=a.next();!s.done;s=a.next()){var u=c(s.value,2),d=u[0],f=u[1];i.set(d,f)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),ee(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,ee(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return ee(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,Xn(this.config.defaultTracking)&&(r&&i&&n.push(this.track(Ir,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 a=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Z(this.config.identify)).promise),Xn(this.config.defaultTracking)&&n.push(this.track(_r,void 0,{event_id:a?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,ee(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Xr(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(ur(t)){var r=t._q;t._q=[],t=sr(new M,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)},t.prototype.groupIdentify=function(t,n,r,i){if(ur(r)){var o=r._q;r._q=[],r=sr(new M,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(ur(t)){var r=t._q;t._q=[],t=sr(new ne,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!ks(this.webAttribution.options))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},t.prototype.process=function(t){return s(this,void 0,void 0,function(){var n,r,i;return u(this,function(o){return n=Date.now(),r=Me(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===_r||t.event_type===Ir||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},t.prototype.logBrowserOptions=function(e){try{var t=o(o({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",X(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t}(te),xs=function(){var e=new Ts;return{init:me(e.init.bind(e),"init",pe(e),ge(e,["config"])),add:me(e.add.bind(e),"add",pe(e),ge(e,["config.apiKey","timeline.plugins"])),remove:me(e.remove.bind(e),"remove",pe(e),ge(e,["config.apiKey","timeline.plugins"])),track:me(e.track.bind(e),"track",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),logEvent:me(e.logEvent.bind(e),"logEvent",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),identify:me(e.identify.bind(e),"identify",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),groupIdentify:me(e.groupIdentify.bind(e),"groupIdentify",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),setGroup:me(e.setGroup.bind(e),"setGroup",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),revenue:me(e.revenue.bind(e),"revenue",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),flush:me(e.flush.bind(e),"flush",pe(e),ge(e,["config.apiKey","timeline.queue.length"])),getUserId:me(e.getUserId.bind(e),"getUserId",pe(e),ge(e,["config","config.userId"])),setUserId:me(e.setUserId.bind(e),"setUserId",pe(e),ge(e,["config","config.userId"])),getDeviceId:me(e.getDeviceId.bind(e),"getDeviceId",pe(e),ge(e,["config","config.deviceId"])),setDeviceId:me(e.setDeviceId.bind(e),"setDeviceId",pe(e),ge(e,["config","config.deviceId"])),reset:me(e.reset.bind(e),"reset",pe(e),ge(e,["config","config.userId","config.deviceId"])),getSessionId:me(e.getSessionId.bind(e),"getSessionId",pe(e),ge(e,["config"])),setSessionId:me(e.setSessionId.bind(e),"setSessionId",pe(e),ge(e,["config"])),extendSession:me(e.extendSession.bind(e),"extendSession",pe(e),ge(e,["config"])),setOptOut:me(e.setOptOut.bind(e),"setOptOut",pe(e),ge(e,["config"])),setTransport:me(e.setTransport.bind(e),"setTransport",pe(e),ge(e,["config"])),getIdentity:me(e.getIdentity.bind(e),"getIdentity",pe(e),ge(e,["config"])),setIdentity:me(e.setIdentity.bind(e),"setIdentity",pe(e),ge(e,["config","config.userId","config.deviceId"])),getOptOut:me(e.getOptOut.bind(e),"getOptOut",pe(e),ge(e,["config"])),_setDiagnosticsSampleRate:me(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",pe(e),ge(e,["config"]))}},Ps=xs(),_s=new Set(["playing","waiting"]),Is=new Set(["last_position","percent_completed","stop_reason"]);var As=function(){function e(e){this.amplitude=e,this.videoEl=null,this.embeddedVideoPlayer=null,this.extraEventProperties={},this.stopEvent=null,this.listeners=[],this.onRemoveListeners=[],this.playId=null,this.playStartTime=null,this.heartbeat=function(e,t){var n=ke.get(e);if(n)return n;var r=new Se(e,6e4,36e5,t);return ke.set(e,r),r}(this.amplitude)}return e.prototype.withVideoElement=function(e){return this.videoEl=e,this},e.prototype.withEmbeddedPlayer=function(e){return this.embeddedVideoPlayer=e,this},e.prototype.withVendor=function(e){return this.vendor=e,this},e.prototype.withExtraEventProperties=function(e){return this.extraEventProperties=e,this},e.prototype.captureVideoStarted=function(){var e=this;return this.listeners.push(function(t,n){var r,i;if(!_s.has(t.playbackState)&&"playing"===n.playbackState){e.playId=z(),e.playStartTime=null!==(i=null===(r=n.lastEvent)||void 0===r?void 0:r.start_time)&&void 0!==i?i:0;var a=(new Date).getTime(),s={insert_id:z(),event_type:xr,time:a,event_properties:o(o(o({},e.parseStartEventProperties(n)),e.extraEventProperties),{play_id:e.playId})};e.stopEvent=o(o({},s),{insert_id:z(),event_type:Pr,time:a+1,event_properties:o(o(o({},e.parseStopEventProperties(n)),e.extraEventProperties),{stop_reason:"timeout",play_id:e.playId})}),e.heartbeat.trackNoDelay(s).catch(e.stop.bind(e)),e.heartbeat.track(e.stopEvent).catch(e.stop.bind(e))}}),this},e.prototype.captureVideoStopped=function(){var e=this;return this.listeners.push(function(t,n){e.stopEvent&&(e.stopEvent.event_properties=o(o(o({},e.stopEvent.event_properties),e.parseStopEventProperties(n)),e.extraEventProperties),e.stopEvent.time=(new Date).getTime(),e.heartbeat.update(e.stopEvent)),_s.has(t.playbackState)&&!_s.has(n.playbackState)&&e.flushStopEvent(n.playbackState)}),this},e.prototype.flushStopEvent=function(e){var t=this.stopEvent;t&&(this.stopEvent=null,this.playStartTime=null,t.event_properties=o(o({},t.event_properties),{stop_reason:e}),this.heartbeat.trackNoDelay(t).catch(this.stop.bind(this)))},e.prototype.start=function(){var e,t=this,n=null!==(e=this.videoEl)&&void 0!==e?e:this.embeddedVideoPlayer;if(!n)throw new Error("Video element not specified. Use withVideoElement() or withEmbeddedPlayer() to specify the video element.");if(this.videoEl&&this.embeddedVideoPlayer)throw new Error("Both video element and embedded video player specified. Use only one of withVideoElement() or withEmbeddedPlayer() to specify the video element.");var r=new Vn({videoEl:n,onStateChange:function(e,n){t.listeners.forEach(function(t){return t(e,n)})},vendor:this.vendor,isEmbedded:!!this.embeddedVideoPlayer});return this.onRemoveListeners.push(function(){r.destroy()}),this},e.prototype.stop=function(){this.onRemoveListeners.forEach(function(e){return e()}),this.onRemoveListeners=[],this.flushStopEvent("untracked")},e.prototype.parseStartEventProperties=function(e){var t,n,r,i,a;return o(o({},function(e){var t,n,r={};try{for(var i=l(Object.entries(null!=e?e:{})),o=i.next();!o.done;o=i.next()){var a=c(o.value,2),s=a[0],u=a[1];Is.has(s)||null==u||(r[s]=u)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r}(e.lastEvent)),{duration:null!==(n=null===(t=e.lastEvent)||void 0===t?void 0:t.duration)&&void 0!==n?n:0,start_time:null!==(i=null===(r=e.lastEvent)||void 0===r?void 0:r.start_time)&&void 0!==i?i:0,position:null!==(a=e.position)&&void 0!==a?a:0,delivery_mode:this.getDeliveryMode()})},e.prototype.getDeliveryMode=function(){return this.videoEl instanceof HTMLAudioElement?"audio":"video"},e.prototype.parseStopEventProperties=function(e){var t,n,r,i,a,s,u;return o(o(o({},this.parseStartEventProperties(e)),{start_time:null!==(r=null!==(t=this.playStartTime)&&void 0!==t?t:null===(n=e.lastEvent)||void 0===n?void 0:n.start_time)&&void 0!==r?r:0,watch_duration:null!==(i=e.watchTime)&&void 0!==i?i:0,percent_completed:Os(null!==(a=e.position)&&void 0!==a?a:0,null!==(u=null===(s=e.lastEvent)||void 0===s?void 0:s.duration)&&void 0!==u?u:0)}),e.errorMessage?{error_message:e.errorMessage}:{})},e}();function Os(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.min(100,Math.max(0,e/t*100))}var Cs=Ps.add,Rs=Ps.extendSession,Ds=Ps.flush,Ls=Ps.getDeviceId,Ns=Ps.getIdentity,Ms=Ps.getOptOut,js=Ps.getSessionId,Us=Ps.getUserId,Fs=Ps.groupIdentify,qs=Ps.identify,Bs=Ps.init,Hs=Ps.logEvent,zs=Ps.remove,Vs=Ps.reset,Ws=Ps.revenue,$s=Ps.setDeviceId,Ks=Ps.setGroup,Gs=Ps.setIdentity,Js=Ps.setOptOut,Ys=Ps.setSessionId,Xs=Ps.setTransport,Qs=Ps.setUserId,Zs=Ps.track,eu=Ps._setDiagnosticsSampleRate,tu=Object.freeze({__proto__:null,add:Cs,extendSession:Rs,flush:Ds,getDeviceId:Ls,getIdentity:Ns,getOptOut:Ms,getSessionId:js,getUserId:Us,groupIdentify:Fs,identify:qs,init:Bs,logEvent:Hs,remove:zs,reset:Vs,revenue:Ws,setDeviceId:$s,setGroup:Ks,setIdentity:Gs,setOptOut:Js,setSessionId:Ys,setTransport:Xs,setUserId:Qs,track:Zs,_setDiagnosticsSampleRate:eu,createInstance:xs,AmplitudeBrowser:Ts,runQueuedFunctions:ar,Revenue:ne,Identify:M,trackVideo:function(e,t,n){var r;void 0===n&&(n={});var i=new As(e);t instanceof HTMLMediaElement?i.withVideoElement(t):i.withEmbeddedPlayer(t),n.vendor&&i.withVendor(n.vendor);var a=null!==(r=n.extraEventProperties)&&void 0!==r?r:{};try{i.withExtraEventProperties(o({view_session_id:z()},a)).captureVideoStarted().captureVideoStopped().start()}catch(e){return e}return function(){return i.stop()}},Types:Fr});!function(e){if(e.scriptUrl){var t=st(e.scriptUrl);t&&function(e){var t=B();if(t){var n=ot();n.includes(e)||(n.push(e),t[it]=n)}}(t)}}({scriptUrl:function(){if("undefined"==typeof document)return;var e=document.currentScript;if(null==e?void 0:e.src)return e.src;return}()}),function(){var e=B();if(e){var t=function(e){var t=xs(),n=B();return n&&n.amplitude&&n.amplitude._iq&&e&&(n.amplitude._iq[e]=t),t};if(e.amplitude=Object.assign(e.amplitude||{},tu,{createInstance:t}),e.amplitude.invoked){var n=e.amplitude._q;e.amplitude._q=[],ar(tu,n);for(var r=Object.keys(e.amplitude._iq)||[],i=0;i<r.length;i++){var o=r[i],a=Object.assign(e.amplitude._iq[o],t(o)),s=a._q;a._q=[],ar(a,s)}}}else console.error("[Amplitude] Error: GlobalScope is not defined")}()}();
2
2
  //# sourceMappingURL=amplitude-min.js.map