@growthbook/edge-utils 0.1.4 → 0.1.6

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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const y={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},p=n,v={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return p.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return p.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new p.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new p.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),S.forEach((t=>{t&&\"idle\"===t.state&&M(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(x,y.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(p.localStorage=globalThis.localStorage)}catch(t){}const m=new Map;let g=!1;const b=new Map,k=new Map,S=new Map,A=new Set;function _(t){const e=C(t),n=m.get(e)||new Set;n.add(t),m.set(e,n)}function x(){S.forEach((t=>{t&&(t.state=\"idle\",N(t))}))}async function E(){try{if(!p.localStorage)return;await p.localStorage.setItem(y.cacheKey,JSON.stringify(Array.from(b.entries())))}catch(t){}}function C(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function O(t){const e=C(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function $(){const t=Array.from(b.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,b.size-y.maxEntries),b.size);for(let n=0;n<e;n++)b.delete(t[n].key)}function R(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+y.staleTTL),s=b.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void E();b.set(e,{data:n,version:i,staleAt:r,sse:A.has(t)}),$(),E();const o=m.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function B(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=C(t),o=O(t);let u=k.get(o);return u||(u=(r?v.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):v.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&A.add(s),t.json()})).then((e=>(R(s,o,e),F(t),k.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(k.delete(o),{data:null,source:\"error\",success:!1,error:t}))),k.set(o,u)),u}function F(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=C(t),i=O(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&A.add(n),y.backgroundSync&&A.has(n)&&p.EventSource){if(S.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=m.get(n);t&&t.forEach((t=>{B(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);R(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};S.set(n,t),M(t)}}function T(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());N(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||M(t)}),Math.min(e,3e5))}}function N(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function M(t){t.src=v.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}var U=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,V={revert:function(){}},I=new Map,D=new Set;function J(t){var e=I.get(t);return e||I.set(t,e={element:t,attributes:{}}),e}function j(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 K(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,ut()):t!==n&&(e.isDirty=!0,ut())}function L(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(function(t){return Y||(Y=document.createElement(\"div\")),Y.innerHTML=t,Y.innerHTML}(e),t)}function H(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),K(Array.from(e).filter(Boolean).join(\" \"),t)}function q(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(e,t)}function P(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),K(e,t)}var z=function(t){return t.innerHTML},G=function(t,e){return t.innerHTML=e};function Z(t){var e=J(t);return e.html||(e.html=j(t,\"html\",z,G,L)),e.html}var Q=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},W=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function X(t){var e=J(t);return e.position||(e.position=j(t,\"position\",Q,W,P)),e.position}var Y,tt,et=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},nt=function(t){return t.className};function it(t){var e=J(t);return e.classes||(e.classes=j(t,\"class\",nt,et,H)),e.classes}function rt(t,e){var n,i=J(t);return i.attributes[e]||(i.attributes[e]=j(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),q)),i.attributes[e]}function st(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=I.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ot(t,e){t.html&&st(e,\"html\",t.html),t.classes&&st(e,\"class\",t.classes),t.position&&st(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){st(e,n,t.attributes[n])}))}function ut(){I.forEach(ot)}function ct(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=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function at(){D.forEach(ct)}function ht(t){return\"undefined\"==typeof document?V:(D.add(t),ct(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function lt(t,e){return ht({kind:\"html\",elements:new Set,mutate:e,selector:t})}function ft(t,e){return ht({kind:\"class\",elements:new Set,mutate:e,selector:t})}function dt(t,e,n){return U.test(e)?\"class\"===e||\"className\"===e?ft(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ht({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):V}\"undefined\"!=typeof document&&(tt||(tt=new MutationObserver((function(){at()}))),at(),tt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const wt={};function yt(t,e){if(\"$or\"in e)return kt(t,e.$or);if(\"$nor\"in e)return!kt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!yt(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!yt(t,e.$not);for(const[n,i]of Object.entries(e))if(!vt(i,pt(t,n)))return!1;return!0}function pt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}function vt(t,e){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)||!mt(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!bt(n,e,t[n]))return!1;return!0}function mt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function gt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function bt(t,e,n){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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)&&gt(e,n);case\"$nin\":return!!Array.isArray(n)&&!gt(e,n);case\"$not\":return!vt(n,e);case\"$size\":return!!Array.isArray(e)&&vt(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=mt(e)?t=>vt(e,t):t=>yt(t,e);for(let e=0;e<t.length;e++)if(t[e]&&n(t[e]))return!0;return!1}(e,n);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let r=0;r<e.length;r++)if(vt(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,wt[i]||(wt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),wt[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 kt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(yt(t,e[n]))return!0;return!1}const St=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,At=function(){let t;try{t=\"1.0.1\"}catch(e){t=\"\"}return t}();class _t{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}}window.dataLayer=window.dataLayer||[];const xt=document.currentScript,Et=xt?xt.dataset:{},Ct=window.growthbook_config||{};function Ot(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function $t(){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 Rt=Ct.uuidCookieName||Et.uuidCookieName||\"gbuuid\",Bt=Ct.uuidKey||Et.uuidKey||\"id\";let Ft,Tt=Ct.uuid||Et.uuid||\"\";function Nt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Rt,Tt)}function Mt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Ut(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Vt(){const t=Et.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Tt||(Tt=Ot(Rt),Tt||(Tt=$t(),t&&Nt(),Tt))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Nt(),{...Ut(),[Bt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Mt()}}(Et,Ct);return Ct.attributes&&Object.assign(t,Ct.attributes),t}\"cookie\"===Ct.useStickyBucketService||\"cookie\"===Et.useStickyBucketService?Ft=new class extends _t{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(this.prefix+n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(this.prefix+e,n,this.cookieAttributes)}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Ct.useStickyBucketService&&\"localStorage\"!==Et.useStickyBucketService||(Ft=new class extends _t{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=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(this.prefix+n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(this.prefix+e,JSON.stringify(t))}catch(t){}}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0}));const It=new class{constructor(t){if(t=t||{},this.version=At,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),St&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments?(this.ready=!0,this.B()):t.antiFlicker&&this.F(),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.T=t;const e=await this.decryptPayload(t);this.N=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,this.M()}initSync(t){this.C=!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\");if(this.T=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return this}async init(t){if(this.C=!0,(t=t||{}).payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&_(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.U({...t,allowStale:!0});await this.setPayload(e||{}),this.V()&&_(this)}async refreshFeatures(t){const e=await this.U({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.T||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async U(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(y.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=C(e),o=O(e),u=new Date,c=new Date(u.getTime()-y.maxAge+y.staleTTL);await async function(){if(!g){g=!0;try{if(p.localStorage){const t=await p.localStorage.getItem(y.cacheKey);if(!y.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;b.set(e,{...n,staleAt:new Date(n.staleAt)})})),$()}}}catch(t){}{const t=v.startIdleListener();t&&(v.stopIdleListener=t)}}}();const a=y.disableCache||r?void 0:b.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&&A.add(s),a.staleAt<u?B(e):F(e),{data:a.data,success:!0,source:\"cache\"};{const t=await function(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}(B(e),i);return t||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}M(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.M()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){return(t={...t}).encryptedFeatures&&(t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n)),delete t.encryptedExperiments),t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.M(),this.B())}setForcedFeatures(t){this.k=t,this.M()}async setURL(t){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}V(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.U({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.T=void 0,this.m&&clearTimeout(this.m),t=this,m.forEach((e=>e.delete(t))),St&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.M())}run(t){const e=this.D(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;const i=this.K(t)?this.L(t,-1,!1,\"\"):this.run(t),r=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===r)return i;if(n&&this.H(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.q(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const n=this.P();var s;if(n)if(St)this.F(),window.setTimeout((()=>{try{n(e)}catch(t){console.error(t)}}),null!==(s=this.i.navigateDelay)&&void 0!==s?s:100);else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(i.value):this.G(i.value);e&&this.A.set(t,{undo:e,valueHash:r})}}return i}H(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}Z(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}St&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}W(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.Z(t,o),o}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 this.X(t)}X(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.W(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.W(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.W(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.X(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.W(t,null,\"cyclicPrerequisite\");if(!yt({value:i.value},n.condition||{})){if(n.gate)return this.W(t,null,\"prerequisite\");continue t}}if(i.filters&&this.Y(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.tt(i.condition))continue;if(!this.et(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.nt(t.experiment,t.result)})),this.W(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const r=this.D(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.W(t,r.value,\"experiment\",i.id,n,r)}return this.W(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}et(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.it(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}tt(t){return yt(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}D(t,e){const n=t.key,i=t.variations.length;if(i<2)return this.L(t,-1,!1,e);if(!1===this.i.enabled)return this.L(t,-1,!1,e);if((t=this.rt(t)).urlPatterns&&!u(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.q(),i);if(null!==o)return this.L(t,o,!1,e);if(this.i.forcedVariations&&n in this.i.forcedVariations)return this.L(t,this.i.forcedVariations[n],!1,e);if(\"draft\"===t.status||!1===t.active)return this.L(t,-1,!1,e);const{hashAttribute:c,hashValue:a}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return this.L(t,-1,!1,e);let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.st({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return this.L(t,-1,!1,e);if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return this.L(t,-1,!1,e);if(t.condition&&!this.tt(t.condition))return this.L(t,-1,!1,e);if(t.parentConditions)for(const n of t.parentConditions){const i=this.X(n.id);if(\"cyclicPrerequisite\"===i.source)return this.L(t,-1,!1,e);if(!yt({value:i.value},n.condition||{}))return this.L(t,-1,!1,e)}if(t.groups&&!this.ot(t.groups))return this.L(t,-1,!1,e)}if(t.url&&!this.ut(t.url))return this.L(t,-1,!1,e);const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return this.L(t,-1,!1,e);if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return this.L(t,-1,!1,e,void 0,!0);if(h<0)return this.L(t,-1,!1,e);if(\"force\"in t)return this.L(t,void 0===t.force?-1:t.force,!1,e);if(this.i.qaMode)return this.L(t,-1,!1,e);if(\"stopped\"===t.status)return this.L(t,-1,!1,e);const y=this.L(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(c,l(a),{[this.ht(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,y),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),y}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.lt(t.experiment,t.result),t])))}fireDeferredTrackingCalls(){this.i.trackingCallback&&(this.$.forEach((t=>{t&&t.experiment&&t.result?this.nt(t.experiment,t.result):console.error(\"Invalid deferred tracking call\",{call:t})})),this.$.clear())}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}lt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}nt(t,e){const n=this.lt(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}rt(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}it(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}L(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}q(){return this.i.url||(St?window.location.href:\"\")}ut(t){const e=this.q();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}ot(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}K(t){const e=w(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.O}P(){return this.i.navigate?this.i.navigate:St?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&St)try{var t;const e=document.createElement(\"style\");e.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(e),document.documentElement.classList.add(\"gb-anti-flicker\"),setTimeout((()=>{document.documentElement.classList.remove(\"gb-anti-flicker\")}),null!==(t=this.i.antiFlickerTimeout)&&void 0!==t?t:3500)}catch(t){console.error(t)}}G(t){if(!St)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return lt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return lt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return ft(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return ft(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return ft(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ht({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return dt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return dt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return dt(e,r,(function(){return null}))}return V}(t).revert)})),()=>{e.forEach((t=>t()))}}ft(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.dt(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}wt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.it(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.it(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}st(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ht(e,n),c=this.wt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ht(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ht(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}dt(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.i.stickyBucketIdentifierAttributes?this.i.stickyBucketIdentifierAttributes:this.ft(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.it(t);e[t]=l(n)})),e}ct(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...Et,remoteEval:!!Et.remoteEval,trackingCallback:(t,e)=>{const n={experiment_id:t.key,variation_id:e.key};window.gtag&&window.gtag(\"event\",\"experiment_viewed\",n),window.dataLayer&&window.dataLayer.push({event:\"experiment_viewed\",...n}),window.analytics&&window.analytics.track&&window.analytics.track(\"Experiment Viewed\",n)},...Ct,attributes:Vt(),stickyBucketService:Ft});It.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),It.init({payload:Ct.payload,streaming:!(Ct.noStreaming||Et.noStreaming||!1===Ct.backgroundSync)});let Dt=location.href;setInterval((()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt),It.updateAttributes(Vt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt)),It.updateAttributes(Vt())})),document.addEventListener(\"growthbookpersist\",(()=>{Nt()}));const Jt=t=>{try{t&&t(It)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{Jt(t)})),window.growthbook_queue={push:t=>{Jt(t)}},It}();\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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function y(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const p={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},v=n,m={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return v.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return v.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new v.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new v.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),A.forEach((t=>{t&&\"idle\"===t.state&&U(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(C,p.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(v.localStorage=globalThis.localStorage)}catch(t){}const g=new Map;let b=!1;const k=new Map,S=new Map,A=new Map,_=new Set;function x(t){const e=E(t),n=g.get(e)||new Set;n.add(t),g.set(e,n)}function C(){A.forEach((t=>{t&&(t.state=\"idle\",M(t))}))}async function O(){try{if(!v.localStorage)return;await v.localStorage.setItem(p.cacheKey,JSON.stringify(Array.from(k.entries())))}catch(t){}}function E(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function $(t){const e=E(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function R(){const t=Array.from(k.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,k.size-p.maxEntries),k.size);for(let n=0;n<e;n++)k.delete(t[n].key)}function B(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+p.staleTTL),s=p.disableCache?void 0:k.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void O();p.disableCache||(k.set(e,{data:n,version:i,staleAt:r,sse:_.has(t)}),R()),O();const o=g.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function F(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=E(t),o=$(t);let u=S.get(o);return u||(u=(r?m.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):m.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&_.add(s),t.json()})).then((e=>(B(s,o,e),N(t),S.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(S.delete(o),{data:null,source:\"error\",success:!1,error:t}))),S.set(o,u)),u}function N(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=E(t),i=$(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&_.add(n),p.backgroundSync&&_.has(n)&&v.EventSource){if(A.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=g.get(n);t&&t.forEach((t=>{F(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);B(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};A.set(n,t),U(t)}}function T(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());M(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||U(t)}),Math.min(e,3e5))}}function M(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function U(t){t.src=m.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}function I(t,e){M(t),A.delete(e)}var V=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,J={revert:function(){}},j=new Map,D=new Set;function P(t){var e=j.get(t);return e||j.set(t,e={element:t,attributes:{}}),e}function K(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 L(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,at()):t!==n&&(e.isDirty=!0,at())}function H(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(function(t){return et||(et=document.createElement(\"div\")),et.innerHTML=t,et.innerHTML}(e),t)}function q(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),L(Array.from(e).filter(Boolean).join(\" \"),t)}function G(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(e,t)}function z(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),L(e,t)}var Z=function(t){return t.innerHTML},Q=function(t,e){return t.innerHTML=e};function W(t){var e=P(t);return e.html||(e.html=K(t,\"html\",Z,Q,H)),e.html}var X=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},Y=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function tt(t){var e=P(t);return e.position||(e.position=K(t,\"position\",X,Y,z)),e.position}var et,nt,it=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},rt=function(t){return t.className};function st(t){var e=P(t);return e.classes||(e.classes=K(t,\"class\",rt,it,q)),e.classes}function ot(t,e){var n,i=P(t);return i.attributes[e]||(i.attributes[e]=K(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),G)),i.attributes[e]}function ut(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=j.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ct(t,e){t.html&&ut(e,\"html\",t.html),t.classes&&ut(e,\"class\",t.classes),t.position&&ut(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){ut(e,n,t.attributes[n])}))}function at(){j.forEach(ct)}function ht(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=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function lt(){D.forEach(ht)}function ft(t){return\"undefined\"==typeof document?J:(D.add(t),ht(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function dt(t,e){return ft({kind:\"html\",elements:new Set,mutate:e,selector:t})}function wt(t,e){return ft({kind:\"class\",elements:new Set,mutate:e,selector:t})}function yt(t,e,n){return V.test(e)?\"class\"===e||\"className\"===e?wt(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ft({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):J}\"undefined\"!=typeof document&&(nt||(nt=new MutationObserver((function(){lt()}))),lt(),nt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const pt={};function vt(t,e,n){n=n||{};for(const[i,r]of Object.entries(e))switch(i){case\"$or\":if(!At(t,r,n))return!1;break;case\"$nor\":if(At(t,r,n))return!1;break;case\"$and\":if(!_t(t,r,n))return!1;break;case\"$not\":if(vt(t,r,n))return!1;break;default:if(!gt(r,mt(t,i),n))return!1}return!0}function mt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}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 i in t)if(!St(i,e,t[i],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,i){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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,i[n]||[]);case\"$notInGroup\":return!kt(e,i[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,i);case\"$size\":return!!Array.isArray(e)&&gt(n,e.length,i);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const i=bt(e)?t=>gt(e,t,n):t=>vt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&i(t[e]))return!0;return!1}(e,n,i);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let r=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],i)){r=!0;break}if(!r)return!1}return!0;case\"$regex\":try{return(r=n,pt[r]||(pt[r]=new RegExp(r.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[r]).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 r}function At(t,e,n){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(vt(t,e[i],n))return!0;return!1}function _t(t,e,n){for(let i=0;i<e.length;i++)if(!vt(t,e[i],n))return!1;return!0}const xt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ct=function(){let t;try{t=\"1.2.1\"}catch(e){t=\"\"}return t}();class Ot{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}getKey(t,e){return\"\".concat(this.prefix).concat(t,\"||\").concat(e)}}window.dataLayer=window.dataLayer||[];const Et=document.currentScript,$t=Et?Et.dataset:{},Rt=window.growthbook_config||{};function Bt(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function Ft(){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 Nt=Rt.uuidCookieName||$t.uuidCookieName||\"gbuuid\",Tt=Rt.uuidKey||$t.uuidKey||\"id\";let Mt,Ut,It=Rt.uuid||$t.uuid||\"\";function Vt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Nt,It)}function Jt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function jt(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Dt(){const t=$t.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return It||(It=Bt(Nt),It||(It=Ft(),t&&Vt(),It))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Vt(),{...jt(),[Tt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Jt()}}($t,Rt);return Rt.attributes&&Object.assign(t,Rt.attributes),t}function Pt(){var t,e;window.clearTimeout(Mt);let n=null!==(t=null!==(e=Rt.antiFlickerTimeout)&&void 0!==e?e:$t.antiFlickerTimeout?parseInt($t.antiFlickerTimeout):null)&&void 0!==t?t:3500;isFinite(n)||(n=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\"),Mt=window.setTimeout(Kt,n)}catch(t){console.error(t)}}function Kt(){window.clearTimeout(Mt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(Rt.antiFlicker||$t.antiFlicker)&&Pt(),\"cookie\"===Rt.useStickyBucketService||\"cookie\"===$t.useStickyBucketService?Ut=new class extends Ot{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=this.getKey(t,e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Rt.useStickyBucketService&&\"localStorage\"!==$t.useStickyBucketService||(Ut=new class extends Ot{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 i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0}));const Lt=new class{constructor(t){if(t=t||{},this.version=Ct,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),xt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.B()),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.F=t;const e=await this.decryptPayload(t);this.N=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.B()),this.ready=!0,this.T()}initSync(t){this.C=!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\");if(this.F=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return this}async init(t){if(this.C=!0,(t=t||{}).cacheSettings&&(Object.assign(p,t.cacheSettings),p.backgroundSync||(_.clear(),A.forEach(I),g.clear(),m.stopIdleListener())),t.payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.M({...t,allowStale:!0});return t.streaming&&x(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.M({...t,allowStale:!0});await this.setPayload(e||{}),this.U()&&x(this)}async refreshFeatures(t){const e=await this.M({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.F||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async M(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(p.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=E(e),o=$(e),u=new Date,c=new Date(u.getTime()-p.maxAge+p.staleTTL);await async function(){if(!b){b=!0;try{if(v.localStorage){const t=await v.localStorage.getItem(p.cacheKey);if(!p.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;k.set(e,{...n,staleAt:new Date(n.staleAt)})})),R()}}}catch(t){}if(!p.disableIdleStreams){const t=m.startIdleListener();t&&(m.stopIdleListener=t)}}}();const a=p.disableCache||r?void 0:k.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&_.add(s),a.staleAt<u?F(e):N(e),{data:a.data,success:!0,source:\"cache\"}):await y(F(e),i)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}T(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.T()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await h(t.encryptedSavedGroups,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.T(),this.B())}setForcedFeatures(t){this.k=t,this.T()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}U(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.M({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.F=void 0,this.m&&clearTimeout(this.m),t=this,g.forEach((e=>e.delete(t))),xt&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.T())}run(t){const{result:e}=this.V(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;let i,r;this.D(t)?i=this.P(t,-1,!1,\"\"):(({result:i,trackingCall:r}=this.V(t,null)),this.J(t,i));const s=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===s)return i;if(n&&this.K(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.L(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const{navigate:n,delay:s}=this.H();var o;if(n)if(xt)Promise.all([...r?[y(r,null!==(o=this.i.maxNavigateDelay)&&void 0!==o?o:1e3)]:[],new Promise((t=>{var e;return window.setTimeout(t,null!==(e=this.i.navigateDelay)&&void 0!==e?e: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(i.value):this.q(i.value);e&&this.A.set(t,{undo:e,valueHash:s})}}return i}K(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}G(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}xt&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}Z(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.G(t,o),o}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 this.W(t)}W(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.Z(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.Z(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.Z(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.W(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.Z(t,null,\"cyclicPrerequisite\");if(!vt({value:i.value},n.condition||{})){if(n.gate)return this.Z(t,null,\"prerequisite\");continue t}}if(i.filters&&this.X(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.Y(i.condition))continue;if(!this.tt(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.et(t.experiment,t.result)})),this.Z(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const{result:r}=this.V(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.Z(t,r.value,\"experiment\",i.id,n,r)}return this.Z(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}tt(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.nt(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}Y(t){return vt(this.getAttributes(),t,this.i.savedGroups||{})}X(t){return t.some((t=>{const{hashValue:e}=this.nt(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}V(t,e){const n=t.key,i=t.variations.length;if(i<2)return{result:this.P(t,-1,!1,e)};if(!1===this.i.enabled)return{result:this.P(t,-1,!1,e)};if((t=this.it(t)).urlPatterns&&!u(this.L(),t.urlPatterns))return{result:this.P(t,-1,!1,e)};const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.L(),i);if(null!==o)return{result:this.P(t,o,!1,e)};if(this.i.forcedVariations&&n in this.i.forcedVariations)return{result:this.P(t,this.i.forcedVariations[n],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:this.P(t,-1,!1,e)};const{hashAttribute:c,hashValue:a}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return{result:this.P(t,-1,!1,e)};let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.rt({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.X(t.filters))return{result:this.P(t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return{result:this.P(t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:this.P(t,-1,!1,e)};if(t.condition&&!this.Y(t.condition))return{result:this.P(t,-1,!1,e)};if(t.parentConditions)for(const n of t.parentConditions){const i=this.W(n.id);if(\"cyclicPrerequisite\"===i.source)return{result:this.P(t,-1,!1,e)};if(!vt({value:i.value},n.condition||{}))return{result:this.P(t,-1,!1,e)}}if(t.groups&&!this.st(t.groups))return{result:this.P(t,-1,!1,e)}}if(t.url&&!this.ot(t.url))return{result:this.P(t,-1,!1,e)};const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return{result:this.P(t,-1,!1,e)};if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return{result:this.P(t,-1,!1,e,void 0,!0)};if(h<0)return{result:this.P(t,-1,!1,e)};if(\"force\"in t)return{result:this.P(t,void 0===t.force?-1:t.force,!1,e)};if(this.i.qaMode)return{result:this.P(t,-1,!1,e)};if(\"stopped\"===t.status)return{result:this.P(t,-1,!1,e)};const y=this.P(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ut(c,l(a),{[this.ct(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}const p=this.et(t,y);return\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),{result:y,trackingCall:p}}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.ht(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.$.forEach((e=>{e&&e.experiment&&e.result?t.push(this.et(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.$.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}ht(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}async et(t,e){const n=this.ht(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}it(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}nt(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}P(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}L(){return this.i.url||(xt?window.location.href:\"\")}ot(t){const e=this.L();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}st(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}D(t){const e=w(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.L());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.O}H(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:xt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}q(t){if(!xt)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return dt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return dt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return wt(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return wt(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return wt(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ft({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return yt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return yt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return yt(e,r,(function(){return null}))}return J}(t).revert)})),()=>{e.forEach((t=>t()))}}lt(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.ft(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}dt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.nt(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.nt(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}rt(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ct(e,n),c=this.dt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ct(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ct(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}ft(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.lt(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.nt(t);e[t]=l(n)})),e}ut(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...$t,remoteEval:!!$t.remoteEval,trackingCallback:async(t,e)=>{const n=[],i={experiment_id:t.key,variation_id:e.key};if(Rt.additionalTrackingCallback&&n.push(Promise.resolve(Rt.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...i,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...i,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",i);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...Rt,attributes:Dt(),stickyBucketService:Ut});Lt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Lt.init({payload:Rt.payload,streaming:!(Rt.noStreaming||$t.noStreaming||!1===Rt.backgroundSync),cacheSettings:Rt.cacheSettings}).then((()=>{(Rt.antiFlicker||$t.antiFlicker)&&(Lt.getRedirectUrl()?Pt():Kt())}));let Ht=location.href;setInterval((()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht),Lt.updateAttributes(Dt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht)),Lt.updateAttributes(Dt())})),document.addEventListener(\"growthbookpersist\",(()=>{Vt()}));const qt=t=>{try{t&&t(Lt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{qt(t)})),window.growthbook_queue={push:t=>{qt(t)}},Lt}();\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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const y={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},p=n,v={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return p.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return p.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new p.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new p.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),S.forEach((t=>{t&&\"idle\"===t.state&&M(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(x,y.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(p.localStorage=globalThis.localStorage)}catch(t){}const m=new Map;let g=!1;const b=new Map,k=new Map,S=new Map,A=new Set;function _(t){const e=C(t),n=m.get(e)||new Set;n.add(t),m.set(e,n)}function x(){S.forEach((t=>{t&&(t.state=\"idle\",N(t))}))}async function E(){try{if(!p.localStorage)return;await p.localStorage.setItem(y.cacheKey,JSON.stringify(Array.from(b.entries())))}catch(t){}}function C(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function O(t){const e=C(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function $(){const t=Array.from(b.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,b.size-y.maxEntries),b.size);for(let n=0;n<e;n++)b.delete(t[n].key)}function R(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+y.staleTTL),s=b.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void E();b.set(e,{data:n,version:i,staleAt:r,sse:A.has(t)}),$(),E();const o=m.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function B(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=C(t),o=O(t);let u=k.get(o);return u||(u=(r?v.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):v.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&A.add(s),t.json()})).then((e=>(R(s,o,e),F(t),k.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(k.delete(o),{data:null,source:\"error\",success:!1,error:t}))),k.set(o,u)),u}function F(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=C(t),i=O(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&A.add(n),y.backgroundSync&&A.has(n)&&p.EventSource){if(S.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=m.get(n);t&&t.forEach((t=>{B(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);R(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};S.set(n,t),M(t)}}function T(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());N(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||M(t)}),Math.min(e,3e5))}}function N(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function M(t){t.src=v.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}var U=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,V={revert:function(){}},I=new Map,D=new Set;function J(t){var e=I.get(t);return e||I.set(t,e={element:t,attributes:{}}),e}function j(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 K(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,ut()):t!==n&&(e.isDirty=!0,ut())}function L(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(function(t){return Y||(Y=document.createElement(\"div\")),Y.innerHTML=t,Y.innerHTML}(e),t)}function H(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),K(Array.from(e).filter(Boolean).join(\" \"),t)}function q(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(e,t)}function P(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),K(e,t)}var z=function(t){return t.innerHTML},G=function(t,e){return t.innerHTML=e};function Z(t){var e=J(t);return e.html||(e.html=j(t,\"html\",z,G,L)),e.html}var Q=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},W=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function X(t){var e=J(t);return e.position||(e.position=j(t,\"position\",Q,W,P)),e.position}var Y,tt,et=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},nt=function(t){return t.className};function it(t){var e=J(t);return e.classes||(e.classes=j(t,\"class\",nt,et,H)),e.classes}function rt(t,e){var n,i=J(t);return i.attributes[e]||(i.attributes[e]=j(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),q)),i.attributes[e]}function st(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=I.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ot(t,e){t.html&&st(e,\"html\",t.html),t.classes&&st(e,\"class\",t.classes),t.position&&st(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){st(e,n,t.attributes[n])}))}function ut(){I.forEach(ot)}function ct(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=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function at(){D.forEach(ct)}function ht(t){return\"undefined\"==typeof document?V:(D.add(t),ct(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function lt(t,e){return ht({kind:\"html\",elements:new Set,mutate:e,selector:t})}function ft(t,e){return ht({kind:\"class\",elements:new Set,mutate:e,selector:t})}function dt(t,e,n){return U.test(e)?\"class\"===e||\"className\"===e?ft(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ht({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):V}\"undefined\"!=typeof document&&(tt||(tt=new MutationObserver((function(){at()}))),at(),tt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const wt={};function yt(t,e){if(\"$or\"in e)return kt(t,e.$or);if(\"$nor\"in e)return!kt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!yt(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!yt(t,e.$not);for(const[n,i]of Object.entries(e))if(!vt(i,pt(t,n)))return!1;return!0}function pt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}function vt(t,e){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)||!mt(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!bt(n,e,t[n]))return!1;return!0}function mt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function gt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function bt(t,e,n){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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)&&gt(e,n);case\"$nin\":return!!Array.isArray(n)&&!gt(e,n);case\"$not\":return!vt(n,e);case\"$size\":return!!Array.isArray(e)&&vt(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=mt(e)?t=>vt(e,t):t=>yt(t,e);for(let e=0;e<t.length;e++)if(t[e]&&n(t[e]))return!0;return!1}(e,n);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let r=0;r<e.length;r++)if(vt(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,wt[i]||(wt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),wt[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 kt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(yt(t,e[n]))return!0;return!1}const St=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,At=function(){let t;try{t=\"1.0.1\"}catch(e){t=\"\"}return t}();class _t{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}}window.dataLayer=window.dataLayer||[];const xt=document.currentScript,Et=xt?xt.dataset:{},Ct=window.growthbook_config||{};function Ot(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function $t(){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 Rt=Ct.uuidCookieName||Et.uuidCookieName||\"gbuuid\",Bt=Ct.uuidKey||Et.uuidKey||\"id\";let Ft,Tt=Ct.uuid||Et.uuid||\"\";function Nt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Rt,Tt)}function Mt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Ut(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Vt(){const t=Et.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Tt||(Tt=Ot(Rt),Tt||(Tt=$t(),t&&Nt(),Tt))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Nt(),{...Ut(),[Bt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Mt()}}(Et,Ct);return Ct.attributes&&Object.assign(t,Ct.attributes),t}\"cookie\"===Ct.useStickyBucketService||\"cookie\"===Et.useStickyBucketService?Ft=new class extends _t{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(this.prefix+n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(this.prefix+e,n,this.cookieAttributes)}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Ct.useStickyBucketService&&\"localStorage\"!==Et.useStickyBucketService||(Ft=new class extends _t{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=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(this.prefix+n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(this.prefix+e,JSON.stringify(t))}catch(t){}}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0}));const It=new class{constructor(t){if(t=t||{},this.version=At,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),St&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments?(this.ready=!0,this.B()):t.antiFlicker&&this.F(),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.T=t;const e=await this.decryptPayload(t);this.N=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,this.M()}initSync(t){this.C=!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\");if(this.T=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return this}async init(t){if(this.C=!0,(t=t||{}).payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&_(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.U({...t,allowStale:!0});await this.setPayload(e||{}),this.V()&&_(this)}async refreshFeatures(t){const e=await this.U({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.T||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async U(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(y.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=C(e),o=O(e),u=new Date,c=new Date(u.getTime()-y.maxAge+y.staleTTL);await async function(){if(!g){g=!0;try{if(p.localStorage){const t=await p.localStorage.getItem(y.cacheKey);if(!y.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;b.set(e,{...n,staleAt:new Date(n.staleAt)})})),$()}}}catch(t){}{const t=v.startIdleListener();t&&(v.stopIdleListener=t)}}}();const a=y.disableCache||r?void 0:b.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&&A.add(s),a.staleAt<u?B(e):F(e),{data:a.data,success:!0,source:\"cache\"};{const t=await function(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}(B(e),i);return t||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}M(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.M()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){return(t={...t}).encryptedFeatures&&(t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n)),delete t.encryptedExperiments),t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.M(),this.B())}setForcedFeatures(t){this.k=t,this.M()}async setURL(t){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}V(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.U({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.T=void 0,this.m&&clearTimeout(this.m),t=this,m.forEach((e=>e.delete(t))),St&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.M())}run(t){const e=this.D(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;const i=this.K(t)?this.L(t,-1,!1,\"\"):this.run(t),r=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===r)return i;if(n&&this.H(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.q(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const n=this.P();var s;if(n)if(St)this.F(),window.setTimeout((()=>{try{n(e)}catch(t){console.error(t)}}),null!==(s=this.i.navigateDelay)&&void 0!==s?s:100);else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(i.value):this.G(i.value);e&&this.A.set(t,{undo:e,valueHash:r})}}return i}H(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}Z(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}St&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}W(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.Z(t,o),o}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 this.X(t)}X(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.W(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.W(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.W(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.X(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.W(t,null,\"cyclicPrerequisite\");if(!yt({value:i.value},n.condition||{})){if(n.gate)return this.W(t,null,\"prerequisite\");continue t}}if(i.filters&&this.Y(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.tt(i.condition))continue;if(!this.et(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.nt(t.experiment,t.result)})),this.W(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const r=this.D(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.W(t,r.value,\"experiment\",i.id,n,r)}return this.W(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}et(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.it(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}tt(t){return yt(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}D(t,e){const n=t.key,i=t.variations.length;if(i<2)return this.L(t,-1,!1,e);if(!1===this.i.enabled)return this.L(t,-1,!1,e);if((t=this.rt(t)).urlPatterns&&!u(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.q(),i);if(null!==o)return this.L(t,o,!1,e);if(this.i.forcedVariations&&n in this.i.forcedVariations)return this.L(t,this.i.forcedVariations[n],!1,e);if(\"draft\"===t.status||!1===t.active)return this.L(t,-1,!1,e);const{hashAttribute:c,hashValue:a}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return this.L(t,-1,!1,e);let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.st({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return this.L(t,-1,!1,e);if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return this.L(t,-1,!1,e);if(t.condition&&!this.tt(t.condition))return this.L(t,-1,!1,e);if(t.parentConditions)for(const n of t.parentConditions){const i=this.X(n.id);if(\"cyclicPrerequisite\"===i.source)return this.L(t,-1,!1,e);if(!yt({value:i.value},n.condition||{}))return this.L(t,-1,!1,e)}if(t.groups&&!this.ot(t.groups))return this.L(t,-1,!1,e)}if(t.url&&!this.ut(t.url))return this.L(t,-1,!1,e);const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return this.L(t,-1,!1,e);if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return this.L(t,-1,!1,e,void 0,!0);if(h<0)return this.L(t,-1,!1,e);if(\"force\"in t)return this.L(t,void 0===t.force?-1:t.force,!1,e);if(this.i.qaMode)return this.L(t,-1,!1,e);if(\"stopped\"===t.status)return this.L(t,-1,!1,e);const y=this.L(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(c,l(a),{[this.ht(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,y),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),y}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.lt(t.experiment,t.result),t])))}fireDeferredTrackingCalls(){this.i.trackingCallback&&(this.$.forEach((t=>{t&&t.experiment&&t.result?this.nt(t.experiment,t.result):console.error(\"Invalid deferred tracking call\",{call:t})})),this.$.clear())}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}lt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}nt(t,e){const n=this.lt(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}rt(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}it(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}L(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}q(){return this.i.url||(St?window.location.href:\"\")}ut(t){const e=this.q();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}ot(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}K(t){const e=w(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.O}P(){return this.i.navigate?this.i.navigate:St?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&St)try{var t;const e=document.createElement(\"style\");e.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(e),document.documentElement.classList.add(\"gb-anti-flicker\"),setTimeout((()=>{document.documentElement.classList.remove(\"gb-anti-flicker\")}),null!==(t=this.i.antiFlickerTimeout)&&void 0!==t?t:3500)}catch(t){console.error(t)}}G(t){if(!St)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return lt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return lt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return ft(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return ft(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return ft(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ht({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return dt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return dt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return dt(e,r,(function(){return null}))}return V}(t).revert)})),()=>{e.forEach((t=>t()))}}ft(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.dt(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}wt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.it(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.it(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}st(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ht(e,n),c=this.wt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ht(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ht(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}dt(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.i.stickyBucketIdentifierAttributes?this.i.stickyBucketIdentifierAttributes:this.ft(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.it(t);e[t]=l(n)})),e}ct(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...Et,remoteEval:!!Et.remoteEval,trackingCallback:(t,e)=>{const n={experiment_id:t.key,variation_id:e.key};window.gtag&&window.gtag(\"event\",\"experiment_viewed\",n),window.dataLayer&&window.dataLayer.push({event:\"experiment_viewed\",...n}),window.analytics&&window.analytics.track&&window.analytics.track(\"Experiment Viewed\",n)},...Ct,attributes:Vt(),stickyBucketService:Ft});It.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),It.init({payload:Ct.payload,streaming:!(Ct.noStreaming||Et.noStreaming||!1===Ct.backgroundSync)});let Dt=location.href;setInterval((()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt),It.updateAttributes(Vt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt)),It.updateAttributes(Vt())})),document.addEventListener(\"growthbookpersist\",(()=>{Nt()}));const Jt=t=>{try{t&&t(It)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{Jt(t)})),window.growthbook_queue={push:t=>{Jt(t)}},It}();\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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function y(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const p={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},v=n,m={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return v.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return v.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new v.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new v.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),A.forEach((t=>{t&&\"idle\"===t.state&&U(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(C,p.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(v.localStorage=globalThis.localStorage)}catch(t){}const g=new Map;let b=!1;const k=new Map,S=new Map,A=new Map,_=new Set;function x(t){const e=E(t),n=g.get(e)||new Set;n.add(t),g.set(e,n)}function C(){A.forEach((t=>{t&&(t.state=\"idle\",M(t))}))}async function O(){try{if(!v.localStorage)return;await v.localStorage.setItem(p.cacheKey,JSON.stringify(Array.from(k.entries())))}catch(t){}}function E(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function $(t){const e=E(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function R(){const t=Array.from(k.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,k.size-p.maxEntries),k.size);for(let n=0;n<e;n++)k.delete(t[n].key)}function B(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+p.staleTTL),s=p.disableCache?void 0:k.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void O();p.disableCache||(k.set(e,{data:n,version:i,staleAt:r,sse:_.has(t)}),R()),O();const o=g.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function F(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=E(t),o=$(t);let u=S.get(o);return u||(u=(r?m.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):m.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&_.add(s),t.json()})).then((e=>(B(s,o,e),N(t),S.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(S.delete(o),{data:null,source:\"error\",success:!1,error:t}))),S.set(o,u)),u}function N(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=E(t),i=$(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&_.add(n),p.backgroundSync&&_.has(n)&&v.EventSource){if(A.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=g.get(n);t&&t.forEach((t=>{F(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);B(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};A.set(n,t),U(t)}}function T(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());M(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||U(t)}),Math.min(e,3e5))}}function M(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function U(t){t.src=m.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}function I(t,e){M(t),A.delete(e)}var V=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,J={revert:function(){}},j=new Map,D=new Set;function P(t){var e=j.get(t);return e||j.set(t,e={element:t,attributes:{}}),e}function K(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 L(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,at()):t!==n&&(e.isDirty=!0,at())}function H(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(function(t){return et||(et=document.createElement(\"div\")),et.innerHTML=t,et.innerHTML}(e),t)}function q(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),L(Array.from(e).filter(Boolean).join(\" \"),t)}function G(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(e,t)}function z(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),L(e,t)}var Z=function(t){return t.innerHTML},Q=function(t,e){return t.innerHTML=e};function W(t){var e=P(t);return e.html||(e.html=K(t,\"html\",Z,Q,H)),e.html}var X=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},Y=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function tt(t){var e=P(t);return e.position||(e.position=K(t,\"position\",X,Y,z)),e.position}var et,nt,it=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},rt=function(t){return t.className};function st(t){var e=P(t);return e.classes||(e.classes=K(t,\"class\",rt,it,q)),e.classes}function ot(t,e){var n,i=P(t);return i.attributes[e]||(i.attributes[e]=K(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),G)),i.attributes[e]}function ut(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=j.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ct(t,e){t.html&&ut(e,\"html\",t.html),t.classes&&ut(e,\"class\",t.classes),t.position&&ut(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){ut(e,n,t.attributes[n])}))}function at(){j.forEach(ct)}function ht(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=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function lt(){D.forEach(ht)}function ft(t){return\"undefined\"==typeof document?J:(D.add(t),ht(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function dt(t,e){return ft({kind:\"html\",elements:new Set,mutate:e,selector:t})}function wt(t,e){return ft({kind:\"class\",elements:new Set,mutate:e,selector:t})}function yt(t,e,n){return V.test(e)?\"class\"===e||\"className\"===e?wt(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ft({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):J}\"undefined\"!=typeof document&&(nt||(nt=new MutationObserver((function(){lt()}))),lt(),nt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const pt={};function vt(t,e,n){n=n||{};for(const[i,r]of Object.entries(e))switch(i){case\"$or\":if(!At(t,r,n))return!1;break;case\"$nor\":if(At(t,r,n))return!1;break;case\"$and\":if(!_t(t,r,n))return!1;break;case\"$not\":if(vt(t,r,n))return!1;break;default:if(!gt(r,mt(t,i),n))return!1}return!0}function mt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}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 i in t)if(!St(i,e,t[i],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,i){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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,i[n]||[]);case\"$notInGroup\":return!kt(e,i[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,i);case\"$size\":return!!Array.isArray(e)&&gt(n,e.length,i);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const i=bt(e)?t=>gt(e,t,n):t=>vt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&i(t[e]))return!0;return!1}(e,n,i);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let r=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],i)){r=!0;break}if(!r)return!1}return!0;case\"$regex\":try{return(r=n,pt[r]||(pt[r]=new RegExp(r.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[r]).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 r}function At(t,e,n){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(vt(t,e[i],n))return!0;return!1}function _t(t,e,n){for(let i=0;i<e.length;i++)if(!vt(t,e[i],n))return!1;return!0}const xt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ct=function(){let t;try{t=\"1.2.1\"}catch(e){t=\"\"}return t}();class Ot{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}getKey(t,e){return\"\".concat(this.prefix).concat(t,\"||\").concat(e)}}window.dataLayer=window.dataLayer||[];const Et=document.currentScript,$t=Et?Et.dataset:{},Rt=window.growthbook_config||{};function Bt(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function Ft(){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 Nt=Rt.uuidCookieName||$t.uuidCookieName||\"gbuuid\",Tt=Rt.uuidKey||$t.uuidKey||\"id\";let Mt,Ut,It=Rt.uuid||$t.uuid||\"\";function Vt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Nt,It)}function Jt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function jt(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Dt(){const t=$t.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return It||(It=Bt(Nt),It||(It=Ft(),t&&Vt(),It))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Vt(),{...jt(),[Tt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Jt()}}($t,Rt);return Rt.attributes&&Object.assign(t,Rt.attributes),t}function Pt(){var t,e;window.clearTimeout(Mt);let n=null!==(t=null!==(e=Rt.antiFlickerTimeout)&&void 0!==e?e:$t.antiFlickerTimeout?parseInt($t.antiFlickerTimeout):null)&&void 0!==t?t:3500;isFinite(n)||(n=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\"),Mt=window.setTimeout(Kt,n)}catch(t){console.error(t)}}function Kt(){window.clearTimeout(Mt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(Rt.antiFlicker||$t.antiFlicker)&&Pt(),\"cookie\"===Rt.useStickyBucketService||\"cookie\"===$t.useStickyBucketService?Ut=new class extends Ot{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=this.getKey(t,e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Rt.useStickyBucketService&&\"localStorage\"!==$t.useStickyBucketService||(Ut=new class extends Ot{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 i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0}));const Lt=new class{constructor(t){if(t=t||{},this.version=Ct,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),xt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.B()),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.F=t;const e=await this.decryptPayload(t);this.N=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.B()),this.ready=!0,this.T()}initSync(t){this.C=!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\");if(this.F=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return this}async init(t){if(this.C=!0,(t=t||{}).cacheSettings&&(Object.assign(p,t.cacheSettings),p.backgroundSync||(_.clear(),A.forEach(I),g.clear(),m.stopIdleListener())),t.payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.M({...t,allowStale:!0});return t.streaming&&x(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.M({...t,allowStale:!0});await this.setPayload(e||{}),this.U()&&x(this)}async refreshFeatures(t){const e=await this.M({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.F||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async M(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(p.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=E(e),o=$(e),u=new Date,c=new Date(u.getTime()-p.maxAge+p.staleTTL);await async function(){if(!b){b=!0;try{if(v.localStorage){const t=await v.localStorage.getItem(p.cacheKey);if(!p.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;k.set(e,{...n,staleAt:new Date(n.staleAt)})})),R()}}}catch(t){}if(!p.disableIdleStreams){const t=m.startIdleListener();t&&(m.stopIdleListener=t)}}}();const a=p.disableCache||r?void 0:k.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&_.add(s),a.staleAt<u?F(e):N(e),{data:a.data,success:!0,source:\"cache\"}):await y(F(e),i)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}T(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.T()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await h(t.encryptedSavedGroups,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.T(),this.B())}setForcedFeatures(t){this.k=t,this.T()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}U(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.M({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.F=void 0,this.m&&clearTimeout(this.m),t=this,g.forEach((e=>e.delete(t))),xt&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.T())}run(t){const{result:e}=this.V(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;let i,r;this.D(t)?i=this.P(t,-1,!1,\"\"):(({result:i,trackingCall:r}=this.V(t,null)),this.J(t,i));const s=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===s)return i;if(n&&this.K(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.L(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const{navigate:n,delay:s}=this.H();var o;if(n)if(xt)Promise.all([...r?[y(r,null!==(o=this.i.maxNavigateDelay)&&void 0!==o?o:1e3)]:[],new Promise((t=>{var e;return window.setTimeout(t,null!==(e=this.i.navigateDelay)&&void 0!==e?e: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(i.value):this.q(i.value);e&&this.A.set(t,{undo:e,valueHash:s})}}return i}K(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}G(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}xt&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}Z(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.G(t,o),o}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 this.W(t)}W(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.Z(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.Z(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.Z(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.W(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.Z(t,null,\"cyclicPrerequisite\");if(!vt({value:i.value},n.condition||{})){if(n.gate)return this.Z(t,null,\"prerequisite\");continue t}}if(i.filters&&this.X(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.Y(i.condition))continue;if(!this.tt(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.et(t.experiment,t.result)})),this.Z(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const{result:r}=this.V(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.Z(t,r.value,\"experiment\",i.id,n,r)}return this.Z(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}tt(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.nt(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}Y(t){return vt(this.getAttributes(),t,this.i.savedGroups||{})}X(t){return t.some((t=>{const{hashValue:e}=this.nt(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}V(t,e){const n=t.key,i=t.variations.length;if(i<2)return{result:this.P(t,-1,!1,e)};if(!1===this.i.enabled)return{result:this.P(t,-1,!1,e)};if((t=this.it(t)).urlPatterns&&!u(this.L(),t.urlPatterns))return{result:this.P(t,-1,!1,e)};const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.L(),i);if(null!==o)return{result:this.P(t,o,!1,e)};if(this.i.forcedVariations&&n in this.i.forcedVariations)return{result:this.P(t,this.i.forcedVariations[n],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:this.P(t,-1,!1,e)};const{hashAttribute:c,hashValue:a}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return{result:this.P(t,-1,!1,e)};let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.rt({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.X(t.filters))return{result:this.P(t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return{result:this.P(t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:this.P(t,-1,!1,e)};if(t.condition&&!this.Y(t.condition))return{result:this.P(t,-1,!1,e)};if(t.parentConditions)for(const n of t.parentConditions){const i=this.W(n.id);if(\"cyclicPrerequisite\"===i.source)return{result:this.P(t,-1,!1,e)};if(!vt({value:i.value},n.condition||{}))return{result:this.P(t,-1,!1,e)}}if(t.groups&&!this.st(t.groups))return{result:this.P(t,-1,!1,e)}}if(t.url&&!this.ot(t.url))return{result:this.P(t,-1,!1,e)};const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return{result:this.P(t,-1,!1,e)};if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return{result:this.P(t,-1,!1,e,void 0,!0)};if(h<0)return{result:this.P(t,-1,!1,e)};if(\"force\"in t)return{result:this.P(t,void 0===t.force?-1:t.force,!1,e)};if(this.i.qaMode)return{result:this.P(t,-1,!1,e)};if(\"stopped\"===t.status)return{result:this.P(t,-1,!1,e)};const y=this.P(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ut(c,l(a),{[this.ct(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}const p=this.et(t,y);return\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),{result:y,trackingCall:p}}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.ht(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.$.forEach((e=>{e&&e.experiment&&e.result?t.push(this.et(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.$.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}ht(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}async et(t,e){const n=this.ht(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}it(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}nt(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}P(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}L(){return this.i.url||(xt?window.location.href:\"\")}ot(t){const e=this.L();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}st(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}D(t){const e=w(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.L());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.O}H(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:xt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}q(t){if(!xt)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return dt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return dt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return wt(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return wt(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return wt(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ft({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return yt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return yt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return yt(e,r,(function(){return null}))}return J}(t).revert)})),()=>{e.forEach((t=>t()))}}lt(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.ft(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}dt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.nt(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.nt(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}rt(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ct(e,n),c=this.dt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ct(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ct(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}ft(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.lt(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.nt(t);e[t]=l(n)})),e}ut(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...$t,remoteEval:!!$t.remoteEval,trackingCallback:async(t,e)=>{const n=[],i={experiment_id:t.key,variation_id:e.key};if(Rt.additionalTrackingCallback&&n.push(Promise.resolve(Rt.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...i,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...i,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",i);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...Rt,attributes:Dt(),stickyBucketService:Ut});Lt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Lt.init({payload:Rt.payload,streaming:!(Rt.noStreaming||$t.noStreaming||!1===Rt.backgroundSync),cacheSettings:Rt.cacheSettings}).then((()=>{(Rt.antiFlicker||$t.antiFlicker)&&(Lt.getRedirectUrl()?Pt():Kt())}));let Ht=location.href;setInterval((()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht),Lt.updateAttributes(Dt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht)),Lt.updateAttributes(Dt())})),document.addEventListener(\"growthbookpersist\",(()=>{Vt()}));const qt=t=>{try{t&&t(Lt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{qt(t)})),window.growthbook_queue={push:t=>{qt(t)}},Lt}();\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,+h0CAA+h0C,CAAC"}
1
+ {"version":3,"file":"sdkWrapper.js","sourceRoot":"","sources":["../../src/generated/sdkWrapper.ts"],"names":[],"mappings":";;;AACa,QAAA,UAAU,GAAG,663CAA663C,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { StickyAssignmentsDocument, StickyBucketService } from "@growthbook/growthbook";
2
2
  import { Context } from "./types";
3
3
  export declare class EdgeStickyBucketService<Req, Res> extends StickyBucketService {
4
+ protected prefix: string;
4
5
  private context;
5
- private prefix;
6
6
  private req;
7
7
  constructor({ context, prefix, req, }: {
8
8
  context: Context<Req, Res>;
@@ -21,13 +21,13 @@ class EdgeStickyBucketService extends growthbook_1.StickyBucketService {
21
21
  getAssignments(attributeName, attributeValue) {
22
22
  var _a, _b;
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- const key = `${attributeName}||${attributeValue}`;
24
+ const key = this.getKey(attributeName, attributeValue);
25
25
  let doc = null;
26
26
  if (!this.req)
27
27
  return doc;
28
28
  try {
29
29
  // const raw = this.req.cookies[this.prefix + key] || "{}";
30
- const raw = ((_b = (_a = this.context.helpers) === null || _a === void 0 ? void 0 : _a.getCookie) === null || _b === void 0 ? void 0 : _b.call(_a, this.req, this.prefix + key)) || "{}";
30
+ const raw = ((_b = (_a = this.context.helpers) === null || _a === void 0 ? void 0 : _a.getCookie) === null || _b === void 0 ? void 0 : _b.call(_a, this.req, key)) || "{}";
31
31
  const data = JSON.parse(raw);
32
32
  if (data.attributeName && data.attributeValue && data.assignments) {
33
33
  doc = data;
@@ -1 +1 @@
1
- {"version":3,"file":"stickyBucketService.js","sourceRoot":"","sources":["../src/stickyBucketService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAGgC;AAGhC,MAAa,uBAAkC,SAAQ,gCAAmB;IAKxE,YAAY,EACV,OAAO,EACP,MAAM,GAAG,mBAAmB,EAC5B,GAAG,GAKJ;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEK,cAAc,CAAC,aAAqB,EAAE,cAAsB;;;YAChE,MAAM,GAAG,GAAG,GAAG,aAAa,KAAK,cAAc,EAAE,CAAC;YAClD,IAAI,GAAG,GAAqC,IAAI,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,GAAG;gBAAE,OAAO,GAAG,CAAC;YAC1B,IAAI;gBACF,2DAA2D;gBAC3D,MAAM,GAAG,GACP,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,SAAS,mDAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAI,IAAI,CAAC;gBACzE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,EAAE;oBACjE,GAAG,GAAG,IAAI,CAAC;iBACZ;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,uBAAuB;aACxB;YACD,OAAO,GAAG,CAAC;;KACZ;IAEK,eAAe,CAAC,CAA4B;;YAChD,uEAAuE;QACzE,CAAC;KAAA;CACF;AAzCD,0DAyCC"}
1
+ {"version":3,"file":"stickyBucketService.js","sourceRoot":"","sources":["../src/stickyBucketService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAGgC;AAGhC,MAAa,uBAAkC,SAAQ,gCAAmB;IAKxE,YAAY,EACV,OAAO,EACP,MAAM,GAAG,mBAAmB,EAC5B,GAAG,GAKJ;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEK,cAAc,CAAC,aAAqB,EAAE,cAAsB;;;YAChE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;YACvD,IAAI,GAAG,GAAqC,IAAI,CAAC;YACjD,IAAI,CAAC,IAAI,CAAC,GAAG;gBAAE,OAAO,GAAG,CAAC;YAC1B,IAAI;gBACF,2DAA2D;gBAC3D,MAAM,GAAG,GACP,CAAA,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,SAAS,mDAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KAAI,IAAI,CAAC;gBAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,EAAE;oBACjE,GAAG,GAAG,IAAI,CAAC;iBACZ;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,uBAAuB;aACxB;YACD,OAAO,GAAG,CAAC;;KACZ;IAEK,eAAe,CAAC,CAA4B;;YAChD,uEAAuE;QACzE,CAAC;KAAA;CACF;AAzCD,0DAyCC"}
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.1.4",
4
+ "version": "0.1.6",
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.0.1",
22
+ "@growthbook/growthbook": "^1.2.1",
23
23
  "node-html-parser": "^6.1.13"
24
24
  },
25
25
  "devDependencies": {
@@ -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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const y={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},p=n,v={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return p.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return p.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new p.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new p.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),S.forEach((t=>{t&&\"idle\"===t.state&&M(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(x,y.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(p.localStorage=globalThis.localStorage)}catch(t){}const m=new Map;let g=!1;const b=new Map,k=new Map,S=new Map,A=new Set;function _(t){const e=C(t),n=m.get(e)||new Set;n.add(t),m.set(e,n)}function x(){S.forEach((t=>{t&&(t.state=\"idle\",N(t))}))}async function E(){try{if(!p.localStorage)return;await p.localStorage.setItem(y.cacheKey,JSON.stringify(Array.from(b.entries())))}catch(t){}}function C(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function O(t){const e=C(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function $(){const t=Array.from(b.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,b.size-y.maxEntries),b.size);for(let n=0;n<e;n++)b.delete(t[n].key)}function R(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+y.staleTTL),s=b.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void E();b.set(e,{data:n,version:i,staleAt:r,sse:A.has(t)}),$(),E();const o=m.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function B(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=C(t),o=O(t);let u=k.get(o);return u||(u=(r?v.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):v.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&A.add(s),t.json()})).then((e=>(R(s,o,e),F(t),k.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(k.delete(o),{data:null,source:\"error\",success:!1,error:t}))),k.set(o,u)),u}function F(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=C(t),i=O(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&A.add(n),y.backgroundSync&&A.has(n)&&p.EventSource){if(S.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=m.get(n);t&&t.forEach((t=>{B(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);R(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};S.set(n,t),M(t)}}function T(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());N(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||M(t)}),Math.min(e,3e5))}}function N(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function M(t){t.src=v.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}var U=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,V={revert:function(){}},I=new Map,D=new Set;function J(t){var e=I.get(t);return e||I.set(t,e={element:t,attributes:{}}),e}function j(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 K(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,ut()):t!==n&&(e.isDirty=!0,ut())}function L(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(function(t){return Y||(Y=document.createElement(\"div\")),Y.innerHTML=t,Y.innerHTML}(e),t)}function H(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),K(Array.from(e).filter(Boolean).join(\" \"),t)}function q(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),K(e,t)}function P(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),K(e,t)}var z=function(t){return t.innerHTML},G=function(t,e){return t.innerHTML=e};function Z(t){var e=J(t);return e.html||(e.html=j(t,\"html\",z,G,L)),e.html}var Q=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},W=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function X(t){var e=J(t);return e.position||(e.position=j(t,\"position\",Q,W,P)),e.position}var Y,tt,et=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},nt=function(t){return t.className};function it(t){var e=J(t);return e.classes||(e.classes=j(t,\"class\",nt,et,H)),e.classes}function rt(t,e){var n,i=J(t);return i.attributes[e]||(i.attributes[e]=j(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),q)),i.attributes[e]}function st(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=I.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ot(t,e){t.html&&st(e,\"html\",t.html),t.classes&&st(e,\"class\",t.classes),t.position&&st(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){st(e,n,t.attributes[n])}))}function ut(){I.forEach(ot)}function ct(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=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function at(){D.forEach(ct)}function ht(t){return\"undefined\"==typeof document?V:(D.add(t),ct(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=Z(e):\"class\"===t.kind?n=it(e):\"attribute\"===t.kind?n=rt(e,t.attribute):\"position\"===t.kind&&(n=X(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function lt(t,e){return ht({kind:\"html\",elements:new Set,mutate:e,selector:t})}function ft(t,e){return ht({kind:\"class\",elements:new Set,mutate:e,selector:t})}function dt(t,e,n){return U.test(e)?\"class\"===e||\"className\"===e?ft(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ht({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):V}\"undefined\"!=typeof document&&(tt||(tt=new MutationObserver((function(){at()}))),at(),tt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const wt={};function yt(t,e){if(\"$or\"in e)return kt(t,e.$or);if(\"$nor\"in e)return!kt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!yt(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!yt(t,e.$not);for(const[n,i]of Object.entries(e))if(!vt(i,pt(t,n)))return!1;return!0}function pt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}function vt(t,e){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)||!mt(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!bt(n,e,t[n]))return!1;return!0}function mt(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function gt(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function bt(t,e,n){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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)&&gt(e,n);case\"$nin\":return!!Array.isArray(n)&&!gt(e,n);case\"$not\":return!vt(n,e);case\"$size\":return!!Array.isArray(e)&&vt(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=mt(e)?t=>vt(e,t):t=>yt(t,e);for(let e=0;e<t.length;e++)if(t[e]&&n(t[e]))return!0;return!1}(e,n);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let i=!1;for(let r=0;r<e.length;r++)if(vt(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,wt[i]||(wt[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),wt[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 kt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(yt(t,e[n]))return!0;return!1}const St=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,At=function(){let t;try{t=\"1.0.1\"}catch(e){t=\"\"}return t}();class _t{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}}window.dataLayer=window.dataLayer||[];const xt=document.currentScript,Et=xt?xt.dataset:{},Ct=window.growthbook_config||{};function Ot(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function $t(){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 Rt=Ct.uuidCookieName||Et.uuidCookieName||\"gbuuid\",Bt=Ct.uuidKey||Et.uuidKey||\"id\";let Ft,Tt=Ct.uuid||Et.uuid||\"\";function Nt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Rt,Tt)}function Mt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function Ut(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Vt(){const t=Et.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Tt||(Tt=Ot(Rt),Tt||(Tt=$t(),t&&Nt(),Tt))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Nt(),{...Ut(),[Bt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Mt()}}(Et,Ct);return Ct.attributes&&Object.assign(t,Ct.attributes),t}\"cookie\"===Ct.useStickyBucketService||\"cookie\"===Et.useStickyBucketService?Ft=new class extends _t{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(this.prefix+n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(this.prefix+e,n,this.cookieAttributes)}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Ct.useStickyBucketService&&\"localStorage\"!==Et.useStickyBucketService||(Ft=new class extends _t{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=\"\".concat(t,\"||\").concat(e);let i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(this.prefix+n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}async saveAssignments(t){const e=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(this.prefix+e,JSON.stringify(t))}catch(t){}}}({prefix:Ct.stickyBucketPrefix||Et.stickyBucketPrefix||void 0}));const It=new class{constructor(t){if(t=t||{},this.version=At,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),St&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments?(this.ready=!0,this.B()):t.antiFlicker&&this.F(),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.T=t;const e=await this.decryptPayload(t);this.N=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,this.M()}initSync(t){this.C=!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\");if(this.T=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return this}async init(t){if(this.C=!0,(t=t||{}).payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");F(this,!0),_(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&_(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.U({...t,allowStale:!0});await this.setPayload(e||{}),this.V()&&_(this)}async refreshFeatures(t){const e=await this.U({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.T||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async U(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(y.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=C(e),o=O(e),u=new Date,c=new Date(u.getTime()-y.maxAge+y.staleTTL);await async function(){if(!g){g=!0;try{if(p.localStorage){const t=await p.localStorage.getItem(y.cacheKey);if(!y.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;b.set(e,{...n,staleAt:new Date(n.staleAt)})})),$()}}}catch(t){}{const t=v.startIdleListener();t&&(v.stopIdleListener=t)}}}();const a=y.disableCache||r?void 0:b.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&&A.add(s),a.staleAt<u?B(e):F(e),{data:a.data,success:!0,source:\"cache\"};{const t=await function(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}(B(e),i);return t||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}M(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.M()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){return(t={...t}).encryptedFeatures&&(t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n)),delete t.encryptedExperiments),t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.M(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.M(),this.B())}setForcedFeatures(t){this.k=t,this.M()}async setURL(t){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}V(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.U({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.T=void 0,this.m&&clearTimeout(this.m),t=this,m.forEach((e=>e.delete(t))),St&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.M())}run(t){const e=this.D(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;const i=this.K(t)?this.L(t,-1,!1,\"\"):this.run(t),r=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===r)return i;if(n&&this.H(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.q(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const n=this.P();var s;if(n)if(St)this.F(),window.setTimeout((()=>{try{n(e)}catch(t){console.error(t)}}),null!==(s=this.i.navigateDelay)&&void 0!==s?s:100);else try{n(e)}catch(t){console.error(t)}}else if(\"visual\"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(i.value):this.G(i.value);e&&this.A.set(t,{undo:e,valueHash:r})}}return i}H(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}Z(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}St&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}W(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.Z(t,o),o}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 this.X(t)}X(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.W(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.W(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.W(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.X(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.W(t,null,\"cyclicPrerequisite\");if(!yt({value:i.value},n.condition||{})){if(n.gate)return this.W(t,null,\"prerequisite\");continue t}}if(i.filters&&this.Y(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.tt(i.condition))continue;if(!this.et(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.nt(t.experiment,t.result)})),this.W(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const r=this.D(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.W(t,r.value,\"experiment\",i.id,n,r)}return this.W(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}et(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.it(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}tt(t){return yt(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}D(t,e){const n=t.key,i=t.variations.length;if(i<2)return this.L(t,-1,!1,e);if(!1===this.i.enabled)return this.L(t,-1,!1,e);if((t=this.rt(t)).urlPatterns&&!u(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.q(),i);if(null!==o)return this.L(t,o,!1,e);if(this.i.forcedVariations&&n in this.i.forcedVariations)return this.L(t,this.i.forcedVariations[n],!1,e);if(\"draft\"===t.status||!1===t.active)return this.L(t,-1,!1,e);const{hashAttribute:c,hashValue:a}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return this.L(t,-1,!1,e);let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.st({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return this.L(t,-1,!1,e);if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return this.L(t,-1,!1,e);if(t.condition&&!this.tt(t.condition))return this.L(t,-1,!1,e);if(t.parentConditions)for(const n of t.parentConditions){const i=this.X(n.id);if(\"cyclicPrerequisite\"===i.source)return this.L(t,-1,!1,e);if(!yt({value:i.value},n.condition||{}))return this.L(t,-1,!1,e)}if(t.groups&&!this.ot(t.groups))return this.L(t,-1,!1,e)}if(t.url&&!this.ut(t.url))return this.L(t,-1,!1,e);const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return this.L(t,-1,!1,e);if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return this.L(t,-1,!1,e,void 0,!0);if(h<0)return this.L(t,-1,!1,e);if(\"force\"in t)return this.L(t,void 0===t.force?-1:t.force,!1,e);if(this.i.qaMode)return this.L(t,-1,!1,e);if(\"stopped\"===t.status)return this.L(t,-1,!1,e);const y=this.L(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(c,l(a),{[this.ht(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,y),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),y}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.lt(t.experiment,t.result),t])))}fireDeferredTrackingCalls(){this.i.trackingCallback&&(this.$.forEach((t=>{t&&t.experiment&&t.result?this.nt(t.experiment,t.result):console.error(\"Invalid deferred tracking call\",{call:t})})),this.$.clear())}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}lt(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}nt(t,e){const n=this.lt(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}rt(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}it(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}L(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}q(){return this.i.url||(St?window.location.href:\"\")}ut(t){const e=this.q();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}ot(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}K(t){const e=w(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.O}P(){return this.i.navigate?this.i.navigate:St?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&St)try{var t;const e=document.createElement(\"style\");e.innerHTML=\".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\",document.head.appendChild(e),document.documentElement.classList.add(\"gb-anti-flicker\"),setTimeout((()=>{document.documentElement.classList.remove(\"gb-anti-flicker\")}),null!==(t=this.i.antiFlickerTimeout)&&void 0!==t?t:3500)}catch(t){console.error(t)}}G(t){if(!St)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return lt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return lt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return ft(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return ft(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return ft(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ht({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return dt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return dt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return dt(e,r,(function(){return null}))}return V}(t).revert)})),()=>{e.forEach((t=>t()))}}ft(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.dt(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}wt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.it(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.it(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}st(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ht(e,n),c=this.wt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ht(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ht(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}dt(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.i.stickyBucketIdentifierAttributes?this.i.stickyBucketIdentifierAttributes:this.ft(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.it(t);e[t]=l(n)})),e}ct(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...Et,remoteEval:!!Et.remoteEval,trackingCallback:(t,e)=>{const n={experiment_id:t.key,variation_id:e.key};window.gtag&&window.gtag(\"event\",\"experiment_viewed\",n),window.dataLayer&&window.dataLayer.push({event:\"experiment_viewed\",...n}),window.analytics&&window.analytics.track&&window.analytics.track(\"Experiment Viewed\",n)},...Ct,attributes:Vt(),stickyBucketService:Ft});It.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),It.init({payload:Ct.payload,streaming:!(Ct.noStreaming||Et.noStreaming||!1===Ct.backgroundSync)});let Dt=location.href;setInterval((()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt),It.updateAttributes(Vt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Dt&&(Dt=location.href,It.setURL(Dt)),It.updateAttributes(Vt())})),document.addEventListener(\"growthbookpersist\",(()=>{Nt()}));const Jt=t=>{try{t&&t(It)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{Jt(t)})),window.growthbook_queue={push:t=>{Jt(t)}},It}();\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 i in n)t[i]=n[i]}return t}var e=function e(n,i){function r(e,r,s){if(\"undefined\"!=typeof document){\"number\"==typeof(s=t({},i,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(r,e)+o}}return Object.create({set:r,get:function(t){if(\"undefined\"!=typeof document&&(!arguments.length||t)){for(var e=document.cookie?document.cookie.split(\"; \"):[],i={},r=0;r<e.length;r++){var s=e[r].split(\"=\"),o=s.slice(1).join(\"=\");try{var u=decodeURIComponent(s[0]);if(i[u]=n.read(o,u),t===u)break}catch(t){}}return t?i[t]:i}},remove:function(e,n){r(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(i)},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:\"/\"});const n={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 i=0;i<n;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function r(t,e,n){return 2===n?i(i(t+e)+\"\")%1e4/1e4:1===n?i(e+t)%1e3/1e3:null}function s(t,e){return t>=e[0]&&t<e[1]}function o(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function u(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=c(t,e[r].type,e[r].pattern);if(!1===e[r].include){if(s)return!1}else n=!0,s&&(i=!0)}return i||!n}function c(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=o(n);return!!t&&(t.test(i.href)||t.test(i.href.substring(i.origin.length)))}return\"simple\"===e&&function(t,e){try{const n=new URL(e.replace(/^([^:/?]*)\\./i,\"https://$1.\").replace(/\\*/g,\"_____\"),\"https://_____\"),i=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&i.push([t.hash,n.hash,!1]),n.searchParams.forEach(((e,n)=>{i.push([t.searchParams.get(n)||\"\",e,!1])})),!i.some((t=>!function(t,e,n){try{let i=e.replace(/[*.+?^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/_____/g,\".*\");return n&&(i=\"\\\\/?\"+i.replace(/(^\\/|\\/$)/g,\"\")+\"\\\\/?\"),new RegExp(\"^\"+i+\"$\",\"i\").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(i,n)}catch(t){return!1}}const a=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function h(t,e,i){if(e=e||\"\",!(i=i||globalThis.crypto&&globalThis.crypto.subtle||n.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const n=await i.importKey(\"raw\",a(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await i.decrypt({name:\"AES-CBC\",iv:a(r)},n,a(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 f(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 d(t){return\"object\"==typeof t&&null!==t}function w(t){return t.urlPatterns&&t.variations.some((t=>d(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>d(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}async function y(t,e){return new Promise((n=>{let i,r=!1;const s=t=>{r||(r=!0,i&&clearTimeout(i),n(t||null))};e&&(i=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const p={staleTTL:6e4,maxAge:144e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},v=n,m={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return v.fetch(\"\".concat(e,\"/api/features/\").concat(n),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:i,headers:r}=t;const s={method:\"POST\",headers:{\"Content-Type\":\"application/json\",...r},body:JSON.stringify(i)};return v.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new v.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new v.EventSource(\"\".concat(e,\"/sub/\").concat(n))},startIdleListener:()=>{let t;if(\"undefined\"==typeof window||\"undefined\"==typeof document)return;const e=()=>{\"visible\"===document.visibilityState?(window.clearTimeout(t),A.forEach((t=>{t&&\"idle\"===t.state&&U(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(C,p.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(v.localStorage=globalThis.localStorage)}catch(t){}const g=new Map;let b=!1;const k=new Map,S=new Map,A=new Map,_=new Set;function x(t){const e=E(t),n=g.get(e)||new Set;n.add(t),g.set(e,n)}function C(){A.forEach((t=>{t&&(t.state=\"idle\",M(t))}))}async function O(){try{if(!v.localStorage)return;await v.localStorage.setItem(p.cacheKey,JSON.stringify(Array.from(k.entries())))}catch(t){}}function E(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function $(t){const e=E(t);if(!t.isRemoteEval())return e;const n=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach((t=>{r[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return\"\".concat(e,\"||\").concat(JSON.stringify({ca:r,fv:s,url:o}))}function R(){const t=Array.from(k.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,k.size-p.maxEntries),k.size);for(let n=0;n<e;n++)k.delete(t[n].key)}function B(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+p.staleTTL),s=p.disableCache?void 0:k.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void O();p.disableCache||(k.set(e,{data:n,version:i,staleAt:r,sse:_.has(t)}),R()),O();const o=g.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function F(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=E(t),o=$(t);let u=S.get(o);return u||(u=(r?m.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):m.fetchFeaturesCall({host:e,clientKey:i,headers:n})).then((t=>{if(!t.ok)throw new Error(\"HTTP error: \".concat(t.status));return\"enabled\"===t.headers.get(\"x-sse-support\")&&_.add(s),t.json()})).then((e=>(B(s,o,e),N(t),S.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(S.delete(o),{data:null,source:\"error\",success:!1,error:t}))),S.set(o,u)),u}function N(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=E(t),i=$(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&_.add(n),p.backgroundSync&&_.has(n)&&v.EventSource){if(A.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=g.get(n);t&&t.forEach((t=>{F(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);B(n,i,t)}t.errors=0}catch(e){T(t)}},errors:0,state:\"active\"};A.set(n,t),U(t)}}function T(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());M(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||U(t)}),Math.min(e,3e5))}}function M(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function U(t){t.src=m.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=()=>T(t),t.src.onopen=()=>{t.errors=0}}function I(t,e){M(t),A.delete(e)}var V=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,J={revert:function(){}},j=new Map,D=new Set;function P(t){var e=j.get(t);return e||j.set(t,e={element:t,attributes:{}}),e}function K(t,e,n,i,r){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 i=n(t);\"position\"===e&&i.parentNode===o.virtualValue.parentNode&&i.insertBeforeNode===o.virtualValue.insertBeforeNode||i!==o.virtualValue&&(o.originalValue=i,r(o))}})),mutationRunner:r,setValue:i,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 L(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,at()):t!==n&&(e.isDirty=!0,at())}function H(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(function(t){return et||(et=document.createElement(\"div\")),et.innerHTML=t,et.innerHTML}(e),t)}function q(t){var e=new Set(t.originalValue.split(/\\s+/).filter(Boolean));t.mutations.forEach((function(t){return t.mutate(e)})),L(Array.from(e).filter(Boolean).join(\" \"),t)}function G(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),L(e,t)}function z(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 i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),L(e,t)}var Z=function(t){return t.innerHTML},Q=function(t,e){return t.innerHTML=e};function W(t){var e=P(t);return e.html||(e.html=K(t,\"html\",Z,Q,H)),e.html}var X=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},Y=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function tt(t){var e=P(t);return e.position||(e.position=K(t,\"position\",X,Y,z)),e.position}var et,nt,it=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},rt=function(t){return t.className};function st(t){var e=P(t);return e.classes||(e.classes=K(t,\"class\",rt,it,q)),e.classes}function ot(t,e){var n,i=P(t);return i.attributes[e]||(i.attributes[e]=K(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),G)),i.attributes[e]}function ut(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,r=j.get(t);if(r)if(\"html\"===e)null==(n=r.html)||null==(i=n.observer)||i.disconnect(),delete r.html;else if(\"class\"===e){var s,o;null==(s=r.classes)||null==(o=s.observer)||o.disconnect(),delete r.classes}else if(\"position\"===e){var u,c;null==(u=r.position)||null==(c=u.observer)||c.disconnect(),delete r.position}else{var a,h,l;null==(a=r.attributes)||null==(h=a[e])||null==(l=h.observer)||l.disconnect(),delete r.attributes[e]}}(t,e),n.setValue(t,i)}}function ct(t,e){t.html&&ut(e,\"html\",t.html),t.classes&&ut(e,\"class\",t.classes),t.position&&ut(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){ut(e,n,t.attributes[n])}))}function at(){j.forEach(ct)}function ht(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=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function lt(){D.forEach(ht)}function ft(t){return\"undefined\"==typeof document?J:(D.add(t),ht(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=W(e):\"class\"===t.kind?n=st(e):\"attribute\"===t.kind?n=ot(e,t.attribute):\"position\"===t.kind&&(n=tt(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),D.delete(e)}})}function dt(t,e){return ft({kind:\"html\",elements:new Set,mutate:e,selector:t})}function wt(t,e){return ft({kind:\"class\",elements:new Set,mutate:e,selector:t})}function yt(t,e,n){return V.test(e)?\"class\"===e||\"className\"===e?wt(t,(function(t){var e=n(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):ft({kind:\"attribute\",attribute:e,elements:new Set,mutate:n,selector:t}):J}\"undefined\"!=typeof document&&(nt||(nt=new MutationObserver((function(){lt()}))),lt(),nt.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const pt={};function vt(t,e,n){n=n||{};for(const[i,r]of Object.entries(e))switch(i){case\"$or\":if(!At(t,r,n))return!1;break;case\"$nor\":if(At(t,r,n))return!1;break;case\"$and\":if(!_t(t,r,n))return!1;break;case\"$not\":if(vt(t,r,n))return!1;break;default:if(!gt(r,mt(t,i),n))return!1}return!0}function mt(t,e){const n=e.split(\".\");let i=t;for(let t=0;t<n.length;t++){if(!i||\"object\"!=typeof i||!(n[t]in i))return null;i=i[n[t]]}return i}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 i in t)if(!St(i,e,t[i],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,i){switch(t){case\"$veq\":return f(e)===f(n);case\"$vne\":return f(e)!==f(n);case\"$vgt\":return f(e)>f(n);case\"$vgte\":return f(e)>=f(n);case\"$vlt\":return f(e)<f(n);case\"$vlte\":return f(e)<=f(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,i[n]||[]);case\"$notInGroup\":return!kt(e,i[n]||[]);case\"$nin\":return!!Array.isArray(n)&&!kt(e,n);case\"$not\":return!gt(n,e,i);case\"$size\":return!!Array.isArray(e)&&gt(n,e.length,i);case\"$elemMatch\":return function(t,e,n){if(!Array.isArray(t))return!1;const i=bt(e)?t=>gt(e,t,n):t=>vt(t,e,n);for(let e=0;e<t.length;e++)if(t[e]&&i(t[e]))return!0;return!1}(e,n,i);case\"$all\":if(!Array.isArray(e))return!1;for(let t=0;t<n.length;t++){let r=!1;for(let s=0;s<e.length;s++)if(gt(n[t],e[s],i)){r=!0;break}if(!r)return!1}return!0;case\"$regex\":try{return(r=n,pt[r]||(pt[r]=new RegExp(r.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),pt[r]).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 r}function At(t,e,n){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(vt(t,e[i],n))return!0;return!1}function _t(t,e,n){for(let i=0;i<e.length;i++)if(!vt(t,e[i],n))return!1;return!0}const xt=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,Ct=function(){let t;try{t=\"1.2.1\"}catch(e){t=\"\"}return t}();class Ot{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=>{if(t){const n=\"\".concat(t.attributeName,\"||\").concat(t.attributeValue);e[n]=t}})),e}getKey(t,e){return\"\".concat(this.prefix).concat(t,\"||\").concat(e)}}window.dataLayer=window.dataLayer||[];const Et=document.currentScript,$t=Et?Et.dataset:{},Rt=window.growthbook_config||{};function Bt(t){const e=(\"; \"+document.cookie).split(\"; \".concat(t,\"=\"));return 2===e.length?e[1].split(\";\")[0]:\"\"}function Ft(){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 Nt=Rt.uuidCookieName||$t.uuidCookieName||\"gbuuid\",Tt=Rt.uuidKey||$t.uuidKey||\"id\";let Mt,Ut,It=Rt.uuid||$t.uuid||\"\";function Vt(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+\"=\"+e+\";path=/;expires=\"+n.toUTCString()}(Nt,It)}function Jt(){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((i=>{const r=\"utm_\".concat(i),s=\"utm\"+i[0].toUpperCase()+i.slice(1);e.has(r)&&(t[s]=e.get(r)||\"\",n=!0)})),n&&sessionStorage.setItem(\"utm_params\",JSON.stringify(t))}}catch(t){}return t}function jt(){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 i=e[n];[\"string\",\"number\",\"boolean\"].includes(typeof i)&&(t[n]=i)})))})),t}function Dt(){const t=$t.noAutoAttributes?{}:function(t,e){const n=null==t.noAutoCookies,i=navigator.userAgent,r=i.match(/Edg/)?\"edge\":i.match(/Chrome/)?\"chrome\":i.match(/Firefox/)?\"firefox\":i.match(/Safari/)?\"safari\":\"unknown\",s=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return It||(It=Bt(Nt),It||(It=Ft(),t&&Vt(),It))}(n);return(e.persistUuidOnLoad||t.persistUuidOnLoad)&&n&&Vt(),{...jt(),[Tt]:s,url:location.href,path:location.pathname,host:location.host,query:location.search,pageTitle:document&&document.title,deviceType:i.match(/Mobi/)?\"mobile\":\"desktop\",browser:r,...Jt()}}($t,Rt);return Rt.attributes&&Object.assign(t,Rt.attributes),t}function Pt(){var t,e;window.clearTimeout(Mt);let n=null!==(t=null!==(e=Rt.antiFlickerTimeout)&&void 0!==e?e:$t.antiFlickerTimeout?parseInt($t.antiFlickerTimeout):null)&&void 0!==t?t:3500;isFinite(n)||(n=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\"),Mt=window.setTimeout(Kt,n)}catch(t){console.error(t)}}function Kt(){window.clearTimeout(Mt);try{document.documentElement.classList.remove(\"gb-anti-flicker\")}catch(t){console.error(t)}}(Rt.antiFlicker||$t.antiFlicker)&&Pt(),\"cookie\"===Rt.useStickyBucketService||\"cookie\"===$t.useStickyBucketService?Ut=new class extends Ot{constructor(t){let{prefix:e=\"gbStickyBuckets__\",jsCookie:n,cookieAttributes:i={expires:180}}=t;super(),this.prefix=e,this.jsCookie=n,this.cookieAttributes=i}async getAssignments(t,e){const n=this.getKey(t,e);let i=null;if(!this.jsCookie)return i;try{const t=this.jsCookie.get(n),e=JSON.parse(t||\"{}\");e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0,jsCookie:e}):\"localStorage\"!==Rt.useStickyBucketService&&\"localStorage\"!==$t.useStickyBucketService||(Ut=new class extends Ot{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 i=null;if(!this.localStorage)return i;try{const t=await this.localStorage.getItem(n)||\"{}\",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(i=e)}catch(t){}return i}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:Rt.stickyBucketPrefix||$t.stickyBucketPrefix||void 0}));const Lt=new class{constructor(t){if(t=t||{},this.version=Ct,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.h=new Set,this.l={},this.debug=!!t.debug,this.p=new Set,this.v=[],this.m=0,this.ready=!1,this.g=new Map,this.k=new Map,this.S={},this.A=new Map,this._=new Set,this.C=!1,this.O=\"\",this.$=new Map,this.R=!t.disableExperimentsOnLoad,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.features&&(this.ready=!0),xt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event(\"gbloaded\"))),t.experiments&&(this.ready=!0,this.B()),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.F=t;const e=await this.decryptPayload(t);this.N=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.B()),this.ready=!0,this.T()}initSync(t){this.C=!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\");if(this.F=e,this.N=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.B()),this.ready=!0,t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return this}async init(t){if(this.C=!0,(t=t||{}).cacheSettings&&(Object.assign(p,t.cacheSettings),p.backgroundSync||(_.clear(),A.forEach(I),g.clear(),m.stopIdleListener())),t.payload){if(await this.setPayload(t.payload),t.streaming){if(!this.i.clientKey)throw new Error(\"Must specify clientKey to enable streaming\");N(this,!0),x(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.M({...t,allowStale:!0});return t.streaming&&x(this),await this.setPayload(e||{}),n}}async loadFeatures(t){this.C=!0,(t=t||{}).autoRefresh&&(this.i.subscribeToChanges=!0);const{data:e}=await this.M({...t,allowStale:!0});await this.setPayload(e||{}),this.U()&&x(this)}async refreshFeatures(t){const e=await this.M({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){const t=this.i.apiHost||\"https://cdn.growthbook.io\";return{apiHost:t.replace(/\\/*$/,\"\"),streamingHost:(this.i.streamingHost||t).replace(/\\/*$/,\"\"),apiRequestHeaders:this.i.apiHostRequestHeaders,streamingHostRequestHeaders:this.i.streamingHostRequestHeaders}}getClientKey(){return this.i.clientKey||\"\"}getPayload(){return this.F||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.N||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async M(t){var e;let{timeout:n,skipCache:i,allowStale:r,streaming:s}=t;if(!this.i.clientKey)throw new Error(\"Missing clientKey\");return async function(t){let{instance:e,timeout:n,skipCache:i,allowStale:r,backgroundSync:s}=t;return s||(p.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=E(e),o=$(e),u=new Date,c=new Date(u.getTime()-p.maxAge+p.staleTTL);await async function(){if(!b){b=!0;try{if(v.localStorage){const t=await v.localStorage.getItem(p.cacheKey);if(!p.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;k.set(e,{...n,staleAt:new Date(n.staleAt)})})),R()}}}catch(t){}if(!p.disableIdleStreams){const t=m.startIdleListener();t&&(m.stopIdleListener=t)}}}();const a=p.disableCache||r?void 0:k.get(o);return a&&(n||a.staleAt>u)&&a.staleAt>c?(a.sse&&_.add(s),a.staleAt<u?F(e):N(e),{data:a.data,success:!0,source:\"cache\"}):await y(F(e),i)||{data:null,success:!1,source:\"timeout\",error:new Error(\"Timeout\")}}({instance:e,allowStale:r,timeout:n,skipCache:i})}({instance:this,timeout:n,skipCache:i||this.i.disableCache,allowStale:r,backgroundSync:null===(e=null!=s?s:this.i.backgroundSync)||void 0===e||e})}T(){if(this.o)try{this.o()}catch(t){console.error(\"Failed to render\",t)}}setFeatures(t){this.i.features=t,this.ready=!0,this.T()}async setEncryptedFeatures(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setFeatures(JSON.parse(i))}setExperiments(t){this.i.experiments=t,this.ready=!0,this.B()}async setEncryptedExperiments(t,e,n){const i=await h(t,e||this.i.decryptionKey,n);this.setExperiments(JSON.parse(i))}async decryptPayload(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await h(t.encryptedFeatures,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await h(t.encryptedExperiments,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await h(t.encryptedSavedGroups,e||this.i.decryptionKey,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}async setAttributes(t){this.i.attributes=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async updateAttributes(t){return this.setAttributes({...this.i.attributes,...t})}async setAttributeOverrides(t){this.S=t,this.i.stickyBucketService&&await this.refreshStickyBuckets(),this.i.remoteEval?await this.I():(this.T(),this.B())}async setForcedVariations(t){this.i.forcedVariations=t||{},this.i.remoteEval?await this.I():(this.T(),this.B())}setForcedFeatures(t){this.k=t,this.T()}async setURL(t){if(t!==this.i.url){if(this.i.url=t,this.O=\"\",this.i.remoteEval)return await this.I(),void this.B(!0);this.B(!0)}}getAttributes(){return{...this.i.attributes,...this.S}}getForcedVariations(){return this.i.forcedVariations||{}}getForcedFeatures(){return this.k||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.h)}subscribe(t){return this.p.add(t),()=>{this.p.delete(t)}}U(){var t;return(null===(t=this.i.backgroundSync)||void 0===t||t)&&this.i.subscribeToChanges}async I(){if(!this.i.remoteEval)return;if(!this.C)return;const t=await this.M({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}destroy(){var t;this.p.clear(),this.g.clear(),this.u.clear(),this.h.clear(),this.$.clear(),this.l={},this.v=[],this.F=void 0,this.m&&clearTimeout(this.m),t=this,g.forEach((e=>e.delete(t))),xt&&window._growthbook===this&&delete window._growthbook,this.A.forEach((t=>{t.undo()})),this.A.clear(),this._.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.B(),this.T())}run(t){const{result:e}=this.V(t,null);return this.J(t,e),e}triggerExperiment(t){return this._.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.R=!0,this.B(!0)}j(t,e){const n=this.A.get(t);if(t.manual&&!this._.has(t.key)&&!n)return null;let i,r;this.D(t)?i=this.P(t,-1,!1,\"\"):(({result:i,trackingCall:r}=this.V(t,null)),this.J(t,i));const s=JSON.stringify(i.value);if(!e&&i.inExperiment&&n&&n.valueHash===s)return i;if(n&&this.K(t),i.inExperiment){const e=w(t);if(\"redirect\"===e&&i.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,i;try{n=new URL(t),i=new URL(e)}catch(t){return console.error(\"Unable to merge query strings: \".concat(t)),e}return n.searchParams.forEach(((t,e)=>{i.searchParams.has(e)||i.searchParams.set(e,t)})),i.toString()}(this.L(),i.value.urlRedirect):i.value.urlRedirect;if(u(e,t.urlPatterns))return this.log(\"Skipping redirect because original URL matches redirect URL\",{id:t.key}),i;this.O=e;const{navigate:n,delay:s}=this.H();var o;if(n)if(xt)Promise.all([...r?[y(r,null!==(o=this.i.maxNavigateDelay)&&void 0!==o?o:1e3)]:[],new Promise((t=>{var e;return window.setTimeout(t,null!==(e=this.i.navigateDelay)&&void 0!==e?e: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(i.value):this.q(i.value);e&&this.A.set(t,{undo:e,valueHash:s})}}return i}K(t){const e=this.A.get(t);e&&(e.undo(),this.A.delete(t))}B(t){if(!this.R)return;const e=this.i.experiments||[],n=new Set(e);this.A.forEach(((t,e)=>{n.has(e)||(t.undo(),this.A.delete(e))}));for(const n of e){const e=this.j(n,t);if(null!=e&&e.inExperiment&&\"redirect\"===w(n))break}}J(t,e){const n=t.key,i=this.g.get(n);i&&i.result.inExperiment===e.inExperiment&&i.result.variationId===e.variationId||(this.g.set(n,{experiment:t,result:e}),this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}})))}G(t,e){if(\"override\"===e.source)return;const n=JSON.stringify(e.value);if(this.l[t]!==n){if(this.l[t]=n,this.i.onFeatureUsage)try{this.i.onFeatureUsage(t,e)}catch(t){}xt&&window.fetch&&(this.v.push({key:t,on:e.on}),this.m||(this.m=window.setTimeout((()=>{this.m=0;const t=[...this.v];this.v=[],this.i.realtimeKey&&window.fetch(\"https://rt.growthbook.io/?key=\".concat(this.i.realtimeKey,\"&events=\").concat(encodeURIComponent(JSON.stringify(t))),{cache:\"no-cache\",mode:\"no-cors\"}).catch((()=>{}))}),this.i.realtimeInterval||2e3)))}}Z(t,e,n,i,r,s){const o={value:e,on:!!e,off:!e,source:n,ruleId:i||\"\"};return r&&(o.experiment=r),s&&(o.experimentResult=s),this.G(t,o),o}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 this.W(t)}W(t,e){if((e=e||{evaluatedFeatures:new Set}).evaluatedFeatures.has(t))return this.Z(t,null,\"cyclicPrerequisite\");if(e.evaluatedFeatures.add(t),e.id=t,this.k.has(t))return this.Z(t,this.k.get(t),\"override\");if(!this.i.features||!this.i.features[t])return this.Z(t,null,\"unknownFeature\");const n=this.i.features[t];if(n.rules)t:for(const i of n.rules){if(i.parentConditions)for(const n of i.parentConditions){const i=this.W(n.id,e);if(\"cyclicPrerequisite\"===i.source)return this.Z(t,null,\"cyclicPrerequisite\");if(!vt({value:i.value},n.condition||{})){if(n.gate)return this.Z(t,null,\"prerequisite\");continue t}}if(i.filters&&this.X(i.filters))continue;if(\"force\"in i){if(i.condition&&!this.Y(i.condition))continue;if(!this.tt(i.seed||t,i.hashAttribute,this.i.stickyBucketService&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{this.et(t.experiment,t.result)})),this.Z(t,i.force,\"force\",i.id)}if(!i.variations)continue;const n={variations:i.variations,key:i.key||t};\"coverage\"in i&&(n.coverage=i.coverage),i.weights&&(n.weights=i.weights),i.hashAttribute&&(n.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(n.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(n.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(n.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(n.minBucketVersion=i.minBucketVersion),i.namespace&&(n.namespace=i.namespace),i.meta&&(n.meta=i.meta),i.ranges&&(n.ranges=i.ranges),i.name&&(n.name=i.name),i.phase&&(n.phase=i.phase),i.seed&&(n.seed=i.seed),i.hashVersion&&(n.hashVersion=i.hashVersion),i.filters&&(n.filters=i.filters),i.condition&&(n.condition=i.condition);const{result:r}=this.V(n,t);if(this.J(n,r),r.inExperiment&&!r.passthrough)return this.Z(t,r.value,\"experiment\",i.id,n,r)}return this.Z(t,void 0===n.defaultValue?null:n.defaultValue,\"defaultValue\")}tt(t,e,n,i,o,u){if(!i&&void 0===o)return!0;if(!i&&0===o)return!1;const{hashValue:c}=this.nt(e,n);if(!c)return!1;const a=r(t,c,u||1);return null!==a&&(i?s(a,i):void 0===o||a<=o)}Y(t){return vt(this.getAttributes(),t,this.i.savedGroups||{})}X(t){return t.some((t=>{const{hashValue:e}=this.nt(t.attribute);if(!e)return!0;const n=r(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>s(n,t)))}))}V(t,e){const n=t.key,i=t.variations.length;if(i<2)return{result:this.P(t,-1,!1,e)};if(!1===this.i.enabled)return{result:this.P(t,-1,!1,e)};if((t=this.it(t)).urlPatterns&&!u(this.L(),t.urlPatterns))return{result:this.P(t,-1,!1,e)};const o=function(t,e,n){if(!e)return null;const i=e.split(\"?\")[1];if(!i)return null;const r=i.replace(/#.*/,\"\").split(\"&\").map((t=>t.split(\"=\",2))).filter((e=>{let[n]=e;return n===t})).map((t=>{let[,e]=t;return parseInt(e)}));return r.length>0&&r[0]>=0&&r[0]<n?r[0]:null}(n,this.L(),i);if(null!==o)return{result:this.P(t,o,!1,e)};if(this.i.forcedVariations&&n in this.i.forcedVariations)return{result:this.P(t,this.i.forcedVariations[n],!1,e)};if(\"draft\"===t.status||!1===t.active)return{result:this.P(t,-1,!1,e)};const{hashAttribute:c,hashValue:a}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!a)return{result:this.P(t,-1,!1,e)};let h=-1,f=!1,d=!1;if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{variation:e,versionIsBlocked:n}=this.rt({expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});f=e>=0,h=e,d=!!n}if(!f){if(t.filters){if(this.X(t.filters))return{result:this.P(t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=r(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(a,t.namespace))return{result:this.P(t,-1,!1,e)};if(t.include&&!function(t){try{return t()}catch(t){return console.error(t),!1}}(t.include))return{result:this.P(t,-1,!1,e)};if(t.condition&&!this.Y(t.condition))return{result:this.P(t,-1,!1,e)};if(t.parentConditions)for(const n of t.parentConditions){const i=this.W(n.id);if(\"cyclicPrerequisite\"===i.source)return{result:this.P(t,-1,!1,e)};if(!vt({value:i.value},n.condition||{}))return{result:this.P(t,-1,!1,e)}}if(t.groups&&!this.st(t.groups))return{result:this.P(t,-1,!1,e)}}if(t.url&&!this.ot(t.url))return{result:this.P(t,-1,!1,e)};const w=r(t.seed||n,a,t.hashVersion||1);if(null===w)return{result:this.P(t,-1,!1,e)};if(f||(h=function(t,e){for(let n=0;n<e.length;n++)if(s(t,e[n]))return n;return-1}(w,t.ranges||function(t,e,n){(e=void 0===e?1:e)<0?e=0:e>1&&(e=1);const i=(r=t)<=0?[]:new Array(r).fill(1/r);var r;(n=n||i).length!==t&&(n=i);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=i);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))),d)return{result:this.P(t,-1,!1,e,void 0,!0)};if(h<0)return{result:this.P(t,-1,!1,e)};if(\"force\"in t)return{result:this.P(t,void 0===t.force?-1:t.force,!1,e)};if(this.i.qaMode)return{result:this.P(t,-1,!1,e)};if(\"stopped\"===t.status)return{result:this.P(t,-1,!1,e)};const y=this.P(t,h,!0,e,w,f);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ut(c,l(a),{[this.ct(t.key,t.bucketVersion)]:y.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}const p=this.et(t,y);return\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),{result:y,trackingCall:p}}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.$.values())}setDeferredTrackingCalls(t){this.$=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[this.ht(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.$.forEach((e=>{e&&e.experiment&&e.result?t.push(this.et(e.experiment,e.result)):console.error(\"Invalid deferred tracking call\",{call:e})})),this.$.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}ht(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}async et(t,e){const n=this.ht(t,e);if(this.i.trackingCallback){if(!this.u.has(n)){this.u.add(n);try{await this.i.trackingCallback(t,e)}catch(t){console.error(t)}}}else this.$.has(n)||this.$.set(n,{experiment:t,result:e})}it(t){const e=t.key,n=this.i.overrides;return n&&n[e]&&\"string\"==typeof(t=Object.assign({},t,n[e])).url&&(t.url=o(t.url)),t}nt(t,e){let n=t||\"id\",i=\"\";return this.S[n]?i=this.S[n]:this.i.attributes?i=this.i.attributes[n]||\"\":this.i.user&&(i=this.i.user[n]||\"\"),!i&&e&&(this.S[e]?i=this.S[e]:this.i.attributes?i=this.i.attributes[e]||\"\":this.i.user&&(i=this.i.user[e]||\"\"),i&&(n=e)),{hashAttribute:n,hashValue:i}}P(t,e,n,i,r,s){let o=!0;(e<0||e>=t.variations.length)&&(e=0,o=!1);const{hashAttribute:u,hashValue:c}=this.nt(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),a=t.meta?t.meta[e]:{},h={key:a.key||\"\"+e,featureId:i,inExperiment:o,hashUsed:n,variationId:e,value:t.variations[e],hashAttribute:u,hashValue:c,stickyBucketUsed:!!s};return a.name&&(h.name=a.name),void 0!==r&&(h.bucket=r),a.passthrough&&(h.passthrough=a.passthrough),h}L(){return this.i.url||(xt?window.location.href:\"\")}ot(t){const e=this.L();if(!e)return!1;const n=e.replace(/^https?:\\/\\//,\"\").replace(/^[^/]*\\//,\"/\");return!!t.test(e)||!!t.test(n)}st(t){const e=this.i.groups||{};for(let n=0;n<t.length;n++)if(e[t[n]])return!0;return!1}D(t){const e=w(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.L());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.O}H(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:xt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}q(t){if(!xt)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,r=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(\"html\"===r){if(\"append\"===n)return dt(e,(function(t){return t+(null!=i?i:\"\")}));if(\"set\"===n)return dt(e,(function(){return null!=i?i:\"\"}))}else if(\"class\"===r){if(\"append\"===n)return wt(e,(function(t){i&&t.add(i)}));if(\"remove\"===n)return wt(e,(function(t){i&&t.delete(i)}));if(\"set\"===n)return wt(e,(function(t){t.clear(),i&&t.add(i)}))}else if(\"position\"===r){if(\"set\"===n&&s)return function(t,e){return ft({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:o,parentSelector:s}},selector:t})}(e)}else{if(\"append\"===n)return yt(e,r,(function(t){return null!==t?t+(null!=i?i:\"\"):null!=i?i:\"\"}));if(\"set\"===n)return yt(e,r,(function(){return null!=i?i:\"\"}));if(\"remove\"===n)return yt(e,r,(function(){return null}))}return J}(t).revert)})),()=>{e.forEach((t=>t()))}}lt(t){const e=new Set,n=t&&t.features?t.features:this.getFeatures(),i=t&&t.experiments?t.experiments:this.getExperiments();return Object.keys(n).forEach((t=>{const i=n[t];if(i.rules)for(const t of i.rules)t.variations&&(e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute))})),i.map((t=>{e.add(t.hashAttribute||\"id\"),t.fallbackAttribute&&e.add(t.fallbackAttribute)})),Array.from(e)}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.ft(t);this.i.stickyBucketAssignmentDocs=await this.i.stickyBucketService.getAllAssignments(e)}}dt(t,e){if(!this.i.stickyBucketAssignmentDocs)return{};const{hashAttribute:n,hashValue:i}=this.nt(t),r=\"\".concat(n,\"||\").concat(l(i)),{hashAttribute:s,hashValue:o}=this.nt(e),u=o?\"\".concat(s,\"||\").concat(l(o)):null,c={};return u&&this.i.stickyBucketAssignmentDocs[u]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[u].assignments||{}),this.i.stickyBucketAssignmentDocs[r]&&Object.assign(c,this.i.stickyBucketAssignmentDocs[r].assignments||{}),c}rt(t){let{expKey:e,expBucketVersion:n,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:s,expMeta:o}=t;n=n||0,s=s||0,i=i||\"id\",o=o||[];const u=this.ct(e,n),c=this.dt(i,r);if(s>0)for(let t=0;t<=s;t++)if(void 0!==c[this.ct(e,t)])return{variation:-1,versionIsBlocked:!0};const a=c[u];if(void 0===a)return{variation:-1};const h=o.findIndex((t=>t.key===a));return h<0?{variation:-1}:{variation:h}}ct(t,e){return e=e||0,\"\".concat(t,\"__\").concat(e)}ft(t){const e={};return this.i.stickyBucketIdentifierAttributes=this.lt(t),this.i.stickyBucketIdentifierAttributes.forEach((t=>{const{hashValue:n}=this.nt(t);e[t]=l(n)})),e}ut(t,e,n){const i=\"\".concat(t,\"||\").concat(e),r=this.i.stickyBucketAssignmentDocs&&this.i.stickyBucketAssignmentDocs[i]&&this.i.stickyBucketAssignmentDocs[i].assignments||{},s={...r,...n};return{key:i,doc:{attributeName:t,attributeValue:e,assignments:s},changed:JSON.stringify(r)!==JSON.stringify(s)}}}({...$t,remoteEval:!!$t.remoteEval,trackingCallback:async(t,e)=>{const n=[],i={experiment_id:t.key,variation_id:e.key};if(Rt.additionalTrackingCallback&&n.push(Promise.resolve(Rt.additionalTrackingCallback(t,e))),window.gtag){let t;const e=new Promise((e=>{t=e}));n.push(e),window.gtag(\"event\",\"experiment_viewed\",{...i,event_callback:t})}if(window.dataLayer){let t;const e=new Promise((e=>{t=e}));n.push(e),window.dataLayer.push({event:\"experiment_viewed\",...i,eventCallback:t})}if(window.analytics&&window.analytics.track){window.analytics.track(\"Experiment Viewed\",i);const t=new Promise((t=>window.setTimeout(t,300)));n.push(t)}await Promise.all(n)},...Rt,attributes:Dt(),stickyBucketService:Ut});Lt.setRenderer((()=>{document.dispatchEvent(new CustomEvent(\"growthbookdata\"))})),Lt.init({payload:Rt.payload,streaming:!(Rt.noStreaming||$t.noStreaming||!1===Rt.backgroundSync),cacheSettings:Rt.cacheSettings}).then((()=>{(Rt.antiFlicker||$t.antiFlicker)&&(Lt.getRedirectUrl()?Pt():Kt())}));let Ht=location.href;setInterval((()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht),Lt.updateAttributes(Dt()))}),500),document.addEventListener(\"growthbookrefresh\",(()=>{location.href!==Ht&&(Ht=location.href,Lt.setURL(Ht)),Lt.updateAttributes(Dt())})),document.addEventListener(\"growthbookpersist\",(()=>{Vt()}));const qt=t=>{try{t&&t(Lt)}catch(t){console.error(\"Uncaught growthbook_queue error\",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{qt(t)})),window.growthbook_queue={push:t=>{qt(t)}},Lt}();\n//# sourceMappingURL=auto.min.js.map\n";
@@ -5,8 +5,8 @@ import {
5
5
  import { Context } from "./types";
6
6
 
7
7
  export class EdgeStickyBucketService<Req, Res> extends StickyBucketService {
8
+ protected prefix: string;
8
9
  private context: Context<Req, Res>;
9
- private prefix: string;
10
10
  private req: Req;
11
11
 
12
12
  constructor({
@@ -25,13 +25,13 @@ export class EdgeStickyBucketService<Req, Res> extends StickyBucketService {
25
25
  }
26
26
 
27
27
  async getAssignments(attributeName: string, attributeValue: string) {
28
- const key = `${attributeName}||${attributeValue}`;
28
+ const key = this.getKey(attributeName, attributeValue);
29
29
  let doc: StickyAssignmentsDocument | null = null;
30
30
  if (!this.req) return doc;
31
31
  try {
32
32
  // const raw = this.req.cookies[this.prefix + key] || "{}";
33
33
  const raw =
34
- this.context.helpers?.getCookie?.(this.req, this.prefix + key) || "{}";
34
+ this.context.helpers?.getCookie?.(this.req, key) || "{}";
35
35
  const data = JSON.parse(raw);
36
36
  if (data.attributeName && data.attributeValue && data.assignments) {
37
37
  doc = data;