1import{AnalyticsConnector as He}from"./analytics-connector.zaoq1t0C.js";import{uaParserExports as Be}from"./ua-parser-js.Dstv6SXd.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="43654a8a-6312-4fae-a3c7-aba7557255e5",r._sentryDebugIdIdentifier="sentry-dbid-43654a8a-6312-4fae-a3c7-aba7557255e5")}catch{}})();{var x=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};x._sentryModuleMetadata=x._sentryModuleMetadata||{},x._sentryModuleMetadata[new x.Error().stack]=Object.assign({},x._sentryModuleMetadata[new x.Error().stack],{dsn:"https://[email protected]/6688884"})}const u={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"},Qe=r=>{const e=[];let t=0;for(let i=0;i<r.length;i++){let s=r.charCodeAt(i);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)==55296&&i+1<r.length&&(r.charCodeAt(i+1)&64512)==56320?(s=65536+((s&1023)<<10)+(r.charCodeAt(++i)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return Uint8Array.from(e)},F=-862048943,V=461845907,D=15,$e=13,Ge=5,Je=-430675100,qe=(r,e=0)=>{const t=Qe(r),i=t.length,s=i>>2;let n=e;for(let c=0;c<s;c++){const d=c<<2,l=ze(t,d);n=We(l,n)}const a=s<<2;let o=0;switch(i-a){case 3:o^=t[a+2]<<16,o^=t[a+1]<<8,o^=t[a],o=Math.imul(o,F),o=U(o,D),o=Math.imul(o,V),n^=o;break;case 2:o^=t[a+1]<<8,o^=t[a],o=Math.imul(o,F),o=U(o,D),o=Math.imul(o,V),n^=o;break;case 1:o^=t[a],o=Math.imul(o,F),o=U(o,D),o=Math.imul(o,V),n^=o;break}return n^=i,Xe(n)>>>0},We=(r,e)=>{let t=r,i=e;return t=Math.imul(t,F),t=U(t,D),t=Math.imul(t,V),i^=t,i=U(i,$e),i=Math.imul(i,Ge),i+Je|0},Xe=r=>{let e=r;return e^=e>>>16,e=Math.imul(e,-2048144789),e^=e>>>13,e=Math.imul(e,-1028477387),e^=e>>>16,e},U=(r,e,t=32)=>{e>t&&(e=e%t);const i=4294967295<<t-e>>>0,s=(r&i)>>>0>>>t-e>>>0;return(r<<e|s)>>>0},ze=(r,e=0)=>{const t=r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3];return Ze(t)},Ze=r=>(r&-16777216)>>>24|(r&16711680)>>>8|(r&65280)<<8|(r&255)<<24,B=(r,e)=>{if(!(!e||e.length===0)){for(const t of e){if(!t||!r||typeof r!="object")return;r=r[t]}if(r!=null)return r}},Ye="(\\d+)\\.(\\d+)",et="(\\d+)",tt="(-(([-\\w]+\\.?)*))?",it=`^${Ye}(\\.${et}${tt})?$`;class W{constructor(e,t,i,s=void 0){this.major=e,this.minor=t,this.patch=i,this.preRelease=s}static parse(e){if(!e)return;const t=new RegExp(it).exec(e);if(!t)return;const i=Number(t[1]),s=Number(t[2]);if(isNaN(i)||isNaN(s))return;const n=Number(t[4])||0,a=t[5]||void 0;return new W(i,s,n,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}}class rt{evaluate(e,t){const i={},s={context:e,result:i};for(const n of t){const a=this.evaluateFlag(s,n);a&&(i[n.key]=a)}return i}evaluateWithTraces(e,t){const i={},s={},n={context:e,result:i};for(const a of t){const{variant:o,trace:c}=this.evaluateFlagWithTrace(n,a);o&&(i[a.key]=o),s[a.key]=c}return{results:i,traces:s}}evaluateFlag(e,t){let i;for(const s of t.segments)if(i=this.evaluateSegment(e,t,s),i){const n=Object.assign(Object.assign(Object.assign({},t.metadata),s.metadata),i.metadata);i=Object.assign(Object.assign({},i),{metadata:n});break}return i}evaluateFlagWithTrace(e,t){var i,s;const n=[];let a,o,c;for(const l of t.segments){if(!l.conditions){const _=this.bucket(e,l),O=_!==void 0;n.push({segmentMetadata:l.metadata,conditionsPassed:!0,bucketed:O,bucketVariant:_,conditionResult:void 0,matched:O}),!a&&_!==void 0&&(a=t.variants[_],o=l,c=(i=l.metadata)===null||i===void 0?void 0:i.segmentName);continue}const h=[];let f=!1;for(const _ of l.conditions){let O=!0;const N=[];for(const I of _){const Ke=B(e,I.selector),te=this.matchCondition(e,I);if(N.push({propValue:Ke,condition:I,matched:te}),!te){O=!1;break}}if(h.push(N),O){f=!0;break}}let S=!1,T;f&&(T=this.bucket(e,l),S=T!==void 0),n.push({segmentMetadata:l.metadata,conditionsPassed:f,bucketed:S,bucketVariant:T,conditionResult:h,matched:f&&S}
1),f&&T!==void 0&&!a&&(a=t.variants[T],o=l,c=(s=l.metadata)===null||s===void 0?void 0:s.segmentName)}if(a&&o){const l=Object.assign(Object.assign(Object.assign({},t.metadata),o.metadata),a.metadata);a=Object.assign(Object.assign({},a),{metadata:l})}const d={flagKey:t.key,matched:a!==void 0,matchedSegment:c,steps:n};return{variant:a,trace:d}}evaluateSegment(e,t,i){if(!i.conditions){const n=this.bucket(e,i);return n!==void 0?t.variants[n]:void 0}if(this.evaluateConditions(e,i.conditions)){const n=this.bucket(e,i);return n!==void 0?t.variants[n]:void 0}}evaluateConditions(e,t){for(const i of t){let s=!0;for(const n of i)if(s=this.matchCondition(e,n),!s)break;if(s)return!0}return!1}matchCondition(e,t){const i=B(e,t.selector);if(i==null)return this.matchNull(t.op,t.values);{const s=this.coerceStringArray(i);if(this.isSetOperator(t.op))return s?this.matchSet(s,t.op,t.values):!1;if(s)return this.matchStringsNonSet(s,t.op,t.values);{const n=this.coerceString(i);return n!==void 0?this.matchString(n,t.op,t.values):!1}}}getHash(e){return qe(e)}bucket(e,t){if(!t.bucket)return t.variant;const i=this.coerceString(B(e,t.bucket.selector));if(!i||i.length===0)return t.variant;const s=`${t.bucket.salt}/${i}`,n=this.getHash(s),a=n%100,o=Math.floor(n/100);for(const c of t.bucket.allocations){const d=c.range[0],l=c.range[1];if(a>=d&&a<l)for(const h of c.distributions){const f=h.range[0],S=h.range[1];if(o>=f&&o<S)return h.variant}}return t.variant}matchNull(e,t){const i=this.containsNone(t);switch(e){case u.IS:case u.CONTAINS:case u.LESS_THAN:case u.LESS_THAN_EQUALS:case u.GREATER_THAN:case u.GREATER_THAN_EQUALS:case u.VERSION_LESS_THAN:case u.VERSION_LESS_THAN_EQUALS:case u.VERSION_GREATER_THAN:case u.VERSION_GREATER_THAN_EQUALS:case u.SET_IS:case u.SET_CONTAINS:case u.SET_CONTAINS_ANY:return i;case u.IS_NOT:case u.DOES_NOT_CONTAIN:case u.SET_DOES_NOT_CONTAIN:case u.SET_DOES_NOT_CONTAIN_ANY:return!i;default:return!1}}matchSet(e,t,i){switch(t){case u.SET_IS:return this.setEquals(e,i);case u.SET_IS_NOT:return!this.setEquals(e,i);case u.SET_CONTAINS:return this.matchesSetContainsAll(e,i);case u.SET_DOES_NOT_CONTAIN:return!this.matchesSetContainsAll(e,i);case u.SET_CONTAINS_ANY:return this.matchesSetContainsAny(e,i);case u.SET_DOES_NOT_CONTAIN_ANY:return!this.matchesSetContainsAny(e,i);default:return!1}}matchString(e,t,i){switch(t){case u.IS:return this.matchesIs(e,i);case u.IS_NOT:return!this.matchesIs(e,i);case u.CONTAINS:return this.matchesContains(e,i);case u.DOES_NOT_CONTAIN:return!this.matchesContains(e,i);case u.LESS_THAN:case u.LESS_THAN_EQUALS:case u.GREATER_THAN:case u.GREATER_THAN_EQUALS:return this.matchesComparable(e,t,i,s=>this.parseNumber(s),(s,n,a)=>this.comparator(s,n,a));case u.VERSION_LESS_THAN:case u.VERSION_LESS_THAN_EQUALS:case u.VERSION_GREATER_THAN:case u.VERSION_GREATER_THAN_EQUALS:return this.matchesComparable(e,t,i,s=>W.parse(s),(s,n,a)=>this.versionComparator(s,n,a));case u.REGEX_MATCH:return this.matchesRegex(e,i);case u.REGEX_DOES_NOT_MATCH:return!this.matchesRegex(e,i);default:return!1}}matchStringsNonSet(e,t,i){return e.some(s=>this.matchString(s,t,i))}matchesIs(e,t){if(this.containsBooleans(t)){const i=e.toLowerCase();if(i==="true"||i==="false")return t.some(s=>s.toLowerCase()===i)}return t.some(i=>e===i)}matchesContains(e,t){for(const i of t)if(e.toLowerCase().includes(i.toLowerCase()))return!0;return!1}matchesComparable(e,t,i,s,n){const a=s(e),o=i.map(c=>s(c)).filter(c=>c!==void 0);return a===void 0||o.length===0?i.some(c=>this.comparator(e,t,c)):o.some(c=>n(a,t,c))}comparator(e,t,i){switch(t){case u.LESS_THAN:case u.VERSION_LESS_THAN:return e<i;case u.LESS_THAN_EQUALS:case u.VERSION_LESS_THAN_EQUALS:return e<=i;case u.GREATER_THAN:case u.VERSION_GREATER_THAN:return e>i;case u.GREATER_THAN_EQUALS:case u.VERSION_GREATER_THAN_EQUALS:return e>=i;default:return!1}}versionComparator(e,t,i){const s=e.compareTo(i);switch(t){case u.LESS_THAN:case u.VERSION_LESS_THAN:return s<0;case u.LESS_THAN_EQUALS:case u.VERSION_LESS_THAN_EQUALS:return s<=0;case u.GREATER_THAN:case u.VERSION_GREATER_THAN:return s>0;case u.GREATER_THAN_EQUALS:case u.VERSION_GREATER_THAN_EQUALS:return s>=0;default:return!1}}matchesRegex(e,t){return t.some(i=>!!new RegExp(i).exec(e))}containsNone(e){return e.some(t=>t==="(none)")}containsBooleans(e){return e.some(t=>{switch(t.toLowerCase()){case"true":case"false":return!0;default:return!1}})}parseNumber(e){var t;return(t=Number(e))!==null&&t!==void 0?t: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(s=>
1this.coerceString(s)).filter(Boolean);const t=String(e);if(t.startsWith("["))try{const i=JSON.parse(t);return Array.isArray(i)?i.map(s=>this.coerceString(s)).filter(Boolean):void 0}catch{return}}isSetOperator(e){switch(e){case u.SET_IS:case u.SET_IS_NOT:case u.SET_CONTAINS:case u.SET_DOES_NOT_CONTAIN:case u.SET_CONTAINS_ANY:case u.SET_DOES_NOT_CONTAIN_ANY:return!0;default:return!1}}setEquals(e,t){const i=new Set(e),s=new Set(t);return i.size===s.size&&[...s].every(n=>i.has(n))}matchesSetContainsAll(e,t){if(e.length<t.length)return!1;for(const i of t)if(!this.matchesIs(i,e))return!1;return!0}matchesSetContainsAny(e,t){for(const i of t)if(this.matchesIs(i,e))return!0;return!1}}const ie=(r,e)=>{const t=Object.assign({},r),i=[],s=e||Object.keys(t);for(const n of s){const a=pe(n,t);a&&i.push(...a)}return i},pe=(r,e,t=[])=>{const i=e[r];if(i){if(!i.dependencies||i.dependencies.length===0)return delete e[i.key],[i]}else return;t.push(i.key);const s=[];for(const n of i.dependencies){if(t.some(o=>o===n))throw Error(`Detected a cycle between flags ${t.join(", ")}`);const a=pe(n,e,t);a&&s.push(...a)}return s.push(i),t.pop(),delete e[i.key],s};function me(r,e,t,i){function s(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function o(l){try{d(i.next(l))}catch(h){a(h)}}function c(l){try{d(i.throw(l))}catch(h){a(h)}}function d(l){l.done?n(l.value):s(l.value).then(o,c)}d((i=i.apply(r,[])).next())})}const ye="3.7.8",st=ye,w=typeof Buffer=="function",re=typeof TextDecoder=="function"?new TextDecoder:void 0,se=typeof TextEncoder=="function"?new TextEncoder:void 0,nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",R=Array.prototype.slice.call(nt),M=(r=>{let e={};return r.forEach((t,i)=>e[t]=i),e})(R),at=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,p=String.fromCharCode.bind(String),ne=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):r=>new Uint8Array(Array.prototype.slice.call(r,0)),Se=r=>r.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),_e=r=>r.replace(/[^A-Za-z0-9\+\/]/g,""),be=r=>{let e,t,i,s,n="";const a=r.length%3;for(let o=0;o<r.length;){if((t=r.charCodeAt(o++))>255||(i=r.charCodeAt(o++))>255||(s=r.charCodeAt(o++))>255)throw new TypeError("invalid character found");e=t<<16|i<<8|s,n+=R[e>>18&63]+R[e>>12&63]+R[e>>6&63]+R[e&63]}return a?n.slice(0,a-3)+"===".substring(a):n},X=typeof btoa=="function"?r=>btoa(r):w?r=>Buffer.from(r,"binary").toString("base64"):be,G=w?r=>Buffer.from(r).toString("base64"):r=>{let t=[];for(let i=0,s=r.length;i<s;i+=4096)t.push(p.apply(null,r.subarray(i,i+4096)));return X(t.join(""))},j=(r,e=!1)=>e?Se(G(r)):G(r),ot=r=>{if(r.length<2){var e=r.charCodeAt(0);return e<128?r:e<2048?p(192|e>>>6)+p(128|e&63):p(224|e>>>12&15)+p(128|e>>>6&63)+p(128|e&63)}else{var e=65536+(r.charCodeAt(0)-55296)*1024+(r.charCodeAt(1)-56320);return p(240|e>>>18&7)+p(128|e>>>12&63)+p(128|e>>>6&63)+p(128|e&63)}},lt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ee=r=>r.replace(lt,ot),ae=w?r=>Buffer.from(r,"utf8").toString("base64"):se?r=>G(se.encode(r)):r=>X(Ee(r)),C=(r,e=!1)=>e?Se(ae(r)):ae(r),oe=r=>C(r,!0),ct=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,ut=r=>{switch(r.length){case 4:var e=(7&r.charCodeAt(0))<<18|(63&r.charCodeAt(1))<<12|(63&r.charCodeAt(2))<<6|63&r.charCodeAt(3),t=e-65536;return p((t>>>10)+55296)+p((t&1023)+56320);case 3:return p((15&r.charCodeAt(0))<<12|(63&r.charCodeAt(1))<<6|63&r.charCodeAt(2));default:return p((31&r.charCodeAt(0))<<6|63&r.charCodeAt(1))}},Ae=r=>r.replace(ct,ut),Te=r=>{if(r=r.replace(/\s+/g,""),!at.test(r))throw new TypeError("malformed base64.");r+="==".slice(2-(r.length&3));let e,t,i,s=[];for(let n=0;n<r.length;)e=M[r.charAt(n++)]<<18|M[r.charAt(n++)]<<12|(t=M[r.charAt(n++)])<<6|(i=M[r.charAt(n++)]),t===64?s.push(p(e>>16&255)):i===64?s.push(p(e>>16&255,e>>8&255)):s.push(p(e>>16&255,e>>8&255,e&255));return s.join("")},z=typeof atob=="function"?r=>atob(_e(r)):w?r=>Buffer.from(r,"base64").toString("binary"):Te,Oe=w?r=>ne(Buffer.from(r,"base64")):r=>ne(z(r).split("").map(e=>e.charCodeAt(0))),Ne=r=>Oe(Ie(r)),dt=w?r=>Buffer.from(r,"base64").toString("utf8"):re?r=>re.decode(Oe(r)):r=>Ae(z(r)),Ie=r=>_e(r.replace(/[-_]/g,e=>e=="-"?"+":"/")),J=r=>dt(Ie(r)),ht=r=>{if(typeof r!="string")return!1;const e=r.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},xe=r=>({value:r,enumerable:!1,writable:!0,configurable:!0}),ke=function(){const r=(e,t)=>Object.defineProperty(String.prototype,e,xe(t));r("fromBase64",function(){return J(this)}),r("toBase64",function(e){return C(this,e)}),r("toBase64URI",function(){return C(this,!0)}),r("toBase64URL",function(){return C(this,!0)}),r("toUint8Array",function(){return Ne(this)})},Ce=function(){const r=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,xe(t));r("toBase64",function(e){return j(this,e)}),r("toBase64URI",function(){return j(this,!0)}),r("toBase64URL",function(){return j(this,!0)})}
1,ft=()=>{ke(),Ce()},q={version:ye,VERSION:st,atob:z,atobPolyfill:Te,btoa:X,btoaPolyfill:be,fromBase64:J,toBase64:C,encode:C,encodeURI:oe,encodeURL:oe,utob:Ee,btou:Ae,decode:J,isValid:ht,fromUint8Array:j,toUint8Array:Ne,extendString:ke,extendUint8Array:Ce,extendBuiltins:ft};class K extends Error{constructor(e,t){super(t),this.statusCode=e,Object.setPrototypeOf(this,K.prototype)}}class L extends Error{constructor(e){super(e),Object.setPrototypeOf(this,L.prototype)}}class gt{constructor(e,t,i){this.deploymentKey=e,this.serverUrl=t,this.httpClient=i}getVariants(e,t){return me(this,void 0,void 0,function*(){const i=q.encodeURL(JSON.stringify(e)),s={Authorization:`Api-Key ${this.deploymentKey}`,"X-Amp-Exp-User":i};t?.flagKeys&&(s["X-Amp-Exp-Flag-Keys"]=q.encodeURL(JSON.stringify(t.flagKeys))),t?.trackingOption&&(s["X-Amp-Exp-Track"]=t.trackingOption),t?.exposureTrackingOption&&(s["X-Amp-Exp-Exposure-Track"]=t.exposureTrackingOption);const n=new URL(`${this.serverUrl}/sdk/v2/vardata?v=0`);t?.evaluationMode&&n.searchParams.append("eval_mode",t?.evaluationMode),t?.deliveryMethod&&n.searchParams.append("delivery_method",t?.deliveryMethod);const a=yield this.httpClient.request({requestUrl:n.toString(),method:"GET",headers:s,timeoutMillis:t?.timeoutMillis});if(a.status!=200)throw new K(a.status,`Fetch error response: status=${a.status}`);return JSON.parse(a.body)})}}class vt{constructor(e,t,i){this.deploymentKey=e,this.serverUrl=t,this.httpClient=i}getFlags(e){return me(this,void 0,void 0,function*(){const t={Authorization:`Api-Key ${this.deploymentKey}`};e?.libraryName&&e?.libraryVersion&&(t["X-Amp-Exp-Library"]=`${e.libraryName}/${e.libraryVersion}`),e?.user&&(t["X-Amp-Exp-User"]=q.encodeURL(JSON.stringify(e.user)));const i=yield this.httpClient.request({requestUrl:`${this.serverUrl}/sdk/v2/flags`+(e?.deliveryMethod?`?delivery_method=${e.deliveryMethod}`:""),method:"GET",headers:t,timeoutMillis:e?.timeoutMillis});if(i.status!=200)throw Error(`Flags error response: status=${i.status}`);return JSON.parse(i.body).reduce((n,a)=>(n[a.key]=a,n),{})})}}const m=()=>{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},pt=()=>{const r=m();if(r)try{const e="EXP_test";return r.localStorage.setItem(e,e),r.localStorage.removeItem(e),!0}catch{return!1}return!1},we=()=>{var r;return(r=m())===null||r===void 0?void 0:r.localStorage},Re=()=>{var r;return(r=m())===null||r===void 0?void 0:r.sessionStorage},mt=()=>{var r;return(r=m())===null||r===void 0?void 0:r.document},yt=()=>{const r=m();return r?.fetch?r.fetch.bind(r):void 0},Z=()=>{const r=m();return r?.setTimeout?r.setTimeout.bind(r):void 0},St=()=>{const r=m();return r?.clearTimeout?r.clearTimeout.bind(r):void 0},Ue=()=>{const r=m();return r?.setInterval?r.setInterval.bind(r):void 0},Pe=()=>{const r=m();return r?.clearInterval?r.clearInterval.bind(r):void 0};class _t{constructor(e,t){this.poller=void 0,this.action=e,this.ms=t}start(){if(this.poller)return;const e=Ue();e&&(this.poller=e(()=>{this.action()},this.ms),this.action())}stop(){if(!this.poller)return;const e=Pe();e&&e(this.poller),this.poller=void 0}}function v(r,e,t,i){function s(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function o(l){try{d(i.next(l))}catch(h){a(h)}}function c(l){try{d(i.throw(l))}catch(h){a(h)}}function d(l){l.done?n(l.value):s(l.value).then(o,c)}d((i=i.apply(r,e||[])).next())})}const le=(r,e=!1)=>{const t=Y(r,e);let i;const s=mt();if(!s)return;const n=s.cookie.split("; ");for(const a of n){const[o,c]=a.split("=",2);o===t&&(i=decodeURIComponent(c))}if(i)try{if(e){const c=atob(i);return JSON.parse(decodeURIComponent(c))}const a=i.split(".");let o;return a.length>=2&&a[1]&&(o=atob(a[1])),{deviceId:a[0],userId:o}}catch{return}},bt=r=>{const e=Y(r,!0);try{const t=we();if(!t)return;const i=t.getItem(e);if(!i)return;const s=JSON.parse(i);return typeof s!="object"?void 0:s}catch{return}},Et=r=>{const e=Y(r,!0);try{const t=Re();if(!t)return;const i=t.getItem(e);if(!i)return;const s=JSON.parse(i);return typeof s!="object"?void 0:s}catch{return}},Y=(r,e)=>{if(e)return r?.length<10?void 0:`AMP_${r.substring(0,10)}`;if(!(r?.length<6))return`amp_${r.substring(0,6)}`};class At{constructor(e,t,i){this.type="integration",this.apiKey=e,this.identityStore=t.identityStore,this.eventBridge=t.eventBridge,this.contextProvider=t.applicationContextProvider,this.timeoutMillis=i,this.loadPersistedState(),i<=0&&(this.setup=void 0)}setup(e,t){return v(this,void 0,void 0,function*(){return e?.automaticFetchOnAmplitudeIdentityChange&&this.identityStore.addIdentityListener(()=>{t?.fetch()}),this.waitForConnectorIdentity(this.timeoutMillis)})}getUser(){const 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=le(this.apiKey,!0);return e?(this.commitIdentityToConnector(e),!0):(e=le(this.apiKey,!1),e?(this.commitIdentityToConnector(e),!0):(e=bt(this.apiKey),e?(this.commitIdentityToConnector(e),!0):(e=Et(this.apiKey),e?(this.commitIdentityToConnector(e),!0):!1)))}commitIdentityToConnector(e){const t=this.identityStore.editIdentity();t.setDeviceId(e.deviceId),e.userId&&t.setUserId(e.userId),t.commit()}waitForConnectorIdentity(e){return v(this,void 0,void 0,function*(){const t=this.identityStore.getIdentity();if(!t.userId&&!t.deviceId)return Promise.race([new Promise(i=>{const s=()=>{i(),this.identityStore.removeIdentityListener(s)};this.identityStore.addIdentityListener(s)}),new Promise((i,s)=>{const n=Z();if(!n){s("Timed out waiting for Amplitude Analytics SDK to initialize.");return}n(s,e,"Timed out waiting for Amplitude Analytics SDK to initialize.")})])})}}function Tt(r,e){return e=e||{},new Promise(function(t,i){var s=new XMLHttpRequest,n=[],a=[],o={},c=function(){return{ok:(s.status/100|0)==2,statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(JSON.parse(s.responseText))},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:c,headers:{keys:function(){return n},entries:function(){return a},get:function(l){return o[l.toLowerCase()]},has:function(l){return l.toLowerCase()in o}}}};for(var d in s.open(e.method||"get",r,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(l,h,f){n.push(h=h.toLowerCase()),a.push([h,f]),o[h]=o[h]?o[h]+","+f:f}),t(c())},s.onerror=i,s.withCredentials=e.credentials=="include",e.headers)s.setRequestHeader(d,e.headers[d]);s.send(e.body||null)})}const Ot=yt()||Tt,Nt=(r,e)=>e==null||e<=0?r:new Promise(function(t,i){const s=Z();s&&s(function(){i(new L(`Request timeout after ${e} milliseconds`))},e),r.then(t,i)}),It=(r,e,t,i,s)=>Nt(v(void 0,void 0,void 0,function*(){const a=yield Ot(r,{method:e,headers:t,body:i});return{status:a.status,body:yield a.text()}}),s);class xt{constructor(e){this.client=e}request(e){return v(this,void 0,void 0,function*(){return yield this.client.request(e.requestUrl,e.method,e.headers,null,e.timeoutMillis)})}}const Le={request:It};var E;(function(r){r[r.Disable=0]="Disable",r[r.Error=1]="Error",r[r.Warn=2]="Warn",r[r.Info=3]="Info",r[r.Debug=4]="Debug",r[r.Verbose=5]="Verbose"})(E||(E={}));var A;(function(r){r.LocalStorage="localStorage",r.InitialVariants="initialVariants"})(A||(A={}));var g;(function(r){r.LocalStorage="storage",r.InitialVariants="initial",r.SecondaryLocalStorage="secondary-storage",r.SecondaryInitialVariants="secondary-initial",r.FallbackInline="fallback-inline",r.FallbackConfig="fallback-config",r.LocalEvaluation="local-evaluation"})(g||(g={}));const ce=r=>!r||r===g.FallbackInline||r===g.FallbackConfig||r===g.SecondaryInitialVariants,k={debug:!1,logLevel:E.Error,loggerProvider:null,instanceName:"$default_instance",fallbackVariant:{},initialVariants:{},initialFlags:void 0,source:A.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:Le};var ue="1.23.1";const Me=512;class kt{constructor(e,t){var i;this.isReady=new Promise(n=>{this.resolve=n}),this.config=e,this.client=t;const s=(i=e.instanceName)!==null&&i!==void 0?i:k.instanceName;this.queue=new wt(s,Me,e.internalPersistenceAllowed),this.cache=new Ct
1(s,e.internalPersistenceAllowed)}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,t){if(this.cache.shouldTrack(e,t)){const i=this.getExposureEvent(e);this.queue.push(i)}}getExposureEvent(e){var t,i,s;let n={eventType:"$exposure",eventProperties:e};return!((t=e.metadata)===null||t===void 0)&&t.exposureEvent?n={eventType:(i=e.metadata)===null||i===void 0?void 0:i.exposureEvent,eventProperties:e}:((s=e.metadata)===null||s===void 0?void 0:s.deliveryMethod)==="web"&&(n={eventType:"$impression",eventProperties:e}),n}}class Ct{constructor(e,t){this.persistenceAllowed=t,this.clearStoredOnReopen=!1,this.hasGatedEntries=!1,this.inMemoryCache={},this.identity={},this.storageKey=`EXP_sent_v3_${e}`}isGated(){return this.persistenceAllowed!==void 0&&!this.persistenceAllowed()}usableStorage(){if(this.isGated())return;this.isSessionStorageAvailable===void 0&&(this.isSessionStorageAvailable=Rt());const e=Re();if(!(!this.isSessionStorageAvailable||!e))return this.clearStoredOnReopen&&(this.clearStoredOnReopen=!1,e.removeItem(this.storageKey)),e}shouldTrack(e,t){var i,s;if(((i=e.metadata)===null||i===void 0?void 0:i.deliveryMethod)==="web")return!0;const n={userId:t?.user_id,deviceId:t?.device_id};this.identityEquals(this.identity,n)||this.clearCache(),this.identity=n,this.loadCache();const a=e.flag_key in this.inMemoryCache,o=this.inMemoryCache[e.flag_key],c=(s=e.variant)!==null&&s!==void 0?s:null,d=o??null;let l=!1;return(!a||d!==c)&&(l=!0,this.inMemoryCache[e.flag_key]=c,this.isGated()&&(this.hasGatedEntries=!0)),this.storeCache(),l}clearCache(){this.inMemoryCache={},this.hasGatedEntries=!1;const e=this.usableStorage();e?e.removeItem(this.storageKey):this.isGated()&&(this.clearStoredOnReopen=!0)}identityEquals(e,t){return e.userId&&t.userId?e.userId===t.userId:!e.userId&&!t.userId?e.deviceId===t.deviceId:!1}loadCache(){const e=this.usableStorage();if(e){const t=e.getItem(this.storageKey),i=t?JSON.parse(t):{};this.hasGatedEntries?(this.inMemoryCache=Object.assign(Object.assign({},i),this.inMemoryCache),this.hasGatedEntries=!1):this.inMemoryCache=i}}storeCache(){const e=this.usableStorage();if(e)try{e.setItem(this.storageKey,JSON.stringify(this.inMemoryCache))}catch{}}}class wt{constructor(e,t=Me,i){this.persistenceAllowed=i,this.inMemoryQueue=[],this.holdsGatedEvents=!1,this.storageKey=`EXP_unsent_${e}`,this.maxQueueSize=t}push(e){this.loadQueue(),this.inMemoryQueue.push(e),this.canPersist()||(this.holdsGatedEvents=!0),this.flush(),this.storeQueue()}setTracker(e){this.tracker=e;const t=Ue();t&&(this.poller=t(()=>{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{break}if(this.inMemoryQueue=this.inMemoryQueue.slice(e),this.inMemoryQueue.length===0&&this.poller){const t=Pe();t&&t(this.poller),this.poller=void 0}}canPersist(){return this.persistenceAllowed?this.persistenceAllowed():!0}usableStorage(){if(!this.canPersist())return;this.isLocalStorageAvailable===void 0&&(this.isLocalStorageAvailable=pt());const e=we();return this.isLocalStorageAvailable&&e?e:void 0}loadQueue(){const e=this.usableStorage();if(e){const t=e.getItem(this.storageKey),i=t?JSON.parse(t):[];this.holdsGatedEvents?(this.inMemoryQueue=[...i,...this.inMemoryQueue],this.holdsGatedEvents=!1):this.inMemoryQueue=i}}storeQueue(){const e=this.usableStorage();if(e){if(this.inMemoryQueue.length===0){e.removeItem(this.storageKey);return}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()}}const Rt=()=>{const r=m();if(r)try{const e="EXP_test";return r.sessionStorage.setItem(e,e),r.sessionStorage.removeItem(e),!0}catch{return!1}return!1};class Ut{constructor(e,t=E.Error){this.logger=e,this.logLevel=t}error(e,...t){this.logLevel>=E.Error&&this.logger.error(e,...t)}warn(e,...t){this.logLevel>=E.Warn&&this.logger.warn(e,...t)}info(e,...t){this.logLevel>=E.Info&&this.logger.info(e,...t)}debug(e,...t){this.logLevel>=E.Debug&&this.logger.debug(e,...t)}verbose(e,...t){this.logLevel>=E.Verbose&&this.logger.verbose(e,...t)}}class Pt{error(e,...t){console.error(e,...t)}warn(e,...t){console.warn(e,...t)}info(e,...t){console.info(e,...t)}debug(e,...t){console.debug(e,...t)}verbose(e,...t){console.debug(e,...t)}}class H{constructor(){this.globalScope=m()}get(e){var t;return(t=this.globalScope)===null||t===void 0?void 0:t.localStorage.getItem(e)}put(e,t){var i;(i=this.globalScope)===null||i===void 0||i.localStorage.setItem(e,t)}delete(e){var t;(t=this.globalScope)===null||t===void 0||t.localStorage.removeItem(e)}}const Lt=(r,e,t)=>{const i=r.substring(r.length-6),s=`amp-exp-${e}-${i}`;return new Fe(s,t,Ve)},Mt=(r,e,t=new H)=>{const i=r.substring(r.length-6),s=`amp-exp-${e}-${i}-flags`;return new Fe(s,t)},Ft=(r,e,t=new H)=>{const i=r.substring(r.length-6),s=`amp-exp-${e}-${i}-variants-options`;return new Vt(s,t)};class Vt{constructor(e,t){this.namespace=e,this.storage=t}get(){return this.value}put(e){this.value=e}load(){const 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))}}class Fe{constructor(e,t,i){this.cache={},this.namespace=e,this.storage=t,this.transformer=i}get(e){return this.cache[e]}getAll(){return Object.assign({},this.cache)}put(e,t){this.cache[e]=t}putAll(e){for(const t of Object.keys(e))this.cache[t]=e[t]}remove(e){delete this.cache[e]}clear(){this.cache={}}load(){const e=this.storage.get(this.namespace);let t;try{t=JSON.parse(e)||{}}catch{return}const i={};for(const s of Object.keys(t))try{let n;this.transformer?n=this.transformer(t[s]):n=t[s],n&&(i[s]=n)}catch{}this.clear(),this.putAll(i)}store(e=this.cache){this.storage.put(this.namespace,JSON.stringify(e))}}const Ve=r=>{if(typeof r=="string")return{key:r,value:r};if(typeof r=="object"){const e=r.key,t=r.value,i=r.payload;let s=r.metadata,n=r.expKey;s&&s.experimentKey?n=s.experimentKey:n&&(s=s||{},s.experimentKey=n);const a={};return e?a.key=e:t&&(a.key=t),t&&(a.value=t),s&&(a.metadata=s),i&&(a.payload=i),n&&(a.expKey=n),a}};class De{constructor(){this.globalScope=m()}get(e){var t;return(t=this.globalScope)===null||t===void 0?void 0:t.sessionStorage.getItem(e)}put(e,t){var i;(i=this.globalScope)===null||i===void 0||i.sessionStorage.setItem(e,t)}delete(e){var t;(t=this.globalScope)===null||t===void 0||t.sessionStorage.removeItem(e)}}const Dt=(r,e,t,i)=>{const s="[Experiment] Exposure",n=t?.value,a=`[Experiment] ${e}`;return{name:s,user:r,key:e,variant:t,userProperty:a,properties:{key:e,variant:n,source:i},userProperties:{[a]:n}}},b=r=>r==null,Q=r=>b(r)?!0:r&&Object.keys(r).length===0,jt=r=>{if(!r||typeof r!="object")return{};const e={};for(const[t,i]of Object.entries(r))b(i)||(e[t]=i);return e},de=r=>{var e;return((e=r?.metadata)===null||e===void 0?void 0:e.evaluationMode)==="local"};class Kt{constructor(e,t,i,s){this.started=!1,this.done=!1,this.attempts=e,this.min=t,this.max=i,this.scalar=s}start(e){return v(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;const e=St();e&&e(this.timeoutHandle)}backoff(e,t,i){return v(this,void 0,void 0,function*(){if(this.done)return;const s=Z();s&&(this.timeoutHandle=s(()=>{v(this,void 0,void 0,function*(){try{yield e()}catch{const a=t+1;if(a<this.attempts){const o=Math.min(i*this.scalar,this.max);yield this.backoff(e,a,o)}}})},i))})}}const he=r=>{var e,t;if(!r)return{};const i={user:r},s=m();s?.location&&(i.page={url:s.location.href});const n={};if(!r.groups)return i;for(const a of Object.keys(r.groups)){const o=r.groups[a];if(o.length>0&&o[0]){const c=o[0],d={group_name:c},l=(t=(e=r.group_properties)===null||e===void 0?void 0:e[a])===null||t===void 0?void 0:t[c];l&&Object.keys(l).length>0&&(d.group_properties=l),n[a]=d}}return Object.keys(n).length>0&&(i.groups=n),delete i.user.groups,delete i.user.group_properties,i},y=r=>r==null?{}:typeof r=="string"?{key:r,value:r}:r,fe=r=>{if(!r)return{};let e;r.metadata&&(e=r.metadata.experimentKey);const t={};return r.key&&(t.key=r.key),r.value&&(t.value=r.value),r.payload&&(t.payload=r.payload),e&&(t.expKey=e),r.metadata&&(t.metadata=r.metadata),t};class Ht{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))}}class Bt{constructor(e){this.tracked={},this.identity={},this.exposureTrackingProvider=e}track(e,t){const i={userId:t?.user_id,deviceId:t?.device_id};this.identityEquals(this.identity,i)||(this.tracked={}),this.identity=i;const s=e.flag_key in this.tracked,n=this.tracked[e.flag_key];s&&n===e.variant||(this.tracked[e.flag_key]=e.variant,this.exposureTrackingProvider.track(e))}identityEquals(e,t){return e.userId===t.userId&&e.deviceId===t.deviceId}}const Qt=1e4,$t=8,Gt=500,Jt=1e4,qt=1.5,ge=6e4,Wt="https://api.lab.eu.amplitude.com",Xt="https://flag.lab.eu.amplitude.com";class ee{constructor(e,t){var i,s,n,a,o;this.engine=new rt,this.isRunning=!1,this.apiKey=e,t=jt(t),this.config=Object.assign(Object.assign(Object.assign({},k),t),{serverUrl:t?.serverUrl||(((i=t?.serverZone)===null||i===void 0?void 0:i.toLowerCase())==="eu"?Wt:k.serverUrl),flagsServerUrl:t?.flagsServerUrl||(((s=t?.serverZone)===null||s===void 0?void 0:s.toLowerCase())==="eu"?Xt:k.flagsServerUrl),flagConfigPollingIntervalMillis:t.flagConfigPollingIntervalMillis<ge?ge:(n=t.flagConfigPollingIntervalMillis)!==null&&n!==void 0?n:k.flagConfigPollingIntervalMillis}),this.logger=new Ut(this.config.loggerProvider||new Pt,ee.getLogLevel(t));const c=(a=this.config)===null||a===void 0?void 0:a.internalInstanceNameSuffix;if(this.isWebExperiment=c==="web",this.poller=new _t(()=>v(this,void 0,void 0,function*(){try{yield this.doFlags()}catch(f){this.logger.info(f)}}),this.config.flagConfigPollingIntervalMillis),this.config.initialVariants)for(const f in this.config.initialVariants)this.config.initialVariants[f]=Ve(this.config.initialVariants[f]);this.config.userProvider&&(this.userProvider=this.config.userProvider),this.config.analyticsProvider&&(this.analyticsProvider=new Ht(this.config.analyticsProvider)),this.config.exposureTrackingProvider&&(this.userSessionExposureTracker=new Bt(this.config.exposureTrackingProvider)),this.integrationManager=new kt(this.config,this);const d=new xt(this.config.httpClient||Le);this.flagApi=new vt(this.apiKey,this.config.flagsServerUrl,d),this.evaluationApi=new gt(this.apiKey,this.config.serverUrl,d);let l;const h=c?`${this.config.instanceName}-${String(c)}`:this.config.instanceName;if(this.isWebExperiment){const f=(o=this.config)===null||o===void 0?void 0:o.internalCacheStorage;l=f??new De}else l=new H;
1this.variants=Lt(this.apiKey,h,l),this.flags=Mt(this.apiKey,h,l),this.fetchVariantsOptions=Ft(this.apiKey,h,l);try{this.flags.load(),this.variants.load(),this.fetchVariantsOptions.load()}catch{}this.mergeInitialFlagsWithStorage()}start(e){return v(this,void 0,void 0,function*(){var t;if(!this.isRunning){this.isRunning=!0,this.setUser(e);try{const i=this.doFlags();((t=this.config.fetchOnStart)!==null&&t!==void 0?t:!0)?yield Promise.all([this.fetch(e),i]):yield i}catch(i){if(this.config.throwOnError)throw i}this.config.pollOnStart&&this.poller.start()}})}stop(){this.isRunning&&(this.poller.stop(),this.isRunning=!1)}fetch(){return v(this,arguments,void 0,function*(e=this.user,t){this.setUser(e||{});try{yield this.fetchInternal(e,this.config.fetchTimeoutMillis,this.config.retryFetchOnFailure,t)}catch(i){if(this.config.throwOnError)throw i;i instanceof L?this.logger.debug(i):this.logger.error(i)}return this})}variant(e,t){var i,s;if(!this.apiKey)return{value:void 0};const n=this.variantAndSource(e,t);return this.config.automaticExposureTracking&&this.exposureInternal(e,n),this.logger.debug(`[Experiment] variant for ${e} is ${((i=n.variant)===null||i===void 0?void 0:i.key)||((s=n.variant)===null||s===void 0?void 0:s.value)}`),n.variant||{}}exposure(e){const t=this.variantAndSource(e);this.exposureInternal(e,t)}all(){if(!this.apiKey)return{};const e=this.evaluate();for(const t in e){const i=this.flags.get(t);de(i)||delete e[t]}return Object.assign(Object.assign(Object.assign({},this.secondaryVariants()),this.sourceVariants()),e)}clear(){this.variants.clear();try{this.variants.store()}catch{}}getUser(){var e;if(!this.user)return this.user;if(!((e=this.user)===null||e===void 0)&&e.user_properties){const t=Object.assign({},this.user.user_properties);return Object.assign(Object.assign({},this.user),{user_properties:t})}else return Object.assign({},this.user)}setUser(e){var t;if(!e){this.user=null;return}if(!((t=this.user)===null||t===void 0)&&t.user_properties){const i=Object.assign({},e.user_properties);this.user=Object.assign(Object.assign({},e),{user_properties:i})}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).forEach(t=>{this.flags.get(t.key)||this.flags.put(t.key,t)})}evaluate(e){const t=this.addContext(this.user),i=ie(this.flags.getAll(),e),s=he(t),n=this.engine.evaluate(s,i),a={};for(const o of Object.keys(n))a[o]=fe(n[o]);return a}getEvaluationTraces(e){const t=this.addContext(this.user),i=ie(this.flags.getAll(),e),s=he(t),{traces:n}=this.engine.evaluateWithTraces(s,i);return n}variantAndSource(e,t){let i={};this.config.source===A.LocalStorage?i=this.localStorageVariantAndSource(e,t):this.config.source===A.InitialVariants&&(i=this.initialVariantsVariantAndSource(e,t));const s=this.flags.get(e);return(de(s)||!i.variant&&s)&&(i=this.localEvaluationVariantAndSource(e,s,t)),i}localEvaluationVariantAndSource(e,t,i){var s;let n={};const a=this.evaluate([t.key])[e],o=g.LocalEvaluation,c=(s=a?.metadata)===null||s===void 0?void 0:s.default;if(!b(a)&&!c)return{variant:y(a),source:o,hasDefaultVariant:!1};if(c&&(n={variant:y(a),source:o,hasDefaultVariant:!0}),!b(i))return{variant:y(i),source:g.FallbackInline,hasDefaultVariant:n.hasDefaultVariant};const d=this.config.initialVariants[e];if(!b(d))return{variant:y(d),source:g.SecondaryInitialVariants,hasDefaultVariant:n.hasDefaultVariant};const l=y(this.config.fallbackVariant),h={variant:l,source:g.FallbackConfig,hasDefaultVariant:n.hasDefaultVariant};return Q(l)?n:h}localStorageVariantAndSource(e,t){var i;let s={};const n=this.variants.get(e),a=(i=n?.metadata)===null||i===void 0?void 0:i.default;if(!b(n)&&!a)return{variant:y(n),source:g.LocalStorage,hasDefaultVariant:!1};if(a&&(s={variant:y(n),source:g.LocalStorage,hasDefaultVariant:!0}),!b(t))return{variant:y(t),source:g.FallbackInline,hasDefaultVariant:s.hasDefaultVariant};const o=this.config.initialVariants[e];if(!b(o))return{variant:y(o),source:g.SecondaryInitialVariants,hasDefaultVariant:s.hasDefaultVariant};const c=y(this.config.fallbackVariant),d={variant:c,source:g.FallbackConfig,hasDefaultVariant:s.hasDefaultVariant};return Q(c)?s:d}initialVariantsVariantAndSource(e,t){var i;let s={};const n=this.config.initialVariants[e];if(!b(n))return{variant:y(n),source:g.InitialVariants,hasDefaultVariant:!1};const a=this.variants.get(e),o=(i=a?.metadata)===null||i===void 0?void 0:i.default;
1if(!b(a)&&!o)return{variant:y(a),source:g.LocalStorage,hasDefaultVariant:!1};if(o&&(s={variant:y(a),source:g.LocalStorage,hasDefaultVariant:!0}),!b(t))return{variant:y(t),source:g.FallbackInline,hasDefaultVariant:s.hasDefaultVariant};const c=y(this.config.fallbackVariant),d={variant:c,source:g.FallbackConfig,hasDefaultVariant:s.hasDefaultVariant};return Q(c)?s:d}fetchInternal(e,t,i,s){return v(this,void 0,void 0,function*(){var n;if(!this.apiKey)throw Error("Experiment API key is empty");this.logger.debug(`[Experiment] Fetch all: retry=${String(i)}`),i&&this.stopRetries();try{const a=yield this.doFetch(e,t,Object.assign({trackingOption:(n=this.fetchVariantsOptions.get())===null||n===void 0?void 0:n.trackingOption},s));return yield this.storeVariants(a,s),a}catch(a){throw i&&this.shouldRetryFetch(a)&&this.startRetries(e,s),a}})}setTracksAssignment(e){return v(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){const t=Object.assign({},e);return delete t.cookie,t}doFetch(e,t,i){return v(this,void 0,void 0,function*(){e=yield this.addContextOrWait(e),e=this.cleanUserPropsForFetch(e),this.logger.debug("[Experiment] Fetch variants for user: ",e);const s=yield this.evaluationApi.getVariants(e,Object.assign({timeoutMillis:t},i)),n={};for(const a of Object.keys(s))n[a]=fe(s[a]);return this.logger.debug("[Experiment] Received variants: ",n),n})}doFlags(){return v(this,void 0,void 0,function*(){try{let e;this.isWebExperiment&&(e=yield this.addContextOrWait(this.getUser()));const t=yield this.flagApi.getFlags({libraryName:"experiment-js-client",libraryVersion:ue,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(t)}catch(e){if(e instanceof L){if(this.logger.debug(e),this.config.throwOnError)throw e}else throw e}try{this.flags.store()}catch{}this.mergeInitialFlagsWithStorage()})}storeVariants(e,t){return v(this,void 0,void 0,function*(){let i=t&&t.flagKeys?t.flagKeys:[];i.length===0&&this.variants.clear();for(const s in e)i=i.filter(n=>n!==s),this.variants.put(s,e[s]);for(const s of i)this.variants.remove(s);try{this.variants.store()}catch{}this.logger.debug("[Experiment] Stored variants: ",e)})}startRetries(e,t){return v(this,void 0,void 0,function*(){this.logger.debug("[Experiment] Retry fetch"),this.retriesBackoff=new Kt($t,Gt,Jt,qt),this.retriesBackoff.start(()=>v(this,void 0,void 0,function*(){yield this.fetchInternal(e,Qt,!1,t)}))})}stopRetries(){this.retriesBackoff&&this.retriesBackoff.cancel()}addContext(e){var t;const i=(t=this.userProvider)===null||t===void 0?void 0:t.getUser(),s=this.integrationManager.getUser(),n=Object.assign(Object.assign(Object.assign({},i?.user_properties),s.user_properties),e?.user_properties);return Object.assign(Object.assign(Object.assign(Object.assign({library:`experiment-js-client/${ue}`},i),s),e),{user_properties:n})}addContextOrWait(e){return v(this,void 0,void 0,function*(){return yield this.integrationManager.ready(),this.addContext(e)})}sourceVariants(){if(this.config.source==A.LocalStorage)return this.variants.getAll();if(this.config.source==A.InitialVariants)return this.config.initialVariants}secondaryVariants(){if(this.config.source==A.LocalStorage)return this.config.initialVariants;if(this.config.source==A.InitialVariants)return this.variants.getAll()}exposureInternal(e,t){var i,s,n,a,o,c,d,l,h;if(!((n=(s=(i=t.variant)===null||i===void 0?void 0:i.metadata)===null||s===void 0?void 0:s.trackExposure)!==null&&n!==void 0?n:!0))return;this.legacyExposureInternal(e,t.variant,t.source);const S={flag_key:e},T=ce(t.source);if(T&&!t.hasDefaultVariant)return;!((a=t.variant)===null||a===void 0)&&a.expKey&&(S.experiment_key=(o=t.variant)===null||o===void 0?void 0:o.expKey);const _=(c=t.variant)===null||c===void 0?void 0:c.metadata;if(!T&&!_?.default&&(!((d=t.variant)===null||d===void 0)&&d.key?S.variant=t.variant.key:!((l=t.variant)===null||l===void 0)&&l.value&&(S.variant=t.variant.value)),_&&(S.metadata=_),this.isWebExperiment&&(S.time=Date.now()),this.isWebExperiment){const N=m();if(N?.location)try{const I=N.location.href;S.metadata.url=I.split("?")[0]||""}catch{}}const O=this.addContext(this.getUser());(h=this.userSessionExposureTracker)===null||h===void 0||h.track(S,O),this.integrationManager.track(S,O)}legacyExposureInternal(e,t,i){var s,n,a,o,c;if(this.analyticsProvider){const d=this.addContext(this.getUser()),l=Dt(d,e,t,i);ce(i)||!t?.value?(n=(s=this.analyticsProvider)===null||s===void 0?void 0:s.unsetUserProperty)===null||n===void 0||n.call(s,l):t?.value&&((o=(a=this.analyticsProvider)===null||a===void 0?void 0:a.setUserProperty)===null||o===void 0||o.call(a,l),(c=this.analyticsProvider)===null||c===void 0||c.track(l))}}static getLogLevel(e){var t;return e.debug===!0?E.Debug:(t=e.logLevel)!==null&&t!==void 0?t:E.Error}shouldRetryFetch(e){return e instanceof K?e.statusCode<400||e.statusCode>=500||e.statusCode===429:!0}addPlugin(e){e.type==="integration"&&this.integrationManager.setIntegration(e)}}class zt{constructor(e,t,i){var s,n,a;this.globalScope=m(),this.userAgent=typeof((s=this.globalScope)===null||s===void 0?void 0:s.navigator)<"u"?(n=this.globalScope)===null||n===void 0?void 0:n.navigator.userAgent:void 0,this.ua=new Be.UAParser(this.userAgent).getResult(),this.localStorage=new H,this.sessionStorage=new De,this.userProvider=e,this.apiKey=t,this.persistenceAllowed=i,this.storageKey=`EXP_${(a=this.apiKey)===null||a===void 0?void 0:a.slice(0,10)}_DEFAULT_USER_PROVIDER`}canPersist(){return this.persistenceAllowed?this.persistenceAllowed():!0}getUser(){var e,t,i,s,n;const 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:(i=(t=this.ua.device)===null||t===void 0?void 0:t.type)!==null&&i!==void 0?i:"desktop",referring_url:(n=(s=this.globalScope)===null||s===void 0?void 0:s.document)===null||n===void 0?void 0:n.referrer.replace(/\/$/,""),cookie
1: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 t,i;return[(t=e.browser)===null||t===void 0?void 0:t.name,(i=e.browser)===null||i===void 0?void 0:i.major].filter(s=>s!=null).join(" ")}getDeviceModel(e){var t;return(t=e.os)===null||t===void 0?void 0:t.name}getBrowser(e){var t;let i=(t=e.browser)===null||t===void 0?void 0:t.name;return i?.includes("Chrom")&&(i="Chrome"),i?.includes("Firefox")&&(i="Firefox"),i?.includes("Safari")&&(i="Safari"),i?.includes("Edge")&&(i="Edge"),i?.includes("Opera")&&(i="Opera"),i}getCookie(){var e,t,i,s,n;if(this.canPersist()&&!((t=(e=this.globalScope)===null||e===void 0?void 0:e.document)===null||t===void 0)&&t.cookie)return Object.fromEntries((n=(s=(i=this.globalScope)===null||i===void 0?void 0:i.document)===null||s===void 0?void 0:s.cookie)===null||n===void 0?void 0:n.split("; ").map(a=>a.split("=")))}getLandingUrl(){var e,t;if(!this.canPersist())return(e=this.gatedLandingUrl)!==null&&e!==void 0||(this.gatedLandingUrl=this.getCurrentUrl()),this.gatedLandingUrl;try{const i=JSON.parse(this.sessionStorage.get(this.storageKey)||"{}");return i.landing_url||(i.landing_url=(t=this.gatedLandingUrl)!==null&&t!==void 0?t:this.getCurrentUrl(),this.sessionStorage.put(this.storageKey,JSON.stringify(i))),i.landing_url}catch{return}}getCurrentUrl(){var e,t;return(t=(e=this.globalScope)===null||e===void 0?void 0:e.location)===null||t===void 0?void 0:t.href.replace(/\/$/,"")}getFirstSeen(){if(!this.canPersist())return(Date.now()/1e3).toString();try{const 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{return}}getUrlParam(){var e;if(!this.globalScope)return;const t={};try{const i=new URL(this.globalScope.location.href);for(const[s,n]of i.searchParams)t[s]=[...(e=t[s])!==null&&e!==void 0?e:[],...n.split(",")]}catch{return}return Object.entries(t).reduce((i,[s,n])=>(i[s]=n.length==1?n[0]:n,i),{})}}var $;const P=m();P&&(P.experimentInstances={});const ve=($=P?.experimentInstances)!==null&&$!==void 0?$:{},ri=(r,e)=>ei(r,e,()=>new At(r,He.getInstance(je(e)),1e4)),je=r=>r?.instanceName||k.instanceName,Zt=(r,e)=>{const t=je(e),i=e?.internalInstanceNameSuffix;return i?`${t}.${r}.${String(i)}`:`${t}.${r}`},Yt=(r,e)=>new ee(r,Object.assign(Object.assign({},e),{userProvider:new zt(e?.userProvider,r,e?.internalPersistenceAllowed)})),ei=(r,e,t)=>{const i=Zt(r,e);let s=ve[i];return s||(s=Yt(r,e),t&&s.addPlugin(t()),ve[i]=s,s)};export{ri as initializeWithAmplitudeAnalytics}; 2//# sourceMappingURL=experiment-js-client.BvwWNT9F.js.map
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.