!function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n,r,i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function l(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i1e3)return!1;for(var t in e){var n=e[t];if(!m(t,n))return!1}return!0},m=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=a(t),s=o.next();!s.done;s=o.next()){var u=s.value;if(Array.isArray(u))return!1;if("object"==typeof u)i=i&&y(u);else if(!["number","string"].includes(typeof u))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return y(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},b=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return i({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(h.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(h.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(h.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(h.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(h.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(h.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(h.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(h.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(h.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[h.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[h.CLEAR_ALL]&&!this._propertySet.has(t)&&(e===h.ADD?"number"==typeof n:e===h.UNSET||e===h.REMOVE||m(t,n))},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(h||(h={}));var w,_=[h.CLEAR_ALL,h.UNSET,h.SET,h.SET_ONCE,h.ADD,h.APPEND,h.PREPEND,h.PREINSERT,h.POSTINSERT,h.REMOVE];!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(w||(w={}));var E,I,S=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=w.Unknown),{event:e,code:t,message:n}},k=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},T=l([],c(Array(256).keys()),!1).map((function(e){return e.toString(16).padStart(2,"0")})),O=function(e){var t,n=k();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,O)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,l([],c(r.entries()),!1).map((function(e){var t=c(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(T[r]):T[r]})).join("")},P=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[]}return e.prototype.register=function(e,t){var n,r;return s(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return this.plugins.some((function(t){return t.name===e.name}))?(t.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=O(),t.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e,t){var n;return s(this,void 0,void 0,(function(){var r,i;return u(this,(function(o){switch(o.label){case 0:return r=this.plugins.findIndex((function(t){return t.name===e})),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}}))}))},e.prototype.reset=function(e){this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)})),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise((function(n){t.queue.push([e,n]),t.scheduleApply(0)}))},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout((function(){t.apply(t.queue.shift()).then((function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)}))}),e))},e.prototype.apply=function(e){return s(this,void 0,void 0,(function(){var t,n,r,o,s,l,d,f,h,p,v,g,y,m,b,w,_,E,I,k;return u(this,(function(u){switch(u.label){case 0:if(!e)return[2];t=c(e,1),n=t[0],r=c(e,2),o=r[1],s=this.plugins.filter((function(e){return"before"===e.type})),u.label=1;case 1:u.trys.push([1,6,7,8]),l=a(s),d=l.next(),u.label=2;case 2:return d.done?[3,5]:(g=d.value).execute?[4,g.execute(i({},n))]:[3,4];case 3:if(null===(y=u.sent()))return o({event:n,code:0,message:""}),[2];n=y,u.label=4;case 4:return d=l.next(),[3,2];case 5:return[3,8];case 6:return f=u.sent(),_={error:f},[3,8];case 7:try{d&&!d.done&&(E=l.return)&&E.call(l)}finally{if(_)throw _.error}return[7];case 8:h=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),u.label=9;case 9:u.trys.push([9,14,15,16]),p=a(h),v=p.next(),u.label=10;case 10:return v.done?[3,13]:(g=v.value).execute?[4,g.execute(i({},n))]:[3,12];case 11:if(null===(y=u.sent()))return o({event:n,code:0,message:""}),[2];n=y,u.label=12;case 12:return v=p.next(),[3,10];case 13:return[3,16];case 14:return m=u.sent(),I={error:m},[3,16];case 15:try{v&&!v.done&&(k=p.return)&&k.call(p)}finally{if(I)throw I.error}return[7];case 16:return b=this.plugins.filter((function(e){return"destination"===e.type})),w=b.map((function(e){var t=i({},n);return e.execute(t).catch((function(e){return S(t,0,String(e))}))})),Promise.all(w).then((function(e){var t=c(e,1)[0]||S(n,100,"Event not tracked, no destination plugins on the instance");o(t)})),[2]}}))}))},e.prototype.flush=function(){return s(this,void 0,void 0,(function(){var e,t,n,r=this;return u(this,(function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map((function(e){return r.apply(e)})))];case 1:return i.sent(),t=this.plugins.filter((function(e){return"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return i.sent(),[2]}}))}))},e.prototype.onIdentityChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)}))},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)}))},e.prototype.onOptOutChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)}))},e}(),A=function(e,t){return i(i({},t),{event_type:r.IDENTIFY,user_properties:e.getUserProperties()})},x=function(e){return{promise:e||Promise.resolve()}},R=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 P(this),this.name=e}return e.prototype._init=function(e){return s(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}}))}))},e.prototype.runQueuedFunctions=function(e){return s(this,void 0,void 0,(function(){var t,n,r,i,o,s,c,l;return u(this,(function(u){switch(u.label){case 0:t=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),n=a(t),r=n.next(),u.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return s=u.sent(),c={error:s},[3,10];case 9:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:u.sent(),u.label=12;case 12:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return i(i(i({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return x(this.dispatch(r))},e.prototype.identify=function(e,t){var n=A(e,t);return x(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,o){var s=function(e,t,n,o){var s;return i(i({},o),{event_type:r.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(s={},s[e]=t,s)})}(e,t,n,o);return x(this.dispatch(s))},e.prototype.setGroup=function(e,t,n){var o=function(e,t,n){var o,s=new b;return s.set(e,t),i(i({},n),{event_type:r.IDENTIFY,user_properties:s.getUserProperties(),groups:(o={},o[e]=t,o)})}(e,t,n);return x(this.dispatch(o))},e.prototype.revenue=function(e,t){var n=function(e,t){return i(i({},t),{event_type:r.REVENUE,event_properties:e.getEventProperties()})}(e,t);return x(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),x())},e.prototype._addPlugin=function(e){return x(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)),x())},e.prototype._removePlugin=function(e){return x(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(S(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return s(this,void 0,void 0,(function(){var t=this;return u(this,(function(n){return this.isReady?[2,this.process(e)]:[2,new Promise((function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))}))]}))}))},e.prototype.getOperationAppliedUserProperties=function(e){var t={};if(void 0===e)return t;var r={};return Object.keys(e).forEach((function(t){Object.values(n).includes(t)||(r[t]=e[t])})),_.forEach((function(r){if(Object.keys(e).includes(r)){var i=e[r];switch(r){case n.CLEAR_ALL:Object.keys(t).forEach((function(e){delete t[e]}));break;case n.UNSET:Object.keys(i).forEach((function(e){delete t[e]}));break;case n.SET:Object.assign(t,i)}}})),Object.assign(t,r),t},e.prototype.process=function(e){return s(this,void 0,void 0,(function(){var t,n,i,o;return u(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),this.config.optOut?[2,S(e,0,"Event skipped due to optOut config")]:(e.event_type===r.IDENTIFY&&(t=this.getOperationAppliedUserProperties(e.user_properties),this.timeline.onIdentityChanged({userProperties:t})),[4,this.timeline.push(e)]);case 1:return 200===(o=s.sent()).code?this.config.loggerProvider.log(o.message):100===o.code?this.config.loggerProvider.warn(o.message):this.config.loggerProvider.error(o.message),[2,o];case 2:return n=s.sent(),i=String(n),this.config.loggerProvider.error(i),[2,o=S(e,0,i)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.timeline.onOptOutChanged(e),this.config.optOut=Boolean(e))},e.prototype.flush=function(){return x(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find((function(t){return t.name===e}));if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter((function(t){return t instanceof e}))},e}(),C=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 y(e)&&(this.properties=e),this},e.prototype.getEventProperties=function(){var e=this.properties?i({},this.properties):{};return e[E.REVENUE_PRODUCT_ID]=this.productId,e[E.REVENUE_QUANTITY]=this.quantity,e[E.REVENUE_PRICE]=this.price,e[E.REVENUE_TYPE]=this.revenueType,e[E.REVENUE_CURRENCY]=this.currency,e[E.REVENUE]=this.revenue,e[E.RECEIPT]=this.receipt,e[E.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(E||(E={})),function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(I||(I={}));var N="Amplitude Logger ",U=function(){function e(){this.logLevel=I.None}return e.prototype.disable=function(){this.logLevel=I.None},e.prototype.enable=function(e){void 0===e&&(e=I.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t0&&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=O()),new Promise((function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()}))},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter((function(e){return e.attempts+=1,e.attemptsthis.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout((function(){t.queue=t.queue.map((function(e){return e.timeout=0,e})),t.flush(!0)}),e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),s(this,void 0,void 0,(function(){var t,n,r=this;return u(this,(function(i){switch(i.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),o=t,a=this.config.flushQueueSize,c=Math.max(a,1),[4,o.reduce((function(e,t,n){var r=Math.floor(n/c);return e[r]||(e[r]=[]),e[r].push(t),e}),[]).reduce((function(t,n){return s(r,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}}))}))}),Promise.resolve())]);case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var o,a,c}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),s(this,void 0,void 0,(function(){var n,r,i,s,a;return u(this,(function(u){switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];n={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,o(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new F,u.label=1;case 1:return u.trys.push([1,3,,4]),r=j(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,[4,this.config.transportProvider.send(r,n)];case 2:return null===(i=u.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(i,e),[3,4]):("body"in i?this.fulfillRequest(e,i.statusCode,"".concat(i.status,": ").concat(M(i))):this.fulfillRequest(e,i.statusCode,i.status),[2]);case 3:return s=u.sent(),a=(c=s)instanceof Error?c.message:String(c),this.config.loggerProvider.error(a),this.handleResponse({status:w.Failed,statusCode:0},e),[3,4];case 4:return[2]}var c}))}))},e.prototype.handleResponse=function(e,t){var n=e.status;switch(n){case w.Success:this.handleSuccessResponse(e,t);break;case w.Invalid:this.handleInvalidResponse(e,t);break;case w.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case w.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(n,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=l(l(l(l([],c(Object.values(e.body.eventsWithInvalidFields)),!1),c(Object.values(e.body.eventsWithMissingFields)),!1),c(Object.values(e.body.eventsWithInvalidIdLengths)),!1),c(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter((function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(M(e));var s=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(s)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(M(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),u=new Set(i),a=new Set(o),c=t.filter((function(t,r){if(!(t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&u.has(t.event.device_id)))return a.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));c.length>0&&this.config.loggerProvider.warn(M(e));var l=this.removeEventsExceedFlushMaxRetries(c);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e})),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){this.removeEvents(e),e.forEach((function(e){return e.callback(S(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}(),$=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:z(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),z=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},B=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}(),K=function(){return K=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 new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Y(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 Q=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=W(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next())if(s.value===i)return e===t}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var u=Array.isArray(e),a=Array.isArray(t);if(u!==a)return!1;if(!u||!a){var c=Object.keys(e).sort(),l=Object.keys(t).sort();if(!Q(c,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){Q(e[n],t[n])||(d=!1)})),d}for(var f=0;fe},ne=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[p,t,e.substring(0,n)].filter(Boolean).join("_")},re=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},ie=function(){var e,t=k();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=oe(n[0]),i=oe(n[1]);return i?(e[r]=i,e):e}),{}):{}},oe=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},se=function(e){return function(){var t=i({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ue=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=a(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},ae=function(e,t){return function(){var n,r,i={};try{for(var o=a(t),s=o.next();!s.done;s=o.next()){var u=s.value;i[u]=ue(e,u)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},ce=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s=200&&e<300?w.Success:429===e?w.RateLimit:413===e?w.PayloadTooLarge:408===e?w.Timeout:e>=400&&e<500?w.Invalid:e>=500?w.Failed:w.Unknown},e}(),ve=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return s(this,void 0,void 0,(function(){var n,r,i;return u(this,(function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},n}(pe);!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(J||(J={}));var ge=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],ye="data-amp-track-",me=["div","span","h1","h2","h3","h4","h5","h6"];function be(e){var t,n,r=k();if(null==r?void 0:r.TextEncoder){var i=r.TextEncoder;if("string"==typeof e)return(new i).encode(e).length;if(e instanceof Blob)return e.size;if(e instanceof URLSearchParams)return(new i).encode(e.toString()).length;if(e instanceof ArrayBuffer)return e.byteLength;if(ArrayBuffer.isView(e))return e.byteLength;if(e instanceof FormData){var o=e,s=0,u=0;try{for(var l=a(o.entries()),d=l.next();!d.done;d=l.next()){var f=c(d.value,2),h=f[0],p=f[1];if(s+=h.length,"string"==typeof p?s+=(new i).encode(p).length:p.size&&(s+=p.size),++u>=100)return}}catch(e){t={error:e}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return s}}}var we,_e,Ee,Ie,Se,ke=function(e,t){void 0===t&&(t=O()),this.callback=e,this.id=t},Te=function(){function e(t){var n;this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var r=k();e.isSupported()&&(this.globalScope=r,this.originalFetch=null===(n=this.globalScope)||void 0===n?void 0:n.fetch)}return e.isSupported=function(){var e=k();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),this.isObserving||(this.observeFetch(),this.isObserving=!0)},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id),this.originalFetch&&this.globalScope&&0===this.eventCallbacks.size&&this.isObserving&&(this.globalScope.fetch=this.originalFetch,this.isObserving=!1)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach((function(n){var r;try{n.callback(e)}catch(e){null===(r=t.logger)||void 0===r||r.debug("an unexpected error occurred while triggering event callbacks",e)}}))},e.prototype.observeFetch=function(){var e=this;if(this.globalScope&&this.originalFetch){var t=this.globalScope.fetch;this.globalScope.fetch=function(n,r){return s(e,void 0,void 0,(function(){var e,i,o,s,a,c,l,d,f;return u(this,(function(u){switch(u.label){case 0:e=Date.now(),i=performance.now(),o={timestamp:e,startTime:e,type:"fetch",method:(null==r?void 0:r.method)||"GET",url:n.toString(),requestHeaders:null==r?void 0:r.headers,requestBodySize:be(null==r?void 0:r.body)},u.label=1;case 1:return u.trys.push([1,3,,4]),[4,t(n,r)];case 2:return s=u.sent(),o.status=s.status,o.duration=Math.floor(performance.now()-i),o.startTime=e,o.endTime=Math.floor(e+o.duration),a={},c=void 0,s.headers.forEach((function(e,t){a[t]=e,"content-length"===t&&(c=parseInt(e,10)||void 0)})),o.responseHeaders=a,o.responseBodySize=c,this.triggerEventCallbacks(o),[2,s];case 3:throw l=u.sent(),d=Date.now(),o.duration=d-e,f=l,o.error={name:f.name||"UnknownError",message:f.message||"An unknown error occurred"},"AbortError"===f.name&&(o.error.name="AbortError",o.status=0),this.triggerEventCallbacks(o),l;case 4:return[2]}}))}))}}},e}(),Oe=new Te,Pe=function(e,t,n){if("boolean"==typeof e)return e;if(null!==e&&"object"==typeof e){if(!1===e[t])return!1;if(void 0===e[t])return n}return!0},Ae=function(e){return Pe(e,"attribution",!0)},xe=function(e){return Pe(e,"pageViews",!0)},Re=function(e){return Pe(e,"sessions",!0)},Ce=function(e){return Pe(e,"networkTracking",!1)},Ne=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},Ue=function(e){if(Ne(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},Le=function(e){if(Ce(e.autocapture)&&e.networkTrackingOptions)return e.networkTrackingOptions},qe=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return xe(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}},De=function(e,t){je(e,t)},je=function(e,t){for(var n=0;n=0;--o)r.push(n.slice(o).join("."));o=0,u.label=2;case 2:return o=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:Bt})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),u.label=1;case 1:u.trys.push([1,3,,4]),n=new URLSearchParams({api_key:this.localConfig.apiKey});try{for(r=a(this.configKeys),o=r.next();!o.done;o=r.next())s=o.value,n.append("config_keys",s)}catch(e){p={error:e}}finally{try{o&&!o.done&&(v=r.return)&&v.call(r)}finally{if(p)throw p.error}}return t&&n.set("session_id",String(t)),c={headers:{Accept:"*/*"},method:"GET"},l="".concat(this.getServerUrl(),"?").concat(n.toString()),this.attempts+=1,[4,fetch(l,i(i({},c),{signal:e}))];case 2:if(null===(d=u.sent()))return[2,this.completeRequest({err:Kt})];switch((new pe).buildStatus(d.status)){case Se.Success:return this.attempts=0,[2,this.parseAndStoreConfig(d)];case Se.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return f=u.sent(),h=f,e.aborted?[2,this.completeRequest({err:Bt})]:[2,this.completeRequest({err:null!==(g=h.message)&&void 0!==g?g:Kt})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return s(r,void 0,void 0,(function(){var n=this;return u(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e){return s(r,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return[4,e.json()];case 1:return t=n.sent(),this.completeRequest({success:"Remote config successfully fetched"}),[2,t]}}))}))},this.localConfig=t,this.configKeys=n}return e.prototype.getServerUrl=function(){return this.localConfig.serverZone===Ie.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===Ie.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),Yt=function(e){var t=e.localConfig,n=e.configKeys;return s(void 0,void 0,void 0,(function(){return u(this,(function(e){return[2,new Wt({localConfig:t,configKeys:n})]}))}))},Qt=function(){function e(e){this.config=e,this.config.loggerProvider.debug("Local configuration before merging with remote config",JSON.stringify(this.config,null,2))}return e.prototype.initialize=function(){return s(this,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return e=this,[4,Yt({localConfig:this.config,configKeys:["analyticsSDK"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(){var e,t,n,r,o,c;return s(this,void 0,void 0,(function(){var s,l,d,f,h,p,v,g,y,m,b,w,_;return u(this,(function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),(l=this.remoteConfigFetch)?[4,this.remoteConfigFetch.getRemoteConfig("analyticsSDK","browserSDK",this.config.sessionId)]:[3,2];case 1:l=u.sent(),u.label=2;case 2:if(s=l,this.config.loggerProvider.debug("Remote configuration:",JSON.stringify(s,null,2)),s&&"autocapture"in s){if("boolean"==typeof s.autocapture&&(this.config.autocapture=s.autocapture),"object"==typeof s.autocapture){if(d=i({},s.autocapture),void 0===this.config.autocapture&&(this.config.autocapture=s.autocapture),"object"==typeof s.autocapture.elementInteractions&&(null===(e=s.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===e?void 0:e.length)){d.elementInteractions=i({},s.autocapture.elementInteractions),f=d.elementInteractions,h=null!==(t=f.pageUrlAllowlist)&&void 0!==t?t:[],p=[];try{for(v=a(s.autocapture.elementInteractions.pageUrlAllowlistRegex),g=v.next();!g.done;g=v.next()){y=g.value;try{p.push(new RegExp(y))}catch(e){this.config.loggerProvider.warn("Invalid regex pattern: ".concat(y),e)}}}catch(e){w={error:e}}finally{try{g&&!g.done&&(_=v.return)&&_.call(v)}finally{if(w)throw w.error}}m=h.concat(p),f.pageUrlAllowlist=m,delete f.pageUrlAllowlistRegex}"boolean"==typeof this.config.autocapture&&(this.config.autocapture=i({attribution:this.config.autocapture,fileDownloads:this.config.autocapture,formInteractions:this.config.autocapture,pageViews:this.config.autocapture,sessions:this.config.autocapture,elementInteractions:this.config.autocapture},d)),"object"==typeof this.config.autocapture&&(this.config.autocapture=i(i({},this.config.autocapture),d))}this.config.defaultTracking=this.config.autocapture}return this.config.loggerProvider.debug("Joined configuration: ",JSON.stringify(this.config,null,2)),null!==(n=(c=this.config).requestMetadata)&&void 0!==n||(c.requestMetadata=new F),(null===(r=this.remoteConfigFetch)||void 0===r?void 0:r.metrics.fetchTimeAPISuccess)&&this.config.requestMetadata.recordHistogram("remote_config_fetch_time_API_success",this.remoteConfigFetch.metrics.fetchTimeAPISuccess),(null===(o=this.remoteConfigFetch)||void 0===o?void 0:o.metrics.fetchTimeAPIFail)&&this.config.requestMetadata.recordHistogram("remote_config_fetch_time_API_fail",this.remoteConfigFetch.metrics.fetchTimeAPIFail),[3,4];case 3:return b=u.sent(),this.config.loggerProvider.error("Failed to fetch remote configuration because of error: ",b),[3,4];case 4:return[2,this.config]}}))}))},e}(),Jt="[Amplitude] Element Clicked",Gt="[Amplitude] Element Tag",Ht="[Amplitude] Element Text",Zt="[Amplitude] Page URL",Xt="https://app.amplitude.com",en={US:Xt,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};function tn(e){return"function"==typeof e}function nn(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var rn=nn((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function on(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var sn=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=a(o),u=s.next();!u.done;u=s.next())u.value.remove(this)}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var d=this.initialTeardown;if(tn(d))try{d()}catch(e){i=e instanceof rn?e.errors:[e]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var h=a(f),p=h.next();!p.done;p=h.next()){var v=p.value;try{cn(v)}catch(e){i=null!=i?i:[],e instanceof rn?i=l(l([],c(i)),c(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}if(i)throw new rn(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)cn(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&on(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&on(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),un=sn.EMPTY;function an(e){return e instanceof sn||e&&"closed"in e&&tn(e.remove)&&tn(e.add)&&tn(e.unsubscribe)}function cn(e){tn(e)?e():e.unsubscribe()}var ln=void 0,dn=!1;function fn(e){!function(e,t){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},n.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},n.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,o=n.observers;return r||i?un:(this.currentObservers=null,o.push(e),new sn((function(){t.currentObservers=null,on(o,e)})))},n.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},n.prototype.asObservable=function(){var e=new Sn;return e.source=this,e},n.create=function(e,t){return new Un(e,t)},n}(Sn),Un=function(e){function n(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t(n,e),n.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},n.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},n.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},n.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:un},n}(Nn);!function(e){function n(t){var n=e.call(this)||this;return n._value=t,n}t(n,e),Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},n.prototype.getValue=function(){var e=this,t=e.hasError,n=e.thrownError,r=e._value;if(t)throw n;return this._throwIfClosed(),r},n.prototype.next=function(t){e.prototype.next.call(this,this._value=t)}}(Nn);var Ln={now:function(){return(Ln.delegate||Date).now()},delegate:void 0};!function(e){function n(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=Ln);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}t(n,e),n.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,o=n._infiniteTimeWindow,s=n._timestampProvider,u=n._windowTime;r||(i.push(t),!o&&i.push(s.now()+u)),this._trimBuffer(),e.prototype.next.call(this,t)},n.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t._scheduled||(t._scheduled=zn.setImmediate(t.flush.bind(t,void 0))))},n.prototype.recycleAsyncId=function(t,n,r){var i;if(void 0===r&&(r=0),null!=r?r>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);var o=t.actions;null!=n&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==n&&(zn.clearImmediate(n),t._scheduled===n&&(t._scheduled=void 0))},n}(jn),Kn=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=Ln.now,e}(),Wn=function(e){function n(t,n){void 0===n&&(n=Kn.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return t(n,e),n.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},n}(Kn),Yn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.flush=function(e){this._active=!0;var t=this._scheduled;this._scheduled=void 0;var n,r=this.actions;e=e||r.shift();do{if(n=e.execute(e.state,e.delay))break}while((e=r[0])&&e.id===t&&r.shift());if(this._active=!1,n){for(;(e=r[0])&&e.id===t&&r.shift();)e.unsubscribe();throw n}},n}(Wn);new Yn(Bn);var Qn=new Wn(jn),Jn=Qn,Gn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return t(n,e),n.prototype.schedule=function(t,n){return void 0===n&&(n=0),n>0?e.prototype.schedule.call(this,t,n):(this.delay=n,this.state=t,this.scheduler.flush(this),this)},n.prototype.execute=function(t,n){return n>0||this.closed?e.prototype.execute.call(this,t,n):this._execute(t,n)},n.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!=r&&r>0||null==r&&this.delay>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.flush(this),0)},n}(jn),Hn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Wn);new Hn(Gn);var Zn=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r}return t(n,e),n.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),null!==r&&r>0?e.prototype.requestAsyncId.call(this,t,n,r):(t.actions.push(this),t._scheduled||(t._scheduled=Rn.requestAnimationFrame((function(){return t.flush(void 0)}))))},n.prototype.recycleAsyncId=function(t,n,r){var i;if(void 0===r&&(r=0),null!=r?r>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,t,n,r);var o=t.actions;null!=n&&n===t._scheduled&&(null===(i=o[o.length-1])||void 0===i?void 0:i.id)!==n&&(Rn.cancelAnimationFrame(n),t._scheduled=void 0)},n}(jn),Xn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.flush=function(e){var t;this._active=!0,e?t=e.id:(t=this._scheduled,this._scheduled=void 0);var n,r=this.actions;e=e||r.shift();do{if(n=e.execute(e.state,e.delay))break}while((e=r[0])&&e.id===t&&r.shift());if(this._active=!1,n){for(;(e=r[0])&&e.id===t&&r.shift();)e.unsubscribe();throw n}},n}(Wn);new Xn(Zn),function(e){function n(t,n){void 0===t&&(t=er),void 0===n&&(n=1/0);var r=e.call(this,t,(function(){return r.frame}))||this;return r.maxFrames=n,r.frame=0,r.index=-1,r}t(n,e),n.prototype.flush=function(){for(var e,t,n=this.actions,r=this.maxFrames;(t=n[0])&&t.delay<=r&&(n.shift(),this.frame=t.delay,!(e=t.execute(t.state,t.delay))););if(e){for(;t=n.shift();)t.unsubscribe();throw e}},n.frameTimeFactor=10}(Wn);var er=function(e){function n(t,n,r){void 0===r&&(r=t.index+=1);var i=e.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.index=r,i.active=!0,i.index=t.index=r,i}return t(n,e),n.prototype.schedule=function(t,r){if(void 0===r&&(r=0),Number.isFinite(r)){if(!this.id)return e.prototype.schedule.call(this,t,r);this.active=!1;var i=new n(this.scheduler,this.work);return this.add(i),i.schedule(t,r)}return sn.EMPTY},n.prototype.requestAsyncId=function(e,t,r){void 0===r&&(r=0),this.delay=e.frame+r;var i=e.actions;return i.push(this),i.sort(n.sortActions),1},n.prototype.recycleAsyncId=function(e,t,n){},n.prototype._execute=function(t,n){if(!0===this.active)return e.prototype._execute.call(this,t,n)},n.sortActions=function(e,t){return e.delay===t.delay?e.index===t.index?0:e.index>t.index?1:-1:e.delay>t.delay?1:-1},n}(jn),tr=new Sn((function(e){return e.complete()}));function nr(e){return e&&tn(e.schedule)}function rr(e){return e[e.length-1]}function ir(e){return nr(rr(e))?e.pop():void 0}var or=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function sr(e){return tn(null==e?void 0:e.then)}function ur(e){return tn(e[En])}function ar(e){return Symbol.asyncIterator&&tn(null==e?void 0:e[Symbol.asyncIterator])}function cr(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var lr,dr="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function fr(e){return tn(null==e?void 0:e[dr])}function hr(e){return function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),o=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function s(e,t){i[e]&&(r[e]=function(t){return new Promise((function(n,r){o.push([e,t,n,r])>1||u(e,t)}))},t&&(r[e]=t(r[e])))}function u(e,t){try{(n=i[e](t)).value instanceof d?Promise.resolve(n.value.v).then(a,c):l(o[0][2],n)}catch(e){l(o[0][3],e)}var n}function a(e){u("next",e)}function c(e){u("throw",e)}function l(e,t){e(t),o.shift(),o.length&&u(o[0][0],o[0][1])}}(this,arguments,(function(){var t,n,r;return u(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,d(t.read())];case 3:return n=i.sent(),r=n.value,n.done?[4,d(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,d(r)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function pr(e){return tn(null==e?void 0:e.getReader)}function vr(e){if(e instanceof Sn)return e;if(null!=e){if(ur(e))return i=e,new Sn((function(e){var t=i[En]();if(tn(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(or(e))return r=e,new Sn((function(e){for(var t=0;t0&&(t=new bn({next:function(e){return v.next(e)},error:function(e){l=!0,d(),r=Fr(f,i,e),v.error(e)},complete:function(){c=!0,d(),r=Fr(f,s),v.complete()}}),vr(e).subscribe(t))}))(e)}}function Fr(e,t){for(var n=[],r=2;rspan,h1,h2,h3,h4,h5,h6")}catch(e){t=null}if(t){var r=t.textContent||"";return zr(r)?r:""}return Qr(n)},Jr=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:Jr(null==e?void 0:e.parentElement,t):null},Gr=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),o=((t={})[Gt]=i,t[Ht]=Kr(e),t[Zt]=window.location.href.split("?")[0],t);return Yr(o)},Hr=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)},Zr=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?Xt:t,r=this;this.endpoint=Xt,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise((function(t,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),(null==n?void 0:n.timeout)>0&&setTimeout((function(){s(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{}:e,r=n.logger,i=n.endpoint,o=n.isElementSelectable,s=n.cssSelectorAllowlist,u=n.actionClickAllowlist;this.logger=r,i&&this.endpoint===Xt&&(this.endpoint=i);var a=null;window.addEventListener("message",(function(e){var n,r,i,c,l;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var d,f=null==e?void 0:e.data,h=null==f?void 0:f.action;if(h)if("id"in f)null===(c=null===(i=t.logger)||void 0===i?void 0:i.debug)||void 0===c||c.call(i,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(f);else if("ping"===h)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===h){var p=null==f?void 0:f.data;(d="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=d,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(d)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;a=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:Gr,isElementSelectable:function(e){return!o||o((null==p?void 0:p.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:t,cssSelectorAllowlist:s,actionClickAllowlist:u}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===h&&(null===(l=null==a?void 0:a.close)||void 0===l||l.call(a))}})),this.notify({action:"page-loaded"})},e}(),Xr=["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot"],ei=["type"],ti=["svg","path","g"],ni=["password","hidden"],ri=function(e){var t;return e?(t=function(e){for(var t=0,n=0;n1024)return e.slice(0,n)}return e}(function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e).map((function(e){return function(e){var t,n,r,i,o,s;if(null===e)return null;var u=String(e.tagName).toLowerCase(),c={tag:u},l=Array.from(null!==(i=null===(r=e.parentElement)||void 0===r?void 0:r.children)&&void 0!==i?i:[]);l.length&&(c.index=l.indexOf(e),c.indexOfType=l.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var d=null===(s=null===(o=e.previousElementSibling)||void 0===o?void 0:o.tagName)||void 0===s?void 0:s.toLowerCase();d&&(c.prevSib=String(d));var f=e.getAttribute("id");f&&(c.id=String(f));var h=Array.from(e.classList);h.length&&(c.classes=h);var p={},v=Array.from(e.attributes).filter((function(e){return!Xr.includes(e.name)})),g=!Br(e);if(!ni.includes(String(e.getAttribute("type")))&&!ti.includes(u))try{for(var y=a(v),m=y.next();!m.done;m=y.next()){var b=m.value;g&&!ei.includes(b.name)||(p[b.name]=String(b.value).substring(0,128))}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=y.return)&&n.call(y)}finally{if(t)throw t.error}}return Object.keys(p).length&&(c.attrs=p),c}(e)}))),t):[]};function ii(e,t){void 0===t&&(t=!1);try{if(null==e)return t?"None":null;if("string"==typeof e)return t?(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")).includes('"')?"'".concat(e,"'"):e.includes("'")?'"'.concat(e.replace(/'/g,"\\'"),'"'):"'".concat(e,"'"):e;if("boolean"==typeof e)return e?"True":"False";if(Array.isArray(e)){var n=e.map((function(e){return ii(e,!0)}));return"[".concat(n.join(", "),"]")}if("object"==typeof e){var r=Object.entries(e).filter((function(e){return null!=c(e,1)[0]})).map((function(e){var t=c(e,2),n=t[0],r=t[1];return"".concat(String(ii(n,!0)),": ").concat(String(ii(r,!0)))})),i="{".concat(r.join(", "),"}");return i.includes("\\'")&&(i=i.replace(/'/g,"'").replace(/'/g,"\\'")),i}return e.toString()}catch(e){return null}}function oi(e){var t,n,r,i=e.amplitude,o=e.allObservables,s=e.options,u=e.shouldTrackEvent,l=o.clickObservable,d=l.pipe(On((function(e,t){var n,r=!1;e.subscribe(Pn(t,(function(e){var i=n;n=e,r&&t.next([i,e]),r=!0})))})),Lr((function(e){var t=c(e,2),n=t[0],r=t[1],i=n.event.target!==r.event.target,o=Math.abs(r.event.screenX-n.event.screenX)<=20&&Math.abs(r.event.screenY-n.event.screenY)<=20;return i&&!o}))),f=Ur(d,l.pipe((t=s.debounceTime,void 0===n&&(n=Qn),On((function(e,r){var i=null,o=null,s=null,u=function(){if(i){i.unsubscribe(),i=null;var e=o;o=null,r.next(e)}};function a(){var e=s+t,o=n.now();if(o0&&d(r)}),void 0,void 0,(function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),a=null}))),!l&&d(null!=n?"number"==typeof n?n:+n-u.now():r)}))}({first:500,with:function(){return tr}}),kr((function(){return e})))},On((function(e,t){var n=null,r=!1,i=function(){return r&&!n&&t.complete()};e.subscribe(Pn(t,(function(e){null==n||n.unsubscribe(),vr(p(e)).subscribe(n=Pn(t,(function(e){return t.next(e)}),(function(){n=null,i()})))}),(function(){r=!0,i()})))}))));return g.subscribe((function(e){null==t||t.track(Jt,i("click",e.closestTrackedAncestor))}))}({allObservables:s,options:e,getEventProperties:g,amplitude:n,shouldTrackEvent:r,shouldTrackActionClick:o}),v.push(f),null===(w=null==t?void 0:t.loggerProvider)||void 0===w||w.log("".concat(p," has been successfully added.")),window.opener&&h.enabled&&(m=e.cssSelectorAllowlist,b=e.actionClickAllowlist,null===(_=h.messenger)||void 0===_||_.setup(i(i({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:en[t.serverZone]}),{isElementSelectable:$r(e,l(l([],c(m),!1),c(b),!1)),cssSelectorAllowlist:m,actionClickAllowlist:b})))),[2]}))}))},execute:function(e){return s(void 0,void 0,void 0,(function(){return u(this,(function(t){return[2,e]}))}))},teardown:function(){return s(void 0,void 0,void 0,(function(){var e,t,n,r;return u(this,(function(i){try{for(e=a(v),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},ai="500-599";function ci(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function li(e,t){var n,r,i=t.split(",");try{for(var o=a(i),s=o.next();!s.done;s=o.next()){var u=c(s.value.split("-").map(Number),2),l=u[0],d=u[1];if(e===l&&void 0===d)return!0;if(e>=l&&e<=d)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function di(e){var t;try{var n=null===(t=k())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),s=r.href,u=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:r.href,host:u}}catch(e){return}}function fi(e,t){var n;void 0===t&&(t={});var r=di(e.url);if(!r)return!1;var i,o=r.host;return(!1===t.ignoreAmplitudeRequests||!ci(o,"*.amplitude.com")&&!ci(o,"amplitude.com"))&&(!(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find((function(e){return ci(o,e)})))&&(!(!t.captureRules&&void 0!==e.status&&!li(e.status,ai))&&!(t.captureRules&&(l([],c(t.captureRules),!1).reverse().find((function(t){return i=function(e,t,n){if(!e.hosts||e.hosts.find((function(e){return ci(t,e)})))return!((n||0===n)&&!li(n,e.statusCodeRange||ai))}(t,o,e.status),void 0!==i})),!i))))}!function(e){e.NetworkObservable="networkObservable"}(si||(si={}));var hi=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=[];return{name:n,type:"enrichment",setup:function(i,o){return s(void 0,void 0,void 0,(function(){var s,a;return u(this,(function(u){return"undefined"==typeof document||(s=function(){var e,n=new Sn((function(e){var n=new ke((function(t){var n=function(e){return{event:e,timestamp:Date.now(),type:"network"}}(t);e.next(n)}));return Oe.subscribe(n,t),function(){Oe.unsubscribe(n)}}));return(e={})[si.NetworkObservable]=n,e}(),a=function(e){var t=e.networkTrackingOptions,n=e.amplitude;return e.allObservables.networkObservable.pipe(Lr((function(e){return fi(e.event,t)}))).subscribe((function(e){var t,r=e.event,i=di(r.url);if(i){var o=((t={})["[Amplitude] URL"]=i.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=i.query,t["[Amplitude] URL Fragment"]=i.fragment,t["[Amplitude] Request Method"]=r.method,t["[Amplitude] Status Code"]=r.status,t["[Amplitude] Start Time"]=r.startTime,t["[Amplitude] Completion Time"]=r.endTime,t["[Amplitude] Duration"]=r.duration,t["[Amplitude] Request Body Size"]=r.requestBodySize,t["[Amplitude] Response Body Size"]=r.responseBodySize,t);null==n||n.track("[Amplitude] Network Request",o)}}))}({allObservables:s,networkTrackingOptions:e,amplitude:o}),r.push(a),null==(t=null==i?void 0:i.loggerProvider)||t.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return s(void 0,void 0,void 0,(function(){return u(this,(function(t){return[2,e]}))}))},teardown:function(){return s(void 0,void 0,void 0,(function(){var e,t,n,i;return u(this,(function(o){try{for(e=a(r),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},pi="dclid",vi="fbclid",gi="gbraid",yi="gclid",mi="ko_click_id",bi="li_fat_id",wi="msclkid",_i="rtd_cid",Ei="ttclid",Ii="twclid",Si="wbraid",ki={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rtd_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},Ti=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},Oi=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}))},Pi=function(){function e(){}return e.prototype.parse=function(){return s(this,void 0,void 0,(function(){return u(this,(function(e){return[2,i(i(i(i({},ki),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=ie();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=ie();return(e={})[pi]=t[pi],e[vi]=t[vi],e[gi]=t[gi],e[yi]=t[yi],e[mi]=t[mi],e[bi]=t[bi],e[wi]=t[wi],e[_i]=t[_i],e[Ei]=t[Ei],e[Ii]=t[Ii],e[Si]=t[Si],e},e}(),Ai=function(){function e(e,t){var n,r,o,s,u,a;this.shouldTrackNewCampaign=!1,this.options=i({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=null===(n=t.cookieOptions)||void 0===n?void 0:n.domain,o=r,o?(o.startsWith(".")&&(o=o.substring(1)),[new RegExp("".concat(o.replace(".","\\."),"$"))]):[])},e),this.storage=t.cookieStorage,this.storageKey=(s=t.apiKey,void 0===(u="MKTG")&&(u=""),void 0===a&&(a=10),[p,u,s.substring(0,a)].filter(Boolean).join("_")),this.currentCampaign=ki,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return s(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return[4,this.fetchCampaign()];case 1:return t=c.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||te(this.sessionTimeout,this.lastEventTime),function(e,t,n,r,i){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,u=o(e,["referrer","referring_domain"]),a=t||{};a.referrer;var c=a.referring_domain,l=o(a,["referrer","referring_domain"]);if(Oi(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var d=JSON.stringify(u)!==JSON.stringify(l),f=Ti(s||"")!==Ti(c||""),h=!t||d||f;return h?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."),h}(this.currentCampaign,this.previousCampaign,this.options,this.logger,e)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.fetchCampaign=function(){return s(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,Promise.all([(new Pi).parse(),this.storage.get(this.storageKey)])];case 1:return[2,e.sent()]}}))}))},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,o,s=(t=this.currentCampaign,n=this.options,r=i(i({},ki),t),o=Object.entries(r).reduce((function(e,t){var r,i=c(t,2),o=i[0],s=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=s?s:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),s?e.set(o,s):e.unset(o)}),new b),A(o));return e&&(s.event_id=e),s},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),xi=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.init=function(e,t,n){var r,o;return void 0===e&&(e=""),arguments.length>2?(r=t,o=n):"string"==typeof t?(r=t,o=void 0):(r=null==t?void 0:t.userId,o=t),x(this._init(i(i({},o),{userId:r,apiKey:e})))},n.prototype._init=function(t){var n,r,o;return s(this,void 0,void 0,(function(){var a,c,l,d,f,h=this;return u(this,(function(p){switch(p.label){case 0:return this.initializing?[2]:(this.initializing=!0,[4,ht(t.apiKey,t,this)]);case 1:return(a=p.sent()).fetchRemoteConfig?[4,(g=a,s(void 0,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return[4,(e=new Qt(g)).initialize()];case 1:return t.sent(),[2,e]}}))})))]:[3,4];case 2:return[4,p.sent().generateJoinedConfig()];case 3:a=p.sent(),p.label=4;case 4:return[4,e.prototype._init.call(this,a)];case 5:return p.sent(),this.logBrowserOptions(a),Ae(this.config.defaultTracking)?(c=function(e){return Ae(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.attribution&&"object"==typeof e.defaultTracking.attribution?i({},e.defaultTracking.attribution):{}}(this.config),this.webAttribution=new Ai(c,this.config),[4,this.webAttribution.init()]):[3,7];case 6:p.sent(),p.label=7;case 7:return l=ie(),d=Number.isNaN(Number(l.ampSessionId))?void 0:Number(l.ampSessionId),this.setSessionId(null!==(o=null!==(r=null!==(n=t.sessionId)&&void 0!==n?n:d)&&void 0!==r?r:this.config.sessionId)&&void 0!==o?o:Date.now()),(f=X(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,9]:[4,this.add(zt()).promise];case 8:p.sent(),p.label=9;case 9:return[4,this.add(new V).promise];case 10:return p.sent(),[4,this.add(new Ve).promise];case 11:return p.sent(),[4,this.add(new ee).promise];case 12:return p.sent(),function(e){$t||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."),$t=!0)}(this.config),v=this.config.defaultTracking,Pe(v,"fileDownloads",!0)?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(Vt()).promise]):[3,14];case 13:p.sent(),p.label=14;case 14:return function(e){return Pe(e,"formInteractions",!0)}(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(jt()).promise]):[3,16];case 15:p.sent(),p.label=16;case 16:return xe(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Ut(qe(this.config))).promise]):[3,18];case 17:p.sent(),p.label=18;case 18:return Ne(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(ui(Ue(this.config))).promise]):[3,20];case 19:p.sent(),p.label=20;case 20:return Ce(this.config.autocapture)&&this.config.networkTrackingOptions?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(hi(Le(this.config))).promise]):[3,22];case 21:p.sent(),p.label=22;case 22:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 23:return p.sent(),f.eventBridge.setEventReceiver((function(e){h.track(e.eventType,e.eventProperties)})),[2]}var v,g}))}))},n.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},n.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){X(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},n.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},n.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){X(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},n.prototype.reset=function(){this.setDeviceId(O()),this.setUserId(void 0)},n.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},n.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),x(Promise.resolve());if(e===this.config.sessionId)return x(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,Re(this.config.defaultTracking)&&(r&&i&&n.push(this.track(nt,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,n);return Re(this.config.defaultTracking)&&n.push(this.track(tt,void 0,{event_id:s?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,x(Promise.all(n))},n.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},n.prototype.setTransport=function(e){this.config?this.config.transportProvider=vt(e):this.q.push(this.setTransport.bind(this,e))},n.prototype.identify=function(t,n){if(Fe(t)){var r=t._q;t._q=[],t=je(new b,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},n.prototype.groupIdentify=function(t,n,r,i){if(Fe(r)){var o=r._q;r._q=[],r=je(new b,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},n.prototype.revenue=function(t,n){if(Fe(t)){var r=t._q;t._q=[],t=je(new C,r)}return e.prototype.revenue.call(this,t,n)},n.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},n.prototype.process=function(t){return s(this,void 0,void 0,(function(){var n,r,i;return u(this,(function(o){return n=Date.now(),r=te(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===tt||t.event_type===nt||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]}))}))},n.prototype.logBrowserOptions=function(e){try{var t=i(i({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",JSON.stringify(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},n}(R),Ri=function(){var e=new xi;return{init:ce(e.init.bind(e),"init",se(e),ae(e,["config"])),add:ce(e.add.bind(e),"add",se(e),ae(e,["config.apiKey","timeline.plugins"])),remove:ce(e.remove.bind(e),"remove",se(e),ae(e,["config.apiKey","timeline.plugins"])),track:ce(e.track.bind(e),"track",se(e),ae(e,["config.apiKey","timeline.queue.length"])),logEvent:ce(e.logEvent.bind(e),"logEvent",se(e),ae(e,["config.apiKey","timeline.queue.length"])),identify:ce(e.identify.bind(e),"identify",se(e),ae(e,["config.apiKey","timeline.queue.length"])),groupIdentify:ce(e.groupIdentify.bind(e),"groupIdentify",se(e),ae(e,["config.apiKey","timeline.queue.length"])),setGroup:ce(e.setGroup.bind(e),"setGroup",se(e),ae(e,["config.apiKey","timeline.queue.length"])),revenue:ce(e.revenue.bind(e),"revenue",se(e),ae(e,["config.apiKey","timeline.queue.length"])),flush:ce(e.flush.bind(e),"flush",se(e),ae(e,["config.apiKey","timeline.queue.length"])),getUserId:ce(e.getUserId.bind(e),"getUserId",se(e),ae(e,["config","config.userId"])),setUserId:ce(e.setUserId.bind(e),"setUserId",se(e),ae(e,["config","config.userId"])),getDeviceId:ce(e.getDeviceId.bind(e),"getDeviceId",se(e),ae(e,["config","config.deviceId"])),setDeviceId:ce(e.setDeviceId.bind(e),"setDeviceId",se(e),ae(e,["config","config.deviceId"])),reset:ce(e.reset.bind(e),"reset",se(e),ae(e,["config","config.userId","config.deviceId"])),getSessionId:ce(e.getSessionId.bind(e),"getSessionId",se(e),ae(e,["config"])),setSessionId:ce(e.setSessionId.bind(e),"setSessionId",se(e),ae(e,["config"])),extendSession:ce(e.extendSession.bind(e),"extendSession",se(e),ae(e,["config"])),setOptOut:ce(e.setOptOut.bind(e),"setOptOut",se(e),ae(e,["config"])),setTransport:ce(e.setTransport.bind(e),"setTransport",se(e),ae(e,["config"]))}},Ci=Ri(),Ni=Object.freeze({__proto__:null,get IdentifyOperation(){return n},get SpecialEventType(){return r},get RevenueProperty(){return E},get LogLevel(){return I},get ServerZone(){return J},OfflineDisabled:null,DEFAULT_CSS_SELECTOR_ALLOWLIST:ge,DEFAULT_DATA_ATTRIBUTE_PREFIX:ye,DEFAULT_ACTION_CLICK_ALLOWLIST:me}),Ui=Ci.add,Li=Ci.extendSession,qi=Ci.flush,Di=Ci.getDeviceId,ji=Ci.getSessionId,Fi=Ci.getUserId,Mi=Ci.groupIdentify,Vi=Ci.identify,$i=Ci.init,zi=Ci.logEvent,Bi=Ci.remove,Ki=Ci.reset,Wi=Ci.revenue,Yi=Ci.setDeviceId,Qi=Ci.setGroup,Ji=Ci.setOptOut,Gi=Ci.setSessionId,Hi=Ci.setTransport,Zi=Ci.setUserId,Xi=Ci.track,eo=Object.freeze({__proto__:null,add:Ui,extendSession:Li,flush:qi,getDeviceId:Di,getSessionId:ji,getUserId:Fi,groupIdentify:Mi,identify:Vi,init:$i,logEvent:zi,remove:Bi,reset:Ki,revenue:Wi,setDeviceId:Yi,setGroup:Qi,setOptOut:Ji,setSessionId:Gi,setTransport:Hi,setUserId:Zi,track:Xi,createInstance:Ri,AmplitudeBrowser:xi,runQueuedFunctions:De,Revenue:C,Identify:b,Types:Ni});!function(){var e=k();if(e){var t=function(e){var t=Ri(),n=k();return n&&n.amplitude&&n.amplitude._iq&&e&&(n.amplitude._iq[e]=t),t};if(e.amplitude=Object.assign(e.amplitude||{},eo,{createInstance:t}),e.amplitude.invoked){var n=e.amplitude._q;e.amplitude._q=[],De(eo,n);for(var r=Object.keys(e.amplitude._iq)||[],i=0;i