1import{a as Dn}from"./chunk-4DJQCJHE.js";import{a as Yt,b as Ul,c as Ml,d as Qt,e as le,f as Pn,g as Fl,h as Cr,i as Gl,j as ct,k as Bl,l as ko,m as Vl,n as Kl,o as Hl,p as Wl,r as ql,s as Xl,t as jl}from"./chunk-2FG6YCVK.js";import{a as Ae,b as T,c as nt,d as y,e as b,f as C,g as w,h as F}from"./chunk-IZQOVDKO.js";import{a as rt,b as Oo,d as wn,e as em,f as Ln,g as Ar}from"./chunk-6IZLXKZM.js";var vc=wn((Wb,$o)=>{var nm=Object.prototype.hasOwnProperty;function dc(t){return"[Throws: "+(t?t.message:"?")+"]"}function im(t,e){if(nm.call(t,e))try{return t[e]}catch(r){return dc(r)}return t[e]}function fc(t){var e=[];function r(n){if(n===null||typeof n!="object")return n;if(e.indexOf(n)!==-1)return"[Circular]";if(e.push(n),typeof n.toJSON=="function")try{var i=r(n.toJSON());return e.pop(),i}catch(s){return dc(s)}if(Array.isArray(n)){var o=n.map(r);return e.pop(),o}var a=Object.keys(n).reduce(function(s,u){return s[u]=r(im(n,u)),s},{});return e.pop(),a}return r(t)}$o.exports=function(t,e,r){return JSON.stringify(fc(t),e,r)};$o.exports.ensureProperties=fc});var wc=wn($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.Observable=void 0;var xc=t=>!!Symbol[t],ya=t=>xc(t)?Symbol[t]:"@@"+t,Pm=ya("iterator"),_a=ya("observable"),Ac=ya("species");function zn(t,e){let r=t[e];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function Br(t){let e=t.constructor;return e!==void 0&&(e=e[Ac],e===null&&(e=void 0)),e!==void 0?e:tr}function Dm(t){return t instanceof tr}function er(t){er.log?er.log(t):setTimeout(()=>{throw t})}function jn(t){Promise.resolve().then(()=>{try{t()}catch(e){er(e)}})}function Cc(t){let e=t._cleanup;if(e!==void 0&&(t._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{let r=zn(e,"unsubscribe");r&&r.call(e)}}catch(r){er(r)}}function ba(t){t._observer=void 0,t._queue=void 0,t._state="closed"}function Om(t){let e=t._queue;if(e){t._queue=void 0,t._state="ready";for(let r=0;r<e.length&&(Rc(t,e[r].type,e[r].value),t._state!=="closed");++r);}}function Rc(t,e,r){t._state="running";let n=t._observer;try{let i=zn(n,e);switch(e){case"next":i&&i.call(n,r);break;case"error":if(ba(t),i)i.call(n,r);else throw r;break;case"complete":ba(t),i&&i.call(n);break}}catch(i){er(i)}t._state==="closed"?Cc(t):t._state==="running"&&(t._state="ready")}function Ea(t,e,r){if(t._state!=="closed"){if(t._state==="buffering"){t._queue.push({type:e,value:r});return}if(t._state!=="ready"){t._state="buffering",t._queue=[{type:e,value:r}],jn(()=>Om(t));return}Rc(t,e,r)}}var Sa=class{constructor(e,r){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,i={get closed(){return n._state==="closed"},next(o){Ea(n,"next",o)},error(o){Ea(n,"error",o)},complete(){Ea(n,"complete")}};try{this._cleanup=r.call(void 0,i)}catch(o){i.error(o)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(ba(this),Cc(this))}},tr=class t{constructor(e){if(!(this instanceof t))throw new TypeError("Observable cannot be called as a function");if(typeof e!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return(typeof e!="object"||e===null)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new Sa(e,this._subscriber)}forEach(e){return new Promise((r,n)=>{if(typeof e!="function"){n(new TypeError(e+" is not a function"));return}function i(){o.unsubscribe(),r()}let o=this.subscribe({next(a){try{e(a,i)}catch(s){n(s),o.unsubscribe()}},error:n,complete:r})})}map(e){if(typeof e!="function")throw new TypeError(e+" is not a function");let r=Br(this);return new r(n=>this.subscribe({next(i){try{i=e(i)}catch(o){return n.error(o)}n.next(i)},error(i){n.error(i)},complete(){n.complete()}}))}filter(e){if(typeof e!="function")throw new TypeError(e+" is not a function");let r=Br(this);return new r(n=>this.subscribe({next(i){try{if(!e(i))return}catch(o){return n.error(o)}n.next(i)},error(i){n.error(i)},complete(){n.complete()}}))}reduce(e){if(typeof e!="function")throw new TypeError(e+" is not a function");let r=Br(this),n=arguments.length>1,i=!1,a=arguments[1];return new r(s=>this.subscribe({next(u){let c=!i;if(i=!0,!c||n)try{a=e(a,u)}catch(l){return s.error(l)}else a=u},error(u){s.error(u)},complete(){if(!i&&!n)return s.error(new TypeError("Cannot reduce an empty sequence"));s.next(a),s.complete()}}))}all(){return Ar(this,null,function*(){let e=[];return yield this.forEach(r=>e.push(r)),e})}concat(...e){let r=Br(this);return new r(n=>{let i,o=0;function a(s){i=s.subscribe({next(u){n.next(u)},error(u){n.error(u)},complete(){o===e.length?(i=void 0,n.complete()):a(r.from(e[o++]))}})}return a(this),()=>{i&&(i.unsubscribe(),i=void 0)}})}flatMap(e){if(typeof e!="function")throw new TypeError(e+" is not a function");let r=Br(this);return new r(n=>{let i=[],o=this.subscribe({next(s){if(e)try{s=e(s)}catch(c){return n.error(c)}let u=r.from(s).subscribe({next(c){n.next(c)},error(c){n.error(c)},complete(){let c=i.indexOf(u);c>=0&&i.splice(c,1),a()}});i.push(u)},error(s){n.error(s)},complete(){a()}});function a(){o.closed&&i.length===0&&n.complete()}return()=>
1{i.forEach(s=>s.unsubscribe()),o.unsubscribe()}})}[_a](){return this}static from(e){let r=typeof this=="function"?this:t;if(e==null)throw new TypeError(e+" is not an object");let n=zn(e,_a);if(n){let i=n.call(e);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Dm(i)&&i.constructor===r?i:new r(o=>i.subscribe(o))}if(xc("iterator")&&(n=zn(e,Pm),n))return new r(i=>{jn(()=>{if(!i.closed){for(let o of n.call(e))if(i.next(o),i.closed)return;i.complete()}})});if(Array.isArray(e))return new r(i=>{jn(()=>{if(!i.closed){for(let o=0;o<e.length;++o)if(i.next(e[o]),i.closed)return;i.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){let r=typeof this=="function"?this:t;return new r(n=>{jn(()=>{if(!n.closed){for(let i=0;i<e.length;++i)if(n.next(e[i]),n.closed)return;n.complete()}})})}static get[Ac](){return this}};$n.Observable=tr;Object.defineProperty(tr,Symbol("extensions"),{value:{symbol:_a,hostReportError:er},configurable:!0})});var Ta=wn((Vy,Lc)=>{Lc.exports=wc().Observable});var Pg=wn((An,Co)=>{(function(t,e){"use strict";var r="0.7.33",n="",i="?",o="function",a="undefined",s="object",u="string",c="major",l="model",f="name",d="type",v="vendor",p="version",h="architecture",g="console",m="mobile",E="tablet",_="smarttv",S="wearable",x="embedded",I=350,A="Amazon",D="Apple",k="ASUS",U="BlackBerry",R="Browser",O="Chrome",P="Edge",N="Firefox",G="Google",M="Huawei",V="LG",X="Microsoft",H="Motorola",Y="Opera",L="Samsung",W="Sharp",K="Sony",z="Xiaomi",$="Zebra",te="Facebook",Q=function(J,ie){var Z={};for(var me in J)ie[me]&&ie[me].length%2===0?Z[me]=ie[me].concat(J[me]):Z[me]=J[me];return Z},ae=function(J){for(var ie={},Z=0;Z<J.length;Z++)ie[J[Z].toUpperCase()]=J[Z];return ie},ne=function(J,ie){return typeof J===u?B(ie).indexOf(B(J))!==-1:!1},B=function(J){return J.toLowerCase()},ge=function(J){return typeof J===u?J.replace(/[^\d\.]/g,n).split(".")[0]:e},ce=function(J,ie){if(typeof J===u)return J=J.replace(/^\s\s*/,n),typeof ie===a?J:J.substring(0,I)},ue=function(J,ie){for(var Z=0,me,ee,At,de,lt,He;Z<ie.length&&!lt;){var Do=ie[Z],re=ie[Z+1];for(me=ee=0;me<Do.length&&!lt;)if(lt=Do[me++].exec(J),lt)for(At=0;At<re.length;At++)He=lt[++ee],de=re[At],typeof de===s&&de.length>0?de.length===2?typeof de[1]==o?this[de[0]]=de[1].call(this,He):this[de[0]]=de[1]:de.length===3?typeof de[1]===o&&!(de[1].exec&&de[1].test)?this[de[0]]=He?de[1].call(this,He,de[2]):e:this[de[0]]=He?He.replace(de[1],de[2]):e:de.length===4&&(this[de[0]]=He?de[3].call(this,He.replace(de[1],de[2])):e):this[de]=He||e;Z+=2}},j=function(J,ie){for(var Z in ie)if(typeof ie[Z]===s&&ie[Z].length>0){for(var me=0;me<ie[Z].length;me++)if(ne(ie[Z][me],J))return Z===i?e:Z}else if(ne(ie[Z],J))return Z===i?e:Z;return J},Le={"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},Ne={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},Ge={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[p,[f,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[p,[f,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[f,p],[/opios[\/ ]+([\w\.]+)/i],[p,[f,Y+" Mini"]],[/\bopr\/([\w\.]+)/i],[p,[f,Y]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[f,p],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[p,[f,"UC"+R]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[p,[f,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[p,[f,"WeChat"]],[/konqueror\/([\w\.]+)/i],[p,[f,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[p,[f,"IE"]],[/yabrowser\/([\w\.]+)/i],[p,[f,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[f,/(.+)/,"$1 Secure "+R],p],[/\bfocus\/([\w\.]+)/i],[p,[f,N+" Focus"]],[/\bopt\/([\w\.]+)/i],[p,[f,Y+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[p,[f,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[p,[f,"Dolphin"]],[/coast\/([\w\.]+)/i],[p,[f,Y+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[p,[f,"MIUI "+R]],[/fxios\/([-\w\.]+)/i],[p,[f,N]],[/\bqihu|(qi?ho?o?|360)browser/i],[[f,"360 "+R]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[f,/(.+)/,"$1 "+R],p],[/(comodo_dragon)\/([\w\.]+)/i],[[f,/_/g," "],p],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[f,p],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[f],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[f,te],p],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[f,p],[/\bgsa\/([\w\.]+) .*safari\//i],[p,[f,"GSA"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[p,[f,O+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[f,O+" WebView"],p],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[p,[f,"Android "+R]],[/(chrome|omniweb|arora|[t
vendor: 4,749 bytes, line 1
1izenoka]{5} ?browser)\/v?([\w\.]+)/i],[f,p],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[p,[f,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[p,f],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[f,[p,j,Le]],[/(webkit|khtml)\/([\w\.]+)/i],[f,p],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[f,"Netscape"],p],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[p,[f,N+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[f,p],[/(cobalt)\/([\w\.]+)/i],[f,[p,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,B]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[h,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[h,"armhf"]],[/windows (ce|mobile); ppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[h,/ower/,n,B]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[h,B]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[l,[v,L],[d,E]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[l,[v,L],[d,m]],[/((ipod|iphone)\d+,\d+)/i],[l,[v,D],[d,m]],[/(ipad\d+,\d+)/i],[l,[v,D],[d,E]],[/\((ip(?:hone|od)[\w ]*);/i],[l,[v,D],[d,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[l,[v,D],[d,E]],[/(macintosh);/i],[l,[v,D]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[l,[v,M],[d,E]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[l,[v,M],[d,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[l,/_/g," "],[v,z],[d,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[l,/_/g," "],[v,z],[d,E]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[l,[v,"OPPO"],[d,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[l,[v,"Vivo"],[d,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[l,[v,"Realme"],[d,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[l,[v,H],[d,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[l,[v,H],[d,E]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[l,[v,V],[d,E]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[l,[v,V],[d,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[l,[v,"Lenovo"],[d,E]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[l,/_/g," "],[v,"Nokia"],[d,m]],[/(pixel c)\b/i],[l,[v,G],[d,E]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[l,[v,G],[d,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[l,[v,K],[d,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[l,"Xperia Tablet"],[v,K],[d,E]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[l,[v,"OnePlus"],[d,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[l,[v,A],[d,E]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[l,/(.+)/g,"Fire Phone $1"],[v,A],[d,m]],[/(playbook);[-\w\),; ]+(rim)/i],[l,v,[d,E]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[l,[v,U],[d,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[l,[v,k],[d,E]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[l,[v,k],[d,m]],[/(nexus 9)/i],[l,[v,"HTC"],[d,E]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i],[v,[l,/_/g," "],[d,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[l,[v,"Acer"],[d,E]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[l,[v,"Meizu"],[d,m]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[l,[v,W],[d,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asu
vendor: 4,230 bytes, line 1
1s)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[v,l,[d,m]],[/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[v,l,[d,E]],[/(surface duo)/i],[l,[v,X],[d,E]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[l,[v,"Fairphone"],[d,m]],[/(u304aa)/i],[l,[v,"AT&T"],[d,m]],[/\bsie-(\w*)/i],[l,[v,"Siemens"],[d,m]],[/\b(rct\w+) b/i],[l,[v,"RCA"],[d,E]],[/\b(venue[\d ]{2,7}) b/i],[l,[v,"Dell"],[d,E]],[/\b(q(?:mv|ta)\w+) b/i],[l,[v,"Verizon"],[d,E]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[l,[v,"Barnes & Noble"],[d,E]],[/\b(tm\d{3}\w+) b/i],[l,[v,"NuVision"],[d,E]],[/\b(k88) b/i],[l,[v,"ZTE"],[d,E]],[/\b(nx\d{3}j) b/i],[l,[v,"ZTE"],[d,m]],[/\b(gen\d{3}) b.+49h/i],[l,[v,"Swiss"],[d,m]],[/\b(zur\d{3}) b/i],[l,[v,"Swiss"],[d,E]],[/\b((zeki)?tb.*\b) b/i],[l,[v,"Zeki"],[d,E]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[v,"Dragon Touch"],l,[d,E]],[/\b(ns-?\w{0,9}) b/i],[l,[v,"Insignia"],[d,E]],[/\b((nxa|next)-?\w{0,9}) b/i],[l,[v,"NextBook"],[d,E]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[v,"Voice"],l,[d,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[v,"LvTel"],l,[d,m]],[/\b(ph-1) /i],[l,[v,"Essential"],[d,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[l,[v,"Envizen"],[d,E]],[/\b(trio[-\w\. ]+) b/i],[l,[v,"MachSpeed"],[d,E]],[/\btu_(1491) b/i],[l,[v,"Rotor"],[d,E]],[/(shield[\w ]+) b/i],[l,[v,"Nvidia"],[d,E]],[/(sprint) (\w+)/i],[v,l,[d,m]],[/(kin\.[onetw]{3})/i],[[l,/\./g," "],[v,X],[d,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[l,[v,$],[d,E]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[l,[v,$],[d,m]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[v,l,[d,g]],[/droid.+; (shield) bui/i],[l,[v,"Nvidia"],[d,g]],[/(playstation [345portablevi]+)/i],[l,[v,K],[d,g]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[l,[v,X],[d,g]],[/smart-tv.+(samsung)/i],[v,[d,_]],[/hbbtv.+maple;(\d+)/i],[[l,/^/,"SmartTV"],[v,L],[d,_]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[v,V],[d,_]],[/(apple) ?tv/i],[v,[l,D+" TV"],[d,_]],[/crkey/i],[[l,O+"cast"],[v,G],[d,_]],[/droid.+aft(\w)( bui|\))/i],[l,[v,A],[d,_]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[l,[v,W],[d,_]],[/(bravia[\w ]+)( bui|\))/i],[l,[v,K],[d,_]],[/(mitv-\w{5}) bui/i],[l,[v,z],[d,_]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i],[[v,ce],[l,ce],[d,_]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,_]],[/((pebble))app/i],[v,l,[d,S]],[/droid.+; (glass) \d/i],[l,[v,G],[d,S]],[/droid.+; (wt63?0{2,3})\)/i],[l,[v,$],[d,S]],[/(quest( 2)?)/i],[l,[v,te],[d,S]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[v,[d,x]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[l,[d,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[l,[d,E]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,E]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,m]],[/(android[-\w\. ]{0,9});.+buil/i],[l,[v,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[p,[f,P+"HTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[p,[f,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[f,p],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[p,f]],os:[[/microsoft (windows) (vista|xp)/i],[f,p],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[f,[p,j,Ne]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,"Windows"],[p,j,Ne]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[p,/_/g,"."],[f,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[f,"Mac OS"],[p,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[p,f],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[f,p],[/\(bb(10);
1/i],[p,[f,U]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[p,[f,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[p,[f,N+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[p,[f,"webOS"]],[/crkey\/([\d\.]+)/i],[p,[f,O+"cast"]],[/(cros) [\w]+ ([\w\.]+\w)/i],[[f,"Chromium OS"],p],[/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[f,p],[/(sunos) ?([\w\.\d]*)/i],[[f,"Solaris"],p],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[f,p]]},Re=function(J,ie){if(typeof J===s&&(ie=J,J=e),!(this instanceof Re))return new Re(J,ie).getResult();var Z=J||(typeof t!==a&&t.navigator&&t.navigator.userAgent?t.navigator.userAgent:n),me=ie?Q(Ge,ie):Ge;return this.getBrowser=function(){var ee={};return ee[f]=e,ee[p]=e,ue.call(ee,Z,me.browser),ee.major=ge(ee.version),ee},this.getCPU=function(){var ee={};return ee[h]=e,ue.call(ee,Z,me.cpu),ee},this.getDevice=function(){var ee={};return ee[v]=e,ee[l]=e,ee[d]=e,ue.call(ee,Z,me.device),ee},this.getEngine=function(){var ee={};return ee[f]=e,ee[p]=e,ue.call(ee,Z,me.engine),ee},this.getOS=function(){var ee={};return ee[f]=e,ee[p]=e,ue.call(ee,Z,me.os),ee},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return Z},this.setUA=function(ee){return Z=typeof ee===u&&ee.length>I?ce(ee,I):ee,this},this.setUA(Z),this};Re.VERSION=r,Re.BROWSER=ae([f,p,c]),Re.CPU=ae([h]),Re.DEVICE=ae([l,v,d,g,m,_,E,S,x]),Re.ENGINE=Re.OS=ae([f,p]),typeof An!==a?(typeof Co!==a&&Co.exports&&(An=Co.exports=Re),An.UAParser=Re):typeof define===o&&define.amd?define(function(){return Re}):typeof t!==a&&(t.UAParser=Re);var Ve=typeof t!==a&&(t.jQuery||t.Zepto);if(Ve&&!Ve.ua){var Ke=new Re;Ve.ua=Ke.getResult(),Ve.ua.get=function(){return Ke.getUA()},Ve.ua.set=function(J){Ke.setUA(J);var ie=Ke.getResult();for(var Z in ie)Ve.ua[Z]=ie[Z]}}})(typeof window=="object"?window:An)});var mt=(function(t){return t.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",t})(mt||{}),it=(function(t){return t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount",t})(it||{});var No="-",Jt="AMP",zl="".concat(Jt,"_unsent"),On="$default_instance",Rr="https://api2.amplitude.com/2/httpapi",kn="https://api.eu.amplitude.com/2/httpapi",Nn="https://api2.amplitude.com/batch",Un="https://api.eu.amplitude.com/batch",$l="utm_campaign",Yl="utm_content",Ql="utm_id",Jl="utm_medium",Zl="utm_source",ec="utm_term",Uo="dclid",Mo="fbclid",Fo="gbraid",Go="gclid",Bo="ko_click_id",Vo="li_fat_id",Ko="msclkid",Ho="rdt_cid",Wo="ttclid",qo="twclid",Xo="wbraid";var Ut={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};var tc=["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"];var tm=1e3,Mn=function(t){if(Object.keys(t).length>tm)return!1;for(var e in t){var r=t[e];if(!jo(e,r))return!1}return!0},jo=function(t,e){var r,n;if(typeof t!="string")return!1;if(Array.isArray(e)){var i=!0;try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if(typeof s=="object")i=i&&Mn(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}else{if(e==null)return!1;if(typeof e=="object")return Mn(e);if(!["number","string","boolean"].includes(typeof e))return!1}return!0};var ot=(function(){function t(){this._propertySet=new Set,this._properties={}}return t.prototype.getUserProperties=function(){return T({},this._properties)},t.prototype.set=function(e,r){return this._safeSet(Te.SET,e,r),this},t.prototype.setOnce=function(e,r){return this._safeSet(Te.SET_ONCE,e,r),this},t.prototype.append=function(e,r){return this._safeSet(Te.APPEND,e,r),this},t.prototype.prepend=function(e,r){return this._safeSet(Te.PREPEND,e,r),this},t.prototype.postInsert=function(e,r){return this._safeSet(Te.POSTINSERT,e,r),this},t.prototype.preInsert=function(e,r){return this._safeSet(Te.PREINSERT,e,r),this},t.prototype.remove=function(e,r){return this._safeSet(Te.REMOVE,e,r),this},t.prototype.add=function(e,r){return this._safeSet(Te.ADD,e,r),this},t.prototype.unset=function(e){return this._safeSet(Te.UNSET,e,No),this},t.prototype.clearAll=function(){return this._properties={},this._properties[Te.CLEAR_ALL]=No,this}
1,t.prototype._safeSet=function(e,r,n){if(this._validate(e,r,n)){var i=this._properties[e];return i===void 0&&(i={},this._properties[e]=i),i[r]=n,this._propertySet.add(r),!0}return!1},t.prototype._validate=function(e,r,n){return this._properties[Te.CLEAR_ALL]!==void 0||this._propertySet.has(r)?!1:e===Te.ADD?typeof n=="number":e!==Te.UNSET&&e!==Te.REMOVE?jo(r,n):!0},t})();var Te=(function(t){return t.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",t})(Te||{}),rc=[Te.CLEAR_ALL,Te.UNSET,Te.SET,Te.SET_ONCE,Te.ADD,Te.APPEND,Te.PREPEND,Te.PREINSERT,Te.POSTINSERT,Te.REMOVE];var nc="Event tracked successfully",ic="Unexpected error occurred",oc="Event rejected due to exceeded retry count",ac="Event skipped due to optOut config",zo="Event skipped due to empty event type",sc="Event rejected due to missing API key",uc="Invalid API key",lc="Client not initialized";var Ce=(function(t){return t.Unknown="unknown",t.Skipped="skipped",t.Success="success",t.RateLimit="rate_limit",t.PayloadTooLarge="payload_too_large",t.Invalid="invalid",t.Failed="failed",t.Timeout="Timeout",t.SystemError="SystemError",t})(Ce||{});var dt=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=Ce.Unknown),{event:t,code:e,message:r}};var oe=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var rm=function(t){return t?(t^Math.random()*16>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,We)},cc=F([],w(Array(256).keys()),!1).map(function(t){return t.toString(16).padStart(2,"0")}),We=function(t){var e,r=oe();if(!(!((e=r?.crypto)===null||e===void 0)&&e.getRandomValues))return rm(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,F([],w(n.entries()),!1).map(function(i){var o=w(i,2),a=o[0],s=o[1];return[4,6,8,10].includes(a)?"-".concat(cc[s]):cc[s]}).join("")};var Yo=Ln(vc()),$e=Yo.default||Yo;var pc=(function(){function t(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this.pluginStatus=new Map,this._optOutListeners=[]}return t.prototype.register=function(e,r){var n,i;return y(this,void 0,void 0,function(){var o;return b(this,function(a){switch(a.label){case 0:return e.name===void 0&&(e.name=We(),this.loggerProvider.warn(`Plugin name is undefined. 2 Generating a random UUID for plugin name: `.concat(e.name,`. 3 Set a name for the plugin to prevent it from being added multiple times.`))),o=e.name,this.pluginStatus.has(o)?(this.loggerProvider.warn("Plugin with name ".concat(o," already exists, skipping registration")),[2]):(e.type=(n=e.type)!==null&&n!==void 0?n:"enrichment",this.pluginStatus.set(o,"locked"),[4,(i=e.setup)===null||i===void 0?void 0:i.call(e,r,this.client)]);case 1:return a.sent(),this.pluginStatus.get(o)!=="locked"?[2]:(this.plugins.push(e),this.pluginStatus.set(o,"installed"),[2])}})})},t.prototype.deregister=function(e,r){var n;return y(this,void 0,void 0,function(){var i,o;return b(this,function(a){switch(a.label){case 0:return this.pluginStatus.delete(e),i=this.plugins.findIndex(function(s){return s.name===e}),i===-1?(r.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(o=this.plugins[i],this.plugins.splice(i,1),[4,(n=o.teardown)===null||n===void 0?void 0:n.call(o)]);case 1:return a.sent(),[2]}})})},t.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1;var r=this.plugins;r.map(function(n){var i;return(i=n.teardown)===null||i===void 0?void 0:i.call(n)}),this.plugins=[],this.pluginStatus.clear(),this.client=e},t.prototype.push=function(e){var r=this;return new Promise(function(n){r.queue.push([e,n]),r.scheduleApply(0)})},t.prototype.scheduleApply=function(e){var r=this;this.applying||(this.applying=!0,setTimeout(function(){r.apply(r.queue.shift()).then(function(){r.applying=!1,r.queue.length>0&&r.scheduleApply(0)})},e))},t.prototype.apply=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a,s,u,v,p,c,l,f,d,v,p,h,g,m,E,_,S,x;return b(this,function(I){switch(I.label){case 0:if(!e)return[2];r=w(e,1),n=r[0],i=w(e,2),o=i[1],this.loggerProvider.log("Timeline.apply: Initial event",n),a=this.plugins.filter(function(A){return A.type==="before"}),I.label=1;case 1:I.trys.push([1,6,7,8]),s=C(a),u=s.next(),I.label=2;case 2:return u.done?[3,5]:(v=u.value,v.execute?[4,v.execute(T({},n))]:[3,4]);case 3:if(p=I.sent(),p===null)return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(v.name),"', event: ").concat($e(n))),o({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(v.name),"', event: ").concat($e(n))),I.label=4;case 4:return u=s.next(),[3,2];case 5:return[3,8];case 6:return c=I.sent(),E={error:c},[3,8];case 7:try{u&&!u.done&&(_=s.return)&&_.call(s)}finally{if(E)throw E.error}
3return[7];case 8:l=this.plugins.filter(function(A){return A.type==="enrichment"||A.type===void 0}),I.label=9;case 9:I.trys.push([9,14,15,16]),f=C(l),d=f.next(),I.label=10;case 10:return d.done?[3,13]:(v=d.value,v.execute?[4,v.execute(T({},n))]:[3,12]);case 11:if(p=I.sent(),p===null)return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(v.name),"', event: ").concat($e(n))),o({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(v.name),"', event: ").concat($e(n))),I.label=12;case 12:return d=f.next(),[3,10];case 13:return[3,16];case 14:return h=I.sent(),S={error:h},[3,16];case 15:try{d&&!d.done&&(x=f.return)&&x.call(f)}finally{if(S)throw S.error}return[7];case 16:return g=this.plugins.filter(function(A){return A.type==="destination"}),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat($e(n))),m=g.map(function(A){var D=T({},n);return A.execute(D).catch(function(k){return dt(D,0,String(k))})}),Promise.all(m).then(function(A){var D=w(A,1),k=D[0],U=k||dt(n,100,"Event not tracked, no destination plugins on the instance");o(U)}),[2]}})})},t.prototype.flush=function(){return y(this,void 0,void 0,function(){var e,r,n,i=this;return b(this,function(o){switch(o.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map(function(a){return i.apply(a)}))];case 1:return o.sent(),r=this.plugins.filter(function(a){return a.type==="destination"}),n=r.map(function(a){return a.flush&&a.flush()}),[4,Promise.all(n)];case 2:return o.sent(),[2]}})})},t.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},t.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},t.prototype.onIdentityChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onIdentityChanged)===null||n===void 0||n.call(r,e)})},t.prototype.onSessionIdChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onSessionIdChanged)===null||n===void 0||n.call(r,e)})},t.prototype.onOptOutChanged=function(e){this.plugins.forEach(function(r){var n;(n=r.onOptOutChanged)===null||n===void 0||n.call(r,e)}),this._callOptOutListeners(e)},t.prototype._callOptOutListeners=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a,s,u;return b(this,function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),r=C(this._optOutListeners),n=r.next(),c.label=1;case 1:if(n.done)return[3,6];i=n.value,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,i(e)];case 3:return c.sent(),[3,5];case 4:return o=c.sent(),this.loggerProvider.error("Error calling optOut listener",o),[3,5];case 5:return n=r.next(),[3,1];case 6:return[3,9];case 7:return a=c.sent(),s={error:a},[3,9];case 8:try{n&&!n.done&&(u=r.return)&&u.call(r)}finally{if(s)throw s.error}return[7];case 9:return[2]}})})},t.prototype.onReset=function(){this.plugins.forEach(function(e){var r;(r=e.onReset)===null||r===void 0||r.call(e)})},t})();var hc=function(t,e,r){var n=typeof t=="string"?{event_type:t}:t;return T(T(T({},n),r),e&&{event_properties:e})},Mt=function(t,e){var r=T(T({},e),{event_type:it.IDENTIFY,user_properties:t.getUserProperties()});return r},gc=function(t,e,r,n){var i,o=T(T({},n),{event_type:it.GROUP_IDENTIFY,group_properties:r.getUserProperties(),groups:(i={},i[t]=e,i)});return o},mc=function(t,e,r){var n,i=new ot;i.set(t,e);var o=T(T({},r),{event_type:it.IDENTIFY,user_properties:i.getUserProperties(),groups:(n={},n[t]=e,n)});return o},Ec=function(t,e){return T(T({},e),{event_type:it.REVENUE,event_properties:t.getEventProperties()})};var Pe=function(t){return{promise:t||Promise.resolve()}};var Qo=(function(){function t(e){e===void 0&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new pc(this),this.name=e}return t.prototype._init=function(e){return y(this,void 0,void 0,function(){var r=this;return b(this,function(n){switch(n.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q",function(){return r.isReady=!0})];case 1:return n.sent(),[2]}})})},t.prototype.runQueuedFunctions=function(e,r){return y(this,void 0,void 0,function(){var n,i,o,a,s,u,c,l;return b(this,function(f){switch(f.label){case 0:n=this[e],this[e]=[],f.label=1;case 1:f.trys.push([1,8,9,10]),i=C(n),o=i.next(),f.label=2;case 2:return o.done?[3,7]:(a=o.value,s=a(),s&&"promise"in s?[4,s.promise]:[3,4]);case 3:return f.sent(),[3,6];case 4:return[4,s];case 5:f.sent(),f.label=6;case 6:return o=i.next(),[3,2];case 7:return[3,10];case 8:return u=f.sent(),c={error:u},[3,10];case 9:try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}
3return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e,r)]:[3,12];case 11:return f.sent(),[3,13];case 12:r?.(),f.label=13;case 13:return[2]}})})},t.prototype.track=function(e,r,n){var i=hc(e,r,n);return this.userProperties=this.getOperationAppliedUserProperties(i.user_properties),Pe(this.dispatch(i))},t.prototype.identify=function(e,r){var n=Mt(e,r);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),Pe(this.dispatch(n))},t.prototype.groupIdentify=function(e,r,n,i){var o=gc(e,r,n,i);return Pe(this.dispatch(o))},t.prototype.setGroup=function(e,r,n){var i=mc(e,r,n);return this.userProperties=this.getOperationAppliedUserProperties(i.user_properties),Pe(this.dispatch(i))},t.prototype.revenue=function(e,r){var n=Ec(e,r);return Pe(this.dispatch(n))},t.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),Pe())},t.prototype._addPlugin=function(e){return Pe(this.timeline.register(e,this.config))},t.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),Pe())},t.prototype._removePlugin=function(e){return Pe(this.timeline.deregister(e,this.config))},t.prototype.dispatchWithCallback=function(e,r){if(!this.isReady)return r(dt(e,0,lc));this.process(e).then(r)},t.prototype.dispatch=function(e){return y(this,void 0,void 0,function(){var r=this;return b(this,function(n){return this.isReady?[2,this.process(e)]:[2,new Promise(function(i){r.dispatchQ.push(r.dispatchWithCallback.bind(r,e,i))})]})})},t.prototype.getOperationAppliedUserProperties=function(e){var r,n=(r=this.userProperties)!==null&&r!==void 0?r:{},i=T({},n);if(e===void 0)return i;var o={};return Object.keys(e).forEach(function(a){Object.values(mt).includes(a)||(o[a]=e[a])}),rc.forEach(function(a){if(Object.keys(e).includes(a)){var s=e[a];
3switch(a){case mt.CLEAR_ALL:Object.keys(i).forEach(function(u){delete i[u]});break;case mt.UNSET:Object.keys(s).forEach(function(u){delete i[u]});break;case mt.SET:Object.assign(i,s);break}}}),Object.assign(i,o),i},t.prototype.process=function(e){return y(this,void 0,void 0,function(){var r,o,n,i,o;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),this.config.optOut?[2,dt(e,0,ac)]:(r=e.event_type,typeof r!="string"||r.trim().length===0?(this.config.loggerProvider.error(zo),[2,dt(e,0,zo)]):(e.event_type===it.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]));case 1:return o=a.sent(),o.code===200?this.config.loggerProvider.log(o.message):o.code===100?this.config.loggerProvider.warn(o.message):this.config.loggerProvider.error(o.message),[2,o];case 2:return n=a.sent(),i=String(n),this.config.loggerProvider.error(i),o=dt(e,0,i),[2,o];case 3:return[2]}})})},t.prototype.setOptOut=function(e){if(!this.isReady){this.q.push(this._setOptOut.bind(this,!!e));return}this._setOptOut(e)},t.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=!!e,this.timeline.onOptOutChanged(e))},t.prototype.flush=function(){return Pe(this.timeline.flush())},t.prototype.plugin=function(e){var r=this.timeline.plugins.find(function(n){return n.name===e});if(r===void 0){this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e));return}return r},t.prototype.plugins=function(e){return this.timeline.plugins.filter(function(r){return r instanceof e})},t})();var wr=(function(){function t(){this.productId="",this.quantity=1,this.price=0}return t.prototype.setProductId=function(e){return this.productId=e,this},t.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},t.prototype.setPrice=function(e){return this.price=e,this},t.prototype.setRevenueType=function(e){return this.revenueType=e,this},t.prototype.setCurrency=function(e){return this.currency=e,this},t.prototype.setRevenue=function(e){return this.revenue=e,this},t.prototype.setReceipt=function(e){return this.receipt=e,this},t.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},t.prototype.setEventProperties=function(e){try{var r=JSON.parse(JSON.stringify(e));Mn(r)&&(this.properties=r)}catch(n){}return this},t.prototype.getEventProperties=function(){var e=this.properties?T({},this.properties):{};return e[Ye.REVENUE_PRODUCT_ID]=this.productId,e[Ye.REVENUE_QUANTITY]=this.quantity,e[Ye.REVENUE_PRICE]=this.price,e[Ye.REVENUE_TYPE]=this.revenueType,e[Ye.REVENUE_CURRENCY]=this.currency,e[Ye.REVENUE]=this.revenue,e[Ye.RECEIPT]=this.receipt,e[Ye.RECEIPT_SIG]=this.receiptSig,e},t})();var Ye=(function(t){return t.REVENUE_PRODUCT_ID="$productId",t.REVENUE_QUANTITY="$quantity",t.REVENUE_PRICE="$price",t.REVENUE_TYPE="$revenueType",t.REVENUE_CURRENCY="$currency",t.REVENUE="$revenue",t.RECEIPT="$receipt",t.RECEIPT_SIG="$receiptSig",t})(Ye||{});var _c=function(t,e){var r=Math.max(e,1);return t.reduce(function(n,i,o){var a=Math.floor(o/r);return n[a]||(n[a]=[]),n[a].push(i),n},[])};var we=(function(t){return t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Verbose=3]="Verbose",t[t.Debug=4]="Debug",t})(we||{});var Fn="Amplitude Logger ",Ft=(function(){function t(){this.logLevel=we.None}return t.prototype.disable=function(){this.logLevel=we.None},t.prototype.enable=function(e){e===void 0&&(e=we.Warn),this.logLevel=e},t.prototype.log=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<we.Verbose||console.log("".concat(Fn,"[Log]: ").concat(e.join(" ")))},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<we.Warn||console.warn("".concat(Fn,"[Warn]: ").concat(e.join(" ")))},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<we.Error||console.error("".concat(Fn,"[Error]: ").concat(e.join(" ")))},t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];this.logLevel<we.Debug||console.log("".concat(Fn,"[Debug]: ").concat(e.join(" ")))},t})();var Gn=function(t){return t===void 0||t===""?On:t};var Bn=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:On,logLevel:we.Warn,loggerProvider:new Ft,offline:!1,optOut:!1,serverUrl:Rr,serverZone:"US",useBatch:!1}},Jo=(function(){function t(e){var r,n,i,o;this._optOut=!1;var a=Bn();this.apiKey=e.apiKey,this.flushIntervalMillis=(r=e.flushIntervalMillis)!==null&&r!==void 0?r:a.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||a.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||a.flushQueueSize,this.instanceName=Gn(e.instanceName),this.loggerProvider=e.loggerProvider||a.loggerProvider,this.logLevel=(n=e.logLevel)!==null&&n!==void 0?n:a.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=e.offline!==void 0?e.offline:a.offline,this.optOut=(i=e.optOut)!==null&&i!==void 0?i:a.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||a.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=(o=e.useBatch)!==null&&o!==void 0?o:a.useBatch,this.loggerProvider.enable(this.logLevel);var s=Zo(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e}
3,enumerable:!1,configurable:!0}),t})();var om=function(t,e){return t==="EU"?e?Un:kn:e?Nn:Rr},Zo=function(t,e,r){if(t===void 0&&(t=""),e===void 0&&(e=Bn().serverZone),r===void 0&&(r=Bn().useBatch),t)return{serverUrl:t,serverZone:void 0};var n=["US","EU"].includes(e)?e:Bn().serverZone;return{serverZone:n,serverUrl:om(n,r)}},ea=(function(){function t(){this.sdk={metrics:{histogram:{}}}}return t.prototype.recordHistogram=function(e,r){this.sdk.metrics.histogram[e]=r},t})();function Lr(t){return t>=200&&t<300}var Pr=function(t){t===void 0&&(t=0);var e=new Error().stack||"";return e.split(` 4`).slice(2+t).map(function(r){return r.trim()})},be=function(t){return function(){var e=T({},t.config),r=e.loggerProvider,n=e.logLevel;return{logger:r,logLevel:n}}},am=function(t,e){var r,n;e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,"");try{for(var i=C(e.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(a in t)t=t[a];else return}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t},Se=function(t,e){return function(){var r,n,i={};try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=am(t,s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}},ye=function(t,e,r,n,i){return i===void 0&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=r(),u=s.logger,c=s.logLevel;if(c&&c<we.Debug||!c||!u)return t.apply(i,o);var l={type:"invoke public method",name:e,args:o,stacktrace:Pr(1),time:{start:new Date().toISOString()},states:{}};n&&l.states&&(l.states.before=n());var f=t.apply(i,o);return f&&f.promise?f.promise.then(function(){n&&l.states&&(l.states.after=n()),l.time&&(l.time.end=new Date().toISOString()),u.debug(JSON.stringify(l,null,2))}):(n&&l.states&&(l.states.after=n()),l.time&&(l.time.end=new Date().toISOString()),u.debug(JSON.stringify(l,null,2))),f}};var sm=new Set([Rr,kn,Nn,Un]),um=function(t,e){return e===void 0&&(e=!1),sm.has(t)?!0:e};function lm(t){return t instanceof Error?t.message:String(t)}function Dr(t){var e="";try{"body"in t&&(e=JSON.stringify(t.body,null,2))}catch(r){}return e}var ta=(function(){function t(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=e?.diagnosticsClient}return t.prototype.setup=function(e){var r;return y(this,void 0,void 0,function(){var n,i=this;return b(this,function(o){switch(o.label){case 0:return this.config=e,this.storageKey="".concat(zl,"_").concat(this.config.apiKey.substring(0,10)),[4,(r=this.config.storageProvider)===null||r===void 0?void 0:r.get(this.storageKey)];case 1:return n=o.sent(),n&&n.length>0&&Promise.all(n.map(function(a){return i.execute(a)})).catch(),[2,Promise.resolve(void 0)]}})})},t.prototype.execute=function(e){var r=this;return e.insert_id||(e.insert_id=We()),new Promise(function(n){var i={event:e,attempts:0,callback:function(o){return n(o)},timeout:0};r.queue.push(i),r.schedule(r.config.flushIntervalMillis),r.saveEvents()})},t.prototype.removeEventsExceedFlushMaxRetries=function(e){var r=this;return e.filter(function(n){return n.attempts+=1,n.attempts<r.config.flushMaxRetries?!0:(r.fulfillRequest([n],500,oc),!1)})},t.prototype.scheduleEvents=function(e){var r=this;e.forEach(function(n){r.schedule(n.timeout===0?r.config.flushIntervalMillis:n.timeout)})},t.prototype.schedule=function(e){var r=this;if(!this.config.offline&&(this.scheduleId===null||this.scheduleId&&e>this.scheduledTimeout)){this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,this.scheduleId=setTimeout(function(){r.queue=r.queue.map(function(n){return n.timeout=0,n}),r.flush(!0)},e);return}},t.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},t.prototype.flush=function(e){return e===void 0&&(e=!1),y(this,void 0,void 0,function(){var r,n,i,o=this;return b(this,function(a){switch(a.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),r=[],n=[],this.queue.forEach(function(s){return s.timeout===0?r.push(s):n.push(s)}),i=_c(r,this.config.flushQueueSize),[4,i.reduce(function(s,u){return y(o,void 0,void 0,function(){return b(this,function(c){switch(c.label){case 0:return[4,s];case 1:return c.sent(),[4,this.send(u,e)];case 2:return[2,c.sent()]}})})},Promise.resolve())]);case 1:return a.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}})})},t.prototype.send=function(e,r){var n;return r===void 0&&(r=!0),y(this,void 0,void 0,function(){var i,o,a,s,u,c;return b(this,function(l){switch(l.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,sc)];i={api_key:this.config.apiKey,events:e.map(function(f){var d=f.event,v=d.extra,p=nt(d,["extra"]);return p}),options:{min_id_length:this.config.minIdLength},client_upload_time:new Date().toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new ea,l.label=1;case 1:return l.trys.push([1,3,,4]),o=Zo(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,a=um(o,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(o,i,a)];case 2:return s=l.sent(),s===null?(this.fulfillRequest(e,0,ic),[2]):r?(this.handleResponse(s,e),[3,4]):("body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(Dr(s))):this.fulfillRequest(e,s.statusCode,s.status),[2]);case 3:return u=l.sent(),c=lm(u),this.config.loggerProvider.error(c),(n=this.diagnosticsClient)===null||n===void 0||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map(function(f){return f.event.event_type}),message:c,stack_trace:Pr()}),this.handleResponse({status:Ce.Failed,statusCode:0},e),[3,4];case 4:return[2]}})})},t.prototype.handleResponse=function(e,r){var n;Lr(e.statusCode)||(n=this.diagnosticsClient)===null||n===void 0||n.recordEvent("analytics.events.unsuccessful",{events:r.map(function(o){return o.event.event_type}),code:e.statusCode,status:e.status,body:Dr(e),stack_trace:Pr()});var i=e.status;switch(i){case Ce.Success:{this.handleSuccessResponse(e,r);break}case Ce.Invalid:{this.handleInvalidResponse(e,r);break}case Ce.PayloadTooLarge:{this.handlePayloadTooLargeResponse(e,r);break}case Ce.RateLimit:{this.handleRateLimitResponse(e,r);break}default:{this.config.loggerProvider.warn(`{code: 0, error: "Status '`.concat(i,"' provided for ").concat(r.length,' events"}')),this.handleOtherResponse(r);break}}},t.prototype.handleSuccessResponse=function(e,r){this.fulfillRequest(r,e.statusCode,nc)},t.prototype.handleInvalidResponse=function(e,r){var n=this;if(e.body.missingField||e.body.error.startsWith(uc)){this.fulfillRequest(r,e.statusCode,e.body.error);return}var i=F(F(F(F([],w(Object.values(e.body.eventsWithInvalidFields)),!1),w(Object.values(e.body.eventsWithMissingFields)),!1),w(Object.values(e.body.eventsWithInvalidIdLengths)),!1),w(e.body.silencedEvents),!1).flat(),o=new Set(i),a=r.filter(function(u,c){if
4(o.has(c)){n.fulfillRequest([u],e.statusCode,e.body.error);return}return!0});a.length>0&&this.config.loggerProvider.warn(Dr(e));var s=this.removeEventsExceedFlushMaxRetries(a);this.scheduleEvents(s)},t.prototype.handlePayloadTooLargeResponse=function(e,r){if(r.length===1){this.fulfillRequest(r,e.statusCode,e.body.error);return}this.config.loggerProvider.warn(Dr(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(r);this.scheduleEvents(n)},t.prototype.handleRateLimitResponse=function(e,r){var n=this,i=Object.keys(e.body.exceededDailyQuotaUsers),o=Object.keys(e.body.exceededDailyQuotaDevices),a=e.body.throttledEvents,s=new Set(i),u=new Set(o),c=new Set(a),l=r.filter(function(d,v){if(d.event.user_id&&s.has(d.event.user_id)||d.event.device_id&&u.has(d.event.device_id)){n.fulfillRequest([d],e.statusCode,e.body.error);return}return c.has(v)&&(d.timeout=n.throttleTimeout),!0});l.length>0&&this.config.loggerProvider.warn(Dr(e));var f=this.removeEventsExceedFlushMaxRetries(l);this.scheduleEvents(f)},t.prototype.handleOtherResponse=function(e){var r=this,n=e.map(function(o){return o.timeout=o.attempts*r.retryTimeout,o}),i=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(i)},t.prototype.fulfillRequest=function(e,r,n){var i,o,a;Lr(r)?(a=this.diagnosticsClient)===null||a===void 0||a.increment("analytics.events.sent",e.length):((i=this.diagnosticsClient)===null||i===void 0||i.increment("analytics.events.dropped",e.length),(o=this.diagnosticsClient)===null||o===void 0||o.recordEvent("analytics.events.dropped",{events:e.map(function(s){return s.event.event_type}),code:r,message:n,stack_trace:Pr()})),this.removeEvents(e),e.forEach(function(s){return s.callback(dt(s.event,r,n))})},t.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map(function(r){return r.event});this.config.storageProvider.set(this.storageKey,e)}},t.prototype.removeEvents=function(e){this.queue=this.queue.filter(function(r){return!e.some(function(n){return n.event.insert_id===r.event.insert_id})}),this.saveEvents()},t})();var Ct=function(t){return Yt.getInstance(Gn(t))},ra=function(t,e){Ct(e).identityStore.editIdentity().setUserId(t).commit()},na=function(t,e){Ct(e).identityStore.editIdentity().setDeviceId(t).commit()};var ia=(function(){function t(){this.name="identity",this.type="before",this.identityStore=Ct().identityStore}return t.prototype.execute=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){return r=e.user_properties,r&&this.identityStore.editIdentity().updateUserProperties(r).commit(),[2,e]})})},t.prototype.setup=function(e){return y(this,void 0,void 0,function(){return b(this,function(r){return e.instanceName&&(this.identityStore=Ct(e.instanceName).identityStore),[2]})})},t})();var Or=function(t,e){e===void 0&&(e=Date.now());var r=Date.now(),n=r-e;return n>t};var Vn=function(t,e,r){return e===void 0&&(e=""),r===void 0&&(r=10),[Jt,e,t.substring(0,r)].filter(Boolean).join("_")},oa=function(t){return"".concat(Jt.toLowerCase(),"_").concat(t.substring(0,6))};var aa=function(){var t,e,r,n;if(typeof navigator>"u")return"";var i=navigator.userLanguage;return(n=(r=(e=(t=navigator.languages)===null||t===void 0?void 0:t[0])!==null&&e!==void 0?e:navigator.language)!==null&&r!==void 0?r:i)!==null&&n!==void 0?n:""};var Rt=function(){var t,e=oe();if(!(!((t=e?.location)===null||t===void 0)&&t.search))return{};var r=e.location.search.substring(1).split("&").filter(Boolean),n=r.reduce(function(i,o){var a=o.split("=",2),s=bc(a[0]),u=bc(a[1]);return u&&(i[s]=u),i},{});return n},bc=function(t){t===void 0&&(t="");try{return decodeURIComponent(t)}catch(e){return""}};var cm=function(t){var e=0;if(t.length===0)return e;for(var r=0;r<t.length;r++){var n=t.charCodeAt(r);e=(e<<5)-e+n,e|=0}return e};var sa=function(t,e){var r=cm(t.toString()),n=Math.abs(r),i=n*31,o=i%1e5;return o/1e5<e};var kr=(function(){function t(){this.memoryStorage=new Map}return t.prototype.isEnabled=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return[2,!0]})})},t.prototype.get=function(e){return y(this,void 0,void 0,function(){return b(this,function(r){return[2,this.memoryStorage.get(e)]})})},t.prototype.getRaw=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return r=n.sent(),[2,r?JSON.stringify(r):void 0]}})})},t.prototype.set=function(e,r){return y(this,void 0,void 0,function(){return b(this,function(n){return this.memoryStorage.set(e,r),[2]})})},t.prototype.remove=function(e){return y(this,void 0,void 0,function(){return b(this,function(r){return this.memoryStorage.delete(e),[2]})})},t.prototype.reset=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return this.memoryStorage.clear(),[2]})})},t})();var dm=function(){var t,e=oe();return(t=e?.navigator)===null||t===void 0?void 0:t.locks},Zt=(function(){function t(e,r){r===void 0&&(r={}),this.options=T({},e),this.config=r}return t.prototype.isEnabled=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o=this;return b(this,function(a){switch(a.label){case 0:return e="AMP_TEST",r=T({},this.options),n=new t(r),i=String(Date.now()),[4,n.transaction(e,function(s){var u,c;try{s.set(i);var l=s.get(),f=l===i;return!f&&o.config.diagnosticsClient&&((u=o.config.diagnosticsClient)===null||u===void 0||u.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:e,testValue:i,sync:!0})),f}catch(v){if(o.config.diagnosticsClient){var d=v instanceof Error?v.message:String(v);(c=o.config.diagnosticsClient)===null||c===void 0||c.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:e,testValue:i,error:d,sync:!0})}return!1}finally{s.set(null)}})];case 1:return[2,a.sent()]}})})},t.prototype.get=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return r=n.sent(),[2,this.decodeCookieValue(e,r)]}})})},t.prototype.decodeCookieValue=function(e,r){if(r)try{var n=Kn(r);if(n===void 0){console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(r));return}return JSON.parse(n)}catch(i){console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(r));return}},t.prototype.getSync=function(e){var r=this.getRawSync(e);return this.decodeCookieValue(e,r)},t.prototype.getRaw=function(e){var r,n;return y(this,void 0,void 0,function(){var i,o,a,s,u,c,l,f,d,v;return b(this,function(p){switch(p.label){case 0:i=oe(),o=i,p.label=1;
4case 1:return p.trys.push([1,4,,5]),a=o?.cookieStore,a?[4,a.getAll(e)]:[3,3];case 2:if(s=p.sent(),s){s.length>1&&((r=this.config.diagnosticsClient)===null||r===void 0||r.recordEvent("cookies.duplicate",{cookies:s.map(function(h){return h.domain})}),(n=this.config.diagnosticsClient)===null||n===void 0||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(u=C(s),c=u.next();!c.done;c=u.next())if(l=c.value,Hn(l.domain,this.options.domain))return[2,l.value]}catch(h){d={error:h}}finally{try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(d)throw d.error}}}p.label=3;case 3:return[3,5];case 4:return f=p.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}})})},t.prototype.getRawSync=function(e){var r=this,n,i,o=oe(),a=((i=(n=o?.document)===null||n===void 0?void 0:n.cookie.split("; "))!==null&&i!==void 0?i:[]).filter(function(c){return c.indexOf(e+"=")===0}),s=void 0,u=this.config.duplicateResolverFn;if(typeof u=="function"&&a.length>1&&(s=a.find(function(c){var l;try{var f=u(c.substring(e.length+1));return f||(l=r.config.diagnosticsClient)===null||l===void 0||l.increment("cookies.duplicate.occurrence.document.cookie"),f}catch(d){return!1}})),s||(s=a[0]),!!s)return s.substring(e.length+1)},t.prototype.set=function(e,r){return y(this,void 0,void 0,function(){return b(this,function(n){return this.setSync(e,r),[2]})})},t.prototype.setSync=function(e,r){var n;try{var i=oe();if(!i||!i.document||typeof i.btoa!="function"||typeof i.encodeURIComponent!="function")return;var o=(n=this.options.expirationDays)!==null&&n!==void 0?n:0,a=r!==null?o:-1,s=void 0;if(a){var u=new Date;u.setTime(u.getTime()+a*24*60*60*1e3),s=u}var c="".concat(e,"=").concat(i.btoa(i.encodeURIComponent(JSON.stringify(r))));s&&(c+="; expires=".concat(s.toUTCString())),c+="; path=/",this.options.domain&&(c+="; domain=".concat(this.options.domain)),this.options.secure&&(c+="; Secure"),this.options.sameSite&&(c+="; SameSite=".concat(this.options.sameSite)),i.document.cookie=c}catch(f){var l=f instanceof Error?f.message:String(f);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(l))}},t.prototype.remove=function(e){return y(this,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return[4,this.set(e,null)];case 1:return r.sent(),[2]}})})},t.prototype.reset=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return[2]})})},t.isDomainWritable=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a;return b(this,function(s){switch(s.label){case 0:if(t.cachedTlds[e])return[2,!0];r={domain:"."+e},n="AMP_TLDTEST",i=new t(r),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,i.transaction(n,function(u){if(t.cachedTlds[e])return!0;try{u.set(1);var c=!!u.get();return c&&(t.cachedTlds[e]=!0),c}finally{u.set(null)}})];case 2:return o=s.sent(),[2,!!o];case 3:return a=s.sent(),[2,!1];case 4:return[2]}})})},t.prototype.transaction=function(e,r){return y(this,void 0,void 0,function(){var n,i,o,a=this;return b(this,function(s){switch(s.label){case 0:if(n=dm(),i=function(){var u={get:function(){return a.getSync(e)},set:function(c){return a.setSync(e,c)}};return r(u)},!n)return[2,i()];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),i)];case 2:return[2,s.sent()];case 3:return o=s.sent(),[2,i()];case 4:return[2]}})})},t.cachedTlds={},t})();var fm=function(t){try{return decodeURIComponent(atob(t))}catch(e){return}},vm=function(t){try{return decodeURIComponent(atob(decodeURIComponent(t)))}catch(e){return}},Kn=function(t){var e;return(e=fm(t))!==null&&e!==void 0?e:vm(t)},Hn=function(t,e){if(t===""&&e==="")return!0;if(!t||!e)return!1;var r=t.startsWith(".")?t.substring(1):t,n=e.startsWith(".")?e.substring(1):e;return r.toLowerCase()===n.toLowerCase()};var Wn=function(t,e,r){return e===void 0&&(e=""),r===void 0&&(r=10),[Jt,e,t.substring(0,r)].filter(Boolean).join("_")};var Nr=(function(){function t(e){this.storage=e}return t.prototype.isEnabled=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o;return b(this,function(a){switch(a.label){case 0:if(!this.storage)return[2,!1];e=String(Date.now()),r=new t(this.storage),n="AMP_TEST",a.label=1;case 1:return a.trys.push([1,4,5,7]),[4,r.set(n,e)];case 2:return a.sent(),[4,r.get(n)];case 3:return i=a.sent(),[2,i===e];case 4:return o=a.sent(),[2,!1];case 5:return[4,r.remove(n)];case 6:return a.sent(),[7];case 7:return[2]}})})},t.prototype.get=function(e){return y(this,void 0,void 0,function(){var r,n;return b(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return r=i.sent(),r?[2,JSON.parse(r)]:[2,void 0];case 2:return n=i.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},t.prototype.getRaw=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){return[2,((r=this.storage)===null||r===void 0?void 0:r.getItem(e))||void 0]})})},t.prototype.set=function(e,r){var n;return y(this,void 0,void 0,function(){return b(this,function(i){try{(n=this.storage)===null||n===void 0||n.setItem(e,JSON.stringify(r))}catch(o){}return[2]})})},t.prototype.remove=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){try{(r=this.storage)===null||r===void 0||r.removeItem(e)}catch(i){}return[2]})})},t.prototype.reset=function(){var e;return y(this,void 0,void 0,function(){return b(this,function(r){try{(e=this.storage)===null||e===void 0||e.clear()}catch(n){}return[2]})})},t})();var pm=10,hm=1,se={TAGS:"tags",COUNTERS:"counters",HISTOGRAMS:"histograms",EVENTS:"events",INTERNAL:"internal"},Sc={LAST_FLUSH_TIMESTAMP:"last_flush_timestamp"},ua=(function(){function t(e,r){this.dbPromise=null,this.logger=r,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return t.isSupported=function(){var e;return((e=oe())===null||e===void 0?void 0:e.indexedDB)!==void 0},t.prototype.getDB=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]})})},t.prototype.openDB=function(){var e=this;return new Promise(function(r,n){var i=indexedDB.open(e.dbName,hm);i.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},i.onsuccess=function(){var o=i.result;
4o.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},o.onerror=function(a){e.logger.debug("DiagnosticsStorage: A global database error occurred.",a),o.close()},r(o)},i.onupgradeneeded=function(){var o=i.result;if(!o){e.logger.debug("DiagnosticsStorage: Missing DB during upgrade.");return}e.createTables(o)}})},t.prototype.createTables=function(e){if(e.objectStoreNames.contains(se.TAGS)||e.createObjectStore(se.TAGS,{keyPath:"key"}),e.objectStoreNames.contains(se.COUNTERS)||e.createObjectStore(se.COUNTERS,{keyPath:"key"}),e.objectStoreNames.contains(se.HISTOGRAMS)||e.createObjectStore(se.HISTOGRAMS,{keyPath:"key"}),!e.objectStoreNames.contains(se.EVENTS)){var r=e.createObjectStore(se.EVENTS,{keyPath:"id",autoIncrement:!0});r.createIndex("time_idx","time",{unique:!1})}e.objectStoreNames.contains(se.INTERNAL)||e.createObjectStore(se.INTERNAL,{keyPath:"key"})},t.prototype.setTags=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a=this;return b(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([se.TAGS],"readwrite"),i=n.objectStore(se.TAGS),[2,new Promise(function(u){var c=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(l){a.logger.debug("DiagnosticsStorage: Failed to set tags",l),u()},c.forEach(function(l){var f=w(l,2),d=f[0],v=f[1],p=i.put({key:d,value:v});p.onerror=function(h){a.logger.debug("DiagnosticsStorage: Failed to set tag",d,v,h)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",o),[3,3];case 3:return[2]}})})},t.prototype.incrementCounters=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a=this;return b(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([se.COUNTERS],"readwrite"),i=n.objectStore(se.COUNTERS),[2,new Promise(function(u){var c=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(l){a.logger.debug("DiagnosticsStorage: Failed to increment counters",l),u()},c.forEach(function(l){var f=w(l,2),d=f[0],v=f[1],p=i.get(d);p.onsuccess=function(){var h=p.result,g=h?h.value:0,m=i.put({key:d,value:g+v});m.onerror=function(E){a.logger.debug("DiagnosticsStorage: Failed to update counter",d,E)}},p.onerror=function(h){a.logger.debug("DiagnosticsStorage: Failed to read existing counter",d,h)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",o),[3,3];case 3:return[2]}})})},t.prototype.setHistogramStats=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a=this;return b(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),Object.entries(e).length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([se.HISTOGRAMS],"readwrite"),i=n.objectStore(se.HISTOGRAMS),[2,new Promise(function(u){var c=Object.entries(e);n.oncomplete=function(){u()},n.onabort=function(l){a.logger.debug("DiagnosticsStorage: Failed to set histogram stats",l),u()},c.forEach(function(l){var f=w(l,2),d=f[0],v=f[1],p=i.get(d);p.onsuccess=function(){var h=p.result,g;h?g={key:d,count:h.count+v.count,min:Math.min(h.min,v.min),max:Math.max(h.max,v.max),sum:h.sum+v.sum}:g={key:d,count:v.count,min:v.min,max:v.max,sum:v.sum};var m=i.put(g);m.onerror=function(E){a.logger.debug("DiagnosticsStorage: Failed to set histogram stats",d,E)}},p.onerror=function(h){a.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",d,h)}})})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",o),[3,3];case 3:return[2]}})})},t.prototype.addEventRecords=function(e){return y(this,void 0,void 0,function(){var r,n,i,o,a=this;return b(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),e.length===0?[2]:[4,this.getDB()];case 1:return r=s.sent(),n=r.transaction([se.EVENTS],"readwrite"),i=n.objectStore(se.EVENTS),[2,new Promise(function(u){n.oncomplete=function(){u()},n.onabort=function(l){a.logger.debug("DiagnosticsStorage: Failed to add event records",l),u()};var c=i.count();c.onsuccess=function(){var l=c.result,f=Math.max(0,pm-l);f<e.length&&a.logger.debug("DiagnosticsStorage: Only added ".concat(f," of ").concat(e.length," events due to storage limit")),e.slice(0,f).forEach(function(d){var v=i.add(d);v.onerror=function(p){a.logger.debug("DiagnosticsStorage: Failed to add event record",p)}})},c.onerror=function(l){a.logger.debug("DiagnosticsStorage: Failed to count existing events",l)}})];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",o),[3,3];case 3:return[2]}})})},t.prototype.setInternal=function(e,r){return y(this,void 0,void 0,function(){var n,i,o,a;return b(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=s.sent(),i=n.transaction([se.INTERNAL],"readwrite"),o=i.objectStore(se.INTERNAL),[2,new Promise(function(u,c){i.onabort=function(){return c(new Error("Failed to set internal value"))};var l=o.put({key:e,value:r});l.onsuccess=function(){return u()},l.onerror=function(){return c(new Error("Failed to set internal value"))}})];case 2:return a=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",a),[3,3];case 3:return[2]}})})},t.prototype.getInternal=function(e){return y(this,void 0,void 0,function(){var r,n,i,o;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return r=a.sent(),n=r.transaction([se.INTERNAL],"readonly"),i=n.objectStore(se.INTERNAL),[2,new Promise(function(s,u){n.onabort=function(){return u(new Error("Failed to get internal value"))};var c=i.get(e);c.onsuccess=function(){return s(c.result)},c.onerror=function(){return u(new Error("Failed to get internal value"))}})];case 2:return o=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",o),[2,void 0];case 3:return[2]}})})},t.prototype.getLastFlushTimestamp=function(){return y(this,void 0,void 0,function(){var e,r;return b(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Sc.LAST_FLUSH_TIMESTAMP)];case 1:return e=n.sent(),[2,e?parseInt(e.value,10):void 0];case 2:return r=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",r),[2,void 0];case 3:return[2]}})})},t.prototype.setLastFlushTimestamp=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Sc.LAST_FLUSH_TIMESTAMP,e.toString())];case 1:return n.sent(),[3,3];case 2:return r=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",r),[3,3];case 3:return[2]}})})},t.prototype.clearTable=function(e,r){return new Promise(function(n,i){var o=e.objectStore(r),a=o.clear();a.onsuccess=function(){return n()},a.onerror=function(){return i(new Error("Failed to clear table ".concat(r)))}})},t.prototype.getAllAndClear=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o,a,s,u;return b(this,function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=c.sent(),r=e.transaction([se.TAGS,se.COUNTERS,se.HISTOGRAMS,se.EVENTS],"readwrite"),[4,Promise.all([this.getAllFromStore(r,se.TAGS),this.getAllFromStore(r,se.COUNTERS),this.getAllFromStore(r,se.HISTOGRAMS),this.getAllFromStore(r,se.EVENTS)])];case 2:return n=w.apply(void 0,[c.sent(),4]),i=n[0],o=n[1],a=n[2],s=n[3],[4,Promise.all([this.clearTable(r,se.COUNTERS),this.clearTable(r,se.HISTOGRAMS),this.clearTable(r,se.EVENTS)])];case 3:return c.sent(),[2,{tags:i,counters:o,histogramStats:a,events:s}];case 4:return u=c.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",u),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}})})},t.prototype.getAllFromStore=function(e,r){return new Promise(function(n,i){var o=e.objectStore(r),a=o.getAll();a.onsuccess=function(){return n(a.result)},a.onerror=function(){return i(new Error("Failed to get all from ".concat(r)))}})},t})();
4var gm="__AMPLITUDE_SCRIPT_URL__",mm="sdk.error.uncaught",Em=function(){var t=oe();if(!t)return[];var e=t[gm];return Array.isArray(e)?e:typeof e=="string"?[e]:[]};var Tc=function(t){var e=oe();if(!(!e||typeof e.addEventListener!="function")){var r=function(o){var a=o.error instanceof Error?o.error:void 0,s=a?.stack,u=yc({filename:o.filename,stack:s});u&&i({type:"error",message:o.message,stack:s,filename:o.filename,errorName:a?.name,metadata:{colno:o.colno,lineno:o.lineno,isTrusted:o.isTrusted,matchReason:u}})},n=function(o){var a,s=o.reason instanceof Error?o.reason:void 0,u=s?.stack,c=_m(u),l=yc({filename:c,stack:u});l&&i({type:"unhandledrejection",message:(a=s?.message)!==null&&a!==void 0?a:bm(o.reason),stack:u,filename:c,errorName:s?.name,metadata:{isTrusted:o.isTrusted,matchReason:l}})},i=function(o){t.recordEvent(mm,T({type:o.type,message:o.message,filename:o.filename,error_name:o.errorName,stack:o.stack},o.metadata))};e.addEventListener("error",r,!0),e.addEventListener("unhandledrejection",n,!0)}},yc=function(t){var e,r,n=Em();if(n.length!==0)try{for(var i=C(n),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.filename&&t.filename.includes(a))return"filename";if(t.stack&&t.stack.includes(a))return"stack"}}catch(s){e={error:s}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}};var _m=function(t){if(t){var e=t.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return e?e[1]:void 0}},bm=function(t){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch(e){return"[object Object]"}};var Sm=1e3,qn=300*1e3,ym="https://diagnostics.prod.us-west-2.amplitude.com/v1/capture",Tm="https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",la=1e4,Im=10,ca=(function(){function t(e,r,n,i,o){n===void 0&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=r,this.serverUrl=n==="US"?ym:Tm,this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(i,null,2)),this.config=T({enabled:!0,sampleRate:0},i),this.startTimestamp=Date.now(),this.shouldTrack=sa(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,o?this.storage=o:ua.isSupported()?this.storage=new ua(e,r):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),Tc(this))}return t.prototype.isStorageAndTrackEnabled=function(){return!!this.storage&&!!this.shouldTrack},t.prototype.setTag=function(e,r){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryTags).length>=la){this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit");return}this.inMemoryTags[e]=r,this.startTimersIfNeeded()}},t.prototype.increment=function(e,r){if(r===void 0&&(r=1),!!this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryCounters).length>=la){this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit");return}this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+r,this.startTimersIfNeeded()}},t.prototype.recordHistogram=function(e,r){if(this.isStorageAndTrackEnabled()){if(Object.keys(this.inMemoryHistograms).length>=la){this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");return}var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,r),n.max=Math.max(n.max,r),n.sum+=r):this.inMemoryHistograms[e]={count:1,min:r,max:r,sum:r},this.startTimersIfNeeded()}},t.prototype.recordEvent=function(e,r){if(this.isStorageAndTrackEnabled()){if(this.inMemoryEvents.length>=Im){this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit");return}this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:r}),this.startTimersIfNeeded()}},t.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout(function(){e.saveAllDataToStorage().catch(function(r){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",r)}).finally(function(){e.saveTimer=null})},Sm)),this.flushTimer||(this.flushTimer=setTimeout(function(){e._flush().catch(function(r){e.logger.debug("DiagnosticsClient: Failed to flush",r)}).finally(function(){e.flushTimer=null})},qn))},t.prototype.saveAllDataToStorage=function(){return y(this,void 0,void 0,function(){var e,r,n,i;return b(this,function(o){switch(o.label){case 0:return this.storage?(e=T({},this.inMemoryTags),r=T({},this.inMemoryCounters),n=T({},this.inMemoryHistograms),i=F([],w(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(r),this.storage.setHistogramStats(n),this.storage.addEventRecords(i)])]):[2];case 1:return o.sent(),[2]}})})},t.prototype._flush=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o,a,s,u,c,l;return b(this,function(f){switch(f.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return f.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=f.sent(),r=e.tags,n=e.counters,i=e.histogramStats,o=e.events,this.storage.setLastFlushTimestamp(Date.now()),a={},r.forEach(function(d){a[d.key]=d.value}),s={}
4,n.forEach(function(d){s[d.key]=d.value}),u={},i.forEach(function(d){u[d.key]={count:d.count,min:d.min,max:d.max,avg:Math.round(d.sum/d.count*100)/100}}),c=o.map(function(d){return{event_name:d.event_name,time:d.time,event_properties:d.event_properties}}),Object.keys(s).length===0&&Object.keys(u).length===0&&c.length===0?[2]:(l={tags:a,histogram:u,counters:s,events:c},this.fetch(l),[2])}})})},t.prototype.fetch=function(e){return y(this,void 0,void 0,function(){var r,n;return b(this,function(i){switch(i.label){case 0:if(i.trys.push([0,2,,3]),!oe())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return r=i.sent(),r.ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return n=i.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",n),[3,3];case 3:return[2]}})})},t.prototype.initializeFlushInterval=function(){return y(this,void 0,void 0,function(){var e,r,n;return b(this,function(i){switch(i.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return r=i.sent()||-1,r===-1?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(qn),[2]):(n=e-r,n>=qn?(this._flush(),[2]):(this._setFlushTimer(qn-n),[2]))}})})},t.prototype._setFlushTimer=function(e){var r=this;this.flushTimer=setTimeout(function(){r._flush().catch(function(n){r.logger.debug("DiagnosticsClient: Failed to flush",n)}).finally(function(){r.flushTimer=null})},e)},t.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=sa(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},t})();var Gt=(function(){function t(){}return t.prototype.send=function(e,r,n){return Promise.resolve(null)},t.prototype.buildResponse=function(e){var r,n,i,o,a,s,u,c,l,f,d,v,p,h,g,m,E,_,S,x,I,A;if(typeof e!="object")return null;var D=e.code||0,k=this.buildStatus(D);switch(k){case Ce.Success:return{status:k,statusCode:D,body:{eventsIngested:(r=e.events_ingested)!==null&&r!==void 0?r:0,payloadSizeBytes:(n=e.payload_size_bytes)!==null&&n!==void 0?n:0,serverUploadTime:(i=e.server_upload_time)!==null&&i!==void 0?i:0}};case Ce.Invalid:return{status:k,statusCode:D,body:{error:(o=e.error)!==null&&o!==void 0?o:"",missingField:(a=e.missing_field)!==null&&a!==void 0?a:"",eventsWithInvalidFields:(s=e.events_with_invalid_fields)!==null&&s!==void 0?s:{},eventsWithMissingFields:(u=e.events_with_missing_fields)!==null&&u!==void 0?u:{},eventsWithInvalidIdLengths:(c=e.events_with_invalid_id_lengths)!==null&&c!==void 0?c:{},epsThreshold:(l=e.eps_threshold)!==null&&l!==void 0?l:0,exceededDailyQuotaDevices:(f=e.exceeded_daily_quota_devices)!==null&&f!==void 0?f:{},silencedDevices:(d=e.silenced_devices)!==null&&d!==void 0?d:[],silencedEvents:(v=e.silenced_events)!==null&&v!==void 0?v:[],throttledDevices:(p=e.throttled_devices)!==null&&p!==void 0?p:{},throttledEvents:(h=e.throttled_events)!==null&&h!==void 0?h:[]}};case Ce.PayloadTooLarge:return{status:k,statusCode:D,body:{error:(g=e.error)!==null&&g!==void 0?g:""}};case Ce.RateLimit:return{status:k,statusCode:D,body:{error:(m=e.error)!==null&&m!==void 0?m:"",epsThreshold:(E=e.eps_threshold)!==null&&E!==void 0?E:0,throttledDevices:(_=e.throttled_devices)!==null&&_!==void 0?_:{},throttledUsers:(S=e.throttled_users)!==null&&S!==void 0?S:{},exceededDailyQuotaDevices:(x=e.exceeded_daily_quota_devices)!==null&&x!==void 0?x:{},exceededDailyQuotaUsers:(I=e.exceeded_daily_quota_users)!==null&&I!==void 0?I:{},throttledEvents:(A=e.throttled_events)!==null&&A!==void 0?A:[]}};case Ce.Timeout:default:return{status:k,statusCode:D}}},t.prototype.buildStatus=function(e){return Lr(e)?Ce.Success:e===429?Ce.RateLimit:e===413?Ce.PayloadTooLarge:e===408?Ce.Timeout:e>=400&&e<500?Ce.Invalid:e>=500?Ce.Failed:Ce.Unknown},t})();var Ur=2*1024;function Mr(){return typeof CompressionStream<"u"}function Fr(t){return y(this,void 0,void 0,function(){var e,r,n;return b(this,function(i){switch(i.label){case 0:if(e=CompressionStream,typeof e>"u")return[2,void 0];i.label=1;case 1:return i.trys.push([1,3,,4]),r=new Blob([t]).stream().pipeThrough(new e("gzip")),[4,new Response(r).arrayBuffer()];case 2:return[2,i.sent()];case 3:return n=i.sent(),[2,void 0];case 4:return[2]}})})}var Ic=(function(){function t(e,r){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=r}return t.prototype.fetchConfig=function(){var e=null,r={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(i){return this.logger.debug("Remote config localstorage failed to access: ",i),Promise.resolve(r)}if(e===null)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(r);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(i){return this.logger.debug("Remote config localstorage failed to parse: ",i),localStorage.removeItem(this.key),Promise.resolve(r)}},t.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(r){this.logger.debug("Remote config localstorage failed to set: ",r)}return Promise.resolve(!1)},t})();function xm(t,e){return new Promise(function(r,n){var i=function(){var o=new Error("Remote config custom fetch aborted by timeout");o.name="AbortError",n(o)};e.addEventListener("abort",i,{once:!0}),t.then(function(o){e.removeEventListener("abort",i),r(o)},function(o){e.removeEventListener("abort",i),n(o)})})}var Am="https://sr-client-cfg.amplitude.com/config",Cm="https://sr-client-cfg.eu.amplitude.com/config",Rm=3,da={INVALID_API_KEY:401,FORB
4IDDEN:403,RATE_LIMIT:429},wm=1e3,Lm=300*1e3,fa=(function(){function t(e,r,n,i,o,a){n===void 0&&(n="US"),a===void 0&&(a=t.CONFIG_GROUP),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=i||(n==="US"?Am:Cm),this.logger=r,this.storage=new Ic(e,r),this.customFetch=o,this.configGroup=a}return t.prototype.subscribe=function(e,r,n){var i=We(),o={id:i,key:e,deliveryMode:r,callback:n};return this.callbackInfos.push(o),r==="all"?this.subscribeAll(o):this.subscribeWaitForRemote(o,r.timeout),i},t.prototype.unsubscribe=function(e){var r=this.callbackInfos.findIndex(function(n){return n.id===e});return r===-1?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(r,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},t.prototype.updateConfigs=function(){return y(this,void 0,void 0,function(){var e,r,n=this;return b(this,function(i){switch(i.label){case 0:return this.lastSuccessfulFetch&&(e=Date.now()-this.lastSuccessfulFetch,e<Lm)?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return r=i.sent(),this.storage.setConfig(r),this.callbackInfos.forEach(function(o){n.sendCallback(o,r,"remote")}),[2]}})})},t.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?this.fetchPromise:this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null}),this.fetchPromise):(this.fetchPromise=this.fetch().then(function(r){return r.remoteConfig!==null&&(e.lastSuccessfulFetch=Date.now()),r}).finally(function(){e.fetchPromise=null}),this.fetchPromise)},t.prototype.subscribeAll=function(e){return y(this,void 0,void 0,function(){var r,n,i,o=this;return b(this,function(a){switch(a.label){case 0:return r=this.getOrCreateFetchPromise().then(function(s){o.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(s))),o.sendCallback(e,s,"remote"),o.storage.setConfig(s)}),n=this.storage.fetchConfig().then(function(s){return s}),[4,Promise.race([r,n])];case 1:return i=a.sent(),i!==void 0&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(i))),i.remoteConfig!==null?this.sendCallback(e,i,"cache"):this.logger.debug("Remote config client skips sending c
4allback because cache is empty (first time user).")),[4,r];case 2:return a.sent(),[2]}})})},t.prototype.subscribeWaitForRemote=function(e,r){return y(this,void 0,void 0,function(){var n,o,i,o;return b(this,function(a){switch(a.label){case 0:n=new Promise(function(s,u){setTimeout(function(){u("Timeout exceeded")},r)}),a.label=1;case 1:return a.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return o=a.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,o,"remote"),this.storage.setConfig(o),[3,5];case 3:return i=a.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 o=a.sent(),o.remoteConfig!==null?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,o,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,o,"remote")),[3,5];case 5:return[2]}})})},t.prototype.sendCallback=function(e,r,n){e.lastCallback=new Date;var i;e.key?i=e.key.split(".").reduce(function(o,a){return o===null?o:a in o?o[a]:null},r.remoteConfig):i=r.remoteConfig,e.callback(i,n,r.lastFetch)},t.prototype.fetch=function(e,r){return e===void 0&&(e=Rm),r===void 0&&(r=wm),y(this,void 0,void 0,function(){var n,i,o,a,s,u,c=this;return b(this,function(l){switch(l.label){case 0:n=r/e,i={remoteConfig:null,lastFetch:new Date},o=function(f){var d,v,p,h,g,m,E,_,S,x,I;return b(this,function(A){switch(A.label){case 0:d=!0,v=new AbortController,p=setTimeout(function(){return v.abort()},r),A.label=1;case 1:return A.trys.push([1,10,11,12]),h=a.getUrlParams(),g={Accept:"*/*"},a.customFetch?[4,xm(a.customFetch({url:h,method:"GET",headers:g,signal:v.signal}),v.signal)]:[3,3];case 2:return E=A.sent(),[3,5];case 3:return[4,fetch(h,{method:"GET",headers:g,signal:v.signal})];case 4:E=A.sent(),A.label=5;case 5:return m=E,_=m.ok||m.status>=200&&m.status<300,_?[3,7]:[4,m.text()];case 6:return S=A.sent(),a.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(m.status,": ").concat(S)),m.status===da.INVALID_API_KEY||m.status===da.FORBIDDEN?(a.logger.error("Remote config client fetch failed with ".concat(m.status,". Invalid API key; future fetches will be skipped.")),a.isLastFetchInvalidApiKey=!0,d=!1):m.status>=400&&m.status<500&&m.status!==da.RATE_LIMIT&&(d=!1),[3,9];case 7:return[4,m.json()];case 8:return x=A.sent(),[2,{value:{remoteConfig:x,lastFetch:new Date}}];case 9:return[3,12];case 10:return I=A.sent(),I instanceof Error&&I.name==="AbortError"?a.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(r,"ms")):a.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),I),[3,12];case 11:return clearTimeout(p),[7];case 12:return d?f<e-1?[4,new Promise(function(D){return setTimeout(D,c.getJitterDelay(n))})]:[3,14]:[2,"break"];case 13:A.sent(),A.label=14;case 14:return[2]}})},a=this,s=0,l.label=1;case 1:return s<e?[5,o(s)]:[3,4];case 2:if(u=l.sent(),typeof u=="object")return[2,u.value];if(u==="break")return[3,4];l.label=3;case 3:return s++,[3,1];case 4:return[2,i]}})})},t.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},t.prototype.getUrlParams=function(){var e=encodeURIComponent(this.apiKey),r=new URLSearchParams;return r.append("config_group",this.configGroup),"".concat(this.serverUrl,"/").concat(e,"?").concat(r.toString())},t.CONFIG_GROUP="browser",t})();var Xn=(function(t){return t.US="US",t.EU="EU",t.STAGING="STAGING",t})(Xn||{});var Gr=null;var va=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],pa="data-amp-track-",ha=["div","span","h1","h2","h3","h4","h5","h6"];var ga=function(t,e){return t?.map(function(r){var n,i;if(!((n=r.urls)===null||n===void 0)&&n.length&&(!((i=r.hosts)===null||i===void 0)&&i.length)){var o=JSON.stringify(r.hosts),a=JSON.stringify(r.urls);return e?.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),T(T({},r),{hosts:void 0})}return r})};var ma=(function(){function t(){}return t.prototype.parse=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return[2,T(T(T(T({},Ut),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},t.prototype.getUtmParam=function(){var e=Rt(),r=e[$l],n=e[Yl],i=e[Ql],o=e[Jl],a=e[Zl],s=e[ec];return{utm_campaign:r,utm_content:n,utm_id:i,utm_medium:o,utm_source:a,utm_term:s}},t.prototype.getReferrer=function(){var e,r,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=(r=(e=n.referrer)===null||e===void 0?void 0:e.split("/")[2])!==null&&r!==void 0?r:void 0}catch(i){}return n},t.prototype.getClickIds=function(){var e,r=Rt();return e={},e[Uo]=r[Uo],e[Mo]=r[Mo],e[Fo]=r[Fo],e[Go]=r[Go],e[Bo]=r[Bo],e[Vo]=r[Vo],e[Ko]=r[Ko],e[Ho]=r[Ho],e[Wo]=r[Wo],e[qo]=r[qo],e[Xo]=r[Xo],e},t})();var Bt={always:"always",ifEmptyCampaign:"ifEmptyCampaign"};function Ia(){var t,e,r=oe();return typeof((e=(t=r?.chrome)===null||t===void 0?void 0:t.runtime)===null||e===void 0?void 0:e.id)=="string"}function Yn(t,e,r){var n,i,o=[];try{for(var a=C(e??[]),s=a.next();!s.done;s=a.next()){var u=s.value;try{o.push(new RegExp(u))}catch(c){r.warn("Invalid regex pattern: ".concat(u),c)}}}catch(c){n={error:c}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return t.concat(o)}function xa(t,e){var r,n,i,o,a;if(!(typeof t!="object"||t===null||!(!((i=t.captureRules)===null||i===void 0)&&i.length))){var s=T({},t),u=(o=s.captureRules)!==null&&o!==void 0?o:[];try{for(var c=C(u),l=c.next();!l.done;l=c.next()){var f=l.value;f.urls=Yn((a=f.urls)!==null&&a!==void 0?a:[],f.urlsRegex,e),delete f.urlsRegex}}catch(d){r={error:d}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return s}}function Qn(t){var e,r,n,i,o,a,s,u,c,l,f,d;if(!(typeof t!="object"||t===null)&&!Array.isArray(t)){var v=Object.keys(t);try{for(var p=C(v),h=p.next();!h.done;h=p.next()){var g=h.value;try{var m=t[g];typeof m?.enabled=="boolean"&&(m.enabled?(delete m.enabled,Object.keys(m).length===0&&(t[g]=!0)):t[g]=!1),Qn(m)}catch(N){}}}catch(N){e={error:N}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(e)throw e.error}}
4try{if(!((c=(u=(s=t.autocapture)===null||s===void 0?void 0:s.networkTracking)===null||u===void 0?void 0:u.captureRules)===null||c===void 0)&&c.length)try{for(var E=C(t.autocapture.networkTracking.captureRules),_=E.next();!_.done;_=E.next()){var S=_.value;try{for(var x=(o=void 0,C(["responseHeaders","requestHeaders"])),I=x.next();!I.done;I=x.next()){var A=I.value,D=(l=S[A])!==null&&l!==void 0?l:{},k=D.captureSafeHeaders,U=D.allowlist;if(!(!k&&!U)){if(U!==void 0&&!Array.isArray(U)){delete S[A];continue}S[A]=F(F([],w(k?tc:[]),!1),w(U??[]),!1)}}}catch(N){o={error:N}}finally{try{I&&!I.done&&(a=x.return)&&a.call(x)}finally{if(o)throw o.error}}}}catch(N){n={error:N}}finally{try{_&&!_.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}}catch(N){}var R=(f=t.autocapture)===null||f===void 0?void 0:f.frustrationInteractions;R&&(R.rageClick&&(R.rageClicks=R.rageClick,delete R.rageClick),R.deadClick&&(R.deadClicks=R.deadClick,delete R.deadClick));try{var O=(d=t.autocapture)===null||d===void 0?void 0:d.elementInteractions;if(O&&typeof O=="object"&&(O.viewportContentUpdated===!0&&(O.viewportContentUpdated={}),O.viewportContentUpdated===!1&&(O.viewportContentUpdated={enabled:!1}),O.exposureDuration!==void 0)){var P=O.viewportContentUpdated;P===void 0?O.viewportContentUpdated={exposureDuration:O.exposureDuration}:typeof P=="object"&&P.exposureDuration===void 0&&P.enabled!==!1&&(P.exposureDuration=O.exposureDuration),delete O.exposureDuration}}catch(N){}}}var rr=function(t,e){return typeof t=="boolean"?t:t?.[e]===!1?!1:Ia()?!!t?.[e]:!0},Jn=function(t){return rr(t,"attribution")},Pc=function(t){return rr(t,"fileDownloads")},Aa=function(t){return rr(t,"formInteractions")},Ca=function(t){return rr(t,"pageViews")},Ra=function(t){return rr(t,"sessions")},Dc=function(t){return rr(t,"pageUrlEnrichment")},wa=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.networkTracking===!0||typeof t.networkTracking=="object")},La=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.elementInteractions===!0||typeof t.elementInteractions=="object")},Oc=function(t){return typeof t=="boolean"?t:typeof t=="object"&&t.webVitals===!0},Pa=function(t){return typeof t=="boolean"?t:typeof t=="object"&&(t.frustrationInteractions===!0||typeof t.frustrationInteractions=="object")},kc=function(t){return typeof t=="object"&&(t.performanceTracking===!0||typeof t.performanceTracking=="object")},Nc=function(t){if(typeof t.autocapture=="object"){var e=t.autocapture.performanceTracking;if(e===!0)return{mainThreadBlock:!0};if(typeof e=="object"&&e!==null)return e}},Uc=function(t){return typeof t=="boolean"?t:typeof t=="object"&&t!==null&&t.enabled!==!1},Mc=function(t){if(La(t.autocapture)&&typeof t.autocapture=="object"&&typeof t.autocapture.elementInteractions=="object")return t.autocapture.elementInteractions},Fc=function(t){if(Pa(t.autocapture)&&typeof t.autocapture=="object"&&typeof t.autocapture.frustrationInteractions=="object")return t.autocapture.frustrationInteractions},Gc=function(t){if(wa(t.autocapture)){var e=void 0;return typeof t.autocapture=="object"&&typeof t.autocapture.networkTracking=="object"?e=t.autocapture.networkTracking:t.networkTrackingOptions&&(e=t.networkTrackingOptions),T(T({},e),{captureRules:ga(e?.captureRules,t.loggerProvider)})}},Da=function(t){var e=function(){return!1},r=void 0,n,i=t.pageCounter,o=Ca(t.defaultTracking);return o&&(e=void 0,n=void 0,t.defaultTracking&&typeof t.defaultTracking=="object"&&t.defaultTracking.pageViews&&typeof t.defaultTracking.pageViews=="object"&&("trackOn"in t.defaultTracking.pageViews&&(e=t.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in t.defaultTracking.pageViews&&(r=t.defaultTracking.pageViews.trackHistoryChanges),"eventType"in t.defaultTracking.pageViews&&t.defaultTracking.pageViews.eventType&&(n=t.defaultTracking.pageViews.eventType))),{trackOn:e,trackHistoryChanges:r,eventType:n,pageCounter:i}},Bc=function(t){return Jn(t.defaultTracking)&&t.defaultTracking&&typeof t.defaultTracking=="object"&&t.defaultTracking.attribution&&typeof t.defaultTracking.attribution=="object"?T({},t.defaultTracking.attribution):{}},Vc=function(t){if(Aa(t.defaultTracking)&&t.defaultTracking&&typeof t.defaultTracking=="object"&&typeof t.defaultTracking.formInteractions=="object")return t.defaultTracking.formInteractions};var Zn=function(t,e){for(var r=0;r<e.length;r++){var n=e[r],i=n.name,o=n.args,a=n.resolve,s=t&&t[i];if(typeof s=="function"){var u=s.apply(t,o);typeof a=="function"&&a(u?.promise)}}return t},ei=function(t){var e=t;return e&&e._q!==void 0};var km=function(t){var e,r;return typeof((r=(e=t.chrome)===null||e===void 0?void 0:e.runtime)===null||r===void 0?void 0:r.id)=="string"},Nm=function(t){var e=t.ServiceWorkerGlobalScope;return typeof e=="function"&&t instanceof e},Um=function(t){var e=t.WorkerGlobalScope;return typeof e=="function"&&t instanceof e},Mm=function(t){return typeof t.document<"u"},Fm=function(t){var e,r;return typeof((r=(e=t.process)===null||e===void 0?void 0:e.versions)===null||r===void 0?void 0:r.no
4de)=="string"};function Kc(){var t=oe();if(!t)return"unknown";var e=km(t);return Nm(t)?e?"chrome_extension_service_worker":"service_worker":Um(t)?"web_worker":Mm(t)?e?"chrome_extension":"browser":Fm(t)?"node":"unknown"}var nr="2.45.10";var ti="amplitude-ts";var Oa="Web",Gm="$remote",Hc=(function(){function t(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(ti,"/").concat(nr),typeof navigator<"u"&&(this.userAgent=navigator.userAgent)}return t.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},t.prototype.execute=function(e){var r,n;return y(this,void 0,void 0,function(){var i,o,a,s;return b(this,function(u){return i=new Date().getTime(),o=(r=this.config.lastEventId)!==null&&r!==void 0?r:-1,a=(n=e.event_id)!==null&&n!==void 0?n:o+1,this.config.lastEventId=a,e.time||(this.config.lastEventTime=i),s=T(T(T(T(T(T(T(T({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:i},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:Oa}),this.config.trackingOptions.language&&{language:aa()}),this.config.trackingOptions.ipAddress&&{ip:Gm}),{insert_id:We(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:a,library:this.library,user_agent:this.userAgent}),[2,s]})})},t})();var ri=1e3,ka=(function(t){Ae(e,t);function e(r){var n=this,i,o,a;try{a=(i=oe())===null||i===void 0?void 0:i.localStorage}catch(s){(o=r?.loggerProvider)===null||o===void 0||o.debug("Failed to access localStorage. error=".concat(JSON.stringify(s))),a=void 0}return n=t.call(this,a)||this,n.loggerProvider=r?.loggerProvider,n}return e.prototype.set=function(r,n){var i;return y(this,void 0,void 0,function(){var o;return b(this,function(a){switch(a.label){case 0:return Array.isArray(n)&&n.length>ri?(o=n.length-ri,[4,t.prototype.set.call(this,r,n.slice(0,ri))]):[3,2];case 1:return a.sent(),(i=this.loggerProvider)===null||i===void 0||i.error("Failed to save ".concat(o," events because the queue length exceeded ").concat(ri,".")),[3,4];case 2:return[4,t.prototype.set.call(this,r,n)];case 3:a.sent(),a.label=4;case 4:return[2]}})})},e})(Nr);var Wc=(function(t){Ae(e,t);function e(){var r;return t.call(this,(r=oe())===null||r===void 0?void 0:r.sessionStorage)||this}return e})(Nr);var qc=(function(t){Ae(e,t);function e(r){r===void 0&&(r={});var n=t.call(this)||this;return n.state={done:4},n.customHeaders=r,n}return e.prototype.send=function(r,n,i){return i===void 0&&(i=!1),y(this,void 0,void 0,function(){var o=this;return b(this,function(a){return[2,new Promise(function(s,u){typeof XMLHttpRequest>"u"&&u(new Error("XHRTransport is not supported."));var c=new XMLHttpRequest;c.open("POST",r,!0),c.onreadystatechange=function(){if(c.readyState===o.state.done){var h=c.responseText;try{s(o.buildResponse(JSON.parse(h)))}catch(g){s(o.buildResponse({code:c.status}))}}};var l={"Content-Type":"application/json",Accept:"*/*"},f=JSON.stringify(n),d=i&&f.length>=Ur&&Mr(),v=function(h){var g,m;l=T(T({},o.customHeaders),l);try{for(var E=C(Object.entries(l)),_=E.next();!_.done;_=E.next()){var S=w(_.value,2),x=S[0],I=S[1];c.setRequestHeader(x,I)}}catch(A){g={error:A}}finally{try{_&&!_.done&&(m=E.return)&&m.call(E)}finally{if(g)throw g.error}}c.send(h)},p=function(){return y(o,void 0,void 0,function(){var h;return b(this,function(g){switch(g.label){case 0:return d?[4,Fr(f)]:[3,2];case 1:return h=g.sent(),h?(l["Content-Encoding"]="gzip",v(h)):v(f),[3,3];case 2:v(f),g.label=3;case 3:return[2]}})})};p().catch(u)})]})})},e})(Gt);var Bm=16*1024,Xc=(function(t){Ae(e,t);function e(r,n,i){r===void 0&&(r={});var o=t.call(this)||this;return o.customHeaders=r,o.enableKeepalive=n!==!1,o.referrerPolicy=i,o}return e.prototype.send=function(r,n,i){return i===void 0&&(i=!1),y(this,void 0,void 0,function(){var o,a,s,u,c,l,f,d,v;return b(this,function(p){switch(p.label){case 0:if(typeof fetch>"u")throw new Error("FetchTransport is not supported");return o=JSON.stringify(n),a=i&&o.length>=Ur&&Mr(),s=o,u={"Content-Type":"application/json",Accept:"*/*"},a?[4,Fr(o)]:[3,2];case 1:c=p.sent(),c&&(u["Content-Encoding"]="gzip",s=c),p.label=2;case 2:return u=T(T({},this.customHeaders),u),l=typeof s=="string"?s.length:s.byteLength,f={headers:u,body:s,method:"POST",keepalive:this.enableKeepalive&&l<=Bm},this.referrerPolicy&&(f.referrerPolicy=this.referrerPolicy),[4,fetch(r,f)];case 3:return d=p.sent(),[4,d.text()];case 4:v=p.sent();try{return[2,this.buildResponse(JSON.parse(v))]}catch(h){return[2,this.buildResponse({code:d.status})]}return[2]}})})},e})(Gt);var jc=(function(t){Ae(e,t);function e(){return t.call(this)||this}return e.prototype.send=function(r,n,i){return i===void 0&&(i=!1),y(this,void 0,void 0,function(){var o=this;return b(this,function(a){return[2,new Promise(function(s,u){var c=oe();if(!c?.navigator.sendBeacon)throw new Error("SendBeaconTransport is not supported");try{var l=JSON.stringify(n),f=c.navigator.sendBeacon(r,l);return s(f?o.buildResponse({code:200,events_ingested:n.events.length,payload_size_bytes:l.length,server_upload_time:Date.now()}):o.buildResponse({code:500}))}catch(d){u(d)}})]})})},e})(Gt);var zc=function(t,e,r){return r===void 0&&(r=!0),y(void 0,void 0,void 0,function(){var n,i,o,a,s,u,c,l,f;return b(this,function(d){switch(d.label){case 0:return n=oa(t),[4,e.getRaw(n)];case 1:return i=d.sent(),i?r?[4,e.remove(n)]:[3,3]:[2,{optOut:!1}];case 2:d.sent(),d.label=3;
4case 3:return o=w(i.split("."),6),a=o[0],s=o[1],u=o[2],c=o[3],l=o[4],f=o[5],[2,{deviceId:a,userId:Vm(s),sessionId:Na(c),lastEventId:Na(f),lastEventTime:Na(l),optOut:!!u}]}})})},Na=function(t){var e=parseInt(t,32);if(!isNaN(e))return e},Vm=function(t){if(!(!atob||!escape||!t))try{return decodeURIComponent(escape(atob(t)))}catch(e){return}};var Qe="[Amplitude]",vI="".concat(Qe," Page Viewed"),Ua="".concat(Qe," Form Started"),$c="".concat(Qe," Form Submitted"),Yc="".concat(Qe," File Downloaded"),Ma="session_start",Fa="session_end",Qc="".concat(Qe," File Extension"),Jc="".concat(Qe," File Name"),Zc="".concat(Qe," Link ID"),ed="".concat(Qe," Link Text"),td="".concat(Qe," Link URL"),ni="".concat(Qe," Form ID"),ii="".concat(Qe," Form Name"),oi="".concat(Qe," Form Destination"),Vr="cookie",ai="US";var Ga={};em(Ga,{DEFAULT_ACTION_CLICK_ALLOWLIST:()=>ha,DEFAULT_CSS_SELECTOR_ALLOWLIST:()=>va,DEFAULT_DATA_ATTRIBUTE_PREFIX:()=>pa,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:()=>Bt,IdentifyOperation:()=>mt,LogLevel:()=>we,OfflineDisabled:()=>Gr,RevenueProperty:()=>Ye,ServerZone:()=>Xn,SpecialEventType:()=>it});var rd=function(t){var e=t.split(".");return e.length<=2?t:e.slice(e.length-2,e.length).join(".")},Km=function(t){return Object.values(t).every(function(e){return!e})},Hm=function(t){var e=T(T({},t),{referring_domain:void 0,referrer:void 0});return Object.values(e).every(function(r){return!r})},id=function(t,e,r,n,i,o){i===void 0&&(i=!0);var a=t.referrer,s=t.referring_domain,u=nt(t,["referrer","referring_domain"]),c=e||{},l=c.referrer,f=c.referring_domain,d=nt(c,["referrer","referring_domain"]),v=r.excludeInternalReferrers;if(v){var p=Xm(v,n);if(!(p instanceof TypeError)&&t.referring_domain&&jm(t.referring_domain,o)){if(p==="always")return nd(p,t.referring_domain,n),!1;if(p==="ifEmptyCampaign"&&Hm(t))return nd(p,t.referring_domain,n),!1}}if(Wm(r.excludeReferrers,t.referring_domain))return n.debug("This is not a new campaign because ".concat(t.referring_domain," is in the exclude referrer list.")),!1;if(!i&&Km(t)&&e)return n.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var h=JSON.stringify(u)!==JSON.stringify(d),g=rd(s||"")!==rd(f||""),m=!e||h||g;return m?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."),m},Wm=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=""),t.some(function(r){return r instanceof RegExp?r.test(e):r===e})},qm=function(t,e){var r=e.startsWith(".")?e:".".concat(e),n=t.startsWith(".")?t:".".concat(t);return!!n.endsWith(r)},od=function(t,e){var r=T(T({},Ut),t),n=Object.entries(r).reduce(function(i,o){var a,s=w(o,2),u=s[0],c=s[1];return i.setOnce("initial_".concat(u),(a=c??e.initialEmptyValue)!==null&&a!==void 0?a:"EMPTY"),c?i.set(u,c):i.unset(u)},new ot);return Mt(n)},ad=function(t){var e=t;return e?(e.startsWith(".")&&(e=e.substring(1)),[new RegExp("".concat(e.replace(".","\\."),"$"))]):[]},Xm=function(t,e){if(t===!0)return Bt.always;if(typeof t=="object"){var r=t.condition;if(typeof r=="string"&&Object.keys(Bt).includes(r))return r;if(typeof r>"u")return Bt.always}var n="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(t));return e.error(n),new TypeError(n)};function nd(t,e,r){var n="This is not a new campaign because referring_domain=".concat(e," is on the same domain as the current page and it is configured to exclude internal referrers");t==="always"?r.debug(n):t==="ifEmptyCampaign"&&r.debug("".concat(n," with empty campaign parameters"))}var Ba=["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"],Va=function(t){var e,r,n=t||((r=(e=oe())===null||e===void 0?void 0:e.location)===null||r===void 0?void 0:r.hostname);if(!n)return"";var i=n.split("."),o=i[i.length-1],a=i[i.length-2];return Ba.find(function(s){return n.endsWith(".".concat(s))})&&(o=i[i.length-2]+"."+i[i.length-1],a=i[i.length-3]),a?"".concat(a,".").concat(o):o},jm=function(t,e){var r=oe();if(!r)return!1;var n=(e||"").trim()||Va(r.location.hostname);return qm(t,n)};var zm=(function(t){Ae(e,t);function e(r,n,i,o,a,s,u,c,l,f,d,v,p,h,g,m,E,_,S,x,I,A,D,k,U,R,O,P,N,G,M,V,X,H,Y,L,W,K,z,$,te,Q,ae,ne){i===void 0&&(i=new kr),o===void 0&&(o={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),c===void 0&&(c=1e3),l===void 0&&(l=5),f===void 0&&(f=30),d===void 0&&(d=Vr),m===void 0&&(m=new Ft),E===void 0&&(E=we.Warn),S===void 0&&(S=!1),x===void 0&&(x=!1),D===void 0&&(D=""),k===void 0&&(k=ai),O===void 0&&(O=1800*1e3),P===void 0&&(P=new ka({loggerProvider:m})),N===void 0&&(N={ipAddress:!0,language:!0,platform:!0}),G===void 0&&(G="fetch"),M===void 0&&(M=!1),V===void 0&&(V=!0),K===void 0&&(K=!0),z===void 0&&(z=0),ae===void 0&&(ae=!1);var B=this,ge;B=t.call(this,{apiKey:r,instanceName:p,storageProvider:P,transportProvider:Ka(G)})||this,B.apiKey=r,B.appVersion=n,B.cookieOptions=o,B.defaultTracking=a,B.autocapture=s,B.flushIntervalMillis=c,B.flushMaxRetries=l,B.flushQueueSize=f,B.identityStorage=d,B.ingestionMetadata=v,B.loggerProvider=m,B.logLevel=E,B.minIdLength=_,B.offline=S,B.partnerId=I,B.plan=A,B.serverUrl=D,B.serverZone=k,B.sessionTimeout=O,B.storageProvider=P,B.trackingOptions=N,B.transport=G,B.useBatch=M,B.fetchRemoteConfig=V,B.networkTrackingOptions=L,B.identify=W,B.enableDiagnostics=K,B.diagnosticsSampleRate=z,B.diagnosticsClient=$,B.remoteConfig=te,B.topLevelDomain=Q,B.enableRequestBodyCompression=ae,B.customEnrichment=ne,B.version=nr,B._optOut=!1,B._cookieStorage=i,B.deviceId=u,B.lastEventId=h,B.lastEventTime=g,B.optOut=x,B.deferredSessionId=R,B.sessionId=U,B.pageCounter=H,B.userId=X,B.debugLogsEnabled=Y,B.loggerProvider.enable(Y?we.Debug:B.logLevel),B.networkTrackingOptions=L,B.identify=W,B.enableDiagnostics=K,B.diagnosticsSampleRate=z,B.diagnosticsClient=$;var ce=(ge=te?.fetchRemoteConfig)!==null&&ge!==void 0?ge:V;return B.remoteConfig=B.remoteConfig||{},B.remoteConfig.fetchRemoteConfig=ce,B.fetchRemoteConfig=ce,B.topLevelDomain=Q||Va(),B}return Object.defineProperty(e.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(r){this._cookieStorage!==r&&(this._cookieStorage=r,this.updateStorage())}
4,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deviceId",{get:function(){return this._deviceId},set:function(r){this._deviceId!==r&&(this._deviceId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"userId",{get:function(){return this._userId},set:function(r){this._userId!==r&&(this._userId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sessionId",{get:function(){return this._sessionId},set:function(r){this._sessionId!==r&&(this._sessionId=r,r!==void 0&&this._deferredSessionId!==void 0&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(r){this._deferredSessionId!==r&&r!==this.sessionId&&(this._deferredSessionId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(r){this._optOut!==r&&(this._optOut=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(r){this._lastEventTime!==r&&(this._lastEventTime=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(r){this._lastEventId!==r&&(this._lastEventId=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(r){this._pageCounter!==r&&(this._pageCounter=r,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugLogsEnabled",{set:function(r){this._debugLogsEnabled!==r&&(this._debugLogsEnabled=r,this.updateStorage())},enumerable:!1,configurable:!0}),e.prototype.updateStorage=function(){var r={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 Zt&&(r.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(Vn(this.apiKey),r)},e})(Jo);var sd=function(t,e,r,n,i){return e===void 0&&(e={}),y(void 0,void 0,void 0,function(){var o,a,s,u,c,l,f,d,v,p,h,g,m,E,_,S,x,I,A,D,k,U,R,O,P,N,G,M,V,X,H,Y,L,W,K,z,$,te,Q,ae,ne,B,ge,ce,ue,j,Le,Ne,Ge,Re,Ve;return b(this,function(Ke){switch(Ke.label){case 0:return o=e.identityStorage||Vr,a="",o===Vr&&!(!((U=e.cookieOptions)===null||U===void 0)&&U.domain)&&((R=e.cookieOptions)===null||R===void 0?void 0:R.domain)!==""?[4,Ym(void 0,n)]:[3,2];case 1:a=Ke.sent(),Ke.label=2;case 2:return s=T({domain:(P=(O=e.cookieOptions)===null||O===void 0?void 0:O.domain)!==null&&P!==void 0?P:a,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},e.cookieOptions),u={duplicateResolverFn:function(J){var ie=Kn(J);if(!ie)return!1;var Z=JSON.parse(ie);return Hn(Z.cookieDomain,s.domain)},diagnosticsClient:n},c=$m(e.identityStorage,s,u),[4,zc(t,c,(G=(N=e.cookieOptions)===null||N===void 0?void 0:N.upgrade)!==null&&G!==void 0?G:!0)];case 3:return l=Ke.sent(),[4,c.get(Vn(t))];case 4:return f=Ke.sent(),d=Rt(),v=d.ampTimestamp?Number(d.ampTimestamp):void 0,p=v?Date.now()<v:!0,h=(Y=(H=(X=(M=e.deviceId)!==null&&M!==void 0?M:p?(V=d.ampDeviceId)!==null&&V!==void 0?V:d.deviceId:void 0)!==null&&X!==void 0?X:f?.deviceId)!==null&&H!==void 0?H:l.deviceId)!==null&&Y!==void 0?Y:We(),g=(L=f?.lastEventId)!==null&&L!==void 0?L:l.lastEventId,m=(W=f?.lastEventTime)!==null&&W!==void 0?W:l.lastEventTime,E=(z=(K=e.optOut)!==null&&K!==void 0?K:f?.optOut)!==null&&z!==void 0?z:l.optOut,_=($=f?.sessionId)!==null&&$!==void 0?$:l.sessionId,S=f?.deferredSessionId,x=(Q=(te=e.userId)!==null&&te!==void 0?te:f?.userId)!==null&&Q!==void 0?Q:l.userId,r.previousSessionDeviceId=(ae=f?.deviceId)!==null&&ae!==void 0?ae:l.deviceId,r.previousSessionUserId=(ne=f?.userId)!==null&&ne!==void 0?ne:l.userId,I={ipAddress:(ge=(B=e.trackingOptions)===null||B===void 0?void 0:B.ipAddress)!==null&&ge!==void 0?ge:!0,language:(ue=(ce=e.trackingOptions)===null||ce===void 0?void 0:ce.language)!==null&&ue!==void 0?ue:!0,platform:(Le=(j=e.trackingOptions)===null||j===void 0?void 0:j.platform)!==null&&Le!==void 0?Le:!0},A=f?.pageCounter,D=f?.debugLogsEnabled,e.autocapture!==void 0&&(e.defaultTracking=e.autocapture),k=new zm(t,e.appVersion,c,s,e.defaultTracking,e.autocapture,h,e.flushIntervalMillis,e.flushMaxRetries,e.flushQueueSize,o,e.ingestionMetadata,e.instanceName,g,m,(Ne=i?.loggerProvider)!==null&&Ne!==void 0?Ne:e.loggerProvider,e.logLevel,e.minIdLength,e.offline,E,e.partnerId,e.plan,e.serverUrl,(Ge=i?.serverZone)!==null&&Ge!==void 0?Ge:e.serverZone,_,S,e.sessionTimeout,e.storageProvider,I,e.transport,e.useBatch,e.fetchRemoteConfig,x,A,D,e.networkTrackingOptions,e.identify,(Re=i?.enableDiagnostics)!==null&&Re!==void 0?Re:e.enableDiagnostics,(Ve=i?.diagnosticsSampleRate)!==null&&Ve!==void 0?Ve:r._diagnosticsSampleRate,n,e.remoteConfig,a,e.enableRequestBodyCompression,e.customEnrichment),[4,k.storageProvider.isEnabled()];case 5:return Ke.sent()||(k.loggerProvider.warn("Storage provider ".concat(k.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),k.storageProvider=new kr),[2,k]}})})},$m=function(t,e,r){switch(t===void 0&&(t=Vr),e===void 0&&(e={}),t){case"localStorage":return new ka;case"sessionStorage":return new Wc;case"none":return new kr;default:return new Zt(T(T({},e),{expirationDays:e.expiration}),r)}},ud=function(t){var e,r;return t===void 0&&(t={}),((e=t.remoteConfig)===null||e===void 0?void 0:e.fetchRemoteConfig)===!0?!0:!(((r=t.remoteConfig)===null||r===void 0?void 0:r.fetchRemoteConfig)===!1||t.fetchRemoteConfig===!1)},Ka=function(t){var e=typeof t=="object"?t.type:t,r=typeof t=="object"?t.headers:void 0,n=typeof t=="object"?t.enableKeepalive:void 0,i=typeof t=="object"?t.referrerPolicy:void 0;return e==="xhr"?new qc(r):e==="beacon"?new jc:new Xc(r,n,i)},Ym=function(t,e){return y(void 0,void 0,void 0,function(){var r,n,i,o,a,a,s,u,c;return b(this,function(l){switch(l.label){case 0:return[4,new Zt(void 0,{diagnosticsClient:e}).isEnabled()];case 1:if(!l.sent()||!t&&(typeof location>"u"||!location.hostname))return[2,""];if(r=t??location.hostname,n=r.split("."),n.length===1)return[2,""];for(i=[],o=1,Ba.find(function(f){return r.endsWith(".".concat(f))})&&(o=2),a=n.length-o-1;a>=0;--a)i.push(n.slice(a).join("."));a=0,l.label=2;case 2:if(!(a<i.length))return[3,7];s=i[a],l.label=3;case 3:return l.trys.push([3,5,,6]),[4,Zt.isDomainWritable(s)];case 4:return u=l.sent(),u?[2,"."+s]:[3,6];case 5:return c=l.sent(),e&&e.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(s),error:c instanceof Error?c.message:String(c)}),[3,6];case 6:return a++,[3,2];case 7:return e&&e.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(r)}),[2,""]}})})};var Kr=(function(t){return t.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",t})(Kr||{});var Qm="AMP",OI="".concat(Qm,"_unsent");var ld="utm_campaign",cd="utm_content",dd="utm_id",fd="utm_medium",vd="utm_source",pd="utm_term",Ha="dclid",Wa="fbclid",qa="gbraid",Xa="gclid",ja="ko_click_id",za="li_fat_id",$a="msclkid",Ya="rdt_cid",Qa="ttclid",Ja="twclid",Za="wbraid";
4var Hr={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};var Vt=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var Jm=function(t){return t?(t^Math.random()*16>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Wr)},hd=F([],w(Array(256).keys()),!1).map(function(t){return t.toString(16).padStart(2,"0")}),Wr=function(t){var e,r=Vt();if(!(!((e=r?.crypto)===null||e===void 0)&&e.getRandomValues))return Jm(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,F([],w(n.entries()),!1).map(function(i){var o=w(i,2),a=o[0],s=o[1];return[4,6,8,10].includes(a)?"-".concat(hd[s]):hd[s]}).join("")};var es=function(){var t,e=Vt();if(!(!((t=e?.location)===null||t===void 0)&&t.search))return{};var r=e.location.search.substring(1).split("&").filter(Boolean),n=r.reduce(function(i,o){var a=o.split("=",2),s=gd(a[0]),u=gd(a[1]);return u&&(i[s]=u),i},{});return n},gd=function(t){t===void 0&&(t="");try{return decodeURIComponent(t)}catch(e){return""}};var ts=function(t){var e={};for(var r in t){var n=t[r];n&&(e[r]=n)}return e};var rs=(function(){function t(e){this.storage=e}return t.prototype.isEnabled=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o;return b(this,function(a){switch(a.label){case 0:if(!this.storage)return[2,!1];e=String(Date.now()),r=new t(this.storage),n="AMP_TEST",a.label=1;case 1:return a.trys.push([1,4,5,7]),[4,r.set(n,e)];case 2:return a.sent(),[4,r.get(n)];case 3:return i=a.sent(),[2,i===e];case 4:return o=a.sent(),[2,!1];case 5:return[4,r.remove(n)];case 6:return a.sent(),[7];case 7:return[2]}})})},t.prototype.get=function(e){return y(this,void 0,void 0,function(){var r,n;return b(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return r=i.sent(),r?[2,JSON.parse(r)]:[2,void 0];case 2:return n=i.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},t.prototype.getRaw=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){return[2,((r=this.storage)===null||r===void 0?void 0:r.getItem(e))||void 0]})})},t.prototype.set=function(e,r){var n;return y(this,void 0,void 0,function(){return b(this,function(i){try{(n=this.storage)===null||n===void 0||n.setItem(e,JSON.stringify(r))}catch(o){}return[2]})})},t.prototype.remove=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){try{(r=this.storage)===null||r===void 0||r.removeItem(e)}catch(i){}return[2]})})},t.prototype.reset=function(){var e;return y(this,void 0,void 0,function(){return b(this,function(r){try{(e=this.storage)===null||e===void 0||e.clear()}catch(n){}return[2]})})},t})();var ns=(function(){function t(){}return t.prototype.parse=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return[2,T(T(T(T({},Hr),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},t.prototype.getUtmParam=function(){var e=es(),r=e[ld],n=e[cd],i=e[dd],o=e[fd],a=e[vd],s=e[pd];return{utm_campaign:r,utm_content:n,utm_id:i,utm_medium:o,utm_source:a,utm_term:s}},t.prototype.getReferrer=function(){var e,r,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=(r=(e=n.referrer)===null||e===void 0?void 0:e.split("/")[2])!==null&&r!==void 0?r:void 0}catch(i){}return n},t.prototype.getClickIds=function(){var e,r=es();return e={},e[Ha]=r[Ha],e[Wa]=r[Wa],e[qa]=r[qa],e[Xa]=r[Xa],e[ja]=r[ja],e[za]=r[za],e[$a]=r[$a],e[Ya]=r[Ya],e[Qa]=r[Qa],e[Ja]=r[Ja],e[Za]=r[Za],e},t})();var md="data-amp-mask",ir="*****",Ed=/\b(?:\d[ -]*?){13,16}\b/,_d=/(\d{3}-?\d{2}-?\d{4})/g,bd=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,is=function(t,e){var r,n;if(e===void 0&&(e=[]),typeof t!="string")return"";var i=t;i=i.replace(Ed,ir),i=i.replace(_d,ir),i=i.replace(bd,ir);try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,ir)}catch(u){}}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},os=function(t){if(typeof document>"u"||!document.title)return"";var e=document.querySelector("title");return e&&e.hasAttribute(md)?ir:t?t(document.title):document.title};var Zm="[Amplitude] Page Viewed",as="AMP_PAGE_VIEW",si=function(t){t===void 0&&(t={});var e,r=Vt(),n=void 0,i=!1,o,a,s=t.trackOn,u=t.trackHistoryChanges,c=t.eventType,l=c===void 0?Zm:c,f=function(E){var _=E;try{_=decodeURI(E)}catch(S){n?.error("Malformed URI sequence: ",S)}return _},d=function(E){return y(void 0,void 0,void 0,function(){var _,S,x;return b(this,function(I){switch(I.label){case 0:return _=f(typeof location<"u"&&location.href||""),x={event_type:l},S=[{}],[4,eE()];case 1:return[2,(x.event_properties=T.apply(void 0,[T.apply(void 0,S.concat([I.sent()])),{"[Amplitude] Page Domain":typeof location<"u"&&location.hostname||"","[Amplitude] Page Location":_,"[Amplitude] Page Path":typeof location<"u"&&f(location.pathname)||"","[Amplitude] Page Title":os(is),"[Amplitude] Page URL":_.split("?")[0],"[Amplitude] Page View ID":E}]),x)]}})})},v=function(){return typeof s>"u"||typeof s=="function"&&s()},p=typeof location<"u"?location.href:null,h=function(){return y(void 0,void 0,void 0,function(){var E,_,S,x,I,A;return b(this,function(D){switch(D.label){case 0:return E=location.href,_=rE(u,E,p||"")&&v(),p=E,_?(S=void 0,a&&(S=Wr(),a.set(as,{pageViewId:S})),n?.log("Tracking page view event"),e!=null?[3,1]:(x=void 0,[3,3])):[3,4];case 1:return A=(I=e).track,[4,d(S)];case 2:x=A.apply(I,[D.sent()]),D.label=3;case 3:D.label=4;case 4:return[2]}})})},g=function(){h()},m={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(E,_){return y(void 0,void 0,void 0,function(){var S,x,I;return b(this,function(A){switch(A.label){case 0:if(e=_,o=E,n=E.loggerProvider,n.log("Installing @amplitude/plugin-page-view-tracking-browser"),i=!0,r){try{a=new rs(r.sessionStorage)}catch(D){n?.debug("sessionStorage is not available in this environment.")}r.addEventListener("popstate",g),r.history.pushState=new Proxy(r.history.pushState,{apply:function(D,k,U){var R=w(U,3),O=R[0],P=R[1],N=R[2];D.apply(k,[O,P,N]),i&&g()}})}return v()?(n.log("Tracking page view event"),S=void 0,a&&(S=Wr(),a.set(as,{pageViewId:S})),I=(x=e).track,[4,d(S)]):[3,2];case 1:I.apply(x,[A.sent()]),A.label=2;case 2:return[2]}})})},execute:function(E){return y(void 0,void 0,void 0,function(){var _,S,x;return b(this,function(I){switch(I.label){case 0:return s==="attribution"&&tE(E)?(n?.log("Enriching c
4ampaign event to page view event with campaign parameters"),_=void 0,a?[4,a.get(as)]:[3,2]):[3,4];case 1:S=I.sent(),_=S?.pageViewId,I.label=2;case 2:return[4,d(_)];case 3:x=I.sent(),E.event_type=x.event_type,E.event_properties=T(T({},E.event_properties),x.event_properties),I.label=4;case 4:return o&&E.event_type===l&&(o.pageCounter=o.pageCounter?o.pageCounter+1:1,E.event_properties=T(T({},E.event_properties),{"[Amplitude] Page Counter":o.pageCounter})),[2,E]}})})},teardown:function(){return y(void 0,void 0,void 0,function(){return b(this,function(E){return r&&(r.removeEventListener("popstate",g),i=!1),[2]})})}};return m},eE=function(){return y(void 0,void 0,void 0,function(){var t;return b(this,function(e){switch(e.label){case 0:return t=ts,[4,new ns().parse()];case 1:return[2,t.apply(void 0,[e.sent()])]}})})},tE=function(t){if(t.event_type==="$identify"&&t.user_properties){var e=t.user_properties,r=e[Kr.SET]||{},n=e[Kr.UNSET]||{},i=F(F([],w(Object.keys(r)),!1),w(Object.keys(n)),!1);return Object.keys(Hr).every(function(o){return i.includes(o)})}return!1},rE=function(t,e,r){switch(t){case"pathOnly":{if(r=="")return!0;var n=new URL(e),i=new URL(r),o=n.origin+n.pathname,a=i.origin+i.pathname;return o!==a}default:return e!==r}};var yd=function(){var t,e=[],r=function(l,f,d){l.addEventListener(f,d),e.push({element:l,type:f,handler:d})},n=function(){e.forEach(function(l){var f=l.element,d=l.type,v=l.handler;f?.removeEventListener(d,v)}),e=[]},i,o="@amplitude/plugin-form-interaction-tracking-browser",a="enrichment",s=function(l,f){return y(void 0,void 0,void 0,function(){var d,v;return b(this,function(p){return i=Vc(l),d=function(){if(!f){l.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.");return}if(!(typeof document>"u")){var h=new WeakSet,g=function(E){if(!h.has(E)){h.add(E);var _=!1;r(E,"change",function(){var S,x=Sd(E);_||f.track(Ua,(S={},S[ni]=or(E.id),S[ii]=or(E.name),S[oi]=x,S)),_=!0}),r(E,"submit",function(S){var x,I,A=Sd(E);if(_||f.track(Ua,(x={},x[ni]=or(E.id),x[ii]=or(E.name),x[oi]=A,x)),_=!0,i?.shouldTrackSubmit!==void 0)if(typeof i.shouldTrackSubmit=="function"&&typeof SubmitEvent<"u"&&S instanceof SubmitEvent)try{var D=i.shouldTrackSubmit(S);if(!D)return}catch(k){l.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else l.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");f.track($c,(I={},I[ni]=or(E.id),I[ii]=or(E.name),I[oi]=A,I)),_=!1})}},m=Array.from(document.getElementsByTagName("form"));m.forEach(g),typeof MutationObserver<"u"&&(t=new MutationObserver(function(E){E.forEach(function(_){_.addedNodes.forEach(function(S){try{if(S.nodeName==="FORM"&&g(S),"querySelectorAll"in S&&typeof S.querySelectorAll=="function"){var x=S,I=x.querySelectorAll("form");I?.forEach(g)}}catch(A){l.loggerProvider.warn("Failed to track form interactions for an added node: ".concat(String(A)))}})})}),t.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState==="complete"?d():(v=oe(),v?v.addEventListener("load",d):l.loggerProvider.debug("Form interaction tracking is not installed because global is undefined.")),[2]})})},u=function(l){return y(void 0,void 0,void 0,function(){return b(this,function(f){return[2,l]})})},c=function(){return y(void 0,void 0,void 0,function(){return b(this,function(l){return t?.disconnect(),n(),[2]})})};return{name:o,type:a,setup:s,execute:u,teardown:c}},or=function(t){if(typeof t=="string")return t},Sd=function(t){var e=t.getAttribute("action");try{e=new URL(encodeURI(e??""),window.location.href).href}catch(r){}return e};var Td=function(){var t,e=[],r=function(c,l,f){c.addEventListener(l,f),e.push({element:c,type:l,handler:f})},n=function(){e.forEach(function(c){var l=c.element,f=c.type,d=c.handler;l?.removeEventListener(f,d)}),e=[]},i="@amplitude/plugin-file-download-tracking-browser",o="enrichment",a=function(c,l){return y(void 0,void 0,void 0,function(){var f,d;return b(this,function(v){return f=function(){if(!l){c.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.");return}if(!(typeof document>"u")){var p=function(m){var E;try{E=new URL(m.href,window.location.href)}catch(x){return}var _=h.exec(E.href),S=_?.[1];S&&r(m,"click",function(){var x;S&&l.track(Yc,(x={},x[Qc]=S,x[Jc]=E.pathname,x[Zc]=m.id,x[ed]=m.text,x[td]=m.href,x))})},h=/\.(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)(\?.+)?$/,g=Array.from(document.getElementsByTagName("a"));g.forEach(p),typeof MutationObserver<"u"&&(t=new MutationObserver(function(m){m.forEach(function(E){E.addedNodes.forEac
4h(function(_){try{if(_.nodeName==="A"&&p(_),"querySelectorAll"in _&&typeof _.querySelectorAll=="function"){var S=_,x=S.querySelectorAll("a");x?.forEach(p)}}catch(I){c.loggerProvider.warn("Failed to track file downloads for an added node: ".concat(String(I)))}})})}),t.observe(document.body,{subtree:!0,childList:!0}))}},document.readyState==="complete"?f():(d=oe(),d?d.addEventListener("load",f):c.loggerProvider.debug("File download tracking is not installed because global is undefined.")),[2]})})},s=function(c){return y(void 0,void 0,void 0,function(){return b(this,function(l){return[2,c]})})},u=function(){return y(void 0,void 0,void 0,function(){return b(this,function(c){return t?.disconnect(),n(),[2]})})};return{name:i,type:o,setup:a,execute:s,teardown:u}};var Id=!1,xd=function(t){if(!(Id||t.defaultTracking!==void 0)){var e=`\`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: 5 6amplitude.init(<YOUR_API_KEY>, { 7 defaultTracking: true, 8}); 9 10Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details.`;t.loggerProvider.warn(e),Id=!0}};var Ad=function(){var t="@amplitude/plugin-network-checker-browser",e="before",r=oe(),n=[],i=function(u,c){r?.addEventListener&&(r?.addEventListener(u,c),n.push({type:u,handler:c}))},o=function(){n.forEach(function(u){var c=u.type,l=u.handler;r?.removeEventListener(c,l)}),n=[]},a=function(u,c){return y(void 0,void 0,void 0,function(){return b(this,function(l){return typeof navigator>"u"?(u.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),u.offline=!1,[2]):(u.offline=!navigator.onLine,i("online",function(){u.offline!==!1&&(u.loggerProvider.debug("Network connectivity changed to online."),u.offline=!1,setTimeout(function(){c.flush()},u.flushIntervalMillis))}),i("offline",function(){u.loggerProvider.debug("Network connectivity changed to offline."),u.offline=!0}),[2])})})},s=function(){return y(void 0,void 0,void 0,function(){return b(this,function(u){return o(),[2]})})};return{name:t,type:e,setup:a,teardown:s}};function Cd(t,e){var r,n;if(t){Qn(t);try{e.loggerProvider.debug("Update browser config with remote configuration:",$e(t));var i=t;if(i&&"autocapture"in i){if(typeof i.autocapture=="boolean"&&(e.autocapture=i.autocapture),typeof i.autocapture=="object"&&i.autocapture!==null){var o=T({},i.autocapture);if(e.autocapture===void 0&&(e.autocapture=i.autocapture),typeof i.autocapture.elementInteractions=="object"&&i.autocapture.elementInteractions!==null&&(!((r=i.autocapture.elementInteractions.pageUrlAllowlistRegex)===null||r===void 0)&&r.length)){o.elementInteractions=T({},i.autocapture.elementInteractions);var a=o.elementInteractions,s=(n=a.pageUrlAllowlist)!==null&&n!==void 0?n:[],u=i.autocapture.elementInteractions.pageUrlAllowlistRegex;a.pageUrlAllowlist=Yn(s,u,e.loggerProvider),delete a.pageUrlAllowlistRegex}var c=xa(i.autocapture.networkTracking,e.loggerProvider);c&&(o.networkTracking=c),typeof e.autocapture=="boolean"&&(e.autocapture=T({attribution:e.autocapture,fileDownloads:e.autocapture,formInteractions:e.autocapture,pageViews:e.autocapture,sessions:e.autocapture,elementInteractions:e.autocapture,webVitals:e.autocapture,frustrationInteractions:e.autocapture},o)),typeof e.autocapture=="object"&&(e.autocapture=T(T({},e.autocapture),o))}e.defaultTracking=e.autocapture}"customEnrichment"in i&&i.customEnrichment!==null&&e.customEnrichment!==!1&&(e.customEnrichment=i.customEnrichment),e.loggerProvider.debug("Browser config after remote config update:",$e(e))}catch(l){e.loggerProvider.error("Failed to apply remote configuration because of error: ",l)}}}var fe=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var ui=function(t,e){return!e||!e.length?!0:e.some(function(r){return typeof r=="string"?t===r:t.match(r)})},ar=function(t,e){var r=t;try{r=decodeURI(t)}catch(n){e?.error("Malformed URI sequence: ",n)}return r};var ss=fe(),sr=ss?.console,Kt={},qr={},us=!1;function nE(t){if(!sr||typeof sr[t]!="function")return!1;if(qr[t])return!0;var e=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{if(Kt[t]&&!us){us=!0;var i=Kt[t];
10i&&i.forEach(function(o){try{o(t,r)}catch(a){}})}}catch(o){}return us=!1,qr[t].apply(sr,r)};return qr[t]=sr[t],sr[t]=e,!0}function iE(t,e){var r=nE(t);if(!r)return new Error("Console override failed");Kt[t]?Kt[t].push(e):Kt[t]=[e]}function oE(t){var e,r;try{for(var n=C(Object.values(Kt)),i=n.next();!i.done;i=n.next())for(var o=i.value,a=o.length-1;a>=0;a--)if(o[a]===t){o.splice(a,1);break}}catch(s){e={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}function aE(){var t,e;try{for(var r=C(Object.entries(qr)),n=r.next();!n.done;n=r.next()){var i=w(n.value,2),o=i[0],a=i[1];a&&(sr[o]=a)}}catch(s){t={error:s}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}qr={},Kt={}}var li={addListener:iE,removeListener:oE,_restoreConsole:aE};var ls=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],Xr="data-amp-track-",cs=["div","span","h1","h2","h3","h4","h5","h6"],jr=150;var sE=["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]'],Rd=F(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],w(sE),!1),ds=Rd,fs=Rd,vs=["*"];var ps=1e3,hs=4,gs=50;var st="data-amp-mask",at="*****",wd=/\b(?:\d[ -]*?){13,16}\b/,Ld=/(\d{3}-?\d{2}-?\d{4})/g,Pd=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,ms=function(t,e){var r,n;if(e===void 0&&(e=[]),typeof t!="string")return"";var i=t;i=i.replace(wd,at),i=i.replace(Ld,at),i=i.replace(Pd,at);try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,at)}catch(u){}}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},Es=function(t){if(typeof document>"u"||!document.title)return"";var e=document.querySelector("title");return e&&e.hasAttribute(st)?at:t?t(document.title):document.title};var xe=Ln(Ta());function Ht(t,e){return new xe.default(function(r){t.subscribe({next:function(n){e(n).then(function(i){return r.next(i)}).catch(function(i){return r.error(i)})},error:function(n){r.error(n)},complete:function(){r.complete()}})})}function Je(t,e){return new xe.default(function(r){var n=!1,i=new Set,o=function(){var s,u;n=!0;try{for(var c=C(i),l=c.next();!l.done;l=c.next()){var f=l.value;try{f.unsubscribe()}catch(d){}}}catch(d){s={error:d}}finally{try{l&&!l.done&&(u=c.return)&&u.call(c)}finally{if(s)throw s.error}}i.clear()},a=function(s){var u=s.subscribe({next:function(c){n||r.next(c)},error:function(c){n||(n=!0,r.error(c),o())},complete:function(){i.delete(u),!n&&i.size===0&&(r.complete(),o(),n=!0)}});i.add(u)};return a(t),a(e),o})}function qe(t){var e=new Set,r=null;function n(){r?.unsubscribe(),r=null,e.clear()}return new xe.default(function(i){return e.add(i),r===null&&(r=t.subscribe({next:function(o){var a,s,u;try{for(var c=C(e),l=c.next();!l.done;l=c.next()){var f=l.value;(u=f.next)===null||u===void 0||u.call(f,o)}}catch(d){a={error:d}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}},error:function(o){var a,s,u;try{for(var c=C(e),l=c.next();!l.done;l=c.next()){var f=l.value;(u=f.error)===null||u===void 0||u.call(f,o)}}catch(d){a={error:d}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}n()},complete:function(){var o,a,s;try{for(var u=C(e),c=u.next();!c.done;c=u.next()){var l=c.value;(s=l.complete)===null||s===void 0||s.call(l)}}catch(f){o={error:f}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(o)throw o.error}}n()}})),function(){e.delete(i),e.size===0&&r&&(r.unsubscribe(),r=null)}})}var ur="https://app.amplitude.com",_s="https://app.eu.amplitude.com",bs="https://apps.stag2.amplitude.com",ci={US:ur,EU:_s,STAGING:bs},di="https://cdn.amplitude.com/libs/background-capture-1.0.3.js.gz";var Dd=function(t){var e=document.querySelector('script[src="'.concat(CSS.escape(t),'"]'));return e?Promise.resolve({status:!0}):new Promise(function(r,n){var i;try{var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=t,o.addEventListener("load",function(){r({status:!0})},{once:!0}),o.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(t)})}),(i=document.head)===null||i===void 0||i.appendChild(o)}catch(a){n(a)}})};function Od(){return"".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9))}var kd,Ss="__AMPLITUDE_MESSENGER_INSTANCE__",fi="__AMPLITUDE_MESSENGER__",uE=(function(){function t(e){var r=e===void 0?{}:e,n=r.origin,i=n===void 0?ur:n;this[kd]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=i}return t.prototype.notify=function(e){var r,n,i,o;(n=(r=this.logger)===null||r===void 0?void 0:r.debug)===null||n===void 0||n.call(r,"Message sent: ",JSON.stringify(e)),(o=(i=window.opener)===null||i===void 0?void 0:i.postMessage)===null||o===void 0||o.call(i,e,this.endpoint)},t.prototype.sendRequest=function(e,r,n){var i=this;n===void 0&&(n={timeout:15e3});var o=Od(),a={id:o,action:e,args:r},s=new Promise(function(u,c){i.requestCallbacks[o]={resolve:u,reject:c},i.notify(a),n.timeout>0&&setTimeout(function(){c(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete i.requestCallbacks[o]},n.timeout)});return s},t.prototype.handleResponse=function(e){var r;if(!this.requestCallbacks[e.id]){(r=this.logger)===null||r===void 0||r.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},t.prototype.registerActionHandler=function(e,r){var n,i,o,a;this.actionHandlers.has(e)&&((a=(o=this.logger)===null||o===void 0?void 0:o.warn)===null||a===void 0||a.call(o,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,r);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var u=C(s),c=u.next();!c.done;c=u.next()){var l=c.value;r(l)}}catch(f){n={error:f}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}},t.prototype.loadScriptOnce=function(e){return y(this,void 0,void 0,function(){var r,n,i;return b(this,function(o){switch(o.label){case 0:if(r=this.scriptLoadPromises.get(e),r)return[2,r];n=Dd(e).then(function(){}),this.scriptLoadPromises.set(e,n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n];case 2:return o.sent(),[3,4];case 3:throw i=o.sent(),this.scriptLoadPromises.delete(e),i;case 4:return[2]}})})},t.prototype.setup=function(e){var r=this,n,i,o=e===void 0?{}:e,a=o.logger,s=o.endpoint;a&&(this.logger=a),s&&this.endpoint===ur&&(this.endpoint=s),!this.isSetup&&(this.isSetup=!0,(i=(n=this.logger)===null||n===void 0?void 0:n.debug)===null||i===void 0||i.call(n,"Setting up messenger"),this.messageHandler=function(u){var c,l,f,d,v;if((l=(c=r.logger)===null||c===void 0?void 0:c.debug)===null||l===void 0||l.call(c,"Message received: ",JSON.stringify(u)),r.endpoint===u.origin){var p=u.data,h=p?.action;if(h)if("id"in p&&p.id)(d=(f=r.logger)===null||f===void 0?void 0:f.debug)===null||d===void 0||d.call(f,"Received Response to previous request: ",JSON.stringify(u)),r.handleResponse(p);else{if(h==="ping"){r.notify({action:"pong"});return}var g=r.actionHandlers.get(h);if(g)g(p.data);else{var m=(v=r.pendingMessages.get(h))!==null&&v!==void 0?v:[];m.push(p.data),r.pendingMessages.set(h,m)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},t.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();
10var e=fe();e?.[fi]===this&&delete e[fi]},t})();kd=Ss;function lE(t){return typeof t=="object"&&t!==null&&Ss in t&&t[Ss]===!0}function ys(t){var e=fe(),r=e?.[fi];if(lE(r))return r;var n=new uE(t);return e&&(e[fi]=n),n}var Nd="__AMPLITUDE_BACKGROUND_CAPTURE__";function Ts(t,e){var r,n=t;if(n[Nd]!==!0){n[Nd]=!0;var i=(r=e?.scriptUrl)!==null&&r!==void 0?r:di,o=null,a=function(s,u){var c,l;s==="background-capture-complete"&&((l=(c=t.logger)===null||c===void 0?void 0:c.debug)===null||l===void 0||l.call(c,"Background capture complete"),t.notify({action:"background-capture-complete",data:u}))};t.registerActionHandler("initialize-background-capture",function(){var s,u;(u=(s=t.logger)===null||s===void 0?void 0:s.debug)===null||u===void 0||u.call(s,"Initializing background capture (external script)");var c=new URL(i,t.endpoint).toString();t.loadScriptOnce(c).then(function(){var l,f,d;(f=(l=t.logger)===null||l===void 0?void 0:l.debug)===null||f===void 0||f.call(l,"Background capture script loaded (external)"),o=(d=window?.amplitudeBackgroundCapture)===null||d===void 0?void 0:d.call(window,{messenger:t,onBackgroundCapture:a}),t.notify({action:"background-capture-loaded"})}).catch(function(){var l;(l=t.logger)===null||l===void 0||l.warn("Failed to initialize background capture")})}),t.registerActionHandler("close-background-capture",function(){var s;(s=o?.close)===null||s===void 0||s.call(o),o=null})}}var vi="1.29.1";var Ud="@amplitude/plugin-autocapture-browser",Md="@amplitude/plugin-frustration-browser",Fd="@amplitude/plugin-performance-browser",pi="[Amplitude] Element Clicked",Gd="[Amplitude] Dead Click",Bd="[Amplitude] Rage Click",Vd="[Amplitude] Error Click",Kd="[Amplitude] Element Changed";var Hd="[Amplitude] Thrashed Cursor",Wd="[Amplitude] Main Thread Block",qd="[Amplitude] Element ID",Xd="[Amplitude] Element Class",Is="[Amplitude] Element Tag",xs="[Amplitude] Element Text",jd="[Amplitude] Element Hierarchy",zd="[Amplitude] Element Href",$d="[Amplitude] Element Position Left",Yd="[Amplitude] Element Position Top",Qd="[Amplitude] Element Aria Label",Jd="[Amplitude] Element Attributes",Zd="[Amplitude] Element Path",ef="[Amplitude] Element Parent Label",zr="[Amplitude] Page URL",tf="[Amplitude] Page Title",hi="[Amplitude] Viewport Height",gi="[Amplitude] Viewport Width",rf="[Amplitude] Max Page X",nf="[Amplitude] Max Page Y",mi="[Amplitude] Page View ID",of="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",af="amp-visual-tagging-selector-highlight",Ei="data-amp-mask-attributes",As="data-amp-internal-shadow",sf=25,_i=128,uf="AMP_PAGE_VIEW",lf=18e3,cf=.5,df=150,ff=4e3,vf=50;var pf=[/^:r[0-9a-z]+:$/,/^radix-/,/^headlessui-/,/^mui-/,/^[a-f0-9]{16,}$/i,/-\d{8,}$/,/\d{4,}/];function hf(t,e){var r,n,i=[];try{for(var o=C(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(c){var u=c instanceof Error?c.message:String(c);e?.warn('@amplitude/element-selector: ignoring invalid autogenerated-id pattern "'.concat(s,'" (').concat(u,")"))}}}catch(c){r={error:c}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function gf(t,e){var r,n;if(t==null||t==="")return!1;try{for(var i=C(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(a.test(t))return!1}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}var mf=[/^(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-/];function Ef(t,e){var r,n,i=[];try{for(var o=C(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i.push(new RegExp(s))}catch(c){var u=c instanceof Error?c.message:String(c);e?.warn('@amplitude/element-selector: ignoring invalid unstable-class pattern "'.concat(s,'" (').concat(u,")"))}}}catch(c){r={error:c}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function bi(t,e){var r=t.getAttribute(e.explicitTrackingAttribute);if(r!==null&&r==="")return null;var n=t.getAttribute("id");return n===null||n===""||!gf(n,e.autogeneratedIdPatterns)?null:n}function _f(t,e){return e.map(cE).join(" > ")}function cE(t){var e=t.tagName.toLowerCase(),r=t.parentElement;if(r===null)return e;var n=dE(t,r);return"".concat(e,":nth-of-type(").concat(n,")")}function dE(t,e){for(var r=0,n=0;n<e.children.length;n++){var i=e.children[n];if(i.tagName===t.tagName&&(r+=1,i===t))return r}return 1}var Cs=" >>> ",Rs=":scope > ";function Xe(t){return typeof ShadowRoot<"u"&&t instanceof ShadowRoot}function Sf(t,e,r){return t&&r&&Xe(e)?"".concat(Rs).concat(t):t}function yf(t){for(var e=t;e!==null;e=e.parentElement)if(e.getAttribute("id"))return!1;return!0}function fE(t){var e,r=t.getRootNode();return Xe(r)?r:(e=t.ownerDocument)!==null&&e!==void 0?e:document}function Tf(t){if(t.parentElement)return t.parentElement;var e=t.getRootNode();return Xe(e)?e.host:null}var ws=1024,If=5e4;function $r(t,e){var r,n,i,o;return b(this,function(a){switch(a.label){case 0:r=t,n=0,i=0,a.label=1;case 1:return r!==null&&i<ws?(i+=1,[4,r]):[3,3];case 2:return a.sent(),r.parentElement?(r=r.parentElement,[3,1]):n<e&&typeof r.getRootNode=="function"&&(o=Tf(r),o&&o!==r)?(n+=1,r=o,[3,1]):[3,3];case 3:return[2]}})}function Yr(t,e){var r=[];if(e<=0)return r;for(var n=[[t,0]],i=0;n.length&&i<If;){i+=1;var o=w(n.pop(),2),a=o[0],s=o[1],u=a.shadowRoot;if(u&&s+1<=e){r.push({root:u,depth:s+1});for(var c=u.children,l=0;l<c.length;l++)n.push([c[l],s+1])}for(var f=a.children,l=0;l<f.length;l++)n.push([f[l],s])}return r}function Qr(t,e){for(var r=[],n=t,i=0;n!==null&&i<ws;){i+=1;var o=fE(n);r.push({root:o,target:n});var a=n.getRootNode();if(!Xe(a))break;n=a.host}
10var s=r.length-1,u=!1,c=r;return s>e&&(c=r.slice(s-e),u=!0),{segments:c.reverse(),truncated:u}}function xf(t,e){var r=t.tagName.toLowerCase(),n=t.parentElement;if(n===null){var i=t.getRootNode();return e&&Xe(i)?"".concat(r,":nth-of-type(").concat(bf(t,i.children),")"):r}return"".concat(r,":nth-of-type(").concat(bf(t,n.children),")")}function bf(t,e){for(var r=0,n=0;n<e.length;n++){var i=e[n];if(i.tagName===t.tagName&&(r+=1,i===t))return r}return 1}var Af={name:"explicitTrackingAttribute",try:function(t,e){var r=e.config.explicitTrackingAttribute,n=t.getAttribute(r);return n===null||n===""?null:"[".concat(r,"=").concat(JSON.stringify(n),"]")}};function lr(t){var e=globalThis.CSS;if(e&&typeof e.escape=="function")return e.escape(t);for(var r=String(t),n=r.length,i="",o=0;o<n;o++){var a=r.charCodeAt(o);if(a===0){i+="\uFFFD";continue}if(a>=1&&a<=31||a===127||o===0&&a>=48&&a<=57||o===1&&a>=48&&a<=57&&r.charCodeAt(0)===45){i+="\\".concat(a.toString(16)," ");continue}if(o===0&&n===1&&a===45){i+="\\-";continue}if(a>=128||a===45||a===95||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122){i+=r.charAt(o);continue}i+="\\".concat(r.charAt(o))}return i}function Si(t){return lr(t)}var Cf={name:"stableId",try:function(t,e){var r=bi(t,e.config);return r===null?null:"".concat(t.tagName.toLowerCase(),"#").concat(Si(r))}};var wf=!1,Lf=1,vE=10,Lt=Object.freeze({enabled:!1,explicitTrackingAttribute:"data-amp-track-id",autogeneratedIdPatterns:F([],w(pf),!1),unstableClassPatterns:F([],w(mf),!1),maxAncestorWalkDepth:void 0,shadowDomEnabled:wf,maxShadowDomDepth:Lf});function Et(t){var e;return T(T({},t),{shadowDomEnabled:(e=t.shadowDomEnabled)!==null&&e!==void 0?e:wf,maxShadowDomDepth:Pf(t.maxShadowDomDepth)})}function yi(t,e){if(!t)return Rf();var r=Rf();return typeof t.enabled=="boolean"&&(r.enabled=t.enabled),typeof t.explicitTrackingAttribute=="string"&&t.explicitTrackingAttribute!==""&&(r.explicitTrackingAttribute=t.explicitTrackingAttribute),Array.isArray(t.autogeneratedIdPatterns)&&(r.autogeneratedIdPatterns=hf(t.autogeneratedIdPatterns,e)),Array.isArray(t.unstableClassPatterns)&&(r.unstableClassPatterns=Ef(t.unstableClassPatterns,e)),r.maxAncestorWalkDepth=pE(t.maxAncestorWalkDepth),typeof t.shadowDomEnabled=="boolean"&&(r.shadowDomEnabled=t.shadowDomEnabled),r.maxShadowDomDepth=Pf(t.maxShadowDomDepth),Et(r)}function pE(t){if(typeof t=="number"&&Number.isFinite(t)&&!(t<=0))return Math.floor(t)}function Pf(t){return typeof t!="number"||!Number.isFinite(t)?Lf:Math.min(Math.max(Math.floor(t),1),vE)}function Rf(){return{enabled:Lt.enabled,explicitTrackingAttribute:Lt.explicitTrackingAttribute,autogeneratedIdPatterns:F([],w(Lt.autogeneratedIdPatterns),!1),unstableClassPatterns:F([],w(Lt.unstableClassPatterns),!1),maxAncestorWalkDepth:Lt.maxAncestorWalkDepth,shadowDomEnabled:Lt.shadowDomEnabled,maxShadowDomDepth:Lt.maxShadowDomDepth}}var hE=[Af,Cf];function Of(t,e,r){var n,i,o,a,s;r===void 0&&(r={});var u=Et(e),c=(o=r.strategies)!==null&&o!==void 0?o:hE,l=(s=(a=r.scope)!==null&&a!==void 0?a:t.ownerDocument)!==null&&s!==void 0?s:document,f={scope:l,config:u},d=gE(t,u.maxAncestorWalkDepth);try{for(var v=C(c),p=v.next();!p.done;p=v.next())for(var h=p.value,g=0;g<d.length;g++){var m=d[g],E=h.try(m,f);if(E!==null){if(g===0){if(Df(l,E,t,h.name,r.logger))return E;continue}var _=d.slice(0,g).reverse(),S=_f(m,_),x="".concat(E," > ").concat(S);if(Df(l,x,t,h.name,r.logger))return x}}}catch(I){n={error:I}}finally{try{p&&!p.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return null}function gE(t,e){for(var r=[],n=t;n!==null&&(r.push(n),!(e!==void 0&&r.length>e));)n=n.parentElement;return r}function Df(t,e,r,n,i){var o;try{o=t.querySelectorAll(e)}catch(s){var a=s instanceof Error?s.message:String(s);return i?.debug('@amplitude/element-selector: strategy "'.concat(n,'" emitted a malformed selector "').concat(e,'" (').concat(a,")")),!1}return o.length===1&&o[0]===r}function kf(t,e,r){var n,i;r===void 0&&(r={});for(var o=Et(e),a=(i=(n=r.scope)!==null&&n!==void 0?n:t.ownerDocument)!==null&&i!==void 0?i:document,s=Xe(a),u=[],c=t,l=0,f=!(o.shadowDomEnabled&&s);c!==null&&!(f&&o.maxAncestorWalkDepth!==void 0&&l>o.maxAncestorWalkDepth);){var d=bi(c,o);if(d!==null){var v="".concat(c.tagName.toLowerCase(),"#").concat(Si(d)),p=F([v],w(u),!1).join(" > ");if(mE(a,p,t))return p}u.unshift(xf(c,o.shadowDomEnabled)),c=c.parentElement,l+=1}var h=u.join(" > ");return o.shadowDomEnabled&&s&&c===null?"".concat(Rs).concat(h):h}function mE(t,e,r){var n;try{n=t.querySelectorAll(e)}catch(i){return!1}return n.length===1&&n[0]===r}var Jr=(function(){function t(e,r){this.value=e,this.optimized=r}return t.prototype.toString=function(){return this.value},t}
10)(),EE=function(t,e){if(t.nodeType!==Node.ELEMENT_NODE)return"";for(var r=[],n=t;n;){var i=_E(n,!!e,n===t);if(!i||(r.push(i),i.optimized))break;n=n.parentElement}return r.reverse(),r.join(" > ")},_E=function(t,e,r){var n,i;if(t.nodeType!==Node.ELEMENT_NODE)return null;var o=t.getAttribute("id");if(e){if(o)return new Jr(Uf(o),!0);var a=t.tagName.toLowerCase();if(a==="body"||a==="head"||a==="html")return new Jr(a,!0)}var s=t.tagName.toLowerCase();if(o)return new Jr(s+Uf(o),!0);var u=t.parentNode;if(!u||u.nodeType===Node.DOCUMENT_NODE)return new Jr(s,!0);for(var c=Nf(t),l=!1,f=!1,d=-1,v=-1,p=u.children,h=0;p&&(d===-1||!f)&&h<p.length;++h){var g=p[h];if(g.nodeType===Node.ELEMENT_NODE){if(v+=1,g===t){d=v;continue}if(!f&&g.tagName.toLowerCase()===s){l=!0;var m=new Set(c);if(!m.size){f=!0;continue}for(var E=Nf(g),_=0;_<E.length;++_){var S=E[_];if(m.has(S)&&(m.delete(S),!m.size)){f=!0;break}}}}}var x=s;if(r&&s.toLowerCase()==="input"&&t.getAttribute("type")&&!t.getAttribute("id")&&!t.getAttribute("class")&&(x+="[type="+lr(t.getAttribute("type")||"")+"]"),f)x+=":nth-child("+String(d+1)+")";else if(l)try{for(var I=C(c),A=I.next();!A.done;A=I.next()){var D=A.value;x+="."+lr(D.slice(1))}}catch(k){n={error:k}}finally{try{A&&!A.done&&(i=I.return)&&i.call(I)}finally{if(n)throw n.error}}return new Jr(x,!1)},Nf=function(t){var e=t.getAttribute("class");return e?e.split(/\s+/g).filter(Boolean).map(function(r){return"$"+r}):[]},Uf=function(t){return"#"+lr(t)};function Ls(t,e){try{return EE(t)}catch(n){var r=n instanceof Error?n.message:String(n);return e?.warn("@amplitude/element-selector: legacyCssPath threw \u2014 emitting empty selector: ".concat(r)),""}}function Ps(t,e){e===void 0&&(e={});var r=Et(t),n=new Set,i=e.logger,o=function(c){return Ls(c,i)},a=function(c,l){var f;return(f=Of(c,r,{strategies:e.strategies,scope:l,logger:i}))!==null&&f!==void 0?f:kf(c,r,{scope:l})},s=function(c,l){return Sf(o(c,l),l,yf(c))};function u(c,l){var f=Qr(c,r.maxShadowDomDepth),d=f.segments,v=f.truncated;return v&&i?.debug("@amplitude/element-selector: target is nested deeper than maxShadowDomDepth (".concat(r.maxShadowDomDepth,") \u2014 emitting a best-effort selector for the outermost in-budget shadow host")),d.map(function(p){var h=p.target,g=p.root;return l(h,g)}).join(Cs)}return{generate:function(c){var l,f;try{if(!r.shadowDomEnabled){var d=r.enabled?a:o;return d(c,(f=(l=e.scope)!==null&&l!==void 0?l:c.ownerDocument)!==null&&f!==void 0?f:document)}return u(c,r.enabled?a:s)}catch(p){var v=p instanceof Error?p.message:String(p);return i?.warn("@amplitude/element-selector: selector generation threw \u2014 falling back to legacy cssPath: ".concat(v)),Ls(c,i)}},getConfig:function(){return r},updateConfig:function(c){var l,f;r=Et(c);try{for(var d=C(n),v=d.next();!v.done;v=d.next()){var p=v.value;try{p(r)}catch(g){var h=g instanceof Error?g.message:String(g);i?.warn("@amplitude/element-selector: onConfigChange subscriber threw \u2014 ".concat(h))}}}catch(g){l={error:g}}finally{try{v&&!v.done&&(f=d.return)&&f.call(d)}finally{if(l)throw l.error}}},onConfigChange:function(c){return n.add(c),function(){n.delete(c)}}}}var bE=1,_t=Object.freeze({enabled:!1,maxDepth:0}),Mf=function(t){var e,r=(e=t.maxShadowDomDepth)!==null&&e!==void 0?e:bE;return!t.shadowDomEnabled||r<=0?_t:Object.freeze({enabled:!0,maxDepth:r})},SE=function(){var t=_t,e=new Set,r=function(n){var i,o;try{for(var a=C(F([],w(e),!1)),s=a.next();!s.done;s=a.next()){var u=s.value;try{u(n)}catch(c){}}}catch(c){i={error:c}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}e.clear()};return{get:function(){return t},arm:function(n){return t.enabled||!n.enabled||(t=n,r(n)),t},onArm:function(n){if(t.enabled){var i=t;try{n(i)}catch(o){}return function(){}}return e.add(n),function(){e.delete(n)}}}},Ds,Ff=function(){return Ds||(Ds=SE()),Ds};var yE=["input","select","textarea"],Gf=function(t,e){var r,n=(r=window?.getComputedStyle)===null||r===void 0?void 0:r.call(window,t);return n?.getPropertyValue("cursor")==="pointer"&&e==="click"},Zr=function(t){var e=t.pageUrlAllowlist,r=t.pageUrlExcludelist;return!(r&&r.length>0&&ui(window.location.href,r)||!ui(window.location.href,e))},Dt=function(t,e){return function(r,n){var i,o,a=t.shouldTrackEventResolver,s=(o=(i=n?.tagName)===null||i===void 0?void 0:i.toLowerCase)===null||o===void 0?void 0:o.call(i);if(!s)return!1;if(a)return a(r,n);if(!Zr(t))return!1;var u=String(n?.getAttribute("type"))||"";if(typeof u=="string")switch(u.toLowerCase()){case"hidden":return!1;case"password":return!1}if(e){var c=e.some(function(l){var f;return!!(!((f=n?.matches)===null||f===void 0)&&f.call(n,l))});if(!c)return!1}switch(s){case"input":case"select":case"textarea":return r==="change"||r==="click";default:return r==="click"}}};var Bf=function(t){var e,r,n,i=(r=(e=t?.tagName)===null||e===void 0?void 0:e.toLowerCase)===null||r===void 0?void 0:r.call(e),o=t instanceof HTMLElement?((n=t.getAttribute("contenteditable"))===null||n===void 0?void 0:n.toLowerCase())==="true":!1;return!yE.includes(i)&&!o},Vf=function(t){return t?t.split(",").map(function(e){return e.trim()}).filter(function(e){return e.length>0&&e!=="id"&&e!=="class"}):[]},Kf=function(t,e){return Object.entries(t).reduce(function(r,n){var i=w(n,2),o=i[0],a=i[1];if(o.startsWith(e)){var s=o.replace(e,"");s&&(r[s]=a||"")}return r},{})},TE=function(t){return t==null||typeof t=="object"&&Object.keys(t).length===0||typeof t=="string"&&t.trim().length===0},Os=function(t){return Object.keys(t).reduce(function(e,r){var n=t[r];return TE(n)||(e[r]=n),e},{})},Ti=function(){var t;
10try{var e=fe(),r=(t=e?.sessionStorage)===null||t===void 0?void 0:t.getItem(uf);if(!r)return;var n=JSON.parse(r);if(typeof n.pageViewId=="string")return n.pageViewId}catch(i){}};var Ii=function(t,e,r){return r===void 0&&(r=_t),r.enabled?IE(t,e,r.maxDepth):Hf(t,e)},Hf=function(t,e){return t?e.some(function(r){var n;return(n=t?.matches)===null||n===void 0?void 0:n.call(t,r)})?t:Hf(t?.parentElement,e):null},IE=function(t,e,r){var n,i;if(!t)return null;var o=function(l){if(e.some(function(f){var d;return(d=l?.matches)===null||d===void 0?void 0:d.call(l,f)}))return{value:l}};try{for(var a=C($r(t,r)),s=a.next();!s.done;s=a.next()){var u=s.value,c=o(u);if(typeof c=="object")return c.value}}catch(l){n={error:l}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return null},ks=function(t,e,r){return r===void 0&&(r=_t),r.enabled?xE(t,e,r.maxDepth):Wf(t,e)},Wf=function(t,e){var r=[];return e&&t.querySelectorAll(e).forEach(function(n){return r.push(n)}),r},xE=function(t,e,r){var n=Wf(t,e),i=t instanceof Document?t.documentElement:t;return i&&Yr(i,r).forEach(function(o){var a=o.root;a.querySelectorAll(e).forEach(function(s){return n.push(s)})}),n},qf=function(t,e){var r,n;if(e===void 0&&(e=_t),!e.enabled)return t.target;var i=(r=t.composedPath)===null||r===void 0?void 0:r.call(t),o=(n=t.target)!==null&&n!==void 0?n:null;if(!i||i.length===0)return o;var a=i[0];if(!(a instanceof Element))return a??o;var s=Qr(a,e.maxDepth),u=s.segments,c=s.truncated;return c&&u.length>0?u[u.length-1].target:a};var ft=function(t){return!(t.event.target===null||!t.closestTrackedAncestor)};function Xf(t){return t.type==="click"||t.type==="change"}function xi(t){if(!t)return"";try{var e=new URL(t);return e.search="",ar(e.href)}catch(r){return ar(t)}}function Pt(t){var e,r;return t===void 0&&(t=fe()),xi((r=(e=t?.location)===null||e===void 0?void 0:e.href)!==null&&r!==void 0?r:"")}function jf(t,e){var r;if(e===void 0&&(e=fe()),t==null||t==="")return Pt(e);var n=((r=e?.location)===null||r===void 0?void 0:r.href)||"http://localhost/";try{return xi(new URL(t,n).href)}catch(i){return Pt(e)}}var en=(function(t){return t[t.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",t[t.MIDDLE=1]="MIDDLE",t[t.RIGHT=2]="RIGHT",t})(en||{});var zf="__AMPLITUDE_VISUAL_TAGGING__";function $f(t,e){var r=t;if(r[zf]!==!0){r[zf]=!0;var n=e.dataExtractor,i=e.isElementSelectable,o=e.cssSelectorAllowlist,a=e.actionClickAllowlist,s=null,u=function(l){t.notify({action:"element-selected",data:l})},c=function(l,f){l==="selector-mode-changed"?t.notify({action:"track-selector-mode-changed",data:f}):l==="selector-moved"&&t.notify({action:"track-selector-moved",data:f})};t.registerActionHandler("initialize-visual-tagging-selector",function(l){t.loadScriptOnce(of).then(function(){var f;s=(f=window?.amplitudeVisualTaggingSelector)===null||f===void 0?void 0:f.call(window,{getEventTagProps:n.getEventTagProps,isElementSelectable:function(d){return i?i(l?.actionType||"click",d):!0},onTrack:c,onSelect:u,visualHighlightClass:af,messenger:t,cssSelectorAllowlist:o,actionClickAllowlist:a,extractDataFromDataSource:n.extractDataFromDataSource,dataExtractor:n,diagnostics:{autocapture:{version:vi}}}),t.notify({action:"selector-loaded"})}).catch(function(){var f;(f=t.logger)===null||f===void 0||f.warn("Failed to initialize visual tagging selector")})}),t.registerActionHandler("close-visual-tagging-selector",function(){var l;(l=s?.close)===null||l===void 0||l.call(s)})}}function Yf(t){var e=t.amplitude,r=t.allObservables,n=t.shouldTrackEvent,i=t.evaluateTriggers,o=r.clickObservable,a=o.filter(ft).filter(function(u){return n("click",u.closestTrackedAncestor)}).map(function(u){return i(u)}),s=a;return s.subscribe(function(u){e?.track(pi,u.targetElementProperties)})}function Qf(t){var e=t.amplitude,r=t.allObservables,n=t.getEventProperties,i=t.shouldTrackEvent,o=t.evaluateTriggers,a=r.changeObservable,s=a.filter(ft).filter(function(u){return i("change",u.closestTrackedAncestor)}).map(function(u){return o(u)});return s.subscribe(function(u){e?.track(Kd,n("change",u.closestTrackedAncestor))})}
10function Jf(t){var e=t.amplitude,r=t.allObservables,n=t.options,i=t.getEventProperties,o=t.shouldTrackEvent,a=t.shouldTrackActionClick,s=r.clickObservable,u=r.mutationObservable,c=r.navigateObservable,l=s.filter(function(g){return!o("click",g.closestTrackedAncestor)}).map(function(g){var m=Ii(g.event.target,n.actionClickAllowlist);return g.closestTrackedAncestor=m,g.closestTrackedAncestor!==null&&(g.targetElementProperties=i(g.type,g.closestTrackedAncestor)),g}).filter(ft).filter(function(g){return a("click",g.closestTrackedAncestor)}),f=c?Je(u,c):u,d=Je(l,f),v=null,p=null,h=Ht(d,function(g){if(v&&(clearTimeout(v),v=null),g.type==="click")return p=g,v=setTimeout(function(){v=null,p=null},500),Promise.resolve(null);if(p){var m=p;return p=null,Promise.resolve(m)}return Promise.resolve(null)});return h.subscribe(function(g){g&&e?.track(pi,i("click",g.closestTrackedAncestor))})}function Zf(t){var e=t.amplitude,r=t.allObservables,n=r.scrollObservable,i={maxX:0,maxY:0},o=n.subscribe(function(){var a,s,u,c,l=fe(),f=Math.floor((s=(a=l?.scrollX)!==null&&a!==void 0?a:l?.pageXOffset)!==null&&s!==void 0?s:0),d=Math.floor((c=(u=l?.scrollY)!==null&&u!==void 0?u:l?.pageYOffset)!==null&&c!==void 0?c:0);i.maxX=Math.max(i.maxX,f),i.maxY=Math.max(i.maxY,d)});return{unsubscribe:function(){o.unsubscribe()},getState:function(){return i},reset:function(){i.maxX=0,i.maxY=0}}}var cr=fe(),tn=function(t){return t.get()},AE={childList:!0,attributes:!0,characterData:!0,subtree:!0},Ai=function(t){return t?new xe.default(function(e){var r=new WeakSet,n=new WeakMap,i=function(l,f){r.has(l)||(r.add(l),Xe(l)&&n.set(l,f),s.observe(l,AE))},o=function(l,f,d){var v=d-f;v<=0||Yr(l,v).forEach(function(p){var h=p.root,g=p.depth;return i(h,f+g)})},a=function(l){var f=l.getRootNode();if(!Xe(f))return 0;var d=n.get(f);return d??0},s=new MutationObserver(function(l){var f,d;e.next(l);try{var v=tn(t);if(!v.enabled)return;var p=function(E){var _=a(E.target);E.addedNodes.forEach(function(S){S instanceof Element&&o(S,_,v.maxDepth)})};try{for(var h=C(l),g=h.next();!g.done;g=h.next()){var m=g.value;p(m)}}catch(E){f={error:E}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(f)throw f.error}}}catch(E){}}),u;if(document.body){var c=document.body;i(c,0),u=t.onArm(function(l){o(c,0,l.maxDepth)})}return function(){u?.(),s.disconnect()}}):new xe.default(function(e){var r=new MutationObserver(function(n){e.next(n)});return document.body&&r.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return r.disconnect()}})},Ci=function(t){return t===void 0&&(t="click"),new xe.default(function(e){var r,n=function(i){e.next(i)};return(r=fe())===null||r===void 0||r.document.addEventListener(t,n,{capture:!0}),function(){var i;(i=fe())===null||i===void 0||i.document.removeEventListener(t,n,{capture:!0})}})},ev=function(){return new xe.default(function(t){var e,r,n=function(i){t.next(i)};return(e=fe())===null||e===void 0||e.addEventListener("scroll",n,{capture:!0,passive:!0}),(r=fe())===null||r===void 0||r.addEventListener("resize",n,{passive:!0}),function(){var i,o;(i=fe())===null||i===void 0||i.removeEventListener("scroll",n,{capture:!0}),(o=fe())===null||o===void 0||o.removeEventListener("resize",n)}})},CE=function(){return new xe.default(function(t){var e=function(r){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var o=void 0;Array.isArray(n[0])&&typeof n[0][0]=="string"&&(o=n[0][0]),t.next({kind:"console",message:o})};return li.addListener("error",e),function(){li.removeListener(e)}})},tv=function(t,e,r,n){var i=typeof r=="function"?r:void 0,o=typeof r=="function"?n:r;return new xe.default(function(a){var s=fe();if(!s?.IntersectionObserver)return function(){};var u=new IntersectionObserver(function(h){h.forEach(function(g){a.next(g)})},{root:null,rootMargin:"0px",threshold:0}),c=e.join(","),l=function(h){h instanceof Element&&h.matches(c)&&u.observe(h),h.querySelectorAll(c).forEach(function(g){u.observe(g)})},f=function(h){if(o)try{ks(h,c,tn(o)).forEach(function(g){u.observe(g)})}catch(g){}},d=function(){var h=s?.document;if(h){var g=[];try{o&&tn(o).enabled?g=ks(h,c,tn(o)):g=h.querySelectorAll(c)}catch(m){return}Array.from(g).forEach(function(m){u.unobserve(m),u.observe(m)})}};i?.(d),d();var v=o?.onArm(function(){s?.document&&f(s.document)}),p=t.subscribe(function(h){var g=h.event;return g.forEach(function(m){var E=m.addedNodes;
10return E.forEach(function(_){if(_ instanceof DocumentFragment){l(_);return}if(_ instanceof Element){if(!o||!tn(o).enabled){l(_);return}try{_.matches(c)&&u.observe(_)}catch(S){}f(_)}})})});return function(){i?.(void 0),v?.(),p.unsubscribe(),u.disconnect()}})},RE=function(){return new xe.default(function(t){var e=function(r){if(r instanceof ErrorEvent){var n={kind:"error"};r.error instanceof Error||r.error instanceof DOMException?n=T(T({},n),{message:r.error.message,stack:r.error.stack,filename:r.filename,lineNumber:r.lineno,columnNumber:r.colno}):typeof r.error=="string"&&(n.message=r.error),t.next(n)}};return cr.addEventListener("error",e),function(){cr.removeEventListener("error",e)}})},wE=function(){return new xe.default(function(t){var e=function(r){var n={kind:"unhandledrejection"};r.reason instanceof Error||r.reason instanceof DOMException?(n.message=r.reason.message,n.stack=r.reason.stack):typeof r.reason=="string"&&(n.message=r.reason),t.next(n)};return cr.addEventListener("unhandledrejection",e),function(){cr.removeEventListener("unhandledrejection",e)}})},rv=function(){var t=Je(RE(),wE());return Je(t,CE())},nv=function(){return new xe.default(function(t){var e=function(n){t.next(n)},r={capture:!0};return cr.document.addEventListener("mousemove",e,r),function(){cr.document.removeEventListener("mousemove",e,r)}})};var iv=function(t,e){try{if(e.subprop_key==="[Amplitude] Element Text")return e.subprop_op==="is"&&e.subprop_value.includes(t.targetElementProperties["[Amplitude] Element Text"]);if(e.subprop_key==="[Amplitude] Element Hierarchy")return e.subprop_op==="autotrack css match"&&!!t.closestTrackedAncestor.closest(e.subprop_value.toString())}catch(r){return console.error("Error matching event to filter",r),!1}return!1};var ov=function(t,e){try{if(t.sourceType==="DOM_ELEMENT"){var r=document.documentElement;return t.scope&&e&&(r=e.closest(t.scope)),r&&t.selector?r.querySelector(t.selector):r}}catch(n){return}},av=function(t,e,r){t.forEach(function(n){if(typeof n!="string"&&n.actionType==="ATTACH_EVENT_PROPERTY"){var i=r.extractDataFromDataSource(n.dataSource,e.closestTrackedAncestor);e.targetElementProperties[n.destinationKey]=i}})};var Ns={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},Us=function(t){var e,r,n,i,o=Object.values(Ns).reduce(function(v,p){return v[p]=new Set,v},{});if(!t)return o;try{for(var a=C(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{try{for(var c=(n=void 0,C(u.definition)),l=c.next();!l.done;l=c.next()){var f=l.value,d=Ns[f.event_type];d&&o[d].add(u.id)}}catch(v){n={error:v}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}}catch(v){console.warn("Skipping Labeled Event due to malformed definition",u?.id,v)}}}catch(v){e={error:v}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o},Ms=function(t){var e,r,n,i,o=new Map;try{for(var a=C(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var c=(n=void 0,C(u.conditions)),l=c.next();!l.done;l=c.next()){var f=l.value;if(f.type==="LABELED_EVENT"){var d=f.match.eventId,v=o.get(d);v||(v=[],o.set(d,v)),v.push(u)}}}catch(p){n={error:p}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}}}catch(p){e={error:p}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o},LE=function(t,e){return e.filter(function(r){return r.definition.some(function(n){return Ns[n.event_type]===t.type&&n.filters.every(function(i){return iv(t,i)})})})},PE=function(t,e){var r,n,i,o,a=new Set;try{for(var s=C(t),u=s.next();!u.done;u=s.next()){var c=u.value,l=e.get(c.id);if(l)try{for(var f=(i=void 0,C(l)),d=f.next();!d.done;d=f.next()){var v=d.value;a.add(v)}}catch(p){i={error:p}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}}}catch(p){r={error:p}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return Array.from(a)},DE=(function(){function t(e,r,n,i){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=r,this.dataExtractor=n,this.options=i}return t.prototype.evaluate=function(e){var r,n,i=this.options.pageActions;if(!i)return e;var o=LE(e,Array.from(this.groupedLabeledEvents[e.type]).map(function(l){return i.labeledEvents[l]})),a=PE(o,this.labeledEventToTriggerMap);try{for(var s=C(a),u=s.next();!u.done;u=s.next()){var c=u.value;av(c.actions,e,this.dataExtractor)}}catch(l){r={error:l}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return e},t.prototype.update=function(e,r,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=r,this.options=n},t})();var sv=function(t,e,r,n){return new DE(t,e,r,n)};var OE=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Ei,st,As]),kE=["type"],NE=["svg","path","g"],UE=["password","hidden"];function ME(t,e){if(t.parentElement)return t.parentElement.children;var r=t.getRootNode();return e&&Xe(r)?r.children:[]}function uv(t,e,r){var n,i,o,a,s;if(r===void 0&&(r=_t),t===null)return null;var u=String(t.tagName).toLowerCase(),c={tag:u},l=Array.from(ME(t,r.enabled));l.length&&(c.index=l.indexOf(t),c.indexOfType=l.filter(function(x){return x.tagName===t.tagName}).indexOf(t));var f=(s=(a=t.previousElementSibling)===null||a===void 0?void 0:a.tagName)===null||s===void 0?void 0:s.toLowerCase();f&&(c.prevSib=String(f));var d=t.getAttribute("id");d&&(c.id=String(d));var v=Array.from(t.classList);v.length&&(c.classes=v);var p={},h=Array.from(t.attributes),g=h.filter(function(x){return!OE.has(x.name)}),m=!Bf(t);if(!UE.includes(String(t.getAttribute("type")))&&!NE.includes(u))try{for(var E=C(g),_=E.next();!_.done;_=E.next()){var S=_.value;
10if(!(m&&!kE.includes(S.name))){if(e.has(S.name)){p[S.name]=at;continue}p[S.name]=String(S.value).substring(0,_i)}}}catch(x){n={error:x}}finally{try{_&&!_.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}return Object.keys(p).length&&(c.attrs=p),t.shadowRoot&&(c.attrs=T(T({},c.attrs||{}),(o={},o[As]="true",o)),c.shadow=!0),c}function Fs(t,e){return e===void 0&&(e=_t),t?e.enabled?GE(t,e.maxDepth):FE(t):[]}function FE(t){var e=[];e.push(t);for(var r=t.parentElement;r&&r.tagName!=="HTML";)e.push(r),r=r.parentElement;return e}function GE(t,e){var r,n,i=[];try{for(var o=C($r(t,e)),a=o.next();!a.done;a=o.next()){var s=a.value;if(s.tagName==="HTML")break;i.push(s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}var BE=function(t){return t.closest("[".concat(st,"]"))!==null},VE=function(t,e){var r,n;return Fs(t,e).some(function(i){return i.hasAttribute(st)})?!0:(n=(r=document.documentElement)===null||r===void 0?void 0:r.hasAttribute(st))!==null&&n!==void 0?n:!1},Gs;function KE(){return Gs||(Gs=Ps(yi())),Gs}var Ri=(function(){function t(e,r){var n,i,o=this,a;this.replaceSensitiveString=function(d){return ms(d,o.additionalMaskTextPatterns)},this.getHierarchy=function(d){var v,p,h,g,m=performance.now(),E=[];if(!d)return[];for(var _=o.getShadowMode(),S=Fs(d,_),x=new Map,I=S.length-1;I>=0;I--){var A=S[I];if(A){var D=Vf(A.getAttribute(Ei)),k=I===S.length-1?[]:(h=x.get(S[I+1]))!==null&&h!==void 0?h:new Set,U=new Set(F(F([],w(k),!1),w(D),!1));x.set(A,U)}}E=S.map(function(M){var V;return uv(M,(V=x.get(M))!==null&&V!==void 0?V:new Set,_)});var R=function(M){M?.attrs&&Object.entries(M.attrs).forEach(function(V){var X=w(V,2),H=X[0],Y=X[1];M.attrs&&(M.attrs[H]=o.replaceSensitiveString(Y))})};try{for(var O=C(E),P=O.next();!P.done;P=O.next()){var N=P.value;R(N)}}catch(M){v={error:M}}finally{try{P&&!P.done&&(p=O.return)&&p.call(O)}finally{if(v)throw v.error}}var G=performance.now();return(g=o.diagnosticsClient)===null||g===void 0||g.recordHistogram("autocapturePlugin.getHierarchy",G-m),E},this.getNearestLabel=function(d){var v=d.parentElement;if(!v)return"";var p;try{p=v.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(h){p=null}return p?o.getText(p):o.getNearestLabel(v)},this.getElementPath=function(d){var v;if(!d)return"";var p=performance.now(),h=o.selectorEngine.generate(d),g=performance.now();return(v=o.diagnosticsClient)===null||v===void 0||v.recordHistogram("autocapturePlugin.getElementPath",g-p),h},this.updateSelectorConfig=function(d,v){var p;if(d!=null){var h=typeof d.enabled=="boolean",g=typeof d.shadowDomEnabled=="boolean";if(!h&&!g){v?.debug("@amplitude/element-selector: ignoring remote-config delivery without an explicit `enabled` or `shadowDomEnabled` flag \u2014 keeping current engine state.");return}var m=yi(d,v),E=o.selectorEngine.getConfig().enabled,_=o.shadowGate.get().enabled,S=o.shadowGate.arm(Mf(m));o.selectorEngine.updateConfig(T(T(T({},h?m:o.selectorEngine.getConfig()),{shadowDomEnabled:S.enabled}),S.enabled&&{maxShadowDomDepth:S.maxDepth})),h&&E!==m.enabled&&v?.debug(m.enabled?"@amplitude/element-selector: engine enabled \u2014 now emitting new element-selector element paths for autocapture events.":"@amplitude/element-selector: engine disabled \u2014 reverting to legacy cssPath for element paths."),!_&&S.enabled&&((p=o.diagnosticsClient)===null||p===void 0||p.setTag("plugin.autocapture.shadowDom","enabled:".concat(S.maxDepth)))}}
10,this.getShadowMode=function(){return o.shadowGate.get()},this.getEventProperties=function(d,v,p){var h,g,m,E,_=(m=(g=v?.tagName)===null||g===void 0?void 0:g.toLowerCase)===null||m===void 0?void 0:m.call(g),S=typeof v.getBoundingClientRect=="function"?v.getBoundingClientRect():{left:null,top:null},x=o.getHierarchy(v),I=(E=x[0])===null||E===void 0?void 0:E.attrs,A=o.getNearestLabel(v),D=Kf(I??{},p),k=(h={},h[jd]=x,h[Is]=_,h[xs]=o.getText(v),h[$d]=S.left==null?null:Math.round(S.left),h[Yd]=S.top==null?null:Math.round(S.top),h[Jd]=D,h[Zd]=o.getElementPath(v),h[ef]=A,h[zr]=ar(window.location.href.split("?")[0]),h[tf]=Es(o.replaceSensitiveString),h[hi]=window.innerHeight,h[gi]=window.innerWidth,h),U=Ti();if(U&&(k[mi]=U),k[qd]=v.getAttribute("id")||"",k[Xd]=v.getAttribute("class"),k[Qd]=I?.["aria-label"],_==="a"&&d==="click"&&v instanceof HTMLAnchorElement){var R=v.href.substring(0,_i);k[zd]=o.replaceSensitiveString(R)}return Os(k)},this.addTypeAndTimestamp=function(d,v){return{event:d,timestamp:Date.now(),type:v}},this.addAdditionalEventProperties=function(d,v,p,h,g){g===void 0&&(g=!1);var m=o.addTypeAndTimestamp(d,v);try{if(Xf(m)&&m.event.target!==null){var E=o.getShadowMode(),_=qf(m.event,E);if(g){var S=Gf(_,m.type);if(S)return m.closestTrackedAncestor=_,m.targetElementProperties=o.getEventProperties(m.type,m.closestTrackedAncestor,h),m}var x=Ii(_,p,E);x&&(m.closestTrackedAncestor=x,m.targetElementProperties=o.getEventProperties(m.type,x,h))}}catch(I){}return m},this.extractDataFromDataSource=function(d,v){if(d.sourceType==="DOM_ELEMENT"){var p=ov(d,v);return p?d.elementExtractType==="TEXT"?o.getText(p):d.elementExtractType==="ATTRIBUTE"&&d.attribute?p.getAttribute(d.attribute):void 0:void 0}},this.getTextWithMaskedDescendants=function(d){var v,p,h="[".concat(st,"], [contenteditable]");if(!d.querySelector(h))return d.innerText;var g="",m=Array.from(d.childNodes);try{for(var E=C(m),_=E.next();!_.done;_=E.next()){var S=_.value;if(S.nodeType===Node.TEXT_NODE){g+=S.textContent||"";continue}if(S instanceof Element){if(S.hasAttribute(st)||S.hasAttribute("contenteditable")){g+=at;continue}g+=o.getTextWithMaskedDescendants(S)}}}catch(x){v={error:x}}finally{try{_&&!_.done&&(p=E.return)&&p.call(E)}finally{if(v)throw v.error}}return g},this.hasMaskedAncestor=function(d){var v=o.getShadowMode();return v.enabled?VE(d,v):BE(d)},this.getText=function(d){var v=o.hasMaskedAncestor(d);if(v)return at;var p="";return d.querySelector("[".concat(st,"], [contenteditable]"))?p=o.getTextWithMaskedDescendants(d):p=d.innerText||"",o.replaceSensitiveString(p.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(d){var v,p,h;if(!d)return{};var g=(h=(p=d?.tagName)===null||p===void 0?void 0:p.toLowerCase)===null||h===void 0?void 0:h.call(p),m=(v={},v[Is]=g,v[xs]=o.getText(d),v[zr]=window.location.href.split("?")[0],v);return Os(m)},this.diagnosticsClient=r?.diagnosticsClient,this.selectorEngine=KE(),this.shadowGate=Ff();var s=(a=e.maskTextRegex)!==null&&a!==void 0?a:[],u=[];try{for(var c=C(s),l=c.next();!l.done;l=c.next()){var f=l.value;if(u.length>=sf)break;if(f instanceof RegExp)u.push(f);else if("pattern"in f&&typeof f.pattern=="string")try{u.push(new RegExp(f.pattern,"i"))}catch(d){}}}catch(d){n={error:d}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=u}return t})();var HE="configs.analyticsSDK.browserSDK.autocapture.elementSelector";function wi(t,e){var r=t.remoteConfigClient;if(!(!t.fetchRemoteConfig||!r)){var n=r.subscribe(HE,"all",function(i,o){t.loggerProvider.debug("@amplitude/element-selector: remote-config delivery (source=".concat(String(o),") ").concat(JSON.stringify(i))),e.updateSelectorConfig(i,t.loggerProvider)});return function(){r.unsubscribe(n)}}}var Li=1,WE=function(t){var e;return t.assignedSlot||t.parentElement||((e=t.parentNode)===null||e===void 0?void 0:e.host)||null},lv=function(t,e){return(e==="fixed"||e==="absolute")&&t instanceof HTMLElement?t.offsetParent:WE(t)},qE=function(t){var e=fe(),r=e.document.documentElement.clientHeight||e.innerHeight,n=e.document.documentElement.clientWidth||e.innerWidth,i=t.getBoundingClientRect(),o=i.top+i.height*cf,a=Math.max(i.left,0),s=Math.min(i.right,n);if(o<-Li||o>r+Li||a>=s||i.width<=0)return!1;for(var u=lv(t,e.getComputedStyle(t).position);u;){var c=e.getComputedStyle(u),l=c.overflowY&&c.overflowY!=="visible",f=c.overflowX&&c.overflowX!=="visible";if(l||f){var d=u.getBoundingClientRect();if(l&&(o<d.top-Li||o>d.bottom+Li)||f&&(a=Math.max(a,d.left),s=Math.min(s,d.right),a>=s))return!1}u=lv(u,c.position)}return!0};function cv(t){var e=t.allObservables,r=t.onExposure,n=t.dataExtractor,i=t.exposureDuration,o=i===void 0?jr:i,a=new Map,s=new Map,u=new Set,c=function(g){var m=s.get(g);m&&(clearTimeout(m),s.set(g,null))},l=function(g){if(!qE(g)){c(g);return}if(!(a.get(g)||s.get(g))){var m=setTimeout(function(){a.set(g,!0);var E=n.getElementPath(g);r(E),s.set(g,null)},o);s.set(g,m)}},f=e.exposureObservable,d=e.scrollObservable,v=f.subscribe(function(g){var m=g,E=m.target;m.isIntersecting?(u.add(E),l(E)):(u.delete(E),c(E))}),p=d.subscribe(function(){u.forEach(l)}
10),h=function(){s.forEach(function(g){g&&clearTimeout(g)}),s.clear(),a.clear()};return{unsubscribe:function(){v.unsubscribe(),p.unsubscribe(),h(),u.clear()},reset:function(){h(),u.forEach(l)}}}function dv(t){var e,r,n,i=t.amplitude,o=t.scrollTracker,a=t.currentElementExposed,s=t.elementExposedForPage,u=t.elementExposedInSentEvents,c=t.exposureTracker,l=t.isPageEnd,f=t.lastScroll,d=o.getState(),v=fe(),p=(r=v?.innerWidth)!==null&&r!==void 0?r:0,h=(n=v?.innerHeight)!==null&&n!==void 0?n:0,g=Array.from(a).filter(function(S){return!u.has(S)}),m=(e={},e[zr]=Pt(v),e[rf]=d.maxX+p,e[nf]=d.maxY+h,e[hi]=h,e[gi]=p,e["[Amplitude] Element Exposed"]=g,e),E=Ti();E&&(m[mi]=E);var _=function(){o.reset();var S=o.getState();f.maxX=S.maxX,f.maxY=S.maxY,s.clear(),u.clear(),c?.reset()};if(g.length===0&&d.maxX===f.maxX&&d.maxY===f.maxY){l&&_();return}i?.track("[Amplitude] Viewport Content Updated",m),f.maxX=d.maxX,f.maxY=d.maxY,g.forEach(function(S){u.add(S)}),a.clear(),l&&_()}function fv(t,e,r,n,i){if(!(e.has(t)||r.has(t))){e.add(t),n.add(t);var o=Array.from(n),a=JSON.stringify(o);a.length>=lf&&i(!1)}}function vv(t){var e=t.mutationObservable,r=t.onRescan,n=t.onFlush,i=t.exposureDuration,o=t.quietMs,a=o===void 0?df:o,s=t.maxWaitMs,u=s===void 0?ff:s,c=!1,l,f,d,v,p,h=function(){l&&(clearTimeout(l),l=void 0),f&&(clearTimeout(f),f=void 0),d&&(clearTimeout(d),d=void 0)},g=function(){p&&(document.removeEventListener("DOMContentLoaded",p),p=void 0)},m=function(){return typeof document<"u"&&document.readyState!=="loading"},E=function(){if(!c){if(!m()){p||(p=function(){p=void 0,_()},document.addEventListener("DOMContentLoaded",p));return}c=!0,h(),g(),r(),d=setTimeout(function(){d=void 0,n()},i+vf)}},_=function(){c||(l&&clearTimeout(l),l=setTimeout(E,a))},S=function(){h(),g(),c=!1,_(),f=setTimeout(E,u)};return{start:function(){v||(v=e.subscribe(function(){_()}),S())},reset:function(){S()},stop:function(){v?.unsubscribe(),v=void 0,h(),g()}}}var Ue=(function(t){return t.ClickObservable="clickObservable",t.PointerDownObservable="pointerDownObservable",t.ChangeObservable="changeObservable",t.NavigateObservable="navigateObservable",t.MutationObservable="mutationObservable",t.ScrollObservable="scrollObservable",t.ExposureObservable="exposureObservable",t.BrowserErrorObservable="browserErrorObservable",t.SelectionObservable="selectionObservable",t.MouseMoveObservable="mouseMoveObservable",t})(Ue||{}),Pi=function(t,e){var r,n,i,o,a,s,u,c,l,f,d,v;t===void 0&&(t={}),e?.diagnosticsClient.setTag("plugin.autocapture.version",vi);var p=t.dataAttributePrefix,h=p===void 0?Xr:p,g=t.visualTaggingOptions,m=g===void 0?{enabled:!0}:g;t.cssSelectorAllowlist=(r=t.cssSelectorAllowlist)!==null&&r!==void 0?r:ls,t.actionClickAllowlist=(n=t.actionClickAllowlist)!==null&&n!==void 0?n:cs,t.debounceTime=(i=t.debounceTime)!==null&&i!==void 0?i:0;var E=((o=t.viewportContentUpdated)===null||o===void 0?void 0:o.enabled)!==!1,_=(u=(s=(a=t.viewportContentUpdated)===null||a===void 0?void 0:a.exposureDuration)!==null&&s!==void 0?s:t.exposureDuration)!==null&&u!==void 0?u:jr;t.viewportContentUpdated=T(T({},t.viewportContentUpdated),{exposureDuration:_}),t.pageUrlExcludelist=(c=t.pageUrlExcludelist)===null||c===void 0?void 0:c.reduce(function(L,W){if(typeof W=="string"&&L.push(W),W instanceof RegExp&&L.push(W),typeof W=="object"&&W!==null&&"pattern"in W)try{L.push(new RegExp(W.pattern))}catch(K){return console.warn("Invalid regex pattern: ".concat(W.pattern),K),L}return L},[]);var S=Ud,x="enrichment",I=[],A=new Ri(t,e),D=new Set,k=new Set,U=new Set,R,O,P=function(){var L,W=qe(Ci().map(function(ne){return A.addAdditionalEventProperties(ne,"click",t.cssSelectorAllowlist,h)})),K=qe(new xe.default(function(ne){var B,ge=function(ce){var ue=A.addAdditionalEventProperties(ce,"change",t.cssSelectorAllowlist,h);ne.next(ue)};return(B=fe())===null||B===void 0||B.document.addEventListener("change",ge,{capture:!0}),function(){var ce;return(ce=fe())===null||ce===void 0?void 0:ce.document.removeEventListener("change",ge)}})),z;window.navigation&&(z=qe(new xe.default(function(ne){var B=function(ge){var ce=A.addAdditionalEventProperties(ge,"navigate",t.cssSelectorAllowlist,h);ne.next(ce)};return window.navigation.addEventListener("navigate",B),function(){window.navigation.removeEventListener("navigate",B)}})));var $=A.shadowGate,te=qe(Ai($).map(function(ne){return A.addAdditionalEventProperties(ne,"mutation",t.cssSelectorAllowlist,h)})),Q=ev(),ae=tv(te,t.cssSelectorAllowlist,function(ne){O=ne},$);return L={},L[Ue.ChangeObservable]=K,L[Ue.ClickObservable]=W,L[Ue.MutationObservable]=te,L[Ue.NavigateObservable]=z,L[Ue.ScrollObservable]=Q,L[Ue.ExposureObservable]=ae,L},N=Us(Object.values((f=(l=t.pageActions)===null||l===void 0?void 0:l.labeledEvents)!==null&&f!==void 0?f:{})),G=Ms((v=(d=t.pageActions)===null||d===void 0?void 0:d.triggers)!==null&&v!==void 0?v:[]),M=sv(N,G,A,t),V=function(L){var W,K;L&&(t.pageActions=T(T({},t.pageActions),L),N=Us(Object.values((W=t.pageActions.labeledEvents)!==null&&W!==void 0?W:{})),G=Ms((K=t.pageActions.triggers)!==null&&K!==void 0?K:[]),M.update(N,G,t))},X=function(L,W){return y(void 0,void 0,void 0,function(){var K,z,$,te,Q,ae,ne,B,ge,ce,ue,j,Le,Ne,Ge,Re,Ve,Ke,J,ie,Z,me,ee,At,de,lt,He;return b(this,function(Do){return typeof document>"u"?[2]:(K=!1,L.fetchRemoteConfig&&(L.remoteConfigClient?L.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",function(re){V(re)}):L.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),z=wi(L,A),z&&I.push({unsubscribe:z}),$=Dt(t,t.cssSelectorAllowlist),te=Dt(t,t.actionClickAllowlist),Q=P(),ae=Yf({allObservables:Q,amplitude:W,shouldTrackEvent:$,evaluateTriggers:M.evaluate.bind(M)}),I.push(ae),ne=Qf({allObservables:Q,getEventProperties:function(){for(var re=[],Ee=0;Ee<arguments.length;Ee++)re[Ee]=arguments[Ee];return A.getEventProperties.apply(A,F(F([],w(re),!1),[h],!1))},amplitude:W,shouldTrackEvent:$,evaluateTriggers:M.evaluate.bind(M)}),I.push(ne),B=Jf({allObservables:Q,options:t,getEventProperties:function(){for(var re=[],Ee=0;Ee<arguments.length;Ee++)re[Ee]=arguments[Ee];return A.getEventProperties.apply(A,F(F([],w(re),!1),[h],!1))},amplitude:W,shouldTrackEvent:$,shouldTrackActionClick:te}),B&&I.push(B),ge=Zf({allObservables:Q,amplitude:W}),I.push(ge),ce=T({},ge.getState()),ue={},j=fe(),Ne=function(re){re&&Le?.reset(),!(re&&K)&&(re&&(K=!0,setTimeout(function(){K=!1},100)),dv({amplitude:W,scrollTracker:ge,currentElementExposed:U,elementExposedForPage:D,elementExposedInSentEvents:k,exposureTracker:ue.exposure,isPageEnd:re,lastScroll:ce}))},Ge=Pt(j),Re=function(){var re=Pt(j);re!==Ge&&(Ge=re,Ne(!0))},Ve=function(re,Ee){var tt=Pt(j),xr=jf(Ee,j);if(tt===xr){re();return}Ge=xr,Ne(!0),re()},Ke=function(re){fv(re,D,k,U,Ne)},E&&(ue.exposure=cv({allObservables:Q,onExposure:Ke,dataExtractor:A,exposureDuration:_}),ue.exposure&&I.push(ue.exposure),Le=vv({mutationObservable:Q[Ue.MutationObservable],onRescan:function(){var re,Ee;(Ee=(re=L.loggerProvider)===null||re===void 0?void 0:re.debug)===null||Ee===void 0||Ee.call(re,"@amplitude/plugin-autocapture-browser: initial exposure snapshot \u2014 rescanning DOM"),O?.()},onFlush:function(){var re,Ee;(Ee=(re=L.loggerProvider)===null||re===void 0?void 0:re.debug)===null||Ee===void 0||Ee.call(re,"@amplitude/plugin-autocapture-browser: initial exposure snapshot \u2014 flushing viewport content updated"),Ne(!1)},exposureDuration:_}),Le.start(),I.push({unsubscribe:function(){Le?.stop()}}),J=function(){Ne(!0)},j?.addEventListener("beforeunload",J),R=function(){j?.removeEventListener("beforeunload",J)},I.push({unsubscribe:function(){return R()}}
10),ie=Q[Ue.NavigateObservable],ie?I.push(ie.subscribe(function(re){var Ee,tt,xr=(tt=(Ee=re.event)===null||Ee===void 0?void 0:Ee.destination)===null||tt===void 0?void 0:tt.url;if(xr){var Nl=xi(xr);if(Nl===Ge)return;Ge=Nl,Ne(!0);return}Re()})):j&&(Z=function(){Re()},j.addEventListener("popstate",Z),me=j.history.pushState,ee=j.history.replaceState,j.history&&me&&(j.history.pushState=new Proxy(me,{apply:function(re,Ee,tt){Ve(function(){re.apply(Ee,tt)},tt[2])}})),j.history&&ee&&(j.history.replaceState=new Proxy(ee,{apply:function(re,Ee,tt){Ve(function(){re.apply(Ee,tt)},tt[2])}})),I.push({unsubscribe:function(){j.removeEventListener("popstate",Z),j.history&&me&&(j.history.pushState=me),j.history&&ee&&(j.history.replaceState=ee)}}))),(He=L?.loggerProvider)===null||He===void 0||He.log("".concat(S," has been successfully added.")),window.opener&&m.enabled&&(At=t.cssSelectorAllowlist,de=t.actionClickAllowlist,lt=ys(),$f(lt,{dataExtractor:A,isElementSelectable:Dt(t,F(F([],w(At),!1),w(de),!1)),cssSelectorAllowlist:At,actionClickAllowlist:de}),Ts(lt),lt.setup(T({logger:L?.loggerProvider},L?.serverZone&&{endpoint:ci[L.serverZone]}))),[2])})})},H=function(L){return y(void 0,void 0,void 0,function(){return b(this,function(W){return[2,L]})})},Y=function(){return y(void 0,void 0,void 0,function(){var L,W,K,z,$;return b(this,function(te){try{for(L=C(I),W=L.next();!W.done;W=L.next())K=W.value,K.unsubscribe()}catch(Q){z={error:Q}}finally{try{W&&!W.done&&($=L.return)&&$.call(L)}finally{if(z)throw z.error}}return[2]})})};return{name:S,type:x,setup:X,execute:H,teardown:Y}};var XE=3e3,jE=["mutation","navigate"];function pv(t){var e=t.amplitude,r=t.allObservables,n=t.getEventProperties,i=t.shouldTrackDeadClick,o=r.clickObservable,a=r.mutationObservable,s=r.navigateObservable,u=o.filter(function(v){return ft(v)&&i("click",v.closestTrackedAncestor)&&v.event.target instanceof Element&&v.event.target.closest('a[target="_blank"]')===null&&v.event.button===en.LEFT_OR_TOUCH_CONTACT}),c=s?Je(a,s):a,l=Je(u,c),f=null,d=Ht(l,function(v){return f&&jE.includes(v.type)?(clearTimeout(f),f=null,Promise.resolve(null)):v.type==="click"?f?Promise.resolve(null):new Promise(function(p){f=setTimeout(function(){p(v),f=null},XE)}):Promise.resolve(null)});return d.subscribe(function(v){if(v){var p={"[Amplitude] X":v.event.clientX,"[Amplitude] Y":v.event.clientY};e.track(Gd,T(T({},n("click",v.closestTrackedAncestor)),p),{time:v.timestamp})}})}var Ev=hs,_v=ps,hv=gs;function gv(t,e){var r,n,i,o,a=e.event,s=a.pageX,u=a.pageY;t.yMin=Math.min((r=t.yMin)!==null&&r!==void 0?r:u,u),t.yMax=Math.max((n=t.yMax)!==null&&n!==void 0?n:u,u),t.xMin=Math.min((i=t.xMin)!==null&&i!==void 0?i:s,s),t.xMax=Math.max((o=t.xMax)!==null&&o!==void 0?o:s,s),t.isOutOfBounds=t.yMax-t.yMin>hv||t.xMax-t.xMin>hv}function mv(t){if(t.length===0)return null;var e=t[0],r=t[t.length-1],n=T({"[Amplitude] Begin Time":new Date(e.timestamp).toISOString(),"[Amplitude] End Time":new Date(r.timestamp).toISOString(),"[Amplitude] Duration":r.timestamp-e.timestamp,"[Amplitude] Clicks":t.map(function(i){return{X:i.event.pageX,Y:i.event.pageY,Time:i.timestamp}}),"[Amplitude] Click Count":t.length},e.targetElementProperties);return{rageClickEvent:n,time:e.timestamp}}function zE(t,e){var r=Math.max(0,t.length-Ev+1),n=t[r];return e.timestamp-n.timestamp>=_v}function $E(t,e){return t.length>0&&t[t.length-1].closestTrackedAncestor!==e.closestTrackedAncestor}function bv(t){var e=this,r=t.amplitude,n=t.allObservables,i=t.shouldTrackRageClick,o=n.pointerDownObservable,a=n.selectionObservable,s=[],u={},c=null;function l(p){s=[],u={},p&&(gv(u,p),s.push(p))}var f=Ht(o.filter(function(p){return i("click",p.closestTrackedAncestor)}),function(p){return y(e,void 0,void 0,function(){var h;return b(this,function(g){return gv(u,p),h=null,s.length===0||$E(s,p)||zE(s,p)||u.isOutOfBounds?(c&&(h=mv(s)),l(p)):s.push(p),c&&(clearTimeout(c.timerId),c.resolve(h),c=null),s.length>=Ev?[2,new Promise(function(m){c={resolve:m,timerId:setTimeout(function(){m(mv(s))},_v)}})]:[2,null]})})}),d=a?.subscribe(function(){l()}),v=f.subscribe(function(p){p!==null&&r.track(Bd,p.rageClickEvent,{time:p.time})});return{unsubscribe:function(){v.unsubscribe(),d?.unsubscribe()}}}var YE=2e3;function Sv(t){var e=t.amplitude,r=t.allObservables,n=t.shouldTrackErrorClick,i=r.pointerDownObservable,o=r.browserErrorObservable,a=i.filter(function(l){return ft(l)&&n("click",l.closestTrackedAncestor)&&l.event.target instanceof Element&&l.event.target.closest('a[target="_blank"]')===null&&l.event.button===en.LEFT_OR_TOUCH_CONTACT}),s=null,u=null,c=function(){s!==null&&(clearTimeout(s),s=null),u=null};return Je(a,o).subscribe(function(l){var f;if(l.type==="click"){c(),u=l,s=setTimeout(c,YE);return}l.type==="error"&&u&&(e.track(Vd,T((f={},f["[Amplitude] Kind"]=l.event.kind,f["[Amplitude] Message"]=l.event.message,f["[Amplitude] Stack"]=l.event.stack,f["[Amplitude] Filename"]=l.event.filename,f["[Amplitude] Line Number"]=l.event.lineNumber,f["[Amplitude] Column Number"]=l.event.columnNumber,f),u.targetElementProperties)),c())})}var bt=(function(t){return t.INCREASING="increasing",t.DECREASING="decreasing",t})(bt||{}),dr=(function(t){return t.X="x",t.Y="y",t})(dr||{}),QE=function(t){var e=t.allWindowObservables,r=e.mouseMoveObservable;return new xe.default(function(n){var i=null,o=null,a=null;return r.subscribe(function(s){var u={x:s.clientX,y:s.clientY};if(i===null){i=u;return}u.x>i.x?(o===bt.DECREASING&&n.next(dr.X),o=bt.INCREASING):u.x<i.x&&(o===bt.INCREASING&&n.next(dr.X),o=bt.DECREASING),u.y>i.y?(a===bt.DECREASING&&n.next(dr.Y),a=bt.INCREASING):u.y<i.y&&(a===bt.INCREASING&&n.next(dr.Y),a=bt.DECREASING),i=u})})};function JE(t){var e=+Date.now();t.startTime=t.startTime||e;var r=t.changes,n=t.changesThreshold;r.push(e),r.length>n&&r.shift()}function yv(t){var e=t.changes,r=t.changesThreshold,n=t.thresholdMs;if(e.length<r)return!1;var i=e[e.length-1]-e[0];return i<n}function Tv(t){t.changes=[],t.startTime=void 0}function Iv(t){for(var e=t.changes,r=t.thresholdMs,n=0,i=e[e.length-1];n<e.length;n++){var o=i-e[n];if(o<r)break}n!==0&&(t.startTime=e[n],t.changes.splice(0,n))}function ZE(t,e){var r=void 0;if(yv(t)&&(r=t.startTime),yv(e)){var n=e.startTime;n&&(!r||n<r)&&(r=n)}return r}var xv=20,Av=2e3,e0=function(t){var e=t.mouseDirectionChangeObservable,r=t.directionChanges,n=r===void 0?xv:r,i=t.thresholdMs,o=i===void 0?Av:i;return new xe.default(function(a){var s={changes:[],changesThreshold:n,thresholdMs:o},u={changes:[],changesThreshold:n,thresholdMs:o},c=void 0,l=null;function f(){c!==void 0&&(a.next(c),c=void 0,l!==null&&clearTimeout(l),Tv(s),Tv(u))}return e.subscribe(function(d){l!==null&&clearTimeout(l),JE(d===dr.X?s:u);var v=ZE(s,u);return v?(c=c||v,l=setTimeout(function(){f(),l=null},o)):f(),Iv(s),Iv(u),function(){l!==null&&(clearTimeout(l),l=null)}})})},Cv=function(t){var e=t.amplitude,r=t.options,n=t.allObservables,i=t.directionChanges,o=i===void 0?xv:i,a=t.thresholdMs,s=a===void 0?Av:a,u=QE({allWindowObservables:n}),c=e0({mouseDirectionChangeObservable:u,directionChanges:o,thresholdMs:s});return c.subscribe(function(l){Zr(r)&&e.track(Hd,void 0,{time:l})})};function Bs(t,e,r,n){if(!n)return[];var i=t[e];return typeof i=="object"&&i!==null&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:r}var Di=5,Oi=4e3,Vs=function(t){var e;t===void 0&&(t={});var r=Md,n="enrichment",i=[],o=t.errorClicks!==!1;t.errorClicks||(o=!1);var a=t.deadClicks!==!1&&t.deadClicks!==null,s=t.rageClicks!==!1&&t.rageClicks!==null,u=t.thrashedCursor!==!1&&t.thrashedCursor!==null;t.thrashedCursor||(u=!1);var c=Bs(t,"rageClicks",vs,s),l=Bs(t,"deadClicks",ds,a),f=Bs(t,"errorClicks",fs,o),d=(e=t.dataAttributePrefix)!==null&&e!==void 0?e:Xr,v=new Ri(t),p=F([],w(new Set(F(F(F([],w(c),!1),w(l),!1),w(f),!1))),!1),h=function(){var _,S=function(P){return qe(Ci(P).map(function(N){return v.addAdditionalEventProperties(N,"click",p,d,!0)}))},x=S("click"),I=S("pointerdown"),A=qe(rv().map(function(P){return v.addTypeAndTimestamp(P,"error")})),D=qe(Ai(v.shadowGate).map(function(P){return v.addAdditionalEventProperties(P,"mutation",p,d)})),k;if(window.navigation){var U=new xe.default(function(P){var N=function(G){P.next(T(T({},G),{type:"navigate"}))};return window.navigation.addEventListener("navigate",N),function(){window.navigation.removeEventListener("navigate",N)}});k=qe(U.map(function(P){return v.addAdditionalEventProperties(P,"navigate",p,d)}))}var R=qe(new xe.default(function(P){var N=function(){var G=document.activeElement;if(G&&(G.tagName==="TEXTAREA"||G.tagName==="INPUT")){var M=void 0,V=void 0;try{if(M=G.selectionStart,V=G.selectionEnd,M===V)return}catch(H){return}return P.next()}var X=window.getSelection();if(!(!X||X.isCollapsed))return P.next()};return window.document.addEventListener("selectionchange",N),function(){window.document.removeEventListener("selectionchange",N)}})),O=qe(nv());return _={},_[Ue.ClickObservable]=x,_[Ue.PointerDownObservable]=I,_[Ue.MutationObservable]=D,_[Ue.NavigateObservable]=k,_[Ue.BrowserErrorObservable]=A,_[Ue.SelectionObservable]=R,_[Ue.MouseMoveObservable]=O,_},g=function(_,S){return y(void 0,void 0,void 0,function(){var x,I,A,D,k,U,R,O,P,N,G,M;return b(this,function(V){return typeof document>"u"?[2]:(x=h(),I=wi(_,v),I&&i.push({unsubscribe:I}),s&&(A=Dt(t,c),D=bv({allObservables:x,amplitude:S,shouldTrackRageClick:A}),i.push(D)),a&&(k=Dt(t,l),U=pv({amplitude:S,allObservables:x,getEventProperties:function(X,H){return v.getEventProperties(X,H,d)},shouldTrackDeadClick:k}),i.push(U)),o&&(R=Dt(t,f),O=Sv({amplitude:S,allObservables:x,shouldTrackErrorClick:R}),i.push(O)),u&&(P=void 0,N=void 0,typeof t.thrashedCursor=="object"&&(P=t.thrashedCursor.directionChanges,N=t.thrashedCursor.threshold,P&&P<Di&&(_.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(P," is below the minimum of ").concat(Di,", setting to ").concat(Di)),P=Di),N&&N>Oi&&(_.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(N," is above the maximum of ").concat(Oi,", setting to ").concat(Oi)),N=Oi)),G=Cv({amplitude:S,options:t,allObservables:x,directionChanges:P,thresholdMs:N}),i.push(G)),(M=_?.loggerProvider)===null||M===void 0||M.log("".concat(r," has been successfully added.")),[2])})})},m=function(_){return y(void 0,void 0,void 0,function(){return b(this,function(S){return[2,_]})})},E=function(){return y(void 0,void 0,void 0,function(){var _,S,x,I,A;return b(this,function(D){try{for(_=C(i),S=_.next();!S.done;S=_.next())x=S.value,x.unsubscribe()}catch(k){I={error:k}}finally{try{S&&!S.done&&(A=_.return)&&A.call(_)}finally{if(I)throw I.error}}return[2]})})};return{name:r,type:n,setup:g,execute:m,teardown:E}};var t0=100,r0=1e4;function Rv(t,e){var r=t.startTime+t.duration;return e.filter(function(n){return n.startTime<r&&n.startTime+n.duration>t.startTime}).map(function(n){return n.name})}function n0(t,e){var r,n=Rv(t,e),i=(r=t.scripts)!==null&&r!==void 0?r:[],o=i.map(function(l){return l.sourceURL}
10).filter(Boolean),a=i.map(function(l){return l.sourceFunctionName}).filter(Boolean),s=i.map(function(l){return l.sourceCharPosition}).filter(function(l){return typeof l=="number"&&l>=0}),u=i.map(function(l){return l.invokerType}).filter(Boolean),c=i.map(function(l){return l.invoker}).filter(Boolean);return T(T(T(T(T(T(T({"[Amplitude] Main Thread Block Source":"long-animation-frame","[Amplitude] Main Thread Block Duration":t.duration,"[Amplitude] Main Thread Block Blocking Duration":t.blockingDuration,"[Amplitude] Main Thread Block Start Time":t.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),{"[Amplitude] Main Thread Block Render Start":t.renderStart,"[Amplitude] Main Thread Block Style And Layout Start":t.styleAndLayoutStart,"[Amplitude] Main Thread Block Script Count":i.length}),o.length>0&&{"[Amplitude] Main Thread Block Script URLs":o}),a.length>0&&{"[Amplitude] Main Thread Block Script Functions":a}),s.length>0&&{"[Amplitude] Main Thread Block Script Positions":s}),u.length>0&&{"[Amplitude] Main Thread Block Invoker Types":u}),c.length>0&&{"[Amplitude] Main Thread Block Invokers":c})}function i0(t,e){var r,n=Rv(t,e),i=(r=t.attribution)!==null&&r!==void 0?r:[];return T(T({"[Amplitude] Main Thread Block Source":"long-task","[Amplitude] Main Thread Block Duration":t.duration,"[Amplitude] Main Thread Block Blocking Duration":t.duration,"[Amplitude] Main Thread Block Start Time":t.startTime},n.length>0&&{"[Amplitude] Main Thread Block Measures":n}),i.length>0&&{"[Amplitude] Main Thread Block Attribution":i.map(function(o){return o.name})})}function o0(){if(typeof PerformanceObserver>"u")return null;try{var t=PerformanceObserver.supportedEntryTypes;if(t.includes("long-animation-frame"))return"long-animation-frame";if(t.includes("longtask"))return"longtask"}catch(e){}return null}function wv(t){var e=t.amplitude,r=t.options,n=t.durationThreshold,i=n===void 0?t0:n,o=o0();if(!o)return{unsubscribe:function(){}};var a=[],s=new PerformanceObserver(function(c){var l,f,d=performance.now();try{for(var v=C(c.getEntries()),p=v.next();!p.done;p=v.next()){var h=p.value;a.push(h)}}catch(m){l={error:m}}finally{try{p&&!p.done&&(f=v.return)&&f.call(v)}finally{if(l)throw l.error}}for(var g=d-r0;a.length>0&&a[0].startTime<g;)a.shift()});try{s.observe({entryTypes:["measure"]})}catch(c){}var u=new PerformanceObserver(function(c){var l,f;try{for(var d=C(c.getEntries()),v=d.next();!v.done;v=d.next()){var p=v.value;if(!Zr(r))return;if(!(p.duration<i)){var h=o==="long-animation-frame"?n0(p,a):i0(p,a);e.track(Wd,h)}}}catch(g){l={error:g}}finally{try{v&&!v.done&&(f=d.return)&&f.call(d)}finally{if(l)throw l.error}}});try{u.observe({entryTypes:[o]})}catch(c){return s.disconnect(),{unsubscribe:function(){}}}return{unsubscribe:function(){u.disconnect(),s.disconnect()}}}var a0=100,Ks=function(t){t===void 0&&(t={});var e=Fd,r="enrichment",n=[],i=t.mainThreadBlock===!0||typeof t.mainThreadBlock=="object"&&t.mainThreadBlock!==null,o=function(u,c){return y(void 0,void 0,void 0,function(){var l,f,d;return b(this,function(v){return typeof document>"u"?[2]:(i&&(l=a0,typeof t.mainThreadBlock=="object"&&t.mainThreadBlock.durationThreshold!==void 0&&(l=t.mainThreadBlock.durationThreshold),f=wv({amplitude:c,options:t,durationThreshold:l}),n.push(f)),(d=u?.loggerProvider)===null||d===void 0||d.log("".concat(e," performance tracking has been successfully added.")),[2])})})},a=function(u){return y(void 0,void 0,void 0,function(){return b(this,function(c){return[2,u]})})},s=function(){return y(void 0,void 0,void 0,function(){var u,c,l,f,d;return b(this,function(v){try{for(u=C(n),c=u.next();!c.done;c=u.next())l=c.value,l.unsubscribe()}catch(p){f={error:p}}finally{try{c&&!c.done&&(d=u.return)&&d.call(u)}finally{if(f)throw f.error}}return[2]})})};return{name:e,type:r,setup:o,execute:a,teardown:s}};var s0="AMP",cw="".concat(s0,"_unsent");var Wt=["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"],Hs=["authorization","cookie","set-cookie"];var je=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var u0=function(t){return t?(t^Math.random()*16>>t/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Ws)},Lv=F([],w(Array(256).keys()),!1).map(function(t){return t.toString(16).padStart(2,"0")}),Ws=function(t){var e,r=je();if(!(!((e=r?.crypto)===null||e===void 0)&&e.getRandomValues))return u0(t);var n=r.crypto.getRandomValues(new Uint8Array(16));return n[6]=n[6]&15|64,n[8]=n[8]&63|128,F([],w(n.entries()),!1).map(function(i){var o=w(i,2),a=o[0],s=o[1];return[4,6,8,10].includes(a)?"-".concat(Lv[s]):Lv[s]}).join("")};var qs=function(t,e){return!e||!e.length?!0:e.some(function(r){return typeof r=="string"?t===r:t.match(r)})};function l0(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null||t===void 0}function js(t,e,r){if(t){var n=e.map(Pv),i=r.map(Pv);Ov({json:t,allowlist:n,excludelist:i,ancestors:[]})}}function Ov(t){var e,r,n=t.json,i=t.targetObject,o=t.allowlist,a=t.excludelist,s=t.ancestors,u=t.parentObject,c=t.targetKey;
10i||(i=n);var l=Object.keys(i);try{for(var f=C(l),d=f.next();!d.done;d=f.next()){var v=d.value,p=F(F([],w(s),!1),[v],!1);l0(i[v])?(!Dv(p,o)||Dv(p,a))&&delete i[v]:Ov({json:n,targetObject:i[v],allowlist:o,excludelist:a,ancestors:p,parentObject:i,targetKey:v})}}catch(h){e={error:h}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}Object.keys(i).length===0&&u&&c&&delete u[c]}function Pv(t){return t.startsWith("/")&&(t=t.slice(1)),t.split("/").map(function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")})}function Xs(t,e,r,n){if(r===void 0&&(r=0),n===void 0&&(n=0),n===e.length)return r===t.length;if(r===t.length){for(;n<e.length&&e[n]==="**";)n++;return n===e.length}var i=e[n];if(i==="**"){if(n+1===e.length)return!0;for(var o=r;o<=t.length;o++)if(Xs(t,e,o,n+1))return!0;return!1}else return i==="*"||i===t[r]?Xs(t,e,r+1,n+1):!1}function Dv(t,e){return e.some(function(r){return Xs(t,r)})}var c0=500,Nv=100,Uv=(function(){function t(e){this.request=e}return t.prototype.headers=function(e){var r,n;e===void 0&&(e=[]);var i=this.request.headers,o={};if(Array.isArray(i))i.forEach(function(f){var d=w(f,2),v=d[0],p=d[1];o[v]=p});else if(i instanceof Headers)i.forEach(function(f,d){o[d]=f});else if(typeof i=="object"&&i!==null)try{for(var a=C(Object.entries(i)),s=a.next();!s.done;s=a.next()){var u=w(s.value,2),c=u[0],l=u[1];o[c]=l}}catch(f){r={error:f}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return Ni(o,{allow:e})},Object.defineProperty(t.prototype,"bodySize",{get:function(){if(typeof this._bodySize=="number")return this._bodySize;var e=je();if(e?.TextEncoder){var r=this.request.body;return this._bodySize=Fv(r,Nv),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return typeof this.request.body=="string"?this.request.body:null},enumerable:!1,configurable:!0}),t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),y(this,void 0,void 0,function(){var n;return b(this,function(i){return e.length===0?[2,null]:(n=this.body,[2,zs(n,e,r)])})})},t})();var Mv=(function(){function t(e,r){this.bodyRaw=e,this.requestHeaders=r}return t.prototype.headers=function(e){return e===void 0&&(e=[]),Ni(this.requestHeaders,{allow:e})},Object.defineProperty(t.prototype,"bodySize",{get:function(){return Fv(this.bodyRaw,Nv)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return typeof this.bodyRaw=="string"?this.bodyRaw:null},enumerable:!1,configurable:!0}),t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),y(this,void 0,void 0,function(){var n;return b(this,function(i){return e.length===0?[2,null]:(n=this.body,[2,zs(n,e,r)])})})},t})();function Fv(t,e){var r,n,i,o=je(),a=o?.TextEncoder;if(a&&t!=null){var s;if(typeof t=="string")s=t,i=new a().encode(s).length;else if(typeof Blob<"u"&&t instanceof Blob)s=t,i=s.size;else if(typeof URLSearchParams<"u"&&t instanceof URLSearchParams)s=t,i=new a().encode(s.toString()).length;else if(ArrayBuffer.isView(t))s=t,i=s.byteLength;else if(t instanceof ArrayBuffer)s=t,i=s.byteLength;else if(typeof FormData<"u"&&t instanceof FormData){var u=t,c=0,l=0;try{for(var f=C(u.entries()),d=f.next();!d.done;d=f.next()){var v=w(d.value,2),p=v[0],h=v[1];if(c+=p.length,typeof h=="string")c+=new a().encode(h).length;else if(typeof Blob<"u"&&h instanceof Blob)c+=h.size;else return;if(++l>=e)return}}catch(g){r={error:g}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}i=c}else if(typeof ReadableStream<"u"&&t instanceof ReadableStream){s=t;return}return i}}var Gv=(function(){function t(e){this.response=e}return t.prototype.headers=function(e){var r;if(e===void 0&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,i={};return(r=n?.forEach)===null||r===void 0||r.call(n,function(o,a){i[a]=o}),Ni(i,{allow:e})}},Object.defineProperty(t.prototype,"bodySize",{get:function(){var e,r;if(this._bodySize!==void 0)return this._bodySize;var n=(r=(e=this.response.headers)===null||e===void 0?void 0:e.get)===null||r===void 0?void 0:r.call(e,"content-length"),i=n?parseInt(n,10):void 0;return this._bodySize=i,i}
10,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),t.prototype.text=function(){return y(this,void 0,void 0,function(){var e,r,n,i;return b(this,function(o){switch(o.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),o.label=1;case 1:return o.trys.push([1,3,,4]),e=this.clonedResponse.text(),r=new Promise(function(a){return setTimeout(function(){return a(null)},c0)}),[4,Promise.race([e,r])];case 2:return n=o.sent(),[2,n];case 3:return i=o.sent(),[2,null];case 4:return[2]}})})},t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),y(this,void 0,void 0,function(){var n;return b(this,function(i){switch(i.label){case 0:return e.length===0?[2,null]:[4,this.text()];case 1:return n=i.sent(),[2,zs(n,e,r)]}})})},t})();var Bv=(function(){function t(e,r,n,i){this.statusCode=e,this.headersString=r,this.size=n,this.getJson=i}return Object.defineProperty(t.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),t.prototype.headers=function(e){var r,n;if(e===void 0&&(e=[]),!this.headersString)return{};var i={},o=this.headersString.split(`\r 11`);try{for(var a=C(o),s=a.next();!s.done;s=a.next()){var u=s.value,c=w(u.split(": "),2),l=c[0],f=c[1];l&&f&&(i[l]=f)}}catch(d){r={error:d}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return Ni(i,{allow:e})},t.prototype.json=function(e,r){return e===void 0&&(e=[]),r===void 0&&(r=[]),y(this,void 0,void 0,function(){var n;return b(this,function(i){return e.length===0?[2,null]:(n=this.getJson(),n?(js(n,e,r),[2,n]):[2,null])})})},t})();function zs(t,e,r){if(!t)return null;try{var n=JSON.parse(t);return js(n,e,r),n}catch(i){return null}}var ki=(function(t){return t.REDACT="redact",t.REMOVE="remove",t})(ki||{}),kv="[REDACTED]",Ni=function(t,e){var r,n,i=e.allow,o=i===void 0?[]:i,a=e.strategy,s=a===void 0?ki.REMOVE:a,u=F([],w(Hs),!1),c={},l=function(p){var h=p.toLowerCase();u.find(function(g){return g.toLowerCase()===h})?s===ki.REDACT&&(c[p]=kv):o.find(function(g){return g.toLowerCase()===h})?c[p]=t[p]:s===ki.REDACT&&(c[p]=kv)};try{for(var f=C(Object.keys(t)),d=f.next();!d.done;d=f.next()){var v=d.value;l(v)}}catch(p){r={error:p}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return c},Vv=(function(){function t(e,r,n,i,o,a,s,u,c,l,f){s===void 0&&(s=0),this.type=e,this.method=r,this.timestamp=n,this.startTime=i,this.url=o,this.requestWrapper=a,this.status=s,this.duration=u,this.responseWrapper=c,this.error=l,this.endTime=f}return t.prototype.toSerializable=function(){var e,r,n,i,o={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:(e=this.requestWrapper)===null||e===void 0?void 0:e.headers(F([],w(Wt),!1)),requestBodySize:(r=this.requestWrapper)===null||r===void 0?void 0:r.bodySize,responseHeaders:(n=this.responseWrapper)===null||n===void 0?void 0:n.headers(F([],w(Wt),!1)),responseBodySize:(i=this.responseWrapper)===null||i===void 0?void 0:i.bodySize};return Object.fromEntries(Object.entries(o).filter(function(a){var s=w(a,2),u=s[0],c=s[1];return c!==void 0}))},t})();function d0(t){return typeof t=="object"&&t!==null&&"url"in t&&"method"in t}var $s=(function(){function t(e,r){r===void 0&&(r=Ws()),this.callback=e,this.id=r}return t})();function qt(t){try{t()}catch(e){}}var f0=(function(){function t(e){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=e;var r=je();t.isSupported()&&(this.globalScope=r)}return t.isSupported=function(){var e=je();return!!e&&!!e.fetch},t.prototype.subscribe=function(e,r){var n,i,o,a,s,u,c,l,f,d;if(this.logger||(this.logger=r),this.eventCallbacks.set(e.id,e),!this.isObserving){var v=(o=(i=(n=this.globalScope)===null||n===void 0?void 0:n.XMLHttpRequest)===null||i===void 0?void 0:i.prototype)===null||o===void 0?void 0:o.open,p=(u=(s=(a=this.globalScope)===null||a===void 0?void 0:a.XMLHttpRequest)===null||s===void 0?void 0:s.prototype)===null||u===void 0?void 0:u.send,h=(f=(l=(c=this.globalScope)===null||c===void 0?void 0:c.XMLHttpRequest)===null||l===void 0?void 0:l.prototype)===null||f===void 0?void 0:f.setRequestHeader;v&&p&&h&&this.observeXhr(v,p,h);var g=(d=this.globalScope)===null||d===void 0?void 0:d.fetch;g&&this.observeFetch(g),this.isObserving=!0}},t.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},t.prototype.triggerEventCallbacks=function(e){var r=this;this.eventCallbacks.forEach(function(n){try{n.callback(e)}catch(i){qt(function(){var o;(o=r.logger)===null||o===void 0||o.debug("an unexpected error occurred while triggering event callbacks",i)})}})},t.prototype.handleNetworkRequestEvent=function(e,r,n,i,o,a,s){var u;if(!(a===void 0||s===void 0)){var c,l="GET";if(d0(r)?(c=r.url,l=r.method):c=(u=r?.toString)===null||u===void 0?void 0:u.call(r),c)try{var f=new URL(c);c="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(m){}l=n?.method||l;var d,v;i&&(d=i.status),o&&(v={name:o.name||"UnknownError",message:o.message||"An unknown error occurred"},d=0);var p=Math.floor(performance.now()-s),h=Math.floor(a+p),g=new Vv(e,l,a,a,c,n,d,p,i,v,h);this.triggerEventCallbacks(g)}},t.prototype.getTimestamps=function(){var e,r;return{startTime:(e=Date.now)===null||e===void 0?void 0:e.call(Date),durationStart:(r=performance?.now)===null||r===void 0?void 0:r.call(performance)}},t.prototype.observeFetch=function(e){var r=this;!this.globalScope||!e||(this.globalScope.fetch=function(n,i){return y(r,void 0,void 0,function(){var o,a,s,u,c=this;return b(this,function(l){switch(l.label){case 0:try{o=this.getTimestamps()}catch(f){qt(function(){var d;return(d=c.logger)===null||d===void 0?void 0:d.debug("an unexpected error occurred while retrieving timestamps",f)})}l.label=1;case 1:return l.trys.push([1,3,,4]),[4,e(n,i)];case 2:return a=l.sent(),[3,4];case 3:return u=l.sent(),s=u,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,i?new Uv(i):void 0,a?new Gv(a):void 0,s,o?.startTime,o?.durationStart)}catch(f){qt(function(){var d;return(d=c.logger)===null||d===void 0?void 0:d.debug("an unexpected error occurred while handling fetch",f)})}if(a)return[2,a];throw s}})})})},t.createXhrJsonParser=function(e,r){return function(){var n;try{if(e.responseType==="json"){if(!((n=r.globalScope)===null||n===void 0)&&n.structuredClone)return r.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(i){return i instanceof Error&&i.name==="InvalidStateError"&&qt(function(){var o;return(o=r.logger)===null||o===void 0?void 0:o.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))}),null}return null}},t.prototype.observeXhr=function(e,r,n){if(!(!this.globalScope||!e||!r)){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var a,s=[],u=0;u<arguments.length;u++)s[u]=arguments[u];var c=this,l=w(s,2),f=l[0],d=l[1];try{c.$$AmplitudeAnalyticsEvent=T({method:f,url:(a=d?.toString)===null||a===void 0?void 0:a.call(d),headers:{}},o.getTimestamps())}catch(v){qt(function(){var p;return(p=o.logger)===null||p===void 0?void 0:p.debug("an unexpected error occurred while calling xhr open",v)})}return e.apply(c,s)},i.send=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u=this,c=u,l=t.createXhrJsonParser(u,o),f=a[0],d=c.$$AmplitudeAnalyticsEvent;return c.$$AmplitudeAnalyticsEvent&&c.addEventListener("loadend",function(){try{var v=c.getAllResponseHeaders(),p=c.getResponseHeader("content-length"),h=new Bv(c.status,v,p?parseInt(p,10):void 0,l),g=c.$$AmplitudeAnalyticsEvent.headers,m=new Mv(f,g);d.status=c.status,o.handleNetworkRequestEvent("xhr",{url:d.url,method:d.method},m,h,void 0,d.startTime,d.durationStart)}catch(E){qt(function(){var _;return(_=o.logger)===null||_===void 0?void 0:_.debug("an unexpected error occurred while handling xhr send",E)})}}),r.apply(c,a)},i.setRequestHeader=function(a,s){var u=this;try{var c=u.$$AmplitudeAnalyticsEvent;c&&(c.headers[a]=s)}catch(l){qt(function(){var f;return(f=o.logger)===null||f===void 0?void 0:f.debug("an unexpected error occurred while calling xhr setRequestHeader",l)})}n.apply(u,[a,s])}}},t})();var Ui=new f0;var Mi=Ln(Ta());function Ys(){var t,e=je();return((t=e?.navigator)===null||t===void 0?void 0:t.product)==="ReactNative"}var Kv="@amplitude/plugin-network-capture-browser",Qs="[Amplitude] Network Request",Hv=!0;var Xv="500-599";function Fi(t,e){var r=e.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&"),n="^"+r.replace(/\*/g,".*")+"$",i=new RegExp(n);return i.test(t)}function jv(t,e){var r,n,i=e.split(",");try{for(var o=C(i),a=o.next();!a.done;a=o.next()){var s=a.value,u=w(s.split("-").map(Number),2),c=u[0],l=u[1];if(t===c&&l===void 0||t>=c&&t<=l)return!0}}catch(f){r={error:f}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function p0(t,e,r,n,i){if(!(t.hosts&&!t.hosts.find(function(a){return Fi(e,a)}))&&!(n&&t.urls&&!qs(n,t.urls))&&!(i&&t.methods&&!t.methods.find(function(a){return i.toLowerCase()===a.toLowerCase()||a==="*"}))){if(r||r===0){var o=t.statusCodeRange||Xv;if(!jv(r,o))return!1}return!0}}function h0(t){var e,r=t.indexOf("#"),n=r>=0?t.slice(r+1):"",i=r>=0?t.slice(0,r):t,o=i.indexOf("?"),a=o>=0?i.slice(o+1):"",s=o>=0?i.slice(0,o):i,u=s.match(/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i),c=(e=u?.[1])!==null&&e!==void 0?e:"";return{query:a,fragment:n,href:t,hrefWithoutQueryOrHash:s,host:c}}function zv(t){var e;if(t)try{var r=(e=je())===null||e===void 0?void 0:e.location.href,n=new URL(t,r),i=n.searchParams.toString(),o=n.hash.replace("#",""),a=n.href,s=n.host;n.hash="",n.search="";var u=n.href;return{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:u,host:s}}catch(c){try{return h0(t)}catch(l){return}}}function g0(t,e){if(t.includes("amplitude.com"))try{var r=e.body;if(typeof r!="string")return!1;var n=JSON.parse(r),i=n.events;if(i.find(function(o){return o.event_type===Qs}))return!0}catch(o){}return!1}function Wv(t){if(typeof t!="object"||t===null){if(t)return F([],w(Wt),!1);if(t===void 0){var e=Hv?void 0:F([],w(Wt),!1);return e}return}if(t.length!==0)return t}function qv(t){var e,r,n;return!(!((e=t?.allowlist)===null||e===void 0)&&e.length)&&!(!((r=t?.blocklist)===null||r===void 0)&&r.length)&&!(!((n=t?.excludelist)===null||n===void 0)&&n.length)}function m0(t,e){var r;e===void 0&&(e={});var n=zv(t.url);if(!n)return!1;var i=n.host;if(e.ignoreAmplitudeRequests!==!1&&(Fi(i,"*.amplitude.com")||Fi(i,"amplitude.com"))||!((r=e.ignoreHosts)===null||r===void 0)&&r.find(function(a){return Fi(i,a)})||!e.captureRules&&t.status!==void 0&&!jv(t.status,Xv))return!1;if(e.captureRules){var o;
11if(F([],w(e.captureRules),!1).reverse().find(function(a){if(o=p0(a,i,t.status,t.url,t.method),o){var s=Wv(a.responseHeaders);if(t.responseWrapper&&s){var u=t.responseWrapper.headers(s);u&&(t.responseHeaders=u)}var c=Wv(a.requestHeaders);if(t.requestWrapper&&c){var l=t.requestWrapper.headers(c);l&&(t.requestHeaders=l)}if(t.responseWrapper&&a.responseBody&&!qv(a.responseBody)){var f=a.responseBody.excludelist||a.responseBody.blocklist;t.responseBodyJson=t.responseWrapper.json(a.responseBody.allowlist,f)}if(t.requestWrapper&&a.requestBody&&!qv(a.requestBody)){var f=a.requestBody.excludelist||a.requestBody.blocklist;t.requestBodyJson=t.requestWrapper.json(a.requestBody.allowlist,f)}}return o!==void 0}),!o)return!1}return!(t.requestWrapper&&g0(i,t.requestWrapper))}function E0(t,e,r,n){return y(this,void 0,void 0,function(){var i,o,a;return b(this,function(s){switch(s.label){case 0:return e.requestBodyJson||e.responseBodyJson?[4,Promise.all([e.requestBodyJson,e.responseBodyJson])]:[3,2];case 1:if(i=w.apply(void 0,[s.sent(),2]),o=i[0],a=i[1],o)try{t["[Amplitude] Request Body"]=JSON.stringify(o)}catch(u){n?.debug("Failed to stringify request body",u)}if(a)try{t["[Amplitude] Response Body"]=JSON.stringify(a)}catch(u){n?.debug("Failed to stringify response body")}s.label=2;case 2:return r?.track(Qs,t),[2]}})})}function $v(t){var e=t.allObservables,r=t.networkTrackingOptions,n=t.amplitude,i=t.loggerProvider,o=e.networkObservable,a=o.filter(function(s){return m0(s.event,r)});return a.subscribe(function(s){var u,c,l,f=s.event,d=zv(f.url);if(d){var v=(c=f.responseWrapper)===null||c===void 0?void 0:c.bodySize,p=(l=f.requestWrapper)===null||l===void 0?void 0:l.bodySize,h=(u={},u["[Amplitude] URL"]=d.hrefWithoutQueryOrHash,u["[Amplitude] URL Query"]=d.query,u["[Amplitude] URL Fragment"]=d.fragment,u["[Amplitude] Request Method"]=f.method,u["[Amplitude] Status Code"]=f.status,u["[Amplitude] Start Time"]=f.startTime,u["[Amplitude] Completion Time"]=f.endTime,u["[Amplitude] Duration"]=f.duration,u["[Amplitude] Request Body Size"]=p,u["[Amplitude] Response Body Size"]=v,u["[Amplitude] Request Type"]=f.type,u["[Amplitude] Request Headers"]=f.requestHeaders,u["[Amplitude] Response Headers"]=f.responseHeaders,u);E0(h,f,n,i)}})}var Qv=(function(t){return t.NetworkObservable="networkObservable",t})(Qv||{}),Yv,Gi=function(t){t===void 0&&(t={});var e=Kv,r="enrichment",n,i=function(c,l){var f={event:c,timestamp:Date.now(),type:l};return f},o=function(){var c,l=new Mi.default(function(f){var d=new $s(function(v){var p=i(v,"network");f.next(p)});return Ui.subscribe(d,n),function(){Ui.unsubscribe(d)}});return c={},c[Qv.NetworkObservable]=l,c},a=function(c,l){return y(void 0,void 0,void 0,function(){var f;return b(this,function(d){return typeof document>"u"&&!Ys()?[2]:(f=o(),n=c?.loggerProvider,Yv=$v({allObservables:f,networkTrackingOptions:t,amplitude:l,loggerProvider:n}),n?.log("".concat(e," has been successfully added.")),[2])})})},s=function(c){return y(void 0,void 0,void 0,function(){return b(this,function(l){return[2,c]})})},u=function(){return y(void 0,void 0,void 0,function(){return b(this,function(c){return Yv.unsubscribe(),[2]})})};return{name:e,type:r,setup:a,execute:s,teardown:u}};var Js=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var rn=function(t,e){var r=t;try{r=decodeURI(t)}catch(n){e?.error("Malformed URI sequence: ",n)}return r};var Jv="web-vitals-browser",Zv="[Amplitude] Web Vitals";var up=-1,vr=t=>{addEventListener("pageshow",e=>{e.persisted&&(up=e.timeStamp,t(e))},!0)},vt=(t,e,r,n)=>{let i,o;return a=>{e.value>=0&&(a||n)&&(o=e.value-(i??0),(o||i===void 0)&&(i=e.value,e.delta=o,e.rating=((s,u)=>s>u[1]?"poor":s>u[0]?"needs-improvement":"good")(e.value,r),t(e)))}},su=t=>{requestAnimationFrame(()=>requestAnimationFrame(()=>t()))},uu=()=>{let t=performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},nn=()=>uu()?.activationStart??0,pt=(t,e=-1)=>{let r=uu(),n="navigate";return up>=0?n="back-forward-cache":r&&(document.prerendering||nn()>0?n="prerender":document.wasDiscarded?n="restore":r.type&&(n=r.type.replace(/_/g,"-"))),{name:t,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:n}},Zs=new WeakMap;function lu(t,e){return Zs.get(t)||Zs.set(t,new e),Zs.get(t)}var tu=class{t;i=0;o=[];h(e){if(e.hadRecentInput)return;let r=this.o[0],n=this.o.at(-1);this.i&&r&&n&&e.startTime-n.startTime<1e3&&e.startTime-r.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},on=(t,e,r={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(t)){let n=new PerformanceObserver(i=>{Promise.resolve().then(()=>{e(i.getEntries())})});return n.observe(rt({type:t,buffered:!0},r)),n}}catch(n){}},cu=t=>{let e=!1;return()=>{e||(t(),e=!0)}},fr=-1,lp=new Set,ep=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,ru=t=>{if(document.visibilityState==="hidden"){if(t.type==="visibilitychange")for(let e of lp)e();isFinite(fr)||(fr=t.type==="visibilitychange"?t.timeStamp:0,removeEventListener("prerenderingchange",ru,!0))}},Vi=()=>
11{if(fr<0){let t=nn();fr=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter(r=>r.name==="hidden"&&r.startTime>t)[0]?.startTime)??ep(),addEventListener("visibilitychange",ru,!0),addEventListener("prerenderingchange",ru,!0),vr(()=>{setTimeout(()=>{fr=ep()})})}return{get firstHiddenTime(){return fr},onHidden(t){lp.add(t)}}},Ki=t=>{document.prerendering?addEventListener("prerenderingchange",()=>t(),!0):t()},tp=[1800,3e3],du=(t,e={})=>{Ki(()=>{let r=Vi(),n,i=pt("FCP"),o=on("paint",a=>{for(let s of a)s.name==="first-contentful-paint"&&(o.disconnect(),s.startTime<r.firstHiddenTime&&(i.value=Math.max(s.startTime-nn(),0),i.entries.push(s),n(!0)))});o&&(n=vt(t,i,tp,e.reportAllChanges),vr(a=>{i=pt("FCP"),n=vt(t,i,tp,e.reportAllChanges),su(()=>{i.value=performance.now()-a.timeStamp,n(!0)})}))})},rp=[.1,.25],cp=(t,e={})=>{let r=Vi();du(cu(()=>{let n,i=pt("CLS",0),o=lu(e,tu),a=u=>{for(let c of u)o.h(c);o.i>i.value&&(i.value=o.i,i.entries=o.o,n())},s=on("layout-shift",a);s&&(n=vt(t,i,rp,e.reportAllChanges),r.onHidden(()=>{a(s.takeRecords()),n(!0)}),vr(()=>{o.i=0,i=pt("CLS",0),n=vt(t,i,rp,e.reportAllChanges),su(()=>n())}),setTimeout(n))}))},dp=0,eu=1/0,Bi=0,_0=t=>{for(let e of t)e.interactionId&&(eu=Math.min(eu,e.interactionId),Bi=Math.max(Bi,e.interactionId),dp=Bi?(Bi-eu)/7+1:0)},nu,np=()=>nu?dp:performance.interactionCount??0,b0=()=>{"interactionCount"in performance||nu||(nu=on("event",_0,{type:"event",buffered:!0,durationThreshold:0}))},ip=0,iu=class{u=[];l=new Map;m;p;v(){ip=np(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((np()-ip)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let r=this.u.at(-1),n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>r.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort((i,o)=>o.P-i.P),this.u.length>10){let i=this.u.splice(10);for(let o of i)this.l.delete(o.id)}this.p?.(n)}}},fp=t=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?t():(t=cu(t),addEventListener("visibilitychange",t,{once:!0,capture:!0}),e(()=>{t(),removeEventListener("visibilitychange",t,{capture:!0})}))},op=[200,500],vp=(t,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let r=Vi();Ki(()=>{b0();let n,i=pt("INP"),o=lu(e,iu),a=u=>{fp(()=>{for(let l of u)o.h(l);let c=o.L();c&&c.P!==i.value&&(i.value=c.P,i.entries=c.entries,n())})},s=on("event",a,{durationThreshold:e.durationThreshold??40});n=vt(t,i,op,e.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),r.onHidden(()=>{a(s.takeRecords()),n(!0)}),vr(()=>{o.v(),i=pt("INP"),n=vt(t,i,op,e.reportAllChanges)}))})},ou=class{m;h(e){this.m?.(e)}},ap=[2500,4e3],pp=(t,e={})=>{Ki(()=>{let r=Vi(),n,i=pt("LCP"),o=lu(e,ou),a=u=>{e.reportAllChanges||(u=u.slice(-1));for(let c of u)o.h(c),c.startTime<r.firstHiddenTime&&(i.value=Math.max(c.startTime-nn(),0),i.entries=[c],n())},s=on("largest-contentful-paint",a);if(s){n=vt(t,i,ap,e.reportAllChanges);let u=cu(()=>{a(s.takeRecords()),s.disconnect(),n(!0)}),c=l=>{l.isTrusted&&(fp(u),removeEventListener(l.type,c,{capture:!0}))};for(let l of["keydown","click","visibilitychange"])addEventListener(l,c,{capture:!0});vr(l=>{i=pt("LCP"),n=vt(t,i,ap,e.reportAllChanges),su(()=>{i.value=performance.now()-l.timeStamp,n(!0)})})}})},sp=[800,1800],au=t=>{document.prerendering?Ki(()=>au(t)):document.readyState!=="complete"?addEventListener("load",()=>au(t),!0):setTimeout(t)},hp=(t,e={})=>{let r=pt("TTFB"),n=vt(t,r,sp,e.reportAllChanges);au(()=>{let i=uu();i&&(r.value=Math.max(i.responseStart-nn(),0),r.entries=[i],n(!0),vr(()=>{r=pt("TTFB",0),n=vt(t,r,sp,e.reportAllChanges),n(!0)}))})};function S0(t){var e,r=((e=t.entries[0])===null||e===void 0?void 0:e.startTime)||0;return performance.timeOrigin+r}function an(t){return{value:t.value,rating:t.rating,delta:t.delta,navigationType:t.navigationType,id:t.id,timestamp:Math.floor(S0(t)),navigationStart:Math.floor(performance.timeOrigin)}}var Hi=function(){var t=null,e=Js(),r=e?.document,n=e?.location,i=function(s,u){return y(void 0,void 0,void 0,function(){var c,l;return b(this,function(f){return r===void 0?[2]:(c=rn(n?.href||"",s.loggerProvider),l={"[Amplitude] Page Domain":n?.hostname||"","[Amplitude] Page Location":c,"[Amplitude] Page Path":rn(n?.pathname||"",s.loggerProvider),"[Amplitude] Page Title":typeof document<"u"&&document.title||"","[Amplitude] Page URL":rn(c.split("?")[0],s.loggerProvider)},pp(function(d){l["[Amplitude] LCP"]=an(d)}),du(function(d){l["[Amplitude] FCP"]=an(d)}),vp(function(d){l["[Amplitude] INP"]=an(d)}),cp(function(d){l["[Amplitude] CLS"]=an(d)}),hp(function(d){l["[Amplitude] TTFB"]=an(d)}),t=function(){r.visibilityState==="hidden"&&t&&(u.track(Zv,l),r.removeEventListener("visibilitychange",t),t=null)},r.addEventListener("visibilitychange",t),[2])})})},o=function(s){return y(void 0,void 0,void 0,function(){return b(this,function(u){return[2,s]})})},a=function(){return y(void 0,void 0,void 0,function(){return b(this,function(s){return t&&r?.removeEventListener("visibilitychange",t),[2]})})};return{name:Jv,type:"enrichment",setup:i,execute:o,teardown:a}};var fu=(function(){function t(e,r){var n;this.shouldTrackNewCampaign=!1,this.options=T({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:ad(((n=r.cookieOptions)===null||n===void 0?void 0:n.domain)||r.topLevelDomain),optOut:r.optOut},e),this.storage=r.cookieStorage,this.storageKey=Wn(r.apiKey,"MKTG"),this.webExpStorageKey=Wn(r.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=Ut,this.sessionTimeout=r.sessionTimeout,this.lastEventTime=r.lastEventTime,this.logger=r.loggerProvider,this.topLevelDomain=r.topLevelDomain,r.loggerProvider.log("Installing web attribution tracking.")}return t.prototype.init=function(){return y(this,void 0,void 0,function(){var e,r;return b(this,function(n){switch(n.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return r=w.apply(void 0,[n.sent(),2]),this.currentCampaign=r[0],this.previousCampaign=r[1],e=this.lastEventTime?Or(this.sessionTimeout,this.lastEventTime):!0,id(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.fetchCampaign=function(){return y(this,void 0,void 0,function(){var e;return b(this,function(r){switch(r.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return e=r.sent(),e?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[4,Promise.all([e||new ma().parse(),this.storage.get(this.storageKey)])];case 4:return[2,r.sent()]}})})},t.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var r=od(this.currentCampaign,this.options);return e&&(r.event_id=e),r},t.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},t})();var sn=(function(t){return t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount",t})(sn||{});var y0="AMP",yL="".concat(y0,"_unsent");
11var gp="utm_campaign",mp="utm_content",Ep="utm_id",_p="utm_medium",bp="utm_source",Sp="utm_term",vu="dclid",pu="fbclid",hu="gbraid",gu="gclid",mu="ko_click_id",Eu="li_fat_id",_u="msclkid",bu="rdt_cid",Su="ttclid",yu="twclid",Tu="wbraid";var yp={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};var un=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var Iu=function(){var t,e=un();if(!(!((t=e?.location)===null||t===void 0)&&t.search))return{};var r=e.location.search.substring(1).split("&").filter(Boolean),n=r.reduce(function(i,o){var a=o.split("=",2),s=Tp(a[0]),u=Tp(a[1]);return u&&(i[s]=u),i},{});return n},Tp=function(t){t===void 0&&(t="");try{return decodeURIComponent(t)}catch(e){return""}};var xu=function(t){var e={};for(var r in t){var n=t[r];n&&(e[r]=n)}return e};var Au=(function(){function t(){}return t.prototype.parse=function(){return y(this,void 0,void 0,function(){return b(this,function(e){return[2,T(T(T(T({},yp),this.getUtmParam()),this.getReferrer()),this.getClickIds())]})})},t.prototype.getUtmParam=function(){var e=Iu(),r=e[gp],n=e[mp],i=e[Ep],o=e[_p],a=e[bp],s=e[Sp];return{utm_campaign:r,utm_content:n,utm_id:i,utm_medium:o,utm_source:a,utm_term:s}},t.prototype.getReferrer=function(){var e,r,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=(r=(e=n.referrer)===null||e===void 0?void 0:e.split("/")[2])!==null&&r!==void 0?r:void 0}catch(i){}return n},t.prototype.getClickIds=function(){var e,r=Iu();return e={},e[vu]=r[vu],e[pu]=r[pu],e[hu]=r[hu],e[gu]=r[gu],e[mu]=r[mu],e[Eu]=r[Eu],e[_u]=r[_u],e[bu]=r[bu],e[Su]=r[Su],e[yu]=r[yu],e[Tu]=r[Tu],e},t})();var T0="[Amplitude] Attribution",I0=new Set([sn.IDENTIFY,sn.GROUP_IDENTIFY]),x0=function(t){return xu(t)},Cu=function(t){var e;t===void 0&&(t={});var r=(e=t.fallbackAttributionEvent)!==null&&e!==void 0?e:!1,n=un(),i,o,a={},s=!1,u=!1,c,l,f,d,v=function(){return y(void 0,void 0,void 0,function(){var g;return b(this,function(m){switch(m.label){case 0:return[4,new Au().parse()];case 1:return g=m.sent(),a=x0(g),r&&(o?.log("Tracking attribution fallback event."),i?.track(T0,a)),[2]}})})},p=function(){v()},h=function(g){return new Proxy(g,{apply:function(m,E,_){Reflect.apply(m,E,_),s&&p()}})};return{name:"@amplitude/plugin-event-property-attribution-browser",type:"enrichment",setup:function(g,m){return y(void 0,void 0,void 0,function(){return b(this,function(E){switch(E.label){case 0:return i=m,o=g.loggerProvider,s=!0,o.log("Installing event property attribution tracking."),[4,v()];case 1:if(E.sent(),!n)return[2];if(n.addEventListener("popstate",p),!u){if(c=Reflect.get(n.history,"pushState"),l=Reflect.get(n.history,"replaceState"),!c||!l)return[2];f=h(c),n.history.pushState=f,d=h(l),n.history.replaceState=d,u=!0}return[2]}})})},execute:function(g){return y(void 0,void 0,void 0,function(){return b(this,function(m){return I0.has(g.event_type)?[2,g]:(g.event_properties=T(T({},a),g.event_properties),[2,g])})})},teardown:function(){return y(void 0,void 0,void 0,function(){var g,m;return b(this,function(E){return n&&(n.removeEventListener("popstate",p),g=Reflect.get(n.history,"pushState"),m=Reflect.get(n.history,"replaceState"),u&&g===f&&c&&(n.history.pushState=c),u&&m===d&&l&&(n.history.replaceState=l)),s=!1,u=!1,c=void 0,l=void 0,f=void 0,d=void 0,a={},[2]})})}}};var pr=(function(t){return t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount",t})(pr||{});var Ru=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var Xt=function(t,e){var r=t;try{r=decodeURI(t)}catch(n){e?.error("Malformed URI sequence: ",n)}return r};var wu=(function(){function t(e){this.storage=e}return t.prototype.isEnabled=function(){return y(this,void 0,void 0,function(){var e,r,n,i,o;return b(this,function(a){switch(a.label){case 0:if(!this.storage)return[2,!1];e=String(Date.now()),r=new t(this.storage),n="AMP_TEST",a.label=1;case 1:return a.trys.push([1,4,5,7]),[4,r.set(n,e)];case 2:return a.sent(),[4,r.get(n)];case 3:return i=a.sent(),[2,i===e];case 4:return o=a.sent(),[2,!1];case 5:return[4,r.remove(n)];case 6:return a.sent(),[7];case 7:return[2]}})})},t.prototype.get=function(e){return y(this,void 0,void 0,function(){var r,n;return b(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return r=i.sent(),r?[2,JSON.parse(r)]:[2,void 0];case 2:return n=i.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}})})},t.prototype.getRaw=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){return[2,((r=this.storage)===null||r===void 0?void 0:r.getItem(e))||void 0]})})},t.prototype.set=function(e,r){var n;return y(this,void 0,void 0,function(){return b(this,function(i){try{(n=this.storage)===null||n===void 0||n.setItem(e,JSON.stringify(r))}catch(o){}return[2]})})},t.prototype.remove=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){try{(r=this.storage)===null||r===void 0||r.removeItem(e)}catch(i){}return[2]})})},t.prototype.reset=function(){var e;return y(this,void 0,void 0,function(){return b(this,function(r){try{(e=this.storage)===null||e===void 0||e.clear()}catch(n){}return[2]})})},t})();var Ip="data-amp-mask",hr="*****",xp=/\b(?:\d[ -]*?){13,16}\b/,Ap=/(\d{3}-?\d{2}-?\d{4})/g,Cp=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Lu=function(t,e){var r,n;if(e===void 0&&(e=[]),typeof t!="string")return"";var i=t;i=i.replace(xp,hr),i=i.replace(Ap,hr),i=i.replace(Cp,hr);try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,hr)}catch(u){}}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},Pu=function(t){if(typeof document>"u"||!document.title)return"";var e=document.querySelector("title");return e&&e.hasAttribute(Ip)?hr:t?t(document.title):document.title};var cn="AMP_CURRENT_PAGE",dn="AMP_PREVIOUS_PAGE",jt="AMP_URL_INFO",Wi=(function(t){return t.Direct="direct",t.Internal="internal",t.External="external",t})(Wi||{}),A0=new Set([pr.IDENTIFY,pr.GROUP_IDENTIFY,pr.REVENUE]);var Du=function(t){var e=t===void 0?{}:t,r=e.internalDomains,n=r===void 0?[]:r,i=Ru(),o=void 0,a=!1,s=void 0,u=!1,c=!1,l=function(h){var g;try{var m=Xt(h,s);g=new URL(m).hostname}catch(E){s?.error("Could not parse URL: ",E)}return g},f=function(h){var g=typeof location<"u"&&location.hostname||"",m=h?l(h):void 0;if(!m)return Wi.Direct;var E=n.some(function(S){return g.indexOf(S)!==-1}),_=n.some(function(S){return m.indexOf(S)!==-1});
11return g===m||_&&E?Wi.Internal:Wi.External},d=function(){return y(void 0,void 0,void 0,function(){var h,g,m,E,_;return b(this,function(S){switch(S.label){case 0:return o&&a?[4,o.get(jt)]:[3,3];case 1:return h=S.sent(),g=Xt(typeof location<"u"&&location.href||""),m=h?.[cn]||"",E=void 0,g===m?E=h?.[dn]||"":m?E=m:E=document.referrer||"",[4,o.set(jt,(_={},_[cn]=g,_[dn]=E,_))];case 2:S.sent(),S.label=3;case 3:return[2]}})})},v=function(){d()},p={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(h,g){return y(void 0,void 0,void 0,function(){var m,E,_,S,x,I,A,D,k;return b(this,function(U){switch(U.label){case 0:if(s=h.loggerProvider,s.log("Installing @amplitude/plugin-page-url-enrichment-browser"),c=!0,!i)return[3,7];try{o=new wu(i.sessionStorage)}catch(R){s?.debug("sessionStorage is not available in this environment.")}return[4,o?.isEnabled()];case 1:return a=(k=U.sent())!==null&&k!==void 0?k:!1,o&&a?(m=typeof document<"u"&&document.referrer||"",E=m?l(m):void 0,_=typeof location<"u"&&location.hostname||"",S=Xt(typeof location<"u"&&location.href||""),[4,o.get(jt)]):[3,6];case 2:return x=U.sent(),I=x?.[cn]||"",A=!!E&&E!==_&&I!==S,A?[4,o.set(jt,(D={},D[cn]=S,D[dn]=m,D))]:[3,4];case 3:return U.sent(),[3,6];case 4:return[4,d()];case 5:U.sent(),U.label=6;case 6:i.addEventListener("popstate",v),u||(i.history.pushState=new Proxy(i.history.pushState,{apply:function(R,O,P){var N=w(P,3),G=N[0],M=N[1],V=N[2];R.apply(O,[G,M,V]),c&&v()}}),i.history.replaceState=new Proxy(i.history.replaceState,{apply:function(R,O,P){var N=w(P,3),G=N[0],M=N[1],V=N[2];R.apply(O,[G,M,V]),c&&v()}}),u=!0),U.label=7;case 7:return[2]}})})},execute:function(h){return y(void 0,void 0,void 0,function(){var g,m,E;return b(this,function(_){switch(_.label){case 0:return g=Xt(typeof location<"u"&&location.href||""),o&&a?[4,o.get(jt)]:[3,2];case 1:if(m=_.sent(),E=m?.[dn]||"",A0.has(h.event_type))return[2,h];h.event_properties=T(T({},h.event_properties||{}),{"[Amplitude] Page Domain":ln(h,"[Amplitude] Page Domain",typeof location<"u"&&location.hostname||""),"[Amplitude] Page Location":ln(h,"[Amplitude] Page Location",g),"[Amplitude] Page Path":ln(h,"[Amplitude] Page Path",typeof location<"u"&&Xt(location.pathname)||""),"[Amplitude] Page Title":ln(h,"[Amplitude] Page Title",Pu(Lu)),"[Amplitude] Page URL":ln(h,"[Amplitude] Page URL",g.split("?")[0]),"[Amplitude] Previous Page Location":E,"[Amplitude] Previous Page Type":f(E)}),_.label=2;case 2:return[2,h]}})})},teardown:function(){return y(void 0,void 0,void 0,function(){return b(this,function(h){switch(h.label){case 0:return i&&(i.removeEventListener("popstate",v),c=!1),o&&a?[4,o.set(jt,{})]:[3,2];case 1:h.sent(),h.label=2;case 2:return[2]}})})}};return p};function ln(t,e,r){return t.event_properties||(t.event_properties={}),t.event_properties[e]===void 0?r:t.event_properties[e]}var Ou=function(){var t,e,r;function n(a){return typeof a!="object"||a===null?!1:"body"in a&&typeof a.body=="string"}function i(a){if(a)try{var s=new Function("return "+a)();if(typeof s=="function")return s;t?.error("Custom enrichment body did not evaluate to a function")}catch(u){t?.error("Could not create custom enrichment function",u)}return function(u){return u}}var o={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(a,s){return y(void 0,void 0,void 0,function(){var u,c;return b(this,function(l){return t=a.loggerProvider,t?.log("Installing @amplitude/plugin-custom-enrichment-browser"),!((c=a.remoteConfig)===null||c===void 0)&&c.fetchRemoteConfig&&(a.remoteConfigClient?(u=a.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",function(f){f&&n(f)?r=i(f.body||""):r=i("")}),e=function(){var f;return(f=a.remoteConfigClient)===null||f===void 0?void 0:f.unsubscribe(u)}):t?.debug("Remote config client is not provided, skipping remote config fetch")),[2]})})},execute:function(a){return y(void 0,void 0,void 0,function(){var s;return b(this,function(u){if(r)try{return[2,(s=r(a))!==null&&s!==void 0?s:null]}catch(c){return t?.error("Could not execute custom enrichment function",c),[2,a]}return[2,a]})})},teardown:function(){return y(void 0,void 0,void 0,function(){return b(this,function(a){return e&&e(),[2]})})}};return o};var ku="userProperty",Nu="eventProperty",C0=function(t){return t===ku||t===Nu},R0=[ku,Nu],w0=function(t){var e=F([],w(new Set((Array.isArray(t)?t:[t]).filter(C0))),!1);return e.length>0?e:F([],w(R0),!1)},Rp=function(t,e){return w0(t.trackingMethod).includes(e)},Uu=function(t){return Rp(t,ku)},wp=function(t){return Rp(t,Nu)};var Mu=-1,fn=(function(t){Ae(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r._diagnosticsSampleRate=0,r}return e.prototype.init=function(r,n,i){r===void 0&&(r="");var o,a;return arguments.length>2?(o=n,a=i):typeof n=="string"?(o=n,a=void 0):(o=n?.userId,a=n),Pe(this._init(T(T({},a),{userId:o,apiKey:r})))},e.prototype._init=function(r){var n,i,o,a,s,u,c,l;return y(this,void 0,void 0,function(){var f,d,v,p,h,g,m,E,_,S,x,I,A,D,k,U=this;return b(this,function(R){switch(R.label){case 0:return this.initializing?[2]:(this.initializing=!0,f=ud(r),d=(n=r.loggerProvider)!==null&&n!==void 0?n:new Ft,r.loggerProvider||d.enable((i=r.logLevel)!==null&&i!==void 0?i:we.Warn),v=(o=r.serverZone)!==null&&o!==void 0?o:ai,h=this._diagnosticsSampleRate,g=(a=r.enableDiagnostics)!==null&&a!==void 0?a:!0,f?(p=new fa(r.apiKey,d,v,(s=r.remoteConfig)===null||s===void 0?void 0:s.serverUrl),[4,new Promise(function(O){p?.subscribe("configs.diagnostics.browserSDK","all",function(P,N,G){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:P,source:N,lastFetch:G},null,2)),P){var M=P.sampleRate;typeof M=="number"&&!isNaN(M)&&(h=M);var V=P.enabled;typeof V=="boolean"&&(g=V)}O()})})]):[3,2]);case 1:R.sent(),R.label=2;case 2:return m=new ca(r.apiKey,d,v,{enabled:g,sampleRate:h}),m.setTag("library","".concat(ti,"/").concat(nr)),m.setTag("platform",Oa),m.setTag("web_environment",Kc()),typeof navigator<"u"&&m.setTag("user_agent",navigator.userAgent),[4,sd(r.apiKey,r,this,m,{loggerProvider:d,serverZone:v,enableDiagnostics:g,diagnosticsSampleRate:h})];case 3:return E=R.sent(),f&&p?[4,new Promise(function(O){p?.subscribe("configs.analyticsSDK.browserSDK","all",function(P,N,G){E.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:P,source:N,lastFetch:G},null,2)),P&&Cd(P,E),O()})})]:[3,5];case 4:R.sent(),R.label=5;case 5:return[4,t.prototype._init.call(this,E)];case 6:return R.sent(),this.logBrowserOptions(E),this.config.remoteConfigClient=p,_=Bc(this.config),Jn(this.config.defaultTracking)&&Uu(_)?(this.config.optOut&&this.timeline.addOptOutListener(function(O){return y(U,void 0,void 0,function(){return b(this,function(P){switch(P.label){case 0:return O?[3,2]:(this.webAttribution=new fu(_,this.config),[4,this.webAttribution.init()]);case 1:P.sent(),P.label=2;case 2:return[2]}})})}),this.webAttribution=new fu(_,this.config),[4,this.webAttribution.init()]):[3,8];case 7:R.sent(),R.label=8;case 8:return S=Rt(),x=S.ampTimestamp?Number(S.ampTimestamp):void 0,I=x?Date.now()<x:!0,A=I&&!Number.isNaN(Number(S.ampSessionId))?Number(S.ampSessionId):void 0,D=this.config.deferredSessionId,D===Mu&&!this.config.optOut&&(D=Date.now()),this.setSessionId((l=(c=(u=r.sessionId)!==null&&u!==void 0?u:A)!==null&&c!==void 0?c:D)!==null&&l!==void 0?l:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener(function(O){return y(U,void 0,void 0,function(){return b(this,function(P){return!O&&this.config.deferredSessionId&&(this.config.deferredSessionId===Mu?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]})})}),k=Ct(this.config.instanceName),k.identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),this.config.offline===Gr?[3,10]:[4,this.add(Ad()).promise];case 9:R.sent(),R.label=10;case 10:return[4,this.add(new ta({diagnosticsClient:m})).promise];case 11:return R.sent(),[4,this.add(new Hc).promise];case 12:return R.sent(),[4,this.add(new ia).promise];case 13:return R.sent(),xd(this.config),Pc(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(Td()).promise]):[3,15];case 14:R.sent(),R.label=15;case 15:return Aa(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(yd()).promise]):[3,17];case 16:R.sent(),R.label=17;case 17:return Ca(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(si(Da(this.config))).promise]):[3,20];case 18:return R.sent(),[3,20];case 19:this.timeline.addOptOutListener(function(O){return y(U,void 0,void 0,function(){return b(this,function(P){switch(P.label){case 0:return O?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(si(Da(this.config))).promise]);case 1:return P.sent(),[2]}})})}),R.label=20;case 20:return Jn(this.config.defaultTracking)&&wp(_)?(this.config.loggerProvider.debug("Adding event property attribution plugin"),[4,this.add(Cu(_)).promise]):[3,22];case 21:R.sent(),R.label=22;case 22:return La(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Pi(Mc(this.config),{diagnosticsClient:m})).promise]):[3,24];case 23:R.sent(),R.label=24;case 24:return Pa(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add(Vs(Fc(this.config))).promise]):[3,26];
11case 25:R.sent(),R.label=26;case 26:return wa(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(Gi(Gc(this.config))).promise]):[3,28];case 27:R.sent(),R.label=28;case 28:return Oc(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(Hi()).promise]):[3,30];case 29:R.sent(),R.label=30;case 30:return kc(this.config.autocapture)?(this.config.loggerProvider.debug("Adding performance tracking plugin"),[4,this.add(Ks(Nc(this.config))).promise]):[3,32];case 31:R.sent(),R.label=32;case 32:return Dc(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(Du()).promise]):[3,34];case 33:R.sent(),R.label=34;case 34:return Uc(this.config.customEnrichment)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(Ou()).promise]):[3,36];case 35:R.sent(),R.label=36;case 36:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 37:return R.sent(),k.eventBridge.setEventReceiver(function(O){var P=O.eventProperties||{},N=P.time,G=nt(P,["time"]),M=typeof N=="number"?{time:N}:void 0;U.track(O.eventType,G,M)}),[2]}})})},e.prototype.getUserId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.userId},e.prototype.setUserId=function(r){if(!this.config){this.q.push(this.setUserId.bind(this,r));return}this.config.loggerProvider.debug("function setUserId: ",r),(r!==this.config.userId||r===void 0)&&(this.config.userId=r,this.timeline.onIdentityChanged({userId:r}),ra(r,this.config.instanceName))},e.prototype.getDeviceId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.deviceId},e.prototype.setDeviceId=function(r){if(!this.config){this.q.push(this.setDeviceId.bind(this,r));return}this.config.loggerProvider.debug("function setDeviceId: ",r),r!==this.config.deviceId&&(this.config.deviceId=r,this.timeline.onIdentityChanged({deviceId:r}),na(r,this.config.instanceName))},e.prototype.reset=function(){this.setDeviceId(We()),this.setUserId(void 0),this.timeline.onReset()},e.prototype.getIdentity=function(){var r,n;return{deviceId:(r=this.config)===null||r===void 0?void 0:r.deviceId,userId:(n=this.config)===null||n===void 0?void 0:n.userId,userProperties:this.userProperties}},e.prototype.setIdentity=function(r){var n,i,o;if("userId"in r&&this.setUserId(r.userId),"deviceId"in r&&r.deviceId&&this.setDeviceId(r.deviceId),"userProperties"in r){this.userProperties=r.userProperties;var a=new ot,s=(o=r.userProperties)!==null&&o!==void 0?o:{};try{for(var u=C(Object.entries(s)),c=u.next();!c.done;c=u.next()){var l=w(c.value,2),f=l[0],d=l[1];a.set(f,d)}}catch(v){n={error:v}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}this.identify(a)}},e.prototype.getOptOut=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.optOut},e.prototype.getSessionId=function(){var r;return(r=this.config)===null||r===void 0?void 0:r.sessionId},e.prototype.setSessionId=function(r){var n,i=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,r)),Pe(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=r??Mu,Pe(Promise.resolve());if(r===void 0&&(r=Date.now()),r===this.config.sessionId)return Pe(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",r);var o=this.getSessionId();o!==r&&this.timeline.onSessionIdChanged(r);var a=this.config.lastEventTime,s=(n=this.config.lastEventId)!==null&&n!==void 0?n:-1;this.config.sessionId=r,this.config.lastEventTime=void 0,this.config.pageCounter=0,Ra(this.config.defaultTracking)&&(o&&a&&i.push(this.track(Fa,void 0,{device_id:this.previousSessionDeviceId,event_id:++s,session_id:o,time:a+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var u=this.trackCampaignEventIfNeeded(++s,i);return this.config.identify&&i.push(this.track(Mt(this.config.identify)).promise),Ra(this.config.defaultTracking)&&i.push(this.track(Ma,void 0,{event_id:u?++s:s,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,Pe(Promise.all(i))},e.prototype.extendSession=function(){if(!this.config){this.q.push(this.extendSession.bind(this));return}
11this.config.lastEventTime=Date.now()},e.prototype.setTransport=function(r){if(!this.config){this.q.push(this.setTransport.bind(this,r));return}this.config.transportProvider=Ka(r)},e.prototype.identify=function(r,n){if(ei(r)){var i=r._q;r._q=[],r=Zn(new ot,i)}return n?.user_id&&this.setUserId(n.user_id),n?.device_id&&this.setDeviceId(n.device_id),t.prototype.identify.call(this,r,n)},e.prototype.groupIdentify=function(r,n,i,o){if(ei(i)){var a=i._q;i._q=[],i=Zn(new ot,a)}return t.prototype.groupIdentify.call(this,r,n,i,o)},e.prototype.revenue=function(r,n){if(ei(r)){var i=r._q;r._q=[],r=Zn(new wr,i)}return t.prototype.revenue.call(this,r,n)},e.prototype.trackCampaignEventIfNeeded=function(r,n){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign||!Uu(this.webAttribution.options))return!1;var i=this.webAttribution.generateCampaignEvent(r);return n?n.push(this.track(i).promise):this.track(i),this.config.loggerProvider.log("Tracking attribution."),!0},e.prototype.process=function(r){return y(this,void 0,void 0,function(){var n,i,o;return b(this,function(a){return n=Date.now(),i=Or(this.config.sessionTimeout,this.config.lastEventTime),o=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),r.event_type!==Ma&&r.event_type!==Fa&&(!r.session_id||r.session_id===this.getSessionId())&&(i||o?(this.setSessionId(n),o&&this.config.loggerProvider.log("Created a new session for new campaign.")):i||this.trackCampaignEventIfNeeded()),[2,t.prototype.process.call(this,r)]})})},e.prototype.logBrowserOptions=function(r){try{var n=T(T({},r),{apiKey:r.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",$e(n))}catch(i){this.config.loggerProvider.error("Error logging browser config",i)}},e.prototype._setDiagnosticsSampleRate=function(r){if(!(r>1||r<0)&&!this.config){this._diagnosticsSampleRate=r;return}},e})(Qo);var L0=function(){var t=new fn;return{init:ye(t.init.bind(t),"init",be(t),Se(t,["config"])),add:ye(t.add.bind(t),"add",be(t),Se(t,["config.apiKey","timeline.plugins"])),remove:ye(t.remove.bind(t),"remove",be(t),Se(t,["config.apiKey","timeline.plugins"])),track:ye(t.track.bind(t),"track",be(t),Se(t,["config.apiKey","timeline.queue.length"])),logEvent:ye(t.logEvent.bind(t),"logEvent",be(t),Se(t,["config.apiKey","timeline.queue.length"])),identify:ye(t.identify.bind(t),"identify",be(t),Se(t,["config.apiKey","timeline.queue.length"])),groupIdentify:ye(t.groupIdentify.bind(t),"groupIdentify",be(t),Se(t,["config.apiKey","timeline.queue.length"])),setGroup:ye(t.setGroup.bind(t),"setGroup",be(t),Se(t,["config.apiKey","timeline.queue.length"])),revenue:ye(t.revenue.bind(t),"revenue",be(t),Se(t,["config.apiKey","timeline.queue.length"])),flush:ye(t.flush.bind(t),"flush",be(t),Se(t,["config.apiKey","timeline.queue.length"])),getUserId:ye(t.getUserId.bind(t),"getUserId",be(t),Se(t,["config","config.userId"])),setUserId:ye(t.setUserId.bind(t),"setUserId",be(t),Se(t,["config","config.userId"])),getDeviceId:ye(t.getDeviceId.bind(t),"getDeviceId",be(t),Se(t,["config","config.deviceId"])),setDeviceId:ye(t.setDeviceId.bind(t),"setDeviceId",be(t),Se(t,["config","config.deviceId"])),reset:ye(t.reset.bind(t),"reset",be(t),Se(t,["config","config.userId","config.deviceId"])),getSessionId:ye(t.getSessionId.bind(t),"getSessionId",be(t),Se(t,["config"])),setSessionId:ye(t.setSessionId.bind(t),"setSessionId",be(t),Se(t,["config"])),extendSession:ye(t.extendSession.bind(t),"extendSession",be(t),Se(t,["config"])),setOptOut:ye(t.setOptOut.bind(t),"setOptOut",be(t),Se(t,["config"])),setTransport:ye(t.setTransport.bind(t),"setTransport",be(t),Se(t,["config"])),getIdentity:ye(t.getIdentity.bind(t),"getIdentity",be(t),Se(t,["config"])),setIdentity:ye(t.setIdentity.bind(t),"setIdentity",be(t),Se(t,["config","config.userId","config.deviceId"])),getOptOut:ye(t.getOptOut.bind(t),"getOptOut",be(t),Se(t,["config"])),_setDiagnosticsSampleRate:ye(t._setDiagnosticsSampleRate.bind(t),"_setDiagnosticsSampleRate",be(t),Se(t,["config"]))}},Ie=L0();var WP=Ie.add,qP=Ie.extendSession,XP=Ie.flush,jP=Ie.getDeviceId,zP=Ie.getIdentity,$P=Ie.getOptOut,YP=Ie.getSessionId,QP=Ie.getUserId,JP=Ie.groupIdentify,ZP=Ie.identify,eD=Ie.init,tD=Ie.logEvent,rD=Ie.remove,nD=Ie.reset,iD=Ie.revenue,oD=Ie.setDeviceId,aD=Ie.setGroup,sD=Ie.setIdentity,uD=Ie.setOptOut,lD=Ie.setSessionId,cD=Ie.setTransport,dD=Ie.setUserId,fD=Ie.track,vD=Ie._setDiagnosticsSampleRate;var vn=(function(t){return t.IDENTIFY="$identify",t.GROUP_IDENTIFY="$groupidentify",t.REVENUE="revenue_amount",t})(vn||{});var P0="AMP",ED="".concat(P0,"_unsent"),Lp="$default_instance";var Fu=function(){var t="ampIntegrationContext";if(typeof globalThis<"u"&&typeof globalThis[t]<"u")return globalThis[t];if(typeof globalThis<"u")return globalThis;if(typeof window<"u")return window;if(typeof self<"u")return self;if(typeof global<"u")return global};var Pp=function(t){return t===void 0||t===""?Lp:t};var Gu=function(t){return Yt.getInstance(Pp(t))};var Dp="[Amplitude]",Op="".concat(Dp," Session Replay ID");var kp=0,Np=Wl.US,Up={enabled:!0},pn=1e3,Mp="".concat(Dp," Session Replay Debug"),Fp="amp-block",qi="amp-mask",Xi="amp-unmask",ji="https://api-sr.amplitude.com/sessions/v2/track",zi="https://api-sr.eu.amplitude.com/sessions/v2/track",$i="https://api-sr.stag2.amplitude.com/sessions/v2/track",kD="".concat(Ml,"_replay_unsent"),D0=2e6,Gp=6e6,Yi=9*1e6,Bp=/payload.*exceed/i,Vp=3e4,Kp=6e4,hn=500,gn=10*1e3,Hp=1e3,Wp=10*1e3,ND=1e3*60*60*24*3,mn=1024,qp=1e3;var Xp=64*1024,jp=1e4,Bu="X-Session-Replay-Event-Skipped",zp="429",$p="4004",Yp="4005",Vu=6e4,Qp=2*D0,En="amplitude-sr-iframe",St=(function(t){return t.GET_SR_PROPS="get-sr-props",t.DEBUG_INFO="debug-info",t.FETCH_REQUEST="fetch-request",t.METADATA="metadata",t.TARGETING_DECISION="targeting-decision",t.REPLAY_GATE_DECISION="replay-gate-decision",t})(St||{});var _n=(function(){function t(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 t.prototype.getSafeMethod=function(e){var r;if(!this.logger)return function(){};var n=this.logger[e];
11if(typeof n=="function"){var i=(r=n.__rrweb_original__)!==null&&r!==void 0?r:n;return i.bind(this.logger)}return function(){}},t.prototype.enable=function(e){this.logger.enable(e)},t.prototype.disable=function(){this.logger.disable()},t})();var Qi="medium";function O0(t){return t.toLowerCase()}function Jp(t){var e=t.type;return t.hasAttribute("data-rr-is-password")?"password":e?O0(e):null}function yt(t,e){return e||(t==="STAGING"?$i:t==="EU"?zi:ji)}var eh=function(t,e,r){switch(e){case"light":{if(t!=="input")return!1;var n=r?Jp(r):"";return n?!!(["password","hidden","email","tel"].includes(n)||r.autocomplete.startsWith("cc-")):!1}case"medium":return t==="input";case"conservative":return!0;default:return eh(t,Qi,r)}},Ku=function(t,e){var r,n,i;if(t&&e.urlMaskLevels)try{for(var o=C(e.urlMaskLevels),a=o.next();!a.done;a=o.next()){var s=a.value;if(ih(s.match).test(t))return s.maskLevel}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return(i=e.defaultMaskLevel)!==null&&i!==void 0?i:Qi},th=function(t,e,r,n){var i,o;if(e===void 0&&(e={defaultMaskLevel:Qi}),r){if(r.closest("."+qi))return!0;var a=((i=e.maskSelector)!==null&&i!==void 0?i:[]).some(function(u){return r.closest(u)});if(a)return!0;if(r.closest("."+Xi))return!1;var s=((o=e.unmaskSelector)!==null&&o!==void 0?o:[]).some(function(u){return r.closest(u)});if(s)return!1}return eh(t,Ku(n,e),r)},Hu=function(t,e,r){return function(n,i){return th(t,e,i,r?.())?n.replace(/[^\s]/g,"*"):n}},rh=function(t,e){return function(r,n,i){var o;if(r==="style"||!((o=t?.maskAttributes)!==null&&o!==void 0?o:[]).includes(r))return n;var a=["INPUT","SELECT","TEXTAREA"].includes(i.tagName)?"input":"text";return th(a,t,i,e?.())?n.replace(/[^\s]/g,"*"):n}},bn=function(){var t=le();return t?.location?t.location.href:""},nh=function(t,e){return"".concat(e,"/").concat(t)},k0=function(t){if(typeof t!="string"||t.trim()==="")return!1;var e=/^\/|^https?:\/\/[^\s]+$/;return!!e.test(t)},Zp=new Map,ih=function(t){var e=Zp.get(t);if(e)return e;var r="\0TRAIL\0",n="\0MID\0",i="\0DS\0",o="\0ST\0",a="\0QU\0",s=t;s=s.replace(/\/\*\*$/,r),s=s.replace(/\/\*\*\//g,n),s=s.replace(/\*\*/g,i),s=s.replace(/\*/g,o),s=s.replace(/\?/g,a),s=s.replace(/[.+^${}()|[\]\\]/g,"\\$&"),s=s.split(r).join("(/.*)?"),s=s.split(n).join("/(.*\\/)?"),s=s.split(i).join(".*"),s=s.split(o).join(".*"),s=s.split(a).join(".");var u=new RegExp("^".concat(s,"$"));return Zp.set(t,u),u},oh=function(t){if(!t.every(function(e){return typeof e.selector=="string"&&typeof e.replacement=="string"}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!t.every(function(e){return k0(e.selector)}))throw new Error("ugcFilterRules must be an array of objects with valid globs")},Ot=function(t,e){var r,n;try{for(var i=C(e),o=i.next();!o.done;o=i.next()){var a=o.value,s=ih(a.selector);if(s.test(t))return t.replace(s,a.replacement)}}catch(u){r={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t},Ji=function(){return y(void 0,void 0,void 0,function(){var t,e,r,n,i,o,a,s;return b(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),t=le(),t?[4,t.navigator.storage.estimate()]:[3,2];case 1:return e=u.sent(),r=e.usage,n=e.quota,i=e.usageDetails,o=r?Math.round(r/mn):0,a=r&&n?Math.round((r/n+Number.EPSILON)*1e3)/1e3:0,[2,{totalStorageSize:o,percentOfQuota:a,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return s=u.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},Zi=function(t){var e=T({},t),r=e.apiKey;return e.apiKey="****".concat(r.substring(r.length-4)),e};var Wu=function(){return{flushMaxRetries:2,logLevel:Fl.Warn,loggerProvider:new Cr,transportProvider:new Kl}},uh=(function(t){Ae(e,t);function e(r,n){var i=this,o,a,s,u,c,l,f,d,v,p,h,g,m,E,_=Wu();i=t.call(this,T(T({transportProvider:_.transportProvider,loggerProvider:new _n(n.loggerProvider||_.loggerProvider)},n),{apiKey:r}))||this,i.flushMaxRetries=n.flushMaxRetries!==void 0&&n.flushMaxRetries<=_.flushMaxRetries?n.flushMaxRetries:_.flushMaxRetries,i.apiKey=r,i.sampleRate=n.sampleRate||kp,i.serverZone=n.serverZone||Np,i.configServerUrl=n.configServerUrl,i.trackServerUrl=n.trackServerUrl,i.shouldInlineStylesheet=n.shouldInlineStylesheet,i.inlineImages=n.inlineImages,i.version=n.version,i.performanceConfig=n.performanceConfig||Up,i.storeType=(o=n.storeType)!==null&&o!==void 0?o:"memory",i.applyBackgroun
11dColorToBlockedElements=(a=n.applyBackgroundColorToBlockedElements)!==null&&a!==void 0?a:!1,i.enableUrlChangePolling=(s=n.enableUrlChangePolling)!==null&&s!==void 0?s:!1,i.urlChangePollingInterval=(u=n.urlChangePollingInterval)!==null&&u!==void 0?u:pn,i.captureDocumentTitle=(c=n.captureDocumentTitle)!==null&&c!==void 0?c:!1,n.fullSnapshotIntervalMs!==void 0&&(i.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),n.eagerFullSnapshotSend!==void 0&&(i.eagerFullSnapshotSend=n.eagerFullSnapshotSend),i.captureFullSnapshotOnFocus=(l=n.captureFullSnapshotOnFocus)!==null&&l!==void 0?l:!1,n.maxPersistedEventsSizeBytes!==void 0&&(i.maxPersistedEventsSizeBytes=sh(n.maxPersistedEventsSizeBytes,ah,N0,"maxPersistedEventsSizeBytes",i.loggerProvider)),n.maxSingleEventSizeBytes!==void 0&&(i.maxSingleEventSizeBytes=sh(n.maxSingleEventSizeBytes,ah,U0,"maxSingleEventSizeBytes",i.loggerProvider)),i.privacyConfig=T(T({},(f=n.privacyConfig)!==null&&f!==void 0?f:{}),{unmaskSelector:Array.from(new Set(F([".".concat(Xi)],w((v=(d=n.privacyConfig)===null||d===void 0?void 0:d.unmaskSelector)!==null&&v!==void 0?v:[]),!1)))}),n.interactionConfig&&(i.interactionConfig=n.interactionConfig,i.interactionConfig.ugcFilterRules&&oh(i.interactionConfig.ugcFilterRules)),n.debugMode&&(i.debugMode=n.debugMode);var S=n;return i.useWebWorker=(g=(p=n.useWebWorker)!==null&&p!==void 0?p:(h=S.experimental)===null||h===void 0?void 0:h.useWebWorker)!==null&&g!==void 0?g:!0,i.enableTransportCompression=(m=n.enableTransportCompression)!==null&&m!==void 0?m:!0,i.sendTimeoutMs=n.sendTimeoutMs,i.captureAdoptedStyleSheets=(E=n.captureAdoptedStyleSheets)!==null&&E!==void 0?E:!0,n.crossOriginIframes&&(i.crossOriginIframes=n.crossOriginIframes),n.flushIntervalConfig?i.flushIntervalConfig=M0(n.flushIntervalConfig,i.loggerProvider):i.flushIntervalConfig={minIntervalMs:Hp,maxIntervalMs:Wp},i.handleSendEvents=n.handleSendEvents,i.handleFetchConfig=n.handleFetchConfig,i}return e})(Gl);var gr=100,ah=1e3,N0=8e6,U0=1e7;function sh(t,e,r,n,i){if(!Number.isFinite(t)){i.warn("".concat(n," value is not a finite number (got ").concat(String(t),"); ignoring."));return}return t<e?(i.warn("".concat(n," ").concat(t," is below floor ").concat(e,"; clamping.")),e):t>r?(i.warn("".concat(n," ").concat(t," exceeds ceiling ").concat(r,"; clamping.")),r):t}function M0(t,e){var r,n,i={};if(t.minIntervalMs!==void 0&&(!Number.isFinite(t.minIntervalMs)||t.minIntervalMs<gr?(e.warn("flushIntervalConfig.minIntervalMs ".concat(t.minIntervalMs," is below floor ").concat(gr,"ms; clamping.")),i.minIntervalMs=gr):i.minIntervalMs=t.minIntervalMs),t.maxIntervalMs!==void 0&&(Number.isNaN(t.maxIntervalMs)||t.maxIntervalMs<gr?(e.warn("flushIntervalConfig.maxIntervalMs ".concat(t.maxIntervalMs," is below floor ").concat(gr,"ms; clamping.")),i.maxIntervalMs=gr):i.maxIntervalMs=t.maxIntervalMs),i.minIntervalMs!==void 0||i.maxIntervalMs!==void 0){var o=(r=i.minIntervalMs)!==null&&r!==void 0?r:hn,a=(n=i.maxIntervalMs)!==null&&n!==void 0?n:gn;a<o&&(i.maxIntervalMs===void 0?(e.warn("flushIntervalConfig.minIntervalMs (".concat(o,") exceeds the default maxIntervalMs (").concat(gn,"); raising max to match min.")),i.maxIntervalMs=o):i.minIntervalMs===void 0?(e.warn("flushIntervalConfig.maxIntervalMs (".concat(a,") is below the default minIntervalMs (").concat(hn,"); lowering min to match max.")),i.minIntervalMs=a):(e.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}var zt=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(zt||{}),eo=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(eo||{}),qu=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(qu||{});var F0=1500,G0=function(t,e){var r=document.createDocumentFragment(),n=function(i){if(i===void 0&&(i=[]),typeof i=="string"&&(i=[i]),i=i.filter(function(o){try{r.querySelector(o)}catch(a){return e.warn('[session-replay-browser] omitting selector "'.concat(o,'" because it is invali
11d')),!1}return!0}),i.length!==0)return i};return t.blockSelector=n(t.blockSelector),t.maskSelector=n(t.maskSelector),t.unmaskSelector=n(t.unmaskSelector),t},B0=(function(){function t(e,r){this.localConfig=r,this.remoteConfigClient=e}return t.prototype.generateJoinedConfig=function(){var e,r,n,i,o,a,s;return y(this,void 0,void 0,function(){var u,c,l,f,d,v,p,h,g,m,E,_,S,x,I,A,D,k=this;return b(this,function(U){switch(U.label){case 0:u=T({},this.localConfig),u.optOut=this.localConfig.optOut,u.captureEnabled=!0,U.label=1;case 1:return U.trys.push([1,3,,4]),[4,new Promise(function(R,O){k.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:F0},function(P,N){var G;if(k.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(N,":"),JSON.stringify(P,null,2)),!P){O(new Error("No remote config received"));return}var M=P,V=M.sr_sampling_config,X=M.sr_privacy_config,H=M.sr_targeting_config,Y=(G=u.interactionConfig)===null||G===void 0?void 0:G.ugcFilterRules;u.interactionConfig=M.sr_interaction_config,u.interactionConfig&&Y&&(u.interactionConfig.ugcFilterRules=Y),u.loggingConfig=M.sr_logging_config,(V||X||H)&&(c={},V&&(c.sr_sampling_config=V),X&&(c.sr_privacy_config=X),H&&(c.sr_targeting_config=H)),R()})})];case 2:return U.sent(),[3,4];case 3:return l=U.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",l),u.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:void 0}];case 4:if(!c)return[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:c}];if(f=c.sr_sampling_config,d=c.sr_privacy_config,v=c.sr_targeting_config,f&&Object.keys(f).length>0?(Object.prototype.hasOwnProperty.call(f,"capture_enabled")?u.captureEnabled=f.capture_enabled:u.captureEnabled=!1,Object.prototype.hasOwnProperty.call(f,"sample_rate")&&(u.sampleRate=f.sample_rate),Object.prototype.hasOwnProperty.call(f,"min_session_duration_ms")&&(u.minSessionDurationMs=this.sanitizeMinSessionDurationMs(f.min_session_duration_ms))):(u.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){p=(e=u.privacyConfig)!==null&&e!==void 0?e:{},h={defaultMaskLevel:(n=(r=d.defaultMaskLevel)!==null&&r!==void 0?r:p.defaultMaskLevel)!==null&&n!==void 0?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:F([],w(new Set(F(F([],w((i=p.maskAttributes)!==null&&i!==void 0?i:[]),!1),w((o=d.maskAttributes)!==null&&o!==void 0?o:[]),!1))),!1),urlMaskLevels:F(F([],w((a=d.urlMaskLevels)!==null&&a!==void 0?a:[]),!1),w((s=p.urlMaskLevels)!==null&&s!==void 0?s:[]),!1)},g=function(R){var O,P,N,G,M,V,X,H,Y,L={};typeof R.blockSelector=="string"&&(R.blockSelector=[R.blockSelector]);try{for(var W=C((X=R.blockSelector)!==null&&X!==void 0?X:[]),K=W.next();!K.done;K=W.next()){var z=K.value;L[z]="block"}}catch(ne){O={error:ne}}finally{try{K&&!K.done&&(P=W.return)&&P.call(W)}finally{if(O)throw O.error}}try{for(var $=C((H=R.maskSelector)!==null&&H!==void 0?H:[]),te=$.next();!te.done;te=$.next()){var z=te.value;L[z]="mask"}}catch(ne){N={error:ne}}finally{try{te&&!te.done&&(G=$.return)&&G.call($)}finally{if(N)throw N.error}}try{for(var Q=C((Y=R.unmaskSelector)!==null&&Y!==void 0?Y:[]),ae=Q.next();!ae.done;ae=Q.next()){var z=ae.value;L[z]="unmask"}}catch(ne){M={error:ne}}finally{try{ae&&!ae.done&&(V=Q.return)&&V.call(Q)}finally{if(M)throw M.error}}return L},m=T(T({},g(p)),g(d));try{for(E=C(Object.entries(m)),_=E.next();!_.done;_=E.next())S=w(_.value,2),x=S[0],I=S[1],I==="mask"?h.maskSelector.push(x):I==="block"?h.blockSelector.push(x):I==="unmask"&&h.unmaskSelector.push(x)}catch(R){A={error:R}}finally{try{_&&!_.done&&(D=E.return)&&D.call(E)}finally{if(A)throw A.error}}u.privacyConfig=G0(h,this.localConfig.loggerProvider)}return v&&Object.keys(v).length>0&&(u.targetingConfig=v),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:Zi(u)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:u,remoteConfig:c}]}})})},t.prototype.sanitizeMinSessionDurationMs=function(e){if(typeof e!="number"||!Number.isFinite(e)){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."));return}if(e<0){this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring."));return}return e>Xu?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(Xu,"ms ceiling; clamping.")),Xu):e},t})();var Xu=6e4,lh=function(t,e){return y(void 0,void 0,void 0,function(){var r,n;return b(this,function(i){return r=new uh(t,e),n=new Hl(t,r.loggerProvider,r.serverZone,e.configServerUrl,e.handleFetchConfig),[2,new B0(n,r)]})})};function ch(t){if(t.type!==zt.IncrementalSnapshot)return!1;var e=t.data;return e.source===eo.Mutation&&!e.isAttachIframe}function V0(t){return typeof t=="object"&&t!==null}function K0(t){var e,r,n,i,o={};try{for(var a=C(t),s=a.next();!s.done;s=a.next()){var u=s.value;try{for(var c=(n=void 0,C(Object.keys(u))),l=c.next();!l.done;l=c.next()){var f=l.value;o[f]=u[f]}}catch(d){n={error:d}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}}}catch(d){e={error:d}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return o}function H0(t){var e,r,n=new Map;if(t.forEach(function(d,v){if(d.attributes&&"style"in d.attributes){var p=n.get(d.id);p?p.push(v):n.set(d.id,[v])}}),n.size===0)return t;var i=function(d){return t[d].attributes.style},o=new Set,a=new Map,s=function(d){if(d.length===1)return"continue";var v=-1;d.forEach(function(m,E){V0(i(m))||(v=E)});var p=[];
11if(d.forEach(function(m,E){E!==v&&(o.add(m),E>v&&p.push(m))}),p.length>0){var h=p[p.length-1],g=K0(p.map(function(m){return i(m)}));o.delete(h),a.set(h,g)}};try{for(var u=C(n.values()),c=u.next();!c.done;c=u.next()){var l=c.value;s(l)}}catch(d){e={error:d}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}if(o.size===0&&a.size===0)return t;var f=[];return t.forEach(function(d,v){var p=a.get(v);if(p!==void 0){f.push(T(T({},d),{attributes:T(T({},d.attributes),{style:p})}));return}if(!o.has(v)){f.push(d);return}var h=T({},d.attributes);delete h.style,Object.keys(h).length>0&&f.push(T(T({},d),{attributes:h}))}),f}function W0(t){var e,r,n,i,o=t[0],a=new Map,s=new Map,u=new Map,c=new Map,l=new Map;t.forEach(function(L,W){var K,z,$,te,Q=L.data;try{for(var ae=C(Q.adds),ne=ae.next();!ne.done;ne=ae.next()){var B=ne.value;a.has(B.node.id)||a.set(B.node.id,W),s.set(B.node.id,W),l.set(B.node.id,B.parentId)}}catch(j){K={error:j}}finally{try{ne&&!ne.done&&(z=ae.return)&&z.call(ae)}finally{if(K)throw K.error}}try{for(var ge=C(Q.removes),ce=ge.next();!ce.done;ce=ge.next()){var ue=ce.value;u.has(ue.id)||u.set(ue.id,W),c.set(ue.id,W)}}catch(j){$={error:j}}finally{try{ce&&!ce.done&&(te=ge.return)&&te.call(ge)}finally{if($)throw $.error}}});var f=new Set,d=new Set;try{for(var v=C(a),p=v.next();!p.done;p=v.next()){var h=w(p.value,2),g=h[0],m=h[1],E=u.get(g);if(E!==void 0){var _=s.get(g),S=c.get(g);_>=S||(m<E?f.add(g):E<m&&d.add(g))}}}catch(L){e={error:L}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(e)throw e.error}}var x=new Set;if(f.size>0||d.size>0)for(var I=!0;I;){I=!1;try{for(var A=(n=void 0,C(l)),D=A.next();!D.done;D=A.next()){var k=w(D.value,2),U=k[0],R=k[1];if(!f.has(U)&&!d.has(U)&&!x.has(U)&&(f.has(R)||d.has(R)||x.has(R))){var O=u.get(U),P=a.get(U);O!==void 0&&P!==void 0&&O<P?d.add(U):O!==void 0&&P!==void 0&&O===P?x.add(U):f.add(U),I=!0}}}catch(L){n={error:L}}finally{try{D&&!D.done&&(i=A.return)&&i.call(A)}finally{if(n)throw n.error}}}var N=f.size>0||d.size>0||x.size>0,G=[];t.forEach(function(L,W){var K,z;try{for(var $=C(L.data.removes),te=$.next();!te.done;te=$.next()){var Q=te.value;f.has(Q.id)||d.has(Q.id)&&W>=a.get(Q.id)||x.has(Q.id)&&(f.has(Q.parentId)||d.has(Q.parentId)||x.has(Q.parentId))||G.push(Q)}}catch(ae){K={error:ae}}finally{try{te&&!te.done&&(z=$.return)&&z.call($)}finally{if(K)throw K.error}}});var M=t.flatMap(function(L){return L.data.adds}),V=t.flatMap(function(L){return L.data.texts}),X=t.flatMap(function(L){return L.data.attributes}),H=N?X.filter(function(L){return!f.has(L.id)&&!d.has(L.id)&&!x.has(L.id)}):X,Y={source:eo.Mutation,removes:G,adds:N?M.filter(function(L){return!f.has(L.node.id)&&!d.has(L.node.id)&&!x.has(L.node.id)}):M,texts:N?V.filter(function(L){return!f.has(L.id)&&!d.has(L.id)&&!x.has(L.id)}):V,attributes:H0(H)};return T(T({},o),{data:Y})}function dh(t){if(t.length<=1)return t;for(var e=[],r=0;r<t.length;){if(!ch(t[r])){e.push(t[r]),r++;continue}for(var n=r+1;n<t.length&&ch(t[n]);)n++;e.push(n>r+1?W0(t.slice(r,n)):t[r]),r=n}return e}var q0=2e3,fh=(function(){function t(e,r,n,i,o){var a=this,s;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(d){var v=d,p=v.type,h=v.timestamp,g=v.delay,m=v.data;return g!=null?JSON.stringify({type:p,timestamp:h,delay:g,data:m}):JSON.stringify({type:p,timestamp:h,data:m})},this.addCompressedEventToManager=function(d,v){var p,h=new Blob([d]).size;if(h>((p=a.config.maxSingleEventSizeBytes)!==null&&p!==void 0?p:Yi)){a.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(h/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."));return}a.eventsManager&&a.deviceId&&a.eventsManager.addEvent({event:{type:"replay",data:d},sessionId:v,deviceId:a.deviceId})},this.addCompressedEvent=function(d,v){if(a.worker)try{a.worker.postMessage({event:d,sessionId:v})}catch(h){h.name==="DataCloneError"?a.worker.postMessage(JSON.stringify({event:d,sessionId:v})):a.config.loggerProvider.warn("Unexpected error while posting message to worker:",h)}else{var p=a.compressEvent(d);a.addCompressedEventToManager(p,v)}},this.flushQueue=function(){var d;for(a.pendingQueue.length>0&&(d=a.taskQueue).push.apply(d,F([],w(a.mergeMutationTasks(a.pendingQueue.splice(0))),!1));a.taskQueue.length>0;){var v=a.taskQueue.shift();if(v){var p=v.event,h=v.sessionId,g=a.compressEvent(p);a.addCompressedEventToManager(g,h)}}a.isProcessing=!1},this.terminate=function(){var d;(d=a.worker)===null||d===void 0||d.terminate()};var u=le();if(this.canUseIdleCallback=u&&"requestIdleCallback"in u,this.eventsManager=e,this.config=r,this.deviceId=n,this.timeout=((s=r.performanceConfig)===null||s===void 0?void 0:s.timeout)||q0,this.onFullSnapshotProcessed=o,i){r.loggerProvider.log("Enabling web worker for compression");try{var c=new Blob([i],{type:"application/javascript"}),l=URL.createObjectURL(c),f=new Worker(l);f.onerror=function(d){d.preventDefault(),r.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(d.message," (").concat(d.filename,":").concat(d.lineno,")")),f.terminate(),a.worker=void 0},f.onmessage=function(d){var v=d.data,p=v.compressedEvent,h=v.sessionId;a.addCompressedEventToManager(p,h)},this.worker=f}catch(d){r.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",d)}}}return t.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(r){e.processQueue(r)},{timeout:this.timeout}))},t.prototype.enqueueEvent=function(e,r){var n,i,o,a;if(e.type===zt.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var s=F(F([],w(this.taskQueue.splice(0)),!1),w(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var u=C(s),c=u.next();!c.done;c=u.next()){var l=c.value,f=this.compressEvent(l.event);this.addCompressedEventToManager(f,l.sessionId)}}catch(v){n={error:v}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,r),(o=this.onFullSnapshotProcessed)===null||o===void 0||o.call(this);return}this.canUseIdleCallback&&(!((a=this.config.performanceConfig)===null||a===void 0)&&a.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:r}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,r))},t.prototype.processQueue=function(e){var r,n=this;for(this.pendingQueue.length>0&&(r=this.taskQueue).push.apply(r,F([],w(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var i=this.taskQueue.shift();if(i){var o=i.event,a=i.sessionId;this.addCompressedEvent(o,a)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(s){n.processQueue(s)},{timeout:this.timeout}):this.isProcessing=!1},t.prototype.mergeMutationTasks=function(e){var r,n,i;if(((i=this.config.performanceConfig)===null||i===void 0?void 0:i.mergeMutations)===!1||e.length<=1)return e;for(var o=[],a=0;a<e.length;){for(var s=e[a].sessionId,u=a+1;u<e.length&&e[u].sessionId===s;)u++;var c=dh(e.slice(a,u).map(function(v){return v.event}));try{for(var l=(r=void 0,C(c)),f=l.next();!f.done;f=l.next()){var d=f.value;o.push({event:d,sessionId:s})}}catch(v){r={error:v}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}a=u}return o},t})();var vh="Unexpected error occurred",ph="Network error occurred, event batch rejected",ju="Session replay event batch rejected due to exceeded retry count",ze="Failed to store session replay events in IndexedDB",hh="Session replay event batch not sent due to missing device ID",gh="Session replay event batch not sent due to missing api key",to="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session";var mr="1.50.1";function mh(t,e){return y(this,void 0,void 0,function(){var r,n,i,o,a,s,u,c,l,f,d,v,p,h,g,m=this;return b(this,function(E){switch(E.label){case 0:return E.trys.push([0,4,,5]),r=e.CompressionStream,n=new r("gzip"),i=n.writable.getWriter(),o=n.readable.getReader(),a=[],s=(function(){return y(m,void 0,void 0,function(){var _,S,x;return b(this,function(I){switch(I.label){case 0:return[4,o.read()];case 1:if(_=I.sent(),S=_.done,x=_.value,S)return[3,3];a.push(x),I.label=2;case 2:return[3,0];case 3:return[2]}})})})(),[4,i.write(new TextEncoder().encode(t))];case 1:return E.sent(),[4,i.close()];case 2:return E.sent(),[4,s];case 3:E.sent(),u=a.reduce(function(_,S){return _+S.length},0),c=new Uint8Array(u),l=0;try{for(f=C(a),d=f.next();!d.done;d=f.next())v=d.value,c.set(v,l),l+=v.length}catch(_){h={error:_}}finally{try{d&&!d.done&&(g=f.return)&&g.call(f)}finally{if(h)throw h.error}}return[2,c];case 4:return p=E.sent(),[2,null];case 5:return[2]}})})}var X0=256,j0=256;function z0(t,e){return new Promise(function(r,n){var i=function(){var o=new Error("Custom session replay transport aborted by send timeout");o.name="AbortError",n(o)};e.addEventListener("abort",i,{once:!0}),t.then(function(o){e.removeEventListener("abort",i),r(o)},function(o){e.removeEventListener("abort",i),n(o)})})}var Eh=(function(){function t(e){var r=e.trackServerUrl,n=e.loggerProvider,i=e.payloadBatcher,o=e.workerScript,a=e.enableTransportCompression,s=e.sendTimeoutMs,u=e.handleSendEvents,c=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=n,this.payloadBatcher=i||function(v){return v},this.trackServerUrl=r,this.enableTransportCompression=a??!0,this.sendTimeoutMs=s??jp,this.handleSendEvents=u,o)try{var l=new Blob([o],{type:"application/javascript"}),f=URL.createObjectURL(l),d=new Worker(f);d.onerror=function(v){var p,h;v.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(v.message," (").concat(v.filename,":").concat(v.lineno,")")),d.terminate(),c.worker=void 0;try{for(var g=C(c.pendingWorkerRequests),m=g.next();!m.done;m=g.next()){var E=w(m.value,2),_=E[1];_.timeout&&clearTimeout(_.timeout),n.warn("Session replay event send failed due to worker crash: ".concat(v.message)),_.resolve()}}catch(S){p={error:S}}finally{try{m&&!m.done&&(h=g.return)&&h.call(g)}finally{if(p)throw p.error}}c.pendingWorkerRequests.clear(),c.timedOutWorkerRequests.clear()},d.onmessage=function(v){var p=v.data;if(p.type==="log")n.log(p.message);else if(p.type==="warn")n.warn(p.message);else if(p.type==="payload_too_large"){var h=c.pendingWorkerRequests.get(p.id);if(h)h.timeout&&clearTimeout(h.timeout),c.handlePayloadTooLargeResponse(h.context,p.isWaf),h.resolve(),c.pendingWorkerRequests.delete(p.id);else{var g=c.timedOutWorkerRequests.get(p.id);g&&(c.timedOutWorkerRequests.delete(p.id),c.handlePayloadTooLargeResponse(g,p.isWaf))}}else if(p.type==="complete"){var m=c.pendingWorkerRequests.get(p.id);if(m)m.timeout&&clearTimeout(m.timeout),p.skipCode!==void 0&&c.applyServerDirective(m.context.sessionId,p.skipCode),c.completeRequest({context:m.context}),m.resolve(),c.pendingWorkerRequests.delete(p.id);else{var g=c.timedOutWorkerRequests.get(p.id);g&&(c.timedOutWorkerRequests.delete(p.id),p.skipCode!==void 0&&c.applyServerDirective(g.sessionId,p.skipCode),c.completeRequest({context:g}))}}else p.type==="fetch-request"&&c.handleDelegatedFetch(d,p).catch(function(E){n.warn("Failed to handle delegated session replay fetch:",E)})},this.worker=d}catch(v){n.error("Failed to create track destination worker, falling back to main-thread sending:",v)}}return t.prototype.sendEventsList=function(e){this.addToQueue(T(T({},e),{attempts:0,timeout:0}))},t.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},t.prototype.sendBeacon=function(e){var r=this,n,i,o=e.events,a=e.sessionId,s=e.deviceId,u=e.apiKey,c=e.serverZone,l=64*1024,f=function(k){return new Blob([k]).size},d=o,v=JSON.stringify({version:2,events:d});if(f(v)>l){for(var p=0,h=d.length;p<h;){var g=Math.floor((p+h+1)/2);f(JSON.stringify({version:2,events:d.slice(0,g)}))<=l?p=g:h=g-1}d=d.slice(0,p),v=JSON.stringify({version:2,events:d}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(o.length," to ").concat(d.length," events"))}if(d.length!==0){if(this.handleSendEvents){var m=new URLSearchParams({device_id:s,session_id:String(a),type:"replay"}),E="".concat(yt(c,this.trackServerUrl),"?").concat(m.toString()),_={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(u)};this.loggerProvider.debug("Routing session replay exit batch (".concat(d.length," events) through custom transport for session id ").concat(a,"."));try{this.handleSendEvents({url:E,method:"POST",headers:_,body:v,keepalive:!0}
11).catch(function(k){r.loggerProvider.warn("Custom transport failed to send session replay exit batch:",k)})}catch(k){this.loggerProvider.warn("Custom transport threw while sending session replay exit batch:",k)}return}var S=new URLSearchParams({device_id:s,session_id:String(a),type:"replay",api_key:u}),x="".concat(yt(c,this.trackServerUrl),"?").concat(S.toString()),I=le();try{var A=new Blob([v],{type:"application/json"}),D=(i=(n=I?.navigator)===null||n===void 0?void 0:n.sendBeacon)===null||i===void 0?void 0:i.call(n,x,A);D===!1&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch(k){}}},t.prototype.addToQueue=function(){for(var e=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=r.filter(function(o){return e.killedSessions.has(o.sessionId)?(e.completeRequest({context:o,err:to}),!1):o.attempts<(o.flushMaxRetries||0)?(o.attempts+=1,!0):(e.completeRequest({context:o,err:ju}),!1)});i.forEach(function(o){e.queue=e.queue.concat(o),e.schedule(0)})},t.prototype.schedule=function(e){var r=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),i=n>0,o=n>e?n:e;i&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){r.flush(!0).then(function(){r.queue.length>0&&r.schedule(e)})},o)}},t.prototype.flush=function(e){return e===void 0&&(e=!1),y(this,void 0,void 0,function(){var r,n,i,o,a,s,u;return b(this,function(c){switch(c.label){case 0:r=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,r=this.mergeQueueAfterThrottle(r)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,r=this.mergeDrainBacklog(r)),c.label=1;case 1:c.trys.push([1,6,7,8]),n=C(r),i=n.next(),c.label=2;case 2:return i.done?[3,5]:(o=i.value,[4,this.send(o,e)]);case 3:c.sent(),c.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=c.sent(),s={error:a},[3,8];case 7:try{i&&!i.done&&(u=n.return)&&u.call(n)}finally{if(s)throw s.error}return[7];case 8:return[2]}})})},t.prototype.mergeQueueAfterThrottle=function(e){var r=this.coalesceByIdentity(e);return r.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(r.length," request(s)"))),r},t.prototype.mergeDrainBacklog=function(e){var r=this.coalesceByIdentity(e);return r.length<e.length&&this.loggerProvider.log("Session replay coalesced ".concat(e.length," persisted page-load backlog batches into ").concat(r.length," request(s)")),r},t.prototype.coalesceByIdentity=function(e){var r,n,i,o,a=this,s,u,c,l,f,d,v;if(e.length<=1)return e;var p=new Map;try{for(var h=C(e),g=h.next();!g.done;g=h.next()){var m=g.value,E=[m.sessionId,(s=m.deviceId)!==null&&s!==void 0?s:"",(u=m.apiKey)!==null&&u!==void 0?u:"",m.type,(c=m.serverZone)!==null&&c!==void 0?c:"",m.sampleRate,(f=(l=m.version)===null||l===void 0?void 0:l.type)!==null&&f!==void 0?f:"",(v=(d=m.version)===null||d===void 0?void 0:d.version)!==null&&v!==void 0?v:""].join("|"),_=p.get(E);_?_.push(m):p.set(E,[m])}}catch(k){r={error:k}}finally{try{g&&!g.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var S=[],x=function(k){var U,R;if(k.length===1)return S.push(k[0]),"continue";var O=null,P=0,N=function(){O&&S.push(O),O=null,P=0},G=function(H){var Y=H.events.reduce(function(K,z){return K+new Blob([z]).size},0);if(O===null)return O=T(T({},H),{events:F([],w(H.events),!1),attempts:0}),P=Y,"continue";if(P+Y>Qp)return N(),O=T(T({},H),{events:F([],w(H.events),!1),attempts:0}),P=Y,"continue";var L=O.onComplete,W=H.onComplete;O.events=O.events.concat(H.events),P+=Y,O.onComplete=function(){return y(a,void 0,void 0,function(){return b(this,function(K){switch(K.label){case 0:return[4,Promise.allSettled([L(),W()])];case 1:return K.sent(),[2]}})})}};try{for(var M=(U=void 0,C(k)),V=M.next();!V.done;V=M.next()){var X=V.value;G(X)}}catch(H){U={error:H}}finally{try{V&&!V.done&&(R=M.return)&&R.call(M)}finally{if(U)throw U.error}}N()};try{for(var I=C(p.values()),A=I.next();!A.done;A=I.next()){var D=A.value;x(D)}}catch(k){i={error:k}}finally{try{A&&!A.done&&(o=I.return)&&o.call(I)}finally{if(i)throw i.error}}return S},t.prototype.send=function(e,r){return r===void 0&&(r=!0),y(this,void 0,void 0,function(){var n,i,o,a;return b(this,function(s){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:to})]:(n=e.apiKey,n?(i=e.deviceId,i?(o=this.payloadBatcher({version:1,events:e.events}),o.events.length===0?(this.completeRequest({context:e}),[2]):(a=this.worker,a?[2,this.sendViaWorker(a,e,o,r)]:[2,this.sendOnMainThread(n,i,e,o,r)])):[2,this.completeRequest({context:e,err:hh})]):[2,this.completeRequest({context:e,err:gh})])})})},t.prototype.sendViaWorker=function(e,r,n,i){return y(this,void 0,void 0,function(){var o,a=this;return b(this,function(s){return o="".concat(++this.sendIdCounter),[2,new Promise(function(u){var c,l=a.sendTimeoutMs>0?setTimeout(function(){var f=a.pendingWorkerRequests.get(o);
11f&&(a.pendingWorkerRequests.delete(o),a.rememberTimedOutRequest(o,f.context),a.loggerProvider.warn("Session replay worker send timed out after ".concat(a.sendTimeoutMs,"ms; leaving events for retry")),f.resolve())},a.sendTimeoutMs):void 0;a.pendingWorkerRequests.set(o,{context:r,resolve:u,timeout:l}),e.postMessage({type:"send",id:o,payload:n,useRetry:i,useCustomTransport:!!a.handleSendEvents,context:{apiKey:r.apiKey,deviceId:r.deviceId,sessionId:r.sessionId,events:r.events,eventType:r.type,flushMaxRetries:(c=r.flushMaxRetries)!==null&&c!==void 0?c:0,sampleRate:r.sampleRate,serverZone:r.serverZone,trackServerUrl:a.trackServerUrl,version:r.version,currentUrl:bn(),sdkVersion:mr,enableTransportCompression:a.enableTransportCompression,sendTimeoutMs:a.sendTimeoutMs}})})]})})},t.prototype.rememberTimedOutRequest=function(e,r){var n,i;if(this.timedOutWorkerRequests.set(e,r),this.timedOutWorkerRequests.size>j0)try{for(var o=C(this.timedOutWorkerRequests.keys()),a=o.next();!a.done;a=o.next()){var s=a.value;this.timedOutWorkerRequests.delete(s);break}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},t.prototype.handleDelegatedFetch=function(e,r){var n,i,o;return y(this,void 0,void 0,function(){var a,s,u,c,l,f,d,v,p,h,g,m;return b(this,function(E){switch(E.label){case 0:a=r.requestId,s=r.url,u=r.method,c=r.headers,l=r.body,f=r.keepalive,E.label=1;case 1:return E.trys.push([1,10,,11]),d=void 0,this.handleSendEvents?[4,this.handleSendEvents({url:s,method:u,headers:c,body:l,keepalive:f})]:[3,3];case 2:return d=E.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:u,headers:c,body:l,keepalive:f})];case 4:d=E.sent(),E.label=5;case 5:if(v=d.status,p=null,h="",v>=200&&v<300&&(p=(o=(i=(n=d.headers)===null||n===void 0?void 0:n.get)===null||i===void 0?void 0:i.call(n,Bu))!==null&&o!==void 0?o:null),v!==413)return[3,9];E.label=6;case 6:return E.trys.push([6,8,,9]),[4,d.text()];case 7:return h=E.sent(),[3,9];case 8:return g=E.sent(),[3,9];case 9:return this.loggerProvider.debug("Delegated session replay fetch (request ".concat(a,") returned status ").concat(v,".")),e.postMessage({type:"fetch-response",requestId:a,status:v,skipHeader:p,body:h}),[3,11];case 10:return m=E.sent(),this.loggerProvider.debug("Delegated session replay fetch (request ".concat(a,") failed:"),m),e.postMessage({type:"fetch-response",requestId:a,status:0,skipHeader:null,body:String(m),error:!0}),[3,11];case 11:return[2]}})})},t.prototype.sendOnMainThread=function(e,r,n,i,o){var a,s,u,c,l,f,d;return y(this,void 0,void 0,function(){var v,p,h,g,m,E,_,S,x,I,A,D,k,U,R,O,P,N,G,M,V,V,X,H,Y;return b(this,function(L){switch(L.label){case 0:v=bn(),p=mr,h=n.sampleRate,g=new URLSearchParams({device_id:r,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),m="".concat((s=(a=n.version)===null||a===void 0?void 0:a.type)!==null&&s!==void 0?s:"standalone","/").concat((c=(u=n.version)===null||u===void 0?void 0:u.version)!==null&&c!==void 0?c:p),L.label=1;case 1:return L.trys.push([1,19,,23]),E=JSON.stringify(i),_=le(),this.enableTransportCompression&&_&&"CompressionStream"in _?[4,mh(E,_)]:[3,3];case 2:return x=L.sent(),[3,4];case 3:x=null,L.label=4;case 4:if(S=x,I=S?S.byteLength:new Blob([E]).size,A=new AbortController,D=T({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":p,"X-Client-Library":m,"X-Client-Url":v.substring(0,qp),"X-Client-Sample-Rate":"".concat(h),"X-Sampling-Hash-Alg":"xxhash32"},S?{"Content-Encoding":"gzip"}:{}),k=S??E,U=I<=Xp,R={headers:D,body:k,method:"POST",keepalive:U,signal:A.signal},O="".concat(yt(n.serverZone,this.trackServerUrl),"?").concat(g.toString()),i.events.length===0)return this.completeRequest({context:n}),[2];P=this.sendTimeoutMs>0?setTimeout(function(){A.abort()},this.sendTimeoutMs):void 0,N=void 0,L.label=5;case 5:return L.trys.push([5,,10,11]),this.handleSendEvents?[4,z0(this.handleSendEvents({url:O,method:"POST",headers:D,body:k,keepalive:U}),A.signal)]:[3,7];case 6:return G=L.sent(),[3,9];case 7:return[4,fetch(O,R)];case 8:G=L.sent(),L.label=9;case 9:return N=G,[3,11];case 10:return P&&clearTimeout(P),[7];case 11:if(N===null)return this.completeRequest({context:n,err:vh}),[2];if(N.status>=200&&N.status<300&&(M=(d=(f=(l=N.headers)===null||l===void 0?void 0:l.get)===null||f===void 0?void 0:f.call(l,Bu))!==null&&d!==void 0?d:null,this.applyServerDirective(n.sessionId,M)),o)return[3,12];V="";try{V=JSON.stringify(N.body,null,2)}catch(W){}return this.completeRequest({context:n,success:"".concat(N.status,": ").concat(V)}),[3,18];
11case 12:if(V="",N.status!==413)return[3,16];L.label=13;case 13:return L.trys.push([13,15,,16]),[4,N.text()];case 14:return V=L.sent(),[3,16];case 15:return X=L.sent(),[3,16];case 16:return[4,this.handleReponse(N.status,n,V)];case 17:L.sent(),L.label=18;case 18:return[3,23];case 19:return H=L.sent(),Y=!!H&&typeof H=="object"&&H.name==="AbortError",Y&&o?[4,this.handleOtherResponse(n)]:[3,21];case 20:return L.sent(),[3,22];case 21:this.completeRequest({context:n,err:H}),L.label=22;case 22:return[3,23];case 23:return[2]}})})},t.prototype.handleReponse=function(e,r,n){return n===void 0&&(n=""),y(this,void 0,void 0,function(){var i,o;return b(this,function(a){switch(a.label){case 0:switch(i=new Vl().buildStatus(e),o=i,o){case Qt.Success:return[3,1];case Qt.Failed:return[3,2];case Qt.Timeout:return[3,2];case Qt.RateLimit:return[3,2];case Qt.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(r),[3,8];case 2:return[4,this.handleOtherResponse(r)];case 3:return a.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(r,Bp.test(n)),[3,8];case 5:return e!==499?[3,7]:[4,this.handleOtherResponse(r)];case 6:return a.sent(),[3,8];case 7:this.completeRequest({context:r,err:ph}),a.label=8;case 8:return[2]}})})},t.prototype.handlePayloadTooLargeResponse=function(e,r){var n=r?"WAF (compressed payload too large)":"server (event too large)",i=Math.round(e.events.reduce(function(s,u){return s+u.length},0)/mn);if(!r){this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(i," KB) \u2014 not retrying non-WAF 413")});return}if(e.events.length===1){this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(i," KB, 1 event) rejected by ").concat(n," \u2014 cannot split further")});return}this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(i," KB total) \u2014 splitting and retrying")),e.onComplete();var o=function(){return Promise.resolve()},a=Math.floor(e.events.length/2);this.sendEventsList(T(T({},e),{events:e.events.slice(0,a),onComplete:o})),this.sendEventsList(T(T({},e),{events:e.events.slice(a),onComplete:o}))},t.prototype.handleSuccessResponse=function(e){var r=Math.round(new Blob(e.events).size/mn);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(r," KB")})},t.prototype.handleOtherResponse=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return r=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:ju}),[2]):[4,new Promise(function(i){return setTimeout(i,r)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},t.prototype.completeRequest=function(e){var r=e.context,n=e.err,i=e.success;r.onComplete(),n?this.loggerProvider.warn(n):i&&this.loggerProvider.log(i)},t.prototype.applyServerDirective=function(e,r){if(r===null){this.flushPauseUntilMs=0,this.mergeLogFiredThisPause=!1;return}if(r===zp){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+Vu,n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(Vu/1e3,"s"));return}(r===Yp||r===$p)&&this.killSession(e,r)},t.prototype.killSession=function(e,r){var n,i,o,a;if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>X0)try{for(var s=C(this.killedSessions),u=s.next();!u.done;u=s.next()){var c=u.value;this.killedSessions.delete(c);break}}catch(p){n={error:p}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(r,"; remaining events will be dropped"));var l=[];try{for(var f=C(this.queue),d=f.next();!d.done;d=f.next()){var v=d.value;v.sessionId===e?this.completeRequest({context:v,err:to}):l.push(v)}}catch(p){o={error:p}}finally{try{d&&!d.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}this.queue=l}},t})();var ro=(function(){function t(e){var r=this,n,i,o;
11this.minInterval=hn,this.maxInterval=gn,this.maxPersistedEventsSize=Gp,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(a,s){var u=r.getStringSize(s),c=r.getEventsArraySize(a);return c+u>=r.maxPersistedEventsSize?!0:Date.now()-r.timeAtLastSplit>r.interval&&a.length?(r.interval=Math.min(r.maxInterval,r.interval+r.minInterval),r._timeAtLastSplit=Date.now(),!0):!1},this.loggerProvider=e.loggerProvider,this.minInterval=(n=e.minInterval)!==null&&n!==void 0?n:this.minInterval,this.maxInterval=(i=e.maxInterval)!==null&&i!==void 0?i:this.maxInterval,this.maxPersistedEventsSize=(o=e.maxPersistedEventsSize)!==null&&o!==void 0?o:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(t.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),t.prototype.getStringSize=function(e){for(var r=0,n=0;n<e.length;n++){var i=e.charCodeAt(n);if(i<=127)r++;else if(i<=2047)r+=2;else if(i>=55296&&i<=56319){var o=n+1<e.length?e.charCodeAt(n+1):NaN;o>=56320&&o<=57343?(r+=4,n++):r+=3}else i>=56320&&i<=57343,r+=3}return r},t.prototype.getEventsArraySize=function(e){var r,n,i=0;try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;i+=this.getStringSize(s)}}catch(c){r={error:c}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}var u=2+Math.max(0,e.length-1)+e.length*2;return i+u},t})();var $0=function(t){return typeof t=="object"&&t!==null&&t.name==="AbortError"},Me=function(t,e,r){$0(r)?t.debug(e):t.warn(e)};function Y0(){try{return crypto.randomUUID()}catch(t){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var r=Math.random()*16|0;return(e==="x"?r:r&3|8).toString(16)})}}var Ze="sessionCurrentSequence",Tt="sequencesToSend";var Q0=2e3,zu=5e3;function J0(t,e,r){return r===void 0&&(r="IDB operation timed out"),new Promise(function(n,i){var o=setTimeout(function(){return i(new Error("".concat(r," after ").concat(e,"ms")))},e);t.then(function(a){clearTimeout(o),n(a)},function(a){clearTimeout(o),i(a)})})}function $u(t,e,r){var n=setTimeout(r,e);return t.then(function(){return clearTimeout(n)},function(){return clearTimeout(n)}),function(){return clearTimeout(n)}}var Z0=function(t){var e,r;return t.objectStoreNames.contains(Ze)||(r=t.createObjectStore(Ze,{keyPath:"sessionId"})),t.objectStoreNames.contains(Tt)||(e=t.createObjectStore(Tt,{keyPath:"sequenceId",autoIncrement:!0}),e.createIndex("sessionId","sessionId")),{sequencesStore:e,currentSequenceStore:r}},e_=function(t){return y(void 0,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,J0(Dn(t,1,{upgrade:Z0}),Q0,"IDB openDB timed out")];case 1:return[2,e.sent()]}})})},_h=(function(t){Ae(e,t);function e(r){var n=this,i;return n=t.call(this,r)||this,n.consecutiveFailures=0,n.hasTriggeredFallback=!1,n.emptyFilteredCount=0,n.getSequencesToSend=function(){return y(n,void 0,void 0,function(){var o,a,s,u,c,l,f,d,v,p,h=this;return b(this,function(g){switch(g.label){case 0:o=!1,a=!1,g.label=1;case 1:return g.trys.push([1,9,,10]),s=[],u=this.db.transaction("sequencesToSend","readwrite"),u.done.catch(function(m){!o&&!a&&(Me(h.loggerProvider,"".concat(ze,": ").concat(m),m),h.recordFailure())}),c=$u(u.done,zu,function(){!o&&!a&&(a=!0,Me(h.loggerProvider,"".concat(ze,": transaction timed out")),h.recordFailure())}),[4,u.store.openCursor()];case 2:l=g.sent(),g.label=3;case 3:return l?(f=l.value,d=f.sessionId,v=f.events,v.length!==0?[3,5]:(this.maybeLogEmptyFiltered("getSequencesToSend"),[4,l.delete()])):[3,8];case 4:return g.sent(),[3,6];case 5:s.push({events:v,sequenceId:l.key,sessionId:d}),g.label=6;case 6:return[4,l.continue()];case 7:return l=g.sent(),[3,3];case 8:return this.recordSuccess(),c(),[2,s];case 9:return p=g.sent(),a||(o=!0,Me(this.loggerProvider,"".concat(ze,": ").concat(p),p),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},n.storeCurrentSequence=function(o){return y(n,void 0,void 0,function(){var a,s,u,c,l,f,d,v,p,h=this;return b(this,function(g){switch(g.label){case 0:a=!1,s=!1,g.label=1;case 1:return g.trys.push([1,5,,6]),u=this.db.transaction([Ze,Tt],"readwrite"),u.done.catch(function(m){!a&&!s&&(Me(h.loggerProvider,"".concat(ze,": ").concat(m),m),h.recordFailure())}),c=$u(u.done,zu,function(){!a&&!s&&(s=!0,Me(h.loggerProvider,"".concat(ze,": transaction timed out")),h.recordFailure())}),[4,u.objectStore(Ze).get(o)];case 2:return l=g.sent(),!l||l.tabId&&l.tabId!==this.tabId?(c(),[2,void 0]):l.events.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),c(),[2,void 0]):[4,u.objectStore(Tt).put({sessionId:o,events:l.events,tabId:this.tabId})];case 3:return f=g.sent(),[4,u.objectStore(Ze).put({sessionId:o,events:[],tabId:this.tabId})];case 4:return g.sent(),this.recordSuccess(),c(),d=l.tabId,v=nt(l,["tabId"]),[2,T(T({},v),{sessionId:o,sequenceId:f})];case 5:return p=g.sent(),s||(a=!0,Me(this.loggerProvider,"".concat(ze,": ").concat(p),p),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},n.addEventToCurrentSequence=function(o,a){return y(n,void 0,void 0,function(){var s,u,c,l,f,d,v,p,h,g=this;return b(this,function(m){switch(m.label){case 0:s=!1,u=!1,m.label=1;case 1:return m.trys.push([1,15,,16]),c=this.db.transaction([Ze,Tt],"readwrite"),c.done.catch(function(E){!s&&!u&&(Me(g.loggerProvider,"".concat(ze,": ").concat(E),E),g.recordFailure())}),l=$u(c.done,zu,function(){!s&&!u&&(u=!0,Me(g.loggerProvider,"".concat(ze,": transaction timed out")),g.recordFailure())}),[4,c.objectStore(Ze).get(o)];case 2:return f=m.sent(),f?.tabId&&f.tabId!==this.tabId?f.events.length>0?[4,c.objectStore(Tt).put({sessionId:o,events:f.events,tabId:f.tabId})]:[3,4]:[3,6];case 3:m.sent(),m.label=4;case 4:return[4,c.objectStore(Ze).put({sessionId:o,events:[a],tabId:this.tabId})];case 5:return m.sent(),this.recordSuccess(),l(),[2,void 0];case 6:return d=f,d?[3,8]:[4,c.objectStore(Ze).put({sessionId:o,events:[a],tabId:this.tabId})];case 7:return m.sent(),this.recordSuccess(),l(),[2,void 0];case 8:return this.shouldSplitEventsList(d.events,a)?[3,10]:[4,c.objectStore(Ze).put({sessionId:o,events:d.events.concat(a),tabId:this.tabId})];case 9:return m.sent(),this.recordSuccess(),l(),[2,void 0];case 10:return v=d.events,v.length!==0?[3,12]:(this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,c.objectStore(Ze).put({sessionId:o,events:[a],tabId:this.tabId})]);case 11:return m.sent(),this.recordSuccess(),l(),[2,void 0];case 12:return[4,c.objectStore(Ze).put({sessionId:o,events:[a],tabId:this.tabId})];case 13:return m.sent(),[4,c.objectStore(Tt).put({sessionId:o,events:v,tabId:this.tabId})];case 14:return p=m.sent(),this.recordSuccess(),l(),[2,{events:v,sessionId:o,sequenceId:p}];case 15:return h=m.sent(),u||(s=!0,Me(this.loggerProvider,"".concat(ze,": ").concat(h),h),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},n.storeSendingEvents=function(o,a){return y(n,void 0,void 0,function(){var s,u;return b(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,this.db.put(Tt,{sessionId:o,events:a,tabId:this.tabId})];case 1:return s=c.sent(),this.recordSuccess(),[2,s];case 2:return u=c.sent(),Me(this.loggerProvider,"".concat(ze,": ").concat(u),u),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(o,a){return y(n,void 0,void 0,function(){var s;return b(this,function(u){switch(u.label){case 0:if(!a)return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.db.delete(Tt,a)];case 2:return u.sent(),this.recordSuccess(),[3,4];case 3:return s=u.sent(),Me(this.loggerProvider,"".concat(ze,": ").concat(s),s),this.recordFailure(),[3,4];case 4:return[2]}})})},n.db=r.db,n.tabId=r.tabId,n.onPersistentFailure=r.onPersistentFailure,n.consecutiveFailureThreshold=(i=r.consecutiveFailureThreshold)!==null&&i!==void 0?i:1,n}return e.prototype.maybeLogEmptyFiltered=function(r){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(r," (idb store)"))},e.prototype.recordFailure=function(){var r;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,(r=this.onPersistentFailure)===null||r===void 0||r.call(this))},e.prototype.recordSuccess=function(){this.consecutiveFailures=0},e.new=function(r,n){var i;return y(this,void 0,void 0,function(){var o,a,s,u,c;return b(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),o=r==="replay"?"":"_".concat(r),a="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(o),[4,e_(a)];case 1:return s=l.sent(),u=(i=n.tabId)!==null&&i!==void 0?i:Y0(),[2,new e(T(T({},n),{db:s,tabId:u}))];case 2:return c=l.sent(),Me(n.loggerProvider,"".concat(ze,": ").concat(c),c),[3,3];case 3:return[2]}})})},e.prototype.getCurrentSequenceEvents=function(r){return y(this,void 0,void 0,function(){var a,s,u,n,i,o,a,s,u,c,l,f;return b(this,function(d){switch(d.label){case 0:return r?[4,this.db.get("sessionCurrentSequence",r)]:[3,2];case 1:return a=d.sent(),a?a.tabId&&a.tabId!==this.tabId?[2,void 0]:(s=a.tabId,u=nt(a,["tabId"]),[2,[u]]):[2,void 0];case 2:n=[],d.label=3;case 3:return d.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:i=C.apply(void 0,[d.sent()]),o=i.next(),d.label=5;case 5:if(o.done)return[3,7];if(a=o.value,a.tabId&&a.tabId!==this.tabId)return[3,6];s=a.tabId,u=nt(a,["tabId"]),n.push(u),d.label=6;case 6:return o=i.next(),[3,5];case 7:return[3,10];case 8:return c=d.sent(),l={error:c},[3,10];case 9:try{o&&!o.done&&(f=i.return)&&f.call(i)}finally{if(l)throw l.error}
11return[7];case 10:return[2,n]}})})},e})(ro);var bh=(function(t){Ae(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.finalizedSequences={},r.sequences={},r.sequenceId=0,r.emptyFilteredCount=0,r}return e.prototype.resetCurrentSequence=function(r){this.sequences[r]=[]},e.prototype.addSequence=function(r){var n=this.sequenceId++,i=F([],w(this.sequences[r]),!1);return this.finalizedSequences[n]={sessionId:r,events:i},this.resetCurrentSequence(r),{sequenceId:n,events:i,sessionId:r}},e.prototype.maybeLogEmptyFiltered=function(r){this.emptyFilteredCount++%100===0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(r," (in-memory store)"))},e.prototype.getSequencesToSend=function(){return y(this,void 0,void 0,function(){var r,n,i,o,a,s,u,c,l,f;return b(this,function(d){r=[];try{for(n=C(Object.entries(this.finalizedSequences)),i=n.next();!i.done;i=n.next()){if(o=w(i.value,2),a=o[0],s=o[1],u=s.sessionId,c=s.events,c.length===0){this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(a)];continue}r.push({sequenceId:Number(a),sessionId:u,events:c})}}catch(v){l={error:v}}finally{try{i&&!i.done&&(f=n.return)&&f.call(n)}finally{if(l)throw l.error}}return[2,r]})})},e.prototype.storeCurrentSequence=function(r){return y(this,void 0,void 0,function(){var n;return b(this,function(i){return n=this.sequences[r],n?n.length===0?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(r)]:[2,void 0]})})},e.prototype.addEventToCurrentSequence=function(r,n){return y(this,void 0,void 0,function(){var i;return b(this,function(o){return this.sequences[r]||this.resetCurrentSequence(r),this.shouldSplitEventsList(this.sequences[r],n)&&(this.sequences[r].length===0?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):i=this.addSequence(r)),this.sequences[r].push(n),[2,i]})})},e.prototype.storeSendingEvents=function(r,n){return y(this,void 0,void 0,function(){return b(this,function(i){return this.finalizedSequences[this.sequenceId]={sessionId:r,events:n},[2,this.sequenceId++]})})},e.prototype.cleanUpSessionEventsStore=function(r,n){return y(this,void 0,void 0,function(){return b(this,function(i){return n!==void 0&&delete this.finalizedSequences[n],[2]})})},e})(ro);var Yu=function(t){var e=t.config,r=t.minInterval,n=t.maxInterval,i=t.maxPersistedEventsSize,o=t.type,a=t.payloadBatcher,s=t.storeType,u=t.trackDestinationWorkerScript,c=t.shouldSend;return y(void 0,void 0,void 0,function(){function l(N){return N===void 0&&(N=!1),y(this,void 0,void 0,function(){return b(this,function(G){return[2,d.flush(N)]})})}var f,d,v,p,h,g,m,E,_,S,x,I,A,D,k,U,R,O,P;return b(this,function(N){switch(N.label){case 0:return f=(P=e.maxSingleEventSizeBytes)!==null&&P!==void 0?P:Yi,d=new Eh(T(T({},e),{loggerProvider:e.loggerProvider,payloadBatcher:a,workerScript:u})),v=function(){return new bh({loggerProvider:e.loggerProvider,maxInterval:n,minInterval:r,maxPersistedEventsSize:i})},h=!1,m=function(){return y(void 0,void 0,void 0,function(){var G,M,V;return b(this,function(X){switch(X.label){case 0:return h?(h=!1,e.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),p?[4,g.getSequencesToSend()]:[3,2]):[2];case 1:return M=X.sent(),[3,3];case 2:M=void 0,X.label=3;case 3:return G=M,g=v(),G&&p&&(V=p,G.forEach(function(H){A({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:V})})),[2]}})})},E=function(){return y(void 0,void 0,void 0,function(){var G;return b(this,function(M){switch(M.label){case 0:return[4,_h.new(o,{loggerProvider:e.loggerProvider,minInterval:r,maxInterval:n,maxPersistedEventsSize:i,apiKey:e.apiKey,onPersistentFailure:function(){m()}})];case 1:return G=M.sent(),G?(h=!0,[2,G]):(e.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,v()])}})})},s!=="idb"?[3,2]:[4,E()];case 1:return _=N.sent(),[3,3];case 2:_=v(),N.label=3;case 3:return g=_,S=[],x=0,I=function(G){if(!(G<=x)){var M=Math.min(G-x,S.length);M>0&&(S.splice(0,M),x=G)}},A=function(G){var M=G.events,V=G.sessionId,X=G.deviceId,H=G.sequenceId,Y=M.map(function(K){return{event:K,bytes:new Blob([K]).size}}
11),L=Y.filter(function(K){return K.bytes>f});L.length>0&&e.loggerProvider.warn("Dropping ".concat(L.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(L.map(function(K){return"".concat(Math.round(K.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 W=L.length>0?Y.filter(function(K){return K.bytes<=f}).map(function(K){return K.event}):M;if(W.length===0){g.cleanUpSessionEventsStore(V,H).catch(function(K){e.loggerProvider.warn("Failed to clean up session replay events store:",K)});return}e.debugMode&&Ji().then(function(K){var z=K.totalStorageSize,$=K.percentOfQuota,te=K.usageDetails;e.loggerProvider.debug("Total storage size: ".concat(z," KB, percentage of quota: ").concat($,"%, usage details: ").concat(te))}).catch(function(){}),d.sendEventsList({events:W,sessionId:V,flushMaxRetries:e.flushMaxRetries,apiKey:e.apiKey,deviceId:X,sampleRate:e.sampleRate,serverZone:e.serverZone,version:e.version,type:o,onComplete:function(){return y(void 0,void 0,void 0,function(){return b(this,function(K){switch(K.label){case 0:return[4,g.cleanUpSessionEventsStore(V,H)];case 1:return K.sent(),[2]}})})}})},D=function(G){var M=G.sessionId,V=G.deviceId;if(p=V,!(c&&!c())){var X=x+S.length;g.storeCurrentSequence(M).then(function(H){H&&(I(X),A({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:V}))}).catch(function(H){e.loggerProvider.warn("Failed to get current sequence of session replay events for session:",H)})}},k=function(G){var M=G.deviceId;return y(void 0,void 0,void 0,function(){var V;return b(this,function(X){switch(X.label){case 0:return p=M,[4,g.getSequencesToSend()];case 1:return V=X.sent(),V?.length?(e.loggerProvider.log("Draining ".concat(V.length," stored sequence(s) from previous session.")),V.length>1&&d.markCoalesceNextFlush(),V.forEach(function(H){A({sequenceId:H.sequenceId,events:H.events,sessionId:H.sessionId,deviceId:M})}),[2]):[2]}})})},U=function(G){var M=G.event,V=G.sessionId,X=G.deviceId;p=X;var H=!c||c(),Y=x+S.length;S.push(M.data),g.addEventToCurrentSequence(V,M.data).then(function(L){if(L){if(!H){g.cleanUpSessionEventsStore(L.sessionId,L.sequenceId).catch(function(W){e.loggerProvider.warn("Failed to clean up dropped session replay sequence:",W)}),I(Y);return}I(Y),A({sequenceId:L.sequenceId,events:L.events,sessionId:L.sessionId,deviceId:X})}}).catch(function(L){e.loggerProvider.warn("Failed to add event to session replay capture:",L)})},R=function(){return F([],w(S),!1)},O=function(){I(x+S.length)},[2,{sendCurrentSequenceEvents:D,addEvent:U,sendStoredEvents:k,flush:l,getBeaconEvents:R,dropPendingBeaconEvents:O,trackDestination:d}]}})})};var Qu=(function(){function t(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=new Map;e.forEach(function(i){n.set(i.name,i.manager)}),this.managers=n}return t.prototype.sendStoredEvents=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return r=[],this.managers.forEach(function(i){r.push(i.sendStoredEvents(e))}),[4,Promise.all(r)];case 1:return n.sent(),[2]}})})},t.prototype.addEvent=function(e){var r,n=e.sessionId,i=e.event,o=e.deviceId;(r=this.managers.get(i.type))===null||r===void 0||r.addEvent({sessionId:n,event:i,deviceId:o})},t.prototype.sendCurrentSequenceEvents=function(e){var r=e.sessionId,n=e.deviceId;this.managers.forEach(function(i){i.sendCurrentSequenceEvents({sessionId:r,deviceId:n})})},t.prototype.flush=function(e){return y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:return r=[],this.managers.forEach(function(i){r.push(i.flush(e))}),[4,Promise.all(r)];case 1:return n.sent(),[2]}})})},t})();var et,Zu,Ih;function xh(t,e){if(Ih=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";var r={root:document.body,idName:function(o){return!0},className:function(o){return!0},tagName:function(o){return!0},attr:function(o,a){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};et=T(T({},r),e),Zu=t_(et.root,r);var n=no(t,"all",function(){return no(t,"two",function(){return no(t,"one",function(){return no(t,"none")})})});if(n){var i=Rh(wh(n,t));return i.length>0&&(n=i[0]),ao(n)}else throw new Error("Selector was not found.")}function t_(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function no(t,e,r){for(var n=null,i=[],o=t,a=0,s=function(){var c,l,f=new Date().getTime()-Ih.getTime();if(et.timeoutMs!==void 0&&f>et.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(f,"ms"));var d=oo(r_(o))||oo.apply(void 0,F([],w(n_(o)),!1))||oo.apply(void 0,F([],w(i_(o)),!1))||oo(o_(o))||[Th()],v=a_(o);if(e=="all")v&&(d=d.concat(d.filter(Ju).map(function(E){return io(E,v)})));else if(e=="two")d=d.slice(0,1),v&&(d=d.concat(d.filter(Ju).map(function(E){return io(E,v)})));else if(e=="one"){var p=w(d=d.slice(0,1),1),h=p[0];v&&Ju(h)&&(d=[io(h,v)])}else e=="none"&&(d=[Th()],v&&(d=[io(d[0],v)]));try{for(var g=(c=void 0,C(d)),m=g.next();!m.done;m=g.next()){var h=m.value;h.level=a}}catch(E){c={error:E}}finally{try{m&&!m.done&&(l=g.return)&&l.call(g)}finally{if(c)throw c.error}}if(i.push(d),i.length>=et.seedMinLength&&(n=Sh(i,r),n))return"break";o=o.parentElement,a++};o;){var u=s();if(u==="break")break}return n||(n=Sh(i,r)),!n&&r?r():n}function Sh(t,e){var r,n,i=Rh(Ch(t));if(i.length>et.threshold)return e?e():null;try{for(var o=C(i),a=o.next();!a.done;a=o.next()){var s=a.value;if(Ah(s))return s}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return null}function ao(t){for(var e=t[0],r=e.name,n=1;n<t.length;n++){var i=t[n].level||0;e.level===i-1?r="".concat(t[n].name," > ").concat(r):r="".concat(t[n].name," ").concat(r),e=t[n]}return r}function yh(t){return t.map(function(e){return e.penalty}).reduce(function(e,r){return e+r},0)}function Ah(t){var e=ao(t);switch(Zu.querySelectorAll(e).length){case 0:throw new Error("Can't select any node with this selector: ".concat(e));case 1:return!0;default:return!1}}function r_(t){var e=t.getAttribute("id");return e&&et.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function n_(t){var e=Array.from(t.attributes).filter(function(r){return et.attr(r.name,r.value)});return e.map(function(r){return{name:"[".concat(CSS.escape(r.name),'="').concat(CSS.escape(r.value),'"]'),penalty:.5}})}function i_(t){var e=Array.from(t.classList).filter(et.className);return e.map(function(r){return{name:"."+CSS.escape(r),penalty:1}})}function o_(t){var e=t.tagName.toLowerCase();return et.tagName(e)?{name:e,penalty:2}:null}function Th(){return{name:"*",penalty:3}}function a_(t){var e=t.parentNode;if(!e)return null;var r=e.firstChild;if(!r)return null;for(var n=0;r&&(r.nodeType===Node.ELEMENT_NODE&&n++,r!==t);)r=r.nextSibling;return n}function io(t,e){return{name:t.name+":nth-child(".concat(e,")"),penalty:t.penalty+1}}function Ju(t){return t.name!=="html"&&!t.name.startsWith("#")}function oo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.filter(s_);return r.length>0?r:null}function s_(t){return t!=null}function Ch(t,e){var r,n,i,o,a,s;return e===void 0&&(e=[]),b(this,function(u){switch(u.label){case 0:if(!(t.length>0))return[3,9];u.label=1;case 1:u.trys.push([1,6,7,8]),r=C(t[0]),n=r.next(),u.label=2;case 2:return n.done?[3,5]:(i=n.value,[5,C(Ch(t.slice(1,t.length),e.concat(i)))]);case 3:u.sent(),u.label=4;case 4:return n=r.next(),[3,2];case 5:return[3,8];case 6:return o=u.sent(),a={error:o},[3,8];case 7:try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(a)throw a.error}
11return[7];case 8:return[3,11];case 9:return[4,e];case 10:u.sent(),u.label=11;case 11:return[2]}})}function Rh(t){return F([],w(t),!1).sort(function(e,r){return yh(e)-yh(r)})}function wh(t,e,r){var n,i,o;return r===void 0&&(r={counter:0,visited:new Map}),b(this,function(a){switch(a.label){case 0:if(!(t.length>2&&t.length>et.optimizedMinLength))return[3,5];n=1,a.label=1;case 1:return n<t.length-1?r.counter>et.maxNumberOfTries?[2]:(r.counter+=1,i=F([],w(t),!1),i.splice(n,1),o=ao(i),r.visited.has(o)?[2]:Ah(i)&&u_(i,e)?[4,i]:[3,4]):[3,5];case 2:return a.sent(),r.visited.set(o,!0),[5,C(wh(i,e,r))];case 3:a.sent(),a.label=4;case 4:return n++,[3,1];case 5:return[2]}})}function u_(t,e){return Zu.querySelector(ao(t))===e}var l_=36e5,Lh=function(t){var e=t.version,r=t.events,n=[];return r.forEach(function(i){var o=JSON.parse(i);o.count=1,o.type==="click"&&n.push(o)}),{version:e,events:n}},Ph=function(t){var e=t.version,r=t.events,n=[];r.forEach(function(o){var a=JSON.parse(o);a.type==="click"&&n.push(a)});var i=n.reduce(function(o,a){var s=a.x,u=a.y,c=a.selector,l=a.timestamp,f=l-l%l_,d="".concat(s,":").concat(u,":").concat(c??"",":").concat(f);return o[d]?o[d].count+=1:o[d]=T(T({},a),{timestamp:f,count:1}),o},{});return{version:e,events:Object.values(i)}},Dh=(function(){function t(e,r){var n=this;this.createHook=function(i){var o=i.eventsManager,a=i.sessionId,s=i.deviceIdFn,u=i.mirror,c=i.ugcFilterRules,l=i.performanceOptions;return function(f){if(f.type===qu.Click){var d=le();if(d){var v=d.location,p=d.innerHeight,h=d.innerWidth;if(v){var g=f.x,m=f.y;if(!(g===void 0||m===void 0)){var E=u.getNode(f.id),_;if(E)try{_=xh(E,l)}catch(A){n.logger.debug("error resolving selector from finder")}var S=Ot(v.href,c),x={x:g+n.scrollWatcher.currentScrollX,y:m+n.scrollWatcher.currentScrollY,selector:_,viewportHeight:p,viewportWidth:h,pageUrl:S,timestamp:Date.now(),type:"click"},I=s();I&&o.addEvent({sessionId:a,event:{type:"interaction",data:JSON.stringify(x)},deviceId:I})}}}}}},this.logger=e,this.scrollWatcher=r}return t})();function so(){var t=le();return t?.innerHeight||document.documentElement&&document.documentElement.clientHeight||0}function uo(){var t=le();return t?.innerWidth||document.documentElement&&document.documentElement.clientWidth||0}var Oh=(function(){function t(e,r){var n=le();n&&n.navigator&&typeof n.navigator.sendBeacon=="function"?this.sendBeacon=function(i,o){try{if(n.navigator.sendBeacon(i,JSON.stringify(o)))return!0}catch(a){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(i,o){var a=new XMLHttpRequest;return a.open("POST",i,!0),a.setRequestHeader("Accept","*/*"),a.send(JSON.stringify(o)),!0},this.basePageUrl=yt(r.serverZone,r.trackServerUrl),this.apiKey=r.apiKey,this.context=e,this.handleSendEvents=r.handleSendEvents,this.loggerProvider=r.loggerProvider}return t.prototype.send=function(e,r){var n=this,i,o=this.context,a=o.sessionId,s=o.type;if(this.handleSendEvents){var u=new URLSearchParams({device_id:e,session_id:String(a),type:String(s)}),c="".concat(this.basePageUrl,"?").concat(u.toString()),l={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(this.apiKey)};try{this.handleSendEvents({url:c,method:"POST",headers:l,body:JSON.stringify(r),keepalive:!0}).catch(function(v){var p;(p=n.loggerProvider)===null||p===void 0||p.warn("Custom transport failed to send session replay interaction beacon:",v)})}catch(v){(i=this.loggerProvider)===null||i===void 0||i.warn("Custom transport threw while sending session replay interaction beacon:",v)}return}var f=new URLSearchParams({device_id:e,session_id:String(a),type:String(s),api_key:this.apiKey}),d="".concat(this.basePageUrl,"?").concat(f.toString());this.sendBeacon(d,r)||this.sendXhr(d,r)},t})();var kh=(function(){function t(e,r){var n=this;this.timestamp=Date.now(),this.hook=function(i){n.update(i)},this.send=function(i){return function(o){var a,s,u,c,l=i(),f=le();if(f&&l){var d=(a=f.scrollX)!==null&&a!==void 0?a:0,v=(s=f.scrollY)!==null&&s!==void 0?s:0;(d>0||v>0)&&n.update({id:1,x:d,y:v}),n.transport.send(l,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHe
11ight:so(),viewportWidth:uo(),pageUrl:Ot(f.location.href,(c=(u=n.config.interactionConfig)===null||u===void 0?void 0:u.ugcFilterRules)!==null&&c!==void 0?c:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=uo(),this._maxScrollHeight=so(),this.config=r,this.transport=e}return t.default=function(e,r){return new t(new Oh(e,r),r)},Object.defineProperty(t.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),t.prototype.update=function(e){var r=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=uo();this._maxScrollX=e.x;var i=e.x+n;i>this._maxScrollWidth&&(this._maxScrollWidth=i),this.timestamp=r}if(e.y>this._maxScrollY){var o=so();this._maxScrollY=e.y;var a=e.y+o;a>this._maxScrollHeight&&(this._maxScrollHeight=a),this.timestamp=r}},t})();var el=(function(){function t(e){var r=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=r,r&&n&&(this.sessionReplayId=nh(r,n))}return t})();var c_="AMP_SR_START_",d_=10,Nh=1440*60*1e3,Uh=function(t){return"".concat(c_).concat(t.substring(0,d_),"_")},tl=function(t,e){return"".concat(Uh(t)).concat(e)},lo=function(){try{var t=le();return t?.localStorage}catch(e){return}},Mh=function(t,e,r,n){var i=lo();if(i){var o=tl(t,e);try{var a=i.getItem(o);if(a!==null){var s=Number(a);if(Number.isFinite(s)&&s>0&&s<=r&&r-s<Nh)return s}return i.setItem(o,String(r)),r}catch(u){n?.debug("Failed to read/write replay start time from storage: ".concat(String(u)));return}}},Fh=function(t,e,r,n){var i=lo();if(i)try{i.setItem(tl(t,e),String(r))}catch(o){n?.debug("Failed to write replay start time to storage: ".concat(String(o)))}},Gh=function(t,e,r){var n=lo();if(n)try{n.removeItem(tl(t,e))}catch(i){r?.debug("Failed to remove replay start time from storage: ".concat(String(i)))}},Bh=function(t,e,r){var n,i,o=lo();if(o){var a=Uh(t);try{for(var s=[],u=0;u<o.length;u++){var c=o.key(u);if(!(!c||!c.startsWith(a))){var l=o.getItem(c);if(l!==null){var f=Number(l);(!Number.isFinite(f)||f<=0||e-f>=Nh)&&s.push(c)}}}try{for(var d=C(s),v=d.next();!v.done;v=d.next()){var c=v.value;o.removeItem(c)}}catch(p){n={error:p}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}catch(p){r?.debug("Failed to prune stale replay start times: ".concat(String(p)))}}};var f_=1e3*60*60*24*2,v_=(function(){function t(){var e=this;this.dbs={},this.createStore=function(r){return y(e,void 0,void 0,function(){return b(this,function(n){switch(n.label){case 0:return[4,Dn(r,1,{upgrade:function(i){i.objectStoreNames.contains("sessionTargetingMatch")||i.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,n.sent()]}})})},this.openOrCreateDB=function(r){return y(e,void 0,void 0,function(){var n,i;return b(this,function(o){switch(o.label){case 0:return this.dbs&&this.dbs[r]?[2,this.dbs[r]]:(n="".concat(r.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(n)]);case 1:return i=o.sent(),this.dbs[r]=i,[2,i]}})})},this.getTargetingMatchForSession=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.sessionId;return y(e,void 0,void 0,function(){var a,s,u,c;return b(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return a=l.sent(),s=String(o),[4,a.get("sessionTargetingMatch",s)];case 2:return u=l.sent(),[2,u?.targetingMatch];case 3:return c=l.sent(),Me(n,"Failed to get targeting match for session id ".concat(o,": ").concat(c),c),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.sessionId,a=r.targetingMatch;return y(e,void 0,void 0,function(){var s,u,c,l;return b(this,function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),[4,this.openOrCreateDB(i)];case 1:return s=f.sent(),u=String(o),[4,s.put("sessionTargetingMatch",{targetingMatch:a,sessionId:u,lastUpdated:Date.now()})];case 2:return c=f.sent(),[2,c];case 3:return l=f.sent(),Me(n,"Failed to store targeting match for session id ".concat(o,": ").concat(l),l),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(r){var n=r.loggerProvider,i=r.apiKey,o=r.currentSessionId;return y(e,void 0,void 0,function(){var a,s,u,c,l,f,d,v;return b(this,function(p){switch(p.label){case 0:return p.trys.push([0,8,,9]),[4,this.openOrCreateDB(i)];case 1:return a=p.sent(),s=String(o),u=a.transaction("sessionTargetingMatch","readwrite"),[4,u.store.getAll()];case 2:c=p.sent(),l=0,p.label=3;case 3:return l<c.length?(f=c[l],d=Date.now()-f.lastUpdated,f.sessionId!==s&&d>f_?[4,u.store.delete(f.sessionId)]:[3,5]):[3,6];case 4:p.sent(),p.label=5;case 5:return l++,[3,3];case 6:return[4,u.done];case 7:return p.sent(),[3,9];case 8:return v=p.sent(),Me(n,"Failed to clear old targeting matches for sessions: ".concat(v),v),[3,9];case 9:return[2]}})})}}return t})();var co=new v_;var Vh=function(t){var e=t.sessionId,r=t.targetingConfig,n=t.loggerProvider,i=t.apiKey,o=t.targetingParams,a=t.urlChange,s=a===void 0?!1:a;return y(void 0,void 0,void 0,function(){var u,c,l,f,d,v,p;return b(this,function(h){switch(h.label){case 0:return[4,co.clearStoreOfOldSessions({loggerProvider:n,apiKey:i,currentSessionId:e})];case 1:return h.sent(),[4,co.getTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e})];case 2:if(u=h.sent(),u===!0&&!s)return[2,!0];c=!0,h.label=3;case 3:return h.trys.push([3,6,,7]),[4,import("./chunk-BG5FAXSG.js")];case 4:return l=h.sent().evaluateTargeting,f=T(T({},o),{flag:r,sessionId:typeof e=="string"?parseInt(e,10):e,apiKey:i,loggerProvider:n}),[4,l(f)];case 5:return d=h.sent(),d&&d.sr_targeting_config&&(c=d.sr_targeting_config.key==="on"),co.storeTargetingMatchForSession({loggerProvider:n,apiKey:i,sessionId:e,targetingMatch:c}),[3,7];case 6:return v=h.sent(),p=v,n.warn(p.message),[3,7];case 7:return[2,c]}})})};var vo=2654435761,po=2246822519,Kh=3266489917,p_=668265263,Hh=374761393;function $t(t,e){return(t<<e|t>>>32-e)>>>0}function fo(t,e){return t=t+Math.imul(e,po)>>>0,t=$t(t,13),t=Math.imul(t,vo)>>>0,t}function Sn(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function h_(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);if(n>=55296&&n<=56319&&r+1<t.length){var i=t.charCodeAt(r+1);i>=56320&&i<=57343&&(n=(n-55296<<10)+(i-56320)+65536,r++)}n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<65536?e.push(224|n>>12,128|n>>6&63,128|n&63):e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63)}return new Uint8Array(e)}function g_(t,e){e===void 0&&(e=0);var r=h_(t),n=r.length,i,o=0;if(n>=16){for(var a=e+vo+po>>>0,s=e+po>>>0,u=e>>>0,c=e-vo>>>0;o<=n-16;)a=fo(a,Sn(r,o)),o+=4,s=fo(s,Sn(r,o)),o+=4,u=fo(u,Sn(r,o)),o+=4,c=fo(c,Sn(r,o)),o+=4;i=$t(a,1)+$t(s,7)+$t(u,12)+$t(c,18)>>>0}else i=e+Hh>>>0;for(i=i+n>>>0;o<=n-4;)i=i+Math.imul(Sn(r,o),Kh)>>>0,i=Math.imul($t(i,17),p_)>>>0,o+=4;for(;o<n;)i=i+Math.imul(r[o],Hh)>>>0,i=Math.imul($t(i,11),vo)>>>0,o++;return i^=i>>>15,i=Math.imul(i,po)>>>0,i^=i>>>13,i=Math.imul(i,Kh)>>>0,i^=i>>>16,i>>>0}function Wh(t,e){var r=g_(t.toString()),n=r%1e6;return n/1e6<e}var rl="__amplitude_url_tracking_patched__",qh=new WeakMap;function nl(t,e,r){if(r===void 0&&(r={}),!t?.location)return function(){};var n=r.enablePolling,i=n===void 0?!1:n,o=r.pollingInterval,a=o===void 0?pn:o;if(i){var s=function(){var S;return(S=t.location.href)!==null&&S!==void 0?S:""},u=s(),c=t.setInterval(function(){var S=s();S!==u&&(u=S,e(S))},a);return function(){c!=null&&t.clearInterval(c)}}var l=qh.get(t);if(!l){var f=void 0,d=new Set,v=function(){var S;return(S=t.location.href)!==null&&S!==void 0?S:""},p=function(){var S=v();f!==void 0&&S===f||(f=S,d.forEach(function(x){return x(S)}))},h=function(S){var x=function(){for(var I=[],A=0;A<arguments.length;A++)I[A]=arguments[A];var D=S.apply(this,I);return p(),D};return x[rl]=!0,x},g=t.history;if(g?.pushState){var m=Reflect.get(g,"pushState");m[rl]||(g.pushState=h(m))}if(g?.replaceState){var E=Reflect.get(g,"replaceState");E[rl]||(g.replaceState=h(E))}l={callbacks:d,notify:p,onPopStateOrHashChange:function(){return p()},listenersAttached:!1},qh.set(t,l)}var _=l;return _.listenersAttached||(t.addEventListener("popstate",_.onPopStateOrHashChange),t.addEventListener("hashchange",_.onPopStateOrHashChange),_.listenersAttached=!0),_.callbacks.add(e),function(){_.callbacks.delete(e),_.callbacks.size===0&&_.listenersAttached&&(t.removeEventListener("popstate",_.onPopStateOrHashChange),t.removeEventListener("hashchange",_.onPopStateOrHashChange),_.listenersAttached=!1)}}function il(t){return t===void 0&&(t={}),{name:"amplitude/url-tracking@1",observer:function(e,r,n){var i,o,a,s=T(T({},t),n),u=s.ugcFilterRules||[],c=(i=s.enablePolling)!==null&&i!==void 0?i:!1,l=(o=s.pollingInterval)!==null&&o!==void 0?o:pn,f=(a=s.captureDocumentTitle)!==null&&a!==void 0?a:!1;if(!r)return function(){};var d=void 0,v=function(){return r.location&&r.location.href||""}
11,p=function(){var m=r.innerHeight,E=r.innerWidth,_=r.document,S=v(),x="";f&&(x=_?.title||"");var I=u.length>0?Ot(S,u):S;return{href:I,title:x,viewportHeight:m,viewportWidth:E,type:"url-change-event"}},h=function(){var m=v();if(d===void 0||m!==d){d=m;var E=p();e(E)}},g=nl(r,function(){return h()},c?{enablePolling:!0,pollingInterval:l}:{});return h(),function(){return g()}},options:t}}var Lk=il();function Xh(){try{var t=le();return t?t.parent!==t:!1}catch(e){return!0}}var jh=(function(){function t(){this.pendingLoadListeners=new Map}return t.prototype.start=function(){var e=this,r;(r=this.mutationObserver)===null||r===void 0||r.disconnect();var n=le();n&&(this.sendToAllIframes({type:En,action:"start"}),this.mutationObserver=new MutationObserver(function(i){var o,a,s,u,c,l;try{for(var f=C(i),d=f.next();!d.done;d=f.next()){var v=d.value;try{for(var p=(s=void 0,C(Array.from(v.addedNodes))),h=p.next();!h.done;h=p.next()){var g=h.value;g instanceof HTMLIFrameElement?e.sendToIframeAfterLoad(g):g instanceof Element&&g.querySelectorAll("iframe").forEach(function(S){e.sendToIframeAfterLoad(S)})}}catch(S){s={error:S}}finally{try{h&&!h.done&&(u=p.return)&&u.call(p)}finally{if(s)throw s.error}}try{for(var m=(c=void 0,C(Array.from(v.removedNodes))),E=m.next();!E.done;E=m.next()){var g=E.value;if(g instanceof HTMLIFrameElement){var _=e.pendingLoadListeners.get(g);_&&(g.removeEventListener("load",_),e.pendingLoadListeners.delete(g))}}}catch(S){c={error:S}}finally{try{E&&!E.done&&(l=m.return)&&l.call(m)}finally{if(c)throw c.error}}}}catch(S){o={error:S}}finally{try{d&&!d.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},t.prototype.stop=function(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(r,n){n.removeEventListener("load",r)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:En,action:"stop"})},t.prototype.sendToIframeAfterLoad=function(e){var r=this,n=function(){r.pendingLoadListeners.delete(e),r.sendToIframe(e,{type:En,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},t.prototype.sendToAllIframes=function(e){var r=this,n=document.querySelectorAll("iframe");n.forEach(function(i){return r.sendToIframe(i,e)})},t.prototype.sendToIframe=function(e,r){var n;try{(n=e.contentWindow)===null||n===void 0||n.postMessage(r,"*")}catch(i){}},t})();function zh(t){var e=le();if(!e)return function(){};var r=e.parent;function n(i){if(i.source===r){var o=i.data;o?.type===En&&(o.action==="start"?t.onStart():o.action==="stop"&&t.onStop())}}return e.addEventListener("message",n),function(){return e.removeEventListener("message",n)}}var $h=(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.recordingEnabled=!0,this.recordingGeneration=0,this.startChildRecordingOnSetup=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeCoordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(r){var n=le();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!r&&n.addEventListener("blur",e.blurListener),!r&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!r&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!r&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){var r;if(e.recordingEnabled)if(e.recordCancelCallback&&e.recordFunction){if(((r=e.config)===null||r===void 0?void 0:r.captureFullSnapshotOnFocus)===!1)return;try{e.recordFunction.takeFullSnapshot(!0)}catch(n){e.loggerProvider.warn("Failed to take full snapshot on focus:",n)}}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(r){var n;(n=e.eventCompressor)===null||n===void 0||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(i){i(r)})},this.evaluateTargetingAndCapture=function(r,n,i,o){return n===void 0&&(n=!1),i===void 0&&(i=!1),o===void 0&&(o=!1),y(e,void 0,void 0,function(){var a,s,u,c,l,f,d,v,p,h,g,m,E;return b(this,function(_){switch(_.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig)if(n)this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");else return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];return this.lastTargetingParams=r,a=this.config.targetingConfig,s=a&&
11!this.sessionTargetingMatch,s?(u=o?this.latestUrlChangeTargetingEvaluationId:void 0,c=r.event,c&&Object.values(Ul).includes(c.event_type)&&(c=void 0),l=(m=(p=(v=r.page)===null||v===void 0?void 0:v.url)!==null&&p!==void 0?p:(g=(h=le())===null||h===void 0?void 0:h.location)===null||g===void 0?void 0:g.href)!==null&&m!==void 0?m:"",f=(E=r.page)!==null&&E!==void 0?E:l!==""?{url:l}:void 0,[4,Vh({sessionId:this.identifiers.sessionId,targetingConfig:a,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:r.userProperties,event:c,page:f},urlChange:o})]):[3,2];case 1:if(d=_.sent(),o&&u!==void 0&&u!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(u,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||d,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:c,targetingParams:r},null,2)),_.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return i||!this.recordCancelCallback?(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]):[3,5];case 4:_.sent(),_.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(r,n,i){return n===void 0&&(n={}),i===void 0&&(i=!0),y(e,void 0,void 0,function(){var o,a,s,u;return b(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),o=void 0,a=this.config,a&&r!==St.METADATA?(o={config:Zi(a),version:mr},i?[4,Ji()]:[3,2]):[3,2];case 1:s=c.sent(),o=T(T({},s),o),c.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(r,T(T({},n),o)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(r," due to no ongoing recording.")),[3,4];case 3:return u=c.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",u),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var r,n,i;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,(r=e.networkObservers)===null||r===void 0||r.stop(),(n=e.crossOriginIframeCoordinator)===null||n===void 0||n.stop(),e.crossOriginIframeCoordinator=null,(i=e.crossOriginParentSignalCleanup)===null||i===void 0||i.call(e),e.crossOriginParentSignalCleanup=null}catch(a){var o=a;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(o.toString()))}},this.loggerProvider=new _n(new Cr)}return t.prototype.init=function(e,r){return Pn(this._init(e,r))},t.prototype.setupUrlChangeListener=function(){var e=this,r,n;(r=this.urlChangeCleanup)===null||r===void 0||r.call(this);var i=le();if(i?.location){var o=!!(!((n=this.config)===null||n===void 0)&&n.targetingConfig),a=function(u){if(e.currentPageUrl=u,o){var c=++e.latestUrlChangeTargetingEvaluationId;e.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:u}},!1,!1,!0),e.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(c," for ").concat(u,"."))}},s=nl(i,a);this.urlChangeCleanup=function(){s(),e.urlChangeCleanup=null}}},t.prototype.isBelowMinSessionDuration=function(){var e,r=(e=this.config)===null||e===void 0?void 0:e.minSessionDurationMs;return r===void 0||this.sessionStartTime===void 0?!1:Date.now()-this.sessionStartTime<r},t.prototype.getCurrentPageForTargeting=function(){var e,r,n=(r=(e=le())===null||e===void 0?void 0:e.location)===null||r===void 0?void 0:r.href;return n!=null?{url:n}:void 0},t.prototype._init=function(e,r){var n,i,o,a,s,u,c,l,f,d,v,p,h,g;return y(this,void 0,void 0,function(){var m,E,_,S,x,I,A,D,k,U,R,O,P,N,G,M,V,L,X,H,Y,L,W,K,z,$,te,Q,ae,ne,B,ge,ce,ue=this;return b(this,function(j){switch(j.label){case 0:return(n=this.urlChangeCleanup)===null||n===void 0||n.call(this),this.recordingEnabled=!0,this.startChildRecordingOnSetup=!1,this.loggerProvider=new _n(r.loggerProvider||new Cr),Object.prototype.hasOwnProperty.call(r,"logLevel")&&this.loggerProvider.enable(r.logLevel),this.currentPageUrl=bn(),this.identifiers=new el({sessionId:r.sessionId,deviceId:r.deviceId}),m=Date.now(),Bh(e,m,this.loggerProvider),this.sessionStartTime=r.sessionId!==void 0&&(i=Mh(e,r.sessionId,m,this.loggerProvider))!==null&&i!==void 0?i:m,E=this,[4,lh(e,r)];case 1:return E.joinedConfigGenerator=j.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return _=j.sent(),S=_.joinedConfig,x=_.localConfig,I=_.remoteConfig,this.config=S,this.setMetadata(r.sessionId,S,x,I,(o=r.version)===null||o===void 0?void 0:o.version,mr,(a=r.version)===null||a===void 0?void 0:a.type),this.pageLeaveFns=[],r.sessionId&&(!((s=this.config.interactionConfig)===null||s===void 0)&&s.enabled)&&(A=kh.default({sessionId:r.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[A.send(this.getDeviceId.bind(this)).bind(A)],this.scrollHook=A.hook.bind(A),this.clickHandler=new Dh(this.loggerProvider,A)),D=[],k=this.config.storeType,k==="idb"&&!(!((u=le())===null||u===void 0)&&u.indexedDB)&&(k="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(k," for event storage.")),O=le(),this.config.useWebWorker&&O&&O.Worker?[4,import("./chunk-UVCIO5OP.js")]:[3,4];case 3:P=j.sent(),N=P.compressionScript,G=P.trackDestinationScript,U=N,R=G,j.label=4;case 4:return j.trys.push([4,6,,7]),[4,Yu({config:this.config,type:"replay",minInterval:(c=this.config.flushIntervalConfig)===null||c===void 0?void 0:c.minIntervalMs,maxInterval:(l=this.config.flushIntervalConfig)===null||l===void 0?void 0:l.maxIntervalMs,maxPer
11sistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:k,trackDestinationWorkerScript:R,shouldSend:function(){return!ue.isBelowMinSessionDuration()}})];case 5:return M=j.sent(),this.rrwebEventManager=M,D.push({name:"replay",manager:M}),[3,7];case 6:return V=j.sent(),L=V,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(L.toString())),[3,7];case 7:if(!(!((f=this.config.interactionConfig)===null||f===void 0)&&f.enabled))return[3,11];X=this.config.interactionConfig.batch?Ph:Lh,j.label=8;case 8:return j.trys.push([8,10,,11]),[4,Yu({config:this.config,type:"interaction",minInterval:(d=this.config.interactionConfig.trackEveryNms)!==null&&d!==void 0?d:Vp,maxInterval:Kp,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:X,storeType:k,trackDestinationWorkerScript:R})];case 9:return H=j.sent(),D.push({name:"interaction",manager:H}),[3,11];case 10:return Y=j.sent(),L=Y,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(L.toString())),[3,11];case 11:if(this.eventsManager=new(Qu.bind.apply(Qu,F([void 0],w(D),!1))),this.eventCompressor&&this.eventCompressor.terminate(),W=this.config.eagerFullSnapshotSend===!0?function(){return ue.sendEvents()}:void 0,this.eventCompressor=new fh(this.eventsManager,this.config,this.getDeviceId(),U,W),this.pendingEmitEvents.length>0){K=this.pendingEmitEvents.splice(0);try{for(z=C(K),$=z.next();!$.done;$=z.next())te=$.value,Q=te.event,ae=te.sessionId,this.eventCompressor.enqueueEvent(Q,ae)}catch(Le){ge={error:Le}}finally{try{$&&!$.done&&(ce=z.return)&&ce.call(z)}finally{if(ge)throw ge.error}}}return this.pageLeaveFns=F(F([],w(this.pageLeaveFns),!1),[function(){var Le;if(!(!ue.config||!(!((Le=ue.identifiers)===null||Le===void 0)&&Le.sessionId)||!M)){var Ne=M.getBeaconEvents();if(Ne.length){var Ge=ue.getDeviceId();Ge&&(ue.isBelowMinSessionDuration()||M.trackDestination.sendBeacon({events:Ne,sessionId:ue.identifiers.sessionId,deviceId:Ge,apiKey:ue.config.apiKey,serverZone:ue.config.serverZone}))}}}],!1),[4,this.initializeNetworkObservers()];case 12:return j.sent(),!((v=le())===null||v===void 0)&&v.opener&&(ne=Xl(),jl(ne),ne.setup(T({logger:this.loggerProvider},this.config.serverZone&&{endpoint:ql[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 j.sent(),B=this.config.targetingConfig||((g=(h=(p=this.config.privacyConfig)===null||p===void 0?void 0:p.urlMaskLevels)===null||h===void 0?void 0:h.length)!==null&&g!==void 0?g:0)>0,B&&this.setupUrlChangeListener(),[2]}})})},t.prototype.setSessionId=function(e,r){return Pn(this.asyncSetSessionId(e,r))},t.prototype.asyncSetSessionId=function(e,r,n){var i,o,a,s;return y(this,void 0,void 0,function(){var u,c,l,f,d;return b(this,function(v){switch(v.label){case 0:return u=(i=this.identifiers)===null||i===void 0?void 0:i.sessionId,c=this.getDeviceId(),u!==void 0&&u===e&&(r===void 0||r===c)&&(n?.userProperties===void 0||Object.keys(n.userProperties).length===0)?[2]:(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,u&&this.sendEvents(u),l=u!==e,l&&((o=this.rrwebEventManager)===null||o===void 0||o.dropPendingBeaconEvents()),f=r||this.getDeviceId(),this.identifiers=new el({sessionId:e,deviceId:f}),l&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,!((a=this.config)===null||a===void 0)&&a.apiKey&&(Fh(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),u!==void 0&&Gh(this.config.apiKey,u,this.loggerProvider))),this.joinedConfigGenerator&&u?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2]);case 1:d=v.sent().joinedConfig,this.config=d,v.label=2;case 2:return!((s=this.config)===null||s===void 0)&&s.targetingConfig?[4,this.evaluateTargetingAndCapture({userProperties:n?.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return v.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:v.sent(),v.label=6;case 6:return[2]}})})},t.prototype.getSessionReplayProperties=function(){var e,r=this.config,n=this.identifiers;if(!r||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var i=this.getShouldRecord(),o={};return i&&(o=(e={},e[Op]=n.sessionReplayId?n.sessionReplayId:null,e),r.debugMode&&(o[Mp]=JSON.stringify({appHash:ko(r.apiKey).toString()}))),this.addCustomRRWebEvent(St.GET_SR_PROPS,{shouldRecord:i,eventProperties:o},this.eventCount===10),this.eventCount===10&&(this.eventCount=0),this.eventCount++,o},t.prototype.sendEvents=function(e){var r,n,i=e||((r=this.identifiers)===null||r===void 0?void 0:r.sessionId),o=this.getDeviceId();if(this.eventsManager&&i&&o){if(this.isBelowMinSessionDuration()){var a=this.sessionStartTime,s=this.config.minSessionDurationMs;this.loggerProvider.log("Session ".concat(i," not sent: duration ").concat(Date.now()-a,"ms is below minimum ").concat(s,"ms.")),this.suppressedSendCount++;return}if(!this.hasEmittedGateDecision&&((n=this.config)===null||n===void 0?void 0:n.minSessionDurationMs)!==void 0&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var u=this.sessionStartTime!==void 0?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent(St.REPLAY_GATE_DECISION,{sessionId:i,suppressedSendCount:this.suppressedSendCount,elapsedMs:u,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:i,deviceId:o})}},t.prototype.initialize=function(e){var r;return e===void 0&&(e=!1),y(this,void 0,void 0,function(){var n;return b(this,function(i){return!((r=this.identifiers)===null||r===void 0)&&r.sessionId?(n=this.getDeviceId(),n?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()])):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},t.prototype.shouldOptOut=function(){var e,r,n;if(!((e=this.config)===null||e===void 0)&&e.instanceName){var i=Bl(this.config.instanceName).identityStore;n=i.getIdentity().optOut}return n!==void 0?n:(r=this.config)===null||r===void 0?void 0:r.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.recordingEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured because recording was stopped.")),!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=!1,r="",n=!1;if(this.config.targetingConfig)this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),e=!0,n=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),e=!1,n=!1);else{var i=Wh(this.identifiers.sessionId,this.config.sampleRate);i?(e=!0,n=!0):(r="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(r),e=!1,n=!1)}return this.lastShouldRecordDecision!==e&&this.config.targetingConfig&&(this.addCustomRRWebEvent(St.TARGETING_DECISION,{message:r,sessionId:this.identifiers.sessionId,matched:n,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=e),e},t.prototype.getBlockSelectors=function(){var e,r,n,i=(n=(r=(e=this.config)===null||e===void 0?void 0:e.privacyConfig)===null||r===void 0?void 0:r.blockSelector)!==null&&n!==void 0?n:[];if(i.length!==0)return i},t.prototype.getMaskTextSelectors=function(){var e,r,n=(e=this.config)===null||e===void 0?void 0:e.privacyConfig,i=n?Ku(this.currentPageUrl,n):void 0;if(i==="conservative"||!((r=n?.urlMaskLevels)===null||r===void 0)&&r.some(function(s){return s.maskLevel==="conservative"}))return"*";var o=n?.urlMaskLevels;if(n?.defaultMaskLevel==="conservative"&&o&&o.length>0)return"*";var a=n?.maskSelector;if(a)return a},t.prototype.getRecordingPlugins=function(e){var r,n,i,o,a,s;return y(this,void 0,void 0,function(){var u,c,l,f;return b(this,function(d){switch(d.label){case 0:u=[];try{c=il({ugcFilterRules:((n=(r=this.config)===null||r===void 0?void 0:r.interactionConfig)===null||n===void 0?void 0:n.ugcFilterRules)||[],enablePolling:((i=this.config)===null||i===void 0?void 0:i.enableUrlChangePolling)||!1,pollingInterval:(o=this.config)===null||o===void 0?void 0:o.urlChangePollingInterval,captureDocumentTitle:(a=this.config)===null||a===void 0?void 0:a.captureDocumentTitle}),u.push(c)}catch(v){this.loggerProvider.warn("Failed to create URL tracking plugin:",v)}if(!(!((s=e?.console)===null||s===void 0)&&s.enabled))return[3,4];d.label=1;case 1:return d.trys.push([1,3,,4]),[4,import("./chunk-E4UZGJ5Q.js")];case 2:return l=d.sent().getRecordConsolePlugin,u.push(l({level:e.console.levels})),[3,4];case 3:return f=d.sent(),this.loggerProvider.warn("Failed to load console plugin:",f),[3,4];case 4:return[2,u.length>0?u:void 0]}})})},t.prototype.getRecordFunction=function(){return y(this,void 0,void 0,function(){var e,r;return b(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,import("./chunk-LGNGPFMW.js")];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];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 e===void 0&&(e=!0),y(this,void 0,void 0,function(){var r;return b(this,function(n){switch(n.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,n.label=1;case 1:return n.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:n.sent(),n.label=3;case 3:return this.recordEventsPendingShouldLogMetadata===null?[3,5]:(r=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(r)]);case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},t.prototype.shouldAbandonRecordStart=function(e){return!this.recordingEnabled||e!==this.recordingGeneration},t.prototype._recordEvents=function(e){var r,n,i,o,a,s,u,c;return e===void 0&&(e=!0),y(this,void 0,void 0,function(){var l,f,d,v,p,h,g,m,E,_,S,x,I,A,D,k,U,R=this;return b(this,function(O){switch(O.label){case 0:return l=this.config,f=this.getShouldRecord(),d=(r=this.identifiers)===null||r===void 0?void 0:r.sessionId,!f||!d||!l?[2]:(this.stopRecordingEvents(),v=this.recordingGeneration,[4,this.getRecordFunction()]);case 1:return p=O.sent(),!p||this.shouldAbandonRecordStart(v)?[2]:[4,this.initializeNetworkObservers()];case 2:if(O.sent(),this.shouldAbandonRecordStart(v))return[2];h=(n=l.loggingConfig)===null||n===void 0?void 0:n.network,g=yt(l.serverZone,l.trackServerUrl),m=[ji,zi,$i,g],(i=this.networkObservers)===null||i===void 0||i.start(function(P){m.some(function(N){return P.url.startsWith(N)})||R.addCustomRRWebEvent(St.FETCH_REQUEST,P)},h),E=l.interactionConfig,_=l.loggingConfig,S=E?.enabled?{mouseInteraction:this.eventsManager&&((o=this.clickHandler)===null||o===void 0?void 0:o.createHook({eventsManager:this.eventsManager,sessionId:d,deviceIdFn:this.getDeviceId.bind(this),mirror:p.mirror,ugcFilterRules:(a=E.ugcFilterRules)!==null&&a!==void 0?a:[],performanceOptions:(s=l.performanceConfig)===null||s===void 0?void 0:s.interaction})),scroll:this.scrollHook}:{},x=E?.enabled&&E.ugcFilterRules?E.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(d,".")),O.label=3;case 3:return O.trys.push([3,5,,6]),I=!!(!((u=l.crossOriginIframes)===null||u===void 0)&&u.enabled),A=((c=l.crossOriginIframes)===null||c===void 0?void 0:c.coordinateChildren)!==!1,D=I&&Xh(),D&&A?(this.crossOriginParentSignalCleanup=zh({onStart:function(){R.recordingEnabled&&R._recordEventsInChildMode(p,d,l,S)},onStop:function(){try{R.recordCancelCallback&&R.recordCancelCallback(),R.recordCancelCallback=null}catch(N){var P=N;R.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(P.toString()))}}}),this.startChildRecordingOnSetup&&(this.startChildRecordingOnSetup=!1,this._recordEventsInChildMode(p,d,l,S)),[2]):(this.startChildRecordingOnSetup=!1,[4,this.getRecordingPlugins(_)]);case 4:return k=O.sent(),this.shouldAbandonRecordStart(v)?[2]:(this.recordCancelCallback=p(T(T({},this.buildRRWebRecordOptions(l,S,function(P){if(R.shouldOptOut()||!R.recordingEnabled){R.loggerProvider.log(R.shouldOptOut()?"Opting session ".concat(d," out of recording due to optOut config."):"Session Replay capture stopping for ".concat(d,".")),R.stopRecordingEvents(),R.sendEvents();return}P.type===zt.Meta&&(P.data.href=Ot(P.data.href,x)),R.eventCompressor?R.eventCompressor.enqueueEvent(P,d):R.pendingEmitEvents.push({event:P,sessionId:d})},"Error while capturing replay: ")),{plugins:k,recordCrossOriginIframes:I}
11)),I&&!D&&A&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new jh),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(St.DEBUG_INFO),e&&this.addCustomRRWebEvent(St.METADATA,this.metadata),[3,6]);case 5:return U=O.sent(),this.loggerProvider.warn("Failed to initialize session replay:",U),[3,6];case 6:return[2]}})})},t.prototype.buildRRWebRecordOptions=function(e,r,n,i){var o=this,a=e.privacyConfig;return T(T({emit:n,inlineStylesheet:e.shouldInlineStylesheet,inlineImages:e.inlineImages,hooks:r,maskAllInputs:!0,maskTextClass:qi,blockClass:Fp,blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:Hu("input",a,function(){return o.currentPageUrl}),maskTextFn:Hu("text",a,function(){return o.currentPageUrl}),maskAttributeFn:rh(a,function(){return o.currentPageUrl}),maskTextSelector:this.getMaskTextSelectors()},e.fullSnapshotIntervalMs!==void 0&&{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(s){var u=s;if(u.message.includes("insertRule")&&u.message.includes("CSSStyleSheet")||u._external_)throw u;return o.loggerProvider.warn(i,u.toString()),!0}})},t.prototype._recordEventsInChildMode=function(e,r,n,i){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e(T(T({},this.buildRRWebRecordOptions(n,i,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(r,"."))}catch(o){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",o)}},t.prototype.getDeviceId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.deviceId},t.prototype.getSessionId=function(){var e;return(e=this.identifiers)===null||e===void 0?void 0:e.sessionId},t.prototype.start=function(){return Pn(this._start())},t.prototype._start=function(){return y(this,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return this.recordingEnabled=!0,this.startChildRecordingOnSetup=!0,[4,this.recordEvents()];case 1:return e.sent(),[2]}})})},t.prototype.stop=function(){this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,this.stopRecordingEvents(),this.sendEvents()},t.prototype.flush=function(e){var r;return e===void 0&&(e=!1),y(this,void 0,void 0,function(){return b(this,function(n){return[2,(r=this.eventsManager)===null||r===void 0?void 0:r.flush(e)]})})},t.prototype.shutdown=function(){var e,r;this.recordingEnabled=!1,this.startChildRecordingOnSetup=!1,this.recordingGeneration++,(e=this.urlChangeCleanup)===null||e===void 0||e.call(this),(r=this.crossOriginParentSignalCleanup)===null||r===void 0||r.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},t.prototype.mapSDKType=function(e){return e==="plugin"?"@amplitude/plugin-session-replay-browser":e==="segment"?"@amplitude/segment-session-replay-plugin":null},t.prototype.setMetadata=function(e,r,n,i,o,a,s){var u=e?.toString()?ko(e.toString()):void 0;this.metadata={joinedConfig:r,localConfig:n,remoteConfig:i,sessionId:e,hashValue:u,sampleRate:r.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:o,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:a}},t.prototype.initializeNetworkObservers=function(){var e,r,n;return y(this,void 0,void 0,function(){var i,o;return b(this,function(a){switch(a.label){case 0:if(!(!((n=(r=(e=this.config)===null||e===void 0?void 0:e.loggingConfig)===null||r===void 0?void 0:r.network)===null||n===void 0)&&n.enabled&&!this.networkObservers))return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,import("./chunk-WPPFTPXU.js")];case 2:return i=a.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return o=a.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},t})();var It=function(t){return function(){var e=t.config,r=e||Wu(),n=r.loggerProvider,i=r.logLevel;return{logger:n,logLevel:i}}},m_=function(){var t=new $h;return{init:ct(t.init.bind(t),"init",It(t)),evaluateTargetingAndCapture:ct(t.evaluateTargetingAndCapture.bind(t),"evaluateTargetingAndRecord",It(t)),setSessionId:ct(t.setSessionId.bind(t),"setSessionId",It(t)),getSessionId:ct(t.getSessionId.bind(t),"getSessionId",It(t)),getSessionReplayProperties:ct(t.getSessionReplayProperties.bind(t),"getSessionReplayProperties",It(t)),flush:ct(t.flush.bind(t),"flush",It(t)),start:ct(t.start.bind(t),"start",It(t)),stop:ct(t.stop.bind(t),"stop",It(t)),shutdown:ct(t.shutdown.bind(t),"shutdown",It(t))}},ht=m_();var Yh=ht.init,Qh=ht.setSessionId,Jh=ht.getSessionId,Zh=ht.getSessionReplayProperties,eg=ht.flush,tg=ht.start,rg=ht.stop,ng=ht.shutdown,ig=ht.evaluateTargetingAndCapture;var xt=(function(t){return t.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",t})(xt||{});var og=[xt.SET,xt.SET_ONCE,xt.ADD,xt.APPEND,xt.PREPEND,xt.POSTINSERT];var ag=function(t){if(t.user_properties){var e={},r=Object.keys(t.user_properties);return r.forEach(function(n){if(og.includes(n)){var i=t.user_properties&&t.user_properties[n];e=T(T({},e),i)}}),e}};var ol="1.35.1";var E_="[Amplitude]",__="".concat(E_," Session Replay ID"),yn=(function(){function t(e){this.name=t.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:eg,getSessionId:Jh,get
11SessionReplayProperties:Zh,init:Yh,setSessionId:Qh,start:tg,stop:rg,shutdown:ng,evaluateTargetingAndCapture:ig},this.options=T({forceSessionTracking:!1},e),this.srInitOptions=this.options}return t.prototype.setup=function(e,r){var n,i,o,a,s,u,c,l;return y(this,void 0,void 0,function(){var f,d,v;return b(this,function(p){switch(p.label){case 0:return p.trys.push([0,2,,3]),e?.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(ol,".")),this.config=e,this.options.forceSessionTracking&&(typeof e.defaultTracking=="boolean"?e.defaultTracking===!1&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=T(T({},e.defaultTracking),{sessions:!0})),f=Gu(this.config.instanceName).identityStore,d=f.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:(n=this.options.deviceId)!==null&&n!==void 0?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl||((i=this.config.remoteConfig)===null||i===void 0?void 0:i.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:(o=this.options.privacyConfig)===null||o===void 0?void 0:o.blockSelector,maskSelector:(a=this.options.privacyConfig)===null||a===void 0?void 0:a.maskSelector,unmaskSelector:(s=this.options.privacyConfig)===null||s===void 0?void 0:s.unmaskSelector,defaultMaskLevel:(u=this.options.privacyConfig)===null||u===void 0?void 0:u.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,inlineImages:this.options.inlineImages,version:{type:"plugin",version:ol},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:(c=this.options.useWebWorker)!==null&&c!==void 0?c:(l=this.options.experimental)===null||l===void 0?void 0:l.useWebWorker,userProperties:d,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.maxPersistedEventsSizeBytes,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 p.sent(),[3,3];case 2:return v=p.sent(),e?.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(v.message)),[3,3];case 3:return[2]}})})},t.prototype.onSessionIdChanged=function(e){var r;return y(this,void 0,void 0,function(){return b(this,function(n){switch(n.label){case 0:return(r=this.config)===null||r===void 0||r.loggerProvider.debug("Analytics session id is changed to ".concat(e,", SR session id is ").concat(String(this.sessionReplay.getSessionId()),".")),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},t.prototype.onOptOutChanged=function(e){var r;return y(this,void 0,void 0,function(){var n;return b(this,function(i){switch(i.label){case 0:return(r=this.config)===null||r===void 0||r.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),e?(this.sessionReplay.shutdown(),[3,4]):[3,1];case 1:return n=this.config!=null,n?[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise]:[3,3];case 2:n=i.sent(),i.label=3;case 3:i.label=4;case 4:return[2]}})})},t.prototype.execute=function(e){var r,n,i;return y(this,void 0,void 0,function(){var o,u,o,a,s,u,c;return b(this,function(l){switch(l.label){case 0:return l.trys.push([0,9,,10]),this.options.customSessionId?(o=this.options.customSessionId(e),o?o===this.sessionReplay.getSessionId()?[3,2]:[4,this.sessionReplay.setSessionId(o).promise]:[3,3]):[3,4];case 1:l.sent(),l.label=2;case 2:u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=T(T({},e.event_properties),u),l.label=3;case 3:return[3,8];case 4:return o=(r=this.config)===null||r===void 0?void 0:r.sessionId,o&&o!==this.sessionReplay.getSessionId()?[4,this.sessionReplay.setSessionId(o).promise]:[3,6];case 5:l.sent(),l.label=6;case 6:return o&&o===e.session_id?(a=void 0,e.event_type===vn.IDENTIFY&&(a=ag(e)),s=Fu(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:a,page:((n=s?.location)===null||n===void 0?void 0:n.href)!=null?{url:s.location.href}:void 0})]):[3,8];case 7:l.sent(),u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=T(T({},e.event_properties),u),l.label=8;case 8:return e.event_type===vn.IDENTIFY&&e.event_properties&&delete e.event_properties[__],[2,Promise.resolve(e)];case 9:return c=l.sent(),(i=this.config)===null||i===void 0||i.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(c.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},t.prototype.teardown=function(){var e;return y(this,void 0,void 0,function(){return b(this,function(r){try{this.sessionReplay.shutdown(),this.config=null}catch(n){(e=this.config)===null||e===void 0||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(n.message))}return[2]})})},t.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},t.prototype.start=function(){return y(this,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,this.sessionReplay.start().promise];case 1:return e.sent(),[2]}})})},t.prototype.stop=function(){this.sessionReplay.stop()},t.pluginName="@amplitude/plugin-session-replay-browser",t})();var ho=function(t){return new yn(t)};var q={IS:"is",IS_NOT:"is not",CONTAINS:"contains",DOES_NOT_CONTAIN:"does not contain",LESS_THAN:"less",LESS_THAN_EQUALS:"less or equal",GREATER_THAN:"greater",GREATER_THAN_EQUALS:"greater or equal",VERSION_LESS_THAN:"version less",VERSION_LESS_THAN_EQUALS:"version less or equal",VERSION_GREATER_THAN:"version greater",VERSION_GREATER_THAN_EQUALS:"version greater or equal",SET_IS:"set is",SET_IS_NOT:"set is not",SET_CONTAINS:"set contains",SET_DOES_NOT_CONTAIN:"set does not contain",SET_CONTAINS_ANY:"set contains any",SET_DOES_NOT_CONTAIN_ANY:"set does not contain any",REGEX_MATCH:"regex match",REGEX_DOES_NOT_MATCH:"regex does not match"},b_=t=>{let e=[],r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)==55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)==56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128)}return Uint8Array.from(e)},mo=-862048943,Eo=461845907,_o=15,S_=13,y_=5,T_=-430675100,I_=(t,e=0)=>{let r=b_(t),n=r.length,i=n>>2,o=e;for(let u=0;u<i;u++){let c=u<<2,l=C_(r,c);o=x_(l,o)}let a=i<<2,s=0;switch(n-a){case 3:s^=r[a+2]<<16,s^=r[a+1]<<8,s^=r[a],s=Math.imul(s,mo),s=In(s,_o),s=Math.imul(s,Eo),o^=s;break;case 2:s^=r[a+1]<<8,s^=r[a],s=Math.imul(s,mo),s=In(s,_o),s=Math.imul(s,Eo),o^=s;break;case 1:s^=r[a],s=Math.imul(s,mo),s=In(s,_o),s=Math.imul(s,Eo),o^=s;break}return o^=n,A_(o)>>>0},x_=(t,e)=>{let r=t,n=e;return r=Math.imul(r,mo),r=In(r,_o),r=Math.imul(r,Eo),n^=r,n=In(n,S_),n=Math.imul(n,y_),n+T_|0},A_=t=>{let e=t;return e^=e>>>16,e=Math.imul(e,-2048144789),e^=e>>>13,e=Math.imul(e,-1028477387),e^=e>>>16,e},In=(t,e,r=32)=>{e>r&&(e=e%r);let n=4294967295<<r-e>>>0,i=(t&n)>>>0>>>r-e>>>0;return(t<<e|i)>>>0},C_=(t,e=0)=>{let r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return R_(r)},R_=t=>(t&-16777216)>>>24|(t&16711680)>>>8|(t&65280)<<8|(t&255)<<24,al=(t,e)=>{if(!(!e||e.length===0)){for(let r of e){if(!r||!t||typeof t!="object")return;t=t[r]}if(t!=null)return t}}
11,w_="(\\d+)\\.(\\d+)",L_="(\\d+)",P_="(-(([-\\w]+\\.?)*))?",D_=`^${w_}(\\.${L_}${P_})?$`,sl=class t{constructor(e,r,n,i=void 0){this.major=e,this.minor=r,this.patch=n,this.preRelease=i}static parse(e){if(!e)return;let r=new RegExp(D_).exec(e);if(!r)return;let n=Number(r[1]),i=Number(r[2]);if(isNaN(n)||isNaN(i))return;let o=Number(r[4])||0,a=r[5]||void 0;return new t(n,i,o,a)}compareTo(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0}},So=class{evaluate(e,r){let n={},i={context:e,result:n};for(let o of r){let a=this.evaluateFlag(i,o);a&&(n[o.key]=a)}return n}evaluateWithTraces(e,r){let n={},i={},o={context:e,result:n};for(let a of r){let{variant:s,trace:u}=this.evaluateFlagWithTrace(o,a);s&&(n[a.key]=s),i[a.key]=u}return{results:n,traces:i}}evaluateFlag(e,r){let n;for(let i of r.segments)if(n=this.evaluateSegment(e,r,i),n){let o=Object.assign(Object.assign(Object.assign({},r.metadata),i.metadata),n.metadata);n=Object.assign(Object.assign({},n),{metadata:o});break}return n}evaluateFlagWithTrace(e,r){var n,i;let o=[],a,s,u;for(let l of r.segments){if(!l.conditions){let h=this.bucket(e,l),g=h!==void 0;o.push({segmentMetadata:l.metadata,conditionsPassed:!0,bucketed:g,bucketVariant:h,conditionResult:void 0,matched:g}),!a&&h!==void 0&&(a=r.variants[h],s=l,u=(n=l.metadata)===null||n===void 0?void 0:n.segmentName);continue}let f=[],d=!1;for(let h of l.conditions){let g=!0,m=[];for(let E of h){let _=al(e,E.selector),S=this.matchCondition(e,E);if(m.push({propValue:_,condition:E,matched:S}),!S){g=!1;break}}if(f.push(m),g){d=!0;break}}let v=!1,p;d&&(p=this.bucket(e,l),v=p!==void 0),o.push({segmentMetadata:l.metadata,conditionsPassed:d,bucketed:v,bucketVariant:p,conditionResult:f,matched:d&&v}),d&&p!==void 0&&!a&&(a=r.variants[p],s=l,u=(i=l.metadata)===null||i===void 0?void 0:i.segmentName)}if(a&&s){let l=Object.assign(Object.assign(Object.assign({},r.metadata),s.metadata),a.metadata);a=Object.assign(Object.assign({},a),{metadata:l})}let c={flagKey:r.key,matched:a!==void 0,matchedSegment:u,steps:o};return{variant:a,trace:c}}evaluateSegment(e,r,n){if(!n.conditions){let o=this.bucket(e,n);return o!==void 0?r.variants[o]:void 0}if(this.evaluateConditions(e,n.conditions)){let o=this.bucket(e,n);return o!==void 0?r.variants[o]:void 0}}evaluateConditions(e,r){for(let n of r){let i=!0;for(let o of n)if(i=this.matchCondition(e,o),!i)break;if(i)return!0}return!1}matchCondition(e,r){let n=al(e,r.selector);if(n==null)return this.matchNull(r.op,r.values);{let i=this.coerceStringArray(n);if(this.isSetOperator(r.op))return i?this.matchSet(i,r.op,r.values):!1;if(i)return this.matchStringsNonSet(i,r.op,r.values);{let o=this.coerceString(n);return o!==void 0?this.matchString(o,r.op,r.values):!1}}}getHash(e){return I_(e)}bucket(e,r){if(!r.bucket)return r.variant;let n=this.coerceString(al(e,r.bucket.selector));if(!n||n.length===0)return r.variant;let i=`${r.bucket.salt}/${n}`,o=this.getHash(i),a=o%100,s=Math.floor(o/100);for(let u of r.bucket.allocations){let c=u.range[0],l=u.range[1];if(a>=c&&a<l)for(let f of u.distributions){let d=f.range[0],v=f.range[1];if(s>=d&&s<v)return f.variant}}return r.variant}matchNull(e,r){let n=this.containsNone(r);switch(e){case q.IS:case q.CONTAINS:case q.LESS_THAN:case q.LESS_THAN_EQUALS:case q.GREATER_THAN:case q.GREATER_THAN_EQUALS:case q.VERSION_LESS_THAN:case q.VERSION_LESS_THAN_EQUALS:case q.VERSION_GREATER_THAN:case q.VERSION_GREATER_THAN_EQUALS:case q.SET_IS:case q.SET_CONTAINS:case q.SET_CONTAINS_ANY:return n;case q.IS_NOT:case q.DOES_NOT_CONTAIN:case q.SET_DOES_NOT_CONTAIN:case q.SET_DOES_NOT_CONTAIN_ANY:return!n;default:return!1}}matchSet(e,r,n){switch(r){case q.SET_IS:return this.setEquals(e,n);case q.SET_IS_NOT:return!this.setEquals(e,n);case q.SET_CONTAINS:return this.matchesSetContainsAll(e,n);case q.SET_DOES_NOT_CONTAIN:return!this.matchesSetContainsAll(e,n);case q.SET_CONTAINS_ANY:return this.matchesSetContainsAny(e,n);case q.SET_DOES_NOT_CONTAIN_ANY:return!this.matchesSetContainsAny(e,n);default:return!1}}matchString(e,r,n){switch(r){case q.IS:return this.matchesIs(e,n);case q.IS_NOT:return!this.matchesIs(e,n);case q.CONTAINS:return this.matchesContains(e,n);case q.DOES_NOT_CONTAIN:return!this.matchesContains(e,n);case q.LESS_THAN:case q.LESS_THAN_EQUALS:case q.GREATER_THAN:case q.GREATER_THAN_EQUALS:return this.matchesComparable(e,r,n,i=>this.parseNumber(i),(i,o,a)=>this.comparator(i,o,a));case q.VERSION_LESS_THAN:case q.VERSION_LESS_THAN_EQUALS:case q.VERSION_GREATER_THAN:case q.VERSION_GREATER_THAN_EQUALS:return this.matchesComparable(e,r,n,i=>sl.parse(i),(i,o,a)=>this.versionComparator(i,o,a));case q.REGEX_MATCH:return this.matchesRegex(e,n);case q.REGEX_DOES_NOT_MATCH:return!this.matchesRegex(e,n);default:return!1}}matchStringsNonSet(e,r,n){return e.some(i=>this.matchString(i,r,n))}matchesIs(e,r){if(this.containsBooleans(r)){let n=e.toLowerCase();if(n==="true"||n==="false")return r.some(i=>i.toLowerCase()===n)}return r.some(n=>e===n)}matchesContains(e,r){for(let n of r)if(e.toLowerCase().includes(n.toLowerCase()))return!0;return!1}matchesComparable(e,r,n,i,o){let a=i(e),s=n.map(u=>i(u)).filter(u=>u!==void 0);return a===void 0||s.length===0?n.some(u=>this.comparator(e,r,u)):s.some(u=>o(a,r,u))}comparator(e,r,n){switch(r){case q.LESS_THAN:case q.VERSION_LESS_THAN:return e<n;case q.LESS_THAN_EQUALS:case q.VERSION_LESS_THAN_EQUALS:return e<=n;case q.GREATER_THAN:case q.VERSION_GREATER_THAN:return e>n;case q.GREATER_THAN_EQUALS:case q.VERSION_GREATER_THAN_EQUALS:return e>=n;default:return!1}}versionComparator(e,r,n){let i=e.compareTo(n);switch(r){case q.LESS_THAN:case q.VERSION_LESS_THAN:return i<0;case q.LESS_THAN_EQUALS:case q.VERSION_LESS_THAN_EQUALS:return i<=0;case q.GREATER_THAN:case q.VERSION_GREATER_THAN:return i>0;case q.GREATER_THAN_EQUALS:case q.VERSION_GREATER_THAN_EQUALS:return i>=0;default:return!1}}matchesRegex(e,r){return r.some(n=>!!new RegExp(n).exec(e))}containsNone(e){return e.some(r=>r==="(none)")}containsBooleans(e){return e.some(r=>{switch(r.toLowerCase()){case"true":case"false":return!0;default:return!1}})}parseNumber(e){var r;return(r=Number(e))!==null&&r!==void 0?r:void 0}coerceString(e){if(e!=null)return typeof e=="object"?JSON.stringify(e):String(e)}coerceStringArray(e){if(Array.isArray(e))return e.map(i=>
11this.coerceString(i)).filter(Boolean);let r=String(e);if(r.startsWith("["))try{let n=JSON.parse(r);return Array.isArray(n)?n.map(i=>this.coerceString(i)).filter(Boolean):void 0}catch(n){return}}isSetOperator(e){switch(e){case q.SET_IS:case q.SET_IS_NOT:case q.SET_CONTAINS:case q.SET_DOES_NOT_CONTAIN:case q.SET_CONTAINS_ANY:case q.SET_DOES_NOT_CONTAIN_ANY:return!0;default:return!1}}setEquals(e,r){let n=new Set(e),i=new Set(r);return n.size===i.size&&[...i].every(o=>n.has(o))}matchesSetContainsAll(e,r){if(e.length<r.length)return!1;for(let n of r)if(!this.matchesIs(n,e))return!1;return!0}matchesSetContainsAny(e,r){for(let n of r)if(this.matchesIs(n,e))return!0;return!1}},dl=(t,e)=>{let r=Object.assign({},t),n=[],i=e||Object.keys(r);for(let o of i){let a=fg(o,r);a&&n.push(...a)}return n},fg=(t,e,r=[])=>{let n=e[t];if(n){if(!n.dependencies||n.dependencies.length===0)return delete e[n.key],[n]}else return;r.push(n.key);let i=[];for(let o of n.dependencies){if(r.some(s=>s===o))throw Error(`Detected a cycle between flags ${r.join(", ")}`);let a=fg(o,e,r);a&&i.push(...a)}return i.push(n),r.pop(),delete e[n.key],i};function vg(t,e,r,n){function i(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function s(l){try{c(n.next(l))}catch(f){a(f)}}function u(l){try{c(n.throw(l))}catch(f){a(f)}}function c(l){l.done?o(l.value):i(l.value).then(s,u)}c((n=n.apply(t,e||[])).next())})}var pg="3.7.8",O_=pg,br=typeof Buffer=="function",sg=typeof TextDecoder=="function"?new TextDecoder:void 0,ug=typeof TextEncoder=="function"?new TextEncoder:void 0,k_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Tn=Array.prototype.slice.call(k_),go=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(Tn),N_=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Fe=String.fromCharCode.bind(String),lg=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),hg=t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),gg=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),mg=t=>{let e,r,n,i,o="",a=t.length%3;for(let s=0;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|i,o+=Tn[e>>18&63]+Tn[e>>12&63]+Tn[e>>6&63]+Tn[e&63]}return a?o.slice(0,a-3)+"===".substring(a):o},fl=typeof btoa=="function"?t=>btoa(t):br?t=>Buffer.from(t,"binary").toString("base64"):mg,ul=br?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,i=t.length;n<i;n+=4096)r.push(Fe.apply(null,t.subarray(n,n+4096)));return fl(r.join(""))},bo=(t,e=!1)=>e?hg(ul(t)):ul(t),U_=t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?Fe(192|e>>>6)+Fe(128|e&63):Fe(224|e>>>12&15)+Fe(128|e>>>6&63)+Fe(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return Fe(240|e>>>18&7)+Fe(128|e>>>12&63)+Fe(128|e>>>6&63)+Fe(128|e&63)}},M_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Eg=t=>t.replace(M_,U_),cg=br?t=>Buffer.from(t,"utf8").toString("base64"):ug?t=>ul(ug.encode(t)):t=>fl(Eg(t)),Er=(t,e=!1)=>e?hg(cg(t)):cg(t),dg=t=>Er(t,!0),F_=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,G_=t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return Fe((r>>>10)+55296)+Fe((r&1023)+56320);case 3:return Fe((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return Fe((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},_g=t=>t.replace(F_,G_),bg=t=>{if(t=t.replace(/\s+/g,""),!N_.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r,n,i=[];for(let o=0;o<t.length;)e=go[t.charAt(o++)]<<18|go[t.charAt(o++)]<<12|(r=go[t.charAt(o++)])<<6|(n=go[t.charAt(o++)]),r===64?i.push(Fe(e>>16&255)):n===64?i.push(Fe(e>>16&255,e>>8&255)):i.push(Fe(e>>16&255,e>>8&255,e&255));return i.join("")},vl=typeof atob=="function"?t=>atob(gg(t)):br?t=>Buffer.from(t,"base64").toString("binary"):bg,Sg=br?t=>lg(Buffer.from(t,"base64")):t=>lg(vl(t).split("").map(e=>e.charCodeAt(0))),yg=t=>Sg(Tg(t)),B_=br?t=>Buffer.from(t,"base64").toString("utf8"):sg?t=>sg.decode(Sg(t)):t=>_g(vl(t)),Tg=t=>gg(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),ll=t=>B_(Tg(t)),V_=t=>
11{if(typeof t!="string")return!1;let e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},Ig=t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),xg=function(){let t=(e,r)=>Object.defineProperty(String.prototype,e,Ig(r));t("fromBase64",function(){return ll(this)}),t("toBase64",function(e){return Er(this,e)}),t("toBase64URI",function(){return Er(this,!0)}),t("toBase64URL",function(){return Er(this,!0)}),t("toUint8Array",function(){return yg(this)})},Ag=function(){let t=(e,r)=>Object.defineProperty(Uint8Array.prototype,e,Ig(r));t("toBase64",function(e){return bo(this,e)}),t("toBase64URI",function(){return bo(this,!0)}),t("toBase64URL",function(){return bo(this,!0)})},K_=()=>{xg(),Ag()},cl={version:pg,VERSION:O_,atob:vl,atobPolyfill:bg,btoa:fl,btoaPolyfill:mg,fromBase64:ll,toBase64:Er,encode:Er,encodeURI:dg,encodeURL:dg,utob:Eg,btou:_g,decode:ll,isValid:V_,fromUint8Array:bo,toUint8Array:yg,extendString:xg,extendUint8Array:Ag,extendBuiltins:K_},xn=class t extends Error{constructor(e,r){super(r),this.statusCode=e,Object.setPrototypeOf(this,t.prototype)}},_r=class t extends Error{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}},yo=class{constructor(e,r,n){this.deploymentKey=e,this.serverUrl=r,this.httpClient=n}getVariants(e,r){return vg(this,void 0,void 0,function*(){let n=cl.encodeURL(JSON.stringify(e)),i={Authorization:`Api-Key ${this.deploymentKey}`,"X-Amp-Exp-User":n};r?.flagKeys&&(i["X-Amp-Exp-Flag-Keys"]=cl.encodeURL(JSON.stringify(r.flagKeys))),r?.trackingOption&&(i["X-Amp-Exp-Track"]=r.trackingOption),r?.exposureTrackingOption&&(i["X-Amp-Exp-Exposure-Track"]=r.exposureTrackingOption);let o=new URL(`${this.serverUrl}/sdk/v2/vardata?v=0`);r?.evaluationMode&&o.searchParams.append("eval_mode",r?.evaluationMode),r?.deliveryMethod&&o.searchParams.append("delivery_method",r?.deliveryMethod);let a=yield this.httpClient.request({requestUrl:o.toString(),method:"GET",headers:i,timeoutMillis:r?.timeoutMillis});if(a.status!=200)throw new xn(a.status,`Fetch error response: status=${a.status}`);return JSON.parse(a.body)})}},To=class{constructor(e,r,n){this.deploymentKey=e,this.serverUrl=r,this.httpClient=n}getFlags(e){return vg(this,void 0,void 0,function*(){let r={Authorization:`Api-Key ${this.deploymentKey}`};e?.libraryName&&e?.libraryVersion&&(r["X-Amp-Exp-Library"]=`${e.libraryName}/${e.libraryVersion}`),e?.user&&(r["X-Amp-Exp-User"]=cl.encodeURL(JSON.stringify(e.user)));let n=yield this.httpClient.request({requestUrl:`${this.serverUrl}/sdk/v2/flags`+(e?.deliveryMethod?`?delivery_method=${e.deliveryMethod}`:""),method:"GET",headers:r,timeoutMillis:e?.timeoutMillis});if(n.status!=200)throw Error(`Flags error response: status=${n.status}`);return JSON.parse(n.body).reduce((o,a)=>(o[a.key]=a,o),{})})}},De=()=>{if(typeof globalThis<"u"&&globalThis!==null)return globalThis;if(typeof window<"u"&&window!==null)return window;if(typeof self<"u"&&self!==null)return self;if(typeof global<"u"&&global!==null)return global},CN=De(),Cg=()=>{let t=De();if(t)try{let e="EXP_test";return t.localStorage.setItem(e,e),t.localStorage.removeItem(e),!0}catch(e){return!1}return!1},xo=()=>{var t;return(t=De())===null||t===void 0?void 0:t.localStorage},Sr=()=>{var t;return(t=De())===null||t===void 0?void 0:t.sessionStorage},Rg=()=>{var t;return(t=De())===null||t===void 0?void 0:t.document},wg=()=>{let t=De();return t?.fetch?t.fetch.bind(t):void 0},Ao=()=>{let t=De();return t?.setTimeout?t.setTimeout.bind(t):void 0},Lg=()=>{let t=De();return t?.clearTimeout?t.clearTimeout.bind(t):void 0},pl=()=>{let t=De();return t?.setInterval?t.setInterval.bind(t):void 0},hl=()=>{let t=De();return t?.clearInterval?t.clearInterval.bind(t):void 0},Io=class{constructor(e,r){this.poller=void 0,this.action=e,this.ms=r}start(){if(this.poller)return;let e=pl();e&&(this.poller=e(()=>{this.action()},this.ms),this.action())}stop(){if(!this.poller)return;let e=hl();e&&e(this.poller),this.poller=void 0}};var Bg=Ln(Pg());function ke(t,e,r,n){function i(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function s(l){try{c(n.next(l))}catch(f){a(f)}}function u(l){try{c(n.throw(l))}catch(f){a(f)}}function c(l){l.done?o(l.value):i(l.value).then(s,u)}c((n=n.apply(t,e||[])).next())})}var Dg=(t,e=!1)=>{let r=Pl(t,e),n,i=Rg();if(!i)return;let o=i.cookie.split("; ");for(let a of o){let[s,u]=a.split("=",2);s===r&&(n=decodeURIComponent(u))}if(n)try{if(e){let u=atob(n);return JSON.parse(decodeURIComponent(u))}let a=n.split("."),s;return a.length>=2&&a[1]&&(s=atob(a[1])),{deviceId:a[0],userId:s}}catch(a){return}},H_=t=>{let e=Pl(t,!0);try{let r=xo();if(!r)return;let n=r.getItem(e);if(!n)return;let i=JSON.parse(n);return typeof i!="object"?void 0:i}catch(r){return}},W_=t=>{let e=Pl(t,!0);try{let r=Sr();if(!r)return;let n=r.getItem(e);if(!n)return;let i=JSON.parse(n);return typeof i!="object"?void 0:i}catch(r){return}},Pl=(t,e)=>{if(e)return t?.length<10?void 0:`AMP_${t.substring(0,10)}`;if(!(t?.length<6))return`amp_${t.substring(0,6)}`},El=class{constructor(e,r,n){this.type="integration",this.apiKey=e,this.identityStore=r.identityStore,this.eventBridge=r.eventBridge,this.contextProvider=r.applicationContextProvider,this.timeoutMillis=n,this.loadPersistedState(),n<=0&&(this.setup=void 0)}setup(e,r){return ke(this,void 0,void 0,function*(){return e?.automaticFetchOnAmplitudeIdentityChange&&this.identityStore.addIdentityListener(()=>{r?.fetch()}),this.waitForConnectorIdentity(this.timeoutMillis)})}getUser(){let e=this.identityStore.getIdentity();return{user_id:e.userId,device_id:e.deviceId,user_properties:e.userProperties,version:this.contextProvider.versionName}}track(e){return this.eventBridge.receiver?(this.eventBridge.logEvent({eventType:e.eventType,eventProperties:e.eventProperties}),!0):!1}loadPersistedState(){if(!this.apiKey||this.apiKey.startsWith("client-"))return!1;let e=Dg(this.apiKey,!0);return e?(this.commitIdentityToConnector(e),!0):(e=Dg(this.apiKey,!1),e?(this.commitIdentityToConnector(e),!0):(e=H_(this.apiKey),e?(this.commitIdentityToConnector(e),!0):(e=W_(this.apiKey),e?(this.commitIdentityToConnector(e),!0):!1)))}commitIdentityToConnector(e){let r=this.identityStore.editIdentity();r.setDeviceId(e.deviceId),e.userId&&r.setUserId(e.userId),r.commit()}waitForConnectorIdentity(e){return ke(this,void 0,void 0,function*(){let r=this.identityStore.getIdentity();if(!r.userId&&!r.deviceId)return Promise.race([new Promise(n=>{let i=()=>{n(),this.identityStore.removeIdentityListener(i)};this.identityStore.addIdentityListener(i)}),new Promise((n,i)=>{let o=Ao();if(!o){i("Timed out waiting for Amplitude Analytics SDK to initialize.");return}o(i,e,"Timed out waiting for Amplitude Analytics SDK to initialize.")})])})}};function q_(t,e){return e=e||{},new Promise(function(r,n){var i=new XMLHttpRequest,o=[],a=[],s={},u=function(){return{ok:(i.status/100|0)==2,statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(JSON.parse(i.responseText))},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return o},entries:function(){return a},get:function(l){return s[l.toLowerCase()]},has:function(l){return l.toLowerCase()in s}}}};for(var c in i.open(e.method||"get",t,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(l,f,d){o.push(f=f.toLowerCase()),a.push([f,d]),s[f]=s[f]?s[f]+","+d:d}),r(u())},i.onerror=n,i.withCredentials=e.credentials=="include",e.headers)i.setRequestHeader(c,e.headers[c]);i.send(e.body||null)})}var X_=wg()||q_,j_=(t,e)=>e==null||e<=0?t:new Promise(function(r,n){let i=Ao();i&&i(function(){n(new _r(`Request timeout after ${e} milliseconds`))},e),t.then(r,n)}),z_=(t,e,r,n,i)=>j_(ke(void 0,void 0,void 0,function*(){let a=yield X_(t,{method:e,headers:r,body:n});return{status:a.status,body:yield a.text()}}),i),_l=class{constructor(e){this.client=e}request(e){return ke(this,void 0,void 0,function*(){return yield this.client.request(e.requestUrl,e.method,e.headers,null,e.timeoutMillis)})}},Vg={request:z_},gt=(function(t){return t[t.Disable=0]="Disable",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Info=3]="Info",t[t.Debug=4]="Debug",t[t.Verbose=5]="Verbose",t})(gt||{}),kt=(function(t){return t.LocalStorage="localStorage",t.InitialVariants="initialVariants",t})(kt||{}),Oe=(function(t){return t.LocalStorage="storage",t.InitialVariants="initial",t.SecondaryLocalStorage="secondary-storage",t.SecondaryInitialVariants="secondary-initial",t.FallbackInline="fallback-inline",t.FallbackConfig="fallback-config",t.L
11ocalEvaluation="local-evaluation",t})(Oe||{}),Og=t=>!t||t===Oe.FallbackInline||t===Oe.FallbackConfig||t===Oe.SecondaryInitialVariants,yr={debug:!1,logLevel:gt.Error,loggerProvider:null,instanceName:"$default_instance",fallbackVariant:{},initialVariants:{},initialFlags:void 0,source:kt.LocalStorage,serverUrl:"https://api.lab.amplitude.com",flagsServerUrl:"https://flag.lab.amplitude.com",serverZone:"US",fetchTimeoutMillis:1e4,retryFetchOnFailure:!0,throwOnError:!1,automaticExposureTracking:!0,pollOnStart:!0,flagConfigPollingIntervalMillis:3e5,fetchOnStart:!0,automaticFetchOnAmplitudeIdentityChange:!1,userProvider:null,analyticsProvider:null,exposureTrackingProvider:null,httpClient:Vg},kg="1.22.1",$_=512,bl=class{constructor(e,r){var n;this.isReady=new Promise(o=>{this.resolve=o}),this.config=e,this.client=r;let i=(n=e.instanceName)!==null&&n!==void 0?n:yr.instanceName;this.queue=new yl(i),this.cache=new Sl(i)}ready(){return this.integration?this.isReady:Promise.resolve()}setIntegration(e){this.integration&&this.integration.teardown&&this.integration.teardown(),this.integration=e,e.setup?this.integration.setup(this.config,this.client).then(()=>{this.queue.setTracker(this.integration.track.bind(e)),this.resolve()},()=>{this.queue.setTracker(this.integration.track.bind(e)),this.resolve()}):(this.queue.setTracker(this.integration.track.bind(e)),this.resolve())}getUser(){return this.integration?this.integration.getUser():{}}track(e,r){if(this.cache.shouldTrack(e,r)){let n=this.getExposureEvent(e);this.queue.push(n)}}getExposureEvent(e){var r,n,i;let o={eventType:"$exposure",eventProperties:e};return!((r=e.metadata)===null||r===void 0)&&r.exposureEvent?o={eventType:(n=e.metadata)===null||n===void 0?void 0:n.exposureEvent,eventProperties:e}:((i=e.metadata)===null||i===void 0?void 0:i.deliveryMethod)==="web"&&(o={eventType:"$impression",eventProperties:e}),o}},Sl=class{constructor(e){this.isSessionStorageAvailable=Y_(),this.inMemoryCache={},this.identity={},this.storageKey=`EXP_sent_v3_${e}`;let r=Sr();this.isSessionStorageAvailable&&r&&(r.removeItem(`EXP_sent_${e}`),r.removeItem(`EXP_sent_v2_${e}`))}shouldTrack(e,r){var n,i;if(((n=e.metadata)===null||n===void 0?void 0:n.deliveryMethod)==="web")return!0;let o={userId:r?.user_id,deviceId:r?.device_id};this.identityEquals(this.identity,o)||this.clearCache(),this.identity=o,this.loadCache();let a=e.flag_key in this.inMemoryCache,s=this.inMemoryCache[e.flag_key],u=(i=e.variant)!==null&&i!==void 0?i:null,c=s??null,l=!1;return(!a||c!==u)&&(l=!0,this.inMemoryCache[e.flag_key]=u),this.storeCache(),l}clearCache(){this.inMemoryCache={};let e=Sr();this.isSessionStorageAvailable&&e&&e.removeItem(this.storageKey)}identityEquals(e,r){return e.userId&&r.userId?e.userId===r.userId:!e.userId&&!r.userId?e.deviceId===r.deviceId:!1}loadCache(){let e=Sr();if(this.isSessionStorageAvailable&&e){let r=e.getItem(this.storageKey);this.inMemoryCache=r?JSON.parse(r):{}}}storeCache(){let e=Sr();if(this.isSessionStorageAvailable&&e)try{e.setItem(this.storageKey,JSON.stringify(this.inMemoryCache))}catch(r){}}},yl=class{constructor(e,r=$_){this.isLocalStorageAvailable=Cg(),this.inMemoryQueue=[],this.storageKey=`EXP_unsent_${e}`,this.maxQueueSize=r}push(e){this.loadQueue(),this.inMemoryQueue.push(e),this.flush(),this.storeQueue()}setTracker(e){this.tracker=e;let r=pl();r&&(this.poller=r(()=>{this.loadFlushStore()},1e3)),this.loadFlushStore()}flush(){if(!this.tracker||this.inMemoryQueue.length===0)return;let e=0;for(;e<this.inMemoryQueue.length;e++)try{if(!this.tracker(this.inMemoryQueue[e]))break}catch(r){break}if(this.inMemoryQueue=this.inMemoryQueue.slice(e),this.inMemoryQueue.length===0&&this.poller){let r=hl();r&&r(this.poller),this.poller=void 0}}loadQueue(){let e=xo();if(this.isLocalStorageAvailable&&e){let r=e.getItem(this.storageKey);this.inMemoryQueue=r?JSON.parse(r):[]}}storeQueue(){let e=xo();this.isLocalStorageAvailable&&e&&(this.inMemoryQueue.length>this.maxQueueSize&&(this.inMemoryQueue=this.inMemoryQueue.slice(this.inMemoryQueue.length-this.maxQueueSize)),e.setItem(this.storageKey,JSON.stringify(this.inMemoryQueue)))}loadFlushStore(){this.loadQueue(),this.flush(),this.storeQueue()}},Y_=()=>{let t=De();if(t)try{let e="EXP_test";return t.sessionStorage.setItem(e,e),t.sessionStorage.removeItem(e),!0}catch(e){return!1}return!1},Tl=class{constructor(e,r=gt.Error){this.logger=e,this.logLevel=r}
11error(e,...r){this.logLevel>=gt.Error&&this.logger.error(e,...r)}warn(e,...r){this.logLevel>=gt.Warn&&this.logger.warn(e,...r)}info(e,...r){this.logLevel>=gt.Info&&this.logger.info(e,...r)}debug(e,...r){this.logLevel>=gt.Debug&&this.logger.debug(e,...r)}verbose(e,...r){this.logLevel>=gt.Verbose&&this.logger.verbose(e,...r)}},Il=class{error(e,...r){console.error(e,...r)}warn(e,...r){console.warn(e,...r)}info(e,...r){console.info(e,...r)}debug(e,...r){console.debug(e,...r)}verbose(e,...r){console.debug(e,...r)}},Tr=class{constructor(){this.globalScope=De()}get(e){var r;return(r=this.globalScope)===null||r===void 0?void 0:r.localStorage.getItem(e)}put(e,r){var n;(n=this.globalScope)===null||n===void 0||n.localStorage.setItem(e,r)}delete(e){var r;(r=this.globalScope)===null||r===void 0||r.localStorage.removeItem(e)}},Q_=(t,e,r)=>{let n=t.substring(t.length-6),i=`amp-exp-${e}-${n}`;return new Ro(i,r,Kg)},J_=(t,e,r=new Tr)=>{let n=t.substring(t.length-6),i=`amp-exp-${e}-${n}-flags`;return new Ro(i,r)},Z_=(t,e,r=new Tr)=>{let n=t.substring(t.length-6),i=`amp-exp-${e}-${n}-variants-options`;return new xl(i,r)},xl=class{constructor(e,r){this.namespace=e,this.storage=r}get(){return this.value}put(e){this.value=e}load(){let e=this.storage.get(this.namespace);e&&(this.value=JSON.parse(e))}store(){this.value===void 0?this.storage.delete(this.namespace):this.storage.put(this.namespace,JSON.stringify(this.value))}},Ro=class{constructor(e,r,n){this.cache={},this.namespace=e,this.storage=r,this.transformer=n}get(e){return this.cache[e]}getAll(){return Object.assign({},this.cache)}put(e,r){this.cache[e]=r}putAll(e){for(let r of Object.keys(e))this.cache[r]=e[r]}remove(e){delete this.cache[e]}clear(){this.cache={}}load(){let e=this.storage.get(this.namespace),r;try{r=JSON.parse(e)||{}}catch(i){return}let n={};for(let i of Object.keys(r))try{let o;this.transformer?o=this.transformer(r[i]):o=r[i],o&&(n[i]=o)}catch(o){}this.clear(),this.putAll(n)}store(e=this.cache){this.storage.put(this.namespace,JSON.stringify(e))}},Kg=t=>{if(typeof t=="string")return{key:t,value:t};if(typeof t=="object"){let e=t.key,r=t.value,n=t.payload,i=t.metadata,o=t.expKey;i&&i.experimentKey?o=i.experimentKey:o&&(i=i||{},i.experimentKey=o);let a={};return e?a.key=e:r&&(a.key=r),r&&(a.value=r),i&&(a.metadata=i),n&&(a.payload=n),o&&(a.expKey=o),a}},wo=class{constructor(){this.globalScope=De()}get(e){var r;return(r=this.globalScope)===null||r===void 0?void 0:r.sessionStorage.getItem(e)}put(e,r){var n;(n=this.globalScope)===null||n===void 0||n.sessionStorage.setItem(e,r)}delete(e){var r;(r=this.globalScope)===null||r===void 0||r.sessionStorage.removeItem(e)}},eb=(t,e,r,n)=>{let i="[Experiment] Exposure",o=r?.value,a=`[Experiment] ${e}`;return{name:i,user:t,key:e,variant:r,userProperty:a,properties:{key:e,variant:o,source:n},userProperties:{[a]:o}}},ut=t=>t==null,gl=t=>ut(t)?!0:t&&Object.keys(t).length===0,tb=t=>{if(!t||typeof t!="object")return{};let e={};for(let[r,n]of Object.entries(t))ut(n)||(e[r]=n);return e},Ng=t=>{var e;return((e=t?.metadata)===null||e===void 0?void 0:e.evaluationMode)==="local"},Al=class{constructor(e,r,n,i){this.started=!1,this.done=!1,this.attempts=e,this.min=r,this.max=n,this.scalar=i}start(e){return ke(this,void 0,void 0,function*(){if(!this.started)this.started=!0;else throw Error("Backoff already started");yield this.backoff(e,0,this.min)})}cancel(){this.done=!0;let e=Lg();e&&e(this.timeoutHandle)}backoff(e,r,n){return ke(this,void 0,void 0,function*(){if(this.done)return;let i=Ao();i&&(this.timeoutHandle=i(()=>{ke(this,void 0,void 0,function*(){try{yield e()}catch(o){let a=r+1;if(a<this.attempts){let s=Math.min(n*this.scalar,this.max);yield this.backoff(e,a,s)}}})},n))})}},Ug=t=>{var e,r;if(!t)return{};let n={user:t},i=De();i?.location&&(n.page={url:i.location.href});let o={};if(!t.groups)return n;for(let a of Object.keys(t.groups)){let s=t.groups[a];if(s.length>0&&s[0]){let u=s[0],c={group_name:u},l=(r=(e=t.group_properties)===null||e===void 0?void 0:e[a])===null||r===void 0?void 0:r[u];l&&Object.keys(l).length>0&&(c.group_properties=l),o[a]=c}}return Object.keys(o).length>0&&(n.groups=o),delete n.user.groups,delete n.user.group_properties,n},Be=t=>t==null?{}:typeof t=="string"?{key:t,value:t}:t,Mg=t=>{if(!t)return{};let e;t.metadata&&(e=t.metadata.experimentKey);let r={};return t.key&&(r.key=t.key),t.value&&(r.value=t.value),t.payload&&(r.payload=t.payload),e&&(r.expKey=e),t.metadata&&(r.metadata=t.metadata),r},Cl=class{constructor(e){this.setProperties={},this.unsetProperties={},this.analyticsProvider=e}track(e){this.setProperties[e.key]!=e.variant.value&&(this.setProperties[e.key]=e.variant.value,delete this.unsetProperties[e.key],this.analyticsProvider.track(e))}setUserProperty(e){this.setProperties[e.key]!=e.variant.value&&this.analyticsProvider.setUserProperty(e)}unsetUserProperty(e){this.unsetProperties[e.key]||(this.unsetProperties[e.key]="unset",delete this.setProperties[e.key],this.analyticsProvider.unsetUserProperty(e))}},Rl=class{constructor(e){this.tracked={},this.identity={},this.exposureTrackingProvider=e}track(e,r){let n={userId:r?.user_id,deviceId:r?.device_id};this.identityEquals(this.identity,n)||(this.tracked={}),this.identity=n;let i=e.flag_key in this.tracked,o=this.tracked[e.flag_key];i&&o===e.variant||(this.tracked[e.flag_key]=e.variant,this.exposureTrackingProvider.track(e))}identityEquals(e,r){return e.userId===r.userId&&e.deviceId===r.deviceId}},rb=1e4,nb=8,ib=500,ob=1e4,ab=1.5,Fg=6e4,sb="https://api.lab.eu.amplitude.com",ub="https://flag.lab.eu.amplitude.com",wl=class t{constructor(e,r){var n,i,o,a,s;this.engine=new So,this.isRunning=!1,this.apiKey=e,r=tb(r),this.config=Object.assign(Object.assign(Object.assign({},yr),r),{serverUrl:r?.serverUrl||(((n=r?.serverZone)===null||n===void 0?void 0:n.toLowerCase())==="eu"?sb:yr.serverUrl),flagsServerUrl:r?.flagsServerUrl||(((i=r?.serverZone)===null||i===void 0?void 0:i.toLowerCase())==="eu"?ub:yr.flagsServerUrl),flagConfigPollingIntervalMillis:r.flagConfigPollingIntervalMillis<Fg?Fg:(o=r.flagConfigPollingIntervalMillis)!==null&&o!==void 0?o:yr.flagConfigPollingIntervalMillis}),this.logger=new Tl(this.config.loggerProvider||new Il,t.getLogLevel(r));let u=(a=this.config)===null||a===void 0?void 0:a.internalInstanceNameSuffix;if(this.isWebExperiment=u==="web",this.poller=new Io(()=>ke(this,void 0,void 0,function*(){try{yield this.doFlags()}catch(d){this.logger.info(d)}}),this.config.flagConfigPollingIntervalMillis),this.config.initialVariants)for(let d in this.config.initialVariants)this.config.initialVariants[d]=Kg(this.config.initialVariants[d]);this.config.userProvider&&(this.userProvider=this.config.userProvider),this.config.analyticsProvider&&(this.analyticsProvider=new Cl(this.config.analyticsProvider)),this.config.exposureTrackingProvider&&(this.userSessionExposureTracker=new Rl(this.config.exposureTrackingProvider)),this.integrationManager=new bl(this.config,this);let c=new _l(this.config.httpClient||Vg);this.flagApi=new To(this.apiKey,this.config.flagsServerUrl,c),this.evaluationApi=new yo(this.apiKey,this.config.serverUrl,c);let l,f=u?`${this.config.instanceName}-${String(u)}`:this.config.instanceName;if(this.isWebExperiment){let d=(s=this.config)===null||s===void 0?void 0:s.internalCacheStorage;l=d??new wo}else l=new Tr;this.variants=Q_(this.apiKey,f,l),this.flags=J_(this.apiKey,f,l),this.fetchVariantsOptions=Z_(this.apiKey,f,l);try{this.flags.load(),this.variants.load(),this.fetchVariantsOptions.load()}catch(d){}this.mergeInitialFlagsWithStorage()}start(e){return ke(this,void 0,void 0,function*(){var r;if(!this.isRunning){this.isRunning=!0,this.setUser(e);try{let n=this.doFlags();((r=this.config.fetchOnStart)!==null&&r!==void 0?r:!0)?yield Promise.all([this.fetch(e),n]):yield n}catch(n){if(this.config.throwOnError)throw n}this.config.pollOnStart&&this.poller.start()}})}stop(){this.isRunning&&(this.poller.stop(),this.isRunning=!1)}fetch(){return ke(this,arguments,void 0,function*(e=this.user,r){this.setUser(e||{});try{yield this.fetchInternal(e,this.config.fetchTimeoutMillis,this.config.retryFetchOnFailure,r)}catch(n){if(this.config.throwOnError)throw n;n instanceof _r?this.logger.debug(n):this.logger.error(n)}return this})}variant(e,r){var n,i;if(!this.apiKey)return{value:void 0};let o=this.variantAndSource(e,r);return this.config.automaticExposureTracking&&this.exposureInternal(e,o),this.logger.debug(`[Experiment] variant for ${e} is ${((n=o.variant)===null||n===void 0?void 0:n.key)||((i=o.variant)===null||i===void 0?void 0:i.value)}`),o.variant||{}}exposure(e){let r=this.variantAndSource(e);this.exposureInternal(e,r)}all(){if(!this.apiKey)return{};let e=this.evaluate();for(let r in e){let n=this.flags.get(r);Ng(n)||delete e[r]}return Object.assign(Object.assign(Object.assign({},this.secondaryVariants()),this.sourceVariants()),e)}clear(){this.variants.clear();try{this.variants.store()}catch(e){}}getUser(){var e;if(!this.user)return this.user;if(!((e=this.user)===null||e===void 0)&&e.user_properties){let r=Object.assign({},this.user.user_properties);return Object.assign(Object.assign({},this.user),{user_properties:r})}else return Object.assign({},this.user)}setUser(e){var r;if(!e){this.user=null;return}if(!((r=this.user)===null||r===void 0)&&r.user_properties){let n=Object.assign({},e.user_properties);this.user=Object.assign(Object.assign({},e),{user_properties:n})}else this.user=Object.assign({},e)}getUserProvider(){return this.userProvider}setUserProvider(e){return this.userProvider=e,this}mergeInitialFlagsWithStorage(){this.config.initialFlags&&JSON.parse(this.config.initialFlags).forEac
11h(r=>{this.flags.get(r.key)||this.flags.put(r.key,r)})}evaluate(e){let r=this.addContext(this.user),n=dl(this.flags.getAll(),e),i=Ug(r),o=this.engine.evaluate(i,n),a={};for(let s of Object.keys(o))a[s]=Mg(o[s]);return a}getEvaluationTraces(e){let r=this.addContext(this.user),n=dl(this.flags.getAll(),e),i=Ug(r),{traces:o}=this.engine.evaluateWithTraces(i,n);return o}variantAndSource(e,r){let n={};this.config.source===kt.LocalStorage?n=this.localStorageVariantAndSource(e,r):this.config.source===kt.InitialVariants&&(n=this.initialVariantsVariantAndSource(e,r));let i=this.flags.get(e);return(Ng(i)||!n.variant&&i)&&(n=this.localEvaluationVariantAndSource(e,i,r)),n}localEvaluationVariantAndSource(e,r,n){var i;let o={},a=this.evaluate([r.key])[e],s=Oe.LocalEvaluation,u=(i=a?.metadata)===null||i===void 0?void 0:i.default;if(!ut(a)&&!u)return{variant:Be(a),source:s,hasDefaultVariant:!1};if(u&&(o={variant:Be(a),source:s,hasDefaultVariant:!0}),!ut(n))return{variant:Be(n),source:Oe.FallbackInline,hasDefaultVariant:o.hasDefaultVariant};let c=this.config.initialVariants[e];if(!ut(c))return{variant:Be(c),source:Oe.SecondaryInitialVariants,hasDefaultVariant:o.hasDefaultVariant};let l=Be(this.config.fallbackVariant),f={variant:l,source:Oe.FallbackConfig,hasDefaultVariant:o.hasDefaultVariant};return gl(l)?o:f}localStorageVariantAndSource(e,r){var n;let i={},o=this.variants.get(e),a=(n=o?.metadata)===null||n===void 0?void 0:n.default;if(!ut(o)&&!a)return{variant:Be(o),source:Oe.LocalStorage,hasDefaultVariant:!1};if(a&&(i={variant:Be(o),source:Oe.LocalStorage,hasDefaultVariant:!0}),!ut(r))return{variant:Be(r),source:Oe.FallbackInline,hasDefaultVariant:i.hasDefaultVariant};let s=this.config.initialVariants[e];if(!ut(s))return{variant:Be(s),source:Oe.SecondaryInitialVariants,hasDefaultVariant:i.hasDefaultVariant};let u=Be(this.config.fallbackVariant),c={variant:u,source:Oe.FallbackConfig,hasDefaultVariant:i.hasDefaultVariant};return gl(u)?i:c}initialVariantsVariantAndSource(e,r){var n;let i={},o=this.config.initialVariants[e];if(!ut(o))return{variant:Be(o),source:Oe.InitialVariants,hasDefaultVariant:!1};let a=this.variants.get(e),s=(n=a?.metadata)===null||n===void 0?void 0:n.default;if(!ut(a)&&!s)return{variant:Be(a),source:Oe.LocalStorage,hasDefaultVariant:!1};if(s&&(i={variant:Be(a),source:Oe.LocalStorage,hasDefaultVariant:!0}),!ut(r))return{variant:Be(r),source:Oe.FallbackInline,hasDefaultVariant:i.hasDefaultVariant};let u=Be(this.config.fallbackVariant),c={variant:u,source:Oe.FallbackConfig,hasDefaultVariant:i.hasDefaultVariant};return gl(u)?i:c}fetchInternal(e,r,n,i){return ke(this,void 0,void 0,function*(){var o;if(!this.apiKey)throw Error("Experiment API key is empty");
11this.logger.debug(`[Experiment] Fetch all: retry=${String(n)}`),n&&this.stopRetries();try{let a=yield this.doFetch(e,r,Object.assign({trackingOption:(o=this.fetchVariantsOptions.get())===null||o===void 0?void 0:o.trackingOption},i));return yield this.storeVariants(a,i),a}catch(a){throw n&&this.shouldRetryFetch(a)&&this.startRetries(e,i),a}})}setTracksAssignment(e){return ke(this,void 0,void 0,function*(){this.fetchVariantsOptions.put(Object.assign(Object.assign({},this.fetchVariantsOptions.get()||{}),{trackingOption:e?"track":"no-track"})),this.fetchVariantsOptions.store()})}cleanUserPropsForFetch(e){let r=Object.assign({},e);return delete r.cookie,r}doFetch(e,r,n){return ke(this,void 0,void 0,function*(){e=yield this.addContextOrWait(e),e=this.cleanUserPropsForFetch(e),this.logger.debug("[Experiment] Fetch variants for user: ",e);let i=yield this.evaluationApi.getVariants(e,Object.assign({timeoutMillis:r},n)),o={};for(let a of Object.keys(i))o[a]=Mg(i[a]);return this.logger.debug("[Experiment] Received variants: ",o),o})}doFlags(){return ke(this,void 0,void 0,function*(){try{let e;this.isWebExperiment&&(e=yield this.addContextOrWait(this.getUser()));let r=yield this.flagApi.getFlags({libraryName:"experiment-js-client",libraryVersion:kg,timeoutMillis:this.config.fetchTimeoutMillis,deliveryMethod:this.isWebExperiment?"web":void 0,user:e?.user_id||e?.device_id?{user_id:e?.user_id,device_id:e?.device_id}:void 0});this.flags.clear(),this.flags.putAll(r)}catch(e){if(e instanceof _r){if(this.logger.debug(e),this.config.throwOnError)throw e}else throw e}try{this.flags.store()}catch(e){}this.mergeInitialFlagsWithStorage()})}storeVariants(e,r){return ke(this,void 0,void 0,function*(){let n=r&&r.flagKeys?r.flagKeys:[];n.length===0&&this.variants.clear();for(let i in e)n=n.filter(o=>o!==i),this.variants.put(i,e[i]);for(let i of n)this.variants.remove(i);try{this.variants.store()}catch(i){}this.logger.debug("[Experiment] Stored variants: ",e)})}startRetries(e,r){return ke(this,void 0,void 0,function*(){this.logger.debug("[Experiment] Retry fetch"),this.retriesBackoff=new Al(nb,ib,ob,ab),this.retriesBackoff.start(()=>ke(this,void 0,void 0,function*(){yield this.fetchInternal(e,rb,!1,r)}))})}stopRetries(){this.retriesBackoff&&this.retriesBackoff.cancel()}addContext(e){var r;let n=(r=this.userProvider)===null||r===void 0?void 0:r.getUser(),i=this.integrationManager.getUser(),o=Object.assign(Object.assign(Object.assign({},n?.user_properties),i.user_properties),e?.user_properties);return Object.assign(Object.assign(Object.assign(Object.assign({library:`experiment-js-client/${kg}`},n),i),e),{user_properties:o})}addContextOrWait(e){return ke(this,void 0,void 0,function*(){return yield this.integrationManager.ready(),this.addContext(e)})}sourceVariants(){if(this.config.source==kt.LocalStorage)return this.variants.getAll();if(this.config.source==kt.InitialVariants)return this.config.initialVariants}secondaryVariants(){if(this.config.source==kt.LocalStorage)return this.config.initialVariants;if(this.config.source==kt.InitialVariants)return this.variants.getAll()}exposureInternal(e,r){var n,i,o,a,s,u,c,l,f;if(!((o=(i=(n=r.variant)===null||n===void 0?void 0:n.metadata)===null||i===void 0?void 0:i.trackExposure)!==null&&o!==void 0?o:!0))return;this.legacyExposureInternal(e,r.variant,r.source);let v={flag_key:e},p=Og(r.source);if(p&&!r.hasDefaultVariant)return;!((a=r.variant)===null||a===void 0)&&a.expKey&&(v.experiment_key=(s=r.variant)===null||s===void 0?void 0:s.expKey);let h=(u=r.variant)===null||u===void 0?void 0:u.metadata;if(!p&&!h?.default&&(!((c=r.variant)===null||c===void 0)&&c.key?v.variant=r.variant.key:!((l=r.variant)===null||l===void 0)&&l.value&&(v.variant=r.variant.value)),h&&(v.metadata=h),this.isWebExperiment&&(v.time=Date.now()),this.isWebExperiment){let m=De();if(m?.location)try{let E=m.location.href;v.metadata.url=E.split("?")[0]||""}catch(E){}}let g=this.addContext(this.getUser());(f=this.userSessionExposureTracker)===null||f===void 0||f.track(v,g),this.integrationManager.track(v,g)}legacyExposureInternal(e,r,n){var i,o,a,s,u;if(this.analyticsProvider){let c=this.addContext(this.getUser()),l=eb(c,e,r,n);Og(n)||!r?.value?(o=(i=this.analyticsProvider)===null||i===void 0?void 0:i.unsetUserProperty)===null||o===void 0||o.call(i,l):r?.value&&((s=(a=this.analyticsProvider)===null||a===void 0?void 0:a.setUserProperty)===null||s===void 0||s.call(a,l),(u=this.analyticsProvider)===null||u===void 0||u.track(l))}}static getLogLevel(e){var r;return e.debug===!0?gt.Debug:(r=e.logLevel)!==null&&r!==void 0?r:gt.Error}shouldRetryFetch(e){return e instanceof xn?e.statusCode<400||e.statusCode>=500||e.statusCode===429:!0}addPlugin(e){e.type==="integration"&&this.integrationManager.setIntegration(e)}},Ll=class{constructor(e,r){var n,i,o;this.globalScope=De(),this.userAgent=typeof((n=this.globalScope)===null||n===void 0?void 0:n.navigator)<"u"?(i=this.globalScope)===null||i===void 0?void 0:i.navigator.userAgent:void 0,this.ua=new Bg.UAParser(this.userAgent).getResult(),this.localStorage=new Tr,this.sessionStorage=new wo,this.userProvider=e,this.apiKey=r,this.storageKey=`EXP_${(o=this.apiKey)===null||o===void 0?void 0:o.slice(0,10)}_DEFAULT_USER_PROVIDER`}getUser(){var e,r,n,i,o;let a=((e=this.userProvider)===null||e===void 0?void 0:e.getUser())||{};return Object.assign({language:this.getLanguage(),platform:"Web",os:this.getOs(this.ua),device_model:this.getDeviceModel(this.ua),device_category:(n=(r=this.ua.device)===null||r===void 0?void 0:r.type)!==null&&n!==void 0?n:"desktop",referring_url:(o=(i=this.globalScope)===null||i===void 0?void 0:i.document)===null||o===void 0?void 0:o.referrer.replace(/\/$/,""),cookie
11:this.getCookie(),browser:this.getBrowser(this.ua),landing_url:this.getLandingUrl(),first_seen:this.getFirstSeen(),url_param:this.getUrlParam(),user_agent:this.userAgent},a)}getLanguage(){return typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]||navigator.language)||""}getOs(e){var r,n;return[(r=e.browser)===null||r===void 0?void 0:r.name,(n=e.browser)===null||n===void 0?void 0:n.major].filter(i=>i!=null).join(" ")}getDeviceModel(e){var r;return(r=e.os)===null||r===void 0?void 0:r.name}getBrowser(e){var r;let n=(r=e.browser)===null||r===void 0?void 0:r.name;return n?.includes("Chrom")&&(n="Chrome"),n?.includes("Firefox")&&(n="Firefox"),n?.includes("Safari")&&(n="Safari"),n?.includes("Edge")&&(n="Edge"),n?.includes("Opera")&&(n="Opera"),n}getCookie(){var e,r,n,i,o;if(!((r=(e=this.globalScope)===null||e===void 0?void 0:e.document)===null||r===void 0)&&r.cookie)return Object.fromEntries((o=(i=(n=this.globalScope)===null||n===void 0?void 0:n.document)===null||i===void 0?void 0:i.cookie)===null||o===void 0?void 0:o.split("; ").map(a=>a.split("=")))}getLandingUrl(){var e,r;try{let n=JSON.parse(this.sessionStorage.get(this.storageKey)||"{}");return n.landing_url||(n.landing_url=(r=(e=this.globalScope)===null||e===void 0?void 0:e.location)===null||r===void 0?void 0:r.href.replace(/\/$/,""),this.sessionStorage.put(this.storageKey,JSON.stringify(n))),n.landing_url}catch(n){return}}getFirstSeen(){try{let e=JSON.parse(this.localStorage.get(this.storageKey)||"{}");return e.first_seen||(e.first_seen=(Date.now()/1e3).toString(),this.localStorage.put(this.storageKey,JSON.stringify(e))),e.first_seen}catch(e){return}}getUrlParam(){var e;if(!this.globalScope)return;let r={};try{let n=new URL(this.globalScope.location.href);for(let[i,o]of n.searchParams)r[i]=[...(e=r[i])!==null&&e!==void 0?e:[],...o.split(",")]}catch(n){return}return Object.entries(r).reduce((n,[i,o])=>(n[i]=o.length==1?o[0]:o,n),{})}},ml,Cn=De();Cn&&(Cn.experimentInstances={});var Gg=(ml=Cn?.experimentInstances)!==null&&ml!==void 0?ml:{};var Hg=(t,e)=>db(t,e,()=>new El(t,Yt.getInstance(Wg(e)),1e4)),Wg=t=>t?.instanceName||yr.instanceName,lb=(t,e)=>{let r=Wg(e),n=e?.internalInstanceNameSuffix;return n?`${r}.${t}.${String(n)}`:`${r}.${t}`},cb=(t,e)=>new wl(t,Object.assign(Object.assign({},e),{userProvider:new Ll(e?.userProvider,t)})),db=(t,e,r)=>{let n=lb(t,e),i=Gg[n];return i||(i=cb(t,e),r&&i.addPlugin(r()),Gg[n]=i,i)};var Ir=(function(){function t(e){this.name=t.pluginName,this.config=e}return t.prototype.setup=function(e,r){var n,i;return y(this,void 0,void 0,function(){var o;return b(this,function(a){return o=((n=this.config)===null||n===void 0?void 0:n.instanceName)!==void 0||e.instanceName===void 0?this.config:T(T({},this.config),{instanceName:e.instanceName}),this.experiment=Hg(((i=this.config)===null||i===void 0?void 0:i.deploymentKey)||e.apiKey,o),[2]})})},t.pluginName="@amplitude/experiment-analytics-plugin",t})();var Dl=function(t){return new Ir(t)};var fb=(function(){function t(){}return t.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:vb(),platform:"Web",os:void 0,deviceModel:void 0}},t})(),vb=function(){return typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},pb=(function(){function t(){this.queue=[]}return t.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},t.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(r){e(r)}),this.queue=[])},t})(),Nt=function(){return Nt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Nt.apply(this,arguments)};function Lo(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qg(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){a={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}var Po=function(t,e){var r,n,i=["string","number","boolean","undefined"],o=typeof t,a=typeof e;if(o!==a)return!1;try{for(var s=Lo(i),u=s.next();!u.done;u=s.next()){var c=u.value;if(c===o)return t===e}}catch(g){r={error:g}}finally{try{u&&!u.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}if(t==null&&e==null)return!0;
11if(t==null||e==null||t.length!==e.length)return!1;var l=Array.isArray(t),f=Array.isArray(e);if(l!==f)return!1;if(l&&f){for(var d=0;d<t.length;d++)if(!Po(t[d],e[d]))return!1}else{var v=Object.keys(t).sort(),p=Object.keys(e).sort();if(!Po(v,p))return!1;var h=!0;return Object.keys(t).forEach(function(g){Po(t[g],e[g])||(h=!1)}),h}return!0},hb="$set",gb="$unset",mb="$clearAll";Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),r=e.length,n=new Array(r);r--;)n[r]=[e[r],t[e[r]]];return n});var Eb=(function(){function t(){this.identity={userProperties:{}},this.listeners=new Set}return t.prototype.editIdentity=function(){var e=this,r=Nt({},this.identity.userProperties),n=Nt(Nt({},this.identity),{userProperties:r});return{setUserId:function(i){return n.userId=i,this},setDeviceId:function(i){return n.deviceId=i,this},setUserProperties:function(i){return n.userProperties=i,this},setOptOut:function(i){return n.optOut=i,this},updateUserProperties:function(i){var o,a,s,u,c,l,f=n.userProperties||{};try{for(var d=Lo(Object.entries(i)),v=d.next();!v.done;v=d.next()){var p=qg(v.value,2),h=p[0],g=p[1];switch(h){case hb:try{for(var m=(s=void 0,Lo(Object.entries(g))),E=m.next();!E.done;E=m.next()){var _=qg(E.value,2),S=_[0],x=_[1];f[S]=x}}catch(D){s={error:D}}finally{try{E&&!E.done&&(u=m.return)&&u.call(m)}finally{if(s)throw s.error}}break;case gb:try{for(var I=(c=void 0,Lo(Object.keys(g))),A=I.next();!A.done;A=I.next()){var S=A.value;delete f[S]}}catch(D){c={error:D}}finally{try{A&&!A.done&&(l=I.return)&&l.call(I)}finally{if(c)throw c.error}}break;case mb:f={};break}}}catch(D){o={error:D}}finally{try{v&&!v.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}return n.userProperties=f,this},commit:function(){return e.setIdentity(n),this}}},t.prototype.getIdentity=function(){return Nt({},this.identity)},t.prototype.setIdentity=function(e){var r=Nt({},this.identity);this.identity=Nt({},e),Po(r,this.identity)||this.listeners.forEach(function(n){n(e)})},t.prototype.addIdentityListener=function(e){this.listeners.add(e)},t.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},t})(),Rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:self,_b=(function(){function t(){this.identityStore=new Eb,this.eventBridge=new pb,this.applicationContextProvider=new fb}return t.getInstance=function(e){return Rn.analyticsConnectorInstances||(Rn.analyticsConnectorInstances={}),Rn.analyticsConnectorInstances[e]||(Rn.analyticsConnectorInstances[e]=new t),Rn.analyticsConnectorInstances[e]},t})(),Xg=["boot"],bb="$default_instance",Ol=Symbol.for("amplitude-engagement-plugin-caller");function Sb(t){var e,r,n,i,o,a,s,u,c,l,f;let d=typeof window<"u"?window.engagement:void 0,v=!1,p={_q:(e=d?._q)!=null?e:[],_configuration:{apiKey:(n=(r=d?._configuration)==null?void 0:r.apiKey)!=null?n:"",serverUrl:(i=d?._configuration)==null?void 0:i.serverUrl,chatUrl:(o=d?._configuration)==null?void 0:o.chatUrl,mediaUrl:(a=d?._configuration)==null?void 0:a.mediaUrl,serverZone:(u=(s=d?._configuration)==null?void 0:s.serverZone)!=null?u:"US",autoRefreshIntervalSeconds:(c=d?._configuration)==null?void 0:c.autoRefreshIntervalSeconds,integrations:(l=d?._configuration)==null?void 0:l.integrations,options:rt({},(f=d?._configuration)==null?void 0:f.options)},init(g,m){var E,_,S,x;if(p._configuration.apiKey){console.log("Engagement SDK has already been initialized. Ignoring additional init call.");return}if(m?.skip===!0){console.log("Engagement SDK init skipped via `skip: true`. The SDK bundle will not be loaded."),v=!0;return}if(v&&(p._q.length=0),v=!1,m!=null&&m.useEngagementDomain){let U=((E=m.serverZone)!=null?E:p._configuration.serverZone)==="EU",R="amplitudeengagement.com";m.serverUrl||(m.serverUrl=U?`https://gs.eu.${R}`:`https://gs.${R}`),m.chatUrl||(m.chatUrl=U?`https://houston-chat.eu.${R}`:`https://houston-chat.${R}`),m.mediaUrl||(m.mediaUrl=U?`https://engagement-static.eu.${R}`:`https://engagement-static.${R}`),m.cdnUrl||(m.cdnUrl=U?`https://cdn.eu.${R}`:`https://cdn.${R}`)}p._configuration=Oo(rt(rt({},p._configuration),m),{apiKey:g,options:rt(rt({splitting:!0},p._configuration.options),m?.options)}),(S=(_=p._configuration)==null?void 0:_.options)!=null&&S.logger&&p._configuration.options.logger.enable((x=p._configuration.options.logLevel)!=null?x:2);let I;if(m!=null&&m.cdnUrl)p._configuration.options.splitting?I=`${m.cdnUrl}/engagement-browser/prod/split/index.js`:I=m.cdnUrl+"/engagement-browser/prod/index.min.js.gz";else{let U=p._configuration.serverZone==="EU"?"https://cdn.eu.amplitude.com":"https://cdn.amplitude.com";p._configuration.options.splitting?I=`${U}/engagement-browser/prod/split/index.js`:I=`${U}/engagement-browser/prod/index.min.js.gz`}let A=null,D=()=>
11{if(v=!0,A&&(clearTimeout(A),A=null),p._q&&p._q.length>0)for(console.warn(`Engagement SDK failed to load within ${k}ms. Resolving pending calls gracefully.`);p._q.length>0;){let U=p._q.shift();if(!U)continue;let R=U[0],O=Xg.includes(R);if(console.warn(`Engagement SDK method '${R}' still in queue (isAsyncMethod=${O}); attempting to resolve as no-op.`),O&&U[1]instanceof Function&&U[2]instanceof Function){let P=U[1];console.warn(`Engagement SDK method '${R}' resolved as no-op due to script loading failure`),P(void 0)}}};t(I,p._configuration.options.splitting?"module":void 0,m?.nonce,D);let k=1e4;A=setTimeout(()=>{D()},k)},plugin(g){let m=p.init,E=g?.token,_=g?.skip===!0,S=(I,A,D)=>{let k=D.getIdentity(),U=typeof E=="function"?E():E;return rt({user_id:I.getUserId(),device_id:I.getDeviceId(),version:A.appVersion,user_properties:k.userProperties,getSessionId:I.getSessionId},U?{token:U}:{})};return{name:"@amplitude/engagement-browser",type:"enrichment",setup(I,A){return Ar(this,null,function*(){var D;if(_){m(I.apiKey,{skip:!0});return}let k=(D=I.instanceName)!=null?D:bb,U=_b.getInstance(k).identityStore;p._configuration._installedViaPlugin=!0,m(I.apiKey,Oo(rt({serverZone:I.serverZone},g),{options:rt({logLevel:I.logLevel,logger:I.loggerProvider},g?.options)}));let R=[{track:O=>{A.track(O)}}];yield window.engagement.boot({user:()=>S(A,I,U),integrations:R},Ol),U.addIdentityListener(O=>{var P,N,G,M;if(!((P=window.engagement)!=null&&P._.user)||!((N=window.engagement)!=null&&N._analytics.hasBooted)){console.warn("Engagement SDK not booted. Ignoring identity change.");return}((M=(G=window.engagement)==null?void 0:G._.user)==null?void 0:M.user_id)!==O.userId?(window.engagement.shutdown(Ol),window.engagement.boot({user:()=>S(A,I,U),integrations:R},Ol)):window.engagement._setUserProperties(O.userProperties)})})},execute(I){return Ar(this,null,function*(){return _||window.engagement.forwardEvent(I),I})}}}},h=p;return new Proxy(p,{get:function(g,m){if(m in h)return h[m];if(m!=="then")return m==="gs"||m==="rc"||m==="assistant"?new Proxy({},{get:function(E,_){return function(){let S=Array.from(arguments),x=`${m}.${_}`;S.unshift(x),p._q.push(S)}}}):Xg.includes(m)?function(){let E=Array.prototype.slice.call(arguments);return new Promise((_,S)=>{E.unshift(m,_,S),p._q.push(E),v&&_(void 0)})}:function(){let E=Array.prototype.slice.call(arguments);E.unshift(m),p._q.push(E)}}})}var zg=(t=>(t.Local="https://local.amplitude.com:3010/",t.Staging="https://apps.stag2.amplitude.com/",t.Production="https://app.amplitude.com/",t.ProductionEU="https://app.eu.amplitude.com/",t))(zg||{}),yb=t=>{if(typeof window<"u"&&window.opener)for(let e of Object.values(zg))window.opener.postMessage({message:t},e)};function Tb(t,e,r,n){for(let i of t){let o=document.createElement("script");o.src=i,o.id="engagement-sdk-bundle",r&&o.setAttribute("nonce",r),e&&o.setAttribute("type",e),n&&(o.onerror=n);let a=document.getElementsByTagName("head")[0];a&&a.appendChild(o)}}var Ib=()=>(yb("ENGAGEMENT_SNIPPET"),Sb((t,e,r,n)=>Tb([t||"https://cdn.amplitude.com/engagement-browser/prod/index.min.js.gz"],e,r,n))),jg=Ib();var $g=t=>(typeof window<"u"&&!window.engagement&&(window.engagement=jg),jg.plugin(t));var Yg="1.1.34";var xb="amplitude-ts-unified",Qg=function(){return{type:"enrichment",name:"@amplitude/unified-library-plugin",execute:function(t){var e;return y(this,void 0,void 0,function(){return b(this,function(r){return t.library="".concat(xb,"/").concat(Yg,"-").concat((e=t.library)!==null&&e!==void 0?e:""),[2,t]})})}}};var Jg=(function(t){Ae(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.sessionReplay=function(){return this._sessionReplay},e.prototype.experiment=function(){if(this.config!==void 0){var r=this.plugins(Ir);if(r.length===0){this.config.loggerProvider.debug("".concat(Ir.pluginName," plugin is not found."));return}else{if(r.length===1)return r[0].experiment;this.config.loggerProvider.debug("Multiple instances of ".concat(Ir.pluginName," are found."));return}}},e.prototype.initAll=function(r,n){return y(this,void 0,void 0,function(){var i=this;return b(this,function(o){return this._initAllPromise?[2,this._initAllPromise]:(this._initAllPromise=(function(){return y(i,void 0,void 0,function(){var a,s;return b(this,function(u){switch(u.label){case 0:return a={serverZone:n?.serverZone,instanceName:n?.instanceName},t.prototype.add.call(this,Qg()),[4,t.prototype.init.call(this,r,T(T({}
11,n?.analytics),a)).promise];case 1:return u.sent(),[4,t.prototype.add.call(this,ho(T(T({},n?.sessionReplay),a))).promise];case 2:return u.sent(),[4,t.prototype.add.call(this,Dl(T(T({},n?.experiment),a))).promise];case 3:return u.sent(),s=this.plugin(yn.pluginName),s===void 0?this.config.loggerProvider.debug("".concat(yn.pluginName," plugin is not found.")):this._sessionReplay=s.sessionReplay,[4,t.prototype.add.call(this,$g(T(T({},n?.engagement),a))).promise];case 4:return u.sent(),[2]}})})})().finally(function(){i._initAllPromise=void 0}),[2,this._initAllPromise])})})},e.prototype.init=function(r,n,i){r===void 0&&(r="");var o=t.prototype.init.call(this,r,n,i);return o},e})(fn);var kl=(function(t){return t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Verbose=3]="Verbose",t[t.Debug=4]="Debug",t})(kl||{});var Ab=function(t){t===void 0&&(t=0);var e=new Error().stack||"";return e.split(` 12`).slice(2+t).map(function(r){return r.trim()})},ve=function(t){return function(){var e=T({},t.config),r=e.loggerProvider,n=e.logLevel;return{logger:r,logLevel:n}}},Cb=function(t,e){var r,n;e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,"");try{for(var i=C(e.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(a in t)t=t[a];else return}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t},pe=function(t,e){return function(){var r,n,i={};try{for(var o=C(e),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=Cb(t,s)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}},he=function(t,e,r,n,i){return i===void 0&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=r(),u=s.logger,c=s.logLevel;if(c&&c<kl.Debug||!c||!u)return t.apply(i,o);var l={type:"invoke public method",name:e,args:o,stacktrace:Ab(1),time:{start:new Date().toISOString()},states:{}};n&&l.states&&(l.states.before=n());var f=t.apply(i,o);return f&&f.promise?f.promise.then(function(){n&&l.states&&(l.states.after=n()),l.time&&(l.time.end=new Date().toISOString()),u.debug(JSON.stringify(l,null,2))}):(n&&l.states&&(l.states.after=n()),l.time&&(l.time.end=new Date().toISOString()),u.debug(JSON.stringify(l,null,2))),f}};var Zg=function(){var t=new Jg;return{_setDiagnosticsSampleRate:he(t._setDiagnosticsSampleRate.bind(t),"_setDiagnosticsSampleRate",ve(t),pe(t,["config"])),experiment:he(t.experiment.bind(t),"experiment",ve(t),pe(t,["config"])),sessionReplay:he(t.sessionReplay.bind(t),"sessionReplay",ve(t),pe(t,["config"])),initAll:he(t.initAll.bind(t),"initAll",ve(t),pe(t,["config"])),init:he(t.init.bind(t),"init",ve(t),pe(t,["config"])),add:he(t.add.bind(t),"add",ve(t),pe(t,["config.apiKey","timeline.plugins"])),remove:he(t.remove.bind(t),"remove",ve(t),pe(t,["config.apiKey","timeline.plugins"])),track:he(t.track.bind(t),"track",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),logEvent:he(t.logEvent.bind(t),"logEvent",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),identify:he(t.identify.bind(t),"identify",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),groupIdentify:he(t.groupIdentify.bind(t),"groupIdentify",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),setGroup:he(t.setGroup.bind(t),"setGroup",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),revenue:he(t.revenue.bind(t),"revenue",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),flush:he(t.flush.bind(t),"flush",ve(t),pe(t,["config.apiKey","timeline.queue.length"])),getUserId:he(t.getUserId.bind(t),"getUserId",ve(t),pe(t,["config","config.userId"])),setUserId:he(t.setUserId.bind(t),"setUserId",ve(t),pe(t,["config","config.userId"])),getDeviceId:he(t.getDeviceId.bind(t),"getDeviceId",ve(t),pe(t,["config","config.deviceId"])),setDeviceId:he(t.setDeviceId.bind(t),"setDeviceId",ve(t),pe(t,["config","config.deviceId"])),reset:he(t.reset.bind(t),"reset",ve(t),pe(t,["config","config.userId","config.deviceId"])),getSessionId:he(t.getSessionId.bind(t),"getSessionId",ve(t),pe(t,["config"])),setSessionId:he(t.setSessionId.bind(t),"setSessionId",ve(t),pe(t,["config"])),extendSession:he(t.extendSession.bind(t),"extendSession",ve(t),pe(t,["config"])),setOptOut:he(t.
12setOptOut.bind(t),"setOptOut",ve(t),pe(t,["config"])),getOptOut:he(t.getOptOut.bind(t),"getOptOut",ve(t),pe(t,["config"])),setTransport:he(t.setTransport.bind(t),"setTransport",ve(t),pe(t,["config"])),getIdentity:he(t.getIdentity.bind(t),"getIdentity",ve(t),pe(t,["config"])),setIdentity:he(t.setIdentity.bind(t),"setIdentity",ve(t),pe(t,["config","config.userId","config.deviceId"]))}},_e=Zg();var aU=_e._setDiagnosticsSampleRate,sU=_e.initAll,uU=_e.experiment,lU=_e.sessionReplay,cU=_e.add,dU=_e.extendSession,fU=_e.flush,vU=_e.getDeviceId,pU=_e.getIdentity,hU=_e.getOptOut,gU=_e.getSessionId,mU=_e.getUserId,EU=_e.groupIdentify,_U=_e.identify,bU=_e.logEvent,SU=_e.remove,yU=_e.reset,TU=_e.revenue,IU=_e.setDeviceId,xU=_e.setGroup,AU=_e.setIdentity,CU=_e.setOptOut,RU=_e.setSessionId,wU=_e.setTransport,LU=_e.setUserId,PU=_e.track;export{ot as Identify,wr as Revenue,Ga as Types,aU as _setDiagnosticsSampleRate,cU as add,Zg as createInstance,uU as experiment,dU as extendSession,fU as flush,vU as getDeviceId,pU as getIdentity,hU as getOptOut,gU as getSessionId,mU as getUserId,EU as groupIdentify,_U as identify,sU as initAll,bU as logEvent,SU as remove,yU as reset,TU as revenue,lU as sessionReplay,IU as setDeviceId,xU as setGroup,AU as setIdentity,CU as setOptOut,RU as setSessionId,wU as setTransport,LU as setUserId,PU as track};
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.