1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="a7a14db5-3edd-fca9-899f-2712503b1678")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,566137,e=>{"use strict";var t=e.i(247167),r=e.i(843476),n=e.i(271645),i=e.i(436370),o=e.i(359861),s=e.i(827085),a=e.i(387644),l=e.i(558249);let u=(0,n.createContext)(void 0);e.s(["AnalyticsContext",0,u,"AnalyticsProvider",0,({children:e})=>{let c="b54511989ea9bdaeb0723a1f49ee248f",d="true"===t.default.env.NEXT_PUBLIC_DISABLE_ANALYTICS,f=(0,n.useRef)(null),{user:g}=(0,s.useUser)(),h=(0,n.useCallback)((...e)=>{},[!0]),p=(0,n.useCallback)(e=>{f.current=e,d||i.setUserId(e),h("setUser:",e)},[d,h]),v=(0,n.useCallback)((e,t)=>{if(!d){let r=(0,l.normalizePayload)(t);i.track(e,r),(0,a.sendGTMEvent)({event:e,...r??{}});try{window.fbq?.("trackCustom",e,r)}catch(e){console.warn("[Analytics] Error tracking event with MetaPixel:",e)}try{let t=l.XEventMapping[e]??e;window.twq?.("event",t,r)}catch(e){console.warn("[Analytics] Error tracking event with X Pixel:",e)}}h("trackEvent:",e,{...t})},[!0,c,d,h]);(0,n.useEffect)(()=>{g?.id&&!d?p(g.id):null===g&&p("")},[g?.id,!0,d]),(0,n.useEffect)(()=>{c&&!d&&(i.init(c,{autocapture:!0,defaultTracking:!0}),i.add((0,o.sessionReplayPlugin)({sampleRate:.5})))},[c,!0,d]);let m=(0,n.useMemo)(()=>({setUser:p,trackEvent:v}),[p,v]);return(0,r.jsx)(u.Provider,{value:m,children:e})}])},558249,e=>{"use strict";var t,r=((t={}).NavigationClick="navigation_click",t.UpgradeClick="upgrade_click",t.SupportClick="support_click",t.SupportSubmitted="support_submitted",t.SearchPerformed="search_performed",t.SearchNoResults="search_no_results",t.FilterApplied="filter_applied",t.SortChanged="sort_changed",t.TabSwitched="tab_switched",t.DateRangeSelected="date_range_selected",t.ToggleSwitched="toggle_switched",t.WatchlistCreated="watchlist_created",t.WatchlistEdited="watchlist_edited",t.WatchlistDuplicated="watchlist_duplicated",t.WatchlistDeleted="watchlist_deleted",t.MultiSelectOptionToggled="multi_select_option_toggled",t.TickerRowClicked="ticker_row_clicked",t.IndustryRowClicked="industry_row_clicked",t.SectorRowClicked="sector_row_clicked",t.CorporateEventRowClicked="corporate_event_row_clicked",t.WatchlistTickerClicked="watchlist_ticker_clicked",t.CompanyCardClicked="company_card_clicked",t.SearchResultClicked="search_result_clicked",t.AskOurExpertAIPromptClicked="ask_our_expert_ai_prompt_clicked",t.AskOurExpertAISubmitted="ask_our_expert_ai_submitted",t.WatchlistTickerAdd="watchlist_ticker_add",t.WatchlistTickerRemoved="watchlist_ticker_removed",t.WatchlistTabSwitched="watchlist_tab_switched",t.WatchlistSwitched="watchlist_switched",t.WatchlistSortChanged="watchlist_sort_changed",t.WatchlistHighlightedTableTickerClicked="watchlist_highlighted_table_ticker_clicked",t.WatchlistTemplateSelected="watchlist_template_selected",t.WatchlistSearchPerformed="watchlist_search_performed",t.DiscoveryBotMessageSubmitted="discovery_bot_message_submitted",t.DiscoveryBotTopicEdit="discovery_bot_topic_edit",t.DiscoveryBotTopicDelete="discovery_bot_topic_delete",t.BuzzTalkFollowUpClicked="buzz_talk_follow_up_clicked",t.BuzzTalkFollowUpQuestionClicked="buzz_talk_follow_up_question_clicked",t.AddToWatchlistsDialogWatchlistCreated="add_to_watchlists_dialog_watchlist_created",t.AddToWatchlistsDialogTickerAdded="add_to_watchlists_dialog_ticker_added",t.AddToWatchlistsDialogWatchlistDeleted="add_to_watchlists_dialog_watchlist_deleted",t.InfoClick="info_click",t.SkipTrial="skip_trial",t.CancelSubscription="cancel_subscription",t.ResumeSubscription="resume_subscription",t.CancelDialogOpened="cancel_dialog_opened",t.CancelDialogClosed="cancel_dialog_closed",t.CancelDialogStepNext="cancel_dialog_step_next",t.CancelDialogStepBack="cancel_dialog_step_back",t.TourStarted="tour_started",t.TourClosed="tour_closed",t.WelcomeDialogCompleted="welcome_dialog_completed",t.BrokerPresentDialogOpened="broker_present_dialog_opened",t.BrokerCardClicked="broker_card_clicked",t.OnboardingChecklistOpened="onboarding_checklist_opened",t.OnboardingChecklistClosed="onboarding_checklist_closed",t.OnboardingChecklistTourClicked="onboarding_checklist_tour_clicked",t.OnboardingChecklistTaskClicked="onboarding_checklist_task_clicked",t.OnboardingChecklistCompleted="onboarding_checklist_completed",t.OnboardingChecklistContactClicked="onboarding_checklist_contact_clicked",t.OnboardingChecklistDiscordClicked="onboarding_checklist_discord_clicked",t);e.s(["AnalyticsEventName",()=>r,"XEventMapping",0,{signup_form:"tw-q14iw-qkr35",signup_complete:"tw-q14iw-qkr36"},"normalizePayload",0,e=>{if(!e)return;let t={},r=(e,n="")=>{Object.entries(e).forEach(([e,i])=>{if(void 0===i||"function"==typeof i||"symbol"==typeof i)return;let o=n?`${n}.${e}`:e;if(!i||"object"!=typeof i||Array.isArray(i)){let e=(e=>{if(null==e)return;let t=typeof e;if("string"===t||"number"===t||"boolean"===t)return e;if(e instanceof Date)return e.toISOString();try{return JSON.stringify(e)}catch{return}})(i);void 0!==e&&(t[o]=e)}else r(i,o)})};return r(e),Object.keys(t).length?t:void 0}])},436370,359861,e=>{"use strict";let t;var r,n,i,o,s,a,l,u,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,I,T,C,P,x,O,A,R,M,D,L,N,F,j,q,U,B,z,W,G,H,$,K,V,J,Y,X,Q,Z=e.i(290571);(r=x||(x={}))[r.None=0]="None",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Verbose=3]="Verbose",r[r.Debug=4]="Debug";var ee=function(e){return void 0===e&&(e=0),(Error().stack||"").split("\n").slice(2+e).map(function(e){return e.trim()})},et=function(e){return function(){var t=(0,Z.__assign)({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},er=function(e,t){var r,n;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=(0,Z.__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){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return e},en=function(e,t){return function(){var r,n,i={};try{for(var o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=er(e,a)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}},ei=function(e,t,r,n,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=r(),l=a.logger,u=a.logLevel;if(u&&u<x.Debug||!u||!l)return e.apply(i,o);var c={type:"invoke public method",name:t,args:o,stacktrace:ee(1),time:{start:new Date().toISOString()},states:{}};n&&c.states&&(c.states.before=n());var d=e.apply(i,o);return d&&d.promise?d.promise.then(function(){n&&c.states&&(c.states.after=n()),c.time&&(c.time.end=new Date().toISOString()),l.debug(JSON.stringify(c,null,2))}):(n&&c.states&&(c.states.after=n()),c.time&&(c.time.end=new Date().toISOString()),l.debug(JSON.stringify(c,null,2))),d}};(n=O||(O={})).SET="$set",n.SET_ONCE="$setOnce",n.ADD="$add",n.APPEND="$append",n.PREPEND="$prepend",n.REMOVE="$remove",n.PREINSERT="$preInsert",n.POSTINSERT="$postInsert",n.UNSET="$unset",n.CLEAR_ALL="$clearAll",(i=A||(A={})).IDENTIFY="$identify",i.GROUP_IDENTIFY="$groupidentify",i.REVENUE="revenue_amount";var eo="".concat("AMP","_unsent"),es="$default_instance",ea="https://api2.amplitude.com/2/httpapi",el="https://api.eu.amplitude.com/2/httpapi",eu="https://api2.amplitude.com/batch",ec="https://api.eu.amplitude.com/batch",ed="dclid",ef="fbclid",eg="gbraid",eh="gclid",ep="ko_click_id",ev="li_fat_id",em="msclkid",ey="rdt_cid",e_="ttclid",eb="twcli
2d",ew="wbraid",eS={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},eE=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],ek=["authorization","cookie","set-cookie"],eI=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var r=e[t];if(!eT(t,r))return!1}return!0},eT=function(e,t){var r,n;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=(0,Z.__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&&eI(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}else if(null==t)return!1;else if("object"==typeof t)return eI(t);else if(!["number","string","boolean"].includes(typeof t))return!1;return!0},eC=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return(0,Z.__assign)({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(R.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(R.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(R.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(R.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(R.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(R.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(R.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(R.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(R.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[R.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,r){if(this._validate(e,t,r)){var n=this._properties[e];return void 0===n&&(n={},this._properties[e]=n),n[t]=r,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,r){return!(void 0!==this._properties[R.CLEAR_ALL]||this._propertySet.has(t))&&(e===R.ADD?"number"==typeof r:e===R.UNSET||e===R.REMOVE||eT(t,r))},e}();(o=R||(R={})).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 eP=[R.CLEAR_ALL,R.UNSET,R.SET,R.SET_ONCE,R.ADD,R.APPEND,R.PREPEND,R.PREINSERT,R.POSTINSERT,R.REMOVE];(s=M||(M={})).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 ex=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=M.Unknown),{event:e,code:t,message:r}},eO=e.i(289812),eA=(0,Z.__spreadArray)([],(0,Z.__read)(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),eR=function(e){var t,r=(0,eO.getGlobalScope)();if(!(null==(t=null==r?void 0:r.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,eR);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=15&n[6]|64,n[8]=63&n[8]|128,(0,Z.__spreadArray)([],(0,Z.__read)(n.entries()),!1).map(function(e){var t=(0,Z.__read)(e,2),r=t[0],n=t[1];return[4,6,8,10].includes(r)?"-".concat(eA[n]):eA[n]}).join("")},eM=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return e.prototype.register=function(e,t){var r,n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(void 0===e.name&&(e.name=eR(),this.loggerProvider.warn("Plugin name is undefined.\n Generating a random UUID for plugin name: ".concat(e.name,".\n Set a name for the plugin to prevent it from being added multiple times."))),i=e.name,this.pluginStatus.has(i))return this.loggerProvider.warn("Plugin with name ".concat(i," already exists, skipping registration")),[2];return e.type=null!=(r=e.type)?r:"enrichment",this.pluginStatus.set(i,"locked"),[4,null==(n=e.setup)?void 0:n.call(e,t,this.client)];case 1:if(o.sent(),"locked"!==this.pluginStatus.get(i))return[2];return this.plugins.push(e),this.pluginStatus.set(i,"installed"),[2]}})})},e.prototype.deregister=function(e,t){var r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(this.pluginStatus.delete(e),-1===(n=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[n],this.plugins.splice(n,1),[4,null==(r=i.teardown)?void 0:r.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.pluginStatus.clear(),this.client=e},e.prototype.push=function(e){var t=this;return new Promise(function(r){t.queue.push([e,r]),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,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i,o,s,a,l,u,c,d,f,g,h,p;return(0,Z.__generator)(this,function(v){switch(v.label){case 0:if(!e)return[2];t=(0,Z.__read)(e,1)[0],r=(0,Z.__read)(e,2)[1],this.loggerProvider.log("Timeline.apply: Initial event",t),n=this.plugins.filter(function(e){return"before"===e.type}),v.label=1;case 1:v.trys.push([1,6,7,8]),o=(i=(0,Z.__values)(n)).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,Z.__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))),r({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}
2return[7];case 8:l=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=(u=(0,Z.__values)(l)).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,Z.__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))),r({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=u.next(),[3,10];case 13:return[3,16];case 14:return h={error:v.sent()},[3,16];case 15:try{c&&!c.done&&(p=u.return)&&p.call(u)}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 r=(0,Z.__assign)({},t);return e.execute(r).catch(function(e){return ex(r,0,String(e))})})).then(function(e){var n=(0,Z.__read)(e,1)[0]||ex(t,100,"Event not tracked, no destination plugins on the instance");r(n)}),[2]}})})},e.prototype.flush=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(e){return t.apply(e)}))];case 1:return r.sent(),[4,Promise.all(this.plugins.filter(function(e){return"destination"===e.type}).map(function(e){return e.flush&&e.flush()}))];case 2:return r.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 r;null==(r=t.onIdentityChanged)||r.call(t,e)})},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(t){var r;null==(r=t.onSessionIdChanged)||r.call(t,e)})},e.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(t){var r;null==(r=t.onOptOutChanged)||r.call(t,e)}),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),r=(t=(0,Z.__values)(this._optOutListeners)).next(),a.label=1;case 1:if(r.done)return[3,6];n=r.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,n(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 r=t.next(),[3,1];case 6:return[3,9];case 7:return o={error:a.sent()},[3,9];case 8:try{r&&!r.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,Z.__assign)((0,Z.__assign)({},t),{event_type:A.IDENTIFY,user_properties:e.getUserProperties()})},eL=function(e,t,r,n){var i;return(0,Z.__assign)((0,Z.__assign)({},n),{event_type:A.GROUP_IDENTIFY,group_properties:r.getUserProperties(),groups:((i={})[e]=t,i)})},eN=function(e,t,r){var n,i=new eC;return i.set(e,t),(0,Z.__assign)((0,Z.__assign)({},r),{event_type:A.IDENTIFY,user_properties:i.getUserProperties(),groups:((n={})[e]=t,n)})},eF=function(e){return{promise:e||Promise.resolve()}},ej=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 eM(this),this.name=e}return e.prototype._init=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q",function(){return t.isReady=!0})];case 1:return r.sent(),[2]}})})},e.prototype.runQueuedFunctions=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i,o,s,a;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:r=this[e],this[e]=[],l.label=1;case 1:l.trys.push([1,8,9,10]),i=(n=(0,Z.__values)(r)).next(),l.label=2;case 2:if(i.done)return[3,7];if(!((o=(0,i.value)())&&"promise"in o))return[3,4];return[4,o.promise];case 3:return l.sent(),[3,6];case 4:return[4,o];case 5:l.sent(),l.label=6;case 6:return i=n.next(),[3,2];case 7:return[3,10];case 8:return s={error:l.sent()},[3,10];case 9:try{i&&!i.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}
2return[7];case 10:if(!this[e].length)return[3,12];return[4,this.runQueuedFunctions(e,t)];case 11:return l.sent(),[3,13];case 12:null==t||t(),l.label=13;case 13:return[2]}})})},e.prototype.track=function(e,t,r){var n=(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({},"string"==typeof e?{event_type:e}:e),r),t&&{event_properties:t});return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),eF(this.dispatch(n))},e.prototype.identify=function(e,t){var r=eD(e,t);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),eF(this.dispatch(r))},e.prototype.groupIdentify=function(e,t,r,n){var i=eL(e,t,r,n);return eF(this.dispatch(i))},e.prototype.setGroup=function(e,t,r){var n=eN(e,t,r);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),eF(this.dispatch(n))},e.prototype.revenue=function(e,t){var r=(0,Z.__assign)((0,Z.__assign)({},t),{event_type:A.REVENUE,event_properties:e.getEventProperties()});return eF(this.dispatch(r))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),eF())},e.prototype._addPlugin=function(e){return eF(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)),eF())},e.prototype._removePlugin=function(e){return eF(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(ex(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t=this;return(0,Z.__generator)(this,function(r){return this.isReady?[2,this.process(e)]:[2,new Promise(function(r){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,r))})]})})},e.prototype.getOperationAppliedUserProperties=function(e){var t,r=null!=(t=this.userProperties)?t:{},n=(0,Z.__assign)({},r);if(void 0===e)return n;var i={};return Object.keys(e).forEach(function(t){Object.values(O).includes(t)||(i[t]=e[t])}),eP.forEach(function(t){if(Object.keys(e).includes(t)){var r=e[t];switch(t){case O.CLEAR_ALL:Object.keys(n).forEach(function(e){delete n[e]});break;case O.UNSET:Object.keys(r).forEach(function(e){delete n[e]});break;case O.SET:Object.assign(n,r)}}}),Object.assign(n,i),n},e.prototype.process=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),this.config.optOut)return[2,ex(e,0,"Event skipped due to optOut config")];return e.event_type===A.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)];case 1:return 200===(t=n.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 r=String(n.sent()),this.config.loggerProvider.error(r),[2,t=ex(e,0,r)];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 eF(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 r=Math.max(t,1);return e.reduce(function(e,t,n){var i=Math.floor(n/r);return e[i]||(e[i]=[]),e[i].push(t),e},[])},eU="Amplitude Logger ",eB=function(){function e(){this.logLevel=x.None}return e.prototype.disable=function(){this.logLevel=x.None},e.prototype.enable=function(e){void 0===e&&(e=x.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Verbose||console.log("".concat(eU,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Warn||console.warn("".concat(eU,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Error||console.error("".concat(eU,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<x.Debug||console.log("".concat(eU,"[Debug]: ").concat(e.join(" ")))},e}(),ez=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:es,logLevel:x.Warn,loggerProvider:new eB,offline:!1,optOut:!1,serverUrl:ea,serverZone:"US",useBatch:!1}},eW=function(){function e(e){this._optOut=!1;var t,r,n,i,o=ez();this.apiKey=e.apiKey,this.flushIntervalMillis=null!=(t=e.flushIntervalMillis)?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!=(r=e.logLevel)?r:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!=(n=e.optOut)?n:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!=(i=e.useBatch)?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=eG(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
2,enumerable:!1,configurable:!0}),e}(),eG=function(e,t,r){if(void 0===e&&(e=""),void 0===t&&(t=ez().serverZone),void 0===r&&(r=ez().useBatch),e)return{serverUrl:e,serverZone:void 0};var n,i=["US","EU"].includes(t)?t:ez().serverZone;return{serverZone:i,serverUrl:(n=r,"EU"===i?n?ec:el:n?eu:ea)}},eH=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function e$(e){return e>=200&&e<300}var eK=new Set([ea,el,eu,ec]);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,Z.__awaiter)(this,void 0,void 0,function(){var r,n=this;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(eo,"_").concat(this.config.apiKey.substring(0,10)),[4,null==(t=this.config.storageProvider)?void 0:t.get(this.storageKey)];case 1:return(r=i.sent())&&r.length>0&&Promise.all(r.map(function(e){return n.execute(e)})).catch(),[2,Promise.resolve(void 0)]}})})},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=eR()),new Promise(function(r){t.queue.push({event:e,attempts:0,callback:function(e){return r(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.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)})},e.prototype.scheduleEvents=function(e){var t=this;e.forEach(function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)})},e.prototype.schedule=function(e){var t=this;if(!this.config.offline&&(null===this.scheduleId||this.scheduleId&&e>this.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,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n=this;return(0,Z.__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=[],r=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):r.push(e)}),[4,eq(t,this.config.flushQueueSize).reduce(function(t,r){return(0,Z.__awaiter)(n,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return[4,t];case 1:return n.sent(),[4,this.send(r,e)];case 2:return[2,n.sent()]}})})},Promise.resolve())];case 1:return i.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},e.prototype.send=function(e,t){var r;return void 0===t&&(t=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var n,i,o,s,a;return(0,Z.__generator)(this,function(l){var u,c,d;switch(l.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,(0,Z.__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 eH,l.label=1;case 1:return l.trys.push([1,3,,4]),u=i=eG(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,void 0===(c=this.config.enableRequestBodyCompression)&&(c=!1),o=!!eK.has(u)||c,[4,this.config.transportProvider.send(i,n,o)];case 2:if(null===(s=l.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=l.sent())instanceof Error?d.message:String(d),this.config.loggerProvider.error(a),null==(r=this.diagnosticsClient)||r.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(e){return e.event.event_type}),message:a,stack_trace:ee()}),this.handleResponse({status:M.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},e.prototype.handleResponse=function(e,t){e$(e.statusCode)||null==(r=this.diagnosticsClient)||r.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:ee()});var r,n=e.status;switch(n){case M.Success:this.handleSuccessResponse(e,t);break;case M.Invalid:this.handleInvalidResponse(e,t);break;case M.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case M.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 r=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))return void this.fulfillRequest(t,e.statusCode,e.body.error);var n=new Set((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(Object.values(e.body.eventsWithInvalidFields)),!1),(0,Z.__read)(Object.values(e.body.eventsWithMissingFields)),!1),(0,Z.__read)(Object.values(e.body.eventsWithInvalidIdLengths)),!1),(0,Z.__read)(e.body.silencedEvents),!1).flat()),i=t.filter(function(t,i){return!n.has(i)||void r.fulfillRequest([t],e.statusCode,e.body.error)});i.length>0&&this.config.loggerProvider.warn(eV(e));
2var 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 r=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(r)},e.prototype.handleRateLimitResponse=function(e,t){var r=this,n=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(n),a=new Set(i),l=new Set(o),u=t.filter(function(t,n){return t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)?void r.fulfillRequest([t],e.statusCode,e.body.error):(l.has(n)&&(t.timeout=r.throttleTimeout),!0)});u.length>0&&this.config.loggerProvider.warn(eV(e));var c=this.removeEventsExceedFlushMaxRetries(u);this.scheduleEvents(c)},e.prototype.handleOtherResponse=function(e){var t=this,r=e.map(function(e){return e.timeout=e.attempts*t.retryTimeout,e}),n=this.removeEventsExceedFlushMaxRetries(r);this.scheduleEvents(n)},e.prototype.fulfillRequest=function(e,t,r){var n,i,o;e$(t)?null==(o=this.diagnosticsClient)||o.increment("analytics.events.sent",e.length):(null==(n=this.diagnosticsClient)||n.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:r,stack_trace:ee()})),this.removeEvents(e),e.forEach(function(e){return e.callback(ex(e.event,t,r))})},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}(),eY=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){try{var t=JSON.parse(JSON.stringify(e));eI(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?(0,Z.__assign)({},this.properties):{};return e[D.REVENUE_PRODUCT_ID]=this.productId,e[D.REVENUE_QUANTITY]=this.quantity,e[D.REVENUE_PRICE]=this.price,e[D.REVENUE_TYPE]=this.revenueType,e[D.REVENUE_CURRENCY]=this.currency,e[D.REVENUE]=this.revenue,e[D.RECEIPT]=this.receipt,e[D.RECEIPT_SIG]=this.receiptSig,e},e}();(a=D||(D={})).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 eX=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:eQ(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),eQ=function(){return"u">typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},eZ=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}(),e0=function(){return(e0=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function e1(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);
2if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function e2(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var e3=function(e,t){var r,n,i=typeof e;if(i!==typeof t)return!1;try{for(var o=e1(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next())if(s.value===i)return e===t}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}if(null==e&&null==t)return!0;if(null==e||null==t||e.length!==t.length)return!1;var a=Array.isArray(e),l=Array.isArray(t);if(a!==l)return!1;if(a&&l){for(var u=0;u<e.length;u++)if(!e3(e[u],t[u]))return!1}else{if(!e3(Object.keys(e).sort(),Object.keys(t).sort()))return!1;var c=!0;return Object.keys(e).forEach(function(r){e3(e[r],t[r])||(c=!1)}),c}return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),r=t.length,n=Array(r);r--;)n[r]=[t[r],e[t[r]]];return n});var e4=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=e0({},this.identity.userProperties),r=e0(e0({},this.identity),{userProperties:t});return{setUserId:function(e){return r.userId=e,this},setDeviceId:function(e){return r.deviceId=e,this},setUserProperties:function(e){return r.userProperties=e,this},setOptOut:function(e){return r.optOut=e,this},updateUserProperties:function(e){var t,n,i,o,s,a,l=r.userProperties||{};try{for(var u=e1(Object.entries(e)),c=u.next();!c.done;c=u.next()){var d=e2(c.value,2),f=d[0],g=d[1];switch(f){case"$set":try{for(var h=(i=void 0,e1(Object.entries(g))),p=h.next();!p.done;p=h.next()){var v=e2(p.value,2),m=v[0],y=v[1];l[m]=y}}catch(e){i={error:e}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}break;case"$unset":try{for(var _=(s=void 0,e1(Object.keys(g))),b=_.next();!b.done;b=_.next()){var m=b.value;delete l[m]}}catch(e){s={error:e}}finally{try{b&&!b.done&&(a=_.return)&&a.call(_)}finally{if(s)throw s.error}}break;case"$clearAll":l={}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return r.userProperties=l,this},commit:function(){return e.setIdentity(r),this}}},e.prototype.getIdentity=function(){return e0({},this.identity)},e.prototype.setIdentity=function(e){var t=e0({},this.identity);this.identity=e0({},e),e3(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),e5="u">typeof globalThis?globalThis:e.g,e6=function(){function e(){this.identityStore=new e4,this.eventBridge=new eZ,this.applicationContextProvider=new eX}return e.getInstance=function(t){return e5.analyticsConnectorInstances||(e5.analyticsConnectorInstances={}),e5.analyticsConnectorInstances[t]||(e5.analyticsConnectorInstances[t]=new e),e5.analyticsConnectorInstances[t]},e}(),e8=function(e){return void 0===e&&(e=es),e6.getInstance(e)},e7=function(e,t){e8(t).identityStore.editIdentity().setUserId(e).commit()},e9=function(e,t){e8(t).identityStore.editIdentity().setDeviceId(e).commit()},te=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},tt=function(){function e(){this.name="identity",this.type="before",this.identityStore=e8().identityStore}return e.prototype.execute=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]})})},e.prototype.setup=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return e.instanceName&&(this.identityStore=e8(e.instanceName).identityStore),[2]})})},e}(),tr=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(
2Boolean).reduce(function(e,t){var r=t.split("=",2),n=tn(r[0]),i=tn(r[1]);return i&&(e[n]=i),e},{}):{}},tn=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},ti=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 r=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(r))),Promise.resolve({remoteConfig:r.remoteConfig,lastFetch:new Date(r.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}(),to=function(){function e(e,t,r,n,i){void 0===r&&(r="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=n||("US"===r?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new ti(e,t),this.customFetch=i}return e.prototype.subscribe=function(e,t,r){var n=eR(),i={id:n,key:e,deliveryMode:t,callback:r};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),n},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,Z.__awaiter)(this,void 0,void 0,function(){var e,t=this;return(0,Z.__generator)(this,function(r){switch(r.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=r.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(r){t.sendCallback(r,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,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__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)}),r=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,r])];case 1:return void 0!==(n=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(n))),null!==n.remoteConfig?this.sendCallback(e,n,"cache"):this.logger.debug("Remote config client skips sending c
2allback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:r=new Promise(function(e,r){setTimeout(function(){r("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),r])];case 2:return n=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,n,"remote"),this.storage.setConfig(n),[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!==(n=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,n,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,n,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,r){var n;e.lastCallback=new Date,n=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(n,r,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i,o,s,a,l=this;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:r=t/e,n={remoteConfig:null,lastFetch:new Date},i=function(n){var i,s,a,u,c,d,f,g,h;return(0,Z.__generator)(this,function(p){switch(p.label){case 0:i=!0,s=new AbortController,a=setTimeout(function(){return s.abort()},t),p.label=1;case 1:var v,m;if(p.trys.push([1,10,11,12]),u=o.getUrlParams(),c={Accept:"*/*"},!o.customFetch)return[3,3];return[4,(v=o.customFetch({url:u,method:"GET",headers:c,signal:s.signal}),m=s.signal,new Promise(function(e,t){var r=function(){var e=Error("Remote config custom fetch aborted by timeout");e.name="AbortError",t(e)};m.addEventListener("abort",r,{once:!0}),v.then(function(t){m.removeEventListener("abort",r),e(t)},function(e){m.removeEventListener("abort",r),t(e)})}))];case 2:return f=p.sent(),[3,5];case 3:return[4,fetch(u,{method:"GET",headers:c,signal:s.signal})];case 4:f=p.sent(),p.label=5;case 5:if((d=f).ok||d.status>=200&&d.status<300)return[3,7];return[4,d.text()];case 6:return g=p.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(d.status,": ").concat(g)),401===d.status||403===d.status?(o.logger.error("Remote config client fetch failed with ".concat(d.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):d.status>=400&&d.status<500&&429!==d.status&&(i=!1),[3,9];case 7:return[4,d.json()];case 8:return[2,{value:{remoteConfig:p.sent(),lastFetch:new Date}}];case 9:return[3,12];case 10:return(h=p.sent())instanceof Error&&"AbortError"===h.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),h),[3,12];case 11:return clearTimeout(a),[7];case 12:if(!i)return[2,"break"];if(!(n<e-1))return[3,14];return[4,new Promise(function(e){return setTimeout(e,l.getJitterDelay(r))})];case 13:p.sent(),p.label=14;case 14:return[2]}})},o=this,s=0,u.label=1;case 1:if(!(s<e))return[3,4];return[5,i(s)];case 2:if("object"==typeof(a=u.sent()))return[2,a.value];if("break"===a)return[3,4];u.label=3;case 3:return s++,[3,1];case 4:return[2,n]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),r=new URLSearchParams;return r.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(r.toString())},e.CONFIG_GROUP="browser",e}(),ts="tags",ta="counters",tl="histograms",tu="events",tc="internal",td="last_flush_timestamp",tf=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return(null==(e=(0,eO.getGlobalScope)())?void 0:e.indexedDB)!==void 0},e.prototype.getDB=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},e.prototype.openDB=function(){var e=this;return new Promise(function(t,r){var n=indexedDB.open(e.dbName,1);n.onerror=function(){e.dbPromise=null,r(Error("Failed to open IndexedDB"))},n.onsuccess=function(){var r=n.result;r.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},r.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),r.close()},t(r)},n.onupgradeneeded=function(){var t=n.result;t?e.createTables(t):e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.")}})},e.prototype.createTables=function(e){e.objectStoreNames.contains(ts)||e.createObjectStore(ts,{keyPath:"key"}),e.objectStoreNames.contains(ta)||e.createObjectStore(ta,{keyPath:"key"}),e.objectStoreNames.contains(tl)||e.createObjectStore(tl,{keyPath:"key"}),e.objectStoreNames.contains(tu)||e.createObjectStore(tu,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1}),e.objectStoreNames.contains(tc)||e.createObjectStore(tc,{keyPath:"key"})},e.prototype.setTags=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.tr
2ys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return r=(t=o.sent().transaction([ts],"readwrite")).objectStore(ts),[2,new Promise(function(n){var o=Object.entries(e);t.oncomplete=function(){n()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to set tags",e),n()},o.forEach(function(e){var t=(0,Z.__read)(e,2),n=t[0],o=t[1];r.put({key:n,value:o}).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to set tag",n,o,e)}})})];case 2:return n=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",n),[3,3];case 3:return[2]}})})},e.prototype.incrementCounters=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return r=(t=o.sent().transaction([ta],"readwrite")).objectStore(ta),[2,new Promise(function(n){var o=Object.entries(e);t.oncomplete=function(){n()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to increment counters",e),n()},o.forEach(function(e){var t=(0,Z.__read)(e,2),n=t[0],o=t[1],s=r.get(n);s.onsuccess=function(){var e=s.result,t=e?e.value:0;r.put({key:n,value:t+o}).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},s.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}})})];case 2:return n=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",n),[3,3];case 3:return[2]}})})},e.prototype.setHistogramStats=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===Object.entries(e).length)return[2];return[4,this.getDB()];case 1:return r=(t=o.sent().transaction([tl],"readwrite")).objectStore(tl),[2,new Promise(function(n){var o=Object.entries(e);t.oncomplete=function(){n()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),n()},o.forEach(function(e){var t=(0,Z.__read)(e,2),n=t[0],o=t[1],s=r.get(n);s.onsuccess=function(){var e,t=s.result;e=t?{key:n,count:t.count+o.count,min:Math.min(t.min,o.min),max:Math.max(t.max,o.max),sum:t.sum+o.sum}:{key:n,count:o.count,min:o.min,max:o.max,sum:o.sum},r.put(e).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},s.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}})})];case 2:return n=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n),[3,3];case 3:return[2]}})})},e.prototype.addEventRecords=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,3]),0===e.length)return[2];return[4,this.getDB()];case 1:return r=(t=o.sent().transaction([tu],"readwrite")).objectStore(tu),[2,new Promise(function(n){t.oncomplete=function(){n()},t.onabort=function(e){i.logger.debug("DiagnosticsStorage: Failed to add event records",e),n()};var o=r.count();o.onsuccess=function(){var t=Math.max(0,10-o.result);t<e.length&&i.logger.debug("DiagnosticsStorage: Only added ".concat(t," of ").concat(e.length," events due to storage limit")),e.slice(0,t).forEach(function(e){r.add(e).onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to add event record",e)}})},o.onerror=function(e){i.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}})];case 2:return n=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",n),[3,3];case 3:return[2]}})})},e.prototype.setInternal=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=(r=o.sent().transaction([tc],"readwrite")).objectStore(tc),[2,new Promise(function(i,o){r.onabort=function(){return o(Error("Failed to set internal value"))};var s=n.put({key:e,value:t});s.onsuccess=function(){return i()},s.onerror=function(){return o(Error("Failed to set internal value"))}})];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",i),[3,3];case 3:return[2]}})})},e.prototype.getInternal=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getDB()];case 1:return r=(t=i.sent().transaction([tc],"readonly")).objectStore(tc),[2,new Promise(function(n,i){t.onabort=function(){return i(Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return n(o.result)},o.onerror=function(){return i(Error("Failed to get internal value"))}})];case 2:return n=i.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",n),[2,void 0];case 3:return[2]}})})},e.prototype.getLastFlushTimestamp=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getInternal(td)];case 1:return[2,(e=r.sent())?parseInt(e.value,10):void 0];case 2:return t=r.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}})})},e.prototype.setLastFlushTimestamp=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.setInternal(td,e.toString())];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}})})},e.prototype.clearTable=function(e,t){return new Promise(function(r,n){var i=e.objectStore(t).clear();i.onsuccess=function(){return r()},i.onerror=function(){return n(Error("Failed to clear table ".concat(t)))}})},e.prototype.getAllAndClear=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,r,n,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=a.sent().transaction([ts,ta,tl,tu],"readwrite"),[4,Promise.all([this.getAllFromStore(e,ts),this.getAllFromStore(e,ta),this.getAllFromStore(e,tl),this.getAllFromStore(e,tu)])];case 2:return r=(t=Z.__read.apply(void 0,[a.sent(),4]))[0],n=t[1],i=t[2],o=t[3],[4,Promise.all([this.clearTable(e,ta),this.clearTable(e,tl),this.clearTable(e,tu)])];case 3:return a.sent(),[2,{tags:r,counters:n,histogramStats:i,events:o}];case 4:return s=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",s),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},e.prototype.getAllFromStore=function(e,t){return new Promise(function(r,n){var i=e.objectStore(t).getAll();i.onsuccess=function(){return r(i.result)},i.onerror=function(){return n(Error("Failed to get all from ".concat(t)))}})},e}(),tg=function(e){var t=0;if(0===e.length)return t;for(var r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return t}
2,th=function(e,t){return 31*Math.abs(tg(e.toString()))%1e5/1e5<t},tp=function(){var e=(0,eO.getGlobalScope)();if(!e)return[];var t=e.__AMPLITUDE_SCRIPT_URL__;return Array.isArray(t)?t:"string"==typeof t?[t]:[]},tv=function(e){var t=(0,eO.getGlobalScope)();if(t&&"function"==typeof t.addEventListener){var r=function(t){e.recordEvent("sdk.error.uncaught",(0,Z.__assign)({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",function(e){var t=e.error instanceof Error?e.error:void 0,n=null==t?void 0:t.stack,i=tm({filename:e.filename,stack:n});i&&r({type:"error",message:e.message,stack:n,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})},!0),t.addEventListener("unhandledrejection",function(e){var t,n=e.reason instanceof Error?e.reason:void 0,i=null==n?void 0:n.stack,o=ty(i),s=tm({filename:o,stack:i});s&&r({type:"unhandledrejection",message:null!=(t=null==n?void 0:n.message)?t:t_(e.reason),stack:i,filename:o,errorName:null==n?void 0:n.name,metadata:{isTrusted:e.isTrusted,matchReason:s}})},!0)}},tm=function(e){var t,r,n=tp();if(0!==n.length)try{for(var i=(0,Z.__values)(n),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.filename&&e.filename.includes(s))return"filename";if(e.stack&&e.stack.includes(s))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},ty=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},t_=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},tb=function(){function e(e,t,r,n){void 0===r&&(r="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===r?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(n,null,2)),this.config=(0,Z.__assign)({enabled:!0,sampleRate:0},n),this.startTimestamp=Date.now(),this.shouldTrack=th(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,tf.isSupported()?this.storage=new tf(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),tv(this))}return e.prototype.isStorageAndTrackEnabled=function(){return!!this.storage&&!!this.shouldTrack},e.prototype.setTag=function(e,t){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryTags).length>=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 r=this.inMemoryHistograms[e];r?(r.count+=1,r.min=Math.min(r.min,t),r.max=Math.max(r.max,t),r.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,Z.__awaiter)(this,void 0,void 0,function(){var e,t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];return e=(0,Z.__assign)({},this.inMemoryTags),t=(0,Z.__assign)({},this.inMemoryCounters),r=(0,Z.__assign)({},this.inMemoryHistograms),n=(0,Z.__spreadArray)([],(0,Z.__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(r),this.storage.addEventRecords(n)])];case 1:return i.sent(),[2]}})})},e.prototype._flush=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,r,n,i,o,s,a,l,u;return(0,Z.__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,r=e.counters,n=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach(function(e){o[e.key]=e.value}),s={},r.forEach(function(e){s[e.key]=e.value}),a={}
2,n.forEach(function(e){a[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}}),l=i.map(function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}}),0===Object.keys(s).length&&0===Object.keys(a).length&&0===l.length)return[2];return u={tags:o,histogram:a,counters:s,events:l},this.fetch(u),[2]}})})},e.prototype.fetch=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(r.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(!r.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=r.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}})})},e.prototype.initializeFlushInterval=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,r;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(!this.storage)return[2];return e=Date.now(),[4,this.storage.getLastFlushTimestamp()];case 1:if(-1===(t=n.sent()||-1))return this.storage.setLastFlushTimestamp(e),this._setFlushTimer(3e5),[2];return(r=e-t)>=3e5?this._flush():this._setFlushTimer(3e5-r),[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=th(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),tw=e.i(422284),tS=tw.default||tw,tE=function(e,t){var r,n,i;return"boolean"==typeof e?e:(null==e?void 0:e[t])!==!1&&("string"!=typeof(null==(n=null==(r=null==(i=(0,eO.getGlobalScope)())?void 0:i.chrome)?void 0:r.runtime)?void 0:n.id)||!!(null==e?void 0:e[t]))},tk=function(e){return tE(e,"attribution")},tI=function(e){return tE(e,"formInteractions")},tT=function(e){return tE(e,"pageViews")},tC=function(e){return tE(e,"sessions")},tP=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},tx=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)},tA=function(e){if("object"==typeof e.autocapture){var t=e.autocapture.performanceTracking;if(!0===t)return{mainThreadBlock:!0};if("object"==typeof t&&null!==t)return t}},tR=function(e){if(tx(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},tM=function(e){if(tO(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},tD=function(e){if(tP(e.autocapture)){var t,r,n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),(0,Z.__assign)((0,Z.__assign)({},n),{captureRules:(t=null==n?void 0:n.captureRules,r=e.loggerProvider,null==t?void 0:t.map(function(e){var t,n;if((null==(t=e.urls)?void 0:t.length)&&(null==(n=e.hosts)?void 0:n.length)){var i=JSON.stringify(e.hosts),o=JSON.stringify(e.urls);return null==r||r.warn("Found network capture rule with both urls='".concat(o,"' and hosts='").concat(i,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),(0,Z.__assign)((0,Z.__assign)({},e),{hosts:void 0})}return e}))})}},tL=function(e){var t,r=function(){return!1},n=void 0,i=e.pageCounter;return tT(e.defaultTracking)&&(r=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:r,trackHistoryChanges:n,eventType:t,pageCounter:i}},tN=function(e){if(tI(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions},tF=function(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.name,o=n.args,s=n.resolve,a=e&&e[i];if("function"==typeof a){var l=a.apply(e,o);"function"==typeof s&&s(null==l?void 0:l.promise)}}return e},tj=function(e){return e&&void 0!==e._q},tq=function(){if("u"<typeof navigator)return"";var e,t,r,n,i=navigator.userLanguage;return null!=(n=null!=(r=null!=(t=null==(e=navigator.languages)?void 0:e[0])?t:navigator.language)?r:i)?n:""},tU="2.45.5",tB="amplitude-ts",tz=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(tB,"/").concat(tU),"u">typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,i,o;return(0,Z.__generator)(this,function(s){return n=new Date().getTime(),i=null!=(t=this.config.lastEventId)?t:-1,o=null!=(r=e.event_id)?r:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=n),[2,(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:n},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:eR(),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}(),tW=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2,!0]})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,this.memoryStorage.get(e)]})})},e.prototype.getRaw=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return[4,this.get(e)];case 1:return[2,(t=r.sent())?JSON.stringify(t):void 0]}})})},e.prototype.set=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return this.memoryStorage.set(e,t),[2]})})},e.prototype.remove=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return this.memoryStorage.delete(e),[2]})})},e.prototype.reset=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return this.memoryStorage.clear(),[2]})})},e}(),tG=function(){var e,t=(0,eO.getGlobalScope)();return null==(e=null==t?void 0:t.navigator)?void 0:e.locks},tH=function(){function e(e,t){void 0===t&&(t={}),this.options=(0,Z.__assign)({},e),this.config=t}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:return t="AMP_TEST",r=new e((0,Z.__assign)({},this.options)),n=String(Date.now()),[4,r.transaction(t,function(e){var r,o;try{e.set(n);var s=e.get()===n;return!s&&i.config.diagnosticsClient&&(null==(r=i.config.diagnosticsClient)||r.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:n,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:n,error:a,sync:!0})}return!1}
2finally{e.set(null)}})];case 1:return[2,o.sent()]}})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return[4,this.getRaw(e)];case 1:return t=r.sent(),[2,this.decodeCookieValue(e,t)]}})})},e.prototype.decodeCookieValue=function(e,t){if(t)try{var r=tV(t);if(void 0===r)return void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t));return JSON.parse(r)}catch(r){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,r;return(0,Z.__awaiter)(this,void 0,void 0,function(){var n,i,o,s,a,l,u,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:n=(0,eO.getGlobalScope)(),d.label=1;case 1:if(d.trys.push([1,4,,5]),!(i=null==n?void 0:n.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==(r=this.config.diagnosticsClient)||r.increment("cookies.duplicate.occurrence.cookieStore"));try{for(a=(s=(0,Z.__values)(o)).next();!a.done;a=s.next())if(l=a.value,tJ(l.domain,this.options.domain))return[2,l.value]}catch(e){u={error:e}}finally{try{a&&!a.done&&(c=s.return)&&c.call(s)}finally{if(u)throw u.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,r,n=this,i=(0,eO.getGlobalScope)(),o=(null!=(r=null==(t=null==i?void 0:i.document)?void 0:t.cookie.split("; "))?r:[]).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 r;try{var i=a(t.substring(e.length+1));return i||null==(r=n.config.diagnosticsClient)||r.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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return this.setSync(e,t),[2]})})},e.prototype.setSync=function(e,t){var r;try{var n=(0,eO.getGlobalScope)();if(!n||!n.document||"function"!=typeof n.btoa||"function"!=typeof n.encodeURIComponent)return;var i=null!=(r=this.options.expirationDays)?r:0,o=null!==t?i:-1,s=void 0;if(o){var a=new Date;a.setTime(a.getTime()+24*o*36e5),s=a}var l="".concat(e,"=").concat(n.btoa(n.encodeURIComponent(JSON.stringify(t))));s&&(l+="; expires=".concat(s.toUTCString())),l+="; path=/",this.options.domain&&(l+="; domain=".concat(this.options.domain)),this.options.secure&&(l+="; Secure"),this.options.sameSite&&(l+="; SameSite=".concat(this.options.sameSite)),n.document.cookie=l}catch(t){var u=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(u))}},e.prototype.remove=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2]})})},e.isDomainWritable=function(t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];r="AMP_TLDTEST",n=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n.transaction(r,function(r){if(e.cachedTlds[t])return!0;try{r.set(1);var n=!!r.get();return n&&(e.cachedTlds[t]=!0),n}finally{r.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,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i=this;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(r=tG(),n=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!r)return[2,n()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,r.request("com.amplitude:cookie-lock:".concat(e),n)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,n()];case 4:return[2]}})})},e.cachedTlds={},e}(),t$=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=t$(e))?t:tK(e)},tJ=function(e,t){if(""===e&&""===t)return!0;
2if(!e||!t)return!1;var r=e.startsWith(".")?e.substring(1):e,n=t.startsWith(".")?t.substring(1):t;return r.toLowerCase()===n.toLowerCase()},tY=function(e,t,r){return void 0===t&&(t=""),void 0===r&&(r=10),["AMP",t,e.substring(0,r)].filter(Boolean).join("_")},tX=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),r=new e(this.storage),n="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,r.set(n,t)];case 2:return i.sent(),[4,r.get(n)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,r.remove(n)];case 6:return i.sent(),[7];case 7:return[2]}})})},e.prototype.get=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:if(!(t=r.sent()))return[2,void 0];return[2,JSON.parse(t)];case 2:return r.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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return[2,(null==(t=this.storage)?void 0:t.getItem(e))||void 0]})})},e.prototype.set=function(e,t){var r;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){try{null==(r=this.storage)||r.setItem(e,JSON.stringify(t))}catch(e){}return[2]})})},e.prototype.remove=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){try{null==(t=this.storage)||t.removeItem(e)}catch(e){}return[2]})})},e.prototype.reset=function(){var e;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){try{null==(e=this.storage)||e.clear()}catch(e){}return[2]})})},e}(),tQ=function(e){function t(t){var r,n,i,o=this;try{i=null==(r=(0,eO.getGlobalScope)())?void 0:r.localStorage}catch(e){null==(n=null==t?void 0:t.loggerProvider)||n.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,Z.__extends)(t,e),t.prototype.set=function(t,r){var n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i;return(0,Z.__generator)(this,function(o){switch(o.label){case 0:if(!(Array.isArray(r)&&r.length>1e3))return[3,2];return i=r.length-1e3,[4,e.prototype.set.call(this,t,r.slice(0,1e3))];case 1:return o.sent(),null==(n=this.loggerProvider)||n.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,r)];case 3:o.sent(),o.label=4;case 4:return[2]}})})},t}(tX),tZ=function(e){function t(){var t;return e.call(this,null==(t=(0,eO.getGlobalScope)())?void 0:t.sessionStorage)||this}return(0,Z.__extends)(t,e),t}(tX),t0=function(){function e(){}return e.prototype.send=function(e,t,r){return Promise.resolve(null)},e.prototype.buildResponse=function(e){if("object"!=typeof e)return null;var t,r,n,i,o,s,a,l,u,c,d,f,g,h,p,v,m,y,_,b,w,S,E=e.code||0,k=this.buildStatus(E);switch(k){case M.Success:return{status:k,statusCode:E,body:{eventsIngested:null!=(t=e.events_ingested)?t:0,payloadSizeBytes:null!=(r=e.payload_size_bytes)?r:0,serverUploadTime:null!=(n=e.server_upload_time)?n:0}};case M.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!=(l=e.events_with_invalid_id_lengths)?l:{},epsThreshold:null!=(u=e.eps_threshold)?u: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 M.PayloadTooLarge:return{status:k,statusCode:E,body:{error:null!=(p=e.error)?p:""}};case M.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 M.Timeout:default:return{status:k,statusCode:E}}},e.prototype.buildStatus=function(e){return e$(e)?M.Success:429===e?M.RateLimit:413===e?M.PayloadTooLarge:408===e?M.Timeout:e>
2=400&&e<500?M.Invalid:e>=500?M.Failed:M.Unknown},e}();function t1(){return"u">typeof CompressionStream}function t2(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,new Response(new Blob([e]).stream().pipeThrough(new t("gzip"))).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}})})}var t3=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.state={done:4},r.customHeaders=t,r}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,r){return void 0===r&&(r=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var n=this;return(0,Z.__generator)(this,function(i){return[2,new Promise(function(i,o){"u"<typeof XMLHttpRequest&&o(Error("XHRTransport is not supported."));var s=new XMLHttpRequest;s.open("POST",e,!0),s.onreadystatechange=function(){if(s.readyState===n.state.done){var e=s.responseText;try{i(n.buildResponse(JSON.parse(e)))}catch(e){i(n.buildResponse({code:s.status}))}}};var a={"Content-Type":"application/json",Accept:"*/*"},l=JSON.stringify(t),u=r&&l.length>=2048&&t1(),c=function(e){var t,r;a=(0,Z.__assign)((0,Z.__assign)({},n.customHeaders),a);try{for(var i=(0,Z.__values)(Object.entries(a)),o=i.next();!o.done;o=i.next()){var l=(0,Z.__read)(o.value,2),u=l[0],c=l[1];s.setRequestHeader(u,c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}s.send(e)};(0,Z.__awaiter)(n,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(!u)return[3,2];return[4,t2(l)];case 1:return(e=t.sent())?(a["Content-Encoding"]="gzip",c(e)):c(l),[3,3];case 2:c(l),t.label=3;case 3:return[2]}})}).catch(o)})]})})},t}(t0),t4=function(e){function t(t,r,n){void 0===t&&(t={});var i=e.call(this)||this;return i.customHeaders=t,i.enableKeepalive=!1!==r,i.referrerPolicy=n,i}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,r){return void 0===r&&(r=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var n,i,o,s,a,l,u,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:if("u"<typeof fetch)throw Error("FetchTransport is not supported");if(n=JSON.stringify(t),i=r&&n.length>=2048&&t1(),o=n,s={"Content-Type":"application/json",Accept:"*/*"},!i)return[3,2];return[4,t2(n)];case 1:(a=f.sent())&&(s["Content-Encoding"]="gzip",o=a),f.label=2;case 2:return s=(0,Z.__assign)((0,Z.__assign)({},this.customHeaders),s),l="string"==typeof o?o.length:o.byteLength,u={headers:s,body:o,method:"POST",keepalive:this.enableKeepalive&&l<=16384},this.referrerPolicy&&(u.referrerPolicy=this.referrerPolicy),[4,fetch(e,u)];case 3:return[4,(c=f.sent()).text()];case 4:d=f.sent();try{return[2,this.buildResponse(JSON.parse(d))]}catch(e){return[2,this.buildResponse({code:c.status})]}}})})},t}(t0),t5=function(e){function t(){return e.call(this)||this}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t,r){return void 0===r&&(r=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var r=this;return(0,Z.__generator)(this,function(n){return[2,new Promise(function(n,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 n(r.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}));return n(r.buildResponse({code:500}))}catch(e){i(e)}})]})})},t}(t0),t6=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},t8=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},t7="[Amplitude]",t9="".concat(t7," Form Started"),re="".concat(t7," Form Submitted"),rt="".concat(t7," File Downloaded"),rr="session_start",rn="session_end",ri="".concat(t7," File Extension"),ro="".concat(t7," File Name"),rs="".concat(t7," Link ID"),ra="".concat(t7," Link Text"),rl="".concat(t7," Link URL"),ru="".concat(t7," Form ID"),rc="".concat(t7," Form Name"),rd="".concat(t7," Form Destination"),rf="cookie",rg={always:"always",ifEmptyCampaign:"ifEmptyCampaign"},rh=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},rp=function(e,t,r,n,i,o){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=(0,Z.__rest)(e,["referrer","referring_domain"]),l=t||{},u=(l.referrer,l.referring_domain),c=(0,Z.__rest)(l,["referrer","referring_domain"]),d=r.excludeInternalReferrers;if(d){var f=r_(d,n);if(!(f instanceof TypeError)&&e.referring_domain&&rE(e.referring_domain,o)){if
2("always"===f)return rb(f,e.referring_domain,n),!1;else if("ifEmptyCampaign"===f&&Object.values((0,Z.__assign)((0,Z.__assign)({},e),{referring_domain:void 0,referrer:void 0})).every(function(e){return!e}))return rb(f,e.referring_domain,n),!1}}if(rv(r.excludeReferrers,e.referring_domain))return n.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 n.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=rh(s||"")!==rh(u||""),p=!t||g||h;return p?n.debug("This is a new campaign. An $identify event will be sent."):n.debug("This is not a new campaign because it's the same as the previous one."),p},rv=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})},rm=function(e,t){var r=t.startsWith(".")?t:".".concat(t);return!!(e.startsWith(".")?e:".".concat(e)).endsWith(r)},ry=function(e){var t=e;return t?(t.startsWith(".")&&(t=t.substring(1)),[new RegExp("".concat(t.replace(".","\\."),"$"))]):[]},r_=function(e,t){if(!0===e)return rg.always;if("object"==typeof e){var r=e.condition;if("string"==typeof r&&Object.keys(rg).includes(r))return r;if(void 0===r)return rg.always}var n="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(n),TypeError(n)};function rb(e,t,r){var n="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?r.debug(n):"ifEmptyCampaign"===e&&r.debug("".concat(n," with empty campaign parameters"))}var rw=["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"],rS=function(e){var t,r,n=e||(null==(r=null==(t=(0,eO.getGlobalScope)())?void 0:t.location)?void 0:r.hostname);if(!n)return"";var i=n.split("."),o=i[i.length-1],s=i[i.length-2];return(rw.find(function(e){return n.endsWith(".".concat(e))})&&(o=i[i.length-2]+"."+i[i.length-1],s=i[i.length-3]),s)?"".concat(s,".").concat(o):o},rE=function(e,t){var r=(0,eO.getGlobalScope)();return!!r&&rm(e,(t||"").trim()||rS(r.location.hostname))},rk=function(e){function t(t,r,n,i,o,s,a,l,u,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,I,T,C,P,O,A,R,M,D,L,N,F,j,q,U,B,z,W,G,H){void 0===n&&(n=new tW),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===l&&(l=1e3),void 0===u&&(u=5),void 0===c&&(c=30),void 0===d&&(d=rf),void 0===v&&(v=new eB),void 0===m&&(m=x.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 tQ({loggerProvider:v})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===A&&(A="fetch"),void 0===R&&(R=!1),void 0===M&&(M=!0),void 0===q&&(q=!0),void 0===U&&(U=0),void 0===G&&(G=!1);var $,K=this;(K=e.call(this,{apiKey:t,storageProvider:P,transportProvider:rC(A)})||this).apiKey=t,K.appVersion=r,K.cookieOptions=i,K.defaultTracking=o,K.autocapture=s,K.flushIntervalMillis=l,K.flushMaxRetries=u,K.flushQueueSize=c,K.identityStorage=d,K.ingestionMetadata=f,K.instanceName=g,K.loggerProvider=v,K.logLevel=m,K.minIdLength=y,K.offline=_,K.partnerId=w,K.plan=S,K.serverUrl=E,K.serverZone=k,K.sessionTimeout=C,K.storageProvider=P,K.trackingOptions=O,K.transport=A,K.useBatch=R,K.fetchRemoteConfig=M,K.networkTrackingOptions=F,K.identify=j,K.enableDiagnostics=q,K.diagnosticsSampleRate=U,K.diagnosticsClient=B,K.remoteConfig=z,K.topLevelDomain=W,K.enableRequestBodyCompression=G,K.customEnrichment=H,K.version=tU,K._optOut=!1,K._cookieStorage=n,K.deviceId=a,K.lastEventId=h,K.lastEventTime=p,K.optOut=b,K.deferredSessionId=T,K.sessionId=I,K.pageCounter=L,K.userId=D,K.debugLogsEnabled=N,K.loggerProvider.enable(N?x.Debug:K.logLevel),K.networkTrackingOptions=F,K.identify=j,K.enableDiagnostics=q,K.diagnosticsSampleRate=U,K.diagnosticsClient=B;var V=null!=($=null==z?void 0:z.fetchRemoteConfig)?$:M;return K.remoteConfig=K.remoteConfig||{},K.remoteConfig.fetchRemoteConfig=V,K.fetchRemoteConfig=V,K.topLevelDomain=W||rS(),K}return(0,Z.__extends)(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())}
2,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 tH&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(tY(this.apiKey),e)},t}(eW),rI=function(e,t,r){switch(void 0===e&&(e=rf),void 0===t&&(t={}),e){case"localStorage":return new tQ;case"sessionStorage":return new tZ;case"none":return new tW;default:return new tH((0,Z.__assign)((0,Z.__assign)({},t),{expirationDays:t.expiration}),r)}},rT=function(e){var t,r;return void 0===e&&(e={}),(null==(t=e.remoteConfig)?void 0:t.fetchRemoteConfig)===!0||(null==(r=e.remoteConfig)?void 0:r.fetchRemoteConfig)!==!1&&!1!==e.fetchRemoteConfig},rC=function(e){var t="object"==typeof e?e.type:e,r="object"==typeof e?e.headers:void 0,n="object"==typeof e?e.enableKeepalive:void 0,i="object"==typeof e?e.referrerPolicy:void 0;return"xhr"===t?new t3(r):"beacon"===t?new t5:new t4(r,n,i)},rP="data-amp-mask",rx="*****",rO=/\b(?:\d[ -]*?){13,16}\b/,rA=/(\d{3}-?\d{2}-?\d{4})/g,rR=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,rM=function(e,t){if(void 0===t&&(t=[]),"string"!=typeof e)return"";var r,n,i=e;i=(i=(i=i.replace(rO,rx)).replace(rA,rx)).replace(rR,rx);try{for(var o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,rx)}catch(e){}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},rD=function(e){if("u"<typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(rP)?rx:e?e(document.title):document.title},rL=function(){function e(){}return e.prototype.parse=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return[2,(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({},eS),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},e.prototype.getUtmParam=function(){var e=tr();
2return{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,r={referrer:void 0,referring_domain:void 0};try{r.referrer=document.referrer||void 0,r.referring_domain=null!=(t=null==(e=r.referrer)?void 0:e.split("/")[2])?t:void 0}catch(e){}return r},e.prototype.getClickIds=function(){var e,t=tr();return(e={})[ed]=t[ed],e[ef]=t[ef],e[eg]=t[eg],e[eh]=t[eh],e[ep]=t[ep],e[ev]=t[ev],e[em]=t[em],e[ey]=t[ey],e[e_]=t[e_],e[eb]=t[eb],e[ew]=t[ew],e},e}(),rN=function(e){var t={};for(var r in e){var n=e[r];n&&(t[r]=n)}return t},rF="AMP_PAGE_VIEW",rj=function(e){void 0===e&&(e={});var t,r,n,i=(0,eO.getGlobalScope)(),o=void 0,s=!1,a=e.trackOn,l=e.trackHistoryChanges,u=e.eventType,c=void 0===u?"[Amplitude] Page Viewed":u,d=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==o||o.error("Malformed URI sequence: ",e)}return t},f=function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return t=d("u">typeof location&&location.href||""),n={event_type:c},r=[{}],[4,rq()];case 1:return[2,(n.event_properties=Z.__assign.apply(void 0,[Z.__assign.apply(void 0,r.concat([i.sent()])),{"[Amplitude] Page Domain":"u">typeof location&&location.hostname||"","[Amplitude] Page Location":t,"[Amplitude] Page Path":"u">typeof location&&d(location.pathname)||"","[Amplitude] Page Title":rD(rM),"[Amplitude] Page URL":t.split("?")[0],"[Amplitude] Page View ID":e}]),n)]}})})},g=function(){return void 0===a||"function"==typeof a&&a()},h="u">typeof location?location.href:null,p=function(){(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,r,i,s,a;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:if(r=rB(l,e=location.href,h||"")&&g(),h=e,!r)return[3,4];if(i=void 0,n&&(i=eR(),n.set(rF,{pageViewId:i})),null==o||o.log("Tracking page view event"),null!=t)return[3,1];return[3,3];case 1:return a=(s=t).track,[4,f(i)];case 2:a.apply(s,[u.sent()]),u.label=3;case 3:u.label=4;case 4:return[2]}})})};return{name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,a){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var l,u,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:if(t=a,r=e,(o=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),s=!0,i){try{n=new tX(i.sessionStorage)}catch(e){null==o||o.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",p),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,r){var n=(0,Z.__read)(r,3),i=n[0],o=n[1],a=n[2];e.apply(t,[i,o,a]),s&&p()}})}if(!g())return[3,2];return o.log("Tracking page view event"),l=void 0,n&&(l=eR(),n.set(rF,{pageViewId:l})),c=(u=t).track,[4,f(l)];case 1:c.apply(u,[d.sent()]),d.label=2;case 2:return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,i,s;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:if(!("attribution"===a&&rU(e)))return[3,4];if(null==o||o.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,!n)return[3,2];return[4,n.get(rF)];case 1:t=null==(i=l.sent())?void 0:i.pageViewId,l.label=2;case 2:return[4,f(t)];case 3:e.event_type=(s=l.sent()).event_type,e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),s.event_properties),l.label=4;case 4:return r&&e.event_type===c&&(r.pageCounter=r.pageCounter?r.pageCounter+1:1,e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),{"[Amplitude] Page Counter":r.pageCounter})),[2,e]}})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return i&&(i.removeEventListener("popstate",p),s=!1),[2]})})}}},rq=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(t){switch(t.label){case 0:return e=rN,[4,new rL().parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}})})},rU=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,r=t[O.SET]||{},n=t[O.UNSET]||{},i=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(Object.keys(r)),!1),(0,Z.__read)(Object.keys(n)),!1);return Object.keys(eS).every(function(e){return i.includes(e)})}return!1},rB=function(e,t,r){if("pathOnly"!==e)return t!==r;if(""==r)return!0;var n=new URL(t),i=new URL(r);return n.origin+n.pathname!==i.origin+i.pathname},rz=function(){var e,t,r=[],n=function(e,t,n){e.addEventListener(t,n),r.push({element:e,type:t,handler:n})},i=function(){r.forEach(function(e){var t=e.element,r=e.type,n=e.handler;null==t||t.removeEventListener(r,n)}),r=[]};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(r,i){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Z.__generator)(this,function(a){return t=tN(r),o=function(){if(!i)return void r.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;n(e,"change",function(){var t,r=rG(e);s||i.track(t9,((t={})[ru]=rW(e.id),t[rc]=rW(e.name),t[rd]=r,t)),s=!0}),n(e,"submit",function(n){var o,a,l=rG(e);if(s||i.track(t9,((o={})[ru]=rW(e.id),o[rc]=rW(e.name),o[rd]=l,o)),s=!0,(null==t?void 0:t.shouldTrackSubmit)!==void 0)if("function"==typeof t.shouldTrackSubmit&&"u">typeof SubmitEvent&&n instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(n))return}catch(e){r.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else r.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(re,((a={})[ru]=rW(e.id),a[rc]=rW(e.name),a[rd]=l,a)),s=!1})}};
2Array.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):r.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return null==e||e.disconnect(),i(),[2]})})}}},rW=function(e){if("string"==typeof e)return e},rG=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},rH=function(){var e,t=[],r=function(e,r,n){e.addEventListener(r,n),t.push({element:e,type:r,handler:n})},n=function(){t.forEach(function(e){var t=e.element,r=e.type,n=e.handler;null==t||t.removeEventListener(r,n)}),t=[]};return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(t,n){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var i,o;return(0,Z.__generator)(this,function(s){return i=function(){if(!n)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&&r(e,"click",function(){var r;s&&n.track(rt,((r={})[ri]=s,r[ro]=t.pathname,r[rs]=e.id,r[ra]=e.text,r[rl]=e.href,r))})},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,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return null==e||e.disconnect(),n(),[2]})})}}},r$=!1,rK=function(e){r$||void 0!==e.defaultTracking||(e.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),r$=!0)},rV=function(){var e=(0,eO.getGlobalScope)(),t=[],r=function(r,n){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(r,n),t.push({type:r,handler:n}))},n=function(){t.forEach(function(t){var r=t.type,n=t.handler;null==e||e.removeEventListener(r,n)}),t=[]};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){return"u"<typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1):(e.offline=!navigator.onLine,r("online",function(){!1!==e.offline&&(e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout(function(){t.flush()},e.flushIntervalMillis))}),r("offline",function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return n(),[2]})})}}};function rJ(e,t,r){var n,i,o=[];try{for(var s=(0,Z.__values)(null!=t?t:[]),a=s.next();!a.done;a=s.next()){var l=a.value;try{o.push(new RegExp(l))}catch(e){r.warn("Invalid regex pattern: ".concat(l),e)}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return e.concat(o)}var rY=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],rX="data-amp-track-",rQ=["div","span","h1","h2","h3","h4","h5","h6"],rZ="https://app.amplitude.com",r0={US:rZ,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},r1="__AMPLITUDE_MESSENGER_INSTANCE__",r2="__AMPLITUDE_MESSENGER__",r3=function(){function e(e){var t=(void 0===e?{}:e).origin;this[L]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=void 0===t?rZ:t}return e.prototype.notify=function(e){var t,r,n,i;null==(r=null==(t=this.logger)?void 0:t.debug)||r.call(t,"Message sent: ",JSON.stringify(e)),null==(i=null==(n=window.opener)?void 0:n.postMessage)||i.call(n,e,this.endpoint)},e.prototype.sendRequest=function(e,t,r){var n=this;void 0===r&&(r={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){n.requestCallbacks[i]={resolve:t,reject:s},n.notify(o),r.timeout>0&&setTimeout(function(){s(Error("".concat(e," timed out (id: ").concat(i,")"))),delete n.requestCallbacks[i]},r.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 r,n,i,o,s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var a=(0,Z.__values)(s),l=a.next();!l.done;l=a.next()){var u=l.value;t(u)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}},e.prototype.loadScriptOnce=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];r=(document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise(function(t,r){var n;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(){r({status:!1,message:"Failed to load the script ".concat(e)})}),null==(n=document.head)||n.appendChild(i)}catch(e){r(e)}})).then(function(){}),this.scriptLoadPromises.set(e,r),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r];case 2:return i.sent(),[3,4];case 3:throw n=i.sent(),this.scriptLoadPromises.delete(e),n;case 4:return[2]}})})},e.prototype.setup=function(e){var t,r,n=this,i=void 0===e?{}:e,o=i.logger,s=i.endpoint;o&&(this.logger=o),s&&this.endpoint===rZ&&(this.endpoint=s),this.isSetup||(this.isSetup=!0,null==(r=null==(t=this.logger)?void 0:t.debug)||r.call(t,"Setting up messenger"),this.messageHandler=function(e){if(null==(r=null==(t=n.logger)?void 0:t.debug)||r.call(t,"Message received: ",JSON.stringify(e)),n.endpoint===e.origin){var t,r,i,o,s,a=e.data,l=null==a?void 0:a.action;if(l)if("id"in a&&a.id)null==(o=null==(i=n.logger)?void 0:i.debug)||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),n.handleResponse(a
2);else{if("ping"===l)return void n.notify({action:"pong"});var u=n.actionHandlers.get(l);if(u)u(a.data);else{var c=null!=(s=n.pendingMessages.get(l))?s:[];c.push(a.data),n.pendingMessages.set(l,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[r2])===this&&delete e[r2]},e}();function r4(e){var t=(0,eO.getGlobalScope)(),r=null==t?void 0:t[r2];if("object"==typeof r&&null!==r&&r1 in r&&!0===r[r1])return r;var n=new r3(e);return t&&(t[r2]=n),n}L=r1;var r5="__AMPLITUDE_BACKGROUND_CAPTURE__";function r6(e,t){var r;if(!0!==e[r5]){e[r5]=!0;var n=null!=(r=null==t?void 0:t.scriptUrl)?r:"https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz",i=null,o=function(t,r){var n,i;"background-capture-complete"===t&&(null==(i=null==(n=e.logger)?void 0:n.debug)||i.call(n,"Background capture complete"),e.notify({action:"background-capture-complete",data:r}))};e.registerActionHandler("initialize-background-capture",function(){null==(r=null==(t=e.logger)?void 0:t.debug)||r.call(t,"Initializing background capture (external script)");var t,r,s=new URL(n,e.endpoint).toString();e.loadScriptOnce(s).then(function(){var t,r,n;null==(r=null==(t=e.logger)?void 0:t.debug)||r.call(t,"Background capture script loaded (external)"),i=null==(n=null==window?void 0:window.amplitudeBackgroundCapture)?void 0:n.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 r8=e.i(881243);function r7(e,t){return new r8.default(function(r){e.subscribe({next:function(e){t(e).then(function(e){return r.next(e)}).catch(function(e){return r.error(e)})},error:function(e){r.error(e)},complete:function(){r.complete()}})})}function r9(e,t){return new r8.default(function(r){var n=!1,i=new Set,o=function(){var e,t;n=!0;try{for(var r=(0,Z.__values)(i),o=r.next();!o.done;o=r.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){n||r.next(e)},error:function(e){n||(n=!0,r.error(e),o())},complete:function(){i.delete(t),n||0!==i.size||(r.complete(),o(),n=!0)}});i.add(t)};return s(e),s(t),o})}function ne(e){var t=new Set,r=null;function n(){null==r||r.unsubscribe(),r=null,t.clear()}return new r8.default(function(i){return t.add(i),null===r&&(r=e.subscribe({next:function(e){try{for(var r,n,i,o=(0,Z.__values)(t),s=o.next();!s.done;s=o.next()){var a=s.value;null==(i=a.next)||i.call(a,e)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}},error:function(e){try{for(var r,i,o,s=(0,Z.__values)(t),a=s.next();!a.done;a=s.next()){var l=a.value;null==(o=l.error)||o.call(l,e)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}n()},complete:function(){try{for(var e,r,i,o=(0,Z.__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&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}n()}})),function(){t.delete(i),0===t.size&&r&&(r.unsubscribe(),r=null)}})}var nt="1.28.10",nr="[Amplitude] Element Clicked",nn="[Amplitude] Element Tag",ni="[Amplitude] Element Text",no="[Amplitude] Page URL",ns="[Amplitude] Viewport Height",na="[Amplitude] Viewport Width",nl="[Amplitude] Page View ID",nu="data-amp-mask-attributes",nc=function(e,t){return!t||!t.length||t.some(function(t){return"string"==typeof t?e===t:e.match(t)})},nd=function(e,t){var r=e;try{r=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return r},nf=["input","select","textarea"],ng=function(e,t){var r,n=null==(r=null==window?void 0:window.getComputedStyle)?void 0:r.call(window,e);return(null==n?void 0:n.getPropertyValue("cursor"))==="pointer"&&"click"===t},nh=function(e){var t=e.pageUrlAllowlist,r=e.pageUrlExcludelist;return!(r&&r.length>0&&nc(window.location.href,r))&&!!nc(window.location.href,t)},np=function(e,t){return function(r,n){var i,o,s=e.shouldTrackEventResolver,a=null==(o=null==(i=null==n?void 0:n.tagName)?void 0:i.toLowerCase)?void 0:o.call(i);if(!a)return!1;if(s)return s(r,n);if(!nh(e))return!1;var l=String(null==n?void 0:n.getAttribute("type"))||"";if("string"==typeof l)switch(l.toLowerCase()){case"hidden":case"password":return!1}if(t&&!t.some(function(e){var t;return!!(null==(t=null==n?void 0:n.matches)?void 0:t.call(n,e))}))return!1;switch(a){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return"click"===r}}},nv=function(e){var t,r,n,i=null==(r=null==(t=null==e?void 0:e.tagName)?void 0:t.toLowerCase)?void 0:r.call(t),o=e instanceof HTMLElement&&(null==(n=e.getAttribute("contenteditable"))?void 0:n.toLowerCase())==="true";return!nf.includes(i)&&!o},nm=function(e){return Object.keys(e).reduce(function(t,r){var n=e[r];return null!=n&&("object"!=typeof n||0!==Object.keys(n).length)&&("string"!=typeof n||0!==n.trim().length)&&(t[r]=n),t},{})},ny=function(){var e;try{var t=(0,eO.getGlobalScope)(),r=null==(e=null==t?void 0:t.sessionStorage)?void 0:e.getItem("AMP_PAGE_VIEW");if(!r)return;var n=JSON.parse(r);if("string"==typeof n.pageViewId)return n.pageViewId}catch(e){}},n_=function(e,t){return e?t.some(function(t){var r;return null==(r=null==e?void 0:e.matches)?void 0:r.call(e,t)})?e:n_(null==e?void 0:e.parentElement,t):null},nb=function(e){return null!==e.event.target&&!!e.closestTrackedAncestor};(l=N||(N={}))[l.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",l[l.MIDDLE=1]="MIDDLE",l[l.RIGHT=2]="RIGHT";var nw="__AMPLITUDE_VISUAL_TAGGING__",nS=r8,nE=(0,eO.getGlobalScope)(),nk=null==nE?void 0:nE.console,nI={},nT={},nC=!1,nP=function(e,t){if(!nk||"function"!=typeof nk[e]||!nT[e]&&(nT[e]=nk[e],nk[e]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{if(nI[e]&&!nC){nC=!0;var n=nI[e];
2n&&n.forEach(function(r){try{r(e,t)}catch(e){}})}}catch(e){}return nC=!1,nT[e].apply(nk,t)},0))return Error("Console override failed");nI[e]?nI[e].push(t):nI[e]=[t]},nx=function(e){var t,r;try{for(var n=(0,Z.__values)(Object.values(nI)),i=n.next();!i.done;i=n.next())for(var o=i.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},nO=(0,eO.getGlobalScope)(),nA=function(){return new nS.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()}})},nR=function(e){return void 0===e&&(e="click"),new nS.default(function(t){var r,n=function(e){t.next(e)};return null==(r=(0,eO.getGlobalScope)())||r.document.addEventListener(e,n,{capture:!0}),function(){var t;null==(t=(0,eO.getGlobalScope)())||t.document.removeEventListener(e,n,{capture:!0})}})},nM=function(){var e=r9(new nS.default(function(e){var t=function(t){if(t instanceof ErrorEvent){var r={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?r=(0,Z.__assign)((0,Z.__assign)({},r),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(r.message=t.error),e.next(r)}};return nO.addEventListener("error",t),function(){nO.removeEventListener("error",t)}}),new nS.default(function(e){var t=function(t){var r={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(r.message=t.reason.message,r.stack=t.reason.stack):"string"==typeof t.reason&&(r.message=t.reason),e.next(r)};return nO.addEventListener("unhandledrejection",t),function(){nO.removeEventListener("unhandledrejection",t)}}));return r9(e,new nS.default(function(e){var t=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=void 0;Array.isArray(r[0])&&"string"==typeof r[0][0]&&(i=r[0][0]),e.next({kind:"console",message:i})};return nP("error",t),function(){nx(t)}}))},nD=function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){console.error("Error matching event to filter",e)}return!1},nL=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var r=document.documentElement;if(e.scope&&t&&(r=t.closest(e.scope)),r&&e.selector)return r.querySelector(e.selector);return r}}catch(e){}},nN=function(e,t,r){e.forEach(function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var n=r.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=n}})},nF={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},nj=function(e){var t,r,n,i,o=Object.values(nF).reduce(function(e,t){return e[t]=new Set,e},{});if(!e)return o;try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var l=a.value;try{try{for(var u=(n=void 0,(0,Z.__values)(l.definition)),c=u.next();!c.done;c=u.next()){var d=nF[c.value.event_type];d&&o[d].add(l.id)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==l?void 0:l.id,e)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o},nq=function(e){var t,r,n,i,o=new Map;try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var l=a.value;try{for(var u=(n=void 0,(0,Z.__values)(l.conditions)),c=u.next();!c.done;c=u.next()){var d=c.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,g=o.get(f);g||(g=[],o.set(f,g)),g.push(l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o},nU=function(e,t){var r,n,i,o,s=new Set;try{for(var a=(0,Z.__values)(e),l=a.next();!l.done;l=a.next()){var u=l.value,c=t.get(u.id);if(c)try{for(var d=(i=void 0,(0,Z.__values)(c)),f=d.next();!f.done;f=d.next()){var g=f.value;s.add(g)}}catch(e){i={error:e}}
2finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return Array.from(s)},nB=function(){function e(e,t,r,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=r,this.options=n}return e.prototype.evaluate=function(e){var t,r,n=this.options.pageActions;if(!n)return e;var i=nU(Array.from(this.groupedLabeledEvents[e.type]).map(function(e){return n.labeledEvents[e]}).filter(function(t){return t.definition.some(function(t){return nF[t.event_type]===e.type&&t.filters.every(function(t){return nD(e,t)})})}),this.labeledEventToTriggerMap);try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value;nN(a.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=r},e}(),nz=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",nu,rP]),nW=["type"],nG=["svg","path","g"],nH=["password","hidden"];function n$(e,t){var r=e.getAttribute(t.explicitTrackingAttribute);if(null!==r&&""===r)return null;var n=e.getAttribute("id");return null===n||""===n||!function(e,t){var r,n;if(null==e||""===e)return!1;try{for(var i=(0,Z.__values)(t),o=i.next();!o.done;o=i.next())if(o.value.test(e))return!1}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}(n,t.autogeneratedIdPatterns)?null:n}function nK(e){var t=globalThis.CSS;if(t&&"function"==typeof t.escape)return t.escape(e);for(var r=String(e),n=r.length,i="",o=0;o<n;o++){var s=r.charCodeAt(o);if(0===s){i+="�";continue}if(s>=1&&s<=31||127===s||0===o&&s>=48&&s<=57||1===o&&s>=48&&s<=57&&45===r.charCodeAt(0)){i+="\\".concat(s.toString(16)," ");continue}if(0===o&&1===n&&45===s){i+="\\-";continue}if(s>=128||45===s||95===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122){i+=r.charAt(o);continue}i+="\\".concat(r.charAt(o))}return i}function nV(e){var t=e.tagName.toLowerCase(),r=e.parentElement;if(null===r)return t;var n=function(e,t){for(var r=0,n=0;n<t.children.length;n++){var i=t.children[n];if(i.tagName===e.tagName&&(r+=1,i===e))return r}return 1}(e,r);return"".concat(t,":nth-of-type(").concat(n,")")}var nJ=[{name:"explicitTrackingAttribute",try:function(e,t){var r=t.config.explicitTrackingAttribute,n=e.getAttribute(r);return null===n||""===n?null:"[".concat(r,"=").concat(JSON.stringify(n),"]")}},{name:"stableId",try:function(e,t){var r=n$(e,t.config);return null===r?null:"".concat(e.tagName.toLowerCase(),"#").concat(nK(r))}}];function nY(e,t,r,n,i){var o;try{o=e.querySelectorAll(t)}catch(e){var s=e instanceof Error?e.message:String(e);return null==i||i.debug('@amplitude/element-selector: strategy "'.concat(n,'" emitted a malformed selector "').concat(t,'" (').concat(s,")")),!1}return 1===o.length&&o[0]===r}var nX=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),nQ=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var r=[],n=e;n;){var i=nZ(n,!!t,n===e);if(!i||(r.push(i),i.optimized))break;n=n.parentElement}return r.reverse(),r.join(" > ")},nZ=function(e,t,r){if(e.nodeType!==Node.ELEMENT_NODE)return null;var n,i,o=e.getAttribute("id");if(t){if(o)return new nX(n1(o),!0);var s=e.tagName.toLowerCase();if("body"===s||"head"===s||"html"===s)return new nX(s,!0)}var a=e.tagName.toLowerCase();if(o)return new nX(a+n1(o),!0);var l=e.parentNode;if(!l||l.nodeType===Node.DOCUMENT_NODE)return new nX(a,!0);for(var u=n0(e),c=!1,d=!1,f=-1,g=-1,h=l.children,p=0;h&&(-1===f||!d)&&p<h.length;++p){var v=h[p];if(v.nodeType===Node.ELEMENT_NODE){if(g+=1,v===e){f=g;continue}if(!d&&v.tagName.toLowerCase()===a){c=!0;var m=new Set(u);if(!m.size){d=!0;continue}for(var y=n0(v),_=0;_<y.length;++_){var b=y[_];if(m.has(b)&&(m.delete(b),!m.size)){d=!0;break}}}}}var w=a;if(r&&"input"===a.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(w+="[type="+nK(e.getAttribute("type")||"")+"]"),d)w+=":nth-child("+String(f+1)+")";else if(c)try{for(var S=(0,Z.__values)(u),E=S.next();!E.done;E=S.next()){var k=E.value;w+="."+nK(k.slice(1))}}catch(e){n={error:e}}finally{try{E&&!E.done&&(i=S.return)&&i.call(S)}finally{if(n)throw n.error}}return new nX(w,!1)},n0=function(e){var t=e.getAttribute("class");
2return t?t.split(/\s+/g).filter(Boolean).map(function(e){return"$"+e}):[]},n1=function(e){return"#"+nK(e)};function n2(e,t){try{return nQ(e)}catch(e){var r=e instanceof Error?e.message:String(e);return null==t||t.warn("@amplitude/element-selector: legacyCssPath threw — emitting empty selector: ".concat(r)),""}}var n3=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:(0,Z.__spreadArray)([],(0,Z.__read)([/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/]),!1),unstableClassPatterns:(0,Z.__spreadArray)([],(0,Z.__read)([/^(p|m|px|py|mx|my|pt|pb|pl|pr|mt|mb|ml|mr)-\d+$/,/^(w|h|min-w|max-w|min-h|max-h)-/,/^(text|bg|border|ring|fill|stroke)-/,/^(hover|focus|active|disabled|group-hover):/,/^(sm|md|lg|xl|2xl):/,/^z-\d+$/,/^data-\[/,/^\[/,/^css-[a-z0-9]{6,}$/,/^[a-zA-Z]+_[a-zA-Z0-9]{3,}__[a-zA-Z0-9]{5,}$/,/^sc-[a-zA-Z0-9]{6,}$/,/^jsx-\d+$/,/^swiper-slide-(visible|fully-visible|active|prev|next|duplicate)$/,/^is-(active|open|selected|hovered|focused|expanded)$/,/^Mui[A-Z][a-zA-Z]+-(focused|selected|disabled|expanded|focusVisible|active|checked)$/,/^Mui-(selected|focused|disabled|expanded|focusVisible|active|checked)$/,/^data-state-/]),!1),maxAncestorWalkDepth:void 0});function n4(e,t){if(!e)return n5();var r=n5();return"boolean"==typeof e.enabled&&(r.enabled=e.enabled),"string"==typeof e.explicitTrackingAttribute&&""!==e.explicitTrackingAttribute&&(r.explicitTrackingAttribute=e.explicitTrackingAttribute),Array.isArray(e.autogeneratedIdPatterns)&&(r.autogeneratedIdPatterns=function(e,t){var r,n,i=[];try{for(var o=(0,Z.__values)(e),s=o.next();!s.done;s=o.next()){var a=s.value;try{i.push(new RegExp(a))}catch(e){var l=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(a,'" (').concat(l,")"))}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}(e.autogeneratedIdPatterns,t)),Array.isArray(e.unstableClassPatterns)&&(r.unstableClassPatterns=function(e,t){var r,n,i=[];try{for(var o=(0,Z.__values)(e),s=o.next();!s.done;s=o.next()){var a=s.value;try{i.push(new RegExp(a))}catch(e){var l=e instanceof Error?e.message:String(e);null==t||t.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(a,'" (').concat(l,")"))}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}(e.unstableClassPatterns,t)),r.maxAncestorWalkDepth=function(e){if("number"==typeof e&&Number.isFinite(e)&&!(e<=0))return Math.floor(e)}(e.maxAncestorWalkDepth),r}function n5(){return{enabled:n3.enabled,explicitTrackingAttribute:n3.explicitTrackingAttribute,autogeneratedIdPatterns:(0,Z.__spreadArray)([],(0,Z.__read)(n3.autogeneratedIdPatterns),!1),unstableClassPatterns:(0,Z.__spreadArray)([],(0,Z.__read)(n3.unstableClassPatterns),!1),maxAncestorWalkDepth:n3.maxAncestorWalkDepth}}var n6=function(e,t){var r,n,i,o,s,a,l,u,c,d=this;this.replaceSensitiveString=function(e){return rM(e,d.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,r,n,i,o=performance.now(),s=[];if(!e)return[];for(var a=function(e){var t=[];if(!e)return t;
2t.push(e);for(var r=e.parentElement;r&&"HTML"!==r.tagName;)t.push(r),r=r.parentElement;return t}(e),l=new Map,u=a.length-1;u>=0;u--){var c=a[u];if(c){var f,g=(f=c.getAttribute(nu))?f.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&"id"!==e&&"class"!==e}):[],h=u===a.length-1?[]:null!=(n=l.get(a[u+1]))?n:new Set,p=new Set((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(h),!1),(0,Z.__read)(g),!1));l.set(c,p)}}s=a.map(function(e){var t;return function(e,t){if(null===e)return null;var r,n,i,o,s,a,l=String(e.tagName).toLowerCase(),u={tag:l},c=Array.from(null!=(o=null==(i=e.parentElement)?void 0:i.children)?o:[]);c.length&&(u.index=c.indexOf(e),u.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&&(u.prevSib=String(d));var f=e.getAttribute("id");f&&(u.id=String(f));var g=Array.from(e.classList);g.length&&(u.classes=g);var h={},p=Array.from(e.attributes).filter(function(e){return!nz.has(e.name)}),v=!nv(e);
2if(!nH.includes(String(e.getAttribute("type")))&&!nG.includes(l))try{for(var m=(0,Z.__values)(p),y=m.next();!y.done;y=m.next()){var _=y.value;if(!v||nW.includes(_.name)){if(t.has(_.name)){h[_.name]=rx;continue}h[_.name]=String(_.value).substring(0,128)}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(r)throw r.error}}return Object.keys(h).length&&(u.attrs=h),u}(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 r=(0,Z.__read)(t,2),n=r[0],i=r[1];e.attrs&&(e.attrs[n]=d.replaceSensitiveString(i))})};try{for(var m=(0,Z.__values)(s),y=m.next();!y.done;y=m.next()){var _=y.value;v(_)}}catch(e){t={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null==(i=d.diagnosticsClient)||i.recordHistogram("autocapturePlugin.getHierarchy",b-o),s},this.getNearestLabel=function(e){var t,r=e.parentElement;if(!r)return"";try{t=r.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?d.getText(t):d.getNearestLabel(r)},this.getElementPath=function(e){if(!e)return"";var t,r=performance.now(),n=d.selectorEngine.generate(e),i=performance.now();return null==(t=d.diagnosticsClient)||t.recordHistogram("autocapturePlugin.getElementPath",i-r),n},this.updateSelectorConfig=function(e,t){if(null==e||"boolean"!=typeof e.enabled){null==t||t.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` flag — keeping current engine state.");return}var r=d.selectorEngine.getConfig().enabled,n=n4(e,t);d.selectorEngine.updateConfig(n),!r&&n.enabled?null==t||t.debug("@amplitude/element-selector: engine enabled — now emitting new element-selector element paths for autocapture events."):r&&!n.enabled&&(null==t||t.debug("@amplitude/element-selector: engine disabled — reverting to legacy cssPath for element paths."))},this.getEventProperties=function(e,t,r){var n,i,o,s,a=null==(o=null==(i=null==t?void 0:t.tagName)?void 0:i.toLowerCase)?void 0:o.call(i),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},u=d.getHierarchy(t),c=null==(s=u[0])?void 0:s.attrs,f=d.getNearestLabel(t),g=Object.entries(null!=c?c:{}).reduce(function(e,t){var n=(0,Z.__read)(t,2),i=n[0],o=n[1];if(i.startsWith(r)){var s=i.replace(r,"");s&&(e[s]=o||"")}return e},{}),h=((n={})["[Amplitude] Element Hierarchy"]=u,n[nn]=a,n[ni]=d.getText(t),n["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),n["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),n["[Amplitude] Element Attributes"]=g,n["[Amplitude] Element Path"]=d.getElementPath(t),n["[Amplitude] Element Parent Label"]=f,n[no]=nd(window.location.href.split("?")[0]),n["[Amplitude] Page Title"]=rD(d.replaceSensitiveString),n[ns]=window.innerHeight,n[na]=window.innerWidth,n),p=ny();if(p&&(h[nl]=p),h["[Amplitude] Element ID"]=t.getAttribute("id")||"",h["[Amplitude] Element Class"]=t.getAttribute("class"),h["[Amplitude] Element Aria Label"]=null==c?void 0:c["aria-label"],"a"===a&&"click"===e&&t instanceof HTMLAnchorElement){var v=t.href.substring(0,128);h["[Amplitude] Element Href"]=d.replaceSensitiveString(v)}return nm(h)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,r,n,i){void 0===i&&(i=!1);var o=d.addTypeAndTimestamp(e,t);if(("click"===o.type||"change"===o.type)&&null!==o.event.target){if(i&&ng(o.event.target,o.type))return o.closestTrackedAncestor=o.event.target,o.targetElementProperties=d.getEventProperties(o.type,o.closestTrackedAncestor,n),o;var s=n_(o.event.target,r);s&&(o.closestTrackedAncestor=s,o.targetElementProperties=d.getEventProperties(o.type,s,n))}return o},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var r=nL(e,t);if(r){if("TEXT"===e.elementExtractType)return d.getText(r);if("ATTRIBUTE"===e.elementExtractType&&e.attribute)return r.getAttribute(e.attribute)}}},this.getTextWithMaskedDescendants=function(e){var t,r,n="[".concat(rP,"], [contenteditable]");if(!e.querySelector(n))return e.innerText;var i="",o=Array.from(e.childNodes);try{for(var s=(0,Z.__values)(o),a=s.next();!a.done;a=s.next()){var l=a.value;if(l.nodeType===Node.TEXT_NODE){i+=l.textContent||"";continue}if(l instanceof Element){if(l.hasAttribute(rP)||l.hasAttribute("contenteditable")){i+=rx;continue}i+=d.getTextWithMaskedDescendants(l)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return i},this.getText=function(e){if(null!==e.closest("[".concat(rP,"]")))return rx;var t="";return t=e.querySelector("[".concat(rP,"], [contenteditable]"))?d.getTextWithMaskedDescendants(e):e.innerText||"",d.replaceSensitiveStr
2ing(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){if(!e)return{};var t,r,n,i=null==(n=null==(r=null==e?void 0:e.tagName)?void 0:r.toLowerCase)?void 0:n.call(r);return nm(((t={})[nn]=i,t[ni]=d.getText(e),t[no]=window.location.href.split("?")[0],t))},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient,this.selectorEngine=(F||(r=n4(),void 0===n&&(n={}),i=r,o=new Set,s=n.logger,a={strategies:n.strategies,scope:n.scope,logger:s},F={generate:function(e){var t,r;if(!i.enabled)return n2(e,s);try{var o=function(e,t,r){void 0===r&&(r={});var n,i,o,s,a,l=null!=(o=r.strategies)?o:nJ,u=null!=(a=null!=(s=r.scope)?s:e.ownerDocument)?a:document,c={scope:u,config:t},d=function(e,t){for(var r=[],n=e;null!==n&&(r.push(n),void 0===t||!(r.length>t));)n=n.parentElement;return r}(e,t.maxAncestorWalkDepth);try{for(var f=(0,Z.__values)(l),g=f.next();!g.done;g=f.next())for(var h=g.value,p=0;p<d.length;p++){var v=d[p],m=h.try(v,c);if(null!==m){if(0===p){if(nY(u,m,e,h.name,r.logger))return m;continue}var y=d.slice(0,p).reverse().map(nV).join(" > "),_="".concat(m," > ").concat(y);if(nY(u,_,e,h.name,r.logger))return _}}}catch(e){n={error:e}}finally{try{g&&!g.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}return null}(e,i,a);if(null!==o)return o;return function(e,t,r){void 0===r&&(r={});for(var n,i,o=null!=(i=null!=(n=r.scope)?n:e.ownerDocument)?i:document,s=[],a=e,l=0;null!==a&&(void 0===t.maxAncestorWalkDepth||!(l>t.maxAncestorWalkDepth));){var u=n$(a,t);if(null!==u){var c="".concat(a.tagName.toLowerCase(),"#").concat(nK(u)),d=(0,Z.__spreadArray)([c],(0,Z.__read)(s),!1).join(" > ");if(function(e,t,r){var n;try{n=e.querySelectorAll(t)}catch(e){return!1}return 1===n.length&&n[0]===r}(o,d,e))return d}s.unshift(function(e){var t=e.tagName.toLowerCase(),r=e.parentElement;if(null===r)return t;var n=function(e,t){for(var r=0,n=0;n<t.children.length;n++){var i=t.children[n];if(i.tagName===e.tagName&&(r+=1,i===e))return r}return 1}(e,r);return"".concat(t,":nth-of-type(").concat(n,")")}(a)),a=a.parentElement,l+=1}return s.join(" > ")}(e,i,{scope:null!=(r=null!=(t=n.scope)?t:e.ownerDocument)?r:document})}catch(t){var l=t instanceof Error?t.message:String(t);return null==s||s.warn("@amplitude/element-selector: strategy chain threw — falling back to legacy cssPath: ".concat(l)),n2(e,s)}},getConfig:function(){return i},updateConfig:function(e){var t,r;i=e;try{for(var n=(0,Z.__values)(o),a=n.next();!a.done;a=n.next()){var l=a.value;try{l(e)}catch(e){var u=e instanceof Error?e.message:String(e);null==s||s.warn("@amplitude/element-selector: onConfigChange subscriber threw — ".concat(u))}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},onConfigChange:function(e){return o.add(e),function(){o.delete(e)}}}),F);var f=null!=(c=e.maskTextRegex)?c:[],g=[];try{for(var h=(0,Z.__values)(f),p=h.next();!p.done;p=h.next()){var v=p.value;if(g.length>=25)break;if(v instanceof RegExp)g.push(v);else if("pattern"in v&&"string"==typeof v.pattern)try{g.push(RegExp(v.pattern,"i"))}catch(e){}}}catch(e){l={error:e}}finally{try{p&&!p.done&&(u=h.return)&&u.call(h)}finally{if(l)throw l.error}}this.additionalMaskTextPatterns=g};function n8(e,t){var r=e.remoteConfigClient;if(e.fetchRemoteConfig&&r){var n=r.subscribe("configs.analyticsSDK.browserSDK.autocapture.elementSelector","all",function(r,n){e.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(n),") ").concat(JSON.stringify(r))),t.updateSelectorConfig(r,e.loggerProvider)});return function(){r.unsubscribe(n)}}}var nS=r8;(u=j||(j={})).ClickObservable="clickObservable",u.ChangeObservable="changeObservable",u.NavigateObservable="navigateObservable",u.MutationObservable="mutationObservable",u.ScrollObservable="scrollObservable",u.ExposureObservable="exposureObservable",u.BrowserErrorObservable="browserErrorObservable",u.SelectionObservable="selectionObservable",u.MouseMoveObservable="mouseMoveObservable";var n7=function(e,t){void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",nt);var r,n,i,o,s,a,l,u,c,d,f,g,h,p=e.dataAttributePrefix,v=void 0===p?rX:p,m=e.visualTaggingOptions,y=void 0===m?{enabled:!0}:m;e.cssSelectorAllowlist=null!=(r=e.cssSelectorAllowlist)?r:rY,e.actionClickAllowlist=null!=(n=e.actionClickAllowlist)?n:rQ,e.debounceTime=null!=(i=e.debounceTime)?i:0;var _=(null==(o=e.viewportContentUpdated)?void 0:o.enabled)!==!1,b=null!=(l=null!=(a=null==(s=e.viewportContentUpdated)?void 0:s.exposureDuration)?a:e.exposureDuration)?l:150;e.viewportContentUpdated=(0,Z.__assign)((0,Z.__assign)({},e.viewportContentUpdated),{exposureDuration:b}),e.pageUrlExcludelist=null==(u=e.pageUrlExcludelist)?void 0:u.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 w="@amplitude/plugin-autocapture-browser",S=[],E=new n6(e,t),k=new Set,I=new Set,T=function(){var t,r,n,i=ne(nR().map(function(t){return E.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,v)})),o=ne(new nS.default(function(t){var r,n=function(r){var n=E.addAdditionalEventProperties(r,"change",e.cssSelectorAllowlist,v);t.next(n)};return null==(r=(0,eO.getGlobalScope)())||r.document.addEventListener("change",n,{
2capture:!0}),function(){var e;return null==(e=(0,eO.getGlobalScope)())?void 0:e.document.removeEventListener("change",n)}}));window.navigation&&(n=ne(new nS.default(function(t){var r=function(r){var n=E.addAdditionalEventProperties(r,"navigate",e.cssSelectorAllowlist,v);t.next(n)};return window.navigation.addEventListener("navigate",r),function(){window.navigation.removeEventListener("navigate",r)}})));var s=ne(nA().map(function(t){return E.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,v)})),a=new nS.default(function(e){var t,r=function(t){e.next(t)};return null==(t=(0,eO.getGlobalScope)())||t.addEventListener("scroll",r),function(){var e;null==(e=(0,eO.getGlobalScope)())||e.removeEventListener("scroll",r)}}),l=(t=e.cssSelectorAllowlist,new nS.default(function(e){var r,n=(0,eO.getGlobalScope)();if(!(null==n?void 0:n.IntersectionObserver))return function(){};var i=new IntersectionObserver(function(t){t.forEach(function(t){e.next(t)})},{root:null,rootMargin:"0px",threshold:1}),o=t.join(",");(null!=(r=null==n?void 0:n.document.querySelectorAll(o))?r:[]).forEach(function(e){i.observe(e)});var a=s.subscribe(function(e){return e.event.forEach(function(e){return e.addedNodes.forEach(function(e){e instanceof Element&&(e.matches(o)&&i.observe(e),e.querySelectorAll(o).forEach(function(e){i.observe(e)}))})})});return function(){a.unsubscribe(),i.disconnect()}}));return(r={})[j.ChangeObservable]=o,r[j.ClickObservable]=i,r[j.MutationObservable]=s,r[j.NavigateObservable]=n,r[j.ScrollObservable]=a,r[j.ExposureObservable]=l,r},C=nj(Object.values(null!=(d=null==(c=e.pageActions)?void 0:c.labeledEvents)?d:{})),P=nq(null!=(g=null==(f=e.pageActions)?void 0:f.triggers)?g:[]),x=new nB(C,P,E,e),O=function(t){var r,n;t&&(e.pageActions=(0,Z.__assign)((0,Z.__assign)({},e.pageActions),t),C=nj(Object.values(null!=(r=e.pageActions.labeledEvents)?r:{})),P=nq(null!=(n=e.pageActions.triggers)?n:[]),x.update(C,P,e))};return{name:w,type:"enrichment",setup:function(t,r){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var n,i,o,s,a,l,u,c,d,f,g,p,m,C,P,A,R,M,D,L,N,F;return(0,Z.__generator)(this,function(q){var U,B,z,W,G,H,$,K,V,J,Y,X,Q,ee,et,er,en,ei,eo,es,ea,el,eu,ec,ed,ef,eg,eh,ep,ev,em,ey,e_,eb,ew,eS,eE,ek,eI;return"u"<typeof document?[2]:(n=!1,i={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(e){O(e)}):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),(o=n8(t,E))&&S.push({unsubscribe:o}),s=np(e,e.cssSelectorAllowlist),a=np(e,e.actionClickAllowlist),B=(U={allObservables:l=T(),amplitude:r,shouldTrackEvent:s,evaluateTriggers:x.evaluate.bind(x)}).amplitude,z=U.allObservables,W=U.shouldTrackEvent,G=U.evaluateTriggers,u=z.clickObservable.filter(nb).filter(function(e){return W("click",e.closestTrackedAncestor)}).map(function(e){return G(e)}).subscribe(function(e){null==B||B.track(nr,e.targetElementProperties)}),S.push(u),$=(H={allObservables:l,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return E.getEventProperties.apply(E,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(e),!1),[v],!1))},amplitude:r,shouldTrackEvent:s,evaluateTriggers:x.evaluate.bind(x)}).amplitude,K=H.allObservables,V=H.getEventProperties,J=H.shouldTrackEvent,Y=H.evaluateTriggers,c=K.changeObservable.filter(nb).filter(function(e){return J("change",e.closestTrackedAncestor)}).map(function(e){return Y(e)}).subscribe(function(e){null==$||$.track("[Amplitude] Element Changed",V("change",e.closestTrackedAncestor))}),S.push(c),Q=(X={allObservables:l,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return E.getEventProperties.apply(E,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(e),!1),[v],!1))},amplitude:r,shouldTrackEvent:s,shouldTrackActionClick:a}).amplitude,ee=X.allObservables,et=X.options,er=X.getEventProperties,en=X.shouldTrackEvent,ei=X.shouldTrackActionClick,eo=ee.clickObservable,es=ee.mutationObservable,ea=ee.navigateObservable,el=eo.filter(function(e){return!en("click",e.closestTrackedAncestor)}).map(function(e){var t=n_(e.event.target,et.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=er(e.type,e.closestTrackedAncestor)),e}).filter(nb).filter(function(e){return ei("click",e.closestTrackedAncestor)}),eu=ea?r9(es,ea):es,ec=r9(el,eu),ed=null,ef=null,(d=r7(ec,function(e){if(ed&&(clearTimeout(ed),ed=null),"click"===e.type)ef=e,ed=setTimeout(function(){ed=null,ef=null},500);else if(ef){var t=ef;return ef=null,Promise.resolve(t)}return Promise.resolve(null)}).subscribe(function(e){e&&(null==Q||Q.track(nr,er("click",e.closestTrackedAncestor)))}))&&S.push(d),(eg={allObservables:l,amplitude:r}).amplitude,eh=eg.allObservables.scrollObservable,ep={maxX:0,maxY:0},ev=eh.subscribe(function(){var e,t,r,n,i=(0,eO.getGlobalScope)(),o=Math.floor(null!=(t=null!=(e=null==i?void 0:i.scrollX)?e:null==i?void 0:i.pageXOffset)?t:0),s=Math.floor(null!=(n=null!=(r=null==i?void 0:i.scrollY)?r:null==i?void 0:i.pageYOffset)?
2n:0);ep.maxX=Math.max(ep.maxX,o),ep.maxY=Math.max(ep.maxY,s)}),f={unsubscribe:function(){ev.unsubscribe()},getState:function(){return ep},reset:function(){ep.maxX=0,ep.maxY=0}},S.push(f),g={},p=(0,eO.getGlobalScope)(),m=function(e){e&&n||(setTimeout(function(){n=!1},100),n=!0,function(e){var t,r,n,i,o,s,a=e.amplitude,l=e.scrollTracker,u=e.currentElementExposed,c=e.elementExposedForPage,d=e.exposureTracker,f=e.isPageEnd,g=e.lastScroll,h=l.getState(),p=(0,eO.getGlobalScope)(),v=null!=(r=null==p?void 0:p.innerWidth)?r:0,m=null!=(n=null==p?void 0:p.innerHeight)?n:0,y=((t={})[no]=nd(null!=(s=null==(o=null==(i=null==p?void 0:p.location)?void 0:i.href)?void 0:o.split("?")[0])?s:""),t["[Amplitude] Max Page X"]=h.maxX+v,t["[Amplitude] Max Page Y"]=h.maxY+m,t[ns]=m,t[na]=v,t["[Amplitude] Element Exposed"]=Array.from(u),t),_=ny();if(_&&(y[nl]=_),0===u.size&&h.maxX===g.maxX&&h.maxY===g.maxY){f&&(l.reset(),c.clear(),null==d||d.reset());return}null==a||a.track("[Amplitude] Viewport Content Updated",y),g.maxX=h.maxX,g.maxY=h.maxY,u.clear(),f&&(l.reset(),c.clear(),null==d||d.reset())}({amplitude:r,scrollTracker:f,currentElementExposed:I,elementExposedForPage:k,exposureTracker:g.exposure,isPageEnd:e,lastScroll:i}))},C=function(e){!k.has(e)&&(k.add(e),I.add(e),JSON.stringify(Array.from(I)).length>=18e3&&m(!1))},_&&(ey=(em={allObservables:l,onExposure:C,dataExtractor:E,exposureDuration:b}).allObservables,e_=em.onExposure,eb=em.dataExtractor,eS=void 0===(ew=em.exposureDuration)?150:ew,eE=new Map,ek=new Map,eI=ey.exposureObservable.subscribe(function(e){var t=e.target;if(e.isIntersecting){if(!eE.get(t)){var r=setTimeout(function(){eE.set(t,!0),e_(eb.getElementPath(t)),ek.set(t,null)},eS);ek.set(t,r)}}else if(!e.isIntersecting&&e.intersectionRatio<1){var r=ek.get(t);r&&(clearTimeout(r),ek.set(t,null))}}),g.exposure={unsubscribe:function(){eI.unsubscribe()},reset:function(){ek.forEach(function(e){e&&clearTimeout(e)}),ek.clear(),eE.clear()}},g.exposure&&S.push(g.exposure),P=function(){m(!0)},null==p||p.addEventListener("beforeunload",P),h=function(){null==p||p.removeEventListener("beforeunload",P)},S.push({unsubscribe:function(){return h()}}),(A=l[j.NavigateObservable])?S.push(A.subscribe(function(){m(!0)})):p&&(R=function(){m(!0)},p.addEventListener("popstate",R),M=p.history.pushState,p.history&&M&&(p.history.pushState=new Proxy(M,{apply:function(e,t,r){var n=(0,Z.__read)(r,3),i=n[0],o=n[1],s=n[2];e.apply(t,[i,o,s]),m(!0)}})),S.push({unsubscribe:function(){p.removeEventListener("popstate",R),p.history&&M&&(p.history.pushState=M)}}))),null==(F=null==t?void 0:t.loggerProvider)||F.log("".concat(w," has been successfully added.")),window.opener&&y.enabled&&(D=e.cssSelectorAllowlist,L=e.actionClickAllowlist,!function(e,t){if(!0!==e[nw]){e[nw]=!0;var r=t.dataExtractor,n=t.isElementSelectable,i=t.cssSelectorAllowlist,o=t.actionClickAllowlist,s=null,a=function(t){e.notify({action:"element-selected",data:t})},l=function(t,r){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:r}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:r})};e.registerActionHandler("initialize-visual-tagging-selector",function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then(function(){var u;s=null==(u=null==window?void 0:window.amplitudeVisualTaggingSelector)?void 0:u.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!n||n((null==t?void 0:t.actionType)||"click",e)},onTrack:l,onSelect:a,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:i,actionClickAllowlist:o,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:nt}}}),e.notify({action:"selector-loaded"})}).catch(function(){var t;null==(t=e.logger)||t.warn("Failed to initialize visual tagging selector")})}),e.registerActionHandler("close-visual-tagging-selector",function(){var e;null==(e=null==s?void 0:s.close)||e.call(s)})}}(N=r4(),{dataExtractor:E,isElementSelectable:np(e,(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(D),!1),(0,Z.__read)(L),!1)),cssSelectorAllowlist:D,actionClickAllowlist:L}),r6(N),N.setup((0,Z.__assign)({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:r0[t.serverZone]}))),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n;return(0,Z.__generator)(this,function(i){try{for(t=(e=(0,Z.__values)(S)).next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(n=e.return)&&n.call(e)}finally{if(r)throw r.error}}return[2]})})}}},nS=r8,n9=(0,Z.__spreadArray)(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],(0,Z.__read)(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),ie=["*"],it=["mutation","navigate"];function ir(e,t){var r,n,i,o,s=t.event,a=s.pageX,l=s.pageY;e.yMin=Math.min(null!=(r=e.yMin)?r:l,l),e.yMax=Math.max(null!=(n=e.yMax)?n:l,l),e.xMin=Math.min(null!=(i=e.xMin)?i:a,a),e.xMax=Math.max(null!=(o=e.xMax)?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function ii(e){if(0===e.length)return null;var t=e[0],r=e[e.length-1];return{rageClickEvent:(0,Z.__assign)({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(r.timestamp).toISOString(),"[Amplitude] Duration":r.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 nS=r8;(c=q||(q={})).INCREASING="increasing",c.DECREASING="decreasing",(d=U||(U={})).X="x",d.Y="y";var io=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new nS.default(function(e){var r=null,n=null,i=null;return t.subscribe(function(t){var o={x:t.clientX,y:t.clientY};if(null===r){r=o;return}o.x>r.x?(n===q.DECREASING&&e.next(U.X),n=q.INCREASING):o.x<r.x&&(n===q.INCREASING&&e.next(U.X),n=q.DECREASING),o.y>r.y?(i===q.DECREASING&&e.next(U.Y),i=q.INCREASING):o.y<r.y&&(i===q.INCREASING&&e.next(U.Y),i=q.DECREASING),r=o})})};function is(e){var t=e.changes,r=e.changesThreshold,n=e.thresholdMs;return!(t.length<r)&&t[t.length-1]-t[0]<n}function ia(e){e.changes=[],e.startTime=void 0}function il(e){for(var t=e.changes,r=e.thresholdMs,n=0,i=t[t.length-1];n<t.length&&!(i-t[n]<r);n++);0!==n&&(e.startTime=t[n],e.changes.splice(0,n))}var iu=function(e){var t=e.mouseDirectionChangeObservable,r=e.directionChanges,n=void 0===r?20:r,i=e.thresholdMs,o=void 0===i?2e3:i;return new nS.default(function(e){var r={changes:[],changesThreshold:n,thresholdMs:o},i={changes:[],changesThreshold:n,thresholdMs:o},s=void 0,a=null;function l(){void 0!==s&&(e.next(s),s=void 0,null!==a&&clearTimeout(a),ia(r),ia(i))}return t.subscribe(function(e){null!==a&&clearTimeout(a),t=e===U.X?r:i,n=+Date.now(),t.startTime=t.startTime||n,u=t.changes,c=t.changesThreshold,u.push(n),u.length>c&&u.shift();var t,n,u,c,d=function(e,t){var r=void 0;if(is(e)&&(r=e.startTime),is(t)){var n=t.startTime;n&&(!r||n<r)&&(r=n)}return r}(r,i);return d?(s=s||d,a=setTimeout(function(){l(),a=null},o)):l(),il(r),il(i),function(){null!==a&&(clearTimeout(a),a=null)}})})},ic=function(e){var t=e.amplitude,r=e.options,n=e.allObservables,i=e.directionChanges,o=e.thresholdMs;return iu({mouseDirectionChangeObservable:io({allWindowObservables:n}),directionChanges:void 0===i?20:i,thresholdMs:void 0===o?2e3:o}).subscribe(function(e){nh(r)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})})};function id(e,t,r,n){if(!n)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:r}var ig=function(e){void 0===e&&(e={});var t,r="@amplitude/plugin-frustration-browser",n=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var o=!1!==e.deadClicks&&null!==e.deadClicks,s=!1!==e.rageClicks&&null!==e.rageClicks,a=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(a=!1);var l=id(e,"rageClicks",ie,s),u=id(e,"deadClicks",n9,o),c=id(e,"errorClicks",n9,i),d=null!=(t=e.dataAttributePrefix)?t:rX,f=new n6(e),g=(0,Z.__spreadArray)([],(0,Z.__read)(new Set((0,Z.__spreadArray)((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(l),!1),(0,Z.__read)(u),!1),(0,Z.__read)(c),!1))),!1),h=function(){var e,t,r=ne(nR("pointerdown").map(function(e){return f.addAdditionalEventProperties(e,"click",g,d,!0)})),n=ne(nM().map(function(e){return f.addTypeAndTimestamp(e,"error")})),i=ne(nA().map(function(e){return f.addAdditionalEventProperties(e,"mutation",g,d)}));window.navigation&&(t=ne(new nS.default(function(e){var t=function(t){e.next((0,Z.__assign)((0,Z.__assign)({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}}).map(function(e){return f.addAdditionalEventProperties(e,"navigate",g,d)})));var o=ne(new nS.default(function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){var r=void 0,n=void 0;try{if(r=t.selectionStart,n=t.selectionEnd,r===n)return}catch(e){return}return e.next()}var i=window.getSelection();if(i&&!i.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}})),s=ne(new nS.default(function(e){var t=function(t){e.next(t)},r={capture:!0};return nO.document.addEventListener("mousemove",t,r),function(){nO.document.removeEventListener("mousemove",t,r)}}));return(e={})[j.ClickObservable]=r,e[j.MutationObservable]=i,e[j.NavigateObservable]=t,e[j.BrowserErrorObservable]=n,e[j.SelectionObservable]=o,e[j.MouseMoveObservable]=s,e};return{name:r,type:"enrichment",setup:function(t,g){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var p,v,m,y,_,b,w,S,E;return(0,Z.__generator)(this,function(k){var I,T,C,P,x,O,A,R,M,D,L,F,j,q,U,B,z,W,G,H,$,K;return"u"<typeof document?[2]:(p=h(),(v=n8(t,f))&&n.push({unsubscribe:v}),s&&(m=function(e){var t=this,r=e.amplitude,n=e.allObservables,i=e.shouldTrackRageClick,o=n.clickObservable,s=n.selectionObservable,a=[],l={},u=null;function c(e){a=[],l={},e&&(ir(l,e),a.push(e))}var d=r7(o.filter(function(e){return i("click",e.closestTrackedAncestor)}),function(e){return(0,Z.__awaiter)(t,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){var n,i,o,s;return(ir(l,e),t=null,0===a.length||(n=a).length>0&&n[n.length-1].closestTrackedAncestor!==e.closestTrackedAncestor||(o=Math.max(0,(i=a).length-4+1),s=i[o],e.timestamp-s.timestamp>=1e3)||l.isOutOfBounds)?(u&&(t=ii(a)),c(e)):a.push(e),(u&&(clearTimeout(u.timerId),u.resolve(t),u=null),a.length>=4)?[2,new Promise(function(e){u={resolve:e,timerId:setTimeout(function(){e(ii(a))},1e3)}})]:[2,null]})})}),f=null==s?void 0:s.subscribe(function(){c()}),g=d.subscribe(function(e){null!==e&&r.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})});return{unsubscribe:function(){g.unsubscribe(),null==f||f.unsubscribe()}}}({allObservables:p,amplitude:g,shouldTrackRageClick:np(e,l)}),n.push(m)),o&&(T=(I={amplitude:g,allObservables:p,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:np(e,u)}).amplitude,C=I.allObservables,P=I.getEventProperties,x=I.shouldTrackDeadClick,O=C.clickObservable,A=C.mutationObservable,R=C.navigateObservable,M=O.filter(function(e){return nb(e)&&x("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=R?r9(A,R):A,L=r9(M,D),F=null,y=r7(L,function(e){if(F&&it.includes(e.type))clearTimeout(F),F=null;else if("click"===e.type)return F?Promise.resolve(null):new Promise(function(t){F=setTimeout(function(){t(e),F=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,Z.__assign)((0,Z.__assign)({},P("click",e.closestTrackedAncestor)),t),{time:e.timestamp})}}),n.push(y)),i&&(q=(j={amplitude:g,allObservables:p,shouldTrackErrorClick:np(e,c)}).amplitude,U=j.allObservables,B=j.shouldTrackErrorClick,z=U.clickObservable,W
2=U.browserErrorObservable,G=z.filter(function(e){return nb(e)&&B("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===N.LEFT_OR_TOUCH_CONTACT}),H=null,$=null,K=function(){null!==H&&(clearTimeout(H),H=null),$=null},_=r9(G,W).subscribe(function(e){var t;if("click"===e.type){K(),$=e,H=setTimeout(K,2e3);return}"error"===e.type&&$&&(q.track("[Amplitude] Error Click",(0,Z.__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),$.targetElementProperties)),K())}),n.push(_)),a&&(b=void 0,w=void 0,"object"==typeof e.thrashedCursor&&(b=e.thrashedCursor.directionChanges,w=e.thrashedCursor.threshold,b&&b<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(b," is below the minimum of ").concat(5,", setting to ").concat(5)),b=5),w&&w>4e3&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(w," is above the maximum of ").concat(4e3,", setting to ").concat(4e3)),w=4e3)),S=ic({amplitude:g,options:e,allObservables:p,directionChanges:b,thresholdMs:w}),n.push(S)),null==(E=null==t?void 0:t.loggerProvider)||E.log("".concat(r," has been successfully added.")),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,i;return(0,Z.__generator)(this,function(o){try{for(t=(e=(0,Z.__values)(n)).next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){r={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(r)throw r.error}}return[2]})})}}};function ih(e,t){var r=e.startTime+e.duration;return t.filter(function(t){return t.startTime<r&&t.startTime+t.duration>e.startTime}).map(function(e){return e.name})}var ip=function(e){void 0===e&&(e={});var t="@amplitude/plugin-performance-browser",r=[],n=!0===e.mainThreadBlock||"object"==typeof e.mainThreadBlock&&null!==e.mainThreadBlock;return{name:t,type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s,a,l;return(0,Z.__generator)(this,function(u){return"u"<typeof document||(n&&(s=100,"object"==typeof e.mainThreadBlock&&void 0!==e.mainThreadBlock.durationThreshold&&(s=e.mainThreadBlock.durationThreshold),a=function(e){var t=e.amplitude,r=e.options,n=e.durationThreshold,i=void 0===n?100:n,o=function(){if("u"<typeof PerformanceObserver)return null;try{var e=PerformanceObserver.supportedEntryTypes;if(e.includes("long-animation-frame"))return"long-animation-frame";if(e.includes("longtask"))return"longtask"}catch(e){}return null}();if(!o)return{unsubscribe:function(){}};var s=[],a=new PerformanceObserver(function(e){var t,r,n=performance.now();try{for(var i=(0,Z.__values)(e.getEntries()),o=i.next();!o.done;o=i.next()){var a=o.value;s.push(a)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}for(var l=n-1e4;s.length>0&&s[0].startTime<l;)s.shift()});try{a.observe({entryTypes:["measure"]})}catch(e){}var l=new PerformanceObserver(function(e){var n,a;try{for(var l=(0,Z.__values)(e.getEntries()),u=l.next();!u.done;u=l.next()){var c=u.value;if(!nh(r))return;if(!(c.duration<i)){var d="long-animation-frame"===o?function(e,t){var r,n=ih(e,t),i=null!=(r=e.scripts)?r:[],o=i.map(function(e){return e.sourceURL}).filter(Boolean),s=i.map(function(e){return e.sourceFunctionName}).filter(Boolean),a=i.map(function(e){return e.sourceCharPosition}).filter(function(e){return"number"==typeof e&&e>=0}),l=i.map(function(e){return e.invokerType}).filter(Boolean),u=i.map(function(e){return e.invoker}).filter(Boolean);return(0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)((0,Z.__assign)({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.blockingDuration,"[Amplitude] Main Thread Block Start Time":e.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),{"[Amplitude] Main Thread Block Render Start":e.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":e.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),o.length>0&&{"[Amplitude] Main Thread Block Script URLs":o}),s.length>0&&{"[Amplitude] Main Thread Block Script Functions":s}),a.length>0&&{"[Amplitude] Main Thread Block Script Positions":a}),l.length>0&&{"[Amplitude] Main Thread Block Invoker Types":l}),u.length>0&&{"[Amplitude] Main Thread Block Invokers":u})}(c,s):function(e,t){var r,n=ih(e,t),i=null!=(r=e.attribution)?r:[];return(0,Z.__assign)((0,Z.__assign)({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":e.duration,"[Amplitude] Main Thread Block Blocking Duration":e.duration,"[Amplitude] Main Thread Block Start Time":e.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(e){return e.name})})}(c,s);t.track("[Amplitude] Main Thread Block",d)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(a=l.return)&&a.call(l)}finally{if(n)throw n.error}}});try{l.observe({entryTypes:[o]})}catch(e){return a.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){l.disconnect(),a.disconnect()}}}({amplitude:o,options:e,durationThreshold:s}),r.push(a)),null==(l=null==i?void 0:i.loggerProvider)||l.log("".concat(t," performance tracking has been successfully added."))),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,n,i;return(0,Z.__generator)(this,function(o){try{for(t=(e=(0,Z.__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]})})}}},iv=e.i(679509),im=function(){function e(e){this.request=e}return e.prototype.headers=function(e){void 0===e&&(e=[]);var t,r,n=this.request.headers,i={};if(Array.isArray(n))n.forEach(function(e){var t=(0,Z.__read)(e,2),r=t[0],n=t[1];i[r]=n});else if(n instanceof Headers)n.forEach(function(e,t){i[t]=e});else if("object"==typeof n&&null!==n)try{for(var o=(0,Z.__values)(Object.entries(n)),s=o.next();!s.done;s=o.next()){var a=(0,Z.__read)(s.value,2),l=a[0],u=a[1];i[l]=u}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return ik(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=(0,eO.getGlobalScope)();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=i_(t,100),this._bodySize}}
2,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return 0===e.length?[2,null]:[2,iS(this.body,e,t)]})})},e}(),iy=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),ik(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return i_(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return 0===e.length?[2,null]:[2,iS(this.body,e,t)]})})},e}();function i_(e,t){var r,n,i,o,s=(0,eO.getGlobalScope)(),a=null==s?void 0:s.TextEncoder;if(a&&null!=e){if("string"==typeof e)o=e,i=new a().encode(o).length;else if("u">typeof Blob&&e instanceof Blob)i=(o=e).size;else if("u">typeof URLSearchParams&&e instanceof URLSearchParams)o=e,i=new a().encode(o.toString()).length;else if(ArrayBuffer.isView(e))i=(o=e).byteLength;else if(e instanceof ArrayBuffer)i=(o=e).byteLength;else if("u">typeof FormData&&e instanceof FormData){var l=0,u=0;try{for(var c=(0,Z.__values)(e.entries()),d=c.next();!d.done;d=c.next()){var f=(0,Z.__read)(d.value,2),g=f[0],h=f[1];if(l+=g.length,"string"==typeof h)l+=new a().encode(h).length;else{if(!("u">typeof Blob&&h instanceof Blob))return;l+=h.size}if(++u>=t)return}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}i=l}else if("u">typeof ReadableStream&&e instanceof ReadableStream){o=e;return}return i}}var ib=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 r=this.response.headers,n={};return null==(t=null==r?void 0:r.forEach)||t.call(r,function(e,t){n[t]=e}),ik(n,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){if(void 0!==this._bodySize)return this._bodySize;var e,t,r=null==(t=null==(e=this.response.headers)?void 0:e.get)?void 0:t.call(e,"content-length"),n=r?parseInt(r,10):void 0;return this._bodySize=n,n},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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(0===e.length)return[2,null];return[4,this.text()];case 1:return[2,iS(r.sent(),e,t)]}})})},e}(),iw=function(){function e(e,t,r,n){this.statusCode=e,this.headersString=t,this.size=r,this.getJson=n}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,r,n={},i=this.headersString.split("\r\n");try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value,l=(0,Z.__read)(a.split(": "),2),u=l[0],c=l[1];u&&c&&(n[u]=c)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return ik(n,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),(0,Z.__awaiter)(this,void 0,void 0,function(){var r;return(0,Z.__generator)(this,function(n){return 0===e.length?[2,null]:(r=this.getJson())?((0,iv.pruneJson)(r,e,t),[2,r]):[2,null]})})},e}();function iS(e,t,r){if(!e)return null;try{var n=JSON.parse(e);return(0,iv.pruneJson)(n,t,r),n}catch(e){return null}}(f=B||(B={})).REDACT="redact",f.REMOVE="remove";var iE="[REDACTED]",ik=function(e,t){var r,n,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?B.REMOVE:s,l=(0,Z.__spreadArray)([],(0,Z.__read)(ek),!1),u={};try{for(var c=(0,Z.__values)(Object.keys(e)),d=c.next();!d.done;d=c.next()){var f=d.value;!function(t){var r=t.toLowerCase();l.find(function(e){return e.toLowerCase()===r})?a===B.REDACT&&(u[t]=iE):o.find(function(e){return e.toLowerCase()===r})?u[t]=e[t]:a===B.REDACT&&(u[t]=iE)}(f)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return u},iI=function(){function e(e,t,r,n,i,o,s,a,l,u,c){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=r,this.startTime=n,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=l,this.error=u,this.endTime=c}return e.prototype.toSerializable=function(){var e,t,r,n;
2return 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,Z.__spreadArray)([],(0,Z.__read)(eE),!1)),requestBodySize:null==(t=this.requestWrapper)?void 0:t.bodySize,responseHeaders:null==(r=this.responseWrapper)?void 0:r.headers((0,Z.__spreadArray)([],(0,Z.__read)(eE),!1)),responseBodySize:null==(n=this.responseWrapper)?void 0:n.bodySize}).filter(function(e){var t=(0,Z.__read)(e,2);return void 0!==(t[0],t[1])}))},e}(),iT=function(e,t){void 0===t&&(t=eR()),this.callback=e,this.id=t};function iC(e){try{e()}catch(e){}}var iP=new(function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var r=(0,eO.getGlobalScope)();e.isSupported()&&(this.globalScope=r)}return e.isSupported=function(){var e=(0,eO.getGlobalScope)();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var r,n,i,o,s,a,l,u,c,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null==(i=null==(n=null==(r=this.globalScope)?void 0:r.XMLHttpRequest)?void 0:n.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==(u=null==(l=this.globalScope)?void 0:l.XMLHttpRequest)?void 0:u.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(r){try{r.callback(e)}catch(e){iC(function(){var r;null==(r=t.logger)||r.debug("an unexpected error occurred while triggering event callbacks",e)})}})},e.prototype.handleNetworkRequestEvent=function(e,t,r,n,i,o,s){if(void 0!==o&&void 0!==s){var a,l,u,c,d="GET";if("object"==typeof t&&null!==t&&"url"in t&&"method"in t?(l=t.url,d=t.method):l=null==(a=null==t?void 0:t.toString)?void 0:a.call(t),l)try{var f=new URL(l);l="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==r?void 0:r.method)||d,n&&(u=n.status),i&&(c={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},u=0);var g=Math.floor(performance.now()-s),h=Math.floor(o+g),p=new iI(e,d,o,o,l,r,u,g,n,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(r,n){return(0,Z.__awaiter)(t,void 0,void 0,function(){var t,i,o,s=this;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:try{t=this.getTimestamps()}catch(e){iC(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(r,n)];case 2:return i=a.sent(),[3,4];case 3:return o=a.sent(),[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",r,n?new im(n):void 0,i?new ib(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){iC(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 r;try{if("json"===e.responseType){if(null==(r=t.globalScope)?void 0:r.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(r){r instanceof Error&&"InvalidStateError"===r.name&&iC(function(){var r;return null==(r=t.logger)?void 0:r.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))})}return null}},e.prototype.observeXhr=function(t,r,n){if(this.globalScope&&t&&r){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=(0,Z.__read)(r,2),s=i[0],a=i[1];try{this.$$AmplitudeAnalyticsEvent=(0,Z.__assign)({method:s,url:null==(e=null==a?void 0:a.toString)?void 0:e.call(a),headers:{}},o.getTimestamps())}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while calling xhr open",e)})}return t.apply(this,r)},i.send=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=this,s=e.createXhrJsonParser(this,o),a=t[0],l=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),r=new iw(i.status,e,t?parseInt(t,10):void 0,s),n=i.$$AmplitudeAnalyticsEvent.headers,u=new iy(a,n);l.status=i.status,o.handleNetworkRequestEvent("xhr",{url:l.url,method:l.method},u,r,void 0,l.startTime,l.durationStart)}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while handling xhr send",e)})}}),r.apply(i,t)},i.setRequestHeader=function(e,t){try{var r=this.$$AmplitudeAnalyticsEvent;r&&(r.headers[e]=t)}catch(e){iC(function(){var t;return null==(t=o.logger)?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)})}n.apply(this,[e,t])}}},e}()),ix="[Amplitude] Network Request",nS=r8,iO="500-599";function iA(e,t){return RegExp("^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$").test(e)}function iR(e,t){var r,n,i=t.split(",");try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value,l=(0,Z.__read)(a.split("-").map(Number),2),u=l[0],c=l[1];if(e===u&&void 0===c||e>=u&&e<=c)return!0}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function iM(e){if(e)try{var t,r,n,i,o,s,a,l,u,c=null==(t=(0,eO.getGlobalScope)())?void 0:t.location.href,d=new URL(e,c),f=d.searchParams.toString(),g=d.hash.replace("#",""),h=d.href,p=d.host;d.hash="",d.search="";var v=d.href;return{query:f,fragment:g,href:h,hrefWithoutQueryOrHash:v,host:p}}catch(t){try{return i=(n=e.indexOf("#"))>=0?e.slice(n+1):"",a=(s=(o=n>=0?e.slice(0,n):e).indexOf("?"))>=0?o.slice(s+1):"",u=(l=s>=0?o.slice(0,s):o).match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i),{query:a,fragment:i,href:e,hrefW
2ithoutQueryOrHash:l,host:null!=(r=null==u?void 0:u[1])?r:""}}catch(e){return}}}function iD(e){return"object"!=typeof e||null===e?e?(0,Z.__spreadArray)([],(0,Z.__read)(eE),!1):void 0:0!==e.length?e:void 0}function iL(e){var t,r,n;return!(null==(t=null==e?void 0:e.allowlist)?void 0:t.length)&&!(null==(r=null==e?void 0:e.blocklist)?void 0:r.length)&&!(null==(n=null==e?void 0:e.excludelist)?void 0:n.length)}(z||(z={})).NetworkObservable="networkObservable";var iN=function(e){void 0===e&&(e={});var t,r="@amplitude/plugin-network-capture-browser",n=function(){var e,r=new nS.default(function(e){var r=new iT(function(t){var r={event:t,timestamp:Date.now(),type:"network"};e.next(r)});return iP.subscribe(r,t),function(){iP.unsubscribe(r)}});return(e={})[z.NetworkObservable]=r,e};return{name:r,type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s;return(0,Z.__generator)(this,function(a){var l,u,c,d,f,g,h;return"u"<typeof document&&(null==(l=null==(u=(0,eO.getGlobalScope)())?void 0:u.navigator)?void 0:l.product)!=="ReactNative"?[2]:(s=n(),t=null==i?void 0:i.loggerProvider,d=(c={allObservables:s,networkTrackingOptions:e,amplitude:o,loggerProvider:t}).allObservables,f=c.networkTrackingOptions,g=c.amplitude,h=c.loggerProvider,W=d.networkObservable.filter(function(e){return function(e,t){void 0===t&&(t={});var r,n,i=iM(e.url);if(!i)return!1;var o=i.host;return!(!1!==t.ignoreAmplitudeRequests&&(iA(o,"*.amplitude.com")||iA(o,"amplitude.com"))||(null==(r=t.ignoreHosts)?void 0:r.find(function(e){return iA(o,e)})))&&(!!t.captureRules||void 0===e.status||!!iR(e.status,iO))&&(!t.captureRules||((0,Z.__spreadArray)([],(0,Z.__read)(t.captureRules),!1).reverse().find(function(t){if(n=function(e,t,r,n,i){if((!e.hosts||e.hosts.find(function(e){return iA(t,e)}))&&(!n||!e.urls||nc(n,e.urls))&&(!i||!e.methods||e.methods.find(function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e})))return(!r&&0!==r||!!iR(r,e.statusCodeRange||iO))&&!0}(t,o,e.status,e.url,e.method)){var r=iD(t.responseHeaders);if(e.responseWrapper&&r){var i=e.responseWrapper.headers(r);i&&(e.responseHeaders=i)}var s=iD(t.requestHeaders);if(e.requestWrapper&&s){var a=e.requestWrapper.headers(s);a&&(e.requestHeaders=a)}if(e.responseWrapper&&t.responseBody&&!iL(t.responseBody)){var l=t.responseBody.excludelist||t.responseBody.blocklist;e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,l)}if(e.requestWrapper&&t.requestBody&&!iL(t.requestBody)){var l=t.requestBody.excludelist||t.requestBody.blocklist;e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,l)}}return void 0!==n}),!!n))&&!(e.requestWrapper&&function(e,t){if(e.includes("amplitude.com"))try{var r=t.body;if("string"!=typeof r)return!1;if(JSON.parse(r).events.find(function(e){return e.event_type===ix}))return!0}catch(e){}return!1}(o,e.requestWrapper))}(e.event,f)}).subscribe(function(e){var t,r,n,i=e.event,o=iM(i.url);if(o){var s=null==(r=i.responseWrapper)?void 0:r.bodySize,a=null==(n=i.requestWrapper)?void 0:n.bodySize;!function(e,t,r,n){(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(!(t.requestBodyJson||t.responseBodyJson))return[3,2];return[4,Promise.all([t.requestBodyJson,t.responseBodyJson])];case 1:if(o=(i=Z.__read.apply(void 0,[a.sent(),2]))[0],s=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==n||n.debug("Failed to stringify request body",e)}if(s)try{e["[Amplitude] Response Body"]=JSON.stringify(s)}catch(e){null==n||n.debug("Failed to stringify response body")}a.label=2;case 2:return null==r||r.track(ix,e),[2]}})})}(((t={})["[Amplitude] URL"]=o.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=o.query,t["[Amplitude] URL Fragment"]=o.fragment,t["[Amplitude] Request Method"]=i.method,t["[Amplitude] Status Code"]=i.status,t["[Amplitude] Start Time"]=i.startTime,t["[Amplitude] Completion Time"]=i.endTime,t["[Amplitude] Duration"]=i.duration,t["[Amplitude] Request Body Size"]=a,t["[Amplitude] Response Body Size"]=s,t["[Amplitude] Request Type"]=i.type,t["[Amplitude] Request Headers"]=i.requestHeaders,t["[Amplitude] Response Headers"]=i.responseHeaders,t),i,g,h)}}),null==t||t.log("".concat(r," has been successfully added.")),[2])})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return W.unsubscribe(),[2]})})}}};let iF=-1,ij=e=>{addEventListener("pageshow",t=>{t.persisted&&(iF=t.timeStamp,e(t))},!0)},iq=(e,t,r,n)=>{let i,o;return s=>{let a;t.value>=0&&(s||n)&&((o=t.value-(i??0))||void 0===i)&&(i=t.value,t.delta=o,a=t.value,t.rating=a>r[1]?"poor":a>r[0]?"needs-improvement":"good",e(t))}},iU=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},iB=()=>{let e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},iz=()=>{let e=iB();return e?.activationStart??0},iW=(e,t=-1)=>{let r=iB(),n="navigate";return iF>=0?n="back-forward-cache":r&&(document.prerendering||iz()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(0x82f79cd8fff*Math.random())+1e12}`,navigationType:n}},iG=new WeakMap;function iH(e,t){return iG.get(e)||iG.set(e,new t),iG.get(e)}class i${t;i=0;o=[];h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.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 iK=(e,t,r={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let n=new PerformanceObserver(e=>{Promise.resolve().then(()=>{t(e.getEntries())})});return n.observe({type:e,buffered:!0,...r}),n}}catch{}},iV=e=>{let t=!1;return()=>{t||(e(),t=!0)}},iJ=-1,iY=new Set,iX=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,iQ=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(let e of iY)e();isFinite(iJ)||(iJ="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",iQ,!0))}},iZ=()=>
2{if(iJ<0){let e=iz();iJ=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(t=>"hidden"===t.name&&t.startTime>e)[0]?.startTime)??iX(),addEventListener("visibilitychange",iQ,!0),addEventListener("prerenderingchange",iQ,!0),ij(()=>{setTimeout(()=>{iJ=iX()})})}return{get firstHiddenTime(){return iJ},onHidden(e){iY.add(e)}}},i0=e=>{document.prerendering?addEventListener("prerenderingchange",()=>e(),!0):e()},i1=[1800,3e3],i2=(e,t={})=>{i0(()=>{let r=iZ(),n,i=iW("FCP"),o=iK("paint",e=>{for(let t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-iz(),0),i.entries.push(t),n(!0)))});o&&(n=iq(e,i,i1,t.reportAllChanges),ij(r=>{n=iq(e,i=iW("FCP"),i1,t.reportAllChanges),iU(()=>{i.value=performance.now()-r.timeStamp,n(!0)})}))})},i3=[.1,.25],i4=0,i5=1/0,i6=0,i8=e=>{for(let t of e)t.interactionId&&(i5=Math.min(i5,t.interactionId),i4=(i6=Math.max(i6,t.interactionId))?(i6-i5)/7+1:0)},i7=()=>t?i4:performance.interactionCount??0,i9=0;class oe{u=[];l=new Map;m;p;v(){i9=i7(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((i7()-i9)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),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?.(r)}}}let ot=e=>{let t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(addEventListener("visibilitychange",e=iV(e),{once:!0,capture:!0}),t(()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})}))},or=[200,500];class on{m;h(e){this.m?.(e)}}let oi=[2500,4e3],oo=[800,1800],os=e=>{document.prerendering?i0(()=>os(e)):"complete"!==document.readyState?addEventListener("load",()=>os(e),!0):setTimeout(e)};function oa(e){var t,r;return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor((r=(null==(t=e.entries[0])?void 0:t.startTime)||0,performance.timeOrigin+r)),navigationStart:Math.floor(performance.timeOrigin)}}var ol=function(){var e=null,r=(0,eO.getGlobalScope)(),n=null==r?void 0:r.document,i=null==r?void 0:r.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(r,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var s,a;return(0,Z.__generator)(this,function(l){return void 0===n||(s=nd((null==i?void 0:i.href)||"",r.loggerProvider),a={"[Amplitude] Page Domain":(null==i?void 0:i.hostname)||"","[Amplitude] Page Location":s,"[Amplitude] Page Path":nd((null==i?void 0:i.pathname)||"",r.loggerProvider),"[Amplitude] Page Title":"u">typeof document&&document.title||"","[Amplitude] Page URL":nd(s.split("?")[0],r.loggerProvider)},((e,t={})=>{i0(()=>{let r=iZ(),n,i=iW("LCP"),o=iH(t,on),s=e=>{for(let s of(t.reportAllChanges||(e=e.slice(-1)),e))o.h(s),s.startTime<r.firstHiddenTime&&(i.value=Math.max(s.startTime-iz(),0),i.entries=[s],n())},a=iK("largest-contentful-paint",s);if(a){n=iq(e,i,oi,t.reportAllChanges);let r=iV(()=>{s(a.takeRecords()),a.disconnect(),n(!0)}),o=e=>{e.isTrusted&&(ot(r),removeEventListener(e.type,o,{capture:!0}))};for(let e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});ij(r=>{n=iq(e,i=iW("LCP"),oi,t.reportAllChanges),iU(()=>{i.value=performance.now()-r.timeStamp,n(!0)})})}})})(function(e){a["[Amplitude] LCP"]=oa(e)}),i2(function(e){a["[Amplitude] FCP"]=oa(e)}),((e,r={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let n=iZ();i0(()=>{"interactionCount"in performance||t||(t=iK("event",i8,{type:"event",buffered:!0,durationThreshold:0}));let i,o=iW("INP"),s=iH(r,oe),a=e=>{ot(()=>{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())})},l=iK("event",a,{durationThreshold:r.durationThreshold??40});i=iq(e,o,or,r.reportAllChanges),l&&(l.observe({type:"first-input",buffered:!0}),n.onHidden(()=>{a(l.takeRecords()),i(!0)}),ij(()=>{s.v(),i=iq(e,o=iW("INP"),or,r.reportAllChanges)}))})})(function(e){a["[Amplitude] INP"]=oa(e)}),((e,t={})=>{let r=iZ();i2(iV(()=>{let n,i=iW("CLS",0),o=iH(t,i$),s=e=>{for(let t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,n())},a=iK("layout-shift",s);a&&(n=iq(e,i,i3,t.reportAllChanges),r.onHidden(()=>{s(a.takeRecords()),n(!0)}),ij(()=>{o.i=0,n=iq(e,i=iW("CLS",0),i3,t.reportAllChanges),iU(()=>n())}),setTimeout(n))}))})(function(e){a["[Amplitude] CLS"]=oa(e)}),((e,t={})=>{let r=iW("TTFB"),n=iq(e,r,oo,t.reportAllChanges);os(()=>{let i=iB();i&&(r.value=Math.max(i.responseStart-iz(),0),r.entries=[i],n(!0),ij(()=>{(n=iq(e,r=iW("TTFB",0),oo,t.reportAllChanges))(!0)}))})})(function(e){a["[Amplitude] TTFB"]=oa(e)}),e=function(){"hidden"===n.visibilityState&&e&&(o.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]})})}}},ou=function(e,t,r){return void 0===t&&(t=""),void 0===r&&(r=10),["AMP",t,e.substring(0,r)].filter(
2Boolean).join("_")},oc=function(){function e(e,t){var r;this.shouldTrackNewCampaign=!1,this.options=(0,Z.__assign)({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:ry((null==(r=t.cookieOptions)?void 0:r.domain)||t.topLevelDomain),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=ou(t.apiKey,"MKTG"),this.webExpStorageKey=ou(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=eS,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,Z.__awaiter)(this,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(this.options.optOut)return[2];return[4,this.fetchCampaign()];case 1:if(t=Z.__read.apply(void 0,[r.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||te(this.sessionTimeout,this.lastEventTime),!rp(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:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.fetchCampaign=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e;return(0,Z.__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 rL().parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}})})},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,r,n=(t=this.currentCampaign,r=this.options,eD(Object.entries((0,Z.__assign)((0,Z.__assign)({},eS),t)).reduce(function(e,t){var n,i=(0,Z.__read)(t,2),o=i[0],s=i[1];return(e.setOnce("initial_".concat(o),null!=(n=null!=s?s:r.initialEmptyValue)?n:"EMPTY"),s)?e.set(o,s):e.unset(o)},new eC)));return e&&(n.event_id=e),n},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),od=new Set([A.IDENTIFY,A.GROUP_IDENTIFY]),of=function(e){void 0===e&&(e={});var t,r,n,i,o,s,a,l=null!=(t=e.fallbackAttributionEvent)&&t,u=(0,eO.getGlobalScope)(),c={},d=!1,f=!1,g=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,new rL().parse()];case 1:return c=rN(e.sent()),l&&(null==n||n.log("Tracking attribution fallback event."),null==r||r.track("[Amplitude] Attribution",c)),[2]}})})},h=function(){g()},p=function(e){return new Proxy(e,{apply:function(e,t,r){Reflect.apply(e,t,r),d&&h()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(l){switch(l.label){case 0:return r=t,n=e.loggerProvider,d=!0,n.log("Installing event property attribution tracking."),[4,g()];case 1:if(l.sent(),!u)return[2];if(u.addEventListener("popstate",h),!f){if(i=Reflect.get(u.history,"pushState"),o=Reflect.get(u.history,"replaceState"),!i||!o)return[2];s=p(i),u.history.pushState=s,a=p(o),u.history.replaceState=a,f=!0}return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return od.has(e.event_type)||(e.event_properties=(0,Z.__assign)((0,Z.__assign)({},c),e.event_properties)),[2,e]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t;return(0,Z.__generator)(this,function(r){return u&&(u.removeEventListener("popstate",h),e=Reflect.get(u.history,"pushState"),t=Reflect.get(u.history,"replaceState"),f&&e===s&&i&&(u.history.pushState=i),f&&t===a&&o&&(u.history.replaceState=o)),d=!1,f=!1,i=void 0,o=void 0,s=void 0,a=void 0,c={},[2]})})}}},og="AMP_CURRENT_PAGE",oh="AMP_PREVIOUS_PAGE",op="AMP_URL_INFO";(g=G||(G={})).Direct="direct",g.Internal="internal",g.External="external";var ov=new Set([A.IDENTIFY,A.GROUP_IDENTIFY,A.REVENUE]),om=function(e){var t=(void 0===e?{}:e).internalDomains,r=void 0===t?[]:t,n=(0,eO.getGlobalScope)(),i=void 0,o=!1,s=void 0,a=!1,l=!1,u=function(e){var t;try{var r=nd(e,s);
2t=new URL(r).hostname}catch(e){null==s||s.error("Could not parse URL: ",e)}return t},c=function(e){var t="u">typeof location&&location.hostname||"",n=e?u(e):void 0;if(!n)return G.Direct;var i=r.some(function(e){return -1!==t.indexOf(e)}),o=r.some(function(e){return -1!==n.indexOf(e)});return t===n||o&&i?G.Internal:G.External},d=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(!(i&&o))return[3,3];return[4,i.get(op)];case 1:return e=a.sent(),t=nd("u">typeof location&&location.href||""),r=(null==e?void 0:e[og])||"",n=void 0,n=t===r?(null==e?void 0:e[oh])||"":r||document.referrer||"",[4,i.set(op,((s={})[og]=t,s[oh]=n,s))];case 2:a.sent(),a.label=3;case 3:return[2]}})})},f=function(){d()};return{name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,r,c,g,h,p,v,m;return(0,Z.__generator)(this,function(y){switch(y.label){case 0:if((s=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),l=!0,!n)return[3,7];try{i=new tX(n.sessionStorage)}catch(e){null==s||s.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:if(o=null!=(m=y.sent())&&m,!(i&&o))return[3,6];return r=(t="u">typeof document&&document.referrer||"")?u(t):void 0,c="u">typeof location&&location.hostname||"",g=nd("u">typeof location&&location.href||""),[4,i.get(op)];case 2:if(p=(null==(h=y.sent())?void 0:h[og])||"",!(r&&r!==c&&p!==g))return[3,4];return[4,i.set(op,((v={})[og]=g,v[oh]=t,v))];case 3:return y.sent(),[3,6];case 4:return[4,d()];case 5:y.sent(),y.label=6;case 6:n.addEventListener("popstate",f),a||(n.history.pushState=new Proxy(n.history.pushState,{apply:function(e,t,r){var n=(0,Z.__read)(r,3),i=n[0],o=n[1],s=n[2];e.apply(t,[i,o,s]),l&&f()}}),n.history.replaceState=new Proxy(n.history.replaceState,{apply:function(e,t,r){var n=(0,Z.__read)(r,3),i=n[0],o=n[1],s=n[2];e.apply(t,[i,o,s]),l&&f()}}),a=!0),y.label=7;case 7:return[2]}})})},execute:function(e){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,r,n;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:if(t=nd("u">typeof location&&location.href||""),!(i&&o))return[3,2];return[4,i.get(op)];case 1:if(n=(null==(r=s.sent())?void 0:r[oh])||"",ov.has(e.event_type))return[2,e];e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties||{}),{"[Amplitude] Page Domain":oy(e,"[Amplitude] Page Domain","u">typeof location&&location.hostname||""),"[Amplitude] Page Location":oy(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":oy(e,"[Amplitude] Page Path","u">typeof location&&nd(location.pathname)||""),"[Amplitude] Page Title":oy(e,"[Amplitude] Page Title",rD(rM)),"[Amplitude] Page URL":oy(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":n,"[Amplitude] Previous Page Type":c(n)}),s.label=2;case 2:return[2,e]}})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:if(n&&(n.removeEventListener("popstate",f),l=!1),!(i&&o))return[3,2];return[4,i.set(op,{})];case 1:e.sent(),e.label=2;case 2:return[2]}})})}}};function oy(e,t,r){return(e.event_properties||(e.event_properties={}),void 0===e.event_properties[t])?r:e.event_properties[t]}var o_=function(){var e,t,r;function n(t){if(t)try{var r=Function("return "+t)();if("function"==typeof r)return r;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}return{name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var o,s;return(0,Z.__generator)(this,function(a){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null==(s=i.remoteConfig)?void 0:s.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(e){r=e&&"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body?n(e.body||""):n("")}),t=function(){var e;return null==(e=i.remoteConfigClient)?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(t){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var n;return(0,Z.__generator)(this,function(i){if(r)try{return[2,null!=(n=r(t))?n:null]}catch(t){null==e||e.error("Could not execute custom enrichment function",t)}return[2,t]})})},teardown:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return t&&t(),[2]})})}}},ob="userProperty",ow="eventProperty",oS=function(e){return e===ob||e===ow},oE=[ob,ow],ok=function(e){var t=(0,Z.__spreadArray)([],(0,Z.__read)(new Set((Array.isArray(e)?e:[e]).filter(oS))),!1);return t.length>0?t:(0,Z.__spreadArray)([],(0,Z.__read)(oE),!1)},oI=function(e,t){return ok(e.trackingMethod).includes(t)},oT=function(e){return oI(e,ob)};let oC={init:ei((h=new(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t}return(0,Z.__extends)(t,e),t.prototype.init=function(e,t,r){var n,i;return void 0===e&&(e=""),arguments.length>2?(n=t,i=r):"string"==typeof t?(n=t,i=void 0):(n=null==t?void 0:t.userId,i=t),eF(this._init((0,Z.__assign)((0,Z.__assign)({},i),{userId:n,apiKey:e})))},t.prototype._init=function(t){var r,n,i,o,s,a,l,u;return(0,Z.__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,Z.__generator)(this,function(I){var T,C,P,O,A,R,M,D,L;switch(I.label){case 0:if(this.initializing)return[2];if(this.initializing=!0,c=rT(t),d=null!=(r=t.loggerProvider)?r:new eB,t.loggerProvider||d.enable(null!=(n=t.logLevel)?n:x.Warn),f=null!=(i=t.serverZone)?i:"US",h=this._diagnosticsSampleRate,p=null==(o=t.enableDiagnostics)||o,!c)return[3,2];return g=new to(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,r,n){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:r,lastFetch:n},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:I.sent(),I.label=2;case 2:return(v=new tb(t.apiKey,d,f,{enabled:p,sampleRate:h})).setTag("library","".concat(tB,"/").concat(tU)),"u">typeof navigator&&v.setTag("user_agent",navigator.userAgent),[4,(T=t.apiKey,C=t,P=this,O=v,A={loggerProvider:d,serverZone:f,enableDiagnostics:p,diagnosticsSampleRate:h},void 0===C&&(C={}),(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n,i,o,s,a,l,u,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,I,x,R,M,D,L,N,F,j,q,U,B,z,W,G,H,$,K,V,J,Y,X,Q,ee,et,er;return(0,Z.__generator)(this,function(en){var ei,eo,es,ea;switch(en.label){case 0:if(e=C.identityStorage||rf,t="",!(e===rf&&!(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=O,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return[4,new tH(void 0,{diagnosticsClient:eo}).isEnabled()];case 1:if(!a.sent()||!ei&&("u"<typeof location||!location.hostname)||1===(t=(e=null!=ei?ei:location.hostname).split(".")).length)return[2,""];for(r=[],n=1,rw.find(function(t){return e.endsWith(".".concat(t))})&&(n=2),i=t.length-n-1;i>=0;--i)r.push(t.slice(i).join("."));i=0,a.label=2;case 2:if(!(i<r.length))return[3,7];o=r[i],a.label=3;
2case 3:return a.trys.push([3,5,,6]),[4,tH.isDomainWritable(o)];case 4:if(a.sent())return[2,"."+o];return[3,6];case 5:return s=a.sent(),eo&&eo.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(o),error:s instanceof Error?s.message:String(s)}),[3,6];case 6:return i++,[3,2];case 7:return eo&&eo.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(e)}),[2,""]}})}))];case 1:t=en.sent(),en.label=2;case 2:return r=(0,Z.__assign)({domain:null!=(k=null==(E=C.cookieOptions)?void 0:E.domain)?k:t,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},C.cookieOptions),n={duplicateResolverFn:function(e){var t=tV(e);return!!t&&tJ(JSON.parse(t).cookieDomain,r.domain)},diagnosticsClient:O},[4,(es=i=rI(C.identityStorage,r,n),void 0===(ea=null==(x=null==(I=C.cookieOptions)?void 0:I.upgrade)||x)&&(ea=!0),(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n,i,o,s,a,l;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:return e="".concat("amp","_").concat(T.substring(0,6)),[4,es.getRaw(e)];case 1:if(!(t=u.sent()))return[2,{optOut:!1}];if(!ea)return[3,3];return[4,es.remove(e)];case 2:u.sent(),u.label=3;case 3:return n=(r=(0,Z.__read)(t.split("."),6))[0],i=r[1],o=r[2],s=r[3],a=r[4],l=r[5],[2,{deviceId:n,userId:t8(i),sessionId:t6(s),lastEventId:t6(l),lastEventTime:t6(a),optOut:!!o}]}})}))];case 3:return o=en.sent(),[4,i.get(tY(T))];case 4:return s=en.sent(),u=!(l=(a=tr()).ampTimestamp?Number(a.ampTimestamp):void 0)||Date.now()<l,c=null!=(N=null!=(L=null!=(D=null!=(R=C.deviceId)?R:u?null!=(M=a.ampDeviceId)?M:a.deviceId:void 0)?D:null==s?void 0:s.deviceId)?L:o.deviceId)?N:eR(),d=null!=(F=null==s?void 0:s.lastEventId)?F:o.lastEventId,f=null!=(j=null==s?void 0:s.lastEventTime)?j:o.lastEventTime,g=null!=(U=null!=(q=C.optOut)?q:null==s?void 0:s.optOut)?U:o.optOut,h=null!=(B=null==s?void 0:s.sessionId)?B:o.sessionId,p=null==s?void 0:s.deferredSessionId,v=null!=(W=null!=(z=C.userId)?z:null==s?void 0:s.userId)?W:o.userId,P.previousSessionDeviceId=null!=(G=null==s?void 0:s.deviceId)?G:o.deviceId,P.previousSessionUserId=null!=(H=null==s?void 0:s.userId)?H:o.userId,m={ipAddress:null==(K=null==($=C.trackingOptions)?void 0:$.ipAddress)||K,language:null==(J=null==(V=C.trackingOptions)?void 0:V.language)||J,platform:null==(X=null==(Y=C.trackingOptions)?void 0:Y.platform)||X},y=null==s?void 0:s.pageCounter,_=null==s?void 0:s.debugLogsEnabled,void 0!==C.autocapture&&(C.defaultTracking=C.autocapture),[4,(b=new rk(T,C.appVersion,i,r,C.defaultTracking,C.autocapture,c,C.flushIntervalMillis,C.flushMaxRetries,C.flushQueueSize,e,C.ingestionMetadata,C.instanceName,d,f,null!=(Q=null==A?void 0:A.loggerProvider)?Q:C.loggerProvider,C.logLevel,C.minIdLength,C.offline,g,C.partnerId,C.plan,C.serverUrl,null!=(ee=null==A?void 0:A.serverZone)?ee:C.serverZone,h,p,C.sessionTimeout,C.storageProvider,m,C.transport,C.useBatch,C.fetchRemoteConfig,v,y,_,C.networkTrackingOptions,C.identify,null!=(et=null==A?void 0:A.enableDiagnostics)?et:C.enableDiagnostics,null!=(er=null==A?void 0:A.diagnosticsSampleRate)?er:P._diagnosticsSampleRate,O,C.remoteConfig,t,C.enableRequestBodyCompression,C.customEnrichment)).storageProvider.isEnabled()];case 5:return en.sent()||(b.loggerProvider.warn("Storage provider ".concat(b.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),b.storageProvider=new tW),[2,b]}})}))];case 3:if(m=I.sent(),!(c&&g))return[3,5];return[4,new Promise(function(e){null==g||g.subscribe("configs.analyticsSDK.browserSDK","all",function(t,r,n){m.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:r,lastFetch:n},null,2)),t&&function(e,t){var r,n;if(e){!function e(t){if("object"==typeof t&&null!==t&&!Array.isArray(t)){var r,n,i,o,s,a,l,u,c,d,f,g,h=Object.keys(t);try{for(var p=(0,Z.__values)(h),v=p.next();!v.done;v=p.next()){var m=v.value;try{var y=t[m];"boolean"==typeof(null==y?void 0:y.enabled)&&(y.enabled?(delete y.enabled,0===Object.keys(y).length&&(t[m]=!0)):t[m]=!1),e(y)}catch(e){}}}catch(e){r={error:e}}finally{try{v&&!v.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}
2try{if(null==(c=null==(u=null==(l=t.autocapture)?void 0:l.networkTracking)?void 0:u.captureRules)?void 0:c.length)try{for(var _=(0,Z.__values)(t.autocapture.networkTracking.captureRules),b=_.next();!b.done;b=_.next()){var w=b.value;try{for(var S=(s=void 0,(0,Z.__values)(["responseHeaders","requestHeaders"])),E=S.next();!E.done;E=S.next()){var k=E.value,I=null!=(d=w[k])?d:{},T=I.captureSafeHeaders,C=I.allowlist;if(T||C){if(void 0!==C&&!Array.isArray(C)){delete w[k];continue}w[k]=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(T?eE:[]),!1),(0,Z.__read)(null!=C?C:[]),!1)}}}catch(e){s={error:e}}finally{try{E&&!E.done&&(a=S.return)&&a.call(S)}finally{if(s)throw s.error}}}}catch(e){i={error:e}}finally{try{b&&!b.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}catch(e){}var P=null==(f=t.autocapture)?void 0:f.frustrationInteractions;P&&(P.rageClick&&(P.rageClicks=P.rageClick,delete P.rageClick),P.deadClick&&(P.deadClicks=P.deadClick,delete P.deadClick));try{var x=null==(g=t.autocapture)?void 0:g.elementInteractions;if(x&&"object"==typeof x&&(!0===x.viewportContentUpdated&&(x.viewportContentUpdated={}),!1===x.viewportContentUpdated&&(x.viewportContentUpdated={enabled:!1}),void 0!==x.exposureDuration)){var O=x.viewportContentUpdated;void 0===O?x.viewportContentUpdated={exposureDuration:x.exposureDuration}:"object"==typeof O&&void 0===O.exposureDuration&&!1!==O.enabled&&(O.exposureDuration=x.exposureDuration),delete x.exposureDuration}}catch(e){}}}(e);try{if(t.loggerProvider.debug("Update browser config with remote configuration:",tS(e)),e&&"autocapture"in e){if("boolean"==typeof e.autocapture&&(t.autocapture=e.autocapture),"object"==typeof e.autocapture&&null!==e.autocapture){var i=(0,Z.__assign)({},e.autocapture);if(void 0===t.autocapture&&(t.autocapture=e.autocapture),"object"==typeof e.autocapture.elementInteractions&&null!==e.autocapture.elementInteractions&&(null==(r=e.autocapture.elementInteractions.pageUrlAllowlistRegex)?void 0:r.length)){i.elementInteractions=(0,Z.__assign)({},e.autocapture.elementInteractions);var o=i.elementInteractions,s=null!=(n=o.pageUrlAllowlist)?n:[],a=e.autocapture.elementInteractions.pageUrlAllowlistRegex;o.pageUrlAllowlist=rJ(s,a,t.loggerProvider),delete o.pageUrlAllowlistRegex}var l=function(e,t){if("object"==typeof e&&null!==e&&(null==(i=e.captureRules)?void 0:i.length)){var r,n,i,o,s,a=(0,Z.__assign)({},e),l=null!=(o=a.captureRules)?o:[];try{for(var u=(0,Z.__values)(l),c=u.next();!c.done;c=u.next()){var d=c.value;d.urls=rJ(null!=(s=d.urls)?s:[],d.urlsRegex,t),delete d.urlsRegex}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return a}}(e.autocapture.networkTracking,t.loggerProvider);l&&(i.networkTracking=l),"boolean"==typeof t.autocapture&&(t.autocapture=(0,Z.__assign)({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},i)),"object"==typeof t.autocapture&&(t.autocapture=(0,Z.__assign)((0,Z.__assign)({},t.autocapture),i))}t.defaultTracking=t.autocapture}"customEnrichment"in e&&null!==e.customEnrichment&&!1!==t.customEnrichment&&(t.customEnrichment=e.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",tS(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}(t,m),e()})})];case 4:I.sent(),I.label=5;case 5:return[4,e.prototype._init.call(this,m)];case 6:if(I.sent(),this.logBrowserOptions(m),this.config.remoteConfigClient=g,y=tk((R=this.config).defaultTracking)&&R.defaultTracking&&"object"==typeof R.defaultTracking&&R.defaultTracking.attribution&&"object"==typeof R.defaultTracking.attribution?(0,Z.__assign)({},R.defaultTracking.attribution):{},!(tk(this.config.defaultTracking)&&oT(y)))return[3,8];return this.config.optOut&&this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(e)return[3,2];return this.webAttribution=new oc(y,this.config),[4,this.webAttribution.init()];case 1:t.sent(),t.label=2;case 2:return[2]}})})}),this.webAttribution=new oc(y,this.config),[4,this.webAttribution.init()];case 7:I.sent(),I.label=8;case 8:if(w=!(!(b=(_=tr()).ampTimestamp?Number(_.ampTimestamp):void 0)||Date.now()<b)||Number.isNaN(Number(_.ampSessionId))?void 0:Number(_.ampSessionId),-1!==(S=this.config.deferredSessionId)||this.config.optOut||(S=Date.now()),this.setSessionId(null!=(u=null!=(l=null!=(a=t.sessionId)?a:w)?l:S)?u:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),(E=e8(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline)return[3,10];return[4,this.add(rV()).promise];case 9:I.sent(),I.label=10;case 10:return[4,this.add(new eJ({diagnosticsClient:v})).promise];case 11:return I.sent(),[4,this.add(new tz).promise];case 12:return I.sent(),[4,this.add(new tt).promise];case 13:if(I.sent(),rK(this.config),!tE(this.config.defaultTracking,"fileDownloads"))return[3,15];return this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(rH()).promise];case 14:I.sent(),I.label=15;case 15:if(!tI(this.config.defaultTracking))return[3,17];return this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(rz()).promise];case 16:I.sent(),I.label=17;case 17:if(!tT(this.config.defaultTracking))return[3,20];if(this.config.optOut)return[3,19];return this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(rj(tL(this.config))).promise];case 18:return I.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(e){return(0,Z.__awaiter)(k,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){switch(t.label){case 0:if(e)return[2];return this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(rj(tL(this.config))).promise];case 1:return t.sent(),[2]}})})}),I.label=20;case 20:if(!(tk(this.config.defaultTracking)&&oI(y,ow)))return[3,22];return this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(of(y)).promise];case 21:I.sent(),I.label=22;case 22:if(!tx(this.config.autocapture))return[3,24];return this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(n7(tR(this.config),{diagnosticsClient:v})).promise];case 23:I.sent(),I.label=24;case 24:if(!tO(this.config.autocapture))return[3,26];return this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(ig(tM(this.config))).promise];
2case 25:I.sent(),I.label=26;case 26:if(!tP(this.config.autocapture))return[3,28];return this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(iN(tD(this.config))).promise];case 27:I.sent(),I.label=28;case 28:if(!("boolean"==typeof(M=this.config.autocapture)?M:"object"==typeof M&&!0===M.webVitals))return[3,30];return this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(ol()).promise];case 29:I.sent(),I.label=30;case 30:if("object"!=typeof(D=this.config.autocapture)||!0!==D.performanceTracking&&"object"!=typeof D.performanceTracking)return[3,32];return this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(ip(tA(this.config))).promise];case 31:I.sent(),I.label=32;case 32:if(!tE(this.config.autocapture,"pageUrlEnrichment"))return[3,34];return this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(om()).promise];case 33:I.sent(),I.label=34;case 34:if(!("boolean"==typeof(L=this.config.customEnrichment)?L:"object"==typeof L&&null!==L&&!1!==L.enabled))return[3,36];return this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(o_()).promise];case 35:I.sent(),I.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return I.sent(),E.eventBridge.setEventReceiver(function(e){var t=e.eventProperties||{},r=t.time,n=(0,Z.__rest)(t,["time"]);k.track(e.eventType,n,"number"==typeof r?{time:r}:void 0)}),[2]}})})},t.prototype.getUserId=function(){var e;return null==(e=this.config)?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),(e!==this.config.userId||void 0===e)&&(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),e7(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null==(e=this.config)?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),e9(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(eR()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null==(e=this.config)?void 0:e.deviceId,userId:null==(t=this.config)?void 0:t.userId,userProperties:this.userProperties}},t.prototype.setIdentity=function(e){if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var t,r,n,i=new eC,o=null!=(n=e.userProperties)?n:{};try{for(var s=(0,Z.__values)(Object.entries(o)),a=s.next();!a.done;a=s.next()){var l=(0,Z.__read)(a.value,2),u=l[0],c=l[1];i.set(u,c)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null==(e=this.config)?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null==(e=this.config)?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,r=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),eF(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,eF(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return eF(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var n=this.getSessionId();n!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!=(t=this.config.lastEventId)?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,tC(this.config.defaultTracking)&&(n&&i&&r.push(this.track(rn,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:n,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,r);return this.config.identify&&r.push(this.track(eD(this.config.identify)).promise),tC(this.config.defaultTracking)&&r.push(this.track(rr,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,eF(Promise.all(r))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=
2Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=rC(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,r){if(tj(t)){var n=t._q;t._q=[],t=tF(new eC,n)}return(null==r?void 0:r.user_id)&&this.setUserId(r.user_id),(null==r?void 0:r.device_id)&&this.setDeviceId(r.device_id),e.prototype.identify.call(this,t,r)},t.prototype.groupIdentify=function(t,r,n,i){if(tj(n)){var o=n._q;n._q=[],n=tF(new eC,o)}return e.prototype.groupIdentify.call(this,t,r,n,i)},t.prototype.revenue=function(t,r){if(tj(t)){var n=t._q;t._q=[],t=tF(new eY,n)}return e.prototype.revenue.call(this,t,r)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!oT(this.webAttribution.options))return!1;var r=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(r).promise):this.track(r),this.config.loggerProvider.log("Tracking attribution."),!0},t.prototype.process=function(t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i;return(0,Z.__generator)(this,function(o){return r=Date.now(),n=te(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type!==rr&&t.event_type!==rn&&(!t.session_id||t.session_id===this.getSessionId())&&(n||i?(this.setSessionId(r),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):n||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]})})},t.prototype.logBrowserOptions=function(e){try{var t=(0,Z.__assign)((0,Z.__assign)({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",tS(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){if(!(e>1)&&!(e<0)&&!this.config){this._diagnosticsSampleRate=e;return}},t}(ej))).init.bind(h),"init",et(h),en(h,["config"])),add:ei(h.add.bind(h),"add",et(h),en(h,["config.apiKey","timeline.plugins"])),remove:ei(h.remove.bind(h),"remove",et(h),en(h,["config.apiKey","timeline.plugins"])),track:ei(h.track.bind(h),"track",et(h),en(h,["config.apiKey","timeline.queue.length"])),logEvent:ei(h.logEvent.bind(h),"logEvent",et(h),en(h,["config.apiKey","timeline.queue.length"])),identify:ei(h.identify.bind(h),"identify",et(h),en(h,["config.apiKey","timeline.queue.length"])),groupIdentify:ei(h.groupIdentify.bind(h),"groupIdentify",et(h),en(h,["config.apiKey","timeline.queue.length"])),setGroup:ei(h.setGroup.bind(h),"setGroup",et(h),en(h,["config.apiKey","timeline.queue.length"])),revenue:ei(h.revenue.bind(h),"revenue",et(h),en(h,["config.apiKey","timeline.queue.length"])),flush:ei(h.flush.bind(h),"flush",et(h),en(h,["config.apiKey","timeline.queue.length"])),getUserId:ei(h.getUserId.bind(h),"getUserId",et(h),en(h,["config","config.userId"])),setUserId:ei(h.setUserId.bind(h),"setUserId",et(h),en(h,["config","config.userId"])),getDeviceId:ei(h.getDeviceId.bind(h),"getDeviceId",et(h),en(h,["config","config.deviceId"])),setDeviceId:ei(h.setDeviceId.bind(h),"setDeviceId",et(h),en(h,["config","config.deviceId"])),reset:ei(h.reset.bind(h),"reset",et(h),en(h,["config","config.userId","config.deviceId"])),getSessionId:ei(h.getSessionId.bind(h),"getSessionId",et(h),en(h,["config"])),setSessionId:ei(h.setSessionId.bind(h),"setSessionId",et(h),en(h,["config"])),extendSession:ei(h.extendSession.bind(h),"extendSession",et(h),en(h,["config"])),setOptOut:ei(h.setOptOut.bind(h),"setOptOut",et(h),en(h,["config"])),setTransport:ei(h.setTransport.bind(h),"setTransport",et(h),en(h,["config"])),getIdentity:ei(h.getIdentity.bind(h),"getIdentity",et(h),en(h,["config"])),setIdentity:ei(h.setIdentity.bind(h),"setIdentity",et(h),en(h,["config","config.userId","config.deviceId"])),getOptOut:ei(h.getOptOut.bind(h),"getOptOut",et(h),en(h,["config"])),_setDiagnosticsSampleRate:ei(h._setDiagnosticsSampleRate.bind(h),"_setDiagnosticsSampleRate",et(h),en(h,["config"]))};e.s([],641521),e.i(641521),(p=H||(H={})).US="US",p.EU="EU",p.STAGING="STAGING",e.s(["DEFAULT_ACTION_CLICK_ALLOWLIST",0,rQ,"DEFAULT_CSS_SELECTOR_ALLOWLIST",0,rY,"DEFAULT_DATA_ATTRIBUTE_PREFIX",0,rX,"EXCLUDE_INTERNAL_REFERRERS_CONDITIONS",0,rg,"IdentifyOperation",0,O,"LogLevel",0,x,"OfflineDisabled",0,null,"RevenueProperty",0,D,"ServerZone",0,H,"SpecialEventType",0,A],991973),e.i(991973);var oP=oC.add,ox=(oC.extendSession,oC.flush,oC.getDeviceId,oC.getIdentity,oC.getOptOut,oC.getSessionId,oC.getUserId,oC.groupIdentify,oC.identify,oC.init),oO=(oC.logEvent,oC.remove,oC.reset,oC.revenue,oC.setDeviceId,oC.setGroup,oC.setIdentity,oC.setOptOut,oC.setSessionId,oC.setTransport,oC.setUserId),oA=oC.track;oC._setDiagnosticsSampleRate,e.s(["add",0,oP,"init",0,ox,"setUserId",0,oO,"track",0,oA],436370);var oR=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.customHeaders=t,r}return(0,Z.__extends)(t,e),t.prototype.send=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if("u"<typeof fetch)throw Error("FetchTransport is not supported");return[4,fetch(e,{headers:(0,Z.__assign)({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"})];case 1:return[4,(r=i.sent()).text()];case 2:n=i.sent();try{return[2,this.buildResponse(JSON.parse(n))]}catch(e){return[2,this.buildResponse({code:r.status})]}}})})},t}(t0),oM="[Amplitude]",oD="".concat(oM," Session Replay ID"),oL=H.US,oN={enabled:!0},oF="".concat(oM," Session Replay Debug"),oj="amp-mask",oq="amp-unmask",oU="https://api-sr.amplitude.com/sessions/v2/track",oB="https://api-sr.eu.amplitude.com/sessions/v2/track",oz="https://api-sr.stag2.amplitude.com/sessions/v2/track",oW=/payload.*exceed/i,oG="X-Se
2ssion-Replay-Event-Skipped",oH="amplitude-sr-iframe";(v=$||($={})).GET_SR_PROPS="get-sr-props",v.DEBUG_INFO="debug-info",v.FETCH_REQUEST="fetch-request",v.METADATA="metadata",v.TARGETING_DECISION="targeting-decision",v.REPLAY_GATE_DECISION="replay-gate-decision";var o$=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){if(!this.logger)return function(){};var t,r=this.logger[e];return"function"==typeof r?(null!=(t=r.__rrweb_original__)?t:r).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),oK="medium",oV=function(e,t,r){switch(t){case"light":if("input"!==e)return!1;var n,i,o=r?(i=(n=r).type,n.hasAttribute("data-rr-is-password")?"password":i?i.toLowerCase():null):"";if(!o)return!1;if(["password","hidden","email","tel"].includes(o)||r.autocomplete.startsWith("cc-"))return!0;return!1;case"medium":return"input"===e;case"conservative":return!0;default:return oV(e,oK,r)}},oJ=function(e,t){if(e&&t.urlMaskLevels)try{for(var r,n,i,o=(0,Z.__values)(t.urlMaskLevels),s=o.next();!s.done;s=o.next()){var a=s.value;if(o0(a.match).test(e))return a.maskLevel}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return null!=(i=t.defaultMaskLevel)?i:oK},oY=function(e,t,r,n){var i,o;if(void 0===t&&(t={defaultMaskLevel:oK}),r){if(r.closest("."+oj)||(null!=(i=t.maskSelector)?i:[]).some(function(e){return r.closest(e)}))return!0;if(r.closest("."+oq)||(null!=(o=t.unmaskSelector)?o:[]).some(function(e){return r.closest(e)}))return!1}return oV(e,oJ(n,t),r)},oX=function(e,t,r){return function(n,i){return oY(e,t,i,null==r?void 0:r())?n.replace(/[^\s]/g,"*"):n}},oQ=function(){var e=(0,eO.getGlobalScope)();return(null==e?void 0:e.location)?e.location.href:""},oZ=new Map,o0=function(e){var t=oZ.get(e);if(t)return t;var r="\0TRAIL\0",n="\0MID\0",i="\0DS\0",o="\0ST\0",s="\0QU\0",a=e;a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=a.replace(/\/\*\*$/,r)).replace(/\/\*\*\//g,n)).replace(/\*\*/g,i)).replace(/\*/g,o)).replace(/\?/g,s)).replace(/[.+^${}()|[\]\\]/g,"\\$&")).split(r).join("(/.*)?")).split(n).join("/(.*\\/)?")).split(i).join(".*")).split(o).join(".*")).split(s).join(".");var l=new RegExp("^".concat(a,"$"));return oZ.set(e,l),l},o1=function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){var t;return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t)}))throw Error("ugcFilterRules must be an array of objects with valid globs")},o2=function(e,t){var r,n;try{for(var i=(0,Z.__values)(t),o=i.next();!o.done;o=i.next()){var s=o.value,a=o0(s.selector);if(a.test(e))return e.replace(a,s.replacement)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return e},o3=function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,t,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(e=(0,eO.getGlobalScope)()))return[3,2];return[4,e.navigator.storage.estimate()];case 1:return r=(t=i.sent()).usage,n=t.quota,[2,{totalStorageSize:r?Math.round(r/1024):0,percentOfQuota:r&&n?Math.round((r/n+Number.EPSILON)*1e3)/1e3:0,usageDetails:JSON.stringify(t.usageDetails)}];case 2:return[3,4];case 3:return i.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},o4=function(e){var t=(0,Z.__assign)({},e),r=t.apiKey;return t.apiKey="****".concat(r.substring(r.length-4)),t},o5=function(){return{flushMaxRetries:2,logLevel:x.Warn,loggerProvider:new eB,transportProvider:new oR}},o6=function(e){function t(t,r){var n,i,o,s,a,l,u,c,d,f,g,h,p,v,m=this,y=o5();return(m=e.call(this,(0,Z.__assign)((0,Z.__assign)({transportProvider:y.transportProvider,loggerProvider:new o$(r.loggerProvider||y.loggerProvider)},r),{apiKey:t}))||this).flushMaxRetries=void 0!==r.flushMaxRetries&&r.flushMaxRetries<=y.flushMaxRetries?r.flushMaxRetries:y.flushMaxRetries,m.apiKey=t,m.sampleRate=r.sampleRate||0,m.serverZone=r.serverZone||oL,m.configServerUrl=r.configServerUrl,m.trackServerUrl=r.trackServerUrl,m.shouldInlineStylesheet=r.shouldInlineStylesheet,m.version=r.version,m.performanceConfig=r.performanceConfig||oN,m.storeType=null!=(n=r.storeType)?n:"memory",m.applyBackgroun
2dColorToBlockedElements=null!=(i=r.applyBackgroundColorToBlockedElements)&&i,m.enableUrlChangePolling=null!=(o=r.enableUrlChangePolling)&&o,m.urlChangePollingInterval=null!=(s=r.urlChangePollingInterval)?s:1e3,m.captureDocumentTitle=null!=(a=r.captureDocumentTitle)&&a,void 0!==r.fullSnapshotIntervalMs&&(m.fullSnapshotIntervalMs=r.fullSnapshotIntervalMs),void 0!==r.eagerFullSnapshotSend&&(m.eagerFullSnapshotSend=r.eagerFullSnapshotSend),m.captureFullSnapshotOnFocus=null!=(l=r.captureFullSnapshotOnFocus)&&l,void 0!==r.maxPersistedEventsSizeBytes&&(m.maxPersistedEventsSizeBytes=se(r.maxPersistedEventsSizeBytes,o8,o7,"maxPersistedEventsSizeBytes",m.loggerProvider)),void 0!==r.maxSingleEventSizeBytes&&(m.maxSingleEventSizeBytes=se(r.maxSingleEventSizeBytes,o8,o9,"maxSingleEventSizeBytes",m.loggerProvider)),m.privacyConfig=(0,Z.__assign)((0,Z.__assign)({},null!=(u=r.privacyConfig)?u:{}),{unmaskSelector:Array.from(new Set((0,Z.__spreadArray)([".".concat(oq)],(0,Z.__read)(null!=(d=null==(c=r.privacyConfig)?void 0:c.unmaskSelector)?d:[]),!1)))}),r.interactionConfig&&(m.interactionConfig=r.interactionConfig,m.interactionConfig.ugcFilterRules&&o1(m.interactionConfig.ugcFilterRules)),r.debugMode&&(m.debugMode=r.debugMode),m.useWebWorker=null==(h=null!=(f=r.useWebWorker)?f:null==(g=r.experimental)?void 0:g.useWebWorker)||h,m.enableTransportCompression=null==(p=r.enableTransportCompression)||p,m.sendTimeoutMs=r.sendTimeoutMs,m.captureAdoptedStyleSheets=null==(v=r.captureAdoptedStyleSheets)||v,r.crossOriginIframes&&(m.crossOriginIframes=r.crossOriginIframes),r.flushIntervalConfig?m.flushIntervalConfig=function(e,t){var r,n,i={};if(void 0!==e.minIntervalMs&&(!Number.isFinite(e.minIntervalMs)||e.minIntervalMs<100?(t.warn("flushIntervalConfig.minIntervalMs ".concat(e.minIntervalMs," is below floor ").concat(100,"ms; clamping.")),i.minIntervalMs=100):i.minIntervalMs=e.minIntervalMs),void 0!==e.maxIntervalMs&&(Number.isNaN(e.maxIntervalMs)||e.maxIntervalMs<100?(t.warn("flushIntervalConfig.maxIntervalMs ".concat(e.maxIntervalMs," is below floor ").concat(100,"ms; clamping.")),i.maxIntervalMs=100):i.maxIntervalMs=e.maxIntervalMs),void 0!==i.minIntervalMs||void 0!==i.maxIntervalMs){var o=null!=(r=i.minIntervalMs)?r:500,s=null!=(n=i.maxIntervalMs)?n:1e4;s<o&&(void 0===i.maxIntervalMs?(t.warn("flushIntervalConfig.minIntervalMs (".concat(o,") exceeds the default maxIntervalMs (").concat(1e4,"); raising max to match min.")),i.maxIntervalMs=o):void 0===i.minIntervalMs?(t.warn("flushIntervalConfig.maxIntervalMs (".concat(s,") is below the default minIntervalMs (").concat(500,"); lowering min to match max.")),i.minIntervalMs=s):(t.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}(r.flushIntervalConfig,m.loggerProvider):m.flushIntervalConfig={minIntervalMs:1e3,maxIntervalMs:1e4},m.handleSendEvents=r.handleSendEvents,m.handleFetchConfig=r.handleFetchConfig,m}return(0,Z.__extends)(t,e),t}(eW),o8=1e3,o7=8e6,o9=1e7;function se(e,t,r,n,i){return Number.isFinite(e)?e<t?(i.warn("".concat(n," ").concat(e," is below floor ").concat(t,"; clamping.")),t):e>r?(i.warn("".concat(n," ").concat(e," exceeds ceiling ").concat(r,"; clamping.")),r):e:void i.warn("".concat(n," value is not a finite number (got ").concat(String(e),"); ignoring."))}var st=((m=st||{})[m.DomContentLoaded=0]="DomContentLoaded",m[m.Load=1]="Load",m[m.FullSnapshot=2]="FullSnapshot",m[m.IncrementalSnapshot=3]="IncrementalSnapshot",m[m.Meta=4]="Meta",m[m.Custom=5]="Custom",m[m.Plugin=6]="Plugin",m),sr=((y=sr||{})[y.Mutation=0]="Mutation",y[y.MouseMove=1]="MouseMove",y[y.MouseInteraction=2]="MouseInteraction",y[y.Scroll=3]="Scroll",y[y.ViewportResize=4]="ViewportResize",y[y.Input=5]="Input",y[y.TouchMove=6]="TouchMove",y[y.MediaInteraction=7]="MediaInteraction",y[y.StyleSheetRule=8]="StyleSheetRule",y[y.CanvasMutation=9]="CanvasMutation",y[y.Font=10]="Font",y[y.Log=11]="Log",y[y.Drag=12]="Drag",y[y.StyleDeclaration=13]="StyleDeclaration",y[y.Selection=14]="Selection",y[y.AdoptedStyleSheet=15]="AdoptedStyleSheet",y[y.CustomElement=16]="CustomElement",y),sn=((_=sn||{})[_.MouseUp=0]="MouseUp",_[_.MouseDown=1]="MouseDown",_[_.Click=2]="Click",_[_.ContextMenu=3]="ContextMenu",_[_.DblClick=4]="DblClick",_[_.Focus=5]="Focus",_[_.Blur=6]="Blur",_[_.TouchStart=7]="TouchStart",_[_.TouchMove_Departed=8]="TouchMove_Departed",_[_.TouchEnd=9]="TouchEnd",_[_.TouchCancel=10]="TouchCancel",_),si=((b=si||{})[b.Mouse=0]="Mouse",b[b.Pen=1]="Pen",b[b.Touch=2]="Touch",b),so=((w=so||{})[w["2D"]=0]="2D",w[w.WebGL=1]="WebGL",w[w.WebGL2=2]="WebGL2",w),ss=((S=ss||{})[S.Play=0]="Play",S[S.Pause=1]="Pause",S[S.Seeked=2]="Seeked",S[S.VolumeChange=3]="VolumeChange",S[S.RateChange=4]="RateChange",S),sa=((E=sa||{}).Start="start",E.Pause="pause",E.Resume="resume",E.Resize="resize",E.Finish="finish",E.FullsnapshotRebuilded="fullsnapshot-rebuilded",E.LoadStylesheetStart="load-stylesheet-start",E.LoadStylesheetEnd="load-stylesheet-end",E.SkipStart="skip-start",E.SkipEnd="skip-end",E.MouseInteraction="mouse-interaction",E.EventCast="event-cast",E.CustomEvent="custom-event",E.Flush="flush",E.StateChange="state-change",E.PlayBack="play-back",E.Destroy="destroy",E.SeekStart="seek-start",E.SeekEnd="seek-end",E),sl=((k=sl||{})[k.Document=0]="Document",k[k.DocumentType=1]="DocumentType",k[k.Element=2]="Element",k[k.Text=3]="Text",k[k.CDATA=4]="CDATA",k[k.Comment=5]="Comment",k),su=function(e,t){var r=document.createDocumentFragment(),n=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),0!==(e=e.filter(function(e){try{r.querySelector(e)}catch(r){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invali
2d')),!1}return!0})).length)return e};return e.blockSelector=n(e.blockSelector),e.maskSelector=n(e.maskSelector),e.unmaskSelector=n(e.unmaskSelector),e},sc=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,r,n,i,o,s;return(0,Z.__awaiter)(this,void 0,void 0,function(){var a,l,u,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k=this;return(0,Z.__generator)(this,function(I){switch(I.label){case 0:(a=(0,Z.__assign)({},this.localConfig)).optOut=this.localConfig.optOut,a.captureEnabled=!0,I.label=1;case 1:return I.trys.push([1,3,,4]),[4,new Promise(function(e,t){k.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:1500},function(r,n){if(k.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(n,":"),JSON.stringify(r,null,2)),!r)return void t(Error("No remote config received"));var i,o=r.sr_sampling_config,s=r.sr_privacy_config,u=r.sr_targeting_config,c=null==(i=a.interactionConfig)?void 0:i.ugcFilterRules;a.interactionConfig=r.sr_interaction_config,a.interactionConfig&&c&&(a.interactionConfig.ugcFilterRules=c),a.loggingConfig=r.sr_logging_config,(o||s||u)&&(l={},o&&(l.sr_sampling_config=o),s&&(l.sr_privacy_config=s),u&&(l.sr_targeting_config=u)),e()})})];case 2:return I.sent(),[3,4];case 3:return u=I.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",u),a.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:void 0}];case 4:if(!l)return[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:l}];if(c=l.sr_sampling_config,d=l.sr_privacy_config,f=l.sr_targeting_config,c&&Object.keys(c).length>0?(Object.prototype.hasOwnProperty.call(c,"capture_enabled")?a.captureEnabled=c.capture_enabled:a.captureEnabled=!1,Object.prototype.hasOwnProperty.call(c,"sample_rate")&&(a.sampleRate=c.sample_rate),Object.prototype.hasOwnProperty.call(c,"min_session_duration_ms")&&(a.minSessionDurationMs=this.sanitizeMinSessionDurationMs(c.min_session_duration_ms))):(a.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){g=null!=(e=a.privacyConfig)?e:{},h={defaultMaskLevel:null!=(r=null!=(t=d.defaultMaskLevel)?t:g.defaultMaskLevel)?r:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:(0,Z.__spreadArray)([],(0,Z.__read)(new Set((0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(null!=(n=g.maskAttributes)?n:[]),!1),(0,Z.__read)(null!=(i=d.maskAttributes)?i:[]),!1))),!1),urlMaskLevels:(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(null!=(o=d.urlMaskLevels)?o:[]),!1),(0,Z.__read)(null!=(s=g.urlMaskLevels)?s:[]),!1)},p=function(e){var t,r,n,i,o,s,a,l,u,c={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var d=(0,Z.__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&&(r=d.return)&&r.call(d)}finally{if(t)throw t.error}}try{for(var h=(0,Z.__values)(null!=(l=e.maskSelector)?l:[]),p=h.next();!p.done;p=h.next()){var g=p.value;c[g]="mask"}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}try{for(var v=(0,Z.__values)(null!=(u=e.unmaskSelector)?u:[]),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},v=(0,Z.__assign)((0,Z.__assign)({},p(g)),p(d));try{for(y=(m=(0,Z.__values)(Object.entries(v))).next();!y.done;y=m.next())b=(_=(0,Z.__read)(y.value,2))[0],w=_[1],"mask"===w?h.maskSelector.push(b):"block"===w?h.blockSelector.push(b):"unmask"===w&&h.unmaskSelector.push(b)}catch(e){S={error:e}}finally{try{y&&!y.done&&(E=m.return)&&E.call(m)}finally{if(S)throw S.error}}a.privacyConfig=su(h,this.localConfig.loggerProvider)}return f&&Object.keys(f).length>0&&(a.targetingConfig=f),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:o4(a)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:l}]}})})},e.prototype.sanitizeMinSessionDurationMs=function(e){return"number"==typeof e&&Number.isFinite(e)?e<0?void this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring.")):e>sd?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(sd,"ms ceiling; clamping.")),sd):e:void this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."))},e}(),sd=6e4;function sf(e,t){return t||("STAGING"===e?oz:"EU"===e?oB:oU)}function sg(e){if(e.type!==st.IncrementalSnapshot)return!1;var t=e.data;return t.source===sr.Mutation&&!t.isAttachIframe}var sh=function(){function e(e,t,r,n,i){var o,s=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e.type,r=e.timestamp,n=e.delay,i=e.data;return null!=n?JSON.stringify({type:t,timestamp:r,delay:n,data:i}):JSON.stringify({type:t,timestamp:r,data:i})},this.addCompressedEventToManager=function(e,t){var r,n=new Blob([e]).size;n>(null!=(r=s.config.maxSingleEventSizeBytes)?r:9e6)?s.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(n/1024)," KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.")):s.eventsManager&&s.deviceId&&s.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:s.deviceId})},this.addCompressedEvent=function(e,t){if(s.worker)try{s.worker.postMessage({event:e,sessionId:t})}catch(r){"DataCloneError"===r.name?s.worker.postMessage(JSON.stringify({event:e,sessionId:t})):s.config.loggerProvider.warn("Unexpected error while posting message to worker:",r)}else{var r=s.compressEvent(e);s.addCompressedEventToManager(r,t)}},this.flushQueue=function(){var e;
2for(s.pendingQueue.length>0&&(e=s.taskQueue).push.apply(e,(0,Z.__spreadArray)([],(0,Z.__read)(s.mergeMutationTasks(s.pendingQueue.splice(0))),!1));s.taskQueue.length>0;){var t=s.taskQueue.shift();if(t){var r=t.event,n=t.sessionId,i=s.compressEvent(r);s.addCompressedEventToManager(i,n)}}s.isProcessing=!1},this.terminate=function(){var e;null==(e=s.worker)||e.terminate()};var a=(0,eO.getGlobalScope)();if(this.canUseIdleCallback=a&&"requestIdleCallback"in a,this.eventsManager=e,this.config=t,this.deviceId=r,this.timeout=(null==(o=t.performanceConfig)?void 0:o.timeout)||2e3,this.onFullSnapshotProcessed=i,n){t.loggerProvider.log("Enabling web worker for compression");try{var l=new Blob([n],{type:"application/javascript"}),u=URL.createObjectURL(l),c=new Worker(u);c.onerror=function(e){e.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),c.terminate(),s.worker=void 0},c.onmessage=function(e){var t=e.data,r=t.compressedEvent,n=t.sessionId;s.addCompressedEventToManager(r,n)},this.worker=c}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){if(e.type===st.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var r,n,i,o,s=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(this.taskQueue.splice(0)),!1),(0,Z.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var a=(0,Z.__values)(s),l=a.next();!l.done;l=a.next()){var u=l.value,c=this.compressEvent(u.event);this.addCompressedEventToManager(c,u.sessionId)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,t),null==(i=this.onFullSnapshotProcessed)||i.call(this);return}this.canUseIdleCallback&&(null==(o=this.config.performanceConfig)?void 0:o.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.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){var t,r=this;for(this.pendingQueue.length>0&&(t=this.taskQueue).push.apply(t,(0,Z.__spreadArray)([],(0,Z.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var n=this.taskQueue.shift();if(n){var i=n.event,o=n.sessionId;this.addCompressedEvent(i,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(e){r.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e.prototype.mergeMutationTasks=function(e){if((null==(n=this.config.performanceConfig)?void 0:n.mergeMutations)===!1||e.length<=1)return e;for(var t,r,n,i=[],o=0;o<e.length;){for(var s=e[o].sessionId,a=o+1;a<e.length&&e[a].sessionId===s;)a++;var l=function(e){if(e.length<=1)return e;for(var t=[],r=0;r<e.length;){if(!sg(e[r])){t.push(e[r]),r++;continue}for(var n=r+1;n<e.length&&sg(e[n]);)n++;t.push(n>r+1?function(e){var t,r,n,i,o=e[0],s=new Map,a=new Map,l=new Map,u=new Map,c=new Map;e.forEach(function(e,t){var r,n,i,o,d=e.data;try{for(var f=(0,Z.__values)(d.adds),g=f.next();!g.done;g=f.next()){var h=g.value;s.has(h.node.id)||s.set(h.node.id,t),a.set(h.node.id,t),c.set(h.node.id,h.parentId)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}try{for(var p=(0,Z.__values)(d.removes),v=p.next();!v.done;v=p.next()){var m=v.value;l.has(m.id)||l.set(m.id,t),u.set(m.id,t)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}});var d=new Set,f=new Set;try{for(var g=(0,Z.__values)(s),h=g.next();!h.done;h=g.next()){var p=(0,Z.__read)(h.value,2),v=p[0],m=p[1],y=l.get(v);if(void 0!==y){var _=a.get(v),b=u.get(v);!(_>=b)&&(m<y?d.add(v):y<m&&f.add(v))}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=g.return)&&r.call(g)}finally{if(t)throw t.error}}var w=new Set;if(d.size>0||f.size>0)for(var S=!0;S;){S=!1;try{for(var E=(n=void 0,(0,Z.__values)(c)),k=E.next();!k.done;k=E.next()){var I=(0,Z.__read)(k.value,2),T=I[0],C=I[1];if(!d.has(T)&&!f.has(T)&&!w.has(T)&&(d.has(C)||f.has(C)||w.has(C))){var P=l.get(T),x=s.get(T);void 0!==P&&void 0!==x&&P<x?f.add(T):void 0!==P&&void 0!==x&&P===x?w.add(T):d.add(T),S=!0}}}catch(e){n={error:e}}finally{try{k&&!k.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}}var O=d.size>0||f.size>0||w.size>0,A=[];e.forEach(function(e,t){var r,n;try{for(var i=(0,Z.__values)(e.data.removes),o=i.next();!o.done;o=i.next()){var a=o.value;!(d.has(a.id)||f.has(a.id)&&t>=s.get(a.id))&&(w.has(a.id)&&(d.has(a.parentId)||f.has(a.parentId)||w.has(a.parentId))||A.push(a))}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}});var R=e.flatMap(function(e){return e.data.adds}),M=e.flatMap(function(e){return e.data.texts}),D=e.flatMap(function(e){return e.data.attributes}),L=O?D.filter(function(e){return!d.has(e.id)&&!f.has(e.id)&&!w.has(e.id)}):D,N={source:sr.Mutation,removes:A,adds:O?R.filter(function(e){return!d.has(e.node.id)&&!f.has(e.node.id)&&!w.has(e.node.id)}):R,texts:O?M.filter(function(e){return!d.has(e.id)&&!f.has(e.id)&&!w.has(e.id)}):M,attributes:function(e){var t,r,n=new Map;if(e.forEach(function(e,t){if(e.attributes&&"style"in e.attributes){var r=n.get(e.id);r?r.push(t):n.set(e.id,[t])}}),0===n.size)return e;var i=function(t){return e[t].attributes.style},o=new Set,s=new Map;try{for(var a=(0,Z.__values)(n.values()),l=a.next();!l.done;l=a.next()){var u=l.value;!function(e){if(1!==e.length){var t=-1;e.forEach(function(e,r){var n;("object"!=typeof(n=i(e))||null===n)&&(t=r)});var r=[];
2if(e.forEach(function(e,n){n!==t&&(o.add(e),n>t&&r.push(e))}),r.length>0){var n=r[r.length-1],a=function(e){var t,r,n,i,o={};try{for(var s=(0,Z.__values)(e),a=s.next();!a.done;a=s.next()){var l=a.value;try{for(var u=(n=void 0,(0,Z.__values)(Object.keys(l))),c=u.next();!c.done;c=u.next()){var d=c.value;o[d]=l[d]}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return o}(r.map(function(e){return i(e)}));o.delete(n),s.set(n,a)}}}(u)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}if(0===o.size&&0===s.size)return e;var c=[];return e.forEach(function(e,t){var r=s.get(t);if(void 0!==r)return void c.push((0,Z.__assign)((0,Z.__assign)({},e),{attributes:(0,Z.__assign)((0,Z.__assign)({},e.attributes),{style:r})}));if(!o.has(t))return void c.push(e);var n=(0,Z.__assign)({},e.attributes);delete n.style,Object.keys(n).length>0&&c.push((0,Z.__assign)((0,Z.__assign)({},e),{attributes:n}))}),c}(L)};return(0,Z.__assign)((0,Z.__assign)({},o),{data:N})}(e.slice(r,n)):e[r]),r=n}return t}(e.slice(o,a).map(function(e){return e.event}));try{for(var u=(t=void 0,(0,Z.__values)(l)),c=u.next();!c.done;c=u.next()){var d=c.value;i.push({event:d,sessionId:s})}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}o=a}return i},e}(),sp="Session replay event batch rejected due to exceeded retry count",sv="Failed to store session replay events in IndexedDB",sm="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",sy="1.48.1",s_=function(){function e(e){var t=e.trackServerUrl,r=e.loggerProvider,n=e.payloadBatcher,i=e.workerScript,o=e.enableTransportCompression,s=e.sendTimeoutMs,a=e.handleSendEvents,l=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.timedOutWorkerRequests=new Map,this.flushPauseUntilMs=0,this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,this.mergeLogFiredThisPause=!1,this.killedSessions=new Set,this.loggerProvider=r,this.payloadBatcher=n||function(e){return e},this.trackServerUrl=t,this.enableTransportCompression=null==o||o,this.sendTimeoutMs=null!=s?s:1e4,this.handleSendEvents=a,i)try{var u=new Blob([i],{type:"application/javascript"}),c=URL.createObjectURL(u),d=new Worker(c);d.onerror=function(e){var t,n;e.preventDefault(),r.error("Track destination worker failed, falling back to main-thread sending: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),d.terminate(),l.worker=void 0;try{for(var i=(0,Z.__values)(l.pendingWorkerRequests),o=i.next();!o.done;o=i.next()){var s=(0,Z.__read)(o.value,2)[1];s.timeout&&clearTimeout(s.timeout),r.warn("Session replay event send failed due to worker crash: ".concat(e.message)),s.resolve()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}l.pendingWorkerRequests.clear(),l.timedOutWorkerRequests.clear()},d.onmessage=function(e){var t=e.data;if("log"===t.type)r.log(t.message);else if("warn"===t.type)r.warn(t.message);else if("payload_too_large"===t.type){var n=l.pendingWorkerRequests.get(t.id);if(n)n.timeout&&clearTimeout(n.timeout),l.handlePayloadTooLargeResponse(n.context,t.isWaf),n.resolve(),l.pendingWorkerRequests.delete(t.id);else{var i=l.timedOutWorkerRequests.get(t.id);i&&(l.timedOutWorkerRequests.delete(t.id),l.handlePayloadTooLargeResponse(i,t.isWaf))}}else if("complete"===t.type){var o=l.pendingWorkerRequests.get(t.id);if(o)o.timeout&&clearTimeout(o.timeout),void 0!==t.skipCode&&l.applyServerDirective(o.context.sessionId,t.skipCode),l.completeRequest({context:o.context}),o.resolve(),l.pendingWorkerRequests.delete(t.id);else{var i=l.timedOutWorkerRequests.get(t.id);i&&(l.timedOutWorkerRequests.delete(t.id),void 0!==t.skipCode&&l.applyServerDirective(i.sessionId,t.skipCode),l.completeRequest({context:i}))}}else"fetch-request"===t.type&&l.handleDelegatedFetch(d,t).catch(function(e){r.warn("Failed to handle delegated session replay fetch:",e)})},this.worker=d}catch(e){r.error("Failed to create track destination worker, falling back to main-thread sending:",e)}}return e.prototype.sendEventsList=function(e){this.addToQueue((0,Z.__assign)((0,Z.__assign)({},e),{attempts:0,timeout:0}))},e.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},e.prototype.sendBeacon=function(e){var t,r,n=this,i=e.events,o=e.sessionId,s=e.deviceId,a=e.apiKey,l=e.serverZone,u=function(e){return new Blob([e]).size},c=i,d=JSON.stringify({version:2,events:c});if(u(d)>65536){for(var f=0,g=c.length;f<g;){var h=Math.floor((f+g+1)/2);65536>=u(JSON.stringify({version:2,events:c.slice(0,h)}))?f=h:g=h-1}d=JSON.stringify({version:2,events:c=c.slice(0,f)}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(i.length," to ").concat(c.length," events"))}if(0!==c.length){if(this.handleSendEvents){var p=new URLSearchParams({device_id:s,session_id:String(o),type:"replay"}),v="".concat(sf(l,this.trackServerUrl),"?").concat(p.toString());this.loggerProvider.debug("Routing session replay exit batch (".concat(c.length," events) through custom transport for session id ").concat(o,"."));try{this.handleSendEvents({url:v,method:"POST",headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(a)},body:d,keepalive:!0}
2).catch(function(e){n.loggerProvider.warn("Custom transport failed to send session replay exit batch:",e)})}catch(e){this.loggerProvider.warn("Custom transport threw while sending session replay exit batch:",e)}return}var m=new URLSearchParams({device_id:s,session_id:String(o),type:"replay",api_key:a}),y="".concat(sf(l,this.trackServerUrl),"?").concat(m.toString()),_=(0,eO.getGlobalScope)();try{var b=new Blob([d],{type:"application/json"}),w=null==(r=null==(t=null==_?void 0:_.navigator)?void 0:t.sendBeacon)?void 0:r.call(t,y,b);!1===w&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch(e){}}},e.prototype.addToQueue=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.filter(function(t){return e.killedSessions.has(t.sessionId)?(e.completeRequest({context:t,err:sm}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:sp}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),e.schedule(0)})},e.prototype.schedule=function(e){var t=this;if(!this.scheduled){var r=this.flushPauseUntilMs-Date.now(),n=r>e?r:e;r>0&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},n)}},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,t=this.mergeQueueAfterThrottle(t)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,t=this.mergeDrainBacklog(t)),a.label=1;case 1:a.trys.push([1,6,7,8]),n=(r=(0,Z.__values)(t)).next(),a.label=2;case 2:if(n.done)return[3,5];return i=n.value,[4,this.send(i,e)];case 3:a.sent(),a.label=4;case 4:return n=r.next(),[3,2];case 5:return[3,8];case 6:return o={error:a.sent()},[3,8];case 7:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}return[7];case 8:return[2]}})})},e.prototype.mergeQueueAfterThrottle=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(t.length," request(s)"))),t},e.prototype.mergeDrainBacklog=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&this.loggerProvider.log("Session replay coalesced ".concat(e.length," persisted page-load backlog batches into ").concat(t.length," request(s)")),t},e.prototype.coalesceByIdentity=function(e){var t,r,n,i,o,s,a,l,u,c,d,f=this;if(e.length<=1)return e;var g=new Map;try{for(var h=(0,Z.__values)(e),p=h.next();!p.done;p=h.next()){var v=p.value,m=[v.sessionId,null!=(o=v.deviceId)?o:"",null!=(s=v.apiKey)?s:"",v.type,null!=(a=v.serverZone)?a:"",v.sampleRate,null!=(u=null==(l=v.version)?void 0:l.type)?u:"",null!=(d=null==(c=v.version)?void 0:c.version)?d:""].join("|"),y=g.get(m);y?y.push(v):g.set(m,[v])}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}var _=[];try{for(var b=(0,Z.__values)(g.values()),w=b.next();!w.done;w=b.next()){var S=w.value;!function(e){if(1===e.length)return _.push(e[0]);var t,r,n=null,i=0,o=function(){n&&_.push(n),n=null,i=0};try{for(var s=(t=void 0,(0,Z.__values)(e)),a=s.next();!a.done;a=s.next()){var l=a.value;!function(e){var t=e.events.reduce(function(e,t){return e+new Blob([t]).size},0);if(null===n)return n=(0,Z.__assign)((0,Z.__assign)({},e),{events:(0,Z.__spreadArray)([],(0,Z.__read)(e.events),!1),attempts:0}),i=t;if(i+t>4e6)return o(),n=(0,Z.__assign)((0,Z.__assign)({},e),{events:(0,Z.__spreadArray)([],(0,Z.__read)(e.events),!1),attempts:0}),i=t;var r=n.onComplete,s=e.onComplete;n.events=n.events.concat(e.events),i+=t,n.onComplete=function(){return(0,Z.__awaiter)(f,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,Promise.allSettled([r(),s()])];case 1:return e.sent(),[2]}})})}}(l)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}o()}(S)}}catch(e){n={error:e}}finally{try{w&&!w.done&&(i=b.return)&&i.call(b)}finally{if(n)throw n.error}}return _},e.prototype.send=function(e,t){return void 0===t&&(t=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i,o;return(0,Z.__generator)(this,function(s){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:sm})]:(r=e.apiKey)?(n=e.deviceId)?0===(i=this.payloadBatcher({version:1,events:e.events})).events.length?(this.completeRequest({context:e}),[2]):(o=this.worker)?[2,this.sendViaWorker(o,e,i,t)]:[2,this.sendOnMainThread(r,n,e,i,t)]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})]})})},e.prototype.sendViaWorker=function(e,t,r,n){return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o=this;return(0,Z.__generator)(this,function(s){return i="".concat(++this.sendIdCounter),[2,new Promise(function(s){var a,l=o.sendTimeoutMs>0?setTimeout(function(){var e=o.pendingWorkerRequests.get(i);
2e&&(o.pendingWorkerRequests.delete(i),o.rememberTimedOutRequest(i,e.context),o.loggerProvider.warn("Session replay worker send timed out after ".concat(o.sendTimeoutMs,"ms; leaving events for retry")),e.resolve())},o.sendTimeoutMs):void 0;o.pendingWorkerRequests.set(i,{context:t,resolve:s,timeout:l}),e.postMessage({type:"send",id:i,payload:r,useRetry:n,useCustomTransport:!!o.handleSendEvents,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:null!=(a=t.flushMaxRetries)?a:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:oQ(),sdkVersion:sy,enableTransportCompression:o.enableTransportCompression,sendTimeoutMs:o.sendTimeoutMs}})})]})})},e.prototype.rememberTimedOutRequest=function(e,t){var r,n;if(this.timedOutWorkerRequests.set(e,t),this.timedOutWorkerRequests.size>256)try{for(var i=(0,Z.__values)(this.timedOutWorkerRequests.keys()),o=i.next();!o.done;o=i.next()){var s=o.value;this.timedOutWorkerRequests.delete(s);break}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},e.prototype.handleDelegatedFetch=function(e,t){var r,n,i;return(0,Z.__awaiter)(this,void 0,void 0,function(){var o,s,a,l,u,c,d,f,g,h,p;return(0,Z.__generator)(this,function(v){switch(v.label){case 0:o=t.requestId,s=t.url,a=t.method,l=t.headers,u=t.body,c=t.keepalive,v.label=1;case 1:if(v.trys.push([1,10,,11]),d=void 0,!this.handleSendEvents)return[3,3];return[4,this.handleSendEvents({url:s,method:a,headers:l,body:u,keepalive:c})];case 2:return d=v.sent(),[3,5];case 3:return this.loggerProvider.warn("Delegated session replay fetch received without a custom transport configured; falling back to built-in fetch."),[4,fetch(s,{method:a,headers:l,body:u,keepalive:c})];case 4:d=v.sent(),v.label=5;case 5:if(f=d.status,g=null,h="",f>=200&&f<300&&(g=null!=(i=null==(n=null==(r=d.headers)?void 0:r.get)?void 0:n.call(r,oG))?i:null),413!==f)return[3,9];v.label=6;case 6:return v.trys.push([6,8,,9]),[4,d.text()];case 7:return h=v.sent(),[3,9];case 8:return v.sent(),[3,9];case 9:return this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") returned status ").concat(f,".")),e.postMessage({type:"fetch-response",requestId:o,status:f,skipHeader:g,body:h}),[3,11];case 10:return p=v.sent(),this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") failed:"),p),e.postMessage({type:"fetch-response",requestId:o,status:0,skipHeader:null,body:String(p),error:!0}),[3,11];case 11:return[2]}})})},e.prototype.sendOnMainThread=function(e,t,r,n,i){var o,s,a,l,u,c,d;return(0,Z.__awaiter)(this,void 0,void 0,function(){var f,g,h,p,v,m,y,_,b,w,S,E,k,I,T,C,P,x,O,A,R,M;return(0,Z.__generator)(this,function(D){switch(D.label){case 0:f=oQ(),g=sy,h=r.sampleRate,p=new URLSearchParams({device_id:t,session_id:"".concat(r.sessionId),type:"".concat(r.type)}),v="".concat(null!=(s=null==(o=r.version)?void 0:o.type)?s:"standalone","/").concat(null!=(l=null==(a=r.version)?void 0:a.version)?l:g),D.label=1;case 1:if(D.trys.push([1,19,,23]),m=JSON.stringify(n),y=(0,eO.getGlobalScope)(),!(this.enableTransportCompression&&y&&"CompressionStream"in y))return[3,3];return[4,function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r,n,i,o,s,a,l,u,c,d,f,g,h=this;return(0,Z.__generator)(this,function(p){switch(p.label){case 0:return p.trys.push([0,4,,5]),n=(r=new t.CompressionStream("gzip")).writable.getWriter(),i=r.readable.getReader(),o=[],s=(0,Z.__awaiter)(h,void 0,void 0,function(){var e,t,r;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return[4,i.read()];case 1:if(t=(e=n.sent()).done,r=e.value,t)return[3,3];o.push(r),n.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,n.write(new TextEncoder().encode(e))];case 1:return p.sent(),[4,n.close()];case 2:return p.sent(),[4,s];case 3:p.sent(),a=new Uint8Array(o.reduce(function(e,t){return e+t.length},0)),l=0;try{for(c=(u=(0,Z.__values)(o)).next();!c.done;c=u.next())d=c.value,a.set(d,l),l+=d.length}catch(e){f={error:e}}finally{try{c&&!c.done&&(g=u.return)&&g.call(u)}finally{if(f)throw f.error}}return[2,a];case 4:return p.sent(),[2,null];case 5:return[2]}})})}(m,y)];case 2:return b=D.sent(),[3,4];case 3:b=null,D.label=4;case 4:if(w=(_=b)?_.byteLength:new Blob([m]).size,S=new AbortController,T={headers:E=(0,Z.__assign)({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":g,"X-Client-Library":v,"X-Client-Url":f.substring(0,1e3),"X-Client-Sample-Rate":"".concat(h),"X-Sampling-Hash-Alg":"xxhash32"},_?{"Content-Encoding":"gzip"}:{}),body:k=null!=_?_:m,method:"POST",keepalive:I=w<=65536,signal:S.signal},C="".concat(sf(r.serverZone,this.trackServerUrl),"?").concat(p.toString()),0===n.events.length)return this.completeRequest({context:r}),[2];P=this.sendTimeoutMs>0?setTimeout(function(){S.abort()},this.sendTimeoutMs):void 0,x=void 0,D.label=5;case 5:var L,N;if(D.trys.push([5,,10,11]),!this.handleSendEvents)return[3,7];return[4,(L=this.handleSendEvents({url:C,method:"POST",headers:E,body:k,keepalive:I}),N=S.signal,new Promise(function(e,t){var r=function(){var e=Error("Custom session replay transport aborted by send timeout");e.name="AbortError",t(e)};N.addEventListener("abort",r,{once:!0}),L.then(function(t){N.removeEventListener("abort",r),e(t)},function(e){N.removeEventListener("abort",r),t(e)})}))];case 6:return O=D.sent(),[3,9];case 7:return[4,fetch(C,T)];case 8:O=D.sent(),D.label=9;case 9:return x=O,[3,11];case 10:return P&&clearTimeout(P),[7];case 11:if(null===x)return this.completeRequest({context:r,err:"Unexpected error occurred"}),[2];if(x.status>=200&&x.status<300&&(A=null!=(d=null==(c=null==(u=x.headers)?void 0:u.get)?void 0:c.call(u,oG))?d:null,this.applyServerDirective(r.sessionId,A)),i)return[3,12];R="";try{R=JSON.stringify(x.body,null,2)}catch(e){}return this.completeRequest({context:r,success:"".concat(x.status,": ").concat(R)}),[3,18];
2case 12:if(R="",413!==x.status)return[3,16];D.label=13;case 13:return D.trys.push([13,15,,16]),[4,x.text()];case 14:return R=D.sent(),[3,16];case 15:return D.sent(),[3,16];case 16:return[4,this.handleReponse(x.status,r,R)];case 17:D.sent(),D.label=18;case 18:return[3,23];case 19:if(!((M=D.sent())&&"object"==typeof M&&"AbortError"===M.name&&i))return[3,21];return[4,this.handleOtherResponse(r)];case 20:return D.sent(),[3,22];case 21:this.completeRequest({context:r,err:M}),D.label=22;case 22:return[3,23];case 23:return[2]}})})},e.prototype.handleReponse=function(e,t,r){return void 0===r&&(r=""),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(n){switch(n.label){case 0:switch(new t0().buildStatus(e)){case M.Success:return[3,1];case M.Failed:case M.Timeout:case M.RateLimit:return[3,2];case M.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:case 6:return n.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,oW.test(r)),[3,8];case 5:if(499!==e)return[3,7];return[4,this.handleOtherResponse(t)];case 7:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),n.label=8;case 8:return[2]}})})},e.prototype.handlePayloadTooLargeResponse=function(e,t){var r=t?"WAF (compressed payload too large)":"server (event too large)",n=Math.round(e.events.reduce(function(e,t){return e+t.length},0)/1024);if(!t)return void this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(r," rejected payload (").concat(e.events.length," events, ").concat(n," KB) — not retrying non-WAF 413")});if(1===e.events.length)return void this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(n," KB, 1 event) rejected by ").concat(r," — cannot split further")});this.loggerProvider.warn("Session replay event batch rejected by ".concat(r," (").concat(e.events.length," events, ").concat(n," KB total) — splitting and retrying")),e.onComplete();var i=function(){return Promise.resolve()},o=Math.floor(e.events.length/2);this.sendEventsList((0,Z.__assign)((0,Z.__assign)({},e),{events:e.events.slice(0,o),onComplete:i})),this.sendEventsList((0,Z.__assign)((0,Z.__assign)({},e),{events:e.events.slice(o),onComplete:i}))},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,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0))return this.completeRequest({context:e,err:sp}),[2];return[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return r.sent(),[4,this.send(e,!0)];case 2:return r.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,r=e.err,n=e.success;t.onComplete(),r?this.loggerProvider.warn(r):n&&this.loggerProvider.log(n)},e.prototype.applyServerDirective=function(e,t){if(null===t){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if("429"===t){var r=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+6e4,r||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60,"s"));return}("4005"===t||"4004"===t)&&this.killSession(e,t)},e.prototype.killSession=function(e,t){if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>256)try{for(var r,n,i,o,s=(0,Z.__values)(this.killedSessions),a=s.next();!a.done;a=s.next()){var l=a.value;this.killedSessions.delete(l);break}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(t,"; remaining events will be dropped"));var u=[];try{for(var c=(0,Z.__values)(this.queue),d=c.next();!d.done;d=c.next()){var f=d.value;f.sessionId===e?this.completeRequest({context:f,err:sm}):u.push(f)}}catch(e){i={error:e}}
2finally{try{d&&!d.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}this.queue=u}},e}(),sb=e.i(610399),sw=function(){function e(e){var t,r,n,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=6e6,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var r=i.getStringSize(t);return i.getEventsArraySize(e)+r>=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!=(r=e.maxInterval)?r:this.maxInterval,this.maxPersistedEventsSize=null!=(n=e.maxPersistedEventsSize)?n:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){for(var t=0,r=0;r<e.length;r++){var n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n>=55296&&n<=56319){var i=r+1<e.length?e.charCodeAt(r+1):NaN;i>=56320&&i<=57343?(t+=4,r++):t+=3}else t+=3}return t},e.prototype.getEventsArraySize=function(e){var t,r,n=0;try{for(var i=(0,Z.__values)(e),o=i.next();!o.done;o=i.next()){var s=o.value;n+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n+(2+Math.max(0,e.length-1)+2*e.length)},e}(),sS=function(e,t,r){"object"==typeof r&&null!==r&&"AbortError"===r.name?e.debug(t):e.warn(t)},sE="sessionCurrentSequence",sk="sequencesToSend";function sI(e,t,r){var n=setTimeout(r,t);return e.then(function(){return clearTimeout(n)},function(){return clearTimeout(n)}),function(){return clearTimeout(n)}}var sT=function(e){var t,r;return e.objectStoreNames.contains(sE)||(r=e.createObjectStore(sE,{keyPath:"sessionId"})),e.objectStoreNames.contains(sk)||(t=e.createObjectStore(sk,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:r}},sC=function(e){function t(t){var r,n=this;return(n=e.call(this,t)||this).consecutiveFailures=0,n.hasTriggeredFallback=!1,n.emptyFilteredCount=0,n.getSequencesToSend=function(){return(0,Z.__awaiter)(n,void 0,void 0,function(){var e,t,r,n,i,o,s,a,l,u,c=this;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:e=!1,t=!1,d.label=1;case 1:return d.trys.push([1,9,,10]),r=[],(n=this.db.transaction("sequencesToSend","readwrite")).done.catch(function(r){e||t||(sS(c.loggerProvider,"".concat(sv,": ").concat(r),r),c.recordFailure())}),i=sI(n.done,5e3,function(){e||t||(t=!0,sS(c.loggerProvider,"".concat(sv,": transaction timed out")),c.recordFailure())}),[4,n.store.openCursor()];case 2:o=d.sent(),d.label=3;case 3:if(!o)return[3,8];if(a=(s=o.value).sessionId,0!==(l=s.events).length)return[3,5];return this.maybeLogEmptyFiltered("getSequencesToSend"),[4,o.delete()];case 4:return d.sent(),[3,6];case 5:r.push({events:l,sequenceId:o.key,sessionId:a}),d.label=6;case 6:return[4,o.continue()];case 7:return o=d.sent(),[3,3];case 8:return this.recordSuccess(),i(),[2,r];case 9:return u=d.sent(),t||(e=!0,sS(this.loggerProvider,"".concat(sv,": ").concat(u),u),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},n.storeCurrentSequence=function(e){return(0,Z.__awaiter)(n,void 0,void 0,function(){var t,r,n,i,o,s,a,l,u=this;return(0,Z.__generator)(this,function(c){switch(c.label){case 0:t=!1,r=!1,c.label=1;case 1:return c.trys.push([1,5,,6]),(n=this.db.transaction([sE,sk],"readwrite")).done.catch(function(e){t||r||(sS(u.loggerProvider,"".concat(sv,": ").concat(e),e),u.recordFailure())}),i=sI(n.done,5e3,function(){t||r||(r=!0,sS(u.loggerProvider,"".concat(sv,": transaction timed out")),u.recordFailure())}),[4,n.objectStore(sE).get(e)];case 2:if(!(o=c.sent())||o.tabId&&o.tabId!==this.tabId)return i(),[2,void 0];if(0===o.events.length)return this.maybeLogEmptyFiltered("storeCurrentSequence"),i(),[2,void 0];return[4,n.objectStore(sk).put({sessionId:e,events:o.events,tabId:this.tabId})];case 3:return s=c.sent(),[4,n.objectStore(sE).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return c.sent(),this.recordSuccess(),i(),o.tabId,a=(0,Z.__rest)(o,["tabId"]),[2,(0,Z.__assign)((0,Z.__assign)({},a),{sessionId:e,sequenceId:s})];case 5:return l=c.sent(),r||(t=!0,sS(this.loggerProvider,"".concat(sv,": ").concat(l),l),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},n.addEventToCurrentSequence=function(e,t){return(0,Z.__awaiter)(n,void 0,void 0,function(){var r,n,i,o,s,a,l,u,c,d=this;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:r=!1,n=!1,f.label=1;case 1:return f.trys.push([1,15,,16]),(i=this.db.transaction([sE,sk],"readwrite")).done.catch(function(e){r||n||(sS(d.loggerProvider,"".concat(sv,": ").concat(e),e),d.recordFailure())}),o=sI(i.done,5e3,function(){r||n||(n=!0,sS(d.loggerProvider,"".concat(sv,": transaction timed out")),d.recordFailure())}),[4,i.objectStore(sE).get(e)];case 2:if(!((null==(s=f.sent())?void 0:s.tabId)&&s.tabId!==this.tabId))return[3,6];if(!(s.events.length>0))return[3,4];return[4,i.objectStore(sk).put({sessionId:e,events:s.events,tabId:s.tabId})];case 3:f.sent(),f.label=4;case 4:case 12:return[4,i.objectStore(sE).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:case 7:case 9:case 11:return f.sent(),this.recordSuccess(),o(),[2,void 0];case 6:if(a=s)return[3,8];return[4,i.objectStore(sE).put({sessionId:e,events:[t],tabId:this.tabId})];case 8:if(this.shouldSplitEventsList(a.events,t))return[3,10];return[4,i.objectStore(sE).put({sessionId:e,events:a.events.concat(t),tabId:this.tabId})];case 10:if(0!==(l=a.events).length)return[3,12];return this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,i.objectStore(sE).put({sessionId:e,events:[t],tabId:this.tabId})];case 13:return f.sent(),[4,i.objectStore(sk).put({sessionId:e,events:l,tabId:this.tabId})];case 14:return u=f.sent(),this.recordSuccess(),o(),[2,{events:l,sessionId:e,sequenceId:u}];case 15:return c=f.sent(),n||(r=!0,sS(this.loggerProvider,"".concat(sv,": ").concat(c),c),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},n.storeSendingEvents=function(e,t){return(0,Z.__awaiter)(n,void 0,void 0,function(){var r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.db.put(sk,{sessionId:e,events:t,tabId:this.tabId})];case 1:return r=i.sent(),this.recordSuccess(),[2,r];case 2:return n=i.sent(),sS(this.loggerProvider,"".concat(sv,": ").concat(n),n),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(e,t){return(0,Z.__awaiter)(n,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(!t)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.db.delete(sk,t)];case 2:return r.sent(),this.recordSuccess(),[3,4];case 3:return e=r.sent(),sS(this.loggerProvider,"".concat(sv,": ").concat(e),e),this.recordFailure(),[3,4];case 4:return[2]}})})},n.db=t.db,n.tabId=t.tabId,n.onPersistentFailure=t.onPersistentFailure,n.consecutiveFailureThreshold=null!=(r=t.consecutiveFailureThreshold)?r:1,n}return(0,Z.__extends)(t,e),t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (idb store)"))},t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,null==(e=this.onPersistentFailure)||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,r){var n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s,a;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:var u;return l.trys.push([0,2,,3]),i="replay"===e?"":"_".concat(e),[4,(u="".concat(r.a
2piKey.substring(0,10),"_amp_session_replay_events").concat(i),(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:var t;return[4,(t=(0,sb.openDB)(u,1,{upgrade:sT}),new Promise(function(e,r){var n=setTimeout(function(){return r(Error("".concat("IDB openDB timed out"," after ").concat(2e3,"ms")))},2e3);t.then(function(t){clearTimeout(n),e(t)},function(e){clearTimeout(n),r(e)})}))];case 1:return[2,e.sent()]}})}))];case 1:return o=l.sent(),s=null!=(n=r.tabId)?n:function(){try{return crypto.randomUUID()}catch(e){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}(),[2,new t((0,Z.__assign)((0,Z.__assign)({},r),{db:o,tabId:s}))];case 2:return a=l.sent(),sS(r.loggerProvider,"".concat(sv,": ").concat(a),a),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r,n,i,o,s,a;return(0,Z.__generator)(this,function(l){switch(l.label){case 0:if(!e)return[3,2];return[4,this.db.get("sessionCurrentSequence",e)];case 1:if(!(t=l.sent())||t.tabId&&t.tabId!==this.tabId)return[2,void 0];return t.tabId,[2,[r=(0,Z.__rest)(t,["tabId"])]];case 2:n=[],l.label=3;case 3:return l.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:o=(i=Z.__values.apply(void 0,[l.sent()])).next(),l.label=5;case 5:if(o.done)return[3,7];if((t=o.value).tabId&&t.tabId!==this.tabId)return[3,6];t.tabId,r=(0,Z.__rest)(t,["tabId"]),n.push(r),l.label=6;case 6:return o=i.next(),[3,5];case 7:return[3,10];case 8:return s={error:l.sent()},[3,10];case 9:try{o&&!o.done&&(a=i.return)&&a.call(i)}finally{if(s)throw s.error}return[7];case 10:return[2,n]}})})},t}(sw),sP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t.emptyFilteredCount=0,t}return(0,Z.__extends)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,r=(0,Z.__spreadArray)([],(0,Z.__read)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:r},this.resetCurrentSequence(e),{sequenceId:t,events:r,sessionId:e}},t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (in-memory store)"))},t.prototype.getSequencesToSend=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var e,t,r,n,i,o,s,a,l,u;return(0,Z.__generator)(this,function(c){e=[];try{for(r=(t=(0,Z.__values)(Object.entries(this.finalizedSequences))).next();!r.done;r=t.next()){if(i=(n=(0,Z.__read)(r.value,2))[0],s=(o=n[1]).sessionId,a=o.events,0===a.length){this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(i)];continue}e.push({sequenceId:Number(i),sessionId:s,events:a})}}catch(e){l={error:e}}finally{try{r&&!r.done&&(u=t.return)&&u.call(t)}finally{if(l)throw l.error}}return[2,e]})})},t.prototype.storeCurrentSequence=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){return(t=this.sequences[e])?0===t.length?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){var r;return(0,Z.__generator)(this,function(n){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(0===this.sequences[e].length?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):r=this.addSequence(e)),this.sequences[e].push(t),[2,r]})})},t.prototype.storeSendingEvents=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(sw),sx=function(e){var t=e.config,r=e.minInterval,n=e.maxInterval,i=e.maxPersistedEventsSize,o=e.type,s=e.payloadBatcher,a=e.storeType,l=e.trackDestinationWorkerScript,u=e.shouldSe
2nd;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,c,d,f,g,h,p,v,m,y,_,b;function w(e){return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(t){return[2,c.flush(e)]})})}return(0,Z.__generator)(this,function(S){switch(S.label){case 0:if(e=null!=(b=t.maxSingleEventSizeBytes)?b:9e6,c=new s_((0,Z.__assign)((0,Z.__assign)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:s,workerScript:l})),d=function(){return new sP({loggerProvider:t.loggerProvider,maxInterval:n,minInterval:r,maxPersistedEventsSize:i})},g=!1,"idb"!==a)return[3,2];return[4,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:return[4,sC.new(o,{loggerProvider:t.loggerProvider,minInterval:r,maxInterval:n,maxPersistedEventsSize:i,apiKey:t.apiKey,onPersistentFailure:function(){(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e,r,n;return(0,Z.__generator)(this,function(i){switch(i.label){case 0:if(!g)return[2];if(g=!1,t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),!f)return[3,2];return[4,h.getSequencesToSend()];case 1:return r=i.sent(),[3,3];case 2:r=void 0,i.label=3;case 3:return e=r,h=d(),e&&f&&(n=f,e.forEach(function(e){_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n})})),[2]}})})}})];case 1:if(!(e=s.sent()))return t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,d()];return g=!0,[2,e]}})})];case 1:return p=S.sent(),[3,3];case 2:p=d(),S.label=3;case 3:return h=p,v=[],m=0,y=function(e){if(!(e<=m)){var t=Math.min(e-m,v.length);t>0&&(v.splice(0,t),m=e)}},_=function(r){var n=r.events,i=r.sessionId,s=r.deviceId,a=r.sequenceId,l=n.map(function(e){return{event:e,bytes:new Blob([e]).size}}),u=l.filter(function(t){return t.bytes>e});u.length>0&&t.loggerProvider.warn("Dropping ".concat(u.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(u.map(function(e){return"".concat(Math.round(e.bytes/1024)," KB")}).join(", "),". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));var d=u.length>0?l.filter(function(t){return t.bytes<=e}).map(function(e){return e.event}):n;0===d.length?h.cleanUpSessionEventsStore(i,a).catch(function(e){t.loggerProvider.warn("Failed to clean up session replay events store:",e)}):(t.debugMode&&o3().then(function(e){var r=e.totalStorageSize,n=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(r," KB, percentage of quota: ").concat(n,"%, usage details: ").concat(i))}).catch(function(){}),c.sendEventsList({events:d,sessionId:i,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:o,onComplete:function(){return(0,Z.__awaiter)(void 0,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,h.cleanUpSessionEventsStore(i,a)];case 1:return e.sent(),[2]}})})}}))},[2,{sendCurrentSequenceEvents:function(e){var r=e.sessionId,n=e.deviceId;if(f=n,!u||u()){var i=m+v.length;h.storeCurrentSequence(r).then(function(e){e&&(y(i),_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n}))}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})}},addEvent:function(e){var r=e.event,n=e.sessionId,i=e.deviceId;f=i;var o=!u||u(),s=m+v.length;v.push(r.data),h.addEventToCurrentSequence(n,r.data).then(function(e){if(e){if(!o){h.cleanUpSessionEventsStore(e.sessionId,e.sequenceId).catch(function(e){t.loggerProvider.warn("Failed to clean up dropped session replay sequence:",e)}),y(s);return}y(s),_({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 r=e.deviceId;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:return f=r,[4,h.getSequencesToSend()];case 1:if(!(null==(e=n.sent())?void 0:e.length))return[2];return t.loggerProvider.log("Draining ".concat(e.length," stored sequence(s) from previous session.")),e.length>1&&c.markCoalesceNextFlush(),e.forEach(function(e){_({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})}),[2]}})})},flush:w,getBeaconEvents:function(){return(0,Z.__spreadArray)([],(0,Z.__read)(v),!1)},dropPendingBeaconEvents:function(){y(m+v.length)},trackDestination:c}]}})})},sO=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=new Map;e.forEach(function(e){r.set(e.name,e.manager)}),this.managers=r}return e.prototype.sendStoredEvents=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return t=[],this.managers.forEac
2h(function(r){t.push(r.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return r.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,r=e.sessionId,n=e.event,i=e.deviceId;null==(t=this.managers.get(n.type))||t.addEvent({sessionId:r,event:n,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,r=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:r})})},e.prototype.flush=function(e){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:return t=[],this.managers.forEach(function(r){t.push(r.flush(e))}),[4,Promise.all(t)];case 1:return r.sent(),[2]}})})},e}();function sA(e,t,r){for(var n=null,i=[],o=e,s=0;o&&"break"!==function(){var e,a,l,u,c=new Date().getTime()-J.getTime();if(void 0!==K.timeoutMs&&c>K.timeoutMs)throw Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var d=sq((e=o.getAttribute("id"))&&K.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null)||sq.apply(void 0,(0,Z.__spreadArray)([],(0,Z.__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))||sq.apply(void 0,(0,Z.__spreadArray)([],(0,Z.__read)(Array.from(o.classList).filter(K.className).map(function(e){return{name:"."+CSS.escape(e),penalty:1}})),!1))||sq((a=o.tagName.toLowerCase(),K.tagName(a)?{name:a,penalty:2}:null))||[sN()],f=function(e){var t=e.parentNode;if(!t)return null;var r=t.firstChild;if(!r)return null;for(var n=0;r&&(r.nodeType===Node.ELEMENT_NODE&&n++,r!==e);)r=r.nextSibling;return n}(o);if("all"==t)f&&(d=d.concat(d.filter(sj).map(function(e){return sF(e,f)})));else if("two"==t)d=d.slice(0,1),f&&(d=d.concat(d.filter(sj).map(function(e){return sF(e,f)})));else if("one"==t){var g=(0,Z.__read)(d=d.slice(0,1),1)[0];f&&sj(g)&&(d=[sF(g,f)])}else"none"==t&&(d=[sN()],f&&(d=[sF(d[0],f)]));try{for(var h=(l=void 0,(0,Z.__values)(d)),p=h.next();!p.done;p=h.next()){var g=p.value;g.level=s}}catch(e){l={error:e}}finally{try{p&&!p.done&&(u=h.return)&&u.call(h)}finally{if(l)throw l.error}}if(i.push(d),i.length>=K.seedMinLength&&(n=sR(i,r)))return"break";o=o.parentElement,s++}(););return(n||(n=sR(i,r)),!n&&r)?r():n}function sR(e,t){var r,n,i=sB(function e(t,r){var n,i,o,s,a;return void 0===r&&(r=[]),(0,Z.__generator)(this,function(l){switch(l.label){case 0:if(!(t.length>0))return[3,9];l.label=1;case 1:l.trys.push([1,6,7,8]),i=(n=(0,Z.__values)(t[0])).next(),l.label=2;case 2:if(i.done)return[3,5];return o=i.value,[5,(0,Z.__values)(e(t.slice(1,t.length),r.concat(o)))];case 3:l.sent(),l.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return s={error:l.sent()},[3,8];case 7:try{i&&!i.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 8:return[3,11];case 9:return[4,r];case 10:l.sent(),l.label=11;case 11:return[2]}})}(e));if(i.length>K.threshold)return t?t():null;try{for(var o=(0,Z.__values)(i),s=o.next();!s.done;s=o.next()){var a=s.value;if(sL(a))return a}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return null}function sM(e){for(var t=e[0],r=t.name,n=1;n<e.length;n++){var i=e[n].level||0;r=t.level===i-1?"".concat(e[n].name," > ").concat(r):"".concat(e[n].name," ").concat(r),t=e[n]}return r}function sD(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function sL(e){var t=sM(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 sN(){return{name:"*",penalty:3}}function sF(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function sj(e){return"html"!==e.name&&!e.name.startsWith("#")}function sq(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.filter(sU);return r.length>0?r:null}function sU(e){return null!=e}function sB(e){return(0,Z.__spreadArray)([],(0,Z.__read)(e),!1).sort(function(e,t){return sD(e)-sD(t)})}var sz=function(e){var t=e.version,r=e.events,n=[];return r.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&n.push(t)}),{version:t,events:n}},sW=function(e){var t=e.version,r=e.events,n=[];return r.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&n.push(t)}),{version:t,events:Object.values(n.reduce(function(e,t){var r=t.x,n=t.y,i=t.selector,o=t.timestamp,s=o-o%36e5,a="".concat(r,":").concat(n,":").concat(null!=i?i:"",":").concat(s);return e[a]?e[a].count+=1:e[a]=(0,Z.__assign)((0,Z.__assign)({},t),{timestamp:s,count:1}),e},{}))}},sG=function(e,t){var r=this;this.createHook=function(e){var t=e.eventsManager,n=e.sessionId,i=e.deviceIdFn,o=e.mirror,s=e.ugcFilterRules,a=e.performanceOptions;return function(e){if(e.type!==sn.Click)return;var l,u=(0,eO.getGlobalScope)();
2if(u){var c=u.location,d=u.innerHeight,f=u.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{l=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 r,n,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};r=(K=(0,Z.__assign)((0,Z.__assign)({},i),t)).root,n=i,V=r.nodeType===Node.DOCUMENT_NODE?r:r===n.root?r.ownerDocument:r;var o=sA(e,"all",function(){return sA(e,"two",function(){return sA(e,"one",function(){return sA(e,"none")})})});if(o){var s=sB(function e(t,r,n){var i,o,s;return void 0===n&&(n={counter:0,visited:new Map}),(0,Z.__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 l,u;if(!(i<t.length-1))return[3,5];if(n.counter>K.maxNumberOfTries||(n.counter+=1,(o=(0,Z.__spreadArray)([],(0,Z.__read)(t),!1)).splice(i,1),s=sM(o),n.visited.has(s)))return[2];if(!(sL(o)&&(l=o,u=r,V.querySelector(sM(l))===u)))return[3,4];return[4,o];case 2:return a.sent(),n.visited.set(s,!0),[5,(0,Z.__values)(e(o,r,n))];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]),sM(o)}throw Error("Selector was not found.")}(p,a)}catch(e){r.logger.debug("error resolving selector from finder")}var v=o2(c.href,s),m={x:g+r.scrollWatcher.currentScrollX,y:h+r.scrollWatcher.currentScrollY,selector:l,viewportHeight:d,viewportWidth:f,pageUrl:v,timestamp:Date.now(),type:"click"},y=i();y&&t.addEvent({sessionId:n,event:{type:"interaction",data:JSON.stringify(m)},deviceId:y})}}}}},this.logger=e,this.scrollWatcher=t};function sH(){var e=(0,eO.getGlobalScope)();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function s$(){var e=(0,eO.getGlobalScope)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var sK=function(){function e(e,t){var r=(0,eO.getGlobalScope)();r&&r.navigator&&"function"==typeof r.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(r.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var r=new XMLHttpRequest;return r.open("POST",e,!0),r.setRequestHeader("Accept","*/*"),r.send(JSON.stringify(t)),!0},this.basePageUrl=sf(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e,this.handleSendEvents=t.handleSendEvents,this.loggerProvider=t.loggerProvider}return e.prototype.send=function(e,t){var r,n=this,i=this.context,o=i.sessionId,s=i.type;if(this.handleSendEvents){var a=new URLSearchParams({device_id:e,session_id:String(o),type:String(s)}),l="".concat(this.basePageUrl,"?").concat(a.toString()),u={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(this.apiKey)};try{this.handleSendEvents({url:l,method:"POST",headers:u,body:JSON.stringify(t),keepalive:!0}).catch(function(e){var t;null==(t=n.loggerProvider)||t.warn("Custom transport failed to send session replay interaction beacon:",e)})}catch(e){null==(r=this.loggerProvider)||r.warn("Custom transport threw while sending session replay interaction beacon:",e)}return}var c=new URLSearchParams({device_id:e,session_id:String(o),type:String(s),api_key:this.apiKey}),d="".concat(this.basePageUrl,"?").concat(c.toString());this.sendBeacon(d,t)||this.sendXhr(d,t)},e}(),sV=function(){function e(e,t){var r=this;this.timestamp=Date.now(),this.hook=function(e){r.update(e)},this.send=function(e){return function(t){var n,i,o,s,a=e(),l=(0,eO.getGlobalScope)();if(l&&a){var u=null!=(n=l.scrollX)?n:0,c=null!=(i=l.scrollY)?i:0;(u>0||c>0)&&r.update({id:1,x:u,y:c}),r.transport.send(a,{version:1,events:[{maxScrollX:r._maxScrollX,maxScrollY:r._maxScrollY,maxScrollWidth:r._maxScrollWidth,maxScrollHeight:r._maxScrollHeight,viewportHe
2ight:sH(),viewportWidth:s$(),pageUrl:o2(l.location.href,null!=(s=null==(o=r.config.interactionConfig)?void 0:o.ugcFilterRules)?s:[]),timestamp:r.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=s$(),this._maxScrollHeight=sH(),this.config=t,this.transport=e}return e.default=function(t,r){return new e(new sK(t,r),r)},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 r=s$();this._maxScrollX=e.x;var n=e.x+r;n>this._maxScrollWidth&&(this._maxScrollWidth=n),this.timestamp=t}if(e.y>this._maxScrollY){var i=sH();this._maxScrollY=e.y;var o=e.y+i;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},e}(),sJ=function(e){var t=e.sessionId,r=e.deviceId;this.deviceId=r,this.sessionId=t,t&&r&&(this.sessionReplayId="".concat(r,"/").concat(t))},sY=function(e){return"".concat("AMP_SR_START_").concat(e.substring(0,10),"_")},sX=function(e,t){return"".concat(sY(e)).concat(t)},sQ=function(){try{var e=(0,eO.getGlobalScope)();return null==e?void 0:e.localStorage}catch(e){return}},sZ=function(e,t,r,n){var i=sQ();if(i){var o=sX(e,t);try{var s=i.getItem(o);if(null!==s){var a=Number(s);if(Number.isFinite(a)&&a>0&&a<=r&&r-a<864e5)return a}return i.setItem(o,String(r)),r}catch(e){null==n||n.debug("Failed to read/write replay start time from storage: ".concat(String(e)));return}}},s0=function(e,t,r,n){var i=sQ();if(i)try{i.setItem(sX(e,t),String(r))}catch(e){null==n||n.debug("Failed to write replay start time to storage: ".concat(String(e)))}},s1=function(e,t,r){var n=sQ();if(n)try{n.removeItem(sX(e,t))}catch(e){null==r||r.debug("Failed to remove replay start time from storage: ".concat(String(e)))}},s2=function(e,t,r){var n,i,o=sQ();if(o){var s=sY(e);try{for(var a=[],l=0;l<o.length;l++){var u=o.key(l);if(u&&u.startsWith(s)){var c=o.getItem(u);if(null!==c){var d=Number(c);(!Number.isFinite(d)||d<=0||t-d>=864e5)&&a.push(u)}}}try{for(var f=(0,Z.__values)(a),g=f.next();!g.done;g=f.next()){var u=g.value;o.removeItem(u)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}catch(e){null==r||r.debug("Failed to prune stale replay start times: ".concat(String(e)))}}},s3=new function(){var e=this;this.dbs={},this.createStore=function(t){return(0,Z.__awaiter)(e,void 0,void 0,function(){return(0,Z.__generator)(this,function(e){switch(e.label){case 0:return[4,(0,sb.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,Z.__awaiter)(e,void 0,void 0,function(){var e,r;return(0,Z.__generator)(this,function(n){switch(n.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 r=n.sent(),this.dbs[t]=r,[2,r]}})})},this.getTargetingMatchForSession=function(t){var r=t.loggerProvider,n=t.apiKey,i=t.sessionId;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(n)];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(),sS(r,"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 r=t.loggerProvider,n=t.apiKey,i=t.sessionId,o=t.targetingMatch;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(n)];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(),sS(r,"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 r=t.loggerProvider,n=t.apiKey,i=t.currentSessionId;return(0,Z.__awaiter)(e,void 0,void 0,function(){var e,t,o,s,a,l,u,c;return(0,Z.__generator)(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.openOrCreateDB(n)];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(!(a<s.length))return[3,6];if(l=s[a],u=Date.now()-l.lastUpdated,!(l.sessionId!==t&&u>1728e5))return[3,5];return[4,o.store.delete(l.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(),sS(r,"Failed to clear old targeting matches for sessions: ".concat(c),c),[3,9];case 9:return[2]}})})}},s4=function(t){var r=t.sessionId,n=t.targetingConfig,i=t.loggerProvider,o=t.apiKey,s=t.targetingParams,a=t.urlChange,l=void 0!==a&&a;return(0,Z.__awaiter)(void 0,void 0,void 0,function(){var t,a,u;return(0,Z.__generator)(this,function(c){switch(c.label){case 0:return[4,s3.clearStoreOfOldSessions({loggerProvider:i,apiKey:o,currentSessionId:r})];case 1:return c.sent(),[4,s3.getTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:r})];case 2:if(!0===c.sent()&&!l)return[2,!0];t=!0,c.label=3;case 3:return c.trys.push([3,6,,7]),[4,e.A(526160)];case 4:return[4,(0,c.sent().evaluateTargeting)((0,Z.__assign)((0,Z.__assign)({},s),{flag:n,sessionId:"string"==typeof r?parseInt(r,10):r,apiKey:o,loggerProvider:i}))];case 5:return(a=c.sent())&&a.sr_targeting_config&&(t="on"===a.sr_targeting_config.key),s3.storeTargetingMatchForSession({loggerProvider:i,apiKey:o,sessionId:r,targetingMatch:t}),[3,7];case 6:return u=c.sent(),i.warn(u.message),[3,7];case 7:return[2,t]}})})};function s5(e,t){return(e<<t|e>>>32-t)>>>0}function s6(e,t){return Math.imul(e=s5(e=e+Math.imul(t,0x85ebca77)>>>0,13),0x9e3779b1)>>>0}function s8(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}var s7="__amplitude_url_tracking_patched__",s9=new WeakMap;function ae(e,t,r){if(void 0===r&&(r={}),!(null==e?void 0:e.location))return function(){};var n=r.enablePolling,i=r.pollingInterval;if(void 0!==n&&n){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 l=s9.get(e);if(!l){var u=void 0,c=new Set,d=function(){var t;return null!=(t=e.location.href)?t:""},f=function(){var e=d();
2(void 0===u||e!==u)&&(u=e,c.forEach(function(t){return t(e)}))},g=function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=e.apply(this,t);return f(),n};return t[s7]=!0,t},h=e.history;if(null==h?void 0:h.pushState){var p=Reflect.get(h,"pushState");p[s7]||(h.pushState=g(p))}if(null==h?void 0:h.replaceState){var v=Reflect.get(h,"replaceState");v[s7]||(h.replaceState=g(v))}l={callbacks:c,notify:f,onPopStateOrHashChange:function(){return f()},listenersAttached:!1},s9.set(e,l)}var m=l;return m.listenersAttached||(e.addEventListener("popstate",m.onPopStateOrHashChange),e.addEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!0),m.callbacks.add(t),function(){m.callbacks.delete(t),0===m.callbacks.size&&m.listenersAttached&&(e.removeEventListener("popstate",m.onPopStateOrHashChange),e.removeEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!1)}}function at(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,r,n){var i,o,s,a=(0,Z.__assign)((0,Z.__assign)({},e),n),l=a.ugcFilterRules||[],u=null!=(i=a.enablePolling)&&i,c=null!=(o=a.pollingInterval)?o:1e3,d=null!=(s=a.captureDocumentTitle)&&s;if(!r)return function(){};var f=void 0,g=function(){return r.location&&r.location.href||""},h=function(){var e=r.innerHeight,t=r.innerWidth,n=r.document,i=g(),o="";return d&&(o=(null==n?void 0:n.title)||""),{href:l.length>0?o2(i,l):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=ae(r,function(){return p()},u?{enablePolling:!0,pollingInterval:c}:{});return p(),function(){return v()}},options:e}}at();var ar=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e,t=this;null==(e=this.mutationObserver)||e.disconnect(),(0,eO.getGlobalScope)()&&(this.sendToAllIframes({type:oH,action:"start"}),this.mutationObserver=new MutationObserver(function(e){var r,n,i,o,s,a;try{for(var l=(0,Z.__values)(e),u=l.next();!u.done;u=l.next()){var c=u.value;try{for(var d=(i=void 0,(0,Z.__values)(Array.from(c.addedNodes))),f=d.next();!f.done;f=d.next()){var g=f.value;g instanceof HTMLIFrameElement?t.sendToIframeAfterLoad(g):g instanceof Element&&g.querySelectorAll("iframe").forEach(function(e){t.sendToIframeAfterLoad(e)})}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}try{for(var h=(s=void 0,(0,Z.__values)(Array.from(c.removedNodes))),p=h.next();!p.done;p=h.next()){var g=p.value;if(g instanceof HTMLIFrameElement){var v=t.pendingLoadListeners.get(g);v&&(g.removeEventListener("load",v),t.pendingLoadListeners.delete(g))}}}catch(e){s={error:e}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(s)throw s.error}}}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},e.prototype.stop=function(){var e;null==(e=this.mutationObserver)||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener("load",e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:oH,action:"stop"})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,r=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:oH,action:"start"})};this.pendingLoadListeners.set(e,r),e.addEventListener("load",r,{once:!0})},e.prototype.sendToAllIframes=function(e){var t=this;document.querySelectorAll("iframe").forEach(function(r){return t.sendToIframe(r,e)})},e.prototype.sendToIframe=function(e,t){var r;try{null==(r=e.contentWindow)||r.postMessage(t,"*")}catch(e){}},e}(),an=function(){function t(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeC
2oordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var r=(0,eO.getGlobalScope)();r&&(r.removeEventListener("blur",e.blurListener),r.removeEventListener("focus",e.focusListener),t||r.addEventListener("blur",e.blurListener),t||r.addEventListener("focus",e.focusListener),r.self&&"onpagehide"in r.self?(r.removeEventListener("pagehide",e.pageLeaveListener),t||r.addEventListener("pagehide",e.pageLeaveListener)):(r.removeEventListener("beforeunload",e.pageLeaveListener),t||r.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){var t;if(e.recordCancelCallback&&e.recordFunction){if((null==(t=e.config)?void 0:t.captureFullSnapshotOnFocus)===!1)return;try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn("Failed to take full snapshot on focus:",t)}}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var r;null==(r=e.eventCompressor)||r.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,r,n,i){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1),(0,Z.__awaiter)(e,void 0,void 0,function(){var e,o,s,a,l,u,c,d,f,g,h,p;return(0,Z.__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(!r)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(A).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:"",l=null!=(p=t.page)?p:""!==a?{url:a}:void 0,[4,s4({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:s,page:l},urlChange:i})];case 1:if(u=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||u,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(!r)return[3,3];return this.initialize(!0),[3,5];case 3:if(!(n||!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,r,n){return void 0===r&&(r={}),void 0===n&&(n=!0),(0,Z.__awaiter)(e,void 0,void 0,function(){var e,i,o,s;return(0,Z.__generator)(this,function(a){switch(a.label){case 0:if(a.trys.push([0,3,,4]),e=void 0,!((i=this.config)&&t!==$.METADATA)||(e={config:o4(i),version:sy},!n))return[3,2];return[4,o3()];case 1:o=a.sent(),e=(0,Z.__assign)((0,Z.__assign)({},o),e),a.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,Z.__assign)((0,Z.__assign)({},r),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,r,n;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null==(t=e.networkObservers)||t.stop(),null==(r=e.crossOriginIframeC
2oordinator)||r.stop(),e.crossOriginIframeCoordinator=null,null==(n=e.crossOriginParentSignalCleanup)||n.call(e),e.crossOriginParentSignalCleanup=null}catch(t){e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new o$(new eB)}return t.prototype.init=function(e,t){return eF(this._init(e,t))},t.prototype.setupUrlChangeListener=function(){var e,t,r=this;null==(e=this.urlChangeCleanup)||e.call(this);var n=(0,eO.getGlobalScope)();if(null==n?void 0:n.location){var i=!!(null==(t=this.config)?void 0:t.targetingConfig),o=ae(n,function(e){if(r.currentPageUrl=e,i){var t=++r.latestUrlChangeTargetingEvaluationId;r.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:e}},!1,!1,!0),r.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(t," for ").concat(e,"."))}});this.urlChangeCleanup=function(){o(),r.urlChangeCleanup=null}}},t.prototype.isBelowMinSessionDuration=function(){var e,t=null==(e=this.config)?void 0:e.minSessionDurationMs;return void 0!==t&&void 0!==this.sessionStartTime&&Date.now()-this.sessionStartTime<t},t.prototype.getCurrentPageForTargeting=function(){var e,t,r=null==(t=null==(e=(0,eO.getGlobalScope)())?void 0:e.location)?void 0:t.href;return null!=r?{url:r}:void 0},t.prototype._init=function(t,r){var n,i,o,s,a,l,u,c,d,f,g,h,p,v;return(0,Z.__awaiter)(this,void 0,void 0,function(){var m,y,_,b,w,S,E,k,I,T,C,P,x,O,A,R,M,D,L,N,F,j,q,U,B,z,W,G,H,$=this;return(0,Z.__generator)(this,function(K){switch(K.label){case 0:return null==(n=this.urlChangeCleanup)||n.call(this),this.loggerProvider=new o$(r.loggerProvider||new eB),Object.prototype.hasOwnProperty.call(r,"logLevel")&&this.loggerProvider.enable(r.logLevel),this.currentPageUrl=oQ(),this.identifiers=new sJ({sessionId:r.sessionId,deviceId:r.deviceId}),s2(t,m=Date.now(),this.loggerProvider),this.sessionStartTime=void 0!==r.sessionId&&null!=(i=sZ(t,r.sessionId,m,this.loggerProvider))?i:m,y=this,[4,(0,Z.__awaiter)(void 0,void 0,void 0,function(){var e;return(0,Z.__generator)(this,function(n){return e=new o6(t,r),[2,new sc(new to(t,e.loggerProvider,e.serverZone,r.configServerUrl,r.handleFetchConfig),e)]})})];case 1:return y.joinedConfigGenerator=K.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:if(b=(_=K.sent()).joinedConfig,w=_.localConfig,S=_.remoteConfig,this.config=b,this.setMetadata(r.sessionId,b,w,S,null==(o=r.version)?void 0:o.version,sy,null==(s=r.version)?void 0:s.type),this.pageLeaveFns=[],r.sessionId&&(null==(a=this.config.interactionConfig)?void 0:a.enabled)&&(E=sV.default({sessionId:r.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[E.send(this.getDeviceId.bind(this)).bind(E)],this.scrollHook=E.hook.bind(E),this.clickHandler=new sG(this.loggerProvider,E)),k=[],"idb"!==(I=this.config.storeType)||(null==(l=(0,eO.getGlobalScope)())?void 0:l.indexedDB)||(I="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(I," for event storage.")),P=(0,eO.getGlobalScope)(),!(this.config.useWebWorker&&P&&P.Worker))return[3,4];return[4,e.A(481696)];case 3:O=(x=K.sent()).compressionScript,A=x.trackDestinationScript,T=O,C=A,K.label=4;case 4:return K.trys.push([4,6,,7]),[4,sx({config:this.config,type:"replay",minInterval:null==(u=this.config.flushIntervalConfig)?void 0:u.minIntervalMs,maxInterval:null==(c=this.config.flushIntervalConfig)?void 0:c.maxIntervalMs,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:I,trackDestinationWorkerScript:C,shouldSend:function(){return!$.isBelowMinSessionDuration()}})];case 5:return R=K.sent(),this.rrwebEventManager=R,k.push({name:"replay",manager:R}),[3,7];case 6:return M=K.sent(),this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(M.toString())),[3,7];case 7:if(!(null==(d=this.config.interactionConfig)?void 0:d.enabled))return[3,11];D=this.config.interactionConfig.batch?sW:sz,K.label=8;case 8:return K.trys.push([8,10,,11]),[4,sx({config:this.config,type:"interaction",minInterval:null!=(f=this.config.interactionConfig.trackEveryNms)?f:3e4,maxInterval:6e4,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:D,storeType:I,trackDestinationWorkerScript:C})];case 9:return L=K.sent(),k.push({name:"interaction",manager:L}),[3,11];case 10:return M=K.sent(),this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(M.toString())),[3,11];case 11:if(this.eventsManager=new(sO.bind.apply(sO,(0,Z.__spreadArray)([void 0],(0,Z.__read)(k),!1))),this.eventCompressor&&this.eventCompressor.terminate(),N=!0===this.config.eagerFullSnapshotSend?function(){return $.sendEvents()}:void 0,this.eventCompressor=new sh(this.eventsManager,this.config,this.getDeviceId(),T,N),this.pendingEmitEvents.length>0){F=this.pendingEmitEvents.splice(0);try{for(q=(j=(0,Z.__values)(F)).next();!q.done;q=j.next())B=(U=q.value).event,z=U.sessionId,this.eventCompressor.enqueueEvent(B,z)}catch(e){G={error:e}}finally{try{q&&!q.done&&(H=j.return)&&H.call(j)}finally{if(G)throw G.error}}}return this.pageLeaveFns=(0,Z.__spreadArray)((0,Z.__spreadArray)([],(0,Z.__read)(this.pageLeaveFns),!1),[function(){if($.config&&(null==(e=$.identifiers)?void 0:e.sessionId)&&R){var e,t=R.getBeaconEvents();if(t.length){var r=$.getDeviceId();!r||$.isBelowMinSessionDuration()||R.trackDestination.sendBeacon({events:t,sessionId:$.identifiers.sessionId,deviceId:r,apiKey:$.config.apiKey,serverZone:$.config.serverZone})}}}],!1),[4,this.initializeNetworkObservers()];case 12:return K.sent(),(null==(g=(0,eO.getGlobalScope)())?void 0:g.opener)&&(r6(W=r4()),W.setup((0,Z.__assign)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:r0[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:r.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return K.sent(),(this.config.targetingConfig||(null!=(v=null==(p=null==(h=this.config.privacyConfig)?void 0:h.urlMaskLevels)?void 0:p.length)?v:0)>0)&&this.setupUrlChangeListener(),[2]}})})},t.prototype.setSessionId=function(e,t){return eF(this.asyncSetSessionId(e,t))},t.prototype.asyncSetSessionId=function(e,t,r){var n,i,o,s;return(0,Z.__awaiter)(this,void 0,void 0,function(){var a,l,u,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:if(a=null==(n=this.identifiers)?void 0:n.sessionId,l=this.getDeviceId(),void 0!==a&&a===e&&(void 0===t||t===l)&&((null==r?void 0:r.userProperties)===void 0||0===Object.keys(r.userProperties).length))return[2];if(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,a&&this.sendEvents(a),(u=a!==e)&&(null==(i=this.rrwebEventManager)||i.dropPendingBeaconEvents()),c=t||this.getDeviceId(),this.identifiers=new sJ({sessionId:e,deviceId:c}),u&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,(null==(o=this.config)?void 0:o.apiKey)&&(s0(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),void 0!==a&&s1(this.config.apiKey,a,this.loggerProvider))),!(this.joinedConfigGenerator&&a))return[3,2];return[4,this.joinedConfigGenerator.generateJoinedConfig()];case 1:d=f.sent().joinedConfig,this.config=d,f.label=2;case 2:if(!(null==(s=this.config)?void 0:s.targetingConfig))return[3,4];return[4,this.evaluateTargetingAndCapture({userProperties:null==r?void 0:r.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)];case 3:return f.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:f.sent(),f.label=6;case 6:return[2]}})})},t.prototype.getSessionReplayProperties=function(){var e,t=this.config,r=this.identifiers;if(!t||!r)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var n=this.getShouldRecord(),i={};return n&&((e={})[oD]=r.sessionReplayId?r.sessionReplayId:null,i=e,t.debugMode&&(i[oF]=JSON.stringify({appHash:tg(t.apiKey).toString()}))),this.addCustomRRWebEvent($.GET_SR_PROPS,{shouldRecord:n,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},t.prototype.sendEvents=function(e){var t,r,n=e||(null==(t=this.identifiers)?void 0:t.sessionId),i=this.getDeviceId();
2if(this.eventsManager&&n&&i){if(this.isBelowMinSessionDuration()){var o=this.sessionStartTime,s=this.config.minSessionDurationMs;this.loggerProvider.log("Session ".concat(n," not sent: duration ").concat(Date.now()-o,"ms is below minimum ").concat(s,"ms.")),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&(null==(r=this.config)?void 0:r.minSessionDurationMs)!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var a=void 0!==this.sessionStartTime?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent($.REPLAY_GATE_DECISION,{sessionId:n,suppressedSendCount:this.suppressedSendCount,elapsedMs:a,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:i})}},t.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,Z.__awaiter)(this,void 0,void 0,function(){var r;return(0,Z.__generator)(this,function(n){return(null==(t=this.identifiers)?void 0:t.sessionId)?(r=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:r}),[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,r;r=e8(this.config.instanceName).identityStore.getIdentity().optOut}return void 0!==r?r: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,r=!1,n="",i=!1;return this.config.targetingConfig?this.sessionTargetingMatch?(n="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(n),r=!0,i=!0):(n="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(n),r=!1,i=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,function(e,t){void 0===t&&(t=0);var r,n=function(e){for(var t=[],r=0;r<e.length;r++){var n=e.charCodeAt(r);if(n>=55296&&n<=56319&&r+1<e.length){var i=e.charCodeAt(r+1);i>=56320&&i<=57343&&(n=(n-55296<<10)+(i-56320)+65536,r++)}n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<65536?t.push(224|n>>12,128|n>>6&63,128|63&n):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}return new Uint8Array(t)}(e),i=n.length,o=0;if(i>=16){for(var s=t+0x9e3779b1+0x85ebca77>>>0,a=t+0x85ebca77>>>0,l=t>>>0,u=t-0x9e3779b1>>>0;o<=i-16;)s=s6(s,s8(n,o)),o+=4,a=s6(a,s8(n,o)),o+=4,l=s6(l,s8(n,o)),o+=4,u=s6(u,s8(n,o)),o+=4;r=s5(s,1)+s5(a,7)+s5(l,12)+s5(u,18)>>>0}else r=t+0x165667b1>>>0;for(r=r+i>>>0;o<=i-4;)r=Math.imul(s5(r=r+Math.imul(s8(n,o),0xc2b2ae3d)>>>0,17),0x27d4eb2f)>>>0,o+=4;for(;o<i;)r=Math.imul(s5(r=r+Math.imul(n[o],0x165667b1)>>>0,11),0x9e3779b1)>>>0,o++;return r^=r>>>15,r=Math.imul(r,0x85ebca77)>>>0,r^=r>>>13,r=Math.imul(r,0xc2b2ae3d)>>>0,(r^=r>>>16)>>>0}(e.toString())%1e6/1e6<t)?(r=!0,i=!0):(n="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(n),r=!1,i=!1),this.lastShouldRecordDecision!==r&&this.config.targetingConfig&&(this.addCustomRRWebEvent($.TARGETING_DECISION,{message:n,sessionId:this.identifiers.sessionId,matched:i,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=r),r},t.prototype.getBlockSelectors=function(){var e,t,r,n=null!=(r=null==(t=null==(e=this.config)?void 0:e.privacyConfig)?void 0:t.blockSelector)?r:[];if(0!==n.length)return n},t.prototype.getMaskTextSelectors=function(){var e,t,r=null==(e=this.config)?void 0:e.privacyConfig;if("conservative"===(r?oJ(this.currentPageUrl,r):void 0)||(null==(t=null==r?void 0:r.urlMaskLevels)?void 0:t.some(function(e){return"conservative"===e.maskLevel})))return"*";var n=null==r?void 0:r.urlMaskLevels;if((null==r?void 0:r.defaultMaskLevel)==="conservative"&&n&&n.length>0)return"*";var i=null==r?void 0:r.maskSelector;if(i)return i},t.prototype.getRecordingPlugins=function(t){var r,n,i,o,s,a;return(0,Z.__awaiter)(this,void 0,void 0,function(){var l,u,c,d;return(0,Z.__generator)(this,function(f){switch(f.label){case 0:l=[];try{u=at({ugcFilterRules:(null==(n=null==(r=this.config)?void 0:r.interactionConfig)?void 0:n.ugcFilterRules)||[],enablePolling:(null==(i=this.config)?void 0:i.enableUrlChangePolling)||!1,pollingInterval:null==(o=this.config)?void 0:o.urlChangePollingInterval,captureDocumentTitle:null==(s=this.config)?void 0:s.captureDocumentTitle}),l.push(u)}catch(e){this.loggerProvider.warn("Failed to create URL tracking plugin:",e)}if(!(null==(a=null==t?void 0:t.console)?void 0:a.enabled))return[3,4];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,e.A(627085)];case 2:return c=f.sent().getRecordConsolePlugin,l.push(c({level:t.console.levels})),[3,4];case 3:return d=f.sent(),this.loggerProvider.warn("Failed to load console plugin:",d),[3,4];case 4:return[2,l.length>0?l:void 0]}})})},t.prototype.getRecordFunction=function(){return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,r;return(0,Z.__generator)(this,function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,e.A(312948)];case 2:return t=n.sent().record,this.recordFunction=t,[2,t];case 3:return r=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",r),[2,null];case 4:return[2]}})})},t.prototype.recordEvents=function(e){return void 0===e&&(e=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var t;return(0,Z.__generator)(this,function(r){switch(r.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,r.label=1;case 1:return r.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:r.sent(),r.label=3;case 3:if(null===this.recordEventsPendingShouldLogMetadata)return[3,5];return t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)];case 4:return r.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},t.prototype._recordEvents=function(e){var t,r,n,i,o,s,a,l;return void 0===e&&(e=!0),(0,Z.__awaiter)(this,void 0,void 0,function(){var u,c,d,f,g,h,p,v,m,y,_,b,w,S,E,k,I,T,C=this;return(0,Z.__generator)(this,function(P){switch(P.label){case 0:if(u=this.config,c=this.getShouldRecord(),d=null==(t=this.identifiers)?void 0:t.sessionId,!c||!d||!u)return[2];return this.stopRecordingEvents(),[4,this.getRecordFunction()];case 1:if(!(f=P.sent()))return[2];return[4,this.initializeNetworkObservers()];case 2:P.sent(),g=null==(r=u.loggingConfig)?void 0:r.network,h=[oU,oB,oz,sf(u.serverZone,u.trackServerUrl)],null==(n=this.networkObservers)||n.start(function(e){h.some(function(t){return e.url.
2startsWith(t)})||C.addCustomRRWebEvent($.FETCH_REQUEST,e)},g),p=u.interactionConfig,v=u.loggingConfig,m=(null==p?void 0:p.enabled)?{mouseInteraction:this.eventsManager&&(null==(i=this.clickHandler)?void 0:i.createHook({eventsManager:this.eventsManager,sessionId:d,deviceIdFn:this.getDeviceId.bind(this),mirror:f.mirror,ugcFilterRules:null!=(o=p.ugcFilterRules)?o:[],performanceOptions:null==(s=u.performanceConfig)?void 0:s.interaction})),scroll:this.scrollHook}:{},y=(null==p?void 0:p.enabled)&&p.ugcFilterRules?p.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(d,".")),P.label=3;case 3:if(P.trys.push([3,5,,6]),_=!!(null==(a=u.crossOriginIframes)?void 0:a.enabled),b=(null==(l=u.crossOriginIframes)?void 0:l.coordinateChildren)!==!1,(w=_&&function(){try{var e=(0,eO.getGlobalScope)();if(!e)return!1;return e.parent!==e}catch(e){return!0}}())&&b)return this.crossOriginParentSignalCleanup=function(e){var t=(0,eO.getGlobalScope)();if(!t)return function(){};var r=t.parent;function n(t){if(t.source===r){var n=t.data;(null==n?void 0:n.type)===oH&&("start"===n.action?e.onStart():"stop"===n.action&&e.onStop())}}return t.addEventListener("message",n),function(){return t.removeEventListener("message",n)}}({onStart:function(){return C._recordEventsInChildMode(f,d,u,m)},onStop:function(){try{C.recordCancelCallback&&C.recordCancelCallback(),C.recordCancelCallback=null}catch(e){C.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))}}}),[2];return S=this,E=f,k=[(0,Z.__assign)({},this.buildRRWebRecordOptions(u,m,function(e){if(C.shouldOptOut()){C.loggerProvider.log("Opting session ".concat(d," out of recording due to optOut config.")),C.stopRecordingEvents(),C.sendEvents();return}e.type===st.Meta&&(e.data.href=o2(e.data.href,y)),C.eventCompressor?C.eventCompressor.enqueueEvent(e,d):C.pendingEmitEvents.push({event:e,sessionId:d})},"Error while capturing replay: "))],T={},[4,this.getRecordingPlugins(v)];case 4:return S.recordCancelCallback=E.apply(void 0,[Z.__assign.apply(void 0,k.concat([(T.plugins=P.sent(),T.recordCrossOriginIframes=_,T)]))]),_&&!w&&b&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new ar),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent($.DEBUG_INFO),e&&this.addCustomRRWebEvent($.METADATA,this.metadata),[3,6];case 5:return I=P.sent(),this.loggerProvider.warn("Failed to initialize session replay:",I),[3,6];case 6:return[2]}})})},t.prototype.buildRRWebRecordOptions=function(e,t,r,n){var i,o=this,s=e.privacyConfig;return(0,Z.__assign)((0,Z.__assign)({emit:r,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:oj,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:oX("input",s,function(){return o.currentPageUrl}),maskTextFn:oX("text",s,function(){return o.currentPageUrl}),maskAttributeFn:(i=function(){return o.currentPageUrl},function(e,t,r){var n;return"style"!==e&&(null!=(n=null==s?void 0:s.maskAttributes)?n:[]).includes(e)?oY(["INPUT","SELECT","TEXTAREA"].includes(r.tagName)?"input":"text",s,r,null==i?void 0:i())?t.replace(/[^\s]/g,"*"):t:t}),maskTextSelector:this.getMaskTextSelectors()},void 0!==e.fullSnapshotIntervalMs&&{checkoutEveryNms:e.fullSnapshotIntervalMs}),{recordCanvas:!1,captureAdoptedStyleSheets:e.captureAdoptedStyleSheets,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},errorHandler:function(e){if(e.message.includes("insertRule")&&e.message.includes("CSSStyleSheet")||e._external_)throw e;return o.loggerProvider.warn(n,e.toString()),!0}})},t.prototype._recordEventsInChildMode=function(e,t,r,n){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e((0,Z.__assign)((0,Z.__assign)({},this.buildRRWebRecordOptions(r,n,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t,"."))}catch(e){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",e)}},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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){return[2,null==(t=this.eventsManager)?void 0:t.flush(e)]})})},t.prototype.shutdown=function(){var e,t;null==(e=this.urlChangeCleanup)||e.call(this),null==(t=this.crossOriginParentSignalCleanup)||t.call(this),this.crossOriginParentSignalCleanup=null,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,r,n,i,o,s){var a=(null==e?void 0:e.toString())?tg(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:r,remoteConfig:n,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,r,n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o;return(0,Z.__generator)(this,function(s){switch(s.label){case 0:if(!((null==(n=null==(r=null==(t=this.config)?void 0:t.loggingConfig)?void 0:r.network)?void 0:n.enabled)&&!this.networkObservers))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,e.A(536374)];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}(),ai=function(e){return function(){var t=e.config||o5();return{logger:t.loggerProvider,logLevel:t.logLevel}}};let ao={init:ei((I=new an).init.bind(I),"init",ai(I)),evaluateTargetingAndCapture:ei(I.evaluateTargetingAndCapture.bind(I),"evaluateTargetingAndRecord",ai(I)
2),setSessionId:ei(I.setSessionId.bind(I),"setSessionId",ai(I)),getSessionId:ei(I.getSessionId.bind(I),"getSessionId",ai(I)),getSessionReplayProperties:ei(I.getSessionReplayProperties.bind(I),"getSessionReplayProperties",ai(I)),flush:ei(I.flush.bind(I),"flush",ai(I)),shutdown:ei(I.shutdown.bind(I),"shutdown",ai(I))};var as=ao.init,aa=ao.setSessionId,al=ao.getSessionId,au=ao.getSessionReplayProperties,ac=ao.flush,ad=ao.shutdown,af=ao.evaluateTargetingAndCapture;(T=Y||(Y={})).SET="$set",T.SET_ONCE="$setOnce",T.ADD="$add",T.APPEND="$append",T.PREPEND="$prepend",T.REMOVE="$remove",T.PREINSERT="$preInsert",T.POSTINSERT="$postInsert",T.UNSET="$unset",T.CLEAR_ALL="$clearAll",(C=X||(X={})).REVENUE_PRODUCT_ID="$productId",C.REVENUE_QUANTITY="$quantity",C.REVENUE_PRICE="$price",C.REVENUE_TYPE="$revenueType",C.REVENUE_CURRENCY="$currency",C.REVENUE="$revenue",(P=Q||(Q={})).IDENTIFY="$identify",P.GROUP_IDENTIFY="$groupidentify",P.REVENUE="revenue_amount";var ag=[Y.SET,Y.SET_ONCE,Y.ADD,Y.APPEND,Y.PREPEND,Y.POSTINSERT],ah=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach(function(r){if(ag.includes(r)){var n=e.user_properties&&e.user_properties[r];t=(0,Z.__assign)((0,Z.__assign)({},t),n)}}),t}},ap="1.33.7",av="".concat("[Amplitude]"," Session Replay ID"),am=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:ac,getSessionId:al,getSessionReplayProperties:au,init:as,setSessionId:aa,shutdown:ad,evaluateTargetingAndCapture:af},this.options=(0,Z.__assign)({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var r,n,i,o,s,a,l,u;return(0,Z.__awaiter)(this,void 0,void 0,function(){var t,c;return(0,Z.__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(ap,".")),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,Z.__assign)((0,Z.__assign)({},e.defaultTracking),{sessions:!0})),t=(void 0===(f=this.config.instanceName)&&(f="$default_instance"),e6.getInstance(f)).identityStore.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!=(r=this.options.deviceId)?r: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==(n=this.config.remoteConfig)?void 0:n.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:ap},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!=(l=this.options.useWebWorker)?l:null==(u=this.options.experimental)?void 0:u.useWebWorker,userProperties:t,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval,captureAdoptedStyleSheets:this.options.captureAdoptedStyleSheets,crossOriginIframes:this.options.crossOriginIframes,flushIntervalConfig:this.options.flushIntervalConfig,eagerFullSnapshotSend:this.options.eagerFullSnapshotSend,captureFullSnapshotOnFocus:this.options.captureFullSnapshotOnFocus,maxPersistedEventsSizeBytes:this.options.maxPer
2sistedEventsSizeBytes,maxSingleEventSizeBytes:this.options.maxSingleEventSizeBytes,sendTimeoutMs:this.options.sendTimeoutMs,handleSendEvents:this.options.handleSendEvents,handleFetchConfig:this.options.handleFetchConfig},[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,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){switch(r.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 r.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__generator)(this,function(r){switch(r.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:r.sent(),r.label=3;case 3:r.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t,r,n;return(0,Z.__awaiter)(this,void 0,void 0,function(){var i,o,s,a,l;return(0,Z.__generator)(this,function(u){switch(u.label){case 0:if(u.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:u.sent(),u.label=2;case 2:o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),o),u.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:u.sent(),u.label=6;case 6:if(!(i&&i===e.session_id))return[3,8];return s=void 0,e.event_type===A.IDENTIFY&&(s=ah(e)),a=(0,eO.getGlobalScope)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:s,page:(null==(r=null==a?void 0:a.location)?void 0:r.href)!=null?{url:a.location.href}:void 0})];case 7:u.sent(),o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,Z.__assign)((0,Z.__assign)({},e.event_properties),o),u.label=8;case 8:return e.event_type===A.IDENTIFY&&e.event_properties&&delete e.event_properties[av],[2,Promise.resolve(e)];case 9:return l=u.sent(),null==(n=this.config)||n.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(l.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return(0,Z.__awaiter)(this,void 0,void 0,function(){return(0,Z.__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}();e.s(["sessionReplayPlugin",0,function(e){return new am(e)}],359861)},461316,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({html:e,height:t=null,width:r=null,children:o,dataNtpc:s=""}){return(0,i.useEffect)(()=>{s&&performance.mark("mark_feature_usage",{detail:{feature:`next-third-parties-${s}`}})},[s]),(0,n.jsxs)(n.Fragment,{children:[o,e?(0,n.jsx)("div",{style:{height:null!=t?`${t}px`:"auto",width:null!=r?`${r}px`:"auto"},"data-ntpc":s,dangerouslySetInnerHTML:{__html:e}}):null]})};let n=e.r(843476),i=e.r(271645)},654576,(e,t,r)=>{"use strict";let n;
2var i=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleAnalytics=function(e){let{gaId:t,debugMode:r,dataLayerName:i="dataLayer",nonce:l}=e;return void 0===n&&(n=i),(0,s.useEffect)(()=>{performance.mark("mark_feature_usage",{detail:{feature:"next-third-parties-ga"}})},[]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.default,{id:"_next-ga-init",dangerouslySetInnerHTML:{__html:` 3 window['${i}'] = window['${i}'] || []; 4 function gtag(){window['${i}'].push(arguments);} 5 gtag('js', new Date()); 6 7 gtag('config', '${t}' ${r?",{ 'debug_mode': true }":""});`},nonce:l}),(0,o.jsx)(a.default,{id:"_next-ga",src:`https://www.googletagmanager.com/gtag/js?id=${t}`,nonce:l})]})},r.sendGAEvent=function(){void 0===n?console.warn("@next/third-parties: GA has not been initialized"):window[n]?window[n].push(arguments):console.warn(`@next/third-parties: GA dataLayer ${n} does not exist`)};let o=e.r(843476),s=e.r(271645),a=i(e.r(3303))},667345,(e,t,r)=>{"use strict";var n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){let{apiKey:t,...r}=e,n={...r,key:t},{html:a}=(0,o.GoogleMapsEmbed)(n);return(0,i.jsx)(s.default,{height:n.height||null,width:n.width||null,html:a,dataNtpc:"GoogleMapsEmbed"})};let i=e.r(843476),o=e.r(981498),s=n(e.r(461316))},19598,(e,t,r)=>{"use strict";var n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.sendGTMEvent=void 0,r.GoogleTagManager=function(e){let{gtmId:t,gtmScriptUrl:r,dataLayerName:n="dataLayer",auth:l,preview:u,dataLayer:c,nonce:d}=e;a=n;let f=new URL(r||"https://www.googletagmanager.com/gtm.js");return t&&f.searchParams.set("id",t),"dataLayer"!==n&&f.searchParams.set("l",n),l&&f.searchParams.set("gtm_auth",l),u&&(f.searchParams.set("gtm_preview",u),f.searchParams.set("gtm_cookies_win","x")),(0,o.useEffect)(()=>{performance.mark("mark_feature_usage",{detail:{feature:"next-third-parties-gtm"}})},[]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.default,{id:"_next-gtm-init",dangerouslySetInnerHTML:{__html:` 8 (function(w,l){ 9 w[l]=w[l]||[]; 10 w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); 11 ${c?`w[l].push(${JSON.stringify(c)})`:""} 12 })(window,'${n}');`},nonce:d}),(0,i.jsx)(s.default,{id:"_next-gtm","data-ntpc":"GTM",src:f.href,nonce:d})]})};let i=e.r(843476),o=e.r(271645),s=n(e.r(3303)),a="dataLayer";r.sendGTMEvent=(e,t)=>{let r=t||a;window[r]=window[r]||[],window[r].push(e)}},387644,(e,t,r)=>{"use strict";var n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.sendGAEvent=r.GoogleAnalytics=r.sendGTMEvent=r.GoogleTagManager=r.YouTubeEmbed=r.GoogleMapsEmbed=void 0;var i=e.r(667345);Object.defineProperty(r,"GoogleMapsEmbed",{enumerable:!0,get:function(){return n(i).default}});var o=e.r(621783);Object.defineProperty(r,"YouTubeEmbed",{enumerable:!0,get:function(){return n(o).default}});var s=e.r(19598);Object.defineProperty(r,"GoogleTagManager",{enumerable:!0,get:function(){return s.GoogleTagManager}}),Object.defineProperty(r,"sendGTMEvent",{enumerable:!0,get:function(){return s.sendGTMEvent}});var a=e.r(654576);Object.defineProperty(r,"GoogleAnalytics",{enumerable:!0,get:function(){return a.GoogleAnalytics}}),Object.defineProperty(r,"sendGAEvent",{enumerable:!0,get:function(){return a.sendGAEvent}})},621783,(e,t,r)=>{"use strict";var n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){let{html:t,scripts:r,stylesheets:n}=(0,s.YouTubeEmbed)(e);return(0,i.jsx)(a.default,{height:e.height||null,width:e.width||null,html:t,dataNtpc:"YouTubeEmbed",children:null==r?void 0:r.map(e=>(0,i.jsx)(o.default,{src:e.url,strategy:l[e.strategy],stylesheets:n},e.url))})};
12let i=e.r(843476),o=n(e.r(3303)),s=e.r(981498),a=n(e.r(461316)),l={server:"beforeInteractive",client:"afterInteractive",idle:"lazyOnload",worker:"worker"}},3303,(e,t,r)=>{t.exports=e.r(479520)},422284,(e,t,r)=>{var n=Object.prototype.hasOwnProperty;function i(e){return"[Throws: "+(e?e.message:"?")+"]"}function o(e){var t=[];return function e(r){if(null===r||"object"!=typeof r)return r;if(-1!==t.indexOf(r))return"[Circular]";if(t.push(r),"function"==typeof r.toJSON)try{var o=e(r.toJSON());return t.pop(),o}catch(e){return i(e)}if(Array.isArray(r)){var s=r.map(e);return t.pop(),s}var a=Object.keys(r).reduce(function(t,o){return t[o]=e(function(e,t){if(n.call(e,t))try{return e[t]}catch(e){return i(e)}return e[t]}(r,o)),t},{});return t.pop(),a}(e)}t.exports=function(e,t,r){return JSON.stringify(o(e),t,r)},t.exports.ensureProperties=o},460953,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Observable=void 0;let n=e=>!!Symbol[e],i=e=>n(e)?Symbol[e]:"@@"+e,o=i("iterator"),s=i("observable"),a=i("species");function l(e,t){let r=e[t];if(null!=r){if("function"!=typeof r)throw TypeError(r+" is not a function");return r}}function u(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=l(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,r){e._state="running";let n=e._observer;try{let i=l(n,t);switch(t){case"next":i&&i.call(n,r);break;case"error":if(g(e),i)i.call(n,r);else throw r;break;case"complete":g(e),i&&i.call(n)}}catch(e){c(e)}"closed"===e._state?f(e):"running"===e._state&&(e._state="ready")}function p(e,t,r){if("closed"!==e._state){if("buffering"===e._state)return void e._queue.push({type:t,value:r});if("ready"!==e._state){e._state="buffering",e._queue=[{type:t,value:r}],d(()=>(function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let r=0;r<t.length&&(h(e,t[r].type,t[r].value),"closed"!==e._state);++r);}})(e));return}h(e,t,r)}}class v{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let r=this,n={get closed(){return"closed"===r._state},next(e){p(r,"next",e)},error(e){p(r,"error",e)},complete(){p(r,"complete")}};try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(g(this),f(this))}}class m{constructor(e){if(!(this instanceof m))throw TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return("object"!=typeof e||null===e)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new v(e,this._subscriber)}forEach(e){return new Promise((t,r)=>{if("function"!=typeof e)return void r(TypeError(e+" is not a function"));function n(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,n)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t})})}map(e){if("function"!=typeof e)throw TypeError(e+" is not a function");return new(u(this))(t=>this.subscribe({next(r){try{r=e(r)}catch(e){return t.error(e)}t.next(r)},error(e){t.error(e)},complete(){t.complete()}}))}filter(e){if("function"!=typeof e)throw TypeError(e+" is not a function");return new(u(this))(t=>this.subscribe({next(r){try{if(!e(r))return}catch(e){return t.error(e)}t.next(r)},error(e){t.error(e)},complete(){t.complete()}}))}reduce(e){if("function"!=typeof e)throw TypeError(e+" is not a function");let t=u(this),r=arguments.length>1,n=!1,i=arguments[1],o=i;return new t(t=>this.subscribe({next(i){let s=!n;if(n=!0,!s||r)try{o=e(o,i)}catch(e){return t.error(e)}else o=i},error(e){t.error(e)},complete(){if(!n&&!r)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(...e){let t=u(this);return new t(r=>{let n,i=0;return!function o(s){n=s.subscribe({next(e){r.next(e)},error(e){r.error(e)},complete(){i===e.length?(n=void 0,r.complete()):o(t.from(e[i++]))}})}(this),()=>{n&&(n.unsubscribe(),n=void 0)}})}flatMap(e){if("function"!=typeof e)throw TypeError(e+" is not a function");let t=u(this);return new t(r=>{let n=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return r.error(e)}let s=t.from(i).subscribe({next(e){r.next(e)},error(e){r.error(e)},complete(){let e=n.indexOf(s);e>=0&&n.splice(e,1),o()}});n.push(s)},error(e){r.error(e)},complete(){o()}});function o(){i.closed&&0===n.length&&r.complete()}return()=>
12{n.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 r=l(e,s);if(r){let n=r.call(e);if(Object(n)!==n)throw TypeError(n+" is not an object");return n instanceof m&&n.constructor===t?n:new t(e=>n.subscribe(e))}if(n("iterator")&&(r=l(e,o)))return new t(t=>{d(()=>{if(!t.closed){for(let n of r.call(e))if(t.next(n),t.closed)return;t.complete()}})});if(Array.isArray(e))return new t(t=>{d(()=>{if(!t.closed){for(let r=0;r<e.length;++r)if(t.next(e[r]),t.closed)return;t.complete()}})});throw TypeError(e+" is not observable")}static of(...e){return new("function"==typeof this?this:m)(t=>{d(()=>{if(!t.closed){for(let r=0;r<e.length;++r)if(t.next(e[r]),t.closed)return;t.complete()}})})}static get[a](){return this}}r.Observable=m,Object.defineProperty(m,Symbol("extensions"),{value:{symbol:s,hostReportError:c},configurable:!0})},881243,(e,t,r)=>{t.exports=e.r(460953).Observable},84297,(e,t,r)=>{t.exports={id:"google-analytics",description:"Install a Google Analytics tag on your website",website:"https://analytics.google.com/analytics/web/",scripts:[{url:"https://www.googletagmanager.com/gtag/js",params:["id"],strategy:"worker",location:"head",action:"append"},{code:"window.dataLayer=window.dataLayer||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};gtag('js',new Date());gtag('config','${args.id}')",strategy:"worker",location:"head",action:"append"}]}},892135,(e,t,r)=>{"use strict";function n(e,t,r=!1){return t?Object.keys(e).filter(e=>r?!t.includes(e):t.includes(e)).reduce((t,r)=>(t[r]=e[r],t),{}):{}}function i(e,t,r,n){let i=n&&Object.keys(n).length>0?new URL(Object.values(n)[0],e):new URL(e);return t&&r&&t.forEach(e=>{r[e]&&i.searchParams.set(e,r[e])}),i.toString()}function o(e,t,r,n,o){var s;if(!t)return`<${e}></${e}>`;let a=(null==(s=t.src)?void 0:s.url)?Object.assign(Object.assign({},t),{src:i(t.src.url,t.src.params,n,o)}):t,l=Object.keys(Object.assign(Object.assign({},a),r)).reduce((e,t)=>{let n=null==r?void 0:r[t],i=a[t],o=null!=n?n:i,s=!0===o?t:`${t}="${o}"`;return o?e+` ${s}`:e},"");return`<${e}${l}></${e}>`}Object.defineProperty(r,"__esModule",{value:!0}),r.formatData=r.createHtml=r.formatUrl=void 0,r.formatUrl=i,r.createHtml=o,r.formatData=function(e,t){var r,s,a,l,u;let c=n(t,null==(r=e.scripts)?void 0:r.reduce((e,t)=>[...e,...Array.isArray(t.params)?t.params:[]],[])),d=n(t,null==(a=null==(s=e.html)?void 0:s.attributes.src)?void 0:a.params),f=n(t,[null==(u=null==(l=e.html)?void 0:l.attributes.src)?void 0:u.slugParam]),g=n(t,[...Object.keys(c),...Object.keys(d),...Object.keys(f)],!0);return Object.assign(Object.assign({},e),{html:e.html?o(e.html.element,e.html.attributes,g,d,f):null,scripts:e.scripts?e.scripts.map(e=>Object.assign(Object.assign({},e),{url:i(e.url,e.params,c)})):null})}},344602,(e,t,r)=>{"use strict";var n=e.e&&e.e.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},i=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleAnalytics=void 0;let o=i(e.r(84297)),s=e.r(892135);r.GoogleAnalytics=e=>{var t=n(e,[]);return(0,s.formatData)(o.default,t)}},560262,(e,t,r)=>{t.exports={id:"google-maps-embed",description:"Embed a Google Maps embed on your webpage",website:"https://developers.google.com/maps/documentation/embed/get-started",html:{element:"iframe",attributes:{loading:"lazy",src:{url:"https://www.google.com/maps/embed/v1/place",slugParam:"mode",params:["key","q","center","zoom","maptype","language","region"]},referrerpolicy:"no-referrer-when-downgrade",frameborder:"0",style:"border:0",allowfullscreen:!0,width:null,height:null}}}},277813,(e,t,r)=>{"use strict";var n=e.e&&e.e.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}
12,i=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleMapsEmbed=void 0;let o=i(e.r(560262)),s=e.r(892135);r.GoogleMapsEmbed=e=>{var t=n(e,[]);return(0,s.formatData)(o.default,t)}},640674,(e,t,r)=>{t.exports={id:"youtube-embed",description:"Embed a YouTube embed on your webpage.",website:"https://github.com/paulirish/lite-youtube-embed",html:{element:"lite-youtube",attributes:{videoid:null,playlabel:null}},stylesheets:["https://cdn.jsdelivr.net/gh/paulirish/lite-youtube-embed@master/src/lite-yt-embed.css"],scripts:[{url:"https://cdn.jsdelivr.net/gh/paulirish/lite-youtube-embed@master/src/lite-yt-embed.js",strategy:"idle",location:"head",action:"append"}]}},515465,(e,t,r)=>{"use strict";var n=e.e&&e.e.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},i=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.YouTubeEmbed=void 0;let o=i(e.r(640674)),s=e.r(892135);r.YouTubeEmbed=e=>{var t=n(e,[]);return(0,s.formatData)(o.default,t)}},981498,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.YouTubeEmbed=r.GoogleMapsEmbed=r.GoogleAnalytics=void 0;var n=e.r(344602);Object.defineProperty(r,"GoogleAnalytics",{enumerable:!0,get:function(){return n.GoogleAnalytics}});var i=e.r(277813);Object.defineProperty(r,"GoogleMapsEmbed",{enumerable:!0,get:function(){return i.GoogleMapsEmbed}});var o=e.r(515465);Object.defineProperty(r,"YouTubeEmbed",{enumerable:!0,get:function(){return o.YouTubeEmbed}})}]); 13 14//# debugId=a7a14db5-3edd-fca9-899f-2712503b1678
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.