@growthbook/edge-utils 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return'\"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,_()):t!==n&&(e.isDirty=!0,_())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function v(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,m,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function $(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function C(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function _(){i.forEach(C)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function R(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function F(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function T(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function B(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?T(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function U(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?U(U(t+e)+\"\")%1e4/1e4:1===n?U(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function D(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function I(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=P(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function P(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=D(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function J(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(i)},r,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function H(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function G(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Z=N,Q={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Z.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Z.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Z.EventSource(`${e}/sub/${n}`,{headers:r}):new Z.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),et.forEach((t=>{t&&\"idle\"===t.state&&dt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(rt,z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Z.localStorage=globalThis.localStorage)}catch(t){}const W=new Map;let X=!1;const Y=new Map,tt=new Map,et=new Map,nt=new Set;function rt(){et.forEach((t=>{t&&(t.state=\"idle\",ft(t))}))}async function it(){try{if(!Z.localStorage)return;await Z.localStorage.setItem(z.cacheKey,JSON.stringify(Array.from(Y.entries())))}catch(t){}}function st(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ot(t){const e=st(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ut(){const t=Array.from(Y.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,Y.size-z.maxEntries),Y.size);for(let n=0;n<e;n++)Y.delete(t[n].key)}function ct(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+z.staleTTL),s=z.disableCache?void 0:Y.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void it();z.disableCache||(Y.set(e,{data:n,version:r,staleAt:i,sse:nt.has(t)}),ut()),it();const o=W.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function at(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=st(t),o=ot(t);let u=tt.get(o);return u||(u=(i?Q.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):Q.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&nt.add(s),t.json()})).then((e=>(ct(s,o,e),lt(t),tt.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(tt.delete(o),{data:null,source:\"error\",success:!1,error:t}))),tt.set(o,u)),u}function lt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=st(t),r=ot(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&nt.add(n),z.backgroundSync&&nt.has(n)&&Z.EventSource){if(et.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=W.get(n);t&&t.forEach((t=>{at(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);ct(n,r,t)}t.errors=0}catch(e){ht(t)}},errors:0,state:\"active\"};et.set(n,t),dt(t)}}function ht(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());ft(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||dt(t)}),Math.min(e,3e5))}}function ft(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function dt(t){t.src=Q.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ht(t),t.src.onopen=()=>{t.errors=0}}function wt(t,e){ft(t),et.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&<(t,!0),function(t){const e=st(t),n=W.get(e)||new Set;n.add(t),W.set(e,n)}(t)}}const pt={};function mt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!$t(t,i,n))return!1;break;case\"$nor\":if($t(t,i,n))return!1;break;case\"$and\":if(!At(t,i,n))return!1;break;case\"$not\":if(mt(t,i,n))return!1;break;default:if(!gt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function gt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!bt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!St(r,e,t[r],n))return!1;return!0}function bt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function kt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function St(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&kt(e,n);case\"$inGroup\":return kt(e,r[n]||[]);case\"$notInGroup\":return!kt(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,r);case\"$size\":return!!Array.isArray(e)&>(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=bt(e)?t=>gt(e,t,n):t=>mt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,pt[i]||(pt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function $t(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(mt(t,e[r],n))return!0;return!1}function At(t,e,n){for(let r=0;r<e.length;r++)if(!mt(t,e[r],n))return!1;return!0}function xt(t,e){if(e.stack.evaluatedFeatures.has(t))return _t(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return _t(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return _t(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules)t:for(const n of r.rules){if(n.parentConditions)for(const r of n.parentConditions){const n=xt(r.id,e);if(\"cyclicPrerequisite\"===n.source)return _t(e,t,null,\"cyclicPrerequisite\");if(!mt({value:n.value},r.condition||{})){if(r.gate)return _t(e,t,null,\"prerequisite\");continue t}}if(n.filters&&Ot(n.filters,e))continue;if(\"force\"in n){if(n.condition&&!Et(n.condition,e))continue;if(!Rt(e,n.seed||t,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach((t=>{let n=!1;e.global.trackingCallback&&(n=!0,Promise.resolve(e.global.trackingCallback(t.experiment,t.result,e.user)).catch((()=>{}))),e.user.trackingCallback&&(n=!0,Promise.resolve(e.user.trackingCallback(t.experiment,t.result)).catch((()=>{}))),!n&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),_t(e,t,n.force,\"force\",n.id)}if(!n.variations)continue;const r={variations:n.variations,key:n.key||t};\"coverage\"in n&&(r.coverage=n.coverage),n.weights&&(r.weights=n.weights),n.hashAttribute&&(r.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(r.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(r.disableStickyBucketing=n.disableStickyBucketing),void 0!==n.bucketVersion&&(r.bucketVersion=n.bucketVersion),void 0!==n.minBucketVersion&&(r.minBucketVersion=n.minBucketVersion),n.namespace&&(r.namespace=n.namespace),n.meta&&(r.meta=n.meta),n.ranges&&(r.ranges=n.ranges),n.name&&(r.name=n.name),n.phase&&(r.phase=n.phase),n.seed&&(r.seed=n.seed),n.hashVersion&&(r.hashVersion=n.hashVersion),n.filters&&(r.filters=n.filters),n.condition&&(r.condition=n.condition);const{result:i}=Ct(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,i),i.inExperiment&&!i.passthrough)return _t(e,t,i.value,\"experiment\",n.id,r,i)}return _t(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Ct(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Ft(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Ft(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=D(t.url)),t}(t,n),t.urlPatterns&&!I(n.user.url||\"\",t.urlPatterns))return{result:Ft(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Ft(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Ft(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Ft(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Tt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Ft(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Bt(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Tt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Tt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Bt(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Ot(t.filters,n))return{result:Ft(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Ft(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Ft(n,t,-1,!1,e)};if(t.condition&&!Et(t.condition,n))return{result:Ft(n,t,-1,!1,e)};if(t.parentConditions)for(const r of t.parentConditions){const i=xt(r.id,n);if(\"cyclicPrerequisite\"===i.source)return{result:Ft(n,t,-1,!1,e)};if(!mt({value:i.value},r.condition||{}))return{result:Ft(n,t,-1,!1,e)}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Ft(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Ft(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Ft(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Ft(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Ft(n,t,-1,!1,e)};if(\"force\"in t)return{result:Ft(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Ft(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Ft(n,t,-1,!1,e)};const d=Ft(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Bt(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=[];n.global.trackingCallback&&w.push(Promise.resolve(n.global.trackingCallback(t,d,n.user)).catch((()=>{}))),n.user.trackingCallback&&w.push(Promise.resolve(n.user.trackingCallback(t,d)).catch((()=>{}))),0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const y=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:y}}function _t(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage)try{t.global.onFeatureUsage(e,u,t.user)}catch(t){}if(t.user.onFeatureUsage)try{t.user.onFeatureUsage(e,u)}catch(t){}}return u}function Et(t,e){return mt(e.user.attributes||{},t,e.global.savedGroups||{})}function Ot(t,e){return t.some((t=>{const{hashValue:n}=Tt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>V(r,t)))}))}function Rt(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Tt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?V(c,i):void 0===s||c<=s)}function Ft(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Tt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Tt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Bt(t,e){return`${t}__${e=e||0}`}const Nt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ut=function(){let t;try{t=\"1.3.1\"}catch(e){t=\"\"}return t}();class Mt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}window.dataLayer=window.dataLayer||[];const Vt=document.currentScript,Dt=Vt?Vt.dataset:{},It=window.growthbook_config||{};function Pt(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function jt(){return window.crypto&&crypto.randomUUID?crypto.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}const Jt=It.uuidCookieName||Dt.uuidCookieName||\"gbuuid\",Lt=It.uuidKey||Dt.uuidKey||\"id\";let Kt,qt,Ht=It.uuid||Dt.uuid||\"\";function Gt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Jt,Ht)}function zt(){let t={};try{const e=sessionStorage.getItem(\"utm_params\");if(e&&(t=JSON.parse(e)),location.search){const e=new URLSearchParams(location.search);let n=!1;[\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((r=>{const i=`utm_${r}`,s=\"utm\"+r[0].toUpperCase()+r.slice(1);e.has(i)&&(t[s]=e.get(i)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Zt(){if(!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}function Qt(){const t=Dt.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,r=navigator.userAgent,i=r.match(/Edg/)?\"edge\":r.match(/Chrome/)?\"chrome\":r.match(/Firefox/)?\"firefox\":r.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Ht||(Ht=Pt(Jt),Ht||(Ht=jt(),t&&Gt(),Ht))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Gt(),{...Zt(),[Lt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:r.match(/Mobi/)?\"mobile\":\"desktop\",browser:i,...zt()}}(Dt,It);return It.attributes&&Object.assign(t,It.attributes),t}function Wt(){window.clearTimeout(Kt);let t=It.antiFlickerTimeout??(Dt.antiFlickerTimeout?parseInt(Dt.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),Kt=window.setTimeout(Xt,t)}catch(t){console.error(t)}}function Xt(){window.clearTimeout(Kt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(It.antiFlicker||Dt.antiFlicker)&&Wt(),\"cookie\"===It.useStickyBucketService||\"cookie\"===Dt.useStickyBucketService?qt=new class extends Mt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==It.useStickyBucketService&&\"localStorage\"!==Dt.useStickyBucketService||(qt=new class extends Mt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0}));const Yt=new class{constructor(t){if(t=t||{},this.version=Ut,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.v={},this.g=new Map,this.k=new Set,this.S=!1,this.$=\"\",this.A=new Map,this.C=!t.disableExperimentsOnLoad,this.log=this.log.bind(this),this._=this._.bind(this),this.O=this.O.bind(this),this.R=this.R.bind(this),this.F=this.F.bind(this),this.T=this.T.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.B=t=>e.saveAssignments(t)}if(t.features&&(this.ready=!0),Nt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.N()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.U=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await J(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await J(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await J(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.M=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,this.V()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.U=e,this.M=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(z,t.cacheSettings),z.backgroundSync||(nt.clear(),et.forEach(wt),W.clear(),Q.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.D({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.D({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.U||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.M||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async D(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=st(e),o=ot(e),u=new Date,c=new Date(u.getTime()-z.maxAge+z.staleTTL);await async function(){if(!X){X=!0;try{if(Z.localStorage){const t=await Z.localStorage.getItem(z.cacheKey);if(!z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;Y.set(e,{...n,staleAt:new Date(n.staleAt)})})),ut()}}}catch(t){}if(!z.disableIdleStreams){const t=Q.startIdleListener();t&&(Q.stopIdleListener=t)}}}();const a=z.disableCache||i?void 0:Y.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&nt.add(s),a.staleAt<u?at(e):lt(e),{data:a.data,success:!0,source:\"cache\"}):await G(at(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}V(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.V()}async setEncryptedFeatures(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.N()}async setEncryptedExperiments(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.v=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.V(),this.N())}setForcedFeatures(t){this.P=t,this.V()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.$=\"\",this.i.remoteEval)return await this.I(),void this.N(!0);this.N(!0)}}getAttributes(){return{...this.i.attributes,...this.v}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async I(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.D({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}destroy(){var t;this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.U=void 0,this.B=void 0,t=this,W.forEach((e=>e.delete(t))),Nt&&window._growthbook===this&&delete window._growthbook,this.g.forEach((t=>{t.undo()})),this.g.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.I():(this.N(),this.V())}run(t){const{result:e}=Ct(t,null,this.j());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.J(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.C=!0,this.N(!0)}j(){return{user:this.L(),global:this.K(),stack:{evaluatedFeatures:new Set}}}L(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.q(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.B,trackingCallback:this.i.trackingCallback?this._:void 0,onFeatureUsage:this.i.onFeatureUsage?this.R:void 0}}K(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.T,saveDeferredTrack:this.O}}J(t,e){const n=this.g.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.H(t)?r=Ft(this.j(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Ct(t,null,this.j())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.G(t),r.inExperiment){const e=H(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.q(),r.value.urlRedirect):r.value.urlRedirect;if(I(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this.$=e;const{navigate:n,delay:s}=this.Z();if(n)if(Nt)Promise.all([...i?[G(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.W(r.value);e&&this.g.set(t,{undo:e,valueHash:s})}}return r}G(t){const e=this.g.get(t);e&&(e.undo(),this.g.delete(t))}N(t){if(!this.C)return;const e=this.i.experiments||[],n=new Set(e);this.g.forEach(((t,e)=>{n.has(e)||(t.undo(),this.g.delete(e))}));for(const n of e){const e=this.J(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===H(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}T(t){this.l.add(t)}R(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return xt(t,this.j())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.X(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this._(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}X(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}O(t){this.A.set(this.X(t.experiment,t.result),t)}async _(t,e){if(!this.i.trackingCallback)return;const n=this.X(t,e);if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}q(){return this.i.url||(Nt?window.location.href:\"\")}H(t){const e=H(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.q());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this.$}Z(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Nt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}W(t){if(!Nt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return F(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return F(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return T(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return T(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return T(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return B(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return B(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return B(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.j(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Tt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({...Dt,remoteEval:!!Dt.remoteEval,trackingCallback:async(t,e)=>{const n=[],r={experiment_id:t.key,variation_id:e.key};if(It.additionalTrackingCallback&&n.push(Promise.resolve(It.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...r,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...r,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",r);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...It,attributes:Qt(),stickyBucketService:qt});Yt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Yt.init({payload:It.payload,streaming:!(It.noStreaming||Dt.noStreaming||!1===It.backgroundSync),cacheSettings:It.cacheSettings}).then((()=>{(It.antiFlicker||Dt.antiFlicker)&&(Yt.getRedirectUrl()?Wt():Xt())}));let te=location.href;setInterval((()=>{location.href!==te&&(te=location.href,Yt.setURL(te),Yt.updateAttributes(Qt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==te&&(te=location.href,Yt.setURL(te)),Yt.updateAttributes(Qt())})),document.addEventListener(\"growthbookpersist\",(()=>{Gt()}));const ee=t=>{try{t&&t(Yt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{ee(t)})),window.growthbook_queue={push:t=>{ee(t)}},Yt}();\n//# sourceMappingURL=auto.min.js.map\n";
|
|
1
|
+
export declare const sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return'\"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return v||(v=document.createElement(\"div\")),v.innerHTML=t,v.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function p(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var y=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function g(t){var e=o(t);return e.position||(e.position=u(t,\"position\",y,m,f)),e.position}var v,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function _(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function $(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function x(t,e){t.html&&$(e,\"html\",t.html),t.classes&&$(e,\"class\",t.classes),t.position&&$(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){$(e,n,t.attributes[n])}))}function C(){i.forEach(x)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function T(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function N(t,e){return T({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return T({kind:\"class\",elements:new Set,mutate:e,selector:t})}function D(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):T({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const R={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function I(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?I(I(t+e)+\"\")%1e4/1e4:1===n?I(e+t)%1e3/1e3:null}function B(t,e){return t>=e[0]&&t<e[1]}function U(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function V(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=J(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function J(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=U(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const P=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function j(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||R.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",P(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:P(i)},r,P(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function H(){let t;try{t=\"1.4.1\"}catch(e){t=\"\"}return t}function q(t){return\"object\"==typeof t&&null!==t}function G(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function z(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const Z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Q=R,W={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Q.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Q.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Q.EventSource(`${e}/sub/${n}`,{headers:r}):new Q.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),nt.forEach((t=>{t&&\"idle\"===t.state&&wt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(it,Z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Q.localStorage=globalThis.localStorage)}catch(t){}const X=new Map;let Y=!1;const tt=new Map,et=new Map,nt=new Map,rt=new Set;function it(){nt.forEach((t=>{t&&(t.state=\"idle\",dt(t))}))}async function st(){try{if(!Q.localStorage)return;await Q.localStorage.setItem(Z.cacheKey,JSON.stringify(Array.from(tt.entries())))}catch(t){}}function ot(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ut(t){const e=ot(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ct(){const t=Array.from(tt.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,tt.size-Z.maxEntries),tt.size);for(let n=0;n<e;n++)tt.delete(t[n].key)}function at(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+Z.staleTTL),s=Z.disableCache?void 0:tt.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void st();Z.disableCache||(tt.set(e,{data:n,version:r,staleAt:i,sse:rt.has(t)}),ct()),st();const o=X.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function lt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=ot(t),o=ut(t);let u=et.get(o);return u||(u=(i?W.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):W.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&rt.add(s),t.json()})).then((e=>(at(s,o,e),ht(t),et.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(et.delete(o),{data:null,source:\"error\",success:!1,error:t}))),et.set(o,u)),u}function ht(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=ot(t),r=ut(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&rt.add(n),Z.backgroundSync&&rt.has(n)&&Q.EventSource){if(nt.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=X.get(n);t&&t.forEach((t=>{lt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);at(n,r,t)}t.errors=0}catch(e){ft(t)}},errors:0,state:\"active\"};nt.set(n,t),wt(t)}}function ft(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());dt(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||wt(t)}),Math.min(e,3e5))}}function dt(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function wt(t){t.src=W.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ft(t),t.src.onopen=()=>{t.errors=0}}function pt(t,e){dt(t),nt.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&&ht(t,!0),function(t){const e=ot(t),n=X.get(e)||new Set;n.add(t),X.set(e,n)}(t)}}const mt={};function gt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!At(t,i,n))return!1;break;case\"$nor\":if(At(t,i,n))return!1;break;case\"$and\":if(!$t(t,i,n))return!1;break;case\"$not\":if(gt(t,i,n))return!1;break;default:if(!bt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function bt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return null!==e&&!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!kt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!_t(r,e,t[r],n))return!1;return!0}function kt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function St(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function _t(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&St(e,n);case\"$inGroup\":return St(e,r[n]||[]);case\"$notInGroup\":return!St(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!St(e,n);case\"$not\":return!bt(n,e,r);case\"$size\":return!!Array.isArray(e)&&bt(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=kt(e)?t=>bt(e,t,n):t=>gt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(bt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,mt[i]||(mt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),mt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function At(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(gt(t,e[r],n))return!0;return!1}function $t(t,e,n){for(let r=0;r<e.length;r++)if(!gt(t,e[r],n))return!1;return!0}const xt=\"Feature Evaluated\",Ct=\"Experiment Viewed\";async function Et(t){try{await t()}catch(t){}}function Ot(t,e,n){const r=[];if(t.global.trackingCallback){const i=t.global.trackingCallback;r.push(Et((()=>i(e,n,t.user))))}if(t.user.trackingCallback){const i=t.user.trackingCallback;r.push(Et((()=>i(e,n))))}if(t.global.eventLogger){const i=t.global.eventLogger;r.push(Et((()=>i(Ct,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user))))}return r}function Tt(t,e){if(e.stack.evaluatedFeatures.has(t))return Ft(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return Ft(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return Ft(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules){const n=new Set(e.stack.evaluatedFeatures);t:for(const i of r.rules){if(i.parentConditions)for(const r of i.parentConditions){e.stack.evaluatedFeatures=new Set(n);const i=Tt(r.id,e);if(\"cyclicPrerequisite\"===i.source)return Ft(e,t,null,\"cyclicPrerequisite\");if(!gt({value:i.value},r.condition||{})){if(r.gate)return Ft(e,t,null,\"prerequisite\");continue t}}if(i.filters&&Rt(i.filters,e))continue;if(\"force\"in i){if(i.condition&&!Dt(i.condition,e))continue;if(!It(e,i.seed||t,i.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{!Ot(e,t.experiment,t.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),Ft(e,t,i.force,\"force\",i.id)}if(!i.variations)continue;const r={variations:i.variations,key:i.key||t};\"coverage\"in i&&(r.coverage=i.coverage),i.weights&&(r.weights=i.weights),i.hashAttribute&&(r.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(r.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(r.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(r.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(r.minBucketVersion=i.minBucketVersion),i.namespace&&(r.namespace=i.namespace),i.meta&&(r.meta=i.meta),i.ranges&&(r.ranges=i.ranges),i.name&&(r.name=i.name),i.phase&&(r.phase=i.phase),i.seed&&(r.seed=i.seed),i.hashVersion&&(r.hashVersion=i.hashVersion),i.filters&&(r.filters=i.filters),i.condition&&(r.condition=i.condition);const{result:s}=Nt(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,s),s.inExperiment&&!s.passthrough)return Ft(e,t,s.value,\"experiment\",i.id,r,s)}}return Ft(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Nt(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Mt(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Mt(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=U(t.url)),t}(t,n),t.urlPatterns&&!V(n.user.url||\"\",t.urlPatterns))return{result:Mt(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Mt(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Mt(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Mt(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Bt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Mt(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Ut(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Bt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Bt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Ut(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Rt(t.filters,n))return{result:Mt(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Mt(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Mt(n,t,-1,!1,e)};if(t.condition&&!Dt(t.condition,n))return{result:Mt(n,t,-1,!1,e)};if(t.parentConditions){const r=new Set(n.stack.evaluatedFeatures);for(const i of t.parentConditions){n.stack.evaluatedFeatures=new Set(r);const s=Tt(i.id,n);if(\"cyclicPrerequisite\"===s.source)return{result:Mt(n,t,-1,!1,e)};if(!gt({value:s.value},i.condition||{}))return{result:Mt(n,t,-1,!1,e)}}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Mt(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Mt(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Mt(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(B(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Mt(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Mt(n,t,-1,!1,e)};if(\"force\"in t)return{result:Mt(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Mt(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Mt(n,t,-1,!1,e)};const d=Mt(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Ut(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=Ot(n,t,d);0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const p=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:p}}function Ft(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage){const n=t.global.onFeatureUsage;Et((()=>n(e,u,t.user)))}if(t.user.onFeatureUsage){const n=t.user.onFeatureUsage;Et((()=>n(e,u)))}if(t.global.eventLogger){const n=t.global.eventLogger;Et((()=>n(xt,{feature:e,source:u.source,value:u.value,ruleId:\"defaultValue\"===u.source?\"$default\":u.ruleId||\"\",variationId:u.experimentResult?u.experimentResult.key:\"\"},t.user)))}}return u}function Dt(t,e){return gt(e.user.attributes||{},t,e.global.savedGroups||{})}function Rt(t,e){return t.some((t=>{const{hashValue:n}=Bt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>B(r,t)))}))}function It(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Bt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?B(c,i):void 0===s||c<=s)}function Mt(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Bt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Bt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Ut(t,e){return`${t}__${e=e||0}`}const Vt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Jt=H();class Pt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}function jt(t){return{browser:t.match(/Edg/)?\"edge\":t.match(/Chrome/)?\"chrome\":t.match(/Firefox/)?\"firefox\":t.match(/Safari/)?\"safari\":\"unknown\",deviceType:t.match(/Mobi/)?\"mobile\":\"desktop\"}}function Lt(t){return t?{url:t.href,path:t.pathname,host:t.host,query:t.search}:{}}function Kt(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}function Ht(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function qt(t){return t&&t.randomUUID?t.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(e=>(e^(t&&t.getRandomValues?t.getRandomValues(new Uint8Array(1))[0]:Math.floor(256*Math.random()))&15>>e/4).toString(16)))}function Gt(t){let e={};try{const t=sessionStorage.getItem(\"utm_params\");t&&(e=JSON.parse(t))}catch(t){}if(t&&t.search){const n=new URLSearchParams(t.search);let r=!1;if([\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((t=>{const i=`utm_${t}`,s=\"utm\"+t[0].toUpperCase()+t.slice(1);n.has(i)&&(e[s]=n.get(i)||\"\",r=!0)})),r)try{sessionStorage.setItem(\"utm_params\",JSON.stringify(e))}catch(t){}}return e}function zt(){if(\"undefined\"==typeof window||!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}const Zt=H();function Qt(t){return\"string\"==typeof t?t:null}function Wt(t){let{eventName:e,properties:n,attributes:r,url:i}=t;const{nested:s,topLevel:o}=function(t){const{user_id:e,device_id:n,anonymous_id:r,id:i,page_id:s,session_id:o,utmCampaign:u,utmContent:c,utmMedium:a,utmSource:l,utmTerm:h,pageTitle:f,...d}=t;return{nested:d,topLevel:{user_id:Qt(e),device_id:Qt(n||r||i),page_id:Qt(s),session_id:Qt(o),utm_campaign:Qt(u)||void 0,utm_content:Qt(c)||void 0,utm_medium:Qt(a)||void 0,utm_source:Qt(l)||void 0,utm_term:Qt(h)||void 0,page_title:Qt(f)||void 0}}}(r||{});return{event_name:e,properties_json:n||{},...o,sdk_language:\"js\",sdk_version:Zt,url:i,context_json:s}}async function Xt(t){let{clientKey:e,ingestorHost:n,events:r}=t;if(!r.length)return;const i=`${n||\"https://us1.gb-ingest.com\"}/track?client_key=${e}`,s=JSON.stringify(r);try{await fetch(i,{method:\"POST\",body:s,headers:{Accept:\"application/json\",\"Content-Type\":\"text/plain\"},credentials:\"omit\"})}catch(t){console.error(\"Failed to track event\",t)}}window.dataLayer=window.dataLayer||[];const Yt=document.currentScript,te=Yt?Yt.dataset:{},ee=window.growthbook_config||{};let ne,re;function ie(){window.clearTimeout(ne);let t=ee.antiFlickerTimeout??(te.antiFlickerTimeout?parseInt(te.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),ne=window.setTimeout(se,t)}catch(t){console.error(t)}}function se(){window.clearTimeout(ne);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(ee.antiFlicker||te.antiFlicker)&&ie(),\"cookie\"===ee.useStickyBucketService||\"cookie\"===te.useStickyBucketService?re=new class extends Pt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==ee.useStickyBucketService&&\"localStorage\"!==te.useStickyBucketService||(re=new class extends Pt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0}));const oe=te.uuid||ee.uuid,ue=[function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"autoAttributesPlugin only works in the browser\");const e=t.uuidCookieName||\"gbuuid\",n=t.uuidKey||\"id\";let r=t.uuid||\"\";function i(){Kt(e,r)}function s(){return r||(r=Ht(e),r||(r=qt(window.crypto),r))}function o(t){const e=navigator.userAgent,r=s();(t.uuidAutoPersist??!t.uuid)&&i();const o=location;return{...zt(),[n]:r,...Lt(o),pageTitle:document.title,...jt(e),...Gt(o)}}return document.addEventListener(\"growthbookpersist\",(()=>{i()})),e=>{if(\"createScopedInstance\"in e)return;const n=o(t);n.url&&e.setURL(n.url),e.updateAttributes(n);let r=n.url;const i=setInterval((()=>{location.href!==r&&(r=location.href,e.setURL(r),e.updateAttributes(o(t)))}),500),s=()=>{location.href!==r&&(r=location.href,e.setURL(r)),e.updateAttributes(o(t))};document.addEventListener(\"growthbookrefresh\",s),\"onDestroy\"in e&&e.onDestroy((()=>{clearInterval(i),document.removeEventListener(\"growthbookrefresh\",s)}))}}({uuid:oe,uuidCookieName:ee.uuidCookieName||te.uuidCookieName,uuidKey:ee.uuidKey||te.uuidKey,uuidAutoPersist:!oe&&null==te.noAutoCookies})],ce=te.tracking||\"gtag,gtm,segment\";if(\"none\"!==ce){const t=ce.toLowerCase().split(\",\").map((t=>t.trim()));t.includes(\"growthbook\")&&ue.push(function(){let{queueFlushInterval:t=100,ingestorHost:e,enable:n=!0,debug:r,dedupeCacheSize:i=1e3,dedupeKeyAttributes:s=[],eventFilter:o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u=>{const c=u.getClientKey();if(!c)throw new Error(\"clientKey must be specified to use event logging\");const a=new Set;if(\"setEventLogger\"in u){let l=[],h=null;const f=async()=>{const t=l;l=[],h&&clearTimeout(h),h=null,t.length&&await Xt({clientKey:c,events:t,ingestorHost:e})};let d=null;u.setEventLogger((async(e,u,c)=>{const w={eventName:e,properties:u,attributes:c.attributes||{},url:c.url||\"\"};if(o&&!o(w))return;if(e===xt||e===Ct){const t={eventName:e,properties:u};for(const e of s)t[\"attr:\"+e]=w.attributes[e];const n=JSON.stringify(t);if(a.has(n))return a.delete(n),void a.add(n);if(a.add(n),a.size>i){const t=a.values().next().value;t&&a.delete(t)}}const p=Wt(w);r&&console.log(\"Logging event to GrowthBook\",JSON.parse(JSON.stringify(p))),n&&(l.push(p),d||(d=new Promise(((e,n)=>{h=setTimeout((()=>{f().then(e).catch(n),d=null}),t)}))),await d)})),\"undefined\"!=typeof document&&document.visibilityState&&document.addEventListener(\"visibilitychange\",(()=>{\"hidden\"===document.visibilityState&&f().catch(console.error)})),\"onDestroy\"in u&&u.onDestroy((()=>{f().catch(console.error)}))}if(\"undefined\"!=typeof window&&!(\"createScopedInstance\"in u)){const t=Array.isArray(window.gbEvents)?window.gbEvents:[];window.gbEvents={push:t=>{\"isDestroyed\"in u&&u.isDestroyed()?window.gbEvents=[t]:\"string\"==typeof t?u.logEvent(t):t&&u.logEvent(t.eventName,t.properties)}};for(const e of t)window.gbEvents.push(e)}}}({ingestorHost:te.eventIngestorHost})),ee.trackingCallback||ue.push(function(){let{additionalCallback:t,trackers:e=[\"gtag\",\"gtm\",\"segment\"]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"thirdPartyTrackingPlugin only works in the browser\");return n=>{n.setTrackingCallback((async(n,r)=>{const i=[],s={experiment_id:n.key,variation_id:r.key};if(t&&i.push(Promise.resolve(t(n,r))),e.includes(\"gtag\")&&window.gtag){let t;const e=new Promise((e=>{t=e}));i.push(e),window.gtag(\"event\",\"experiment_viewed\",{...s,event_callback:t})}if(e.includes(\"gtm\")&&window.dataLayer){let t;const e=new Promise((e=>{t=e}));i.push(e),window.dataLayer.push({event:\"experiment_viewed\",...s,eventCallback:t})}if(e.includes(\"segment\")&&window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",s);const t=new Promise((t=>window.setTimeout(t,300)));i.push(t)}await Promise.all(i)}))}}({additionalCallback:ee.additionalTrackingCallback,trackers:t}))}const ae=new class{constructor(t){if(t=t||{},this.version=Jt,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.g={},this.v=new Map,this.k=new Set,this.S=!1,this._=\"\",this.A=new Map,this.$=!t.disableExperimentsOnLoad,this.C=[],this.logs=[],this.log=this.log.bind(this),this.O=this.O.bind(this),this.T=this.T.bind(this),this.N=this.N.bind(this),this.F=this.F.bind(this),this.D=this.D.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.R=t=>e.saveAssignments(t)}if(t.plugins)for(const e of t.plugins)e(this);if(t.features&&(this.ready=!0),Vt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.I()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.M=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await j(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await j(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await j(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.B=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,this.U()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.M=e,this.B=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(Z,t.cacheSettings),Z.backgroundSync||(rt.clear(),nt.forEach(pt),X.clear(),W.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.V({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.V({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.M||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.B||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async V(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(Z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=ot(e),o=ut(e),u=new Date,c=new Date(u.getTime()-Z.maxAge+Z.staleTTL);await async function(){if(!Y){Y=!0;try{if(Q.localStorage){const t=await Q.localStorage.getItem(Z.cacheKey);if(!Z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;tt.set(e,{...n,staleAt:new Date(n.staleAt)})})),ct()}}}catch(t){}if(!Z.disableIdleStreams){const t=W.startIdleListener();t&&(W.stopIdleListener=t)}}}();const a=Z.disableCache||i?void 0:tt.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&rt.add(s),a.staleAt<u?lt(e):ht(e),{data:a.data,success:!0,source:\"cache\"}):await z(lt(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}U(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.U()}async setEncryptedFeatures(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.I()}async setEncryptedExperiments(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.g=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.J():(this.U(),this.I())}setForcedFeatures(t){this.P=t,this.U()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this._=\"\",this.i.remoteEval)return await this.J(),void this.I(!0);this.I(!0)}}getAttributes(){return{...this.i.attributes,...this.g}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async J(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.V({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}onDestroy(t){this.C.push(t)}isDestroyed(){return!!this.j}destroy(){var t;this.j=!0,this.C.forEach((t=>{try{t()}catch(t){console.error(t)}})),this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.C=[],this.M=void 0,this.R=void 0,t=this,X.forEach((e=>e.delete(t))),this.logs=[],Vt&&window._growthbook===this&&delete window._growthbook,this.v.forEach((t=>{t.undo()})),this.v.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.J():(this.I(),this.U())}run(t){const{result:e}=Nt(t,null,this.L());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.K(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.$=!0,this.I(!0)}L(){return{user:this.H(),global:this.q(),stack:{evaluatedFeatures:new Set}}}H(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.G(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.R,trackingCallback:this.i.trackingCallback?this.O:void 0,onFeatureUsage:this.N}}q(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.D,saveDeferredTrack:this.T,eventLogger:this.i.eventLogger}}K(t,e){const n=this.v.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.Z(t)?r=Mt(this.L(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Nt(t,null,this.L())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.W(t),r.inExperiment){const e=G(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.G(),r.value.urlRedirect):r.value.urlRedirect;if(V(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this._=e;const{navigate:n,delay:s}=this.X();if(n)if(Vt)Promise.all([...i?[z(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.Y(r.value);e&&this.v.set(t,{undo:e,valueHash:s})}}return r}W(t){const e=this.v.get(t);e&&(e.undo(),this.v.delete(t))}I(t){if(!this.$)return;const e=this.i.experiments||[],n=new Set(e);this.v.forEach(((t,e)=>{n.has(e)||(t.undo(),this.v.delete(e))}));for(const n of e){const e=this.K(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===G(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}D(t){this.l.add(t)}N(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.enableDevMode&&this.logs.push({featureKey:t,result:e,timestamp:Date.now().toString(),logType:\"feature\"}),this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return Tt(t,this.L())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.tt(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this.O(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}setEventLogger(t){this.i.eventLogger=t}async logEvent(t,e){if(this.j)console.error(\"Cannot log event to destroyed GrowthBook instance\");else if(this.i.enableDevMode&&this.logs.push({eventName:t,properties:e,timestamp:Date.now().toString(),logType:\"event\"}),this.i.eventLogger)try{await this.i.eventLogger(t,e||{},this.H())}catch(t){console.error(t)}else console.error(\"No event logger configured\")}tt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}T(t){this.A.set(this.tt(t.experiment,t.result),t)}async O(t,e){const n=this.tt(t,e);if(!this.u.has(n)&&(this.u.add(n),this.i.enableDevMode&&this.logs.push({experiment:t,result:e,timestamp:Date.now().toString(),logType:\"experiment\"}),this.i.trackingCallback))try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}G(){return this.i.url||(Vt?window.location.href:\"\")}Z(t){const e=G(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.G());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this._}X(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Vt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}Y(t){if(!Vt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return N(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return N(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return F(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return F(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return T({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return D(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return D(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return D(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.L(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Bt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({enableDevMode:!0,...te,remoteEval:!!te.remoteEval,...ee,plugins:ue,stickyBucketService:re});ae.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),ae.init({payload:ee.payload,streaming:!(ee.noStreaming||te.noStreaming||!1===ee.backgroundSync),cacheSettings:ee.cacheSettings}).then((()=>{(ee.antiFlicker||te.antiFlicker)&&(ae.getRedirectUrl()?ie():se())}));const le=t=>{try{t&&t(ae)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{le(t)})),window.growthbook_queue={push:t=>{le(t)}},ae}();\n//# sourceMappingURL=auto.min.js.map\n";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sdkWrapper = void 0;
|
|
4
|
-
exports.sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return\'\"\'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,_()):t!==n&&(e.isDirty=!0,_())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function v(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,m,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function $(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function C(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function _(){i.forEach(C)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function R(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function F(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function T(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function B(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?T(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function U(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?U(U(t+e)+\"\")%1e4/1e4:1===n?U(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function D(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function I(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=P(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function P(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=D(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function J(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(i)},r,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function H(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function G(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Z=N,Q={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Z.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Z.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Z.EventSource(`${e}/sub/${n}`,{headers:r}):new Z.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),et.forEach((t=>{t&&\"idle\"===t.state&&dt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(rt,z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Z.localStorage=globalThis.localStorage)}catch(t){}const W=new Map;let X=!1;const Y=new Map,tt=new Map,et=new Map,nt=new Set;function rt(){et.forEach((t=>{t&&(t.state=\"idle\",ft(t))}))}async function it(){try{if(!Z.localStorage)return;await Z.localStorage.setItem(z.cacheKey,JSON.stringify(Array.from(Y.entries())))}catch(t){}}function st(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ot(t){const e=st(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ut(){const t=Array.from(Y.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,Y.size-z.maxEntries),Y.size);for(let n=0;n<e;n++)Y.delete(t[n].key)}function ct(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+z.staleTTL),s=z.disableCache?void 0:Y.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void it();z.disableCache||(Y.set(e,{data:n,version:r,staleAt:i,sse:nt.has(t)}),ut()),it();const o=W.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function at(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=st(t),o=ot(t);let u=tt.get(o);return u||(u=(i?Q.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):Q.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&nt.add(s),t.json()})).then((e=>(ct(s,o,e),lt(t),tt.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(tt.delete(o),{data:null,source:\"error\",success:!1,error:t}))),tt.set(o,u)),u}function lt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=st(t),r=ot(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&nt.add(n),z.backgroundSync&&nt.has(n)&&Z.EventSource){if(et.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=W.get(n);t&&t.forEach((t=>{at(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);ct(n,r,t)}t.errors=0}catch(e){ht(t)}},errors:0,state:\"active\"};et.set(n,t),dt(t)}}function ht(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());ft(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||dt(t)}),Math.min(e,3e5))}}function ft(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function dt(t){t.src=Q.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ht(t),t.src.onopen=()=>{t.errors=0}}function wt(t,e){ft(t),et.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&<(t,!0),function(t){const e=st(t),n=W.get(e)||new Set;n.add(t),W.set(e,n)}(t)}}const pt={};function mt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!$t(t,i,n))return!1;break;case\"$nor\":if($t(t,i,n))return!1;break;case\"$and\":if(!At(t,i,n))return!1;break;case\"$not\":if(mt(t,i,n))return!1;break;default:if(!gt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function gt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!bt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!St(r,e,t[r],n))return!1;return!0}function bt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function kt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function St(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&kt(e,n);case\"$inGroup\":return kt(e,r[n]||[]);case\"$notInGroup\":return!kt(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,r);case\"$size\":return!!Array.isArray(e)&>(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=bt(e)?t=>gt(e,t,n):t=>mt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,pt[i]||(pt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function $t(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(mt(t,e[r],n))return!0;return!1}function At(t,e,n){for(let r=0;r<e.length;r++)if(!mt(t,e[r],n))return!1;return!0}function xt(t,e){if(e.stack.evaluatedFeatures.has(t))return _t(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return _t(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return _t(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules)t:for(const n of r.rules){if(n.parentConditions)for(const r of n.parentConditions){const n=xt(r.id,e);if(\"cyclicPrerequisite\"===n.source)return _t(e,t,null,\"cyclicPrerequisite\");if(!mt({value:n.value},r.condition||{})){if(r.gate)return _t(e,t,null,\"prerequisite\");continue t}}if(n.filters&&Ot(n.filters,e))continue;if(\"force\"in n){if(n.condition&&!Et(n.condition,e))continue;if(!Rt(e,n.seed||t,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach((t=>{let n=!1;e.global.trackingCallback&&(n=!0,Promise.resolve(e.global.trackingCallback(t.experiment,t.result,e.user)).catch((()=>{}))),e.user.trackingCallback&&(n=!0,Promise.resolve(e.user.trackingCallback(t.experiment,t.result)).catch((()=>{}))),!n&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),_t(e,t,n.force,\"force\",n.id)}if(!n.variations)continue;const r={variations:n.variations,key:n.key||t};\"coverage\"in n&&(r.coverage=n.coverage),n.weights&&(r.weights=n.weights),n.hashAttribute&&(r.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(r.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(r.disableStickyBucketing=n.disableStickyBucketing),void 0!==n.bucketVersion&&(r.bucketVersion=n.bucketVersion),void 0!==n.minBucketVersion&&(r.minBucketVersion=n.minBucketVersion),n.namespace&&(r.namespace=n.namespace),n.meta&&(r.meta=n.meta),n.ranges&&(r.ranges=n.ranges),n.name&&(r.name=n.name),n.phase&&(r.phase=n.phase),n.seed&&(r.seed=n.seed),n.hashVersion&&(r.hashVersion=n.hashVersion),n.filters&&(r.filters=n.filters),n.condition&&(r.condition=n.condition);const{result:i}=Ct(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,i),i.inExperiment&&!i.passthrough)return _t(e,t,i.value,\"experiment\",n.id,r,i)}return _t(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Ct(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Ft(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Ft(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=D(t.url)),t}(t,n),t.urlPatterns&&!I(n.user.url||\"\",t.urlPatterns))return{result:Ft(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Ft(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Ft(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Ft(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Tt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Ft(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Bt(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Tt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Tt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Bt(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Ot(t.filters,n))return{result:Ft(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Ft(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Ft(n,t,-1,!1,e)};if(t.condition&&!Et(t.condition,n))return{result:Ft(n,t,-1,!1,e)};if(t.parentConditions)for(const r of t.parentConditions){const i=xt(r.id,n);if(\"cyclicPrerequisite\"===i.source)return{result:Ft(n,t,-1,!1,e)};if(!mt({value:i.value},r.condition||{}))return{result:Ft(n,t,-1,!1,e)}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Ft(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Ft(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Ft(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Ft(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Ft(n,t,-1,!1,e)};if(\"force\"in t)return{result:Ft(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Ft(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Ft(n,t,-1,!1,e)};const d=Ft(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Bt(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=[];n.global.trackingCallback&&w.push(Promise.resolve(n.global.trackingCallback(t,d,n.user)).catch((()=>{}))),n.user.trackingCallback&&w.push(Promise.resolve(n.user.trackingCallback(t,d)).catch((()=>{}))),0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const y=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:y}}function _t(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage)try{t.global.onFeatureUsage(e,u,t.user)}catch(t){}if(t.user.onFeatureUsage)try{t.user.onFeatureUsage(e,u)}catch(t){}}return u}function Et(t,e){return mt(e.user.attributes||{},t,e.global.savedGroups||{})}function Ot(t,e){return t.some((t=>{const{hashValue:n}=Tt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>V(r,t)))}))}function Rt(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Tt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?V(c,i):void 0===s||c<=s)}function Ft(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Tt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Tt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Bt(t,e){return`${t}__${e=e||0}`}const Nt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ut=function(){let t;try{t=\"1.3.1\"}catch(e){t=\"\"}return t}();class Mt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}window.dataLayer=window.dataLayer||[];const Vt=document.currentScript,Dt=Vt?Vt.dataset:{},It=window.growthbook_config||{};function Pt(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function jt(){return window.crypto&&crypto.randomUUID?crypto.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}const Jt=It.uuidCookieName||Dt.uuidCookieName||\"gbuuid\",Lt=It.uuidKey||Dt.uuidKey||\"id\";let Kt,qt,Ht=It.uuid||Dt.uuid||\"\";function Gt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Jt,Ht)}function zt(){let t={};try{const e=sessionStorage.getItem(\"utm_params\");if(e&&(t=JSON.parse(e)),location.search){const e=new URLSearchParams(location.search);let n=!1;[\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((r=>{const i=`utm_${r}`,s=\"utm\"+r[0].toUpperCase()+r.slice(1);e.has(i)&&(t[s]=e.get(i)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Zt(){if(!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}function Qt(){const t=Dt.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,r=navigator.userAgent,i=r.match(/Edg/)?\"edge\":r.match(/Chrome/)?\"chrome\":r.match(/Firefox/)?\"firefox\":r.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Ht||(Ht=Pt(Jt),Ht||(Ht=jt(),t&&Gt(),Ht))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Gt(),{...Zt(),[Lt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:r.match(/Mobi/)?\"mobile\":\"desktop\",browser:i,...zt()}}(Dt,It);return It.attributes&&Object.assign(t,It.attributes),t}function Wt(){window.clearTimeout(Kt);let t=It.antiFlickerTimeout??(Dt.antiFlickerTimeout?parseInt(Dt.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),Kt=window.setTimeout(Xt,t)}catch(t){console.error(t)}}function Xt(){window.clearTimeout(Kt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(It.antiFlicker||Dt.antiFlicker)&&Wt(),\"cookie\"===It.useStickyBucketService||\"cookie\"===Dt.useStickyBucketService?qt=new class extends Mt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==It.useStickyBucketService&&\"localStorage\"!==Dt.useStickyBucketService||(qt=new class extends Mt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0}));const Yt=new class{constructor(t){if(t=t||{},this.version=Ut,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.v={},this.g=new Map,this.k=new Set,this.S=!1,this.$=\"\",this.A=new Map,this.C=!t.disableExperimentsOnLoad,this.log=this.log.bind(this),this._=this._.bind(this),this.O=this.O.bind(this),this.R=this.R.bind(this),this.F=this.F.bind(this),this.T=this.T.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.B=t=>e.saveAssignments(t)}if(t.features&&(this.ready=!0),Nt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.N()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.U=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await J(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await J(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await J(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.M=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,this.V()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.U=e,this.M=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(z,t.cacheSettings),z.backgroundSync||(nt.clear(),et.forEach(wt),W.clear(),Q.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.D({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.D({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.U||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.M||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async D(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=st(e),o=ot(e),u=new Date,c=new Date(u.getTime()-z.maxAge+z.staleTTL);await async function(){if(!X){X=!0;try{if(Z.localStorage){const t=await Z.localStorage.getItem(z.cacheKey);if(!z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;Y.set(e,{...n,staleAt:new Date(n.staleAt)})})),ut()}}}catch(t){}if(!z.disableIdleStreams){const t=Q.startIdleListener();t&&(Q.stopIdleListener=t)}}}();const a=z.disableCache||i?void 0:Y.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&nt.add(s),a.staleAt<u?at(e):lt(e),{data:a.data,success:!0,source:\"cache\"}):await G(at(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}V(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.V()}async setEncryptedFeatures(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.N()}async setEncryptedExperiments(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.v=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.V(),this.N())}setForcedFeatures(t){this.P=t,this.V()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.$=\"\",this.i.remoteEval)return await this.I(),void this.N(!0);this.N(!0)}}getAttributes(){return{...this.i.attributes,...this.v}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async I(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.D({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}destroy(){var t;this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.U=void 0,this.B=void 0,t=this,W.forEach((e=>e.delete(t))),Nt&&window._growthbook===this&&delete window._growthbook,this.g.forEach((t=>{t.undo()})),this.g.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.I():(this.N(),this.V())}run(t){const{result:e}=Ct(t,null,this.j());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.J(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.C=!0,this.N(!0)}j(){return{user:this.L(),global:this.K(),stack:{evaluatedFeatures:new Set}}}L(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.q(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.B,trackingCallback:this.i.trackingCallback?this._:void 0,onFeatureUsage:this.i.onFeatureUsage?this.R:void 0}}K(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.T,saveDeferredTrack:this.O}}J(t,e){const n=this.g.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.H(t)?r=Ft(this.j(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Ct(t,null,this.j())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.G(t),r.inExperiment){const e=H(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.q(),r.value.urlRedirect):r.value.urlRedirect;if(I(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this.$=e;const{navigate:n,delay:s}=this.Z();if(n)if(Nt)Promise.all([...i?[G(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.W(r.value);e&&this.g.set(t,{undo:e,valueHash:s})}}return r}G(t){const e=this.g.get(t);e&&(e.undo(),this.g.delete(t))}N(t){if(!this.C)return;const e=this.i.experiments||[],n=new Set(e);this.g.forEach(((t,e)=>{n.has(e)||(t.undo(),this.g.delete(e))}));for(const n of e){const e=this.J(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===H(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}T(t){this.l.add(t)}R(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return xt(t,this.j())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.X(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this._(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}X(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}O(t){this.A.set(this.X(t.experiment,t.result),t)}async _(t,e){if(!this.i.trackingCallback)return;const n=this.X(t,e);if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}q(){return this.i.url||(Nt?window.location.href:\"\")}H(t){const e=H(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.q());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this.$}Z(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Nt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}W(t){if(!Nt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return F(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return F(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return T(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return T(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return T(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return B(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return B(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return B(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.j(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Tt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({...Dt,remoteEval:!!Dt.remoteEval,trackingCallback:async(t,e)=>{const n=[],r={experiment_id:t.key,variation_id:e.key};if(It.additionalTrackingCallback&&n.push(Promise.resolve(It.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...r,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...r,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",r);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...It,attributes:Qt(),stickyBucketService:qt});Yt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Yt.init({payload:It.payload,streaming:!(It.noStreaming||Dt.noStreaming||!1===It.backgroundSync),cacheSettings:It.cacheSettings}).then((()=>{(It.antiFlicker||Dt.antiFlicker)&&(Yt.getRedirectUrl()?Wt():Xt())}));let te=location.href;setInterval((()=>{location.href!==te&&(te=location.href,Yt.setURL(te),Yt.updateAttributes(Qt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==te&&(te=location.href,Yt.setURL(te)),Yt.updateAttributes(Qt())})),document.addEventListener(\"growthbookpersist\",(()=>{Gt()}));const ee=t=>{try{t&&t(Yt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{ee(t)})),window.growthbook_queue={push:t=>{ee(t)}},Yt}();\n//# sourceMappingURL=auto.min.js.map\n";
|
|
4
|
+
exports.sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return\'\"\'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return v||(v=document.createElement(\"div\")),v.innerHTML=t,v.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function p(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var y=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function g(t){var e=o(t);return e.position||(e.position=u(t,\"position\",y,m,f)),e.position}var v,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function _(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function $(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function x(t,e){t.html&&$(e,\"html\",t.html),t.classes&&$(e,\"class\",t.classes),t.position&&$(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){$(e,n,t.attributes[n])}))}function C(){i.forEach(x)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function T(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function N(t,e){return T({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return T({kind:\"class\",elements:new Set,mutate:e,selector:t})}function D(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):T({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const R={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function I(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?I(I(t+e)+\"\")%1e4/1e4:1===n?I(e+t)%1e3/1e3:null}function B(t,e){return t>=e[0]&&t<e[1]}function U(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function V(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=J(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function J(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=U(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const P=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function j(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||R.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",P(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:P(i)},r,P(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function H(){let t;try{t=\"1.4.1\"}catch(e){t=\"\"}return t}function q(t){return\"object\"==typeof t&&null!==t}function G(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function z(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const Z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Q=R,W={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Q.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Q.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Q.EventSource(`${e}/sub/${n}`,{headers:r}):new Q.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),nt.forEach((t=>{t&&\"idle\"===t.state&&wt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(it,Z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Q.localStorage=globalThis.localStorage)}catch(t){}const X=new Map;let Y=!1;const tt=new Map,et=new Map,nt=new Map,rt=new Set;function it(){nt.forEach((t=>{t&&(t.state=\"idle\",dt(t))}))}async function st(){try{if(!Q.localStorage)return;await Q.localStorage.setItem(Z.cacheKey,JSON.stringify(Array.from(tt.entries())))}catch(t){}}function ot(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ut(t){const e=ot(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ct(){const t=Array.from(tt.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,tt.size-Z.maxEntries),tt.size);for(let n=0;n<e;n++)tt.delete(t[n].key)}function at(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+Z.staleTTL),s=Z.disableCache?void 0:tt.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void st();Z.disableCache||(tt.set(e,{data:n,version:r,staleAt:i,sse:rt.has(t)}),ct()),st();const o=X.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function lt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=ot(t),o=ut(t);let u=et.get(o);return u||(u=(i?W.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):W.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&rt.add(s),t.json()})).then((e=>(at(s,o,e),ht(t),et.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(et.delete(o),{data:null,source:\"error\",success:!1,error:t}))),et.set(o,u)),u}function ht(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=ot(t),r=ut(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&rt.add(n),Z.backgroundSync&&rt.has(n)&&Q.EventSource){if(nt.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=X.get(n);t&&t.forEach((t=>{lt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);at(n,r,t)}t.errors=0}catch(e){ft(t)}},errors:0,state:\"active\"};nt.set(n,t),wt(t)}}function ft(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());dt(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||wt(t)}),Math.min(e,3e5))}}function dt(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function wt(t){t.src=W.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ft(t),t.src.onopen=()=>{t.errors=0}}function pt(t,e){dt(t),nt.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&&ht(t,!0),function(t){const e=ot(t),n=X.get(e)||new Set;n.add(t),X.set(e,n)}(t)}}const mt={};function gt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!At(t,i,n))return!1;break;case\"$nor\":if(At(t,i,n))return!1;break;case\"$and\":if(!$t(t,i,n))return!1;break;case\"$not\":if(gt(t,i,n))return!1;break;default:if(!bt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function bt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return null!==e&&!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!kt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!_t(r,e,t[r],n))return!1;return!0}function kt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function St(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function _t(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&St(e,n);case\"$inGroup\":return St(e,r[n]||[]);case\"$notInGroup\":return!St(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!St(e,n);case\"$not\":return!bt(n,e,r);case\"$size\":return!!Array.isArray(e)&&bt(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=kt(e)?t=>bt(e,t,n):t=>gt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(bt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,mt[i]||(mt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),mt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function At(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(gt(t,e[r],n))return!0;return!1}function $t(t,e,n){for(let r=0;r<e.length;r++)if(!gt(t,e[r],n))return!1;return!0}const xt=\"Feature Evaluated\",Ct=\"Experiment Viewed\";async function Et(t){try{await t()}catch(t){}}function Ot(t,e,n){const r=[];if(t.global.trackingCallback){const i=t.global.trackingCallback;r.push(Et((()=>i(e,n,t.user))))}if(t.user.trackingCallback){const i=t.user.trackingCallback;r.push(Et((()=>i(e,n))))}if(t.global.eventLogger){const i=t.global.eventLogger;r.push(Et((()=>i(Ct,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user))))}return r}function Tt(t,e){if(e.stack.evaluatedFeatures.has(t))return Ft(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return Ft(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return Ft(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules){const n=new Set(e.stack.evaluatedFeatures);t:for(const i of r.rules){if(i.parentConditions)for(const r of i.parentConditions){e.stack.evaluatedFeatures=new Set(n);const i=Tt(r.id,e);if(\"cyclicPrerequisite\"===i.source)return Ft(e,t,null,\"cyclicPrerequisite\");if(!gt({value:i.value},r.condition||{})){if(r.gate)return Ft(e,t,null,\"prerequisite\");continue t}}if(i.filters&&Rt(i.filters,e))continue;if(\"force\"in i){if(i.condition&&!Dt(i.condition,e))continue;if(!It(e,i.seed||t,i.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{!Ot(e,t.experiment,t.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),Ft(e,t,i.force,\"force\",i.id)}if(!i.variations)continue;const r={variations:i.variations,key:i.key||t};\"coverage\"in i&&(r.coverage=i.coverage),i.weights&&(r.weights=i.weights),i.hashAttribute&&(r.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(r.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(r.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(r.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(r.minBucketVersion=i.minBucketVersion),i.namespace&&(r.namespace=i.namespace),i.meta&&(r.meta=i.meta),i.ranges&&(r.ranges=i.ranges),i.name&&(r.name=i.name),i.phase&&(r.phase=i.phase),i.seed&&(r.seed=i.seed),i.hashVersion&&(r.hashVersion=i.hashVersion),i.filters&&(r.filters=i.filters),i.condition&&(r.condition=i.condition);const{result:s}=Nt(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,s),s.inExperiment&&!s.passthrough)return Ft(e,t,s.value,\"experiment\",i.id,r,s)}}return Ft(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Nt(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Mt(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Mt(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=U(t.url)),t}(t,n),t.urlPatterns&&!V(n.user.url||\"\",t.urlPatterns))return{result:Mt(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Mt(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Mt(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Mt(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Bt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Mt(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Ut(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Bt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Bt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Ut(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Rt(t.filters,n))return{result:Mt(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Mt(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Mt(n,t,-1,!1,e)};if(t.condition&&!Dt(t.condition,n))return{result:Mt(n,t,-1,!1,e)};if(t.parentConditions){const r=new Set(n.stack.evaluatedFeatures);for(const i of t.parentConditions){n.stack.evaluatedFeatures=new Set(r);const s=Tt(i.id,n);if(\"cyclicPrerequisite\"===s.source)return{result:Mt(n,t,-1,!1,e)};if(!gt({value:s.value},i.condition||{}))return{result:Mt(n,t,-1,!1,e)}}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Mt(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Mt(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Mt(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(B(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Mt(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Mt(n,t,-1,!1,e)};if(\"force\"in t)return{result:Mt(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Mt(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Mt(n,t,-1,!1,e)};const d=Mt(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Ut(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=Ot(n,t,d);0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const p=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:p}}function Ft(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage){const n=t.global.onFeatureUsage;Et((()=>n(e,u,t.user)))}if(t.user.onFeatureUsage){const n=t.user.onFeatureUsage;Et((()=>n(e,u)))}if(t.global.eventLogger){const n=t.global.eventLogger;Et((()=>n(xt,{feature:e,source:u.source,value:u.value,ruleId:\"defaultValue\"===u.source?\"$default\":u.ruleId||\"\",variationId:u.experimentResult?u.experimentResult.key:\"\"},t.user)))}}return u}function Dt(t,e){return gt(e.user.attributes||{},t,e.global.savedGroups||{})}function Rt(t,e){return t.some((t=>{const{hashValue:n}=Bt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>B(r,t)))}))}function It(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Bt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?B(c,i):void 0===s||c<=s)}function Mt(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Bt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Bt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Ut(t,e){return`${t}__${e=e||0}`}const Vt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Jt=H();class Pt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}function jt(t){return{browser:t.match(/Edg/)?\"edge\":t.match(/Chrome/)?\"chrome\":t.match(/Firefox/)?\"firefox\":t.match(/Safari/)?\"safari\":\"unknown\",deviceType:t.match(/Mobi/)?\"mobile\":\"desktop\"}}function Lt(t){return t?{url:t.href,path:t.pathname,host:t.host,query:t.search}:{}}function Kt(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}function Ht(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function qt(t){return t&&t.randomUUID?t.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(e=>(e^(t&&t.getRandomValues?t.getRandomValues(new Uint8Array(1))[0]:Math.floor(256*Math.random()))&15>>e/4).toString(16)))}function Gt(t){let e={};try{const t=sessionStorage.getItem(\"utm_params\");t&&(e=JSON.parse(t))}catch(t){}if(t&&t.search){const n=new URLSearchParams(t.search);let r=!1;if([\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((t=>{const i=`utm_${t}`,s=\"utm\"+t[0].toUpperCase()+t.slice(1);n.has(i)&&(e[s]=n.get(i)||\"\",r=!0)})),r)try{sessionStorage.setItem(\"utm_params\",JSON.stringify(e))}catch(t){}}return e}function zt(){if(\"undefined\"==typeof window||!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}const Zt=H();function Qt(t){return\"string\"==typeof t?t:null}function Wt(t){let{eventName:e,properties:n,attributes:r,url:i}=t;const{nested:s,topLevel:o}=function(t){const{user_id:e,device_id:n,anonymous_id:r,id:i,page_id:s,session_id:o,utmCampaign:u,utmContent:c,utmMedium:a,utmSource:l,utmTerm:h,pageTitle:f,...d}=t;return{nested:d,topLevel:{user_id:Qt(e),device_id:Qt(n||r||i),page_id:Qt(s),session_id:Qt(o),utm_campaign:Qt(u)||void 0,utm_content:Qt(c)||void 0,utm_medium:Qt(a)||void 0,utm_source:Qt(l)||void 0,utm_term:Qt(h)||void 0,page_title:Qt(f)||void 0}}}(r||{});return{event_name:e,properties_json:n||{},...o,sdk_language:\"js\",sdk_version:Zt,url:i,context_json:s}}async function Xt(t){let{clientKey:e,ingestorHost:n,events:r}=t;if(!r.length)return;const i=`${n||\"https://us1.gb-ingest.com\"}/track?client_key=${e}`,s=JSON.stringify(r);try{await fetch(i,{method:\"POST\",body:s,headers:{Accept:\"application/json\",\"Content-Type\":\"text/plain\"},credentials:\"omit\"})}catch(t){console.error(\"Failed to track event\",t)}}window.dataLayer=window.dataLayer||[];const Yt=document.currentScript,te=Yt?Yt.dataset:{},ee=window.growthbook_config||{};let ne,re;function ie(){window.clearTimeout(ne);let t=ee.antiFlickerTimeout??(te.antiFlickerTimeout?parseInt(te.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),ne=window.setTimeout(se,t)}catch(t){console.error(t)}}function se(){window.clearTimeout(ne);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(ee.antiFlicker||te.antiFlicker)&&ie(),\"cookie\"===ee.useStickyBucketService||\"cookie\"===te.useStickyBucketService?re=new class extends Pt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==ee.useStickyBucketService&&\"localStorage\"!==te.useStickyBucketService||(re=new class extends Pt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0}));const oe=te.uuid||ee.uuid,ue=[function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"autoAttributesPlugin only works in the browser\");const e=t.uuidCookieName||\"gbuuid\",n=t.uuidKey||\"id\";let r=t.uuid||\"\";function i(){Kt(e,r)}function s(){return r||(r=Ht(e),r||(r=qt(window.crypto),r))}function o(t){const e=navigator.userAgent,r=s();(t.uuidAutoPersist??!t.uuid)&&i();const o=location;return{...zt(),[n]:r,...Lt(o),pageTitle:document.title,...jt(e),...Gt(o)}}return document.addEventListener(\"growthbookpersist\",(()=>{i()})),e=>{if(\"createScopedInstance\"in e)return;const n=o(t);n.url&&e.setURL(n.url),e.updateAttributes(n);let r=n.url;const i=setInterval((()=>{location.href!==r&&(r=location.href,e.setURL(r),e.updateAttributes(o(t)))}),500),s=()=>{location.href!==r&&(r=location.href,e.setURL(r)),e.updateAttributes(o(t))};document.addEventListener(\"growthbookrefresh\",s),\"onDestroy\"in e&&e.onDestroy((()=>{clearInterval(i),document.removeEventListener(\"growthbookrefresh\",s)}))}}({uuid:oe,uuidCookieName:ee.uuidCookieName||te.uuidCookieName,uuidKey:ee.uuidKey||te.uuidKey,uuidAutoPersist:!oe&&null==te.noAutoCookies})],ce=te.tracking||\"gtag,gtm,segment\";if(\"none\"!==ce){const t=ce.toLowerCase().split(\",\").map((t=>t.trim()));t.includes(\"growthbook\")&&ue.push(function(){let{queueFlushInterval:t=100,ingestorHost:e,enable:n=!0,debug:r,dedupeCacheSize:i=1e3,dedupeKeyAttributes:s=[],eventFilter:o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u=>{const c=u.getClientKey();if(!c)throw new Error(\"clientKey must be specified to use event logging\");const a=new Set;if(\"setEventLogger\"in u){let l=[],h=null;const f=async()=>{const t=l;l=[],h&&clearTimeout(h),h=null,t.length&&await Xt({clientKey:c,events:t,ingestorHost:e})};let d=null;u.setEventLogger((async(e,u,c)=>{const w={eventName:e,properties:u,attributes:c.attributes||{},url:c.url||\"\"};if(o&&!o(w))return;if(e===xt||e===Ct){const t={eventName:e,properties:u};for(const e of s)t[\"attr:\"+e]=w.attributes[e];const n=JSON.stringify(t);if(a.has(n))return a.delete(n),void a.add(n);if(a.add(n),a.size>i){const t=a.values().next().value;t&&a.delete(t)}}const p=Wt(w);r&&console.log(\"Logging event to GrowthBook\",JSON.parse(JSON.stringify(p))),n&&(l.push(p),d||(d=new Promise(((e,n)=>{h=setTimeout((()=>{f().then(e).catch(n),d=null}),t)}))),await d)})),\"undefined\"!=typeof document&&document.visibilityState&&document.addEventListener(\"visibilitychange\",(()=>{\"hidden\"===document.visibilityState&&f().catch(console.error)})),\"onDestroy\"in u&&u.onDestroy((()=>{f().catch(console.error)}))}if(\"undefined\"!=typeof window&&!(\"createScopedInstance\"in u)){const t=Array.isArray(window.gbEvents)?window.gbEvents:[];window.gbEvents={push:t=>{\"isDestroyed\"in u&&u.isDestroyed()?window.gbEvents=[t]:\"string\"==typeof t?u.logEvent(t):t&&u.logEvent(t.eventName,t.properties)}};for(const e of t)window.gbEvents.push(e)}}}({ingestorHost:te.eventIngestorHost})),ee.trackingCallback||ue.push(function(){let{additionalCallback:t,trackers:e=[\"gtag\",\"gtm\",\"segment\"]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"thirdPartyTrackingPlugin only works in the browser\");return n=>{n.setTrackingCallback((async(n,r)=>{const i=[],s={experiment_id:n.key,variation_id:r.key};if(t&&i.push(Promise.resolve(t(n,r))),e.includes(\"gtag\")&&window.gtag){let t;const e=new Promise((e=>{t=e}));i.push(e),window.gtag(\"event\",\"experiment_viewed\",{...s,event_callback:t})}if(e.includes(\"gtm\")&&window.dataLayer){let t;const e=new Promise((e=>{t=e}));i.push(e),window.dataLayer.push({event:\"experiment_viewed\",...s,eventCallback:t})}if(e.includes(\"segment\")&&window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",s);const t=new Promise((t=>window.setTimeout(t,300)));i.push(t)}await Promise.all(i)}))}}({additionalCallback:ee.additionalTrackingCallback,trackers:t}))}const ae=new class{constructor(t){if(t=t||{},this.version=Jt,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.g={},this.v=new Map,this.k=new Set,this.S=!1,this._=\"\",this.A=new Map,this.$=!t.disableExperimentsOnLoad,this.C=[],this.logs=[],this.log=this.log.bind(this),this.O=this.O.bind(this),this.T=this.T.bind(this),this.N=this.N.bind(this),this.F=this.F.bind(this),this.D=this.D.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.R=t=>e.saveAssignments(t)}if(t.plugins)for(const e of t.plugins)e(this);if(t.features&&(this.ready=!0),Vt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.I()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.M=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await j(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await j(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await j(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.B=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,this.U()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.M=e,this.B=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(Z,t.cacheSettings),Z.backgroundSync||(rt.clear(),nt.forEach(pt),X.clear(),W.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.V({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.V({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.M||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.B||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async V(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(Z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=ot(e),o=ut(e),u=new Date,c=new Date(u.getTime()-Z.maxAge+Z.staleTTL);await async function(){if(!Y){Y=!0;try{if(Q.localStorage){const t=await Q.localStorage.getItem(Z.cacheKey);if(!Z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;tt.set(e,{...n,staleAt:new Date(n.staleAt)})})),ct()}}}catch(t){}if(!Z.disableIdleStreams){const t=W.startIdleListener();t&&(W.stopIdleListener=t)}}}();const a=Z.disableCache||i?void 0:tt.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&rt.add(s),a.staleAt<u?lt(e):ht(e),{data:a.data,success:!0,source:\"cache\"}):await z(lt(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}U(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.U()}async setEncryptedFeatures(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.I()}async setEncryptedExperiments(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.g=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.J():(this.U(),this.I())}setForcedFeatures(t){this.P=t,this.U()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this._=\"\",this.i.remoteEval)return await this.J(),void this.I(!0);this.I(!0)}}getAttributes(){return{...this.i.attributes,...this.g}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async J(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.V({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}onDestroy(t){this.C.push(t)}isDestroyed(){return!!this.j}destroy(){var t;this.j=!0,this.C.forEach((t=>{try{t()}catch(t){console.error(t)}})),this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.C=[],this.M=void 0,this.R=void 0,t=this,X.forEach((e=>e.delete(t))),this.logs=[],Vt&&window._growthbook===this&&delete window._growthbook,this.v.forEach((t=>{t.undo()})),this.v.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.J():(this.I(),this.U())}run(t){const{result:e}=Nt(t,null,this.L());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.K(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.$=!0,this.I(!0)}L(){return{user:this.H(),global:this.q(),stack:{evaluatedFeatures:new Set}}}H(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.G(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.R,trackingCallback:this.i.trackingCallback?this.O:void 0,onFeatureUsage:this.N}}q(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.D,saveDeferredTrack:this.T,eventLogger:this.i.eventLogger}}K(t,e){const n=this.v.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.Z(t)?r=Mt(this.L(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Nt(t,null,this.L())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.W(t),r.inExperiment){const e=G(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.G(),r.value.urlRedirect):r.value.urlRedirect;if(V(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this._=e;const{navigate:n,delay:s}=this.X();if(n)if(Vt)Promise.all([...i?[z(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.Y(r.value);e&&this.v.set(t,{undo:e,valueHash:s})}}return r}W(t){const e=this.v.get(t);e&&(e.undo(),this.v.delete(t))}I(t){if(!this.$)return;const e=this.i.experiments||[],n=new Set(e);this.v.forEach(((t,e)=>{n.has(e)||(t.undo(),this.v.delete(e))}));for(const n of e){const e=this.K(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===G(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}D(t){this.l.add(t)}N(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.enableDevMode&&this.logs.push({featureKey:t,result:e,timestamp:Date.now().toString(),logType:\"feature\"}),this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return Tt(t,this.L())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.tt(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this.O(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}setEventLogger(t){this.i.eventLogger=t}async logEvent(t,e){if(this.j)console.error(\"Cannot log event to destroyed GrowthBook instance\");else if(this.i.enableDevMode&&this.logs.push({eventName:t,properties:e,timestamp:Date.now().toString(),logType:\"event\"}),this.i.eventLogger)try{await this.i.eventLogger(t,e||{},this.H())}catch(t){console.error(t)}else console.error(\"No event logger configured\")}tt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}T(t){this.A.set(this.tt(t.experiment,t.result),t)}async O(t,e){const n=this.tt(t,e);if(!this.u.has(n)&&(this.u.add(n),this.i.enableDevMode&&this.logs.push({experiment:t,result:e,timestamp:Date.now().toString(),logType:\"experiment\"}),this.i.trackingCallback))try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}G(){return this.i.url||(Vt?window.location.href:\"\")}Z(t){const e=G(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.G());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this._}X(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Vt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}Y(t){if(!Vt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return N(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return N(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return F(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return F(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return T({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return D(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return D(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return D(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.L(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Bt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({enableDevMode:!0,...te,remoteEval:!!te.remoteEval,...ee,plugins:ue,stickyBucketService:re});ae.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),ae.init({payload:ee.payload,streaming:!(ee.noStreaming||te.noStreaming||!1===ee.backgroundSync),cacheSettings:ee.cacheSettings}).then((()=>{(ee.antiFlicker||te.antiFlicker)&&(ae.getRedirectUrl()?ie():se())}));const le=t=>{try{t&&t(ae)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{le(t)})),window.growthbook_queue={push:t=>{le(t)}},ae}();\n//# sourceMappingURL=auto.min.js.map\n";
|
|
5
5
|
//# sourceMappingURL=sdkWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkWrapper.js","sourceRoot":"","sources":["../../src/generated/sdkWrapper.ts"],"names":[],"mappings":";;;AACa,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"sdkWrapper.js","sourceRoot":"","sources":["../../src/generated/sdkWrapper.ts"],"names":[],"mappings":";;;AACa,QAAA,UAAU,GAAG,6kkDAA6kkD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@growthbook/edge-utils",
|
|
3
3
|
"description": "Edge worker base app",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dev": "node scripts/generate-sdk-wrapper.js && tsc --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@growthbook/growthbook": "^1.
|
|
22
|
+
"@growthbook/growthbook": "^1.4.1",
|
|
23
23
|
"node-html-parser": "^7.0.1",
|
|
24
24
|
"pako": "^2.1.0"
|
|
25
25
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export const sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return\'\"\'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,_()):t!==n&&(e.isDirty=!0,_())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function v(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,m,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function $(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function C(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function _(){i.forEach(C)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function R(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=$(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=v(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function F(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function T(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function B(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?T(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function U(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?U(U(t+e)+\"\")%1e4/1e4:1===n?U(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function D(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function I(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=P(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function P(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=D(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function J(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(i)},r,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function H(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function G(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Z=N,Q={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Z.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Z.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Z.EventSource(`${e}/sub/${n}`,{headers:r}):new Z.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),et.forEach((t=>{t&&\"idle\"===t.state&&dt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(rt,z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Z.localStorage=globalThis.localStorage)}catch(t){}const W=new Map;let X=!1;const Y=new Map,tt=new Map,et=new Map,nt=new Set;function rt(){et.forEach((t=>{t&&(t.state=\"idle\",ft(t))}))}async function it(){try{if(!Z.localStorage)return;await Z.localStorage.setItem(z.cacheKey,JSON.stringify(Array.from(Y.entries())))}catch(t){}}function st(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ot(t){const e=st(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ut(){const t=Array.from(Y.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,Y.size-z.maxEntries),Y.size);for(let n=0;n<e;n++)Y.delete(t[n].key)}function ct(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+z.staleTTL),s=z.disableCache?void 0:Y.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void it();z.disableCache||(Y.set(e,{data:n,version:r,staleAt:i,sse:nt.has(t)}),ut()),it();const o=W.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function at(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=st(t),o=ot(t);let u=tt.get(o);return u||(u=(i?Q.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):Q.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&nt.add(s),t.json()})).then((e=>(ct(s,o,e),lt(t),tt.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(tt.delete(o),{data:null,source:\"error\",success:!1,error:t}))),tt.set(o,u)),u}function lt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=st(t),r=ot(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&nt.add(n),z.backgroundSync&&nt.has(n)&&Z.EventSource){if(et.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=W.get(n);t&&t.forEach((t=>{at(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);ct(n,r,t)}t.errors=0}catch(e){ht(t)}},errors:0,state:\"active\"};et.set(n,t),dt(t)}}function ht(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());ft(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||dt(t)}),Math.min(e,3e5))}}function ft(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function dt(t){t.src=Q.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ht(t),t.src.onopen=()=>{t.errors=0}}function wt(t,e){ft(t),et.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&<(t,!0),function(t){const e=st(t),n=W.get(e)||new Set;n.add(t),W.set(e,n)}(t)}}const pt={};function mt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!$t(t,i,n))return!1;break;case\"$nor\":if($t(t,i,n))return!1;break;case\"$and\":if(!At(t,i,n))return!1;break;case\"$not\":if(mt(t,i,n))return!1;break;default:if(!gt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function gt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!bt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!St(r,e,t[r],n))return!1;return!0}function bt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function kt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function St(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&kt(e,n);case\"$inGroup\":return kt(e,r[n]||[]);case\"$notInGroup\":return!kt(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,r);case\"$size\":return!!Array.isArray(e)&>(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=bt(e)?t=>gt(e,t,n):t=>mt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,pt[i]||(pt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function $t(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(mt(t,e[r],n))return!0;return!1}function At(t,e,n){for(let r=0;r<e.length;r++)if(!mt(t,e[r],n))return!1;return!0}function xt(t,e){if(e.stack.evaluatedFeatures.has(t))return _t(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return _t(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return _t(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules)t:for(const n of r.rules){if(n.parentConditions)for(const r of n.parentConditions){const n=xt(r.id,e);if(\"cyclicPrerequisite\"===n.source)return _t(e,t,null,\"cyclicPrerequisite\");if(!mt({value:n.value},r.condition||{})){if(r.gate)return _t(e,t,null,\"prerequisite\");continue t}}if(n.filters&&Ot(n.filters,e))continue;if(\"force\"in n){if(n.condition&&!Et(n.condition,e))continue;if(!Rt(e,n.seed||t,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach((t=>{let n=!1;e.global.trackingCallback&&(n=!0,Promise.resolve(e.global.trackingCallback(t.experiment,t.result,e.user)).catch((()=>{}))),e.user.trackingCallback&&(n=!0,Promise.resolve(e.user.trackingCallback(t.experiment,t.result)).catch((()=>{}))),!n&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),_t(e,t,n.force,\"force\",n.id)}if(!n.variations)continue;const r={variations:n.variations,key:n.key||t};\"coverage\"in n&&(r.coverage=n.coverage),n.weights&&(r.weights=n.weights),n.hashAttribute&&(r.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(r.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(r.disableStickyBucketing=n.disableStickyBucketing),void 0!==n.bucketVersion&&(r.bucketVersion=n.bucketVersion),void 0!==n.minBucketVersion&&(r.minBucketVersion=n.minBucketVersion),n.namespace&&(r.namespace=n.namespace),n.meta&&(r.meta=n.meta),n.ranges&&(r.ranges=n.ranges),n.name&&(r.name=n.name),n.phase&&(r.phase=n.phase),n.seed&&(r.seed=n.seed),n.hashVersion&&(r.hashVersion=n.hashVersion),n.filters&&(r.filters=n.filters),n.condition&&(r.condition=n.condition);const{result:i}=Ct(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,i),i.inExperiment&&!i.passthrough)return _t(e,t,i.value,\"experiment\",n.id,r,i)}return _t(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Ct(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Ft(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Ft(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=D(t.url)),t}(t,n),t.urlPatterns&&!I(n.user.url||\"\",t.urlPatterns))return{result:Ft(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Ft(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Ft(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Ft(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Tt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Ft(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Bt(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Tt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Tt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Bt(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Ot(t.filters,n))return{result:Ft(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Ft(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Ft(n,t,-1,!1,e)};if(t.condition&&!Et(t.condition,n))return{result:Ft(n,t,-1,!1,e)};if(t.parentConditions)for(const r of t.parentConditions){const i=xt(r.id,n);if(\"cyclicPrerequisite\"===i.source)return{result:Ft(n,t,-1,!1,e)};if(!mt({value:i.value},r.condition||{}))return{result:Ft(n,t,-1,!1,e)}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Ft(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Ft(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Ft(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Ft(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Ft(n,t,-1,!1,e)};if(\"force\"in t)return{result:Ft(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Ft(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Ft(n,t,-1,!1,e)};const d=Ft(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Bt(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=[];n.global.trackingCallback&&w.push(Promise.resolve(n.global.trackingCallback(t,d,n.user)).catch((()=>{}))),n.user.trackingCallback&&w.push(Promise.resolve(n.user.trackingCallback(t,d)).catch((()=>{}))),0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const y=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:y}}function _t(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage)try{t.global.onFeatureUsage(e,u,t.user)}catch(t){}if(t.user.onFeatureUsage)try{t.user.onFeatureUsage(e,u)}catch(t){}}return u}function Et(t,e){return mt(e.user.attributes||{},t,e.global.savedGroups||{})}function Ot(t,e){return t.some((t=>{const{hashValue:n}=Tt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>V(r,t)))}))}function Rt(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Tt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?V(c,i):void 0===s||c<=s)}function Ft(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Tt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Tt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Bt(t,e){return`${t}__${e=e||0}`}const Nt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ut=function(){let t;try{t=\"1.3.1\"}catch(e){t=\"\"}return t}();class Mt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}window.dataLayer=window.dataLayer||[];const Vt=document.currentScript,Dt=Vt?Vt.dataset:{},It=window.growthbook_config||{};function Pt(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function jt(){return window.crypto&&crypto.randomUUID?crypto.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)))}const Jt=It.uuidCookieName||Dt.uuidCookieName||\"gbuuid\",Lt=It.uuidKey||Dt.uuidKey||\"id\";let Kt,qt,Ht=It.uuid||Dt.uuid||\"\";function Gt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Jt,Ht)}function zt(){let t={};try{const e=sessionStorage.getItem(\"utm_params\");if(e&&(t=JSON.parse(e)),location.search){const e=new URLSearchParams(location.search);let n=!1;[\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((r=>{const i=`utm_${r}`,s=\"utm\"+r[0].toUpperCase()+r.slice(1);e.has(i)&&(t[s]=e.get(i)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Zt(){if(!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}function Qt(){const t=Dt.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,r=navigator.userAgent,i=r.match(/Edg/)?\"edge\":r.match(/Chrome/)?\"chrome\":r.match(/Firefox/)?\"firefox\":r.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Ht||(Ht=Pt(Jt),Ht||(Ht=jt(),t&&Gt(),Ht))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Gt(),{...Zt(),[Lt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:r.match(/Mobi/)?\"mobile\":\"desktop\",browser:i,...zt()}}(Dt,It);return It.attributes&&Object.assign(t,It.attributes),t}function Wt(){window.clearTimeout(Kt);let t=It.antiFlickerTimeout??(Dt.antiFlickerTimeout?parseInt(Dt.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),Kt=window.setTimeout(Xt,t)}catch(t){console.error(t)}}function Xt(){window.clearTimeout(Kt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(It.antiFlicker||Dt.antiFlicker)&&Wt(),\"cookie\"===It.useStickyBucketService||\"cookie\"===Dt.useStickyBucketService?qt=new class extends Mt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==It.useStickyBucketService&&\"localStorage\"!==Dt.useStickyBucketService||(qt=new class extends Mt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:It.stickyBucketPrefix||Dt.stickyBucketPrefix||void 0}));const Yt=new class{constructor(t){if(t=t||{},this.version=Ut,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.v={},this.g=new Map,this.k=new Set,this.S=!1,this.$=\"\",this.A=new Map,this.C=!t.disableExperimentsOnLoad,this.log=this.log.bind(this),this._=this._.bind(this),this.O=this.O.bind(this),this.R=this.R.bind(this),this.F=this.F.bind(this),this.T=this.T.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.B=t=>e.saveAssignments(t)}if(t.features&&(this.ready=!0),Nt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.N()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.U=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await J(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await J(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await J(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.M=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,this.V()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.U=e,this.M=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.N()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(z,t.cacheSettings),z.backgroundSync||(nt.clear(),et.forEach(wt),W.clear(),Q.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.D({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.D({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.U||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.M||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async D(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=st(e),o=ot(e),u=new Date,c=new Date(u.getTime()-z.maxAge+z.staleTTL);await async function(){if(!X){X=!0;try{if(Z.localStorage){const t=await Z.localStorage.getItem(z.cacheKey);if(!z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;Y.set(e,{...n,staleAt:new Date(n.staleAt)})})),ut()}}}catch(t){}if(!z.disableIdleStreams){const t=Q.startIdleListener();t&&(Q.stopIdleListener=t)}}}();const a=z.disableCache||i?void 0:Y.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&nt.add(s),a.staleAt<u?at(e):lt(e),{data:a.data,success:!0,source:\"cache\"}):await G(at(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}V(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.V()}async setEncryptedFeatures(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.N()}async setEncryptedExperiments(t,e,n){const r=await J(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.v=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.V(),this.N())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.V(),this.N())}setForcedFeatures(t){this.P=t,this.V()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.$=\"\",this.i.remoteEval)return await this.I(),void this.N(!0);this.N(!0)}}getAttributes(){return{...this.i.attributes,...this.v}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async I(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.D({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}destroy(){var t;this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.U=void 0,this.B=void 0,t=this,W.forEach((e=>e.delete(t))),Nt&&window._growthbook===this&&delete window._growthbook,this.g.forEach((t=>{t.undo()})),this.g.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.I():(this.N(),this.V())}run(t){const{result:e}=Ct(t,null,this.j());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.J(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.C=!0,this.N(!0)}j(){return{user:this.L(),global:this.K(),stack:{evaluatedFeatures:new Set}}}L(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.q(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.B,trackingCallback:this.i.trackingCallback?this._:void 0,onFeatureUsage:this.i.onFeatureUsage?this.R:void 0}}K(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.T,saveDeferredTrack:this.O}}J(t,e){const n=this.g.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.H(t)?r=Ft(this.j(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Ct(t,null,this.j())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.G(t),r.inExperiment){const e=H(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.q(),r.value.urlRedirect):r.value.urlRedirect;if(I(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this.$=e;const{navigate:n,delay:s}=this.Z();if(n)if(Nt)Promise.all([...i?[G(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.W(r.value);e&&this.g.set(t,{undo:e,valueHash:s})}}return r}G(t){const e=this.g.get(t);e&&(e.undo(),this.g.delete(t))}N(t){if(!this.C)return;const e=this.i.experiments||[],n=new Set(e);this.g.forEach(((t,e)=>{n.has(e)||(t.undo(),this.g.delete(e))}));for(const n of e){const e=this.J(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===H(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}T(t){this.l.add(t)}R(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return xt(t,this.j())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.X(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this._(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}X(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}O(t){this.A.set(this.X(t.experiment,t.result),t)}async _(t,e){if(!this.i.trackingCallback)return;const n=this.X(t,e);if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}q(){return this.i.url||(Nt?window.location.href:\"\")}H(t){const e=H(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.q());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this.$}Z(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Nt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}W(t){if(!Nt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return F(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return F(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return T(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return T(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return T(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return B(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return B(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return B(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.j(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Tt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({...Dt,remoteEval:!!Dt.remoteEval,trackingCallback:async(t,e)=>{const n=[],r={experiment_id:t.key,variation_id:e.key};if(It.additionalTrackingCallback&&n.push(Promise.resolve(It.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...r,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...r,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",r);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...It,attributes:Qt(),stickyBucketService:qt});Yt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Yt.init({payload:It.payload,streaming:!(It.noStreaming||Dt.noStreaming||!1===It.backgroundSync),cacheSettings:It.cacheSettings}).then((()=>{(It.antiFlicker||Dt.antiFlicker)&&(Yt.getRedirectUrl()?Wt():Xt())}));let te=location.href;setInterval((()=>{location.href!==te&&(te=location.href,Yt.setURL(te),Yt.updateAttributes(Qt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==te&&(te=location.href,Yt.setURL(te)),Yt.updateAttributes(Qt())})),document.addEventListener(\"growthbookpersist\",(()=>{Gt()}));const ee=t=>{try{t&&t(Yt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{ee(t)})),window.growthbook_queue={push:t=>{ee(t)}},Yt}();\n//# sourceMappingURL=auto.min.js.map\n";
|
|
2
|
+
export const sdkWrapper = "var _growthbook=function(){\"use strict\";function t(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}var e=function e(n,r){function i(e,i,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},r,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=\"\";for(var u in s)s[u]&&(o+=\"; \"+u,!0!==s[u]&&(o+=\"=\"+s[u].split(\";\")[0]));return document.cookie=e+\"=\"+n.write(i,e)+o}}return Object.create({set:i,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],r={},i=0;i<e.length;i++){var s=e[i].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(r[u]=n.read(o,u),t===u)break}catch(t){}}return t?r[t]:r}},remove:function(e,n){i(e,\"\",t({},n,{expires:-1}))},withAttributes:function(n){return e(this.converter,t({},this.attributes,n))},withConverter:function(n){return e(t({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(n)}})}({read:function(t){return\'\"\'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,r={revert:function(){}},i=new Map,s=new Set;function o(t){var e=i.get(t);return e||i.set(t,e={element:t,attributes:{}}),e}function u(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,t:null,observer:new MutationObserver((function(){if(\"position\"!==e||!o.t){\"position\"===e&&(o.t=setTimeout((function(){o.t=null}),1e3));var r=n(t);\"position\"===e&&r.parentNode===o.virtualValue.parentNode&&r.insertBeforeNode===o.virtualValue.insertBeforeNode||r!==o.virtualValue&&(o.originalValue=r,i(o))}})),mutationRunner:i,setValue:r,getCurrentValue:n};return\"position\"===e&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,function(t){return\"html\"===t?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}(e)),o}function c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return v||(v=document.createElement(\"div\")),v.innerHTML=t,v.innerHTML}(e),t)}function l(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function h(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var r=e?document.querySelector(e):null;return e&&!r?null:{parentNode:n,insertBeforeNode:r}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function p(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var y=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},m=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function g(t){var e=o(t);return e.position||(e.position=u(t,\"position\",y,m,f)),e.position}var v,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function _(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,l)),e.classes}function A(t,e){var n,r=o(t);return r.attributes[e]||(r.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),h)),r.attributes[e]}function $(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||function(t,e){var n,r,s=i.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(r=n.observer)||r.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var l,h,f;null==(l=s.attributes)||null==(h=l[e])||null==(f=h.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,r)}}function x(t,e){t.html&&$(e,\"html\",t.html),t.classes&&$(e,\"class\",t.classes),t.position&&$(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){$(e,n,t.attributes[n])}))}function C(){i.forEach(x)}function E(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function O(){s.forEach(E)}function T(t){return\"undefined\"==typeof document?r:(s.add(t),E(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=p(e):\"class\"===t.kind?n=_(e):\"attribute\"===t.kind?n=A(e,t.attribute):\"position\"===t.kind&&(n=g(e)),n){var r=n.mutations.indexOf(t);-1!==r&&n.mutations.splice(r,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function N(t,e){return T({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return T({kind:\"class\",elements:new Set,mutate:e,selector:t})}function D(t,e,i){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=i(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):T({kind:\"attribute\",attribute:e,elements:new Set,mutate:i,selector:t}):r}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){O()}))),O(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const R={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function I(t){let e=2166136261;const n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function M(t,e,n){return 2===n?I(I(t+e)+\"\")%1e4/1e4:1===n?I(e+t)%1e3/1e3:null}function B(t,e){return t>=e[0]&&t<e[1]}function U(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function V(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){const s=J(t,e[i].type,e[i].pattern);if(!1===e[i].include){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function J(t,e,n){try{const r=new URL(t,\"https://_\");if(\"regex\"===e){const t=U(n);return!!t&&(t.test(r.href)||t.test(r.href.substring(r.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{r.push([t.searchParams.get(n)||\"\",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(r=\"\\\\/?\"+r.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+r+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const P=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function j(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||R.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const r=await n.importKey(\"raw\",P(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[i,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:P(i)},r,P(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function K(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function H(){let t;try{t=\"1.4.1\"}catch(e){t=\"\"}return t}function q(t){return\"object\"==typeof t&&null!==t}function G(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function z(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const Z={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Q=R,W={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return Q.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...i},body:JSON.stringify(r)};return Q.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new Q.EventSource(`${e}/sub/${n}`,{headers:r}):new Q.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),nt.forEach((t=>{t&&\"idle\"===t.state&&wt(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(it,Z.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Q.localStorage=globalThis.localStorage)}catch(t){}const X=new Map;let Y=!1;const tt=new Map,et=new Map,nt=new Map,rt=new Set;function it(){nt.forEach((t=>{t&&(t.state=\"idle\",dt(t))}))}async function st(){try{if(!Q.localStorage)return;await Q.localStorage.setItem(Z.cacheKey,JSON.stringify(Array.from(tt.entries())))}catch(t){}}function ot(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ut(t){const e=ot(t);if(!(\"isRemoteEval\"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ct(){const t=Array.from(tt.entries()).map((t=>{let[e,n]=t;return{key:e,staleAt:n.staleAt.getTime()}})).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,tt.size-Z.maxEntries),tt.size);for(let n=0;n<e;n++)tt.delete(t[n].key)}function at(t,e,n){const r=n.dateUpdated||\"\",i=new Date(Date.now()+Z.staleTTL),s=Z.disableCache?void 0:tt.get(e);if(s&&r&&s.version===r)return s.staleAt=i,void st();Z.disableCache||(tt.set(e,{data:n,version:r,staleAt:i,sse:rt.has(t)}),ct()),st();const o=X.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function lt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i=\"isRemoteEval\"in t&&t.isRemoteEval(),s=ot(t),o=ut(t);let u=et.get(o);return u||(u=(i?W.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):W.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return\"enabled\"===t.headers.get(\"x-sse-support\")&&rt.add(s),t.json()})).then((e=>(at(s,o,e),ht(t),et.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(et.delete(o),{data:null,source:\"error\",success:!1,error:t}))),et.set(o,u)),u}function ht(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=ot(t),r=ut(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&rt.add(n),Z.backgroundSync&&rt.has(n)&&Q.EventSource){if(nt.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=X.get(n);t&&t.forEach((t=>{lt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);at(n,r,t)}t.errors=0}catch(e){ft(t)}},errors:0,state:\"active\"};nt.set(n,t),wt(t)}}function ft(t){if(\"idle\"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());dt(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||wt(t)}),Math.min(e,3e5))}}function dt(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function wt(t){t.src=W.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state=\"active\",t.src.addEventListener(\"features\",t.cb),t.src.addEventListener(\"features-updated\",t.cb),t.src.onerror=()=>ft(t),t.src.onopen=()=>{t.errors=0}}function pt(t,e){dt(t),nt.delete(e)}function yt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error(\"Must specify clientKey to enable streaming\");e.payload&&ht(t,!0),function(t){const e=ot(t),n=X.get(e)||new Set;n.add(t),X.set(e,n)}(t)}}const mt={};function gt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case\"$or\":if(!At(t,i,n))return!1;break;case\"$nor\":if(At(t,i,n))return!1;break;case\"$and\":if(!$t(t,i,n))return!1;break;case\"$not\":if(gt(t,i,n))return!1;break;default:if(!bt(i,vt(t,r),n))return!1}return!0}function vt(t,e){const n=e.split(\".\");let r=t;for(let t=0;t<n.length;t++){if(!r||\"object\"!=typeof r||!(n[t]in r))return null;r=r[n[t]]}return r}function bt(t,e,n){if(\"string\"==typeof t)return e+\"\"===t;if(\"number\"==typeof t)return 1*e===t;if(\"boolean\"==typeof t)return null!==e&&!!e===t;if(null===t)return null===e;if(Array.isArray(t)||!kt(t))return JSON.stringify(e)===JSON.stringify(t);for(const r in t)if(!_t(r,e,t[r],n))return!1;return!0}function kt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function St(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function _t(t,e,n,r){switch(t){case\"$veq\":return K(e)===K(n);case\"$vne\":return K(e)!==K(n);case\"$vgt\":return K(e)>K(n);case\"$vgte\":return K(e)>=K(n);case\"$vlt\":return K(e)<K(n);case\"$vlte\":return K(e)<=K(n);case\"$eq\":return e===n;case\"$ne\":return e!==n;case\"$lt\":return e<n;case\"$lte\":return e<=n;case\"$gt\":return e>n;case\"$gte\":return e>=n;case\"$exists\":return n?null!=e:null==e;case\"$in\":return!!Array.isArray(n)&&St(e,n);case\"$inGroup\":return St(e,r[n]||[]);case\"$notInGroup\":return!St(e,r[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!St(e,n);case\"$not\":return!bt(n,e,r);case\"$size\":return!!Array.isArray(e)&&bt(n,e.length,r);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const r=kt(e)?t=>bt(e,t,n):t=>gt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&r(t[e]))return!0;return!1}(e,n,r);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let s=0;s<e.length;s++)if(bt(n[t],e[s],r)){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,mt[i]||(mt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),mt[i]).test(e)}catch(t){return!1}case\"$type\":return function(t){if(null===t)return\"null\";if(Array.isArray(t))return\"array\";const e=typeof t;return[\"string\",\"number\",\"boolean\",\"object\",\"undefined\"].includes(e)?e:\"unknown\"}(e)===n;default:return console.error(\"Unknown operator: \"+t),!1}var i}function At(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(gt(t,e[r],n))return!0;return!1}function $t(t,e,n){for(let r=0;r<e.length;r++)if(!gt(t,e[r],n))return!1;return!0}const xt=\"Feature Evaluated\",Ct=\"Experiment Viewed\";async function Et(t){try{await t()}catch(t){}}function Ot(t,e,n){const r=[];if(t.global.trackingCallback){const i=t.global.trackingCallback;r.push(Et((()=>i(e,n,t.user))))}if(t.user.trackingCallback){const i=t.user.trackingCallback;r.push(Et((()=>i(e,n))))}if(t.global.eventLogger){const i=t.global.eventLogger;r.push(Et((()=>i(Ct,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user))))}return r}function Tt(t,e){if(e.stack.evaluatedFeatures.has(t))return Ft(e,t,null,\"cyclicPrerequisite\");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return Ft(e,t,n.get(t),\"override\");if(!e.global.features||!e.global.features[t])return Ft(e,t,null,\"unknownFeature\");const r=e.global.features[t];if(r.rules){const n=new Set(e.stack.evaluatedFeatures);t:for(const i of r.rules){if(i.parentConditions)for(const r of i.parentConditions){e.stack.evaluatedFeatures=new Set(n);const i=Tt(r.id,e);if(\"cyclicPrerequisite\"===i.source)return Ft(e,t,null,\"cyclicPrerequisite\");if(!gt({value:i.value},r.condition||{})){if(r.gate)return Ft(e,t,null,\"prerequisite\");continue t}}if(i.filters&&Rt(i.filters,e))continue;if(\"force\"in i){if(i.condition&&!Dt(i.condition,e))continue;if(!It(e,i.seed||t,i.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{!Ot(e,t.experiment,t.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),Ft(e,t,i.force,\"force\",i.id)}if(!i.variations)continue;const r={variations:i.variations,key:i.key||t};\"coverage\"in i&&(r.coverage=i.coverage),i.weights&&(r.weights=i.weights),i.hashAttribute&&(r.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(r.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(r.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(r.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(r.minBucketVersion=i.minBucketVersion),i.namespace&&(r.namespace=i.namespace),i.meta&&(r.meta=i.meta),i.ranges&&(r.ranges=i.ranges),i.name&&(r.name=i.name),i.phase&&(r.phase=i.phase),i.seed&&(r.seed=i.seed),i.hashVersion&&(r.hashVersion=i.hashVersion),i.filters&&(r.filters=i.filters),i.condition&&(r.condition=i.condition);const{result:s}=Nt(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,s),s.inExperiment&&!s.passthrough)return Ft(e,t,s.value,\"experiment\",i.id,r,s)}}return Ft(e,t,void 0===r.defaultValue?null:r.defaultValue,\"defaultValue\")}function Nt(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:Mt(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:Mt(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&\"string\"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=U(t.url)),t}(t,n),t.urlPatterns&&!V(n.user.url||\"\",t.urlPatterns))return{result:Mt(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split(\"?\")[1];if(!r)return null;const i=r.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}(r,n.user.url||\"\",i);if(null!==s)return{result:Mt(n,t,s,!1,e)};const o=function(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}(n);if(r in o)return{result:Mt(n,t,o[r],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:Mt(n,t,-1,!1,e)};const{hashAttribute:u,hashValue:c}=Bt(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!c)return{result:Mt(n,t,-1,!1,e)};let a=-1,l=!1,h=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:r}=function(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:u}=t;r=r||0,o=o||0,i=i||\"id\",u=u||[];const c=Ut(n,r),a=function(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};const{hashAttribute:r,hashValue:i}=Bt(t,e),s=`${r}||${L(i)}`,{hashAttribute:o,hashValue:u}=Bt(t,n),c=u?`${o}||${L(u)}`:null,a={};return c&&t.user.stickyBucketAssignmentDocs[c]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[c].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(a,t.user.stickyBucketAssignmentDocs[s].assignments||{}),a}(e,i,s);if(o>0)for(let t=0;t<=o;t++)if(void 0!==a[Ut(n,t)])return{variation:-1,versionIsBlocked:!0};const l=a[c];if(void 0===l)return{variation:-1};const h=u.findIndex((t=>t.key===l));return h<0?{variation:-1}:{variation:h}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Rt(t.filters,n))return{result:Mt(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=M(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(c,t.namespace))return{result:Mt(n,t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:Mt(n,t,-1,!1,e)};if(t.condition&&!Dt(t.condition,n))return{result:Mt(n,t,-1,!1,e)};if(t.parentConditions){const r=new Set(n.stack.evaluatedFeatures);for(const i of t.parentConditions){n.stack.evaluatedFeatures=new Set(r);const s=Tt(i.id,n);if(\"cyclicPrerequisite\"===s.source)return{result:Mt(n,t,-1,!1,e)};if(!gt({value:s.value},i.condition||{}))return{result:Mt(n,t,-1,!1,e)}}}if(t.groups&&!function(t,e){const n=e.global.groups||{};for(let e=0;e<t.length;e++)if(n[t[e]])return!0;return!1}(t.groups,n))return{result:Mt(n,t,-1,!1,e)}}if(t.url&&!function(t,e){const n=e.user.url;if(!n)return!1;const r=n.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(n)||!!t.test(r)}(t.url,n))return{result:Mt(n,t,-1,!1,e)};const f=M(t.seed||r,c,t.hashVersion||1);if(null===f)return{result:Mt(n,t,-1,!1,e)};if(l||(a=function(t,e){for(let n=0;n<e.length;n++)if(B(t,e[n]))return n;return-1}(f,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:Mt(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:Mt(n,t,-1,!1,e)};if(\"force\"in t)return{result:Mt(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:Mt(n,t,-1,!1,e)};if(\"stopped\"===t.status)return{result:Mt(n,t,-1,!1,e)};const d=Mt(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=`${e}||${n}`,s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Ut(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=Ot(n,t,d);0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const p=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return\"changeId\"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:p}}function Ft(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||\"\"};if(s&&(u.experiment=s),o&&(u.experimentResult=o),\"override\"!==r){if(t.global.onFeatureUsage){const n=t.global.onFeatureUsage;Et((()=>n(e,u,t.user)))}if(t.user.onFeatureUsage){const n=t.user.onFeatureUsage;Et((()=>n(e,u)))}if(t.global.eventLogger){const n=t.global.eventLogger;Et((()=>n(xt,{feature:e,source:u.source,value:u.value,ruleId:\"defaultValue\"===u.source?\"$default\":u.ruleId||\"\",variationId:u.experimentResult?u.experimentResult.key:\"\"},t.user)))}}return u}function Dt(t,e){return gt(e.user.attributes||{},t,e.global.savedGroups||{})}function Rt(t,e){return t.some((t=>{const{hashValue:n}=Bt(e,t.attribute);if(!n)return!0;const r=M(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>B(r,t)))}))}function It(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Bt(t,n,r);if(!u)return!1;const c=M(e,u,o||1);return null!==c&&(i?B(c,i):void 0===s||c<=s)}function Mt(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Bt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||\"\"+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Bt(t,e,n){let r=e||\"id\",i=\"\";return t.user.attributes&&t.user.attributes[r]&&(i=t.user.attributes[r]),t.user.attributes&&!i&&n&&(t.user.attributes[n]&&(i=t.user.attributes[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Ut(t,e){return`${t}__${e=e||0}`}const Vt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Jt=H();class Pt{constructor(t){this.prefix=(t=t||{}).prefix||\"\"}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((t=>{let[e,n]=t;return this.getAssignments(e,n)})))).forEach((t=>{t&&(e[`${t.attributeName}||${t.attributeValue}`]=t)})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}function jt(t){return{browser:t.match(/Edg/)?\"edge\":t.match(/Chrome/)?\"chrome\":t.match(/Firefox/)?\"firefox\":t.match(/Safari/)?\"safari\":\"unknown\",deviceType:t.match(/Mobi/)?\"mobile\":\"desktop\"}}function Lt(t){return t?{url:t.href,path:t.pathname,host:t.host,query:t.search}:{}}function Kt(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}function Ht(t){const e=(\"; \"+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(\";\")[0]:\"\"}function qt(t){return t&&t.randomUUID?t.randomUUID():\"10000000-1000-4000-8000-100000000000\".replace(/[018]/g,(e=>(e^(t&&t.getRandomValues?t.getRandomValues(new Uint8Array(1))[0]:Math.floor(256*Math.random()))&15>>e/4).toString(16)))}function Gt(t){let e={};try{const t=sessionStorage.getItem(\"utm_params\");t&&(e=JSON.parse(t))}catch(t){}if(t&&t.search){const n=new URLSearchParams(t.search);let r=!1;if([\"source\",\"medium\",\"campaign\",\"term\",\"content\"].forEach((t=>{const i=`utm_${t}`,s=\"utm\"+t[0].toUpperCase()+t.slice(1);n.has(i)&&(e[s]=n.get(i)||\"\",r=!0)})),r)try{sessionStorage.setItem(\"utm_params\",JSON.stringify(e))}catch(t){}}return e}function zt(){if(\"undefined\"==typeof window||!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&\"object\"==typeof e&&!(\"length\"in e)&&(\"event\"in e||Object.keys(e).forEach((n=>{if(\"string\"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof r)&&(t[n]=r)})))})),t}const Zt=H();function Qt(t){return\"string\"==typeof t?t:null}function Wt(t){let{eventName:e,properties:n,attributes:r,url:i}=t;const{nested:s,topLevel:o}=function(t){const{user_id:e,device_id:n,anonymous_id:r,id:i,page_id:s,session_id:o,utmCampaign:u,utmContent:c,utmMedium:a,utmSource:l,utmTerm:h,pageTitle:f,...d}=t;return{nested:d,topLevel:{user_id:Qt(e),device_id:Qt(n||r||i),page_id:Qt(s),session_id:Qt(o),utm_campaign:Qt(u)||void 0,utm_content:Qt(c)||void 0,utm_medium:Qt(a)||void 0,utm_source:Qt(l)||void 0,utm_term:Qt(h)||void 0,page_title:Qt(f)||void 0}}}(r||{});return{event_name:e,properties_json:n||{},...o,sdk_language:\"js\",sdk_version:Zt,url:i,context_json:s}}async function Xt(t){let{clientKey:e,ingestorHost:n,events:r}=t;if(!r.length)return;const i=`${n||\"https://us1.gb-ingest.com\"}/track?client_key=${e}`,s=JSON.stringify(r);try{await fetch(i,{method:\"POST\",body:s,headers:{Accept:\"application/json\",\"Content-Type\":\"text/plain\"},credentials:\"omit\"})}catch(t){console.error(\"Failed to track event\",t)}}window.dataLayer=window.dataLayer||[];const Yt=document.currentScript,te=Yt?Yt.dataset:{},ee=window.growthbook_config||{};let ne,re;function ie(){window.clearTimeout(ne);let t=ee.antiFlickerTimeout??(te.antiFlickerTimeout?parseInt(te.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById(\"gb-anti-flicker-style\")){const t=document.createElement(\"style\");t.setAttribute(\"id\",\"gb-anti-flicker-style\"),t.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(t)}document.documentElement.classList.add(\"gb-anti-flicker\"),ne=window.setTimeout(se,t)}catch(t){console.error(t)}}function se(){window.clearTimeout(ne);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(ee.antiFlicker||te.antiFlicker)&&ie(),\"cookie\"===ee.useStickyBucketService||\"cookie\"===te.useStickyBucketService?re=new class extends Pt{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:r={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=r}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==ee.useStickyBucketService&&\"localStorage\"!==te.useStickyBucketService||(re=new class extends Pt{constructor(t){t=t||{},super(),this.prefix=t.prefix||\"gbStickyBuckets__\";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:ee.stickyBucketPrefix||te.stickyBucketPrefix||void 0}));const oe=te.uuid||ee.uuid,ue=[function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"autoAttributesPlugin only works in the browser\");const e=t.uuidCookieName||\"gbuuid\",n=t.uuidKey||\"id\";let r=t.uuid||\"\";function i(){Kt(e,r)}function s(){return r||(r=Ht(e),r||(r=qt(window.crypto),r))}function o(t){const e=navigator.userAgent,r=s();(t.uuidAutoPersist??!t.uuid)&&i();const o=location;return{...zt(),[n]:r,...Lt(o),pageTitle:document.title,...jt(e),...Gt(o)}}return document.addEventListener(\"growthbookpersist\",(()=>{i()})),e=>{if(\"createScopedInstance\"in e)return;const n=o(t);n.url&&e.setURL(n.url),e.updateAttributes(n);let r=n.url;const i=setInterval((()=>{location.href!==r&&(r=location.href,e.setURL(r),e.updateAttributes(o(t)))}),500),s=()=>{location.href!==r&&(r=location.href,e.setURL(r)),e.updateAttributes(o(t))};document.addEventListener(\"growthbookrefresh\",s),\"onDestroy\"in e&&e.onDestroy((()=>{clearInterval(i),document.removeEventListener(\"growthbookrefresh\",s)}))}}({uuid:oe,uuidCookieName:ee.uuidCookieName||te.uuidCookieName,uuidKey:ee.uuidKey||te.uuidKey,uuidAutoPersist:!oe&&null==te.noAutoCookies})],ce=te.tracking||\"gtag,gtm,segment\";if(\"none\"!==ce){const t=ce.toLowerCase().split(\",\").map((t=>t.trim()));t.includes(\"growthbook\")&&ue.push(function(){let{queueFlushInterval:t=100,ingestorHost:e,enable:n=!0,debug:r,dedupeCacheSize:i=1e3,dedupeKeyAttributes:s=[],eventFilter:o}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u=>{const c=u.getClientKey();if(!c)throw new Error(\"clientKey must be specified to use event logging\");const a=new Set;if(\"setEventLogger\"in u){let l=[],h=null;const f=async()=>{const t=l;l=[],h&&clearTimeout(h),h=null,t.length&&await Xt({clientKey:c,events:t,ingestorHost:e})};let d=null;u.setEventLogger((async(e,u,c)=>{const w={eventName:e,properties:u,attributes:c.attributes||{},url:c.url||\"\"};if(o&&!o(w))return;if(e===xt||e===Ct){const t={eventName:e,properties:u};for(const e of s)t[\"attr:\"+e]=w.attributes[e];const n=JSON.stringify(t);if(a.has(n))return a.delete(n),void a.add(n);if(a.add(n),a.size>i){const t=a.values().next().value;t&&a.delete(t)}}const p=Wt(w);r&&console.log(\"Logging event to GrowthBook\",JSON.parse(JSON.stringify(p))),n&&(l.push(p),d||(d=new Promise(((e,n)=>{h=setTimeout((()=>{f().then(e).catch(n),d=null}),t)}))),await d)})),\"undefined\"!=typeof document&&document.visibilityState&&document.addEventListener(\"visibilitychange\",(()=>{\"hidden\"===document.visibilityState&&f().catch(console.error)})),\"onDestroy\"in u&&u.onDestroy((()=>{f().catch(console.error)}))}if(\"undefined\"!=typeof window&&!(\"createScopedInstance\"in u)){const t=Array.isArray(window.gbEvents)?window.gbEvents:[];window.gbEvents={push:t=>{\"isDestroyed\"in u&&u.isDestroyed()?window.gbEvents=[t]:\"string\"==typeof t?u.logEvent(t):t&&u.logEvent(t.eventName,t.properties)}};for(const e of t)window.gbEvents.push(e)}}}({ingestorHost:te.eventIngestorHost})),ee.trackingCallback||ue.push(function(){let{additionalCallback:t,trackers:e=[\"gtag\",\"gtm\",\"segment\"]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(\"undefined\"==typeof window)throw new Error(\"thirdPartyTrackingPlugin only works in the browser\");return n=>{n.setTrackingCallback((async(n,r)=>{const i=[],s={experiment_id:n.key,variation_id:r.key};if(t&&i.push(Promise.resolve(t(n,r))),e.includes(\"gtag\")&&window.gtag){let t;const e=new Promise((e=>{t=e}));i.push(e),window.gtag(\"event\",\"experiment_viewed\",{...s,event_callback:t})}if(e.includes(\"gtm\")&&window.dataLayer){let t;const e=new Promise((e=>{t=e}));i.push(e),window.dataLayer.push({event:\"experiment_viewed\",...s,eventCallback:t})}if(e.includes(\"segment\")&&window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",s);const t=new Promise((t=>window.setTimeout(t,300)));i.push(t)}await Promise.all(i)}))}}({additionalCallback:ee.additionalTrackingCallback,trackers:t}))}const ae=new class{constructor(t){if(t=t||{},this.version=Jt,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.m=new Map,this.g={},this.v=new Map,this.k=new Set,this.S=!1,this._=\"\",this.A=new Map,this.$=!t.disableExperimentsOnLoad,this.C=[],this.logs=[],this.log=this.log.bind(this),this.O=this.O.bind(this),this.T=this.T.bind(this),this.N=this.N.bind(this),this.F=this.F.bind(this),this.D=this.D.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error(\"Encryption is not available for remoteEval\");if(!t.clientKey)throw new Error(\"Missing clientKey\");let e=!1;try{e=!!new URL(t.apiHost||\"\").hostname.match(/growthbook\\.io$/i)}catch(t){}if(e)throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\")}else if(t.cacheKeyAttributes)throw new Error(\"cacheKeyAttributes are only used for remoteEval\");if(t.stickyBucketService){const e=t.stickyBucketService;this.R=t=>e.saveAssignments(t)}if(t.plugins)for(const e of t.plugins)e(this);if(t.features&&(this.ready=!0),Vt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.I()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.M=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await j(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await j(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await j(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.B=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,this.U()}initSync(t){this.S=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error(\"initSync does not support encrypted payloads\");if(this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs)throw new Error(\"initSync requires you to pass stickyBucketAssignmentDocs into the GrowthBook constructor\");return this.M=e,this.B=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.I()),this.ready=!0,yt(this,t),this}async init(t){if(this.S=!0,(t=t||{}).cacheSettings&&(Object.assign(Z,t.cacheSettings),Z.backgroundSync||(rt.clear(),nt.forEach(pt),X.clear(),W.stopIdleListener())),t.payload)return await this.setPayload(t.payload),yt(this,t),{success:!0,source:\"init\"};{const{data:e,...n}=await this.V({...t,allowStale:!0});return yt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.V({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||\"https://cdn.growthbook.io\";return{apiHost:e.replace(/\\/*$/,\"\"),streamingHost:(t.streamingHost||e).replace(/\\/*$/,\"\"),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.M||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.B||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async V(t){let{timeout:e,skipCache:n,allowStale:r,streaming:i}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(Z.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t;const s=ot(e),o=ut(e),u=new Date,c=new Date(u.getTime()-Z.maxAge+Z.staleTTL);await async function(){if(!Y){Y=!0;try{if(Q.localStorage){const t=await Q.localStorage.getItem(Z.cacheKey);if(!Z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;tt.set(e,{...n,staleAt:new Date(n.staleAt)})})),ct()}}}catch(t){}if(!Z.disableIdleStreams){const t=W.startIdleListener();t&&(W.stopIdleListener=t)}}}();const a=Z.disableCache||i?void 0:tt.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&rt.add(s),a.staleAt<u?lt(e):ht(e),{data:a.data,success:!0,source:\"cache\"}):await z(lt(e),r)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:i,timeout:n,skipCache:r})}({instance:this,timeout:e,skipCache:n||this.i.disableCache,allowStale:r,backgroundSync:i??this.i.backgroundSync??!0})}U(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.U()}async setEncryptedFeatures(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(r))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.I()}async setEncryptedExperiments(t,e,n){const r=await j(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(r))}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.g=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.J():(this.U(),this.I())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.J():(this.U(),this.I())}setForcedFeatures(t){this.P=t,this.U()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this._=\"\",this.i.remoteEval)return await this.J(),void this.I(!0);this.I(!0)}}getAttributes(){return{...this.i.attributes,...this.g}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.P||new Map}getStickyBucketAssignmentDocs(){return this.i.stickyBucketAssignmentDocs||{}}getUrl(){return this.i.url||\"\"}getFeatures(){return this.i.features||{}}getExperiments(){return this.i.experiments||[]}getCompletedChangeIds(){return Array.from(this.l)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}async J(){if(!this.i.remoteEval)return;if(!this.S)return;const t=await this.V({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.m)}onDestroy(t){this.C.push(t)}isDestroyed(){return!!this.j}destroy(){var t;this.j=!0,this.C.forEach((t=>{try{t()}catch(t){console.error(t)}})),this.p.clear(),this.m.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.C=[],this.M=void 0,this.R=void 0,t=this,X.forEach((e=>e.delete(t))),this.logs=[],Vt&&window._growthbook===this&&delete window._growthbook,this.v.forEach((t=>{t.undo()})),this.v.clear(),this.k.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.J():(this.I(),this.U())}run(t){const{result:e}=Nt(t,null,this.L());return this.F(t,e),e}triggerExperiment(t){return this.k.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.K(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this.$=!0,this.I(!0)}L(){return{user:this.H(),global:this.q(),stack:{evaluatedFeatures:new Set}}}H(){return{attributes:this.i.user?{...this.i.user,...this.getAttributes()}:this.getAttributes(),blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.G(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.P,saveStickyBucketAssignmentDoc:this.R,trackingCallback:this.i.trackingCallback?this.O:void 0,onFeatureUsage:this.N}}q(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.p.size>0?this.F:void 0,recordChangeId:this.D,saveDeferredTrack:this.T,eventLogger:this.i.eventLogger}}K(t,e){const n=this.v.get(t);if(t.manual&&!this.k.has(t.key)&&!n)return null;let r,i;this.Z(t)?r=Mt(this.L(),t,-1,!1,\"\"):(({result:r,trackingCall:i}=Nt(t,null,this.L())),this.F(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.W(t),r.inExperiment){const e=G(t);if(\"redirect\"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.G(),r.value.urlRedirect):r.value.urlRedirect;if(V(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),r;this._=e;const{navigate:n,delay:s}=this.X();if(n)if(Vt)Promise.all([...i?[z(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.Y(r.value);e&&this.v.set(t,{undo:e,valueHash:s})}}return r}W(t){const e=this.v.get(t);e&&(e.undo(),this.v.delete(t))}I(t){if(!this.$)return;const e=this.i.experiments||[],n=new Set(e);this.v.forEach(((t,e)=>{n.has(e)||(t.undo(),this.v.delete(e))}));for(const n of e){const e=this.K(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===G(n))break}}F(t,e){const n=t.key,r=this.m.get(n);r&&r.result.inExperiment===e.inExperiment&&r.result.variationId===e.variationId||(this.m.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}D(t){this.l.add(t)}N(t,e){const n=JSON.stringify(e.value);if(this.h[t]!==n&&(this.h[t]=n,this.i.enableDevMode&&this.logs.push({featureKey:t,result:e,timestamp:Date.now().toString(),logType:\"feature\"}),this.i.onFeatureUsage))try{this.i.onFeatureUsage(t,e)}catch(t){}}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return Tt(t,this.L())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.tt(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this.O(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}setEventLogger(t){this.i.eventLogger=t}async logEvent(t,e){if(this.j)console.error(\"Cannot log event to destroyed GrowthBook instance\");else if(this.i.enableDevMode&&this.logs.push({eventName:t,properties:e,timestamp:Date.now().toString(),logType:\"event\"}),this.i.eventLogger)try{await this.i.eventLogger(t,e||{},this.H())}catch(t){console.error(t)}else console.error(\"No event logger configured\")}tt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}T(t){this.A.set(this.tt(t.experiment,t.result),t)}async O(t,e){const n=this.tt(t,e);if(!this.u.has(n)&&(this.u.add(n),this.i.enableDevMode&&this.logs.push({experiment:t,result:e,timestamp:Date.now().toString(),logType:\"experiment\"}),this.i.trackingCallback))try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}G(){return this.i.url||(Vt?window.location.href:\"\")}Z(t){const e=G(t);if(\"visual\"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if(\"redirect\"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.G());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log(\"Error parsing current or redirect URL\",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this._}X(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:Vt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}Y(t){if(!Vt)return;const e=[];if(t.css){const n=document.createElement(\"style\");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement(\"script\");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return N(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return N(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return F(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return F(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return T({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return D(e,s,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return D(e,s,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return D(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.L(),n=await async function(t,e,n){const r=function(t,e){const n={};return function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e).forEach((e=>{const{hashValue:r}=Bt(t,e);n[e]=L(r)})),n}(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}}({enableDevMode:!0,...te,remoteEval:!!te.remoteEval,...ee,plugins:ue,stickyBucketService:re});ae.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),ae.init({payload:ee.payload,streaming:!(ee.noStreaming||te.noStreaming||!1===ee.backgroundSync),cacheSettings:ee.cacheSettings}).then((()=>{(ee.antiFlicker||te.antiFlicker)&&(ae.getRedirectUrl()?ie():se())}));const le=t=>{try{t&&t(ae)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{le(t)})),window.growthbook_queue={push:t=>{le(t)}},ae}();\n//# sourceMappingURL=auto.min.js.map\n";
|