(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,427968,(e,t,n)=>{var r=Object.prototype.hasOwnProperty;function i(e){return"[Throws: "+(e?e.message:"?")+"]"}function o(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 o=e(n.toJSON());return t.pop(),o}catch(e){return i(e)}if(Array.isArray(n)){var s=n.map(e);return t.pop(),s}var a=Object.keys(n).reduce(function(t,o){return t[o]=e(function(e,t){if(r.call(e,t))try{return e[t]}catch(e){return i(e)}return e[t]}(n,o)),t},{});return t.pop(),a}(e)}t.exports=function(e,t,n){return JSON.stringify(o(e),t,n)},t.exports.ensureProperties=o},14919,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Observable=void 0;let r=e=>!!Symbol[e],i=e=>r(e)?Symbol[e]:"@@"+e,o=i("iterator"),s=i("observable"),a=i("species");function u(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw TypeError(n+" is not a function");return n}}function l(e){let t=e.constructor;return void 0!==t&&null===(t=t[a])&&(t=void 0),void 0!==t?t:m}function c(e){c.log?c.log(e):setTimeout(()=>{throw e})}function d(e){Promise.resolve().then(()=>{try{e()}catch(e){c(e)}})}function f(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=u(t,"unsubscribe");e&&e.call(t)}}catch(e){c(e)}}function g(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function h(e,t,n){e._state="running";let r=e._observer;try{let i=u(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(g(e),i)i.call(r,n);else throw n;break;case"complete":g(e),i&&i.call(r)}}catch(e){c(e)}"closed"===e._state?f(e):"running"===e._state&&(e._state="ready")}function p(e,t,n){if("closed"!==e._state){if("buffering"===e._state)return void e._queue.push({type:t,value:n});if("ready"!==e._state){e._state="buffering",e._queue=[{type:t,value:n}],d(()=>(function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n{if("function"!=typeof e)return void n(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 TypeError(e+" is not a function");return new(l(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 TypeError(e+" is not a function");return new(l(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 TypeError(e+" is not a function");let t=l(this),n=arguments.length>1,r=!1,i=arguments[1],o=i;return new t(t=>this.subscribe({next(i){let s=!r;if(r=!0,!s||n)try{o=e(o,i)}catch(e){return t.error(e)}else o=i},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(TypeError("Cannot reduce an empty sequence"));t.next(o),t.complete()}}))}async all(){let e=[];return await this.forEach(t=>e.push(t)),e}concat(){for(var e=arguments.length,t=Array(e),n=0;n{let n,i=0;return!function o(s){n=s.subscribe({next(t){e.next(t)},error(t){e.error(t)},complete(){i===t.length?(n=void 0,e.complete()):o(r.from(t[i++]))}})}(this),()=>{n&&(n.unsubscribe(),n=void 0)}})}flatMap(e){if("function"!=typeof e)throw TypeError(e+" is not a function");let t=l(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 s=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(s);e>=0&&r.splice(e,1),o()}});r.push(s)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach(e=>e.unsubscribe()),i.unsubscribe()}})}[s](){return this}static from(e){let t="function"==typeof this?this:m;if(null==e)throw TypeError(e+" is not an object");let n=u(e,s);if(n){let r=n.call(e);if(Object(r)!==r)throw TypeError(r+" is not an object");return r instanceof m&&r.constructor===t?r:new t(e=>r.subscribe(e))}if(r("iterator")&&(n=u(e,o)))return new t(t=>{d(()=>{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=>{d(()=>{if(!t.closed){for(let n=0;n{d(()=>{if(!e.closed){for(let n=0;n{t.exports=e.r(14919).Observable},512006,19259,759730,e=>{"use strict";let t;var n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,T,I,C,P,O,R,x,A,D,L,M,N,U,q,j,F,B,H,W,z,G,K,V,J,$,Y,X,Q=e.i(824627);(n=O||(O={}))[n.None=0]="None",n[n.Error=1]="Error",n[n.Warn=2]="Warn",n[n.Verbose=3]="Verbose",n[n.Debug=4]="Debug";var Z=function(e){return void 0===e&&(e=0),(Error().stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},ee=function(e){return function(){var t=(0,Q.__assign)({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},et=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=(0,Q.__values)(t.split(".")),o=i.next();!o.done;o=i.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},en=function(e,t){return function(){var n,r,i={};try{for(var o=(0,Q.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=et(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},er=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s1e3)return!1;for(var t in e){var n=e[t];if(!eT(t,n))return!1}return!0},eT=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=(0,Q.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)i=i&&ek(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else if(null==t)return!1;else if("object"==typeof t)return ek(t);else if(!["number","string","boolean"].includes(typeof t))return!1;return!0},eI=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return(0,Q.__assign)({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(A.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(A.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(A.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(A.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(A.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(A.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(A.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(A.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(A.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[A.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[A.CLEAR_ALL]||this._propertySet.has(t))&&(e===A.ADD?"number"==typeof n:e===A.UNSET||e===A.REMOVE||eT(t,n))},e}();(o=A||(A={})).SET="$set",o.SET_ONCE="$setOnce",o.ADD="$add",o.APPEND="$append",o.PREPEND="$prepend",o.REMOVE="$remove",o.PREINSERT="$preInsert",o.POSTINSERT="$postInsert",o.UNSET="$unset",o.CLEAR_ALL="$clearAll";var eC=[A.CLEAR_ALL,A.UNSET,A.SET,A.SET_ONCE,A.ADD,A.APPEND,A.PREPEND,A.PREINSERT,A.POSTINSERT,A.REMOVE];e.s(["Identify",()=>eI,"OrderedIdentifyOperations",()=>eC],19259),(s=D||(D={})).Unknown="unknown",s.Skipped="skipped",s.Success="success",s.RateLimit="rate_limit",s.PayloadTooLarge="payload_too_large",s.Invalid="invalid",s.Failed="failed",s.Timeout="Timeout",s.SystemError="SystemError";var eP=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=D.Unknown),{event:e,code:t,message:n}},eO=e.i(751818),eR=(0,Q.__spreadArray)([],(0,Q.__read)(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),ex=function(e){var t,n=(0,eO.getGlobalScope)();if(!(null==(t=null==n?void 0:n.crypto)?void 0:t.getRandomValues))return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,ex);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(0,Q.__spreadArray)([],(0,Q.__read)(r.entries()),!1).map(function(e){var t=(0,Q.__read)(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(eR[r]):eR[r]}).join("")},eA=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(i){switch(i.label){case 0:if(this.plugins.some(function(t){return t.name===e.name}))return this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2];return void 0===e.name&&(e.name=ex(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!=(n=e.type)?n:"enrichment",[4,null==(r=e.setup)?void 0:r.call(e,t,this.client)];case 1:return i.sent(),this.plugins.push(e),[2]}})})},e.prototype.deregister=function(e,t){var n;return(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i;return(0,Q.__generator)(this,function(o){switch(o.label){case 0:if(-1===(r=this.plugins.findIndex(function(t){return t.name===e})))return t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2];return i=this.plugins[r],this.plugins.splice(r,1),[4,null==(n=i.teardown)?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.call(e)}),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(n){t.queue.push([e,n]),t.scheduleApply(0)})},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout(function(){t.apply(t.queue.shift()).then(function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)})},e))},e.prototype.apply=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s,a,u,l,c,d,f,g,h,p;return(0,Q.__generator)(this,function(v){switch(v.label){case 0:if(!e)return[2];t=(0,Q.__read)(e,1)[0],n=(0,Q.__read)(e,2)[1],this.loggerProvider.log("Timeline.apply: Initial event",t),r=this.plugins.filter(function(e){return"before"===e.type}),v.label=1;case 1:v.trys.push([1,6,7,8]),o=(i=(0,Q.__values)(r)).next(),v.label=2;case 2:if(o.done)return[3,5];if(!(s=o.value).execute)return[3,4];return[4,s.execute((0,Q.__assign)({},t))];case 3:if(null===(a=v.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),n({event:t,code:0,message:""}),[2];t=a,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),v.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f={error:v.sent()},[3,8];case 7:try{o&&!o.done&&(g=i.return)&&g.call(i)}finally{if(f)throw f.error}return[7];case 8:u=this.plugins.filter(function(e){return"enrichment"===e.type||void 0===e.type}),v.label=9;case 9:v.trys.push([9,14,15,16]),c=(l=(0,Q.__values)(u)).next(),v.label=10;case 10:if(c.done)return[3,13];if(!(s=c.value).execute)return[3,12];return[4,s.execute((0,Q.__assign)({},t))];case 11:if(null===(a=v.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),n({event:t,code:0,message:""}),[2];t=a,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(s.name),"', event: ").concat(JSON.stringify(t))),v.label=12;case 12:return c=l.next(),[3,10];case 13:return[3,16];case 14:return h={error:v.sent()},[3,16];case 15:try{c&&!c.done&&(p=l.return)&&p.call(l)}finally{if(h)throw h.error}return[7];case 16:return d=this.plugins.filter(function(e){return"destination"===e.type}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(t))),Promise.all(d.map(function(e){var n=(0,Q.__assign)({},t);return e.execute(n).catch(function(e){return eP(n,0,String(e))})})).then(function(e){var r=(0,Q.__read)(e,1)[0]||eP(t,100,"Event not tracked, no destination plugins on the instance");n(r)}),[2]}})})},e.prototype.flush=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return t.apply(e)}))];case 1:return n.sent(),[4,Promise.all(this.plugins.filter(function(e){return"destination"===e.type}).map(function(e){return e.flush&&e.flush()}))];case 2:return n.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)||n.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var n;null==(n=t.onSessionIdChanged)||n.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var n;null==(n=t.onOptOutChanged)||n.call(t,e)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=(t=(0,Q.__values)(this._optOutListeners)).next(),a.label=1;case 1:if(n.done)return[3,6];r=n.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,r(e)];case 3:return a.sent(),[3,5];case 4:return i=a.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={error:a.sent()},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},e.prototype.onReset=function(){this.plugins.forEach(function(e){var t;null==(t=e.onReset)||t.call(e)})},e}(),eD=function(e,t){return(0,Q.__assign)((0,Q.__assign)({},t),{event_type:x.IDENTIFY,user_properties:e.getUserProperties()})},eL=function(e,t,n,r){var i;return(0,Q.__assign)((0,Q.__assign)({},r),{event_type:x.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:((i={})[e]=t,i)})},eM=function(e,t,n){var r,i=new eI;return i.set(e,t),(0,Q.__assign)((0,Q.__assign)({},n),{event_type:x.IDENTIFY,user_properties:i.getUserProperties(),groups:((r={})[e]=t,r)})},eN=function(e){return{promise:e||Promise.resolve()}},eU=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 eA(this),this.name=e}return e.prototype._init=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}})})},e.prototype.runQueuedFunctions=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:t=this[e],this[e]=[],a.label=1;case 1:a.trys.push([1,8,9,10]),r=(n=(0,Q.__values)(t)).next(),a.label=2;case 2:if(r.done)return[3,7];if(!((i=(0,r.value)())&&"promise"in i))return[3,4];return[4,i.promise];case 3:return a.sent(),[3,6];case 4:return[4,i];case 5:a.sent(),a.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return o={error:a.sent()},[3,10];case 9:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}return[7];case 10:if(!this[e].length)return[3,12];return[4,this.runQueuedFunctions(e)];case 11:a.sent(),a.label=12;case 12:return[2]}})})},e.prototype.track=function(e,t,n){var r=(0,Q.__assign)((0,Q.__assign)((0,Q.__assign)({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t});return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),eN(this.dispatch(r))},e.prototype.identify=function(e,t){var n=eD(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),eN(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=eL(e,t,n,r);return eN(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=eM(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),eN(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=(0,Q.__assign)((0,Q.__assign)({},t),{event_type:x.REVENUE,event_properties:e.getEventProperties()});return eN(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),eN())},e.prototype._addPlugin=function(e){return eN(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)),eN())},e.prototype._removePlugin=function(e){return eN(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(eP(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,Q.__generator)(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)?t:{},r=(0,Q.__assign)({},n);if(void 0===e)return r;var i={};return Object.keys(e).forEach(function(t){Object.values(R).includes(t)||(i[t]=e[t])}),eC.forEach(function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case R.CLEAR_ALL:Object.keys(r).forEach(function(e){delete r[e]});break;case R.UNSET:Object.keys(n).forEach(function(e){delete r[e]});break;case R.SET:Object.assign(r,n)}}}),Object.assign(r,i),r},e.prototype.process=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),this.config.optOut)return[2,eP(e,0,"Event skipped due to optOut config")];return e.event_type===x.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)];case 1:return 200===(t=r.sent()).code?this.config.loggerProvider.log(t.message):100===t.code?this.config.loggerProvider.warn(t.message):this.config.loggerProvider.error(t.message),[2,t];case 2:return n=String(r.sent()),this.config.loggerProvider.error(n),[2,t=eP(e,0,n)];case 3:return[2]}})})},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,!!e))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=!!e,this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return eN(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find(function(t){return t.name===e});return void 0===t?void this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e)):t},e.prototype.plugins=function(e){return this.timeline.plugins.filter(function(t){return t instanceof e})},e}(),eq=function(e,t){var n=Math.max(t,1);return e.reduce(function(e,t,r){var i=Math.floor(r/n);return e[i]||(e[i]=[]),e[i].push(t),e},[])},ej="Amplitude Logger ",eF=function(){function e(){this.logLevel=O.None}return e.prototype.disable=function(){this.logLevel=O.None},e.prototype.enable=function(e){void 0===e&&(e=O.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t=200&&e<300}var eK=new Set([es,ea,eu,el]);function eV(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var eJ=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r=this;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(ei,"_").concat(this.config.apiKey.substring(0,10)),[4,null==(t=this.config.storageProvider)?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=ex()),new Promise(function(n){t.queue.push({event:e,attempts:0,callback:function(e){return n(e)},timeout:0}),t.schedule(t.config.flushIntervalMillis),t.saveEvents()})},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter(function(e){return e.attempts+=1,e.attemptsthis.scheduledTimeout)){this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,this.scheduleId=setTimeout(function(){t.queue=t.queue.map(function(e){return e.timeout=0,e}),t.flush(!0)},e);return}},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r=this;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:if(this.config.offline)return this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2];if(this.flushId)return this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2];return this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):n.push(e)}),[4,eq(t,this.config.flushQueueSize).reduce(function(t,n){return(0,Q.__awaiter)(r,void 0,void 0,function(){return(0,Q.__generator)(this,function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}})})},Promise.resolve())];case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a;return(0,Q.__generator)(this,function(u){var l,c,d;switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map(function(e){var t=e.event;return t.extra,(0,Q.__rest)(t,["extra"])}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new ez,u.label=1;case 1:return u.trys.push([1,3,,4]),l=i=eW(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,void 0===(c=this.config.enableRequestBodyCompression)&&(c=!1),o=!!eK.has(l)||c,[4,this.config.transportProvider.send(i,r,this.config._enableRequestBodyCompressionExperimental&&o)];case 2:if(null===(s=u.sent()))return this.fulfillRequest(e,0,"Unexpected error occurred"),[2];if(!t)return"body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(eV(s))):this.fulfillRequest(e,s.statusCode,s.status),[2];return this.handleResponse(s,e),[3,4];case 3:return a=(d=u.sent())instanceof Error?d.message:String(d),this.config.loggerProvider.error(a),null==(n=this.diagnosticsClient)||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:a,stack_trace:Z()}),this.handleResponse({status:D.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},e.prototype.handleResponse=function(e,t){eG(e.statusCode)||null==(n=this.diagnosticsClient)||n.recordEvent("analytics.events.unsuccessful",{events:t.map(function(e){return e.event.event_type}),code:e.statusCode,status:e.status,body:eV(e),stack_trace:Z()});var n,r=e.status;switch(r){case D.Success:this.handleSuccessResponse(e,t);break;case D.Invalid:this.handleInvalidResponse(e,t);break;case D.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case D.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))return void this.fulfillRequest(t,e.statusCode,e.body.error);var r=new Set((0,Q.__spreadArray)((0,Q.__spreadArray)((0,Q.__spreadArray)((0,Q.__spreadArray)([],(0,Q.__read)(Object.values(e.body.eventsWithInvalidFields)),!1),(0,Q.__read)(Object.values(e.body.eventsWithMissingFields)),!1),(0,Q.__read)(Object.values(e.body.eventsWithInvalidIdLengths)),!1),(0,Q.__read)(e.body.silencedEvents),!1).flat()),i=t.filter(function(t,i){return!r.has(i)||void n.fulfillRequest([t],e.statusCode,e.body.error)});i.length>0&&this.config.loggerProvider.warn(eV(e));var o=this.removeEventsExceedFlushMaxRetries(i);this.scheduleEvents(o)},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1===t.length)return void this.fulfillRequest(t,e.statusCode,e.body.error);this.config.loggerProvider.warn(eV(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),a=new Set(i),u=new Set(o),l=t.filter(function(t,r){return t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)?void n.fulfillRequest([t],e.statusCode,e.body.error):(u.has(r)&&(t.timeout=n.throttleTimeout),!0)});l.length>0&&this.config.loggerProvider.warn(eV(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;eG(t)?null==(o=this.diagnosticsClient)||o.increment("analytics.events.sent",e.length):(null==(r=this.diagnosticsClient)||r.increment("analytics.events.dropped",e.length),null==(i=this.diagnosticsClient)||i.recordEvent("analytics.events.dropped",{events:e.map(function(e){return e.event.event_type}),code:t,message:n,stack_trace:Z()})),this.removeEvents(e),e.forEach(function(e){return e.callback(eP(e.event,t,n))})},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(e){return e.event});this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(t){return!e.some(function(e){return e.event.insert_id===t.event.insert_id})}),this.saveEvents()},e}(),e$=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){return ek(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?(0,Q.__assign)({},this.properties):{};return e[L.REVENUE_PRODUCT_ID]=this.productId,e[L.REVENUE_QUANTITY]=this.quantity,e[L.REVENUE_PRICE]=this.price,e[L.REVENUE_TYPE]=this.revenueType,e[L.REVENUE_CURRENCY]=this.currency,e[L.REVENUE]=this.revenue,e[L.RECEIPT]=this.receipt,e[L.RECEIPT_SIG]=this.receiptSig,e},e}();(a=L||(L={})).REVENUE_PRODUCT_ID="$productId",a.REVENUE_QUANTITY="$quantity",a.REVENUE_PRICE="$price",a.REVENUE_TYPE="$revenueType",a.REVENUE_CURRENCY="$currency",a.REVENUE="$revenue",a.RECEIPT="$receipt",a.RECEIPT_SIG="$receiptSig";var eY=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:eX(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),eX=function(){return"u">typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},eQ=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}(),eZ=function(){return(eZ=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function e1(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var e2=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=e0(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next())if(s.value===i)return e===t}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t||e.length!==t.length)return!1;var a=Array.isArray(e),u=Array.isArray(t);if(a!==u)return!1;if(a&&u){for(var l=0;ltypeof globalThis?globalThis:e.g,e5=function(){function e(){this.identityStore=new e3,this.eventBridge=new eQ,this.applicationContextProvider=new eY}return e.getInstance=function(t){return e4.analyticsConnectorInstances||(e4.analyticsConnectorInstances={}),e4.analyticsConnectorInstances[t]||(e4.analyticsConnectorInstances[t]=new e),e4.analyticsConnectorInstances[t]},e}(),e6=function(e){return void 0===e&&(e=eo),e5.getInstance(e)},e8=function(e,t){e6(t).identityStore.editIdentity().setUserId(e).commit()},e7=function(e,t){e6(t).identityStore.editIdentity().setDeviceId(e).commit()},e9=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},te=function(){function e(){this.name="identity",this.type="before",this.identityStore=e6().identityStore}return e.prototype.execute=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return e.instanceName&&(this.identityStore=e6(e.instanceName).identityStore),[2]})})},e}(),tt=function(){var e,t=(0,eO.getGlobalScope)();return(null==(e=null==t?void 0:t.location)?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce(function(e,t){var n=t.split("=",2),r=tn(n[0]),i=tn(n[1]);return i&&(e[r]=i),e},{}):{}},tn=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},tr=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}(),ti=function(){function e(e,t,n,r){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 tr(e,t)}return e.prototype.subscribe=function(e,t,n){var r=ex(),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(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5)return this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2];return[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.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.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(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Q.__generator)(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(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Q.__generator)(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),(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r,i,o,s,a,u=this;return(0,Q.__generator)(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,a,l,c,d;return(0,Q.__generator)(this,function(f){switch(f.label){case 0:i=!0,s=new AbortController,a=setTimeout(function(){return s.abort()},t),f.label=1;case 1:return f.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:s.signal})];case 2:if((l=f.sent()).ok)return[3,4];return[4,l.text()];case 3:return c=f.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(l.status,": ").concat(c)),401===l.status?(o.logger.error("Remote config client fetch failed with ".concat(401,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):l.status>=400&&l.status<500&&429!==l.status&&(i=!1),[3,6];case 4:return[4,l.json()];case 5:return[2,{value:{remoteConfig:f.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=f.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(a),[7];case 9:if(!i)return[2,"break"];if(!(r=1e4)return void this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit");this.inMemoryTags[e]=t,this.startTimersIfNeeded()}},e.prototype.increment=function(e,t){if(void 0===t&&(t=1),this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryCounters).length>=1e4)return void 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>=1e4)return void this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");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){if(this.isStorageAndTrackEnabled()){if(this.inMemoryEvents.length>=10)return void 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})},3e5))},e.prototype.saveAllDataToStorage=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t,n,r;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];return e=(0,Q.__assign)({},this.inMemoryTags),t=(0,Q.__assign)({},this.inMemoryCounters),n=(0,Q.__assign)({},this.inMemoryHistograms),r=(0,Q.__spreadArray)([],(0,Q.__read)(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)])];case 1:return i.sent(),[2]}})})},e.prototype._flush=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l;return(0,Q.__generator)(this,function(c){switch(c.label){case 0:if(!this.storage)return[2];return[4,this.saveAllDataToStorage()];case 1:return c.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:if(t=(e=c.sent()).tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={},n.forEach(function(e){s[e.key]=e.value}),a={},r.forEach(function(e){a[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),u=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(s).length&&0===Object.keys(a).length&&0===u.length)return[2];return l={tags:o,histogram:a,counters:s,events:u},this.fetch(l),[2]}})})},e.prototype.fetch=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!(0,eO.getGlobalScope)())throw 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:if(!n.sent().ok)return this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2];return this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3];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(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t,n;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:if(!this.storage)return[2];return e=Date.now(),[4,this.storage.getLastFlushTimestamp()];case 1:if(-1===(t=r.sent()||-1))return this.storage.setLastFlushTimestamp(e),this._setFlushTimer(3e5),[2];return(n=e-t)>=3e5?this._flush():this._setFlushTimer(3e5-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=tg(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),tb=e.i(427968),tw=tb.default||tb,tS=function(e,t){return"boolean"==typeof e?e:(null==e?void 0:e[t])!==!1},tE=function(e){return tS(e,"attribution")},tk=function(e){return tS(e,"formInteractions")},tT=function(e){return tS(e,"pageViews")},tI=function(e){return tS(e,"sessions")},tC=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},tP=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},tO=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},tR=function(e){if(tP(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},tx=function(e){if(tO(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},tA=function(e){var t;if(tC(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),(0,Q.__assign)((0,Q.__assign)({},n),{captureRules:null==(t=null==n?void 0:n.captureRules)?void 0:t.map(function(t){var n,r,i;if((null==(n=t.urls)?void 0:n.length)&&(null==(r=t.hosts)?void 0:r.length)){var o=JSON.stringify(t.hosts),s=JSON.stringify(t.urls);return null==(i=e.loggerProvider)||i.warn("Found network capture rule with both urls='".concat(s,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),(0,Q.__assign)((0,Q.__assign)({},t),{hosts:void 0})}return t})})}},tD=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return tT(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}},tL=function(e){return tE(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.attribution&&"object"==typeof e.defaultTracking.attribution?(0,Q.__assign)({},e.defaultTracking.attribution):{}},tM=function(e){if(tk(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions},tN=function(e,t){for(var n=0;ntypeof 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(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,Q.__generator)(this,function(s){return r=new Date().getTime(),i=null!=(t=this.config.lastEventId)?t:-1,o=null!=(n=e.event_id)?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,(0,Q.__assign)((0,Q.__assign)((0,Q.__assign)((0,Q.__assign)((0,Q.__assign)((0,Q.__assign)((0,Q.__assign)((0,Q.__assign)({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:tq()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:ex(),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:o,library:this.library,user_agent:this.userAgent})]})})},e}(),tH=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(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(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),tW=function(){var e,t=(0,eO.getGlobalScope)();return null==(e=null==t?void 0:t.navigator)?void 0:e.locks},tz=function(){function e(e,t){void 0===t&&(t={}),this.options=(0,Q.__assign)({},e),this.config=t}return e.prototype.isEnabled=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,Q.__generator)(this,function(o){switch(o.label){case 0:return t="AMP_TEST",n=new e((0,Q.__assign)({},this.options)),r=String(Date.now()),[4,n.transaction(t,function(e){var n,o;try{e.set(r);var s=e.get()===r;return!s&&i.config.diagnosticsClient&&(null==(n=i.config.diagnosticsClient)||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:r,sync:!0})),s}catch(e){if(i.config.diagnosticsClient){var a=e instanceof Error?e.message:String(e);null==(o=i.config.diagnosticsClient)||o.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:r,error:a,sync:!0})}return!1}finally{e.set(null)}})];case 1:return[2,o.sent()]}})})},e.prototype.get=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(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=tV(t);if(void 0===n)return void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t));return JSON.parse(n)}catch(n){console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t));return}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,l,c;return(0,Q.__generator)(this,function(d){switch(d.label){case 0:r=(0,eO.getGlobalScope)(),d.label=1;case 1:if(d.trys.push([1,4,,5]),!(i=null==r?void 0:r.cookieStore))return[3,3];return[4,i.getAll(e)];case 2:if(o=d.sent()){o.length>1&&(null==(t=this.config.diagnosticsClient)||t.recordEvent("cookies.duplicate",{cookies:o.map(function(e){return e.domain})}),null==(n=this.config.diagnosticsClient)||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(a=(s=(0,Q.__values)(o)).next();!a.done;a=s.next())if(u=a.value,tJ(u.domain,this.options.domain))return[2,u.value]}catch(e){l={error:e}}finally{try{a&&!a.done&&(c=s.return)&&c.call(s)}finally{if(l)throw l.error}}}d.label=3;case 3:return[3,5];case 4:return d.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},e.prototype.getRawSync=function(e){var t,n,r=this,i=(0,eO.getGlobalScope)(),o=(null!=(n=null==(t=null==i?void 0:i.document)?void 0:t.cookie.split("; "))?n:[]).filter(function(t){return 0===t.indexOf(e+"=")}),s=void 0,a=this.config.duplicateResolverFn;if("function"==typeof a&&o.length>1&&(s=o.find(function(t){var n;try{var i=a(t.substring(e.length+1));return i||null==(n=r.config.diagnosticsClient)||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}})),s||(s=o[0]),s)return s.substring(e.length+1)},e.prototype.set=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){var n;try{var r=null!=(n=this.options.expirationDays)?n:0,i=null!==t?r:-1,o=void 0;if(i){var s=new Date;s.setTime(s.getTime()+24*i*36e5),o=s}var a="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t))));o&&(a+="; expires=".concat(o.toUTCString())),a+="; path=/",this.options.domain&&(a+="; domain=".concat(this.options.domain)),this.options.secure&&(a+="; Secure"),this.options.sameSite&&(a+="; SameSite=".concat(this.options.sameSite));var u=(0,eO.getGlobalScope)();u&&(u.document.cookie=a)}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(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(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(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return[2]})})},e.isDomainWritable=function(t){return(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Q.__generator)(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(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r,i=this;return(0,Q.__generator)(this,function(o){switch(o.label){case 0:if(n=tW(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];return[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 1:return[2,o.sent()]}})})},e.cachedTlds={},e}(),tG=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}},tK=function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}},tV=function(e){var t;return null!=(t=tG(e))?t:tK(e)},tJ=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()},t$=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),["AMP",t,e.substring(0,n)].filter(Boolean).join("_")},tY=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r;return(0,Q.__generator)(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(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:if(!(t=n.sent()))return[2,void 0];return[2,JSON.parse(t)];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(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return[2,(null==(t=this.storage)?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var n;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(r){try{null==(n=this.storage)||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){try{null==(t=this.storage)||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){try{null==(e=this.storage)||e.clear()}catch(e){}return[2]})})},e}(),tX=function(e){function t(t){var n,r,i,o=this;try{i=null==(n=(0,eO.getGlobalScope)())?void 0:n.localStorage}catch(e){null==(r=null==t?void 0:t.loggerProvider)||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(0,Q.__extends)(t,e),t.prototype.set=function(t,n){var r;return(0,Q.__awaiter)(this,void 0,void 0,function(){var i;return(0,Q.__generator)(this,function(o){switch(o.label){case 0:if(!(Array.isArray(n)&&n.length>1e3))return[3,2];return i=n.length-1e3,[4,e.prototype.set.call(this,t,n.slice(0,1e3))];case 1:return o.sent(),null==(r=this.loggerProvider)||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat(1e3,".")),[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}(tY),tQ=function(e){function t(){var t;return e.call(this,null==(t=(0,eO.getGlobalScope)())?void 0:t.sessionStorage)||this}return(0,Q.__extends)(t,e),t}(tY),tZ=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){if("object"!=typeof e)return null;var t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,w,S,E=e.code||0,k=this.buildStatus(E);switch(k){case D.Success:return{status:k,statusCode:E,body:{eventsIngested:null!=(t=e.events_ingested)?t:0,payloadSizeBytes:null!=(n=e.payload_size_bytes)?n:0,serverUploadTime:null!=(r=e.server_upload_time)?r:0}};case D.Invalid:return{status:k,statusCode:E,body:{error:null!=(i=e.error)?i:"",missingField:null!=(o=e.missing_field)?o:"",eventsWithInvalidFields:null!=(s=e.events_with_invalid_fields)?s:{},eventsWithMissingFields:null!=(a=e.events_with_missing_fields)?a:{},eventsWithInvalidIdLengths:null!=(u=e.events_with_invalid_id_lengths)?u:{},epsThreshold:null!=(l=e.eps_threshold)?l:0,exceededDailyQuotaDevices:null!=(c=e.exceeded_daily_quota_devices)?c:{},silencedDevices:null!=(d=e.silenced_devices)?d:[],silencedEvents:null!=(f=e.silenced_events)?f:[],throttledDevices:null!=(g=e.throttled_devices)?g:{},throttledEvents:null!=(h=e.throttled_events)?h:[]}};case D.PayloadTooLarge:return{status:k,statusCode:E,body:{error:null!=(p=e.error)?p:""}};case D.RateLimit:return{status:k,statusCode:E,body:{error:null!=(v=e.error)?v:"",epsThreshold:null!=(m=e.eps_threshold)?m:0,throttledDevices:null!=(y=e.throttled_devices)?y:{},throttledUsers:null!=(_=e.throttled_users)?_:{},exceededDailyQuotaDevices:null!=(b=e.exceeded_daily_quota_devices)?b:{},exceededDailyQuotaUsers:null!=(w=e.exceeded_daily_quota_users)?w:{},throttledEvents:null!=(S=e.throttled_events)?S:[]}};case D.Timeout:default:return{status:k,statusCode:E}}},e.prototype.buildStatus=function(e){return eG(e)?D.Success:429===e?D.RateLimit:413===e?D.PayloadTooLarge:408===e?D.Timeout:e>=400&&e<500?D.Invalid:e>=500?D.Failed:D.Unknown},e}();function t0(){return"u">typeof CompressionStream}function t1(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,new Response(new Blob([e]).stream().pipeThrough(new t("gzip"))).arrayBuffer()];case 2:return[2,n.sent()];case 3:return n.sent(),[2,void 0];case 4:return[2]}})})}var t2=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(0,Q.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var r=this;return(0,Q.__generator)(this,function(i){return[2,new Promise(function(i,o){"u"=2048&&t0(),c=function(e){var t,n;a=(0,Q.__assign)((0,Q.__assign)({},r.customHeaders),a);try{for(var i=(0,Q.__values)(Object.entries(a)),o=i.next();!o.done;o=i.next()){var u=(0,Q.__read)(o.value,2),l=u[0],c=u[1];s.setRequestHeader(l,c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}s.send(e)};(0,Q.__awaiter)(r,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(t){switch(t.label){case 0:if(!l)return[3,2];return[4,t1(u)];case 1:return(e=t.sent())?(a["Content-Encoding"]="gzip",c(e)):c(u),[3,3];case 2:c(u),t.label=3;case 3:return[2]}})}).catch(o)})]})})},t}(tZ),t3=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return(0,Q.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i,o,s,a,u,l;return(0,Q.__generator)(this,function(c){switch(c.label){case 0:if("u"=2048&&t0(),o=r,s={"Content-Type":"application/json",Accept:"*/*"},!i)return[3,2];return[4,t1(r)];case 1:(a=c.sent())&&(s["Content-Encoding"]="gzip",o=a),c.label=2;case 2:return[4,fetch(e,{headers:s=(0,Q.__assign)((0,Q.__assign)({},this.customHeaders),s),body:o,method:"POST"})];case 3:return[4,(u=c.sent()).text()];case 4:l=c.sent();try{return[2,this.buildResponse(JSON.parse(l))]}catch(e){return[2,this.buildResponse({code:u.status})]}}})})},t}(tZ),t4=function(e){function t(){return e.call(this)||this}return(0,Q.__extends)(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var n=this;return(0,Q.__generator)(this,function(r){return[2,new Promise(function(r,i){var o=(0,eO.getGlobalScope)();if(!(null==o?void 0:o.navigator.sendBeacon))throw Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);if(o.navigator.sendBeacon(e,s))return r(n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}));return r(n.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(tZ),t5=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},t6=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},t8="[Amplitude]",t7="".concat(t8," Form Started"),t9="".concat(t8," Form Submitted"),ne="".concat(t8," File Downloaded"),nt="session_start",nn="session_end",nr="".concat(t8," File Extension"),ni="".concat(t8," File Name"),no="".concat(t8," Link ID"),ns="".concat(t8," Link Text"),na="".concat(t8," Link URL"),nu="".concat(t8," Form ID"),nl="".concat(t8," Form Name"),nc="".concat(t8," Form Destination"),nd="cookie",nf={always:"always",ifEmptyCampaign:"ifEmptyCampaign"},ng=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},nh=function(e,t,n,r,i,o){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=(0,Q.__rest)(e,["referrer","referring_domain"]),u=t||{},l=(u.referrer,u.referring_domain),c=(0,Q.__rest)(u,["referrer","referring_domain"]),d=n.excludeInternalReferrers;if(d){var f=ny(d,r);if(!(f instanceof TypeError)&&e.referring_domain&&nS(e.referring_domain,o)){if("always"===f)return n_(f,e.referring_domain,r),!1;else if("ifEmptyCampaign"===f&&Object.values((0,Q.__assign)((0,Q.__assign)({},e),{referring_domain:void 0,referrer:void 0})).every(function(e){return!e}))return n_(f,e.referring_domain,r),!1}}if(np(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&&Object.values(e).every(function(e){return!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(a)!==JSON.stringify(c),h=ng(s||"")!==ng(l||""),p=!t||g||h;return p?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."),p},np=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})},nv=function(e,t){var n=t.startsWith(".")?t:".".concat(t);return!!(e.startsWith(".")?e:".".concat(e)).endsWith(n)},nm=function(e){var t=e;return t?(t.startsWith(".")&&(t=t.substring(1)),[new RegExp("".concat(t.replace(".","\\."),"$"))]):[]},ny=function(e,t){if(!0===e)return nf.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(nf).includes(n))return n;if(void 0===n)return nf.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),TypeError(r)};function n_(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 nb=["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"],nw=function(e){var t,n,r=e||(null==(n=null==(t=(0,eO.getGlobalScope)())?void 0:t.location)?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],s=i[i.length-2];return(nb.find(function(e){return r.endsWith(".".concat(e))})&&(o=i[i.length-2]+"."+i[i.length-1],s=i[i.length-3]),s)?"".concat(s,".").concat(o):o},nS=function(e,t){var n=(0,eO.getGlobalScope)();return!!n&&nv(e,(t||"").trim()||nw(n.location.hostname))},nE=function(e){function t(t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,T,I,C,P,R,x,A,D,L,M,N,U,q,j,F,B,H,W,z,G){void 0===r&&(r=new tH),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=nd),void 0===v&&(v=new eF),void 0===m&&(m=O.Warn),void 0===_&&(_=!1),void 0===b&&(b=!1),void 0===E&&(E=""),void 0===k&&(k="US"),void 0===C&&(C=18e5),void 0===P&&(P=new tX({loggerProvider:v})),void 0===R&&(R={ipAddress:!0,language:!0,platform:!0}),void 0===x&&(x="fetch"),void 0===A&&(A=!1),void 0===D&&(D=!0),void 0===j&&(j=!0),void 0===F&&(F=0),void 0===z&&(z=!1),void 0===G&&(G=!1);var K,V=this;(V=e.call(this,{apiKey:t,storageProvider:P,transportProvider:nI(x)})||this).apiKey=t,V.appVersion=n,V.cookieOptions=i,V.defaultTracking=o,V.autocapture=s,V.flushIntervalMillis=u,V.flushMaxRetries=l,V.flushQueueSize=c,V.identityStorage=d,V.ingestionMetadata=f,V.instanceName=g,V.loggerProvider=v,V.logLevel=m,V.minIdLength=y,V.offline=_,V.partnerId=w,V.plan=S,V.serverUrl=E,V.serverZone=k,V.sessionTimeout=C,V.storageProvider=P,V.trackingOptions=R,V.transport=x,V.useBatch=A,V.fetchRemoteConfig=D,V.networkTrackingOptions=U,V.identify=q,V.enableDiagnostics=j,V.diagnosticsSampleRate=F,V.diagnosticsClient=B,V.remoteConfig=H,V.topLevelDomain=W,V.enableRequestBodyCompression=z,V._enableRequestBodyCompressionExperimental=G,V.version=tj,V._optOut=!1,V._cookieStorage=r,V.deviceId=a,V.lastEventId=h,V.lastEventTime=p,V.optOut=b,V.deferredSessionId=I,V.sessionId=T,V.pageCounter=M,V.userId=L,V.debugLogsEnabled=N,V.loggerProvider.enable(N?O.Debug:V.logLevel),V.networkTrackingOptions=U,V.identify=q,V.enableDiagnostics=j,V.diagnosticsSampleRate=F,V.diagnosticsClient=B;var J=null!=(K=null==H?void 0:H.fetchRemoteConfig)?K:D;return V.remoteConfig=V.remoteConfig||{},V.remoteConfig.fetchRemoteConfig=J,V.fetchRemoteConfig=J,V.topLevelDomain=W||nw(),V}return(0,Q.__extends)(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 tz&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(t$(this.apiKey),e)},t}(eH),nk=function(e,t,n){switch(void 0===e&&(e=nd),void 0===t&&(t={}),e){case"localStorage":return new tX;case"sessionStorage":return new tQ;case"none":return new tH;default:return new tz((0,Q.__assign)((0,Q.__assign)({},t),{expirationDays:t.expiration}),n)}},nT=function(e){var t,n;return void 0===e&&(e={}),(null==(t=e.remoteConfig)?void 0:t.fetchRemoteConfig)===!0||(null==(n=e.remoteConfig)?void 0:n.fetchRemoteConfig)!==!1&&!1!==e.fetchRemoteConfig},nI=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0;return"xhr"===t?new t2(n):"beacon"===t?new t4:new t3(n)},nC="data-amp-mask",nP="*****",nO=/\b(?:\d[ -]*?){13,16}\b/,nR=/(\d{3}-?\d{2}-?\d{4})/g,nx=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,nA=function(e,t){if(void 0===t&&(t=[]),"string"!=typeof e)return"";var n,r,i=e;i=(i=(i=i.replace(nO,nP)).replace(nR,nP)).replace(nx,nP);try{for(var o=(0,Q.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,nP)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},nD=function(e){if("u"typeof location&&location.href||""),n={event_type:l},t=[{}],[4,nU()];case 1:return[2,(n.event_properties=Q.__assign.apply(void 0,[Q.__assign.apply(void 0,t.concat([r.sent()])),{"[Amplitude] Page Domain":"u">typeof location&&location.hostname||"","[Amplitude] Page Location":e,"[Amplitude] Page Path":"u">typeof location&&c(location.pathname)||"","[Amplitude] Page Title":nD(nA),"[Amplitude] Page URL":e.split("?")[0]}]),n)]}})})},f=function(){return void 0===s||"function"==typeof s&&s()},g="u">typeof location?location.href:null,h=function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,n,r,o;return(0,Q.__generator)(this,function(s){switch(s.label){case 0:if(n=nj(a,e=location.href,g||"")&&f(),g=e,!n)return[3,4];if(null==i||i.log("Tracking page view event"),null!=t)return[3,1];return[3,3];case 1:return o=(r=t).track,[4,d()];case 2:o.apply(r,[s.sent()]),s.label=3;case 3:s.label=4;case 4:return[2]}})})},p=function(){h()};return{name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,s){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var a,u;return(0,Q.__generator)(this,function(l){switch(l.label){case 0:if(t=s,n=e,(i=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),o=!0,r&&(r.addEventListener("popstate",p),r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=(0,Q.__read)(n,3),i=r[0],s=r[1],a=r[2];e.apply(t,[i,s,a]),o&&h()}})),!f())return[3,2];return i.log("Tracking page view event"),u=(a=t).track,[4,d()];case 1:u.apply(a,[l.sent()]),l.label=2;case 2:return[2]}})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:if(!("attribution"===s&&nq(e)))return[3,2];return null==i||i.log("Enriching campaign event to page view event with campaign parameters"),[4,d()];case 1:e.event_type=(t=r.sent()).event_type,e.event_properties=(0,Q.__assign)((0,Q.__assign)({},e.event_properties),t.event_properties),r.label=2;case 2:return n&&e.event_type===l&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=(0,Q.__assign)((0,Q.__assign)({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return r&&(r.removeEventListener("popstate",p),o=!1),[2]})})}}},nU=function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(t){switch(t.label){case 0:return e=nM,[4,new nL().parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},nq=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[R.SET]||{},r=t[R.UNSET]||{},i=(0,Q.__spreadArray)((0,Q.__spreadArray)([],(0,Q.__read)(Object.keys(n)),!1),(0,Q.__read)(Object.keys(r)),!1);return Object.keys(ew).every(function(e){return i.includes(e)})}return!1},nj=function(e,t,n){if("pathOnly"!==e)return t!==n;if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname},nF=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})},i=function(){n.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),n=[]};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Q.__generator)(this,function(a){return t=tM(n),o=function(){if(!i)return void n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.");if("u">typeof document){var o=new WeakSet,s=function(e){if(!o.has(e)){o.add(e);var s=!1;r(e,"change",function(){var t,n=nH(e);s||i.track(t7,((t={})[nu]=nB(e.id),t[nl]=nB(e.name),t[nc]=n,t)),s=!0}),r(e,"submit",function(r){var o,a,u=nH(e);if(s||i.track(t7,((o={})[nu]=nB(e.id),o[nl]=nB(e.name),o[nc]=u,o)),s=!0,(null==t?void 0:t.shouldTrackSubmit)!==void 0)if("function"==typeof t.shouldTrackSubmit&&"u">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(t9,((a={})[nu]=nB(e.id),a[nl]=nB(e.name),a[nc]=u,a)),s=!1})}};Array.from(document.getElementsByTagName("form")).forEach(s),"u">typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"FORM"===e.nodeName&&s(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(s)})})})).observe(document.body,{subtree:!0,childList:!0})}},"complete"===document.readyState?o():(s=(0,eO.getGlobalScope)())?s.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return null==e||e.disconnect(),i(),[2]})})}}},nB=function(e){if("string"==typeof e)return e},nH=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},nW=function(){var e,t=[],n=function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})},r=function(){t.forEach(function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)}),t=[]};return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(t,r){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var i,o;return(0,Q.__generator)(this,function(s){return i=function(){if(!r)return void t.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.");if("u">typeof document){var i=function(e){try{t=new URL(e.href,window.location.href)}catch(e){return}var t,i=o.exec(t.href),s=null==i?void 0:i[1];s&&n(e,"click",function(){var n;s&&r.track(ne,((n={})[nr]=s,n[ni]=t.pathname,n[no]=e.id,n[ns]=e.text,n[na]=e.href,n))})},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),"u">typeof MutationObserver&&(e=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.forEach(function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)})})})).observe(document.body,{subtree:!0,childList:!0})}},"complete"===document.readyState?i():(o=(0,eO.getGlobalScope)())?o.addEventListener("load",i):t.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return null==e||e.disconnect(),r(),[2]})})}}},nz=!1,nG=function(e){nz||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(, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),nz=!0)},nK=function(){var e=(0,eO.getGlobalScope)(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))},r=function(){t.forEach(function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)}),t=[]};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(r){return"u"0&&setTimeout(function(){s(Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;if(!this.requestCallbacks[e.id]){null==(t=this.logger)||t.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},e.prototype.registerActionHandler=function(e,t){this.actionHandlers.has(e)&&(null==(o=null==(i=this.logger)?void 0:i.warn)||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var n,r,i,o,s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var a=(0,Q.__values)(s),u=a.next();!u.done;u=a.next()){var l=u.value;t(l)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=(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)||r.appendChild(i)}catch(e){n(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,s=i.endpoint;o&&(this.logger=o),s&&this.endpoint===nX&&(this.endpoint=s),this.isSetup||(this.isSetup=!0,null==(n=null==(t=this.logger)?void 0:t.debug)||n.call(t,"Setting up messenger"),this.messageHandler=function(e){if(null==(n=null==(t=r.logger)?void 0:t.debug)||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var t,n,i,o,s,a=e.data,u=null==a?void 0:a.action;if(u)if("id"in a&&a.id)null==(o=null==(i=r.logger)?void 0:i.debug)||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a);else{if("ping"===u)return void r.notify({action:"pong"});var l=r.actionHandlers.get(u);if(l)l(a.data);else{var c=null!=(s=r.pendingMessages.get(u))?s:[];c.push(a.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=(0,eO.getGlobalScope)();(null==e?void 0:e[n0])===this&&delete e[n0]},e}();function n2(e){var t=(0,eO.getGlobalScope)(),n=null==t?void 0:t[n0];if("object"==typeof n&&null!==n&&nZ in n&&!0===n[nZ])return n;var r=new n1(e);return t&&(t[n0]=r),r}M=nZ;var n3="__AMPLITUDE_BACKGROUND_CAPTURE__";function n4(e,t){var n;if(!0!==e[n3]){e[n3]=!0;var r=null!=(n=null==t?void 0:t.scriptUrl)?n:"https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.2.js.gz",i=null,o=function(t,n){var r,i;"background-capture-complete"===t&&(null==(i=null==(r=e.logger)?void 0:r.debug)||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){null==(n=null==(t=e.logger)?void 0:t.debug)||n.call(t,"Initializing background capture (external script)");var t,n,s=new URL(r,e.endpoint).toString();e.loadScriptOnce(s).then(function(){var t,n,r;null==(n=null==(t=e.logger)?void 0:t.debug)||n.call(t,"Background capture script loaded (external)"),i=null==(r=null==window?void 0:window.amplitudeBackgroundCapture)?void 0:r.call(window,{messenger:e,onBackgroundCapture:o}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null==(t=e.logger)||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null==(e=null==i?void 0:i.close)||e.call(i),i=null})}}var n5=e.i(523072);function n6(e,t){return new n5.default(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 n8(e,t){return new n5.default(function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=(0,Q.__values)(i),o=n.next();!o.done;o=n.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return s(e),s(t),o})}function n7(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new n5.default(function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){try{for(var n,r,i,o=(0,Q.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;null==(i=a.next)||i.call(a,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){try{for(var n,i,o,s=(0,Q.__values)(t),a=s.next();!a.done;a=s.next()){var u=a.value;null==(o=u.error)||o.call(u,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}r()},complete:function(){try{for(var e,n,i,o=(0,Q.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;null==(i=a.complete)||i.call(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}})}var n9="1.23.4",re="[Amplitude] Element Clicked",rt="[Amplitude] Element Tag",rn="[Amplitude] Element Text",rr="[Amplitude] Page URL",ri="data-amp-mask-attributes",ro=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},rs=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},ra=["input","select","textarea"],ru=function(e,t){var n,r=null==(n=null==window?void 0:window.getComputedStyle)?void 0:n.call(window,e);return(null==r?void 0:r.getPropertyValue("cursor"))==="pointer"&&"click"===t},rl=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&ro(window.location.href,n))&&!!ro(window.location.href,t)},rc=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,s,a=e.shouldTrackEventResolver,u=null==(s=null==(o=null==i?void 0:i.tagName)?void 0:o.toLowerCase)?void 0:s.call(o);if(!u)return!1;if(a)return a(r,i);if(!rl(e))return!1;var l=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof l)switch(l.toLowerCase()){case"hidden":case"password":return!1}var c=ru(i,r);if(n&&c)return!0;if(t&&!t.some(function(e){var t;return!!(null==(t=null==i?void 0:i.matches)?void 0:t.call(i,e))}))return!1;switch(u){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:if(c)return!0;return"click"===r}}},rd=function(e){var t,n,r,i=null==(n=null==(t=null==e?void 0:e.tagName)?void 0:t.toLowerCase)?void 0:n.call(t),o=e instanceof HTMLElement&&(null==(r=e.getAttribute("contenteditable"))?void 0:r.toLowerCase())==="true";return!ra.includes(i)&&!o},rf=function(e){return Object.keys(e).reduce(function(t,n){var r=e[n];return null!=r&&("object"!=typeof r||0!==Object.keys(r).length)&&("string"!=typeof r||0!==r.trim().length)&&(t[n]=r),t},{})},rg=function(e,t){return e?t.some(function(t){var n;return null==(n=null==e?void 0:e.matches)?void 0:n.call(e,t)})?e:rg(null==e?void 0:e.parentElement,t):null},rh=function(e){return null!==e.event.target&&!!e.closestTrackedAncestor};(u=N||(N={}))[u.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",u[u.MIDDLE=1]="MIDDLE",u[u.RIGHT=2]="RIGHT";var rp="__AMPLITUDE_VISUAL_TAGGING__",rv=n5,rm=(0,eO.getGlobalScope)(),ry=null==rm?void 0:rm.console,r_={},rb={},rw=!1,rS=function(e,t){if(!ry||"function"!=typeof ry[e]||!rb[e]&&(rb[e]=ry[e],ry[e]=function(){for(var t=[],n=0;n=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},rk=(0,eO.getGlobalScope)(),rT=function(){return new rv.default(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()}})},rI=function(e){return void 0===e&&(e="click"),new rv.default(function(t){var n=function(e){t.next(e)};return rk.document.addEventListener(e,n,{capture:!0}),function(){rk.document.removeEventListener(e,n,{capture:!0})}})},rC=function(){var e=n8(new rv.default(function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=(0,Q.__assign)((0,Q.__assign)({},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 rk.addEventListener("error",t),function(){rk.removeEventListener("error",t)}}),new rv.default(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 rk.addEventListener("unhandledrejection",t),function(){rk.removeEventListener("unhandledrejection",t)}}));return n8(e,new rv.default(function(e){var t=function(t){for(var n=[],r=1;r=0;c--){var d=u[c];if(d){var f,g=(f=d.getAttribute(ri))?f.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[],h=c===u.length-1?[]:null!=(r=l.get(u[c+1]))?r:new Set,p=new Set((0,Q.__spreadArray)((0,Q.__spreadArray)([],(0,Q.__read)(h),!1),(0,Q.__read)(g),!1));l.set(d,p)}}a=u.map(function(e){var t;return function(e,t){if(null===e)return null;var n,r,i,o,s,a,u=String(e.tagName).toLowerCase(),l={tag:u},c=Array.from(null!=(o=null==(i=e.parentElement)?void 0:i.children)?o:[]);c.length&&(l.index=c.indexOf(e),l.indexOfType=c.filter(function(t){return t.tagName===e.tagName}).indexOf(e));var d=null==(a=null==(s=e.previousElementSibling)?void 0:s.tagName)?void 0:a.toLowerCase();d&&(l.prevSib=String(d));var f=e.getAttribute("id");f&&(l.id=String(f));var g=Array.from(e.classList);g.length&&(l.classes=g);var h={},p=Array.from(e.attributes).filter(function(e){return!rN.has(e.name)}),v=!rd(e);if(!rj.includes(String(e.getAttribute("type")))&&!rq.includes(u))try{for(var m=(0,Q.__values)(p),y=m.next();!y.done;y=m.next()){var _=y.value;if(!v||rU.includes(_.name)){if(t.has(_.name)){h[_.name]=nP;continue}h[_.name]=String(_.value).substring(0,128)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(h).length&&(l.attrs=h),l}(e,null!=(t=l.get(e))?t:new Set)});var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach(function(t){var n=(0,Q.__read)(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))})};try{for(var m=(0,Q.__values)(a),y=m.next();!y.done;y=m.next()){var _=y.value;v(_)}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null==(i=o.diagnosticsClient)||i.recordHistogram("autocapturePlugin.getHierarchy",b-s),a},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getEventProperties=function(e,t,n){var r,i,s,a,u=null==(s=null==(i=null==t?void 0:t.tagName)?void 0:i.toLowerCase)?void 0:s.call(i),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},c=o.getHierarchy(t),d=null==(a=c[0])?void 0:a.attrs,f=o.getNearestLabel(t),g=Object.entries(null!=d?d:{}).reduce(function(e,t){var r=(0,Q.__read)(t,2),i=r[0],o=r[1];if(i.startsWith(n)){var s=i.replace(n,"");s&&(e[s]=o||"")}return e},{}),h=((r={})["[Amplitude] Element Hierarchy"]=c,r[rt]=u,r[rn]=o.getText(t),r["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),r["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),r["[Amplitude] Element Attributes"]=g,r["[Amplitude] Element Parent Label"]=f,r[rr]=rs(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=nD(o.replaceSensitiveString),r["[Amplitude] Viewport Height"]=window.innerHeight,r["[Amplitude] Viewport Width"]=window.innerWidth,r);if(h["[Amplitude] Element ID"]=t.getAttribute("id")||"",h["[Amplitude] Element Class"]=t.getAttribute("class"),h["[Amplitude] Element Aria Label"]=null==d?void 0:d["aria-label"],"a"===u&&"click"===e&&t instanceof HTMLAnchorElement){var p=t.href.substring(0,128);h["[Amplitude] Element Href"]=o.replaceSensitiveString(p)}return rf(h)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var s=o.addTypeAndTimestamp(e,t);if(("click"===s.type||"change"===s.type)&&null!==s.event.target){if(i&&ru(s.event.target,s.type))return s.closestTrackedAncestor=s.event.target,s.targetElementProperties=o.getEventProperties(s.type,s.closestTrackedAncestor,r),s;var a=rg(s.event.target,n);a&&(s.closestTrackedAncestor=a,s.targetElementProperties=o.getEventProperties(s.type,a,r))}return s},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=rO(e,t);if(n){if("TEXT"===e.elementExtractType)return o.getText(n);if("ATTRIBUTE"===e.elementExtractType&&e.attribute)return n.getAttribute(e.attribute)}}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(nC,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",s=Array.from(e.childNodes);try{for(var a=(0,Q.__values)(s),u=a.next();!u.done;u=a.next()){var l=u.value;if(l.nodeType===Node.TEXT_NODE){i+=l.textContent||"";continue}if(l instanceof Element){if(l.hasAttribute(nC)||l.hasAttribute("contenteditable")){i+=nP;continue}i+=o.getTextWithMaskedDescendants(l)}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},this.getText=function(e){if(null!==e.closest("[".concat(nC,"]")))return nP;var t="";return t=e.querySelector("[".concat(nC,"], [contenteditable]"))?o.getTextWithMaskedDescendants(e):e.innerText||"",o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){if(!e)return{};var t,n,r,i=null==(r=null==(n=null==e?void 0:e.tagName)?void 0:n.toLowerCase)?void 0:r.call(n);return rf(((t={})[rt]=i,t[rn]=o.getText(e),t[rr]=window.location.href.split("?")[0],t))},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var s=null!=(i=e.maskTextRegex)?i:[],a=[];try{for(var u=(0,Q.__values)(s),l=u.next();!l.done;l=u.next()){var c=l.value;if(a.length>=25)break;if(c instanceof RegExp)a.push(c);else if("pattern"in c&&"string"==typeof c.pattern)try{a.push(RegExp(c.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=a},rv=n5;(l=U||(U={})).ClickObservable="clickObservable",l.ChangeObservable="changeObservable",l.NavigateObservable="navigateObservable",l.MutationObservable="mutationObservable",l.BrowserErrorObservable="browserErrorObservable",l.SelectionObservable="selectionObservable",l.MouseMoveObservable="mouseMoveObservable";var rB=function(e,t){void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",n9);var n,r,i,o,s,a,u,l,c=e.dataAttributePrefix,d=void 0===c?n$:c,f=e.visualTaggingOptions,g=void 0===f?{enabled:!0}:f;e.cssSelectorAllowlist=null!=(n=e.cssSelectorAllowlist)?n:nJ,e.actionClickAllowlist=null!=(r=e.actionClickAllowlist)?r:nY,e.debounceTime=null!=(i=e.debounceTime)?i:0,e.pageUrlExcludelist=null==(o=e.pageUrlExcludelist)?void 0:o.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(e){console.warn("Invalid regex pattern: ".concat(t.pattern),e)}return e},[]);var h="@amplitude/plugin-autocapture-browser",p=[],v=new rF(e,t),m=function(){var t,n,r=n7(rI().map(function(t){return v.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,d)})),i=n7(new rv.default(function(t){var n,r=function(n){var r=v.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,d);t.next(r)};return null==(n=(0,eO.getGlobalScope)())||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null==(e=(0,eO.getGlobalScope)())?void 0:e.document.removeEventListener("change",r)}}));window.navigation&&(n=n7(new rv.default(function(t){var n=function(n){var r=v.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,d);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}})));var o=n7(rT().map(function(t){return v.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,d)}));return(t={})[U.ChangeObservable]=i,t[U.ClickObservable]=r,t[U.MutationObservable]=o,t[U.NavigateObservable]=n,t},y=rA(Object.values(null!=(a=null==(s=e.pageActions)?void 0:s.labeledEvents)?a:{})),_=rD(null!=(l=null==(u=e.pageActions)?void 0:u.triggers)?l:[]),b=new rM(y,_,v,e),w=function(t){var n,r;t&&(e.pageActions=(0,Q.__assign)((0,Q.__assign)({},e.pageActions),t),y=rA(Object.values(null!=(n=e.pageActions.labeledEvents)?n:{})),_=rD(null!=(r=e.pageActions.triggers)?r:[]),b.update(y,_,e))};return{name:h,type:"enrichment",setup:function(t,n){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var r,i,o,s,a,u,l,c,f,y;return(0,Q.__generator)(this,function(_){var S,E,k,T,I,C,P,O,R,x,A,D,L,M,N,U,q,j,F,B,H,W,z,G,K,V;return"u"50||e.xMax-e.xMin>50}function rK(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:(0,Q.__assign)({"[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}}var rv=n5;(c=q||(q={})).INCREASING="increasing",c.DECREASING="decreasing",(d=j||(j={})).X="x",d.Y="y";var rV=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new rv.default(function(e){var n=null,r=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};if(null===n){n=o;return}o.x>n.x?(r===q.DECREASING&&e.next(j.X),r=q.INCREASING):o.xn.y?(i===q.DECREASING&&e.next(j.Y),i=q.INCREASING):o.yc&&l.shift();var t,r,l,c,d=function(e,t){var n=void 0;if(rJ(e)&&(n=e.startTime),rJ(t)){var r=t.startTime;r&&(!n||r0&&r[r.length-1].closestTrackedAncestor!==e.closestTrackedAncestor||(o=Math.max(0,(i=a).length-4+1),s=i[o],e.timestamp-s.timestamp>=1e3)||u.isOutOfBounds)?(l&&(t=rK(a)),c(e)):a.push(e),(l&&(clearTimeout(l.timerId),l.resolve(t),l=null),a.length>=4)?[2,new Promise(function(e){l={resolve:e,timerId:setTimeout(function(){e(rK(a))},1e3)}})]:[2,null]})})}),f=null==s?void 0:s.subscribe(function(){c()}),g=d.subscribe(function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){g.unsubscribe(),null==f||f.unsubscribe()}}}({allObservables:p,amplitude:g,shouldTrackRageClick:rc(e,u)}),r.push(v)),o&&(T=(k={amplitude:g,allObservables:p,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:rc(e,l)}).amplitude,I=k.allObservables,C=k.getEventProperties,P=k.shouldTrackDeadClick,O=I.clickObservable,R=I.mutationObservable,x=I.navigateObservable,A=O.filter(function(e){return rh(e)&&P("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===N.LEFT_OR_TOUCH_CONTACT}),D=x?n8(R,x):R,L=n8(A,D),M=null,m=n6(L,function(e){if(M&&rz.includes(e.type))clearTimeout(M),M=null;else if("click"===e.type)return M?Promise.resolve(null):new Promise(function(t){M=setTimeout(function(){t(e),M=null},3e3)});return Promise.resolve(null)}).subscribe(function(e){if(e){var t={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};T.track("[Amplitude] Dead Click",(0,Q.__assign)((0,Q.__assign)({},C("click",e.closestTrackedAncestor)),t),{time:e.timestamp})}}),r.push(m)),i&&(q=(U={amplitude:g,allObservables:p,shouldTrackErrorClick:rc(e,c)}).amplitude,j=U.allObservables,F=U.shouldTrackErrorClick,B=j.clickObservable,H=j.browserErrorObservable,W=B.filter(function(e){return rh(e)&&F("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===N.LEFT_OR_TOUCH_CONTACT}),z=null,G=null,K=function(){null!==z&&(clearTimeout(z),z=null),G=null},y=n8(W,H).subscribe(function(e){var t;if("click"===e.type){K(),G=e,z=setTimeout(K,2e3);return}"error"===e.type&&G&&(q.track("[Amplitude] Error Click",(0,Q.__assign)(((t={})["[Amplitude] Kind"]=e.event.kind,t["[Amplitude] Message"]=e.event.message,t["[Amplitude] Stack"]=e.event.stack,t["[Amplitude] Filename"]=e.event.filename,t["[Amplitude] Line Number"]=e.event.lineNumber,t["[Amplitude] Column Number"]=e.event.columnNumber,t),G.targetElementProperties)),K())}),r.push(y)),a&&(_=void 0,b=void 0,"object"==typeof e.thrashedCursor&&(_=e.thrashedCursor.directionChanges,b=e.thrashedCursor.threshold,_&&_<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(_," is below the minimum of ").concat(5,", setting to ").concat(5)),_=5),b&&b>4e3&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(b," is above the maximum of ").concat(4e3,", setting to ").concat(4e3)),b=4e3)),w=rQ({amplitude:g,options:e,allObservables:p,directionChanges:_,thresholdMs:b}),r.push(w)),null==(S=null==t?void 0:t.loggerProvider)||S.log("".concat(n," has been successfully added.")),[2])})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,i;return(0,Q.__generator)(this,function(o){try{for(t=(e=(0,Q.__values)(r)).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 r1(e,t,n){e&&function e(t){var n,r,i=t.json,o=t.targetObject,s=t.allowlist,a=t.excludelist,u=t.ancestors,l=t.parentObject,c=t.targetKey;o||(o=i);var d=Object.keys(o);try{for(var f=(0,Q.__values)(d),g=f.next();!g.done;g=f.next()){var h,p=g.value,v=(0,Q.__spreadArray)((0,Q.__spreadArray)([],(0,Q.__read)(u),!1),[p],!1);(h=o[p],"string"==typeof h||"number"==typeof h||"boolean"==typeof h||null==h)?(!r3(v,s)||r3(v,a))&&delete o[p]:e({json:i,targetObject:o[p],allowlist:s,excludelist:a,ancestors:v,parentObject:o,targetKey:p})}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}0===Object.keys(o).length&&l&&c&&delete l[c]}({json:e,allowlist:t.map(r2),excludelist:n.map(r2),ancestors:[]})}function r2(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function r3(e,t){return t.some(function(t){return function e(t,n,r,i){if(void 0===r&&(r=0),void 0===i&&(i=0),i===n.length)return r===t.length;if(r===t.length){for(;i=t)return}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}i=u}else if(e instanceof ReadableStream){o=e;return}return i}}var r8=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)||t.call(n,function(e,t){r[t]=e}),it(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){if(void 0!==this._bodySize)return this._bodySize;var e,t,n=null==(t=null==(e=this.response.headers)?void 0:e.get)?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(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){switch(e.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,Promise.race([this.clonedResponse.text(),new Promise(function(e){return setTimeout(function(){return e(null)},500)})])];case 2:return[2,e.sent()];case 3:return e.sent(),[2,null];case 4:return[2]}})})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(0===e.length)return[2,null];return[4,this.text()];case 1:return[2,r9(n.sent(),e,t)]}})})},e}(),r7=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){if(void 0===e&&(e=[]),!this.headersString)return{};var t,n,r={},i=this.headersString.split("\r\n");try{for(var o=(0,Q.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value,u=(0,Q.__read)(a.split(": "),2),l=u[0],c=u[1];l&&c&&(r[l]=c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return it(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Q.__awaiter)(this,void 0,void 0,function(){var n;return(0,Q.__generator)(this,function(r){return 0===e.length?[2,null]:(n=this.getJson())?(r1(n,e,t),[2,n]):[2,null]})})},e}();function r9(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return r1(r,t,n),r}catch(e){return null}}(f=F||(F={})).REDACT="redact",f.REMOVE="remove";var ie="[REDACTED]",it=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?F.REMOVE:s,u=(0,Q.__spreadArray)([],(0,Q.__read)(eE),!1),l={};try{for(var c=(0,Q.__values)(Object.keys(e)),d=c.next();!d.done;d=c.next()){var f=d.value;!function(t){var n=t.toLowerCase();u.find(function(e){return e.toLowerCase()===n})?a===F.REDACT&&(l[t]=ie):o.find(function(e){return e.toLowerCase()===n})?l[t]=e[t]:a===F.REDACT&&(l[t]=ie)}(f)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return l},ir=function(){function e(e,t,n,r,i,o,s,a,u,l,c){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=u,this.error=l,this.endTime=c}return e.prototype.toSerializable=function(){var e,t,n,r;return Object.fromEntries(Object.entries({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.headers((0,Q.__spreadArray)([],(0,Q.__read)(eS),!1)),requestBodySize:null==(t=this.requestWrapper)?void 0:t.bodySize,responseHeaders:null==(n=this.responseWrapper)?void 0:n.headers((0,Q.__spreadArray)([],(0,Q.__read)(eS),!1)),responseBodySize:null==(r=this.responseWrapper)?void 0:r.bodySize}).filter(function(e){var t=(0,Q.__read)(e,2);return void 0!==(t[0],t[1])}))},e}(),ii=function(e,t){void 0===t&&(t=ex()),this.callback=e,this.id=t};function io(e){try{e()}catch(e){}}var is=new(function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=(0,eO.getGlobalScope)();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=(0,eO.getGlobalScope)();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,s,a,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.XMLHttpRequest)?void 0:r.prototype)?void 0:i.open,g=null==(a=null==(s=null==(o=this.globalScope)?void 0:o.XMLHttpRequest)?void 0:s.prototype)?void 0:a.send,h=null==(c=null==(l=null==(u=this.globalScope)?void 0:u.XMLHttpRequest)?void 0:l.prototype)?void 0:c.setRequestHeader;f&&g&&h&&this.observeXhr(f,g,h);var p=null==(d=this.globalScope)?void 0:d.fetch;p&&this.observeFetch(p),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){io(function(){var n;null==(n=t.logger)||n.debug("an unexpected error occurred while triggering event callbacks",e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,s){if(void 0!==o&&void 0!==s){var a,u,l,c,d="GET";if("object"==typeof t&&null!==t&&"url"in t&&"method"in t?(u=t.url,d=t.method):u=null==(a=null==t?void 0:t.toString)?void 0:a.call(t),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 g=Math.floor(performance.now()-s),h=Math.floor(o+g),p=new ir(e,d,o,o,u,n,l,g,r,c,h);this.triggerEventCallbacks(p)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null==(e=Date.now)?void 0:e.call(Date),durationStart:null==(t=null==performance?void 0:performance.now)?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return(0,Q.__awaiter)(t,void 0,void 0,function(){var t,i,o,s=this;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:try{t=this.getTimestamps()}catch(e){io(function(){var t;return null==(t=s.logger)?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)})}a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=a.sent(),[3,4];case 3:return o=a.sent(),[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new r4(r):void 0,i?new r8(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){io(function(){var t;return null==(t=s.logger)?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.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){n instanceof Error&&"InvalidStateError"===n.name&&io(function(){var n;return null==(n=t.logger)?void 0:n.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))})}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n=[],r=0;r=l&&e<=c)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function id(e){var t;if(e)try{var n=null==(t=(0,eO.getGlobalScope)())?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),s=r.href,a=r.host;r.hash="",r.search="";var u=r.href;return{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:u,host:a}}catch(e){return}}function ig(e){return"object"!=typeof e||null===e?e?(0,Q.__spreadArray)([],(0,Q.__read)(eS),!1):void 0:0!==e.length?e:void 0}function ih(e){var t,n;return!(null==(t=null==e?void 0:e.allowlist)?void 0:t.length)&&!(null==(n=null==e?void 0:e.blocklist)?void 0:n.length)}(B||(B={})).NetworkObservable="networkObservable";var ip=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new rv.default(function(e){var n=new ii(function(t){var n={event:t,timestamp:Date.now(),type:"network"};e.next(n)});return is.subscribe(n,t),function(){is.unsubscribe(n)}});return(e={})[B.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var s;return(0,Q.__generator)(this,function(a){var u,l,c,d,f;return"u"{addEventListener("pageshow",t=>{t.persisted&&(iv=t.timeStamp,e(t))},!0)},iy=(e,t,n,r)=>{let i,o;return s=>{let a;t.value>=0&&(s||r)&&((o=t.value-(i??0))||void 0===i)&&(i=t.value,t.delta=o,a=t.value,t.rating=a>n[1]?"poor":a>n[0]?"needs-improvement":"good",e(t))}},i_=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},ib=()=>{let e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart{let e=ib();return e?.activationStart??0},iS=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=ib(),r="navigate";return iv>=0?r="back-forward-cache":n&&(document.prerendering||iw()>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(0x82f79cd8fff*Math.random())+1e12}`,navigationType:r}},iE=new WeakMap;function ik(e,t){return iE.get(e)||iE.set(e,new t),iE.get(e)}class iT{t;i=0;o=[];h(e){if(e.hadRecentInput)return;let 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)}}let iI=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{Promise.resolve().then(()=>{t(e.getEntries())})});return r.observe({type:e,buffered:!0,...n}),r}}catch{}},iC=e=>{let t=!1;return()=>{t||(e(),t=!0)}},iP=-1,iO=new Set,iR=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,ix=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(let e of iO)e();isFinite(iP)||(iP="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",ix,!0))}},iA=()=>{if(iP<0){let e=iw();iP=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime)??iR(),addEventListener("visibilitychange",ix,!0),addEventListener("prerenderingchange",ix,!0),im(()=>{setTimeout(()=>{iP=iR()})})}return{get firstHiddenTime(){return iP},onHidden(e){iO.add(e)}}},iD=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},iL=[1800,3e3],iM=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};iD(()=>{let n=iA(),r,i=iS("FCP"),o=iI("paint",e=>{for(let t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime{r=iy(e,i=iS("FCP"),iL,t.reportAllChanges),i_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},iN=[.1,.25],iU=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=iA();iM(iC(()=>{let r,i=iS("CLS",0),o=ik(t,iT),s=e=>{for(let t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},a=iI("layout-shift",s);a&&(r=iy(e,i,iN,t.reportAllChanges),n.onHidden(()=>{s(a.takeRecords()),r(!0)}),im(()=>{o.i=0,r=iy(e,i=iS("CLS",0),iN,t.reportAllChanges),i_(()=>r())}),setTimeout(r))}))},iq=0,ij=1/0,iF=0,iB=e=>{for(let t of e)t.interactionId&&(ij=Math.min(ij,t.interactionId),iq=(iF=Math.max(iF,t.interactionId))?(iF-ij)/7+1:0)},iH=()=>t?iq:performance.interactionCount??0,iW=0;class iz{u=[];l=new Map;m;p;v(){iW=iH(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((iH()-iW)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;let t=this.u.at(-1),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)for(let e of this.u.splice(10))this.l.delete(e.id);this.p?.(n)}}}let iG=e=>{let t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(addEventListener("visibilitychange",e=iC(e),{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},iK=[200,500],iV=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let r=iA();iD(()=>{"interactionCount"in performance||t||(t=iI("event",iB,{type:"event",buffered:!0,durationThreshold:0}));let i,o=iS("INP"),s=ik(n,iz),a=e=>{iG(()=>{for(let t of e)s.h(t);let t=s.L();t&&t.P!==o.value&&(o.value=t.P,o.entries=t.entries,i())})},u=iI("event",a,{durationThreshold:n.durationThreshold??40});i=iy(e,o,iK,n.reportAllChanges),u&&(u.observe({type:"first-input",buffered:!0}),r.onHidden(()=>{a(u.takeRecords()),i(!0)}),im(()=>{s.v(),i=iy(e,o=iS("INP"),iK,n.reportAllChanges)}))})};class iJ{m;h(e){this.m?.(e)}}let i$=[2500,4e3],iY=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};iD(()=>{let n=iA(),r,i=iS("LCP"),o=ik(t,iJ),s=e=>{for(let s of(t.reportAllChanges||(e=e.slice(-1)),e))o.h(s),s.startTime{s(a.takeRecords()),a.disconnect(),r(!0)}),o=e=>{e.isTrusted&&(iG(n),removeEventListener(e.type,o,{capture:!0}))};for(let e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});im(n=>{r=iy(e,i=iS("LCP"),i$,t.reportAllChanges),i_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})},iX=[800,1800],iQ=e=>{document.prerendering?iD(()=>iQ(e)):"complete"!==document.readyState?addEventListener("load",()=>iQ(e),!0):setTimeout(e)},iZ=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=iS("TTFB"),r=iy(e,n,iX,t.reportAllChanges);iQ(()=>{let i=ib();i&&(n.value=Math.max(i.responseStart-iw(),0),n.entries=[i],r(!0),im(()=>{(r=iy(e,n=iS("TTFB",0),iX,t.reportAllChanges))(!0)}))})};function i0(e){var t,n;return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor((n=(null==(t=e.entries[0])?void 0:t.startTime)||0,performance.timeOrigin+n)),navigationStart:Math.floor(performance.timeOrigin)}}var i1=function(){var e=null,t=(0,eO.getGlobalScope)(),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(0,Q.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Q.__generator)(this,function(a){return void 0===n||(o=rs((null==r?void 0:r.href)||"",t.loggerProvider),s={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":rs((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"u">typeof document&&document.title||"","[Amplitude] Page URL":rs(o.split("?")[0],t.loggerProvider)},iY(function(e){s["[Amplitude] LCP"]=i0(e)}),iM(function(e){s["[Amplitude] FCP"]=i0(e)}),iV(function(e){s["[Amplitude] INP"]=i0(e)}),iU(function(e){s["[Amplitude] CLS"]=i0(e)}),iZ(function(e){s["[Amplitude] TTFB"]=i0(e)}),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",s),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},i2=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),["AMP",t,e.substring(0,n)].filter(Boolean).join("_")},i3=function(){function e(e,t){var n;this.shouldTrackNewCampaign=!1,this.options=(0,Q.__assign)({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:nm((null==(n=t.cookieOptions)?void 0:n.domain)||t.topLevelDomain),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=i2(t.apiKey,"MKTG"),this.webExpStorageKey=i2(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=ew,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(0,Q.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(this.options.optOut)return[2];return[4,this.fetchCampaign()];case 1:if(t=Q.__read.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||e9(this.sessionTimeout,this.lastEventTime),!nh(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain))return[3,3];return this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:if(!(e=t.sent()))return[3,3];return[4,this.storage.remove(this.webExpStorageKey)];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||new nL().parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r=(t=this.currentCampaign,n=this.options,eD(Object.entries((0,Q.__assign)((0,Q.__assign)({},ew),t)).reduce(function(e,t){var r,i=(0,Q.__read)(t,2),o=i[0],s=i[1];return(e.setOnce("initial_".concat(o),null!=(r=null!=s?s:n.initialEmptyValue)?r:"EMPTY"),s)?e.set(o,s):e.unset(o)},new eI)));return e&&(r.event_id=e),r},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),i4="AMP_CURRENT_PAGE",i5="AMP_PREVIOUS_PAGE",i6="AMP_URL_INFO";(g=W||(W={})).Direct="direct",g.Internal="internal",g.External="external";var i8=new Set([x.IDENTIFY,x.GROUP_IDENTIFY,x.REVENUE]),i7=function(e){var t=(void 0===e?{}:e).internalDomains,n=void 0===t?[]:t,r=(0,eO.getGlobalScope)(),i=void 0,o=!1,s=void 0,a=!1,u=!1,l=function(e){var t;try{var n=rs(e,s);t=new URL(n).hostname}catch(e){null==s||s.error("Could not parse URL: ",e)}return t},c=function(e){var t="u">typeof location&&location.hostname||"",r=e?l(e):void 0;if(!r)return W.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?W.Internal:W.External},d=function(){(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:if(!(i&&o))return[3,3];return[4,i.get(i6)];case 1:return e=a.sent(),t=rs("u">typeof location&&location.href||""),n=(null==e?void 0:e[i4])||"",r=void 0,r=t===n?(null==e?void 0:e[i5])||"":n||document.referrer||"",[4,i.set(i6,((s={})[i4]=t,s[i5]=r,s))];case 2:a.sent(),a.label=3;case 3:return[2]}})})};return{name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){switch(t.label){case 0:if((s=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),u=!0,!r)return[3,2];return[4,(i=new tY(r.sessionStorage)).isEnabled()];case 1:o=t.sent(),r.addEventListener("popstate",d),a||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=(0,Q.__read)(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),u&&d()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=(0,Q.__read)(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),u&&d()}}),a=!0),t.label=2;case 2:return[2]}})})},execute:function(e){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var t,n,r,s,a;return(0,Q.__generator)(this,function(u){switch(u.label){case 0:if(t=rs("u">typeof location&&location.href||""),!(i&&o))return[3,5];return[4,i.get(i6)];case 1:if(null==(n=u.sent())?void 0:n[i4])return[3,3];return[4,i.set(i6,((a={})[i4]=t,a[i5]=document.referrer||"",a))];case 2:u.sent(),u.label=3;case 3:return[4,i.get(i6)];case 4:if(r=u.sent(),s="",r&&(s=r[i5]||""),i8.has(e.event_type))return[2,e];e.event_properties=(0,Q.__assign)((0,Q.__assign)({},e.event_properties||{}),{"[Amplitude] Page Domain":i9(e,"[Amplitude] Page Domain","u">typeof location&&location.hostname||""),"[Amplitude] Page Location":i9(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":i9(e,"[Amplitude] Page Path","u">typeof location&&rs(location.pathname)||""),"[Amplitude] Page Title":i9(e,"[Amplitude] Page Title",nD(nA)),"[Amplitude] Page URL":i9(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":s,"[Amplitude] Previous Page Type":c(s)}),u.label=5;case 5:return[2,e]}})})},teardown:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){switch(e.label){case 0:if(r&&(r.removeEventListener("popstate",d),u=!1),!(i&&o))return[3,2];return[4,i.set(i6,{})];case 1:e.sent(),e.label=2;case 2:return[2]}})})}}};function i9(e,t,n){return(e.event_properties||(e.event_properties={}),void 0===e.event_properties[t])?n:e.event_properties[t]}let oe={init:er((h=new(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t._enableRequestBodyCompressionExperimentalValue=!1,t}return(0,Q.__extends)(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),eN(this._init((0,Q.__assign)((0,Q.__assign)({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o,s,a,u,l;return(0,Q.__awaiter)(this,void 0,void 0,function(){var c,d,f,g,h,p,v,m,y,_,b,w,S,E,k=this;return(0,Q.__generator)(this,function(T){var I,C,P,R,x,A;switch(T.label){case 0:if(this.initializing)return[2];if(this.initializing=!0,c=nT(t),d=null!=(n=t.loggerProvider)?n:new eF,t.loggerProvider||d.enable(null!=(r=t.logLevel)?r:O.Warn),f=null!=(i=t.serverZone)?i:"US",h=this._diagnosticsSampleRate,p=null==(o=t.enableDiagnostics)||o,!c)return[3,2];return g=new ti(t.apiKey,d,f,null==(s=t.remoteConfig)?void 0:s.serverUrl),[4,new Promise(function(e){null==g||g.subscribe("configs.diagnostics.browserSDK","all",function(t,n,r){if(d.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)||(h=i);var o=t.enabled;"boolean"==typeof o&&(p=o)}e()})})];case 1:T.sent(),T.label=2;case 2:return(v=new t_(t.apiKey,d,f,{enabled:p,sampleRate:h})).setTag("library","".concat(tF,"/").concat(tj)),"u">typeof navigator&&v.setTag("user_agent",navigator.userAgent),[4,(I=t.apiKey,C=t,P=this,R=v,x={loggerProvider:d,serverZone:f,enableDiagnostics:p,diagnosticsSampleRate:h},void 0===C&&(C={}),(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s,a,u,l,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,T,O,A,D,L,M,N,U,q,j,F,B,H,W,z,G,K,V,J,$,Y,X,Z,ee,et,en;return(0,Q.__generator)(this,function(er){var ei,eo,es,ea;switch(er.label){case 0:if(e=C.identityStorage||nd,t="",!(e===nd&&!(null==(w=C.cookieOptions)?void 0:w.domain)&&(null==(S=C.cookieOptions)?void 0:S.domain)!==""))return[3,2];return[4,(ei=void 0,eo=R,(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,r,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:return[4,new tz(void 0,{diagnosticsClient:eo}).isEnabled()];case 1:if(!a.sent()||!ei&&("u"=0;--i)n.push(t.slice(i).join("."));i=0,a.label=2;case 2:if(!(i1)&&!(e<0)&&!this.config){this._diagnosticsSampleRate=e;return}},t.prototype._enableRequestBodyCompressionExperimental=function(e){if(!this.config){this._enableRequestBodyCompressionExperimentalValue=e;return}},t}(eU))).init.bind(h),"init",ee(h),en(h,["config"])),add:er(h.add.bind(h),"add",ee(h),en(h,["config.apiKey","timeline.plugins"])),remove:er(h.remove.bind(h),"remove",ee(h),en(h,["config.apiKey","timeline.plugins"])),track:er(h.track.bind(h),"track",ee(h),en(h,["config.apiKey","timeline.queue.length"])),logEvent:er(h.logEvent.bind(h),"logEvent",ee(h),en(h,["config.apiKey","timeline.queue.length"])),identify:er(h.identify.bind(h),"identify",ee(h),en(h,["config.apiKey","timeline.queue.length"])),groupIdentify:er(h.groupIdentify.bind(h),"groupIdentify",ee(h),en(h,["config.apiKey","timeline.queue.length"])),setGroup:er(h.setGroup.bind(h),"setGroup",ee(h),en(h,["config.apiKey","timeline.queue.length"])),revenue:er(h.revenue.bind(h),"revenue",ee(h),en(h,["config.apiKey","timeline.queue.length"])),flush:er(h.flush.bind(h),"flush",ee(h),en(h,["config.apiKey","timeline.queue.length"])),getUserId:er(h.getUserId.bind(h),"getUserId",ee(h),en(h,["config","config.userId"])),setUserId:er(h.setUserId.bind(h),"setUserId",ee(h),en(h,["config","config.userId"])),getDeviceId:er(h.getDeviceId.bind(h),"getDeviceId",ee(h),en(h,["config","config.deviceId"])),setDeviceId:er(h.setDeviceId.bind(h),"setDeviceId",ee(h),en(h,["config","config.deviceId"])),reset:er(h.reset.bind(h),"reset",ee(h),en(h,["config","config.userId","config.deviceId"])),getSessionId:er(h.getSessionId.bind(h),"getSessionId",ee(h),en(h,["config"])),setSessionId:er(h.setSessionId.bind(h),"setSessionId",ee(h),en(h,["config"])),extendSession:er(h.extendSession.bind(h),"extendSession",ee(h),en(h,["config"])),setOptOut:er(h.setOptOut.bind(h),"setOptOut",ee(h),en(h,["config"])),setTransport:er(h.setTransport.bind(h),"setTransport",ee(h),en(h,["config"])),getIdentity:er(h.getIdentity.bind(h),"getIdentity",ee(h),en(h,["config"])),setIdentity:er(h.setIdentity.bind(h),"setIdentity",ee(h),en(h,["config","config.userId","config.deviceId"])),getOptOut:er(h.getOptOut.bind(h),"getOptOut",ee(h),en(h,["config"])),_setDiagnosticsSampleRate:er(h._setDiagnosticsSampleRate.bind(h),"_setDiagnosticsSampleRate",ee(h),en(h,["config"])),_enableRequestBodyCompressionExperimental:er(h._enableRequestBodyCompressionExperimental.bind(h),"_enableRequestBodyCompressionExperimental",ee(h),en(h,["config"]))};e.s([],219814),e.i(219814),(p=z||(z={})).US="US",p.EU="EU",p.STAGING="STAGING",e.s(["DEFAULT_ACTION_CLICK_ALLOWLIST",()=>nY,"DEFAULT_CSS_SELECTOR_ALLOWLIST",()=>nJ,"DEFAULT_DATA_ATTRIBUTE_PREFIX",()=>n$,"EXCLUDE_INTERNAL_REFERRERS_CONDITIONS",()=>nf,"IdentifyOperation",()=>R,"LogLevel",()=>O,"OfflineDisabled",()=>null,"RevenueProperty",()=>L,"ServerZone",()=>z,"SpecialEventType",()=>x],67106),e.i(67106);var ot=oe.add,on=(oe.extendSession,oe.flush,oe.getDeviceId,oe.getIdentity,oe.getOptOut,oe.getSessionId,oe.getUserId,oe.groupIdentify,oe.identify),or=oe.init,oi=(oe.logEvent,oe.remove,oe.reset),oo=(oe.revenue,oe.setDeviceId,oe.setGroup,oe.setIdentity,oe.setOptOut,oe.setSessionId,oe.setTransport,oe.setUserId),os=oe.track;oe._setDiagnosticsSampleRate,oe._enableRequestBodyCompressionExperimental,e.s(["add",()=>ot,"identify",()=>on,"init",()=>or,"reset",()=>oi,"setUserId",()=>oo,"track",()=>os],759730);var oa=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return(0,Q.__extends)(t,e),t.prototype.send=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){var n,r;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:if("u"0?(Object.prototype.hasOwnProperty.call(s,"capture_enabled")?r.captureEnabled=s.capture_enabled:r.captureEnabled=!1,Object.prototype.hasOwnProperty.call(s,"sample_rate")&&(r.sampleRate=s.sample_rate)):(r.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),a){l=null!=(e=r.privacyConfig)?e:{},c={defaultMaskLevel:null!=(n=null!=(t=a.defaultMaskLevel)?t:l.defaultMaskLevel)?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},d=function(e){var t,n,r,i,o,s,a,u,l,c={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var d=(0,Q.__values)(null!=(a=e.blockSelector)?a:[]),f=d.next();!f.done;f=d.next()){var g=f.value;c[g]="block"}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}try{for(var h=(0,Q.__values)(null!=(u=e.maskSelector)?u:[]),p=h.next();!p.done;p=h.next()){var g=p.value;c[g]="mask"}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}try{for(var v=(0,Q.__values)(null!=(l=e.unmaskSelector)?l:[]),m=v.next();!m.done;m=v.next()){var g=m.value;c[g]="unmask"}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}return c},f=(0,Q.__assign)((0,Q.__assign)({},d(l)),d(a));try{for(h=(g=(0,Q.__values)(Object.entries(f))).next();!h.done;h=g.next())v=(p=(0,Q.__read)(h.value,2))[0],m=p[1],"mask"===m?c.maskSelector.push(v):"block"===m?c.blockSelector.push(v):"unmask"===m&&c.unmaskSelector.push(v)}catch(e){y={error:e}}finally{try{h&&!h.done&&(_=g.return)&&_.call(g)}finally{if(y)throw y.error}}r.privacyConfig=oN(c,this.localConfig.loggerProvider)}return u&&Object.keys(u).length>0&&(r.targetingConfig=u),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:oT(r)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:i}]}})})},e}(),oq=Uint8Array,oj=Uint16Array,oF=Uint32Array,oB=new oq([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oH=new oq([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),oW=new oq([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oz=function(e,t){for(var n=new oj(31),r=0;r<31;++r)n[r]=t+=1<>>1|(21845&oX)<<1;oQ=(61680&(oQ=(52428&oQ)>>>2|(13107&oQ)<<2))>>>4|(3855&oQ)<<4,oY[oX]=((65280&oQ)>>>8|(255&oQ)<<8)>>>1}for(var oZ=function(e,t,n){for(var r,i=e.length,o=0,s=new oj(t);o>>u]=l}else for(o=0,r=new oj(i);o>>15-e[o];return r},o0=new oq(288),oX=0;oX<144;++oX)o0[oX]=8;for(var oX=144;oX<256;++oX)o0[oX]=9;for(var oX=256;oX<280;++oX)o0[oX]=7;for(var oX=280;oX<288;++oX)o0[oX]=8;for(var o1=new oq(32),oX=0;oX<32;++oX)o1[oX]=5;var o2=oZ(o0,9,0),o3=oZ(o1,5,0),o4=function(e){return(e/8|0)+(7&e&&1)},o5=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof oj?oj:e instanceof oF?oF:oq)(n-t);return r.set(e.subarray(t,n)),r},o6=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},o8=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},o7=function(e,t){for(var n=[],r=0;rf&&(f=o[r].s);var g=new oj(f+1),h=o9(n[c-1],g,0);if(h>t){var r=0,p=0,v=h-t,m=1<t)p+=m-(1<>>=v;p>0;){var _=o[r].s;g[_]=0&&p;--r){var b=o[r].s;g[b]==t&&(--g[b],++p)}h=t}return[new oq(g),h]},o9=function(e,t,n){return -1==e.s?Math.max(o9(e.l,t,n+1),o9(e.r,t,n+1)):t[e.s]=n},se=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new oj(++t),r=0,i=e[0],o=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==i&&a!=t)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=e[a]}return[n.subarray(0,r),t]},st=function(e,t){for(var n=0,r=0;r>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var o=0;o4&&!R[oW[A-1]];--A);var D=l+5<<3,L=st(i,o0)+st(o,o1)+s,M=st(i,v)+st(o,_)+s+14+3*A+st(C,R)+(2*C[16]+3*C[17]+7*C[18]);if(D<=L&&D<=M)return sn(t,c,e.subarray(u,u+l));if(o6(t,c,1+(M15&&(o6(t,c,j[P]>>>5&127),c+=j[P]>>>12)}}else d=o2,f=o0,g=o3,h=o1;for(var P=0;P255){var F=r[P]>>>18&31;o8(t,c,d[F+257]),c+=f[F+257],F>7&&(o6(t,c,r[P]>>>23&31),c+=oB[F]);var B=31&r[P];o8(t,c,g[B]),c+=h[B],B>3&&(o8(t,c,r[P]>>>5&8191),c+=oH[B])}else o8(t,c,d[r[P]]),c+=f[r[P]];return o8(t,c,d[256]),c+f[256]},si=new oF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),so=function(e,t,n,r,i,o){var s=e.length,a=new oq(r+s+5*(1+Math.floor(s/7e3))+i),u=a.subarray(r,a.length-i),l=0;if(!t||s<8)for(var c=0;c<=s;c+=65535){var d=c+65535;d>>13,h=8191&f,p=(1<7e3||I>24576)&&A>423){l=sr(e,u,0,w,S,E,T,I,P,c-P,l),I=k=T=0,P=c;for(var D=0;D<286;++D)S[D]=0;for(var D=0;D<30;++D)E[D]=0}var L=2,M=0,N=h,U=R-x&32767;if(A>2&&O==b(c-U))for(var q=Math.min(g,A)-1,j=Math.min(32767,c),F=Math.min(258,A);U<=j&&--N&&R!=x;){if(e[c+L]==e[c+L-U]){for(var B=0;BL){if(L=B,M=U,B>q)break;for(var H=Math.min(U,B-2),W=0,D=0;DW&&(W=K,x=z)}}}x=v[R=x],U+=R-x+32768&32767}if(M){w[I++]=0x10000000|oV[L]<<18|o$[M];var V=31&oV[L],J=31&o$[M];T+=oB[V]+oH[J],++S[257+V],++E[J],C=c+L,++k}else w[I++]=e[c],++S[e[c]]}}l=sr(e,u,o,w,S,E,T,I,P,c-P,l)}return o5(a,0,r+o4(l)+i)},ss=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,o=n.length,s=0;s!=o;){for(var a=Math.min(s+5552,o);s>>8<<16|(255&t)<<8|t>>>8)+((255&e)<<23)*2}}},sa=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},su=function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)},sl=function(){function e(e,t,n,r){var i,o=this;this.taskQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t,n,r,i,o;return JSON.stringify(function(e,t){var n="";if(!t&&"u">typeof TextDecoder)return new TextDecoder().decode(e);for(var r=0;r>10,56320|1023&i)}return n}((t=function(e,t){var n=e.length;if("u">typeof TextEncoder)return new TextEncoder().encode(e);for(var r=new oq(e.length+(e.length>>>1)),i=0,o=function(e){r[i++]=e},s=0;sr.length){var a=new oq(i+8+(n-s<<1));a.set(r),r=a}var u=e.charCodeAt(s);u<128?o(u):(u<2048?o(192|u>>>6):(u>55295&&u<57344?(o(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++s))>>>18),o(128|u>>>12&63)):o(224|u>>>12),o(128|u>>>6&63)),o(128|63&u))}return o5(r,0,i)}(JSON.stringify({...e,v:"v1"})),void 0===n&&(n={}),(r=ss()).p(t),su(o=so(t,null==(i=n).level?6:i.level,null==i.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+i.mem,2,4,!0),n),sa(o,o.length-4,r.d()),o),!0))},this.addCompressedEventToManager=function(e,t){o.eventsManager&&o.deviceId&&o.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:o.deviceId})},this.addCompressedEvent=function(e,t){if(o.worker)try{o.worker.postMessage({event:e,sessionId:t})}catch(n){"DataCloneError"===n.name?o.worker.postMessage(JSON.stringify({event:e,sessionId:t})):o.config.loggerProvider.warn("Unexpected error while posting message to worker:",n)}else{var n=o.compressEvent(e);o.addCompressedEventToManager(n,t)}},this.terminate=function(){var e;null==(e=o.worker)||e.terminate()};var s=(0,eO.getGlobalScope)();if(this.canUseIdleCallback=s&&"requestIdleCallback"in s,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null==(i=t.performanceConfig)?void 0:i.timeout)||2e3,r){t.loggerProvider.log("Enabling web worker for compression");try{var a=new Blob([r],{type:"application/javascript"}),u=URL.createObjectURL(a),l=new Worker(u);l.onerror=function(e){e.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression:",e),l.terminate(),o.worker=void 0},l.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;o.addCompressedEventToManager(n,r)},this.worker=l}catch(e){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",e)}}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n;this.canUseIdleCallback&&(null==(n=this.config.performanceConfig)?void 0:n.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.taskQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){for(var t=this;this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var n=this.taskQueue.shift();if(n){var r=n.event,i=n.sessionId;this.addCompressedEvent(r,i)}}this.taskQueue.length>0?requestIdleCallback(function(e){t.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e}(),sc="Session replay event batch rejected due to exceeded retry count",sd="Failed to store session replay events in IndexedDB",sf="1.32.1",sg=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t}return e.prototype.sendEventsList=function(e){this.addToQueue((0,Q.__assign)((0,Q.__assign)({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n0&&t.schedule(e)})},e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),a.label=1;case 1:a.trys.push([1,6,7,8]),r=(n=(0,Q.__values)(t)).next(),a.label=2;case 2:if(r.done)return[3,5];return i=r.value,[4,this.send(i,e)];case 3:a.sent(),a.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o={error:a.sent()},[3,8];case 7:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}return[7];case 8:return[2]}})})},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t=!0),(0,Q.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u,l,c,d,f,g,h,p;return(0,Q.__generator)(this,function(v){switch(v.label){case 0:if(!(i=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(o=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(s=o_(),a=sf,u=e.sampleRate,l=new URLSearchParams({device_id:o,session_id:"".concat(e.sessionId),type:"".concat(e.type)}),c="".concat((null==(n=e.version)?void 0:n.type)||"standalone","/").concat((null==(r=e.version)?void 0:r.version)||a),0===(d=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];v.label=1;case 1:return v.trys.push([1,6,,7]),f={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(i),"X-Client-Version":a,"X-Client-Library":c,"X-Client-Url":s.substring(0,1e3),"X-Client-Sample-Rate":"".concat(u)},body:JSON.stringify(d),method:"POST"},[4,fetch("".concat(ob(e.serverZone,this.trackServerUrl),"?").concat(l.toString()),f)];case 2:if(null===(g=v.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)return[3,3];h="";try{h=JSON.stringify(g.body,null,2)}catch(e){}return this.completeRequest({context:e,success:"".concat(g.status,": ").concat(h)}),[3,5];case 3:return[4,this.handleReponse(g.status,e)];case 4:v.sent(),v.label=5;case 5:return[3,7];case 6:return p=v.sent(),this.completeRequest({context:e,err:p}),[3,7];case 7:return[2]}})})},e.prototype.handleReponse=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){switch(n.label){case 0:switch(new tZ().buildStatus(e)){case D.Success:return[3,1];case D.Failed:return[3,2]}return[3,4];case 1:return this.handleSuccessResponse(t),[3,5];case 2:return[4,this.handleOtherResponse(t)];case 3:return n.sent(),[3,5];case 4:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),n.label=5;case 5:return[2]}})})},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(t=e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0))return this.completeRequest({context:e,err:sc}),[2];return[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}(),sh=e.i(601217),sp=function(){function e(e){var t,n,r,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=1e6,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>=i.maxPersistedEventsSize||Date.now()-i.timeAtLastSplit>i.interval&&!!e.length&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!=(t=e.minInterval)?t:this.minInterval,this.maxInterval=null!=(n=e.maxInterval)?n:this.maxInterval,this.maxPersistedEventsSize=null!=(r=e.maxPersistedEventsSize)?r:this.maxPersistedEventsSize}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){return e.length},e.prototype.getEventsArraySize=function(e){var t,n,r=0;try{for(var i=(0,Q.__values)(e),o=i.next();!o.done;o=i.next()){var s=o.value;r+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}(),sv=function(e,t,n){"object"==typeof n&&null!==n&&"AbortError"===n.name?e.debug(t):e.warn(t)},sm="sessionCurrentSequence",sy="sequencesToSend",s_=function(e){var t,n;return e.objectStoreNames.contains(sm)||(n=e.createObjectStore(sm,{keyPath:"sessionId"})),e.objectStoreNames.contains(sy)||(t=e.createObjectStore(sy,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},sb=function(e){function t(t){var n=e.call(this,t)||this;return n.getSequencesToSend=function(){return(0,Q.__awaiter)(n,void 0,void 0,function(){var e,t,n,r,i,o;return(0,Q.__generator)(this,function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),e=[],[4,this.db.transaction("sequencesToSend").store.openCursor()];case 1:t=s.sent(),s.label=2;case 2:if(!t)return[3,4];return r=(n=t.value).sessionId,i=n.events,e.push({events:i,sequenceId:t.key,sessionId:r}),[4,t.continue()];case 3:return t=s.sent(),[3,2];case 4:return[2,e];case 5:return o=s.sent(),sv(this.loggerProvider,"".concat(sd,": ").concat(o),o),[3,6];case 6:return[2,void 0]}})})},n.storeCurrentSequence=function(e){return(0,Q.__awaiter)(n,void 0,void 0,function(){var t,n,r;return(0,Q.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,this.db.get(sm,e)];case 1:if(!(t=i.sent()))return[2,void 0];return[4,this.db.put(sy,{sessionId:e,events:t.events})];case 2:return n=i.sent(),[4,this.db.put(sm,{sessionId:e,events:[]})];case 3:return i.sent(),[2,(0,Q.__assign)((0,Q.__assign)({},t),{sessionId:e,sequenceId:n})];case 4:return r=i.sent(),sv(this.loggerProvider,"".concat(sd,": ").concat(r),r),[3,5];case 5:return[2,void 0]}})})},n.addEventToCurrentSequence=function(e,t){return(0,Q.__awaiter)(n,void 0,void 0,function(){var n,r,i,o,s,a;return(0,Q.__generator)(this,function(u){switch(u.label){case 0:return u.trys.push([0,10,,11]),[4,(n=this.db.transaction(sm,"readwrite")).store.get(e)];case 1:if(r=u.sent())return[3,3];return[4,n.store.put({sessionId:e,events:[t]})];case 2:return u.sent(),[2];case 3:if(i=void 0,!this.shouldSplitEventsList(r.events,t))return[3,5];return i=r.events,[4,n.store.put({sessionId:e,events:[t]})];case 4:return u.sent(),[3,7];case 5:return o=r.events.concat(t),[4,n.store.put({sessionId:e,events:o})];case 6:u.sent(),u.label=7;case 7:return[4,n.done];case 8:if(u.sent(),!i)return[2,void 0];return[4,this.storeSendingEvents(e,i)];case 9:if(!(s=u.sent()))return[2,void 0];return[2,{events:i,sessionId:e,sequenceId:s}];case 10:return a=u.sent(),sv(this.loggerProvider,"".concat(sd,": ").concat(a),a),[3,11];case 11:return[2,void 0]}})})},n.storeSendingEvents=function(e,t){return(0,Q.__awaiter)(n,void 0,void 0,function(){var n;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.db.put(sy,{sessionId:e,events:t})];case 1:return[2,r.sent()];case 2:return n=r.sent(),sv(this.loggerProvider,"".concat(sd,": ").concat(n),n),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(e,t){return(0,Q.__awaiter)(n,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(sy,t)];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),sv(this.loggerProvider,"".concat(sd,": ").concat(e),e),[3,4];case 4:return[2]}})})},n.db=t.db,n}return(0,Q.__extends)(t,e),t.new=function(e,n){return(0,Q.__awaiter)(this,void 0,void 0,function(){var r,i,o;return(0,Q.__generator)(this,function(s){switch(s.label){case 0:var a;return s.trys.push([0,2,,3]),r="replay"===e?"":"_".concat(e),[4,(a="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(r),(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){switch(e.label){case 0:return[4,(0,sh.openDB)(a,1,{upgrade:s_})];case 1:return[2,e.sent()]}})}))];case 1:return i=s.sent(),[2,new t((0,Q.__assign)((0,Q.__assign)({},n),{db:i}))];case 2:return o=s.sent(),sv(n.loggerProvider,"".concat(sd,": ").concat(o),o),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n,r,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:if(!e)return[3,2];return[4,this.db.get("sessionCurrentSequence",e)];case 1:if(!(t=a.sent()))return[2,void 0];return[2,[t]];case 2:n=[],a.label=3;case 3:return a.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:i=(r=Q.__values.apply(void 0,[a.sent()])).next(),a.label=5;case 5:if(i.done)return[3,7];t=i.value,n.push(t),a.label=6;case 6:return i=r.next(),[3,5];case 7:return[3,10];case 8:return o={error:a.sent()},[3,10];case 9:try{i&&!i.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}return[7];case 10:return[2,n]}})})},t}(sp),sw=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return(0,Q.__extends)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,n=(0,Q.__spreadArray)([],(0,Q.__read)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},t.prototype.getSequencesToSend=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return[2,Object.entries(this.finalizedSequences).map(function(e){var t=(0,Q.__read)(e,2),n=t[0],r=t[1],i=r.sessionId,o=r.events;return{sequenceId:Number(n),sessionId:i,events:o}})]})})},t.prototype.storeCurrentSequence=function(e){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){var n;return(0,Q.__generator)(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},t.prototype.storeSendingEvents=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(sp),sS=function(e){var t=e.config,n=e.minInterval,r=e.maxInterval,i=e.type,o=e.payloadBatcher,s=e.storeType;return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e,a,u,l,c;function d(t){return void 0===t&&(t=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return[2,e.flush(t)]})})}return(0,Q.__generator)(this,function(f){switch(f.label){case 0:if(e=new sg((0,Q.__assign)((0,Q.__assign)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:o})),a=function(){return new sw({loggerProvider:t.loggerProvider,maxInterval:r,minInterval:n})},"idb"!==s)return[3,2];return[4,(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(o){switch(o.label){case 0:return[4,sb.new(i,{loggerProvider:t.loggerProvider,minInterval:n,maxInterval:r,apiKey:t.apiKey})];case 1:if(!(e=o.sent()))return t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,a()];return[2,e]}})})];case 1:return l=f.sent(),[3,3];case 2:l=a(),f.label=3;case 3:return u=l,c=function(n){var r=n.events,o=n.sessionId,s=n.deviceId,a=n.sequenceId;t.debugMode&&ok().then(function(e){var n=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(i))}).catch(function(){}),e.sendEventsList({events:r,sessionId:o,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:i,onComplete:function(){return(0,Q.__awaiter)(void 0,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){switch(e.label){case 0:return[4,u.cleanUpSessionEventsStore(o,a)];case 1:return e.sent(),[2]}})})}})},[2,{sendCurrentSequenceEvents:function(e){var n=e.sessionId,r=e.deviceId;u.storeCurrentSequence(n).then(function(e){e&&c({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})},addEvent:function(e){var n=e.event,r=e.sessionId,i=e.deviceId;u.addEventToCurrentSequence(r,n.data).then(function(e){return e&&c({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})}).catch(function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)})},sendStoredEvents:function(e){var t=e.deviceId;return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(n){switch(n.label){case 0:return[4,u.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach(function(e){c({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})}),[2]}})})},flush:d}]}})})},sE=function(){function e(){for(var e=[],t=0;tK.timeoutMs)throw Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var d=sA((e=o.getAttribute("id"))&&K.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null)||sA.apply(void 0,(0,Q.__spreadArray)([],(0,Q.__read)(Array.from(o.attributes).filter(function(e){return K.attr(e.name,e.value)}).map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})),!1))||sA.apply(void 0,(0,Q.__spreadArray)([],(0,Q.__read)(Array.from(o.classList).filter(K.className).map(function(e){return{name:"."+CSS.escape(e),penalty:1}})),!1))||sA((a=o.tagName.toLowerCase(),K.tagName(a)?{name:a,penalty:2}:null))||[sO()],f=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;for(var r=0;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(o);if("all"==t)f&&(d=d.concat(d.filter(sx).map(function(e){return sR(e,f)})));else if("two"==t)d=d.slice(0,1),f&&(d=d.concat(d.filter(sx).map(function(e){return sR(e,f)})));else if("one"==t){var g=(0,Q.__read)(d=d.slice(0,1),1)[0];f&&sx(g)&&(d=[sR(g,f)])}else"none"==t&&(d=[sO()],f&&(d=[sR(d[0],f)]));try{for(var h=(u=void 0,(0,Q.__values)(d)),p=h.next();!p.done;p=h.next()){var g=p.value;g.level=s}}catch(e){u={error:e}}finally{try{p&&!p.done&&(l=h.return)&&l.call(h)}finally{if(u)throw u.error}}if(i.push(d),i.length>=K.seedMinLength&&(r=sT(i,n)))return"break";o=o.parentElement,s++}(););return(r||(r=sT(i,n)),!r&&n)?n():r}function sT(e,t){var n,r,i=sL(function e(t,n){var r,i,o,s,a;return void 0===n&&(n=[]),(0,Q.__generator)(this,function(u){switch(u.label){case 0:if(!(t.length>0))return[3,9];u.label=1;case 1:u.trys.push([1,6,7,8]),i=(r=(0,Q.__values)(t[0])).next(),u.label=2;case 2:if(i.done)return[3,5];return o=i.value,[5,(0,Q.__values)(e(t.slice(1,t.length),n.concat(o)))];case 3:u.sent(),u.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return s={error:u.sent()},[3,8];case 7:try{i&&!i.done&&(a=r.return)&&a.call(r)}finally{if(s)throw s.error}return[7];case 8:return[3,11];case 9:return[4,n];case 10:u.sent(),u.label=11;case 11:return[2]}})}(e));if(i.length>K.threshold)return t?t():null;try{for(var o=(0,Q.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value;if(sP(a))return a}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null}function sI(e){for(var t=e[0],n=t.name,r=1;r ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function sC(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function sP(e){var t=sI(e);switch(V.querySelectorAll(t).length){case 0:throw Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function sO(){return{name:"*",penalty:3}}function sR(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function sx(e){return"html"!==e.name&&!e.name.startsWith("#")}function sA(){for(var e=[],t=0;t0?n:null}function sD(e){return null!=e}function sL(e){return(0,Q.__spreadArray)([],(0,Q.__read)(e),!1).sort(function(e,t){return sC(e)-sC(t)})}var sM=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)}),{version:t,events:r}},sN=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)}),{version:t,events:Object.values(r.reduce(function(e,t){var n=t.x,r=t.y,i=t.selector,o=t.timestamp,s=o-o%36e5,a="".concat(n,":").concat(r,":").concat(null!=i?i:"",":").concat(s);return e[a]?e[a].count+=1:e[a]=(0,Q.__assign)((0,Q.__assign)({},t),{timestamp:s,count:1}),e},{}))}},sU=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,o=e.mirror,s=e.ugcFilterRules,a=e.performanceOptions;return function(e){if(e.type!==oR.Click)return;var u,l=(0,eO.getGlobalScope)();if(l){var c=l.location,d=l.innerHeight,f=l.innerWidth;if(c){var g=e.x,h=e.y;if(void 0!==g&&void 0!==h){var p=o.getNode(e.id);if(p)try{u=function(e,t){if(J=new Date,e.nodeType!==Node.ELEMENT_NODE)throw Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n,r,i={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};n=(K=(0,Q.__assign)((0,Q.__assign)({},i),t)).root,r=i,V=n.nodeType===Node.DOCUMENT_NODE?n:n===r.root?n.ownerDocument:n;var o=sk(e,"all",function(){return sk(e,"two",function(){return sk(e,"one",function(){return sk(e,"none")})})});if(o){var s=sL(function e(t,n,r){var i,o,s;return void 0===r&&(r={counter:0,visited:new Map}),(0,Q.__generator)(this,function(a){switch(a.label){case 0:if(!(t.length>2&&t.length>K.optimizedMinLength))return[3,5];i=1,a.label=1;case 1:var u,l;if(!(iK.maxNumberOfTries||(r.counter+=1,(o=(0,Q.__spreadArray)([],(0,Q.__read)(t),!1)).splice(i,1),s=sI(o),r.visited.has(s)))return[2];if(!(sP(o)&&(u=o,l=n,V.querySelector(sI(u))===l)))return[3,4];return[4,o];case 2:return a.sent(),r.visited.set(s,!0),[5,(0,Q.__values)(e(o,n,r))];case 3:a.sent(),a.label=4;case 4:return i++,[3,1];case 5:return[2]}})}(o,e));return s.length>0&&(o=s[0]),sI(o)}throw Error("Selector was not found.")}(p,a)}catch(e){n.logger.debug("error resolving selector from finder")}var v=oE(c.href,s),m={x:g+n.scrollWatcher.currentScrollX,y:h+n.scrollWatcher.currentScrollY,selector:u,viewportHeight:d,viewportWidth:f,pageUrl:v,timestamp:Date.now(),type:"click"},y=i();y&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(m)},deviceId:y})}}}}},this.logger=e,this.scrollWatcher=t};function sq(){var e=(0,eO.getGlobalScope)();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function sj(){var e=(0,eO.getGlobalScope)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var sF=function(){function e(e,t){var n=(0,eO.getGlobalScope)();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=ob(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,i=n.type,o=new URLSearchParams({device_id:e,session_id:String(r),type:String(i),api_key:this.apiKey}),s="".concat(this.basePageUrl,"?").concat(o.toString());this.sendBeacon(s,t)||this.sendXhr(s,t)},e}(),sB=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,i,o=e(),s=(0,eO.getGlobalScope)();s&&o&&n.transport.send(o,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:sq(),viewportWidth:sj(),pageUrl:oE(s.location.href,null!=(i=null==(r=n.config.interactionConfig)?void 0:r.ugcFilterRules)?i:[]),timestamp:n.timestamp,type:"scroll"}]})}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=sj(),this._maxScrollHeight=sq(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new sF(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=sj();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=sq();this._maxScrollY=e.y;var o=e.y+i;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},e}(),sH=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId="".concat(n,"/").concat(t))},sW=new function(){var e=this;this.dbs={},this.createStore=function(t){return(0,Q.__awaiter)(e,void 0,void 0,function(){return(0,Q.__generator)(this,function(e){switch(e.label){case 0:return[4,(0,sh.openDB)(t,1,{upgrade:function(e){e.objectStoreNames.contains("sessionTargetingMatch")||e.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return(0,Q.__awaiter)(e,void 0,void 0,function(){var e,n;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:if(this.dbs&&this.dbs[t])return[2,this.dbs[t]];return e="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(e)];case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId;return(0,Q.__awaiter)(e,void 0,void 0,function(){var e,t,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(o=a.sent())?void 0:o.targetingMatch];case 3:return s=a.sent(),sv(n,"Failed to get targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,o=t.targetingMatch;return(0,Q.__awaiter)(e,void 0,void 0,function(){var e,t,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.put("sessionTargetingMatch",{targetingMatch:o,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,a.sent()];case 3:return s=a.sent(),sv(n,"Failed to store targeting match for session id ".concat(i,": ").concat(s),s),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return(0,Q.__awaiter)(e,void 0,void 0,function(){var e,t,o,s,a,u,l,c;return(0,Q.__generator)(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=d.sent(),t=String(i),[4,(o=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:s=d.sent(),a=0,d.label=3;case 3:if(!(a1728e5))return[3,5];return[4,o.store.delete(u.sessionId)];case 4:d.sent(),d.label=5;case 5:return a++,[3,3];case 6:return[4,o.done];case 7:return d.sent(),[3,9];case 8:return c=d.sent(),sv(n,"Failed to clear old targeting matches for sessions: ".concat(c),c),[3,9];case 9:return[2]}})})}},sz=function(t){var n=t.sessionId,r=t.targetingConfig,i=t.loggerProvider,o=t.apiKey,s=t.targetingParams,a=t.urlChange,u=void 0!==a&&a;return(0,Q.__awaiter)(void 0,void 0,void 0,function(){var t,a,l;return(0,Q.__generator)(this,function(c){switch(c.label){case 0:return[4,sW.clearStoreOfOldSessions({loggerProvider:i,apiKey:o,currentSessionId:n})];case 1:return c.sent(),[4,sW.getTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:n})];case 2:if(!0===c.sent()&&!u)return[2,!0];t=!0,c.label=3;case 3:return c.trys.push([3,6,,7]),[4,e.A(18737)];case 4:return[4,(0,c.sent().evaluateTargeting)((0,Q.__assign)((0,Q.__assign)({},s),{flag:r,sessionId:"string"==typeof n?parseInt(n,10):n,apiKey:o,loggerProvider:i}))];case 5:return(a=c.sent())&&a.sr_targeting_config&&(t="on"===a.sr_targeting_config.key),sW.storeTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:n,targetingMatch:t}),[3,7];case 6:return l=c.sent(),i.warn(l.message),[3,7];case 7:return[2,t]}})})},sG="__amplitude_url_tracking_patched__",sK=new WeakMap;function sV(e,t,n){if(void 0===n&&(n={}),!(null==e?void 0:e.location))return function(){};var r=n.enablePolling,i=n.pollingInterval;if(void 0!==r&&r){var o=function(){var t;return null!=(t=e.location.href)?t:""},s=o(),a=e.setInterval(function(){var e=o();e!==s&&(s=e,t(e))},void 0===i?1e3:i);return function(){null!=a&&e.clearInterval(a)}}var u=sK.get(e);if(!u){var l=void 0,c=new Set,d=function(){var t;return null!=(t=e.location.href)?t:""},f=function(){var e=d();(void 0===l||e!==l)&&(l=e,c.forEach(function(t){return t(e)}))},g=function(e){var t=function(){for(var t=[],n=0;n0?oE(i,u):i,title:o,viewportHeight:e,viewportWidth:t,type:"url-change-event"}},p=function(){var e=g();(void 0===f||e!==f)&&(f=e,t(h()))},v=sV(n,function(){return p()},l?{enablePolling:!0,pollingInterval:c}:{});return p(),function(){return v()}},options:e}}sJ();var s$=function(){function t(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.recordFunction=null,this.urlChangeCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=(0,eO.getGlobalScope)();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),t||n.addEventListener("blur",e.blurListener),t||n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),t||n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),t||n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){e.recordEvents(!1)},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,r,i){return void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),(0,Q.__awaiter)(e,void 0,void 0,function(){var e,o,s,a,u,l,c,d,f,g,h,p;return(0,Q.__generator)(this,function(v){switch(v.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig)if(!n)return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];else this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");if(this.lastTargetingParams=t,!((e=this.config.targetingConfig)&&!this.sessionTargetingMatch))return[3,2];return o=i?this.latestUrlChangeTargetingEvaluationId:void 0,(s=t.event)&&Object.values(x).includes(s.event_type)&&(s=void 0),a=null!=(h=null!=(d=null==(c=t.page)?void 0:c.url)?d:null==(g=null==(f=(0,eO.getGlobalScope)())?void 0:f.location)?void 0:g.href)?h:"",u=null!=(p=t.page)?p:""!==a?{url:a}:void 0,[4,sz({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:s,page:u},urlChange:i})];case 1:if(l=v.sent(),i&&void 0!==o&&o!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(o,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||l,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:s,targetingParams:t},null,2)),v.label=2;case 2:if(!n)return[3,3];return this.initialize(!0),[3,5];case 3:if(!(r||!this.recordCancelCallback))return[3,5];return this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()];case 4:v.sent(),v.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,r){return void 0===n&&(n={}),void 0===r&&(r=!0),(0,Q.__awaiter)(e,void 0,void 0,function(){var e,i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:if(a.trys.push([0,3,,4]),e=void 0,!((i=this.config)&&t!==G.METADATA)||(e={config:oT(i),version:sf},!r))return[3,2];return[4,ok()];case 1:o=a.sent(),e=(0,Q.__assign)((0,Q.__assign)({},o),e),a.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,Q.__assign)((0,Q.__assign)({},n),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return s=a.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",s),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null==(t=e.networkObservers)||t.stop()}catch(t){e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new oh(new eF)}return t.prototype.init=function(e,t){return eN(this._init(e,t))},t.prototype.setupUrlChangeListenerForTargeting=function(){var e,t=this;null==(e=this.urlChangeCleanup)||e.call(this);var n=(0,eO.getGlobalScope)();if(null==n?void 0:n.location){var r=sV(n,function(e){var n=++t.latestUrlChangeTargetingEvaluationId;t.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:e}},!1,!1,!0),t.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(n," for ").concat(e,"."))});this.urlChangeCleanup=function(){r(),t.urlChangeCleanup=null}}},t.prototype.getCurrentPageForTargeting=function(){var e,t,n=null==(t=null==(e=(0,eO.getGlobalScope)())?void 0:e.location)?void 0:t.href;return null!=n?{url:n}:void 0},t.prototype._init=function(t,n){var r,i,o,s,a,u,l,c;return(0,Q.__awaiter)(this,void 0,void 0,function(){var d,f,g,h,p,v,m,y,_,b,w,S,E,k,T;return(0,Q.__generator)(this,function(I){switch(I.label){case 0:return null==(r=this.urlChangeCleanup)||r.call(this),this.loggerProvider=new oh(n.loggerProvider||new eF),Object.prototype.hasOwnProperty.call(n,"logLevel")&&this.loggerProvider.enable(n.logLevel),this.identifiers=new sH({sessionId:n.sessionId,deviceId:n.deviceId}),d=this,[4,(0,Q.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Q.__generator)(this,function(r){return e=new oC(t,n),[2,new oU(new ti(t,e.loggerProvider,e.serverZone,n.configServerUrl),e)]})})];case 1:return d.joinedConfigGenerator=I.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:g=(f=I.sent()).joinedConfig,h=f.localConfig,p=f.remoteConfig,this.config=g,this.setMetadata(n.sessionId,g,h,p,null==(i=n.version)?void 0:i.version,sf,null==(o=n.version)?void 0:o.type),n.sessionId&&(null==(s=this.config.interactionConfig)?void 0:s.enabled)&&(v=sB.default({sessionId:n.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[v.send(this.getDeviceId.bind(this)).bind(v)],this.scrollHook=v.hook.bind(v),this.clickHandler=new sU(this.loggerProvider,v)),m=[],"idb"!==(y=this.config.storeType)||(null==(a=(0,eO.getGlobalScope)())?void 0:a.indexedDB)||(y="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(y," for event storage.")),I.label=3;case 3:return I.trys.push([3,5,,6]),[4,sS({config:this.config,type:"replay",storeType:y})];case 4:return _=I.sent(),m.push({name:"replay",manager:_}),[3,6];case 5:return b=I.sent(),this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(b.toString())),[3,6];case 6:if(!(null==(u=this.config.interactionConfig)?void 0:u.enabled))return[3,10];w=this.config.interactionConfig.batch?sN:sM,I.label=7;case 7:return I.trys.push([7,9,,10]),[4,sS({config:this.config,type:"interaction",minInterval:null!=(l=this.config.interactionConfig.trackEveryNms)?l:3e4,maxInterval:6e4,payloadBatcher:w,storeType:y})];case 8:return S=I.sent(),m.push({name:"interaction",manager:S}),[3,10];case 9:return b=I.sent(),this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(b.toString())),[3,10];case 10:if(this.eventsManager=new(sE.bind.apply(sE,(0,Q.__spreadArray)([void 0],(0,Q.__read)(m),!1))),this.eventCompressor&&this.eventCompressor.terminate(),E=void 0,k=(0,eO.getGlobalScope)(),!(this.config.useWebWorker&&k&&k.Worker))return[3,12];return[4,e.A(557776)];case 11:E=I.sent().compressionScript,I.label=12;case 12:return this.eventCompressor=new sl(this.eventsManager,this.config,this.getDeviceId(),E),[4,this.initializeNetworkObservers()];case 13:return I.sent(),(null==(c=(0,eO.getGlobalScope)())?void 0:c.opener)&&(n4(T=n2()),T.setup((0,Q.__assign)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:nQ[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:n.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 14:return I.sent(),this.config.targetingConfig&&this.setupUrlChangeListenerForTargeting(),[2]}})})},t.prototype.setSessionId=function(e,t){return eN(this.asyncSetSessionId(e,t))},t.prototype.asyncSetSessionId=function(e,t,n){var r;return(0,Q.__awaiter)(this,void 0,void 0,function(){var i,o,s;return(0,Q.__generator)(this,function(a){switch(a.label){case 0:if(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,(i=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(i),o=t||this.getDeviceId(),this.identifiers=new sH({sessionId:e,deviceId:o}),!(this.joinedConfigGenerator&&i))return[3,2];return[4,this.joinedConfigGenerator.generateJoinedConfig()];case 1:s=a.sent().joinedConfig,this.config=s,a.label=2;case 2:if(!(null==(r=this.config)?void 0:r.targetingConfig))return[3,4];return[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)];case 3:return a.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:a.sent(),a.label=6;case 6:return[2]}})})},t.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),i={};return r&&((e={})[ol]=n.sessionReplayId?n.sessionReplayId:null,i=e,t.debugMode&&(i[of]=JSON.stringify({appHash:tf(t.apiKey).toString()}))),this.addCustomRRWebEvent(G.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},t.prototype.sendEvents=function(e){var t,n=e||(null==(t=this.identifiers)?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},t.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){var n;return(0,Q.__generator)(this,function(r){return(null==(t=this.identifiers)?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},t.prototype.shouldOptOut=function(){if(null==(e=this.config)?void 0:e.instanceName){var e,t,n;n=e6(this.config.instanceName).identityStore.getIdentity().optOut}return void 0!==n?n:null==(t=this.config)?void 0:t.optOut},t.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n=!1,r="",i=!1;return this.config.targetingConfig?this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),n=!0,i=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),n=!1,i=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,31*Math.abs(tf(e.toString()))%1e6/1e60?u:void 0]}})})},t.prototype.getRecordFunction=function(){return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,n;return(0,Q.__generator)(this,function(r){switch(r.label){case 0:if(this.recordFunction)return[2,this.recordFunction];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,e.A(355074)];case 2:return t=r.sent().record,this.recordFunction=t,[2,t];case 3:return n=r.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",n),[2,null];case 4:return[2]}})})},t.prototype.recordEvents=function(e){var t,n,r,i,o,s,a;return void 0===e&&(e=!0),(0,Q.__awaiter)(this,void 0,void 0,function(){var u,l,c,d,f,g,h,p,v,m,y,_,b,w=this;return(0,Q.__generator)(this,function(S){switch(S.label){case 0:if(u=this.config,l=this.getShouldRecord(),c=null==(t=this.identifiers)?void 0:t.sessionId,!l||!c||!u)return[2];return this.stopRecordingEvents(),[4,this.getRecordFunction()];case 1:if(!(d=S.sent()))return[2];return[4,this.initializeNetworkObservers()];case 2:S.sent(),null==(n=this.networkObservers)||n.start(function(e){w.addCustomRRWebEvent(G.FETCH_REQUEST,e)}),f=u.privacyConfig,g=u.interactionConfig,h=u.loggingConfig,p=(null==g?void 0:g.enabled)?{mouseInteraction:this.eventsManager&&(null==(r=this.clickHandler)?void 0:r.createHook({eventsManager:this.eventsManager,sessionId:c,deviceIdFn:this.getDeviceId.bind(this),mirror:d.mirror,ugcFilterRules:null!=(i=g.ugcFilterRules)?i:[],performanceOptions:null==(o=u.performanceConfig)?void 0:o.interaction})),scroll:this.scrollHook}:{},v=(null==g?void 0:g.enabled)&&g.ugcFilterRules?g.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(c,".")),S.label=3;case 3:return S.trys.push([3,5,,6]),m=this,y=d,b={emit:function(e){if(w.shouldOptOut()){w.loggerProvider.log("Opting session ".concat(c," out of recording due to optOut config.")),w.stopRecordingEvents(),w.sendEvents();return}e.type===oP.Meta&&(e.data.href=oE(e.data.href,v)),w.eventCompressor&&w.eventCompressor.enqueueEvent(e,c)},inlineStylesheet:u.shouldInlineStylesheet,hooks:p,maskAllInputs:!0,maskTextClass:og,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:u.applyBackgroundColorToBlockedElements,maskInputFn:oy("input",f),maskTextFn:oy("text",f),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,slimDOMOptions:{script:null==(s=u.omitElementTags)?void 0:s.script,comment:null==(a=u.omitElementTags)?void 0:a.comment},errorHandler:function(e){if(e.message.includes("insertRule")&&e.message.includes("CSSStyleSheet")||e._external_)throw e;return w.loggerProvider.warn("Error while capturing replay: ",e.toString()),!0}},[4,this.getRecordingPlugins(h)];case 4:return m.recordCancelCallback=y.apply(void 0,[(b.plugins=S.sent(),b)]),this.addCustomRRWebEvent(G.DEBUG_INFO),e&&this.addCustomRRWebEvent(G.METADATA,this.metadata),[3,6];case 5:return _=S.sent(),this.loggerProvider.warn("Failed to initialize session replay:",_),[3,6];case 6:return[2]}})})},t.prototype.getDeviceId=function(){var e;return null==(e=this.identifiers)?void 0:e.deviceId},t.prototype.getSessionId=function(){var e;return null==(e=this.identifiers)?void 0:e.sessionId},t.prototype.flush=function(e){var t;return void 0===e&&(e=!1),(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){return[2,null==(t=this.eventsManager)?void 0:t.flush(e)]})})},t.prototype.shutdown=function(){var e;null==(e=this.urlChangeCleanup)||e.call(this),this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},t.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},t.prototype.setMetadata=function(e,t,n,r,i,o,s){var a=(null==e?void 0:e.toString())?tf(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:i,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:o}},t.prototype.initializeNetworkObservers=function(){var t,n,r;return(0,Q.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,Q.__generator)(this,function(s){switch(s.label){case 0:if(!((null==(r=null==(n=null==(t=this.config)?void 0:t.loggingConfig)?void 0:n.network)?void 0:r.enabled)&&!this.networkObservers))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,e.A(835465)];case 2:return i=s.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return o=s.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},t}(),sY=function(e){return function(){var t=e.config||oI();return{logger:t.loggerProvider,logLevel:t.logLevel}}};let sX={init:er((T=new s$).init.bind(T),"init",sY(T)),evaluateTargetingAndCapture:er(T.evaluateTargetingAndCapture.bind(T),"evaluateTargetingAndRecord",sY(T)),setSessionId:er(T.setSessionId.bind(T),"setSessionId",sY(T)),getSessionId:er(T.getSessionId.bind(T),"getSessionId",sY(T)),getSessionReplayProperties:er(T.getSessionReplayProperties.bind(T),"getSessionReplayProperties",sY(T)),flush:er(T.flush.bind(T),"flush",sY(T)),shutdown:er(T.shutdown.bind(T),"shutdown",sY(T))};var sQ=sX.init,sZ=sX.setSessionId,s0=sX.getSessionId,s1=sX.getSessionReplayProperties,s2=sX.flush,s3=sX.shutdown,s4=sX.evaluateTargetingAndCapture;(I=$||($={})).SET="$set",I.SET_ONCE="$setOnce",I.ADD="$add",I.APPEND="$append",I.PREPEND="$prepend",I.REMOVE="$remove",I.PREINSERT="$preInsert",I.POSTINSERT="$postInsert",I.UNSET="$unset",I.CLEAR_ALL="$clearAll",(C=Y||(Y={})).REVENUE_PRODUCT_ID="$productId",C.REVENUE_QUANTITY="$quantity",C.REVENUE_PRICE="$price",C.REVENUE_TYPE="$revenueType",C.REVENUE_CURRENCY="$currency",C.REVENUE="$revenue",(P=X||(X={})).IDENTIFY="$identify",P.GROUP_IDENTIFY="$groupidentify",P.REVENUE="revenue_amount";var s5=[$.SET,$.SET_ONCE,$.ADD,$.APPEND,$.PREPEND,$.POSTINSERT],s6=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach(function(n){if(s5.includes(n)){var r=e.user_properties&&e.user_properties[n];t=(0,Q.__assign)((0,Q.__assign)({},t),r)}}),t}},s8="1.26.1",s7="".concat("[Amplitude]"," Session Replay ID"),s9=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:s2,getSessionId:s0,getSessionReplayProperties:s1,init:sQ,setSessionId:sZ,shutdown:s3,evaluateTargetingAndCapture:s4},this.options=(0,Q.__assign)({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var n,r,i,o,s,a,u,l;return(0,Q.__awaiter)(this,void 0,void 0,function(){var t,c;return(0,Q.__generator)(this,function(d){switch(d.label){case 0:var f;return d.trys.push([0,2,,3]),null==e||e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(s8,".")),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=(0,Q.__assign)((0,Q.__assign)({},e.defaultTracking),{sessions:!0})),t=(void 0===(f=this.config.instanceName)&&(f="$default_instance"),e5.getInstance(f)).identityStore.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!=(n=this.options.deviceId)?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl||(null==(r=this.config.remoteConfig)?void 0:r.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null==(i=this.options.privacyConfig)?void 0:i.blockSelector,maskSelector:null==(o=this.options.privacyConfig)?void 0:o.maskSelector,unmaskSelector:null==(s=this.options.privacyConfig)?void 0:s.unmaskSelector,defaultMaskLevel:null==(a=this.options.privacyConfig)?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:s8},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!=(u=this.options.useWebWorker)?u:null==(l=this.options.experimental)?void 0:l.useWebWorker,userProperties:t,omitElementTags:this.options.omitElementTags,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return d.sent(),[3,3];case 2:return c=d.sent(),null==e||e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(c.message)),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){switch(n.label){case 0:return null==(t=this.config)||t.loggerProvider.debug("Analytics session id is changed to ".concat(e,", SR session id is ").concat(String(this.sessionReplay.getSessionId()),".")),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(n){switch(n.label){case 0:if(null==(t=this.config)||t.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),!e)return[3,1];return this.sessionReplay.shutdown(),[3,4];case 1:if(null==this.config)return[3,3];return[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise];case 2:n.sent(),n.label=3;case 3:n.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t,n,r;return(0,Q.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,u;return(0,Q.__generator)(this,function(l){switch(l.label){case 0:if(l.trys.push([0,9,,10]),!this.options.customSessionId)return[3,4];if(!(i=this.options.customSessionId(e)))return[3,3];if(i===this.sessionReplay.getSessionId())return[3,2];return[4,this.sessionReplay.setSessionId(i).promise];case 1:l.sent(),l.label=2;case 2:o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Q.__assign)((0,Q.__assign)({},e.event_properties),o),l.label=3;case 3:return[3,8];case 4:if(!((i=null==(t=this.config)?void 0:t.sessionId)&&i!==this.sessionReplay.getSessionId()))return[3,6];return[4,this.sessionReplay.setSessionId(i).promise];case 5:l.sent(),l.label=6;case 6:if(!(i&&i===e.session_id))return[3,8];return s=void 0,e.event_type===x.IDENTIFY&&(s=s6(e)),a=(0,eO.getGlobalScope)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:s,page:(null==(n=null==a?void 0:a.location)?void 0:n.href)!=null?{url:a.location.href}:void 0})];case 7:l.sent(),o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Q.__assign)((0,Q.__assign)({},e.event_properties),o),l.label=8;case 8:return e.event_type===x.IDENTIFY&&e.event_properties&&delete e.event_properties[s7],[2,Promise.resolve(e)];case 9:return u=l.sent(),null==(r=this.config)||r.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(u.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return(0,Q.__awaiter)(this,void 0,void 0,function(){return(0,Q.__generator)(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null==(e=this.config)||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(t.message))}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.pluginName="@amplitude/plugin-session-replay-browser",e}(),ae=e.i(942347),at=e.i(925521);let an=()=>at.IS_CLOUD_EDITION&&!!at.AMPLITUDE_API_KEY,ar=ae.memo(e=>{let{sessionReplaySampleRate:t=.5}=e;return(0,ae.useEffect)(()=>{an()&&(or(at.AMPLITUDE_API_KEY,{defaultTracking:{sessions:!0,pageViews:!0,formInteractions:!0,fileDownloads:!0,attribution:!0}}),ot({name:"page-name-enrichment",type:"enrichment",setup:async()=>void 0,execute:async e=>{if("[Amplitude] Page Viewed"===e.event_type&&e.event_properties){let t,n=window.location.pathname;e.event_properties["[Amplitude] Page Title"]=({"":"Home",apps:"Studio",datasets:"Knowledge",explore:"Explore",tools:"Tools",account:"Account",signin:"Sign In",signup:"Sign Up"})[t=n.replace(/^\//,"").split("/")[0]||"home"]||t.charAt(0).toUpperCase()+t.slice(1)}return e}}),ot(new s9({sampleRate:t})))},[]),null});e.s(["default",0,ar,"isAmplitudeEnabled",0,an],512006)},207331,e=>{"use strict";var t=e.i(759730),n=e.i(19259),r=e.i(512006);e.s(["resetUser",0,()=>{(0,r.isAmplitudeEnabled)()&&t.reset()},"setUserId",0,e=>{(0,r.isAmplitudeEnabled)()&&t.setUserId(e)},"setUserProperties",0,e=>{if(!(0,r.isAmplitudeEnabled)())return;let i=new n.Identify;Object.entries(e).forEach(e=>{let[t,n]=e;i.set(t,n)}),t.identify(i)},"trackEvent",0,(e,n)=>{(0,r.isAmplitudeEnabled)()&&t.track(e,n)}])}]);