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K,EAAa,CAAC,EAQpB,OAPA6X,KAAKC,KAAK+N,iCAAoChO,KAAKC,KAAK+N,iCAAwFhO,KAAKC,KAAK+N,iCAA/DhO,KAAKoN,wCAAwC7a,GACxIyN,KAAKC,KAAK+N,iCAAiChkB,SAAQzB,IACjD,MAAM,UACJ0gB,GACEjJ,KAAKkJ,kBAAkB3gB,GAC3BJ,EAAWI,GAAQ,EAAS0gB,EAAU,IAEjC9gB,CACT,CACA,kCAAAyiB,CAAmCqD,EAAeC,EAAgBR,GAChE,MAAMjZ,EAAM,GAAGwD,OAAOgW,EAAe,MAAMhW,OAAOiW,GAC5CC,EAAsBnO,KAAKC,KAAKsD,4BAA8BvD,KAAKC,KAAKsD,2BAA2B9O,IAAOuL,KAAKC,KAAKsD,2BAA2B9O,GAAKiZ,aAAoB,CAAC,EACzKU,EAAiB,IAClBD,KACAT,GAGL,MAAO,CACLjZ,MACAkW,IAAK,CACHsD,gBACAC,iBACAR,YAAaU,GAEf3D,QARcvV,KAAKC,UAAUgZ,KAAyBjZ,KAAKC,UAAUiZ,GAUzE,E","sources":["webpack://app/./node_modules/dom-mutator/dist/dom-mutator.esm.js","webpack://app/./node_modules/@growthbook/growthbook/dist/esm/util.js","webpack://app/./node_modules/@growthbook/growthbook/dist/esm/mongrule.js","webpack://app/./node_modules/@growthbook/growthbook/dist/esm/feature-repository.js","webpack://app/./node_modules/@growthbook/growthbook/dist/esm/GrowthBook.js"],"sourcesContent":["var validAttributeName = /^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/;\nvar nullController = {\n revert: function revert() {}\n};\nvar elements = /*#__PURE__*/new Map();\nvar mutations = /*#__PURE__*/new Set();\n\nfunction getObserverInit(attr) {\n return attr === 'html' ? {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true\n } : {\n childList: false,\n subtree: false,\n attributes: true,\n attributeFilter: [attr]\n };\n}\n\nfunction getElementRecord(element) {\n var record = elements.get(element);\n\n if (!record) {\n record = {\n element: element,\n attributes: {}\n };\n elements.set(element, record);\n }\n\n return record;\n}\n\nfunction createElementPropertyRecord(el, attr, getCurrentValue, setValue, mutationRunner) {\n var currentValue = getCurrentValue(el);\n var record = {\n isDirty: false,\n originalValue: currentValue,\n virtualValue: currentValue,\n mutations: [],\n el: el,\n _positionTimeout: null,\n observer: new MutationObserver(function () {\n // enact a 1 second timeout that blocks subsequent firing of the\n // observer until the timeout is complete. This will prevent multiple\n // mutations from firing in quick succession, which can cause the\n // mutation to be reverted before the DOM has a chance to update.\n if (attr === 'position' && record._positionTimeout) return;else if (attr === 'position') record._positionTimeout = setTimeout(function () {\n record._positionTimeout = null;\n }, 1000);\n var currentValue = getCurrentValue(el);\n if (attr === 'position' && currentValue.parentNode === record.virtualValue.parentNode && currentValue.insertBeforeNode === record.virtualValue.insertBeforeNode) return;\n if (currentValue === record.virtualValue) return;\n record.originalValue = currentValue;\n mutationRunner(record);\n }),\n mutationRunner: mutationRunner,\n setValue: setValue,\n getCurrentValue: getCurrentValue\n };\n\n if (attr === 'position' && el.parentNode) {\n record.observer.observe(el.parentNode, {\n childList: true,\n subtree: true,\n attributes: false,\n characterData: false\n });\n } else {\n record.observer.observe(el, getObserverInit(attr));\n }\n\n return record;\n}\n\nfunction queueIfNeeded(val, record) {\n var currentVal = record.getCurrentValue(record.el);\n record.virtualValue = val;\n\n if (val && typeof val !== 'string') {\n if (!currentVal || val.parentNode !== currentVal.parentNode || val.insertBeforeNode !== currentVal.insertBeforeNode) {\n record.isDirty = true;\n runDOMUpdates();\n }\n } else if (val !== currentVal) {\n record.isDirty = true;\n runDOMUpdates();\n }\n}\n\nfunction htmlMutationRunner(record) {\n var val = record.originalValue;\n record.mutations.forEach(function (m) {\n return val = m.mutate(val);\n });\n queueIfNeeded(getTransformedHTML(val), record);\n}\n\nfunction classMutationRunner(record) {\n var val = new Set(record.originalValue.split(/\\s+/).filter(Boolean));\n record.mutations.forEach(function (m) {\n return m.mutate(val);\n });\n queueIfNeeded(Array.from(val).filter(Boolean).join(' '), record);\n}\n\nfunction attrMutationRunner(record) {\n var val = record.originalValue;\n record.mutations.forEach(function (m) {\n return val = m.mutate(val);\n });\n queueIfNeeded(val, record);\n}\n\nfunction _loadDOMNodes(_ref) {\n var parentSelector = _ref.parentSelector,\n insertBeforeSelector = _ref.insertBeforeSelector;\n var parentNode = document.querySelector(parentSelector);\n if (!parentNode) return null;\n var insertBeforeNode = insertBeforeSelector ? document.querySelector(insertBeforeSelector) : null;\n if (insertBeforeSelector && !insertBeforeNode) return null;\n return {\n parentNode: parentNode,\n insertBeforeNode: insertBeforeNode\n };\n}\n\nfunction positionMutationRunner(record) {\n var val = record.originalValue;\n record.mutations.forEach(function (m) {\n var selectors = m.mutate();\n\n var newNodes = _loadDOMNodes(selectors);\n\n val = newNodes || val;\n });\n queueIfNeeded(val, record);\n}\n\nvar getHTMLValue = function getHTMLValue(el) {\n return el.innerHTML;\n};\n\nvar setHTMLValue = function setHTMLValue(el, value) {\n return el.innerHTML = value;\n};\n\nfunction getElementHTMLRecord(element) {\n var elementRecord = getElementRecord(element);\n\n if (!elementRecord.html) {\n elementRecord.html = createElementPropertyRecord(element, 'html', getHTMLValue, setHTMLValue, htmlMutationRunner);\n }\n\n return elementRecord.html;\n}\n\nvar getElementPosition = function getElementPosition(el) {\n return {\n parentNode: el.parentElement,\n insertBeforeNode: el.nextElementSibling\n };\n};\n\nvar setElementPosition = function setElementPosition(el, value) {\n if (value.insertBeforeNode && !value.parentNode.contains(value.insertBeforeNode)) {\n // skip position mutation - insertBeforeNode not a child of parent. happens\n // when mutation observer for indvidual element fires out of order\n return;\n }\n\n value.parentNode.insertBefore(el, value.insertBeforeNode);\n};\n\nfunction getElementPositionRecord(element) {\n var elementRecord = getElementRecord(element);\n\n if (!elementRecord.position) {\n elementRecord.position = createElementPropertyRecord(element, 'position', getElementPosition, setElementPosition, positionMutationRunner);\n }\n\n return elementRecord.position;\n}\n\nvar setClassValue = function setClassValue(el, val) {\n return val ? el.className = val : el.removeAttribute('class');\n};\n\nvar getClassValue = function getClassValue(el) {\n return el.className;\n};\n\nfunction getElementClassRecord(el) {\n var elementRecord = getElementRecord(el);\n\n if (!elementRecord.classes) {\n elementRecord.classes = createElementPropertyRecord(el, 'class', getClassValue, setClassValue, classMutationRunner);\n }\n\n return elementRecord.classes;\n}\n\nvar getAttrValue = function getAttrValue(attrName) {\n return function (el) {\n var _el$getAttribute;\n\n return (_el$getAttribute = el.getAttribute(attrName)) != null ? _el$getAttribute : null;\n };\n};\n\nvar setAttrValue = function setAttrValue(attrName) {\n return function (el, val) {\n return val !== null ? el.setAttribute(attrName, val) : el.removeAttribute(attrName);\n };\n};\n\nfunction getElementAttributeRecord(el, attr) {\n var elementRecord = getElementRecord(el);\n\n if (!elementRecord.attributes[attr]) {\n elementRecord.attributes[attr] = createElementPropertyRecord(el, attr, getAttrValue(attr), setAttrValue(attr), attrMutationRunner);\n }\n\n return elementRecord.attributes[attr];\n}\n\nfunction deleteElementPropertyRecord(el, attr) {\n var element = elements.get(el);\n if (!element) return;\n\n if (attr === 'html') {\n var _element$html, _element$html$observe;\n\n (_element$html = element.html) == null ? void 0 : (_element$html$observe = _element$html.observer) == null ? void 0 : _element$html$observe.disconnect();\n delete element.html;\n } else if (attr === 'class') {\n var _element$classes, _element$classes$obse;\n\n (_element$classes = element.classes) == null ? void 0 : (_element$classes$obse = _element$classes.observer) == null ? void 0 : _element$classes$obse.disconnect();\n delete element.classes;\n } else if (attr === 'position') {\n var _element$position, _element$position$obs;\n\n (_element$position = element.position) == null ? void 0 : (_element$position$obs = _element$position.observer) == null ? void 0 : _element$position$obs.disconnect();\n delete element.position;\n } else {\n var _element$attributes, _element$attributes$a, _element$attributes$a2;\n\n (_element$attributes = element.attributes) == null ? void 0 : (_element$attributes$a = _element$attributes[attr]) == null ? void 0 : (_element$attributes$a2 = _element$attributes$a.observer) == null ? void 0 : _element$attributes$a2.disconnect();\n delete element.attributes[attr];\n }\n}\n\nvar transformContainer;\n\nfunction getTransformedHTML(html) {\n if (!transformContainer) {\n transformContainer = document.createElement('div');\n }\n\n transformContainer.innerHTML = html;\n return transformContainer.innerHTML;\n}\n\nfunction setPropertyValue(el, attr, m) {\n if (!m.isDirty) return;\n m.isDirty = false;\n var val = m.virtualValue;\n\n if (!m.mutations.length) {\n deleteElementPropertyRecord(el, attr);\n }\n\n m.setValue(el, val);\n}\n\nfunction setValue(m, el) {\n m.html && setPropertyValue(el, 'html', m.html);\n m.classes && setPropertyValue(el, 'class', m.classes);\n m.position && setPropertyValue(el, 'position', m.position);\n Object.keys(m.attributes).forEach(function (attr) {\n setPropertyValue(el, attr, m.attributes[attr]);\n });\n}\n\nfunction runDOMUpdates() {\n elements.forEach(setValue);\n} // find or create ElementPropertyRecord, add mutation to it, then run\n\n\nfunction startMutating(mutation, element) {\n var record = null;\n\n if (mutation.kind === 'html') {\n record = getElementHTMLRecord(element);\n } else if (mutation.kind === 'class') {\n record = getElementClassRecord(element);\n } else if (mutation.kind === 'attribute') {\n record = getElementAttributeRecord(element, mutation.attribute);\n } else if (mutation.kind === 'position') {\n record = getElementPositionRecord(element);\n }\n\n if (!record) return;\n record.mutations.push(mutation);\n record.mutationRunner(record);\n} // get (existing) ElementPropertyRecord, remove mutation from it, then run\n\n\nfunction stopMutating(mutation, el) {\n var record = null;\n\n if (mutation.kind === 'html') {\n record = getElementHTMLRecord(el);\n } else if (mutation.kind === 'class') {\n record = getElementClassRecord(el);\n } else if (mutation.kind === 'attribute') {\n record = getElementAttributeRecord(el, mutation.attribute);\n } else if (mutation.kind === 'position') {\n record = getElementPositionRecord(el);\n }\n\n if (!record) return;\n var index = record.mutations.indexOf(mutation);\n if (index !== -1) record.mutations.splice(index, 1);\n record.mutationRunner(record);\n} // maintain list of elements associated with mutation\n\n\nfunction refreshElementsSet(mutation) {\n // if a position mutation has already found an element to move, don't move\n // any more elements\n if (mutation.kind === 'position' && mutation.elements.size === 1) return;\n var existingElements = new Set(mutation.elements);\n var matchingElements = document.querySelectorAll(mutation.selector);\n matchingElements.forEach(function (el) {\n if (!existingElements.has(el)) {\n mutation.elements.add(el);\n startMutating(mutation, el);\n }\n });\n}\n\nfunction revertMutation(mutation) {\n mutation.elements.forEach(function (el) {\n return stopMutating(mutation, el);\n });\n mutation.elements.clear();\n mutations[\"delete\"](mutation);\n}\n\nfunction refreshAllElementSets() {\n mutations.forEach(refreshElementsSet);\n} // Observer for elements that don't exist in the DOM yet\n\n\nvar observer;\nfunction disconnectGlobalObserver() {\n observer && observer.disconnect();\n}\nfunction connectGlobalObserver() {\n if (typeof document === 'undefined') return;\n\n if (!observer) {\n observer = new MutationObserver(function () {\n refreshAllElementSets();\n });\n }\n\n refreshAllElementSets();\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n attributes: false,\n characterData: false\n });\n} // run on init\n\nconnectGlobalObserver();\n\nfunction newMutation(m) {\n // Not in a browser\n if (typeof document === 'undefined') return nullController; // add to global index of mutations\n\n mutations.add(m); // run refresh on init to establish list of elements associated w/ mutation\n\n refreshElementsSet(m);\n return {\n revert: function revert() {\n revertMutation(m);\n }\n };\n}\n\nfunction html(selector, mutate) {\n return newMutation({\n kind: 'html',\n elements: new Set(),\n mutate: mutate,\n selector: selector\n });\n}\n\nfunction position(selector, mutate) {\n return newMutation({\n kind: 'position',\n elements: new Set(),\n mutate: mutate,\n selector: selector\n });\n}\n\nfunction classes(selector, mutate) {\n return newMutation({\n kind: 'class',\n elements: new Set(),\n mutate: mutate,\n selector: selector\n });\n}\n\nfunction attribute(selector, attribute, mutate) {\n if (!validAttributeName.test(attribute)) return nullController;\n\n if (attribute === 'class' || attribute === 'className') {\n return classes(selector, function (classnames) {\n var mutatedClassnames = mutate(Array.from(classnames).join(' '));\n classnames.clear();\n if (!mutatedClassnames) return;\n mutatedClassnames.split(/\\s+/g).filter(Boolean).forEach(function (c) {\n return classnames.add(c);\n });\n });\n }\n\n return newMutation({\n kind: 'attribute',\n attribute: attribute,\n elements: new Set(),\n mutate: mutate,\n selector: selector\n });\n}\n\nfunction declarative(_ref2) {\n var selector = _ref2.selector,\n action = _ref2.action,\n value = _ref2.value,\n attr = _ref2.attribute,\n parentSelector = _ref2.parentSelector,\n insertBeforeSelector = _ref2.insertBeforeSelector;\n\n if (attr === 'html') {\n if (action === 'append') {\n return html(selector, function (val) {\n return val + (value != null ? value : '');\n });\n } else if (action === 'set') {\n return html(selector, function () {\n return value != null ? value : '';\n });\n }\n } else if (attr === 'class') {\n if (action === 'append') {\n return classes(selector, function (val) {\n if (value) val.add(value);\n });\n } else if (action === 'remove') {\n return classes(selector, function (val) {\n if (value) val[\"delete\"](value);\n });\n } else if (action === 'set') {\n return classes(selector, function (val) {\n val.clear();\n if (value) val.add(value);\n });\n }\n } else if (attr === 'position') {\n if (action === 'set' && parentSelector) {\n return position(selector, function () {\n return {\n insertBeforeSelector: insertBeforeSelector,\n parentSelector: parentSelector\n };\n });\n }\n } else {\n if (action === 'append') {\n return attribute(selector, attr, function (val) {\n return val !== null ? val + (value != null ? value : '') : value != null ? value : '';\n });\n } else if (action === 'set') {\n return attribute(selector, attr, function () {\n return value != null ? value : '';\n });\n } else if (action === 'remove') {\n return attribute(selector, attr, function () {\n return null;\n });\n }\n }\n\n return nullController;\n}\n\nvar index = {\n html: html,\n classes: classes,\n attribute: attribute,\n position: position,\n declarative: declarative\n};\n\nexport default index;\nexport { connectGlobalObserver, disconnectGlobalObserver, validAttributeName };\n//# sourceMappingURL=dom-mutator.esm.js.map\n","function hashFnv32a(str) {\n let hval = 0x811c9dc5;\n const l = str.length;\n for (let i = 0; i < l; i++) {\n hval ^= str.charCodeAt(i);\n hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);\n }\n return hval >>> 0;\n}\nexport function hash(seed, value, version) {\n // New unbiased hashing algorithm\n if (version === 2) {\n return hashFnv32a(hashFnv32a(seed + value) + \"\") % 10000 / 10000;\n }\n // Original biased hashing algorithm (keep for backwards compatibility)\n if (version === 1) {\n return hashFnv32a(value + seed) % 1000 / 1000;\n }\n\n // Unknown hash version\n return null;\n}\nexport function getEqualWeights(n) {\n if (n <= 0) return [];\n return new Array(n).fill(1 / n);\n}\nexport function inRange(n, range) {\n return n >= range[0] && n < range[1];\n}\nexport function inNamespace(hashValue, namespace) {\n const n = hash(\"__\" + namespace[0], hashValue, 1);\n if (n === null) return false;\n return n >= namespace[1] && n < namespace[2];\n}\nexport function chooseVariation(n, ranges) {\n for (let i = 0; i < ranges.length; i++) {\n if (inRange(n, ranges[i])) {\n return i;\n }\n }\n return -1;\n}\nexport function getUrlRegExp(regexString) {\n try {\n const escaped = regexString.replace(/([^\\\\])\\//g, \"$1\\\\/\");\n return new RegExp(escaped);\n } catch (e) {\n console.error(e);\n return undefined;\n }\n}\nexport function isURLTargeted(url, targets) {\n if (!targets.length) return false;\n let hasIncludeRules = false;\n let isIncluded = false;\n for (let i = 0; i < targets.length; i++) {\n const match = _evalURLTarget(url, targets[i].type, targets[i].pattern);\n if (targets[i].include === false) {\n if (match) return false;\n } else {\n hasIncludeRules = true;\n if (match) isIncluded = true;\n }\n }\n return isIncluded || !hasIncludeRules;\n}\nfunction _evalSimpleUrlPart(actual, pattern, isPath) {\n try {\n // Escape special regex characters and change wildcard `_____` to `.*`\n let escaped = pattern.replace(/[*.+?^${}()|[\\]\\\\]/g, \"\\\\$&\").replace(/_____/g, \".*\");\n if (isPath) {\n // When matching pathname, make leading/trailing slashes optional\n escaped = \"\\\\/?\" + escaped.replace(/(^\\/|\\/$)/g, \"\") + \"\\\\/?\";\n }\n const regex = new RegExp(\"^\" + escaped + \"$\", \"i\");\n return regex.test(actual);\n } catch (e) {\n return false;\n }\n}\nfunction _evalSimpleUrlTarget(actual, pattern) {\n try {\n // If a protocol is missing, but a host is specified, add `https://` to the front\n // Use \"_____\" as the wildcard since `*` is not a valid hostname in some browsers\n const expected = new URL(pattern.replace(/^([^:/?]*)\\./i, \"https://$1.\").replace(/\\*/g, \"_____\"), \"https://_____\");\n\n // Compare each part of the URL separately\n const comps = [[actual.host, expected.host, false], [actual.pathname, expected.pathname, true]];\n // We only want to compare hashes if it's explicitly being targeted\n if (expected.hash) {\n comps.push([actual.hash, expected.hash, false]);\n }\n expected.searchParams.forEach((v, k) => {\n comps.push([actual.searchParams.get(k) || \"\", v, false]);\n });\n\n // If any comparisons fail, the whole thing fails\n return !comps.some(data => !_evalSimpleUrlPart(data[0], data[1], data[2]));\n } catch (e) {\n return false;\n }\n}\nfunction _evalURLTarget(url, type, pattern) {\n try {\n const parsed = new URL(url, \"https://_\");\n if (type === \"regex\") {\n const regex = getUrlRegExp(pattern);\n if (!regex) return false;\n return regex.test(parsed.href) || regex.test(parsed.href.substring(parsed.origin.length));\n } else if (type === \"simple\") {\n return _evalSimpleUrlTarget(parsed, pattern);\n }\n return false;\n } catch (e) {\n return false;\n }\n}\nexport function getBucketRanges(numVariations, coverage, weights) {\n coverage = coverage === undefined ? 1 : coverage;\n\n // Make sure coverage is within bounds\n if (coverage < 0) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(\"Experiment.coverage must be greater than or equal to 0\");\n }\n coverage = 0;\n } else if (coverage > 1) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(\"Experiment.coverage must be less than or equal to 1\");\n }\n coverage = 1;\n }\n\n // Default to equal weights if missing or invalid\n const equal = getEqualWeights(numVariations);\n weights = weights || equal;\n if (weights.length !== numVariations) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(\"Experiment.weights array must be the same length as Experiment.variations\");\n }\n weights = equal;\n }\n\n // If weights don't add up to 1 (or close to it), default to equal weights\n const totalWeight = weights.reduce((w, sum) => sum + w, 0);\n if (totalWeight < 0.99 || totalWeight > 1.01) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(\"Experiment.weights must add up to 1\");\n }\n weights = equal;\n }\n\n // Covert weights to ranges\n let cumulative = 0;\n return weights.map(w => {\n const start = cumulative;\n cumulative += w;\n return [start, start + coverage * w];\n });\n}\nexport function getQueryStringOverride(id, url, numVariations) {\n if (!url) {\n return null;\n }\n const search = url.split(\"?\")[1];\n if (!search) {\n return null;\n }\n const match = search.replace(/#.*/, \"\") // Get rid of anchor\n .split(\"&\") // Split into key/value pairs\n .map(kv => kv.split(\"=\", 2)).filter(_ref => {\n let [k] = _ref;\n return k === id;\n }) // Look for key that matches the experiment id\n .map(_ref2 => {\n let [, v] = _ref2;\n return parseInt(v);\n }); // Parse the value into an integer\n\n if (match.length > 0 && match[0] >= 0 && match[0] < numVariations) return match[0];\n return null;\n}\nexport function isIncluded(include) {\n try {\n return include();\n } catch (e) {\n console.error(e);\n return false;\n }\n}\nconst base64ToBuf = b => Uint8Array.from(atob(b), c => c.charCodeAt(0));\nexport async function decrypt(encryptedString, decryptionKey, subtle) {\n decryptionKey = decryptionKey || \"\";\n subtle = subtle || globalThis.crypto && globalThis.crypto.subtle;\n if (!subtle) {\n throw new Error(\"No SubtleCrypto implementation found\");\n }\n try {\n const key = await subtle.importKey(\"raw\", base64ToBuf(decryptionKey), {\n name: \"AES-CBC\",\n length: 128\n }, true, [\"encrypt\", \"decrypt\"]);\n const [iv, cipherText] = encryptedString.split(\".\");\n const plainTextBuffer = await subtle.decrypt({\n name: \"AES-CBC\",\n iv: base64ToBuf(iv)\n }, key, base64ToBuf(cipherText));\n return new TextDecoder().decode(plainTextBuffer);\n } catch (e) {\n throw new Error(\"Failed to decrypt\");\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function toString(input) {\n if (typeof input === \"string\") return input;\n return JSON.stringify(input);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function paddedVersionString(input) {\n if (typeof input === \"number\") {\n input = input + \"\";\n }\n if (!input || typeof input !== \"string\") {\n input = \"0\";\n }\n // Remove build info and leading `v` if any\n // Split version into parts (both core version numbers and pre-release tags)\n // \"v1.2.3-rc.1+build123\" -> [\"1\",\"2\",\"3\",\"rc\",\"1\"]\n const parts = input.replace(/(^v|\\+.*$)/g, \"\").split(/[-.]/);\n\n // If it's SemVer without a pre-release, add `~` to the end\n // [\"1\",\"0\",\"0\"] -> [\"1\",\"0\",\"0\",\"~\"]\n // \"~\" is the largest ASCII character, so this will make \"1.0.0\" greater than \"1.0.0-beta\" for example\n if (parts.length === 3) {\n parts.push(\"~\");\n }\n\n // Left pad each numeric part with spaces so string comparisons will work (\"9\">\"10\", but \" 9\"<\"10\")\n // Then, join back together into a single string\n return parts.map(v => v.match(/^[0-9]+$/) ? v.padStart(5, \" \") : v).join(\"-\");\n}\nexport function loadSDKVersion() {\n let version;\n try {\n // @ts-expect-error right-hand value to be replaced by build with string literal\n version = \"0.36.0\";\n } catch (e) {\n version = \"\";\n }\n return version;\n}\nexport function mergeQueryStrings(oldUrl, newUrl) {\n let currUrl;\n let redirectUrl;\n try {\n currUrl = new URL(oldUrl);\n redirectUrl = new URL(newUrl);\n } catch (e) {\n console.error(\"Unable to merge query strings: \".concat(e));\n return newUrl;\n }\n currUrl.searchParams.forEach((value, key) => {\n // skip if search param already exists in redirectUrl\n if (redirectUrl.searchParams.has(key)) {\n return;\n }\n redirectUrl.searchParams.set(key, value);\n });\n return redirectUrl.toString();\n}\n//# sourceMappingURL=util.js.map","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { paddedVersionString } from \"./util\";\nconst _regexCache = {};\n\n// The top-level condition evaluation function\nexport function evalCondition(obj, condition) {\n // Recursive condition\n if (\"$or\" in condition) {\n return evalOr(obj, condition[\"$or\"]);\n }\n if (\"$nor\" in condition) {\n return !evalOr(obj, condition[\"$nor\"]);\n }\n if (\"$and\" in condition) {\n return evalAnd(obj, condition[\"$and\"]);\n }\n if (\"$not\" in condition) {\n return !evalCondition(obj, condition[\"$not\"]);\n }\n\n // Condition is an object, keys are object paths, values are the condition for that path\n for (const [k, v] of Object.entries(condition)) {\n if (!evalConditionValue(v, getPath(obj, k))) return false;\n }\n return true;\n}\n\n// Return value at dot-separated path of an object\nfunction getPath(obj, path) {\n const parts = path.split(\".\");\n let current = obj;\n for (let i = 0; i < parts.length; i++) {\n if (current && typeof current === \"object\" && parts[i] in current) {\n current = current[parts[i]];\n } else {\n return null;\n }\n }\n return current;\n}\n\n// Transform a regex string into a real RegExp object\nfunction getRegex(regex) {\n if (!_regexCache[regex]) {\n _regexCache[regex] = new RegExp(regex.replace(/([^\\\\])\\//g, \"$1\\\\/\"));\n }\n return _regexCache[regex];\n}\n\n// Evaluate a single value against a condition\nfunction evalConditionValue(condition, value) {\n // Simple equality comparisons\n if (typeof condition === \"string\") {\n return value + \"\" === condition;\n }\n if (typeof condition === \"number\") {\n return value * 1 === condition;\n }\n if (typeof condition === \"boolean\") {\n return !!value === condition;\n }\n if (condition === null) {\n return value === null;\n }\n if (Array.isArray(condition) || !isOperatorObject(condition)) {\n return JSON.stringify(value) === JSON.stringify(condition);\n }\n\n // This is a special operator condition and we should evaluate each one separately\n for (const op in condition) {\n if (!evalOperatorCondition(op, value, condition[op])) {\n return false;\n }\n }\n return true;\n}\n\n// If the object has only keys that start with '$'\nfunction isOperatorObject(obj) {\n const keys = Object.keys(obj);\n return keys.length > 0 && keys.filter(k => k[0] === \"$\").length === keys.length;\n}\n\n// Return the data type of a value\nfunction getType(v) {\n if (v === null) return \"null\";\n if (Array.isArray(v)) return \"array\";\n const t = typeof v;\n if ([\"string\", \"number\", \"boolean\", \"object\", \"undefined\"].includes(t)) {\n return t;\n }\n return \"unknown\";\n}\n\n// At least one element of actual must match the expected condition/value\nfunction elemMatch(actual, expected) {\n if (!Array.isArray(actual)) return false;\n const check = isOperatorObject(expected) ? v => evalConditionValue(expected, v) : v => evalCondition(v, expected);\n for (let i = 0; i < actual.length; i++) {\n if (actual[i] && check(actual[i])) {\n return true;\n }\n }\n return false;\n}\nfunction isIn(actual, expected) {\n // Do an intersection is attribute is an array\n if (Array.isArray(actual)) {\n return actual.some(el => expected.includes(el));\n }\n return expected.includes(actual);\n}\n\n// Evaluate a single operator condition\nfunction evalOperatorCondition(operator, actual, expected) {\n switch (operator) {\n case \"$veq\":\n return paddedVersionString(actual) === paddedVersionString(expected);\n case \"$vne\":\n return paddedVersionString(actual) !== paddedVersionString(expected);\n case \"$vgt\":\n return paddedVersionString(actual) > paddedVersionString(expected);\n case \"$vgte\":\n return paddedVersionString(actual) >= paddedVersionString(expected);\n case \"$vlt\":\n return paddedVersionString(actual) < paddedVersionString(expected);\n case \"$vlte\":\n return paddedVersionString(actual) <= paddedVersionString(expected);\n case \"$eq\":\n return actual === expected;\n case \"$ne\":\n return actual !== expected;\n case \"$lt\":\n return actual < expected;\n case \"$lte\":\n return actual <= expected;\n case \"$gt\":\n return actual > expected;\n case \"$gte\":\n return actual >= expected;\n case \"$exists\":\n // Using `!=` and `==` instead of strict checks so it also matches for undefined\n return expected ? actual != null : actual == null;\n case \"$in\":\n if (!Array.isArray(expected)) return false;\n return isIn(actual, expected);\n case \"$nin\":\n if (!Array.isArray(expected)) return false;\n return !isIn(actual, expected);\n case \"$not\":\n return !evalConditionValue(expected, actual);\n case \"$size\":\n if (!Array.isArray(actual)) return false;\n return evalConditionValue(expected, actual.length);\n case \"$elemMatch\":\n return elemMatch(actual, expected);\n case \"$all\":\n if (!Array.isArray(actual)) return false;\n for (let i = 0; i < expected.length; i++) {\n let passed = false;\n for (let j = 0; j < actual.length; j++) {\n if (evalConditionValue(expected[i], actual[j])) {\n passed = true;\n break;\n }\n }\n if (!passed) return false;\n }\n return true;\n case \"$regex\":\n try {\n return getRegex(expected).test(actual);\n } catch (e) {\n return false;\n }\n case \"$type\":\n return getType(actual) === expected;\n default:\n console.error(\"Unknown operator: \" + operator);\n return false;\n }\n}\n\n// Recursive $or rule\nfunction evalOr(obj, conditions) {\n if (!conditions.length) return true;\n for (let i = 0; i < conditions.length; i++) {\n if (evalCondition(obj, conditions[i])) {\n return true;\n }\n }\n return false;\n}\n\n// Recursive $and rule\nfunction evalAnd(obj, conditions) {\n for (let i = 0; i < conditions.length; i++) {\n if (!evalCondition(obj, conditions[i])) {\n return false;\n }\n }\n return true;\n}\n//# sourceMappingURL=mongrule.js.map","// Config settings\nconst cacheSettings = {\n // Consider a fetch stale after 1 minute\n staleTTL: 1000 * 60,\n // Max time to keep a fetch in cache (24 hours default)\n maxAge: 1000 * 60 * 60 * 24,\n cacheKey: \"gbFeaturesCache\",\n backgroundSync: true,\n maxEntries: 10,\n disableIdleStreams: false,\n idleStreamInterval: 20000\n};\nconst polyfills = {\n fetch: globalThis.fetch ? globalThis.fetch.bind(globalThis) : undefined,\n SubtleCrypto: globalThis.crypto ? globalThis.crypto.subtle : undefined,\n EventSource: globalThis.EventSource\n};\nexport const helpers = {\n fetchFeaturesCall: _ref => {\n let {\n host,\n clientKey,\n headers\n } = _ref;\n return polyfills.fetch(\"\".concat(host, \"/api/features/\").concat(clientKey), {\n headers\n });\n },\n fetchRemoteEvalCall: _ref2 => {\n let {\n host,\n clientKey,\n payload,\n headers\n } = _ref2;\n const options = {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...headers\n },\n body: JSON.stringify(payload)\n };\n return polyfills.fetch(\"\".concat(host, \"/api/eval/\").concat(clientKey), options);\n },\n eventSourceCall: _ref3 => {\n let {\n host,\n clientKey,\n headers\n } = _ref3;\n if (headers) {\n return new polyfills.EventSource(\"\".concat(host, \"/sub/\").concat(clientKey), {\n headers\n });\n }\n return new polyfills.EventSource(\"\".concat(host, \"/sub/\").concat(clientKey));\n },\n startIdleListener: () => {\n let idleTimeout;\n const isBrowser = typeof window !== \"undefined\" && typeof document !== \"undefined\";\n if (!isBrowser) return;\n const onVisibilityChange = () => {\n if (document.visibilityState === \"visible\") {\n window.clearTimeout(idleTimeout);\n onVisible();\n } else if (document.visibilityState === \"hidden\") {\n idleTimeout = window.setTimeout(onHidden, cacheSettings.idleStreamInterval);\n }\n };\n document.addEventListener(\"visibilitychange\", onVisibilityChange);\n return () => document.removeEventListener(\"visibilitychange\", onVisibilityChange);\n },\n stopIdleListener: () => {\n // No-op, replaced by startIdleListener\n }\n};\ntry {\n if (globalThis.localStorage) {\n polyfills.localStorage = globalThis.localStorage;\n }\n} catch (e) {\n // Ignore localStorage errors\n}\n\n// Global state\nconst subscribedInstances = new Map();\nlet cacheInitialized = false;\nconst cache = new Map();\nconst activeFetches = new Map();\nconst streams = new Map();\nconst supportsSSE = new Set();\n\n// Public functions\nexport function setPolyfills(overrides) {\n Object.assign(polyfills, overrides);\n}\nexport function configureCache(overrides) {\n Object.assign(cacheSettings, overrides);\n if (!cacheSettings.backgroundSync) {\n clearAutoRefresh();\n }\n}\nexport async function clearCache() {\n cache.clear();\n activeFetches.clear();\n clearAutoRefresh();\n cacheInitialized = false;\n await updatePersistentCache();\n}\nexport async function refreshFeatures(instance, timeout, skipCache, allowStale, updateInstance, backgroundSync) {\n if (!backgroundSync) {\n cacheSettings.backgroundSync = false;\n }\n const data = await fetchFeaturesWithCache(instance, allowStale, timeout, skipCache);\n updateInstance && data && (await refreshInstance(instance, data));\n}\n\n// Subscribe a GrowthBook instance to feature changes\nexport function subscribe(instance) {\n const key = getKey(instance);\n const subs = subscribedInstances.get(key) || new Set();\n subs.add(instance);\n subscribedInstances.set(key, subs);\n}\nexport function unsubscribe(instance) {\n subscribedInstances.forEach(s => s.delete(instance));\n}\nexport function onHidden() {\n streams.forEach(channel => {\n if (!channel) return;\n channel.state = \"idle\";\n disableChannel(channel);\n });\n}\nexport function onVisible() {\n streams.forEach(channel => {\n if (!channel) return;\n if (channel.state !== \"idle\") return;\n enableChannel(channel);\n });\n}\n\n// Private functions\n\nasync function updatePersistentCache() {\n try {\n if (!polyfills.localStorage) return;\n await polyfills.localStorage.setItem(cacheSettings.cacheKey, JSON.stringify(Array.from(cache.entries())));\n } catch (e) {\n // Ignore localStorage errors\n }\n}\nasync function fetchFeaturesWithCache(instance, allowStale, timeout, skipCache) {\n const key = getKey(instance);\n const cacheKey = getCacheKey(instance);\n const now = new Date();\n const minStaleAt = new Date(now.getTime() - cacheSettings.maxAge + cacheSettings.staleTTL);\n await initializeCache();\n const existing = cache.get(cacheKey);\n if (existing && !skipCache && (allowStale || existing.staleAt > now) && existing.staleAt > minStaleAt) {\n // Restore from cache whether SSE is supported\n if (existing.sse) supportsSSE.add(key);\n\n // Reload features in the background if stale\n if (existing.staleAt < now) {\n fetchFeatures(instance);\n }\n // Otherwise, if we don't need to refresh now, start a background sync\n else {\n startAutoRefresh(instance);\n }\n return existing.data;\n } else {\n return await promiseTimeout(fetchFeatures(instance), timeout);\n }\n}\nfunction getKey(instance) {\n const [apiHost, clientKey] = instance.getApiInfo();\n return \"\".concat(apiHost, \"||\").concat(clientKey);\n}\nfunction getCacheKey(instance) {\n const baseKey = getKey(instance);\n if (!instance.isRemoteEval()) return baseKey;\n const attributes = instance.getAttributes();\n const cacheKeyAttributes = instance.getCacheKeyAttributes() || Object.keys(instance.getAttributes());\n const ca = {};\n cacheKeyAttributes.forEach(key => {\n ca[key] = attributes[key];\n });\n const fv = instance.getForcedVariations();\n const url = instance.getUrl();\n return \"\".concat(baseKey, \"||\").concat(JSON.stringify({\n ca,\n fv,\n url\n }));\n}\n\n// Guarantee the promise always resolves within {timeout} ms\n// Resolved value will be `null` when there's an error or it takes too long\n// Note: The promise will continue running in the background, even if the timeout is hit\nfunction promiseTimeout(promise, timeout) {\n return new Promise(resolve => {\n let resolved = false;\n let timer;\n const finish = data => {\n if (resolved) return;\n resolved = true;\n timer && clearTimeout(timer);\n resolve(data || null);\n };\n if (timeout) {\n timer = setTimeout(() => finish(), timeout);\n }\n promise.then(data => finish(data)).catch(() => finish());\n });\n}\n\n// Populate cache from localStorage (if available)\nasync function initializeCache() {\n if (cacheInitialized) return;\n cacheInitialized = true;\n try {\n if (polyfills.localStorage) {\n const value = await polyfills.localStorage.getItem(cacheSettings.cacheKey);\n if (value) {\n const parsed = JSON.parse(value);\n if (parsed && Array.isArray(parsed)) {\n parsed.forEach(_ref4 => {\n let [key, data] = _ref4;\n cache.set(key, {\n ...data,\n staleAt: new Date(data.staleAt)\n });\n });\n }\n cleanupCache();\n }\n }\n } catch (e) {\n // Ignore localStorage errors\n }\n if (!cacheSettings.disableIdleStreams) {\n const cleanupFn = helpers.startIdleListener();\n if (cleanupFn) {\n helpers.stopIdleListener = cleanupFn;\n }\n }\n}\n\n// Enforce the maxEntries limit\nfunction cleanupCache() {\n const entriesWithTimestamps = Array.from(cache.entries()).map(_ref5 => {\n let [key, value] = _ref5;\n return {\n key,\n staleAt: value.staleAt.getTime()\n };\n }).sort((a, b) => a.staleAt - b.staleAt);\n const entriesToRemoveCount = Math.min(Math.max(0, cache.size - cacheSettings.maxEntries), cache.size);\n for (let i = 0; i < entriesToRemoveCount; i++) {\n cache.delete(entriesWithTimestamps[i].key);\n }\n}\n\n// Called whenever new features are fetched from the API\nfunction onNewFeatureData(key, cacheKey, data) {\n // If contents haven't changed, ignore the update, extend the stale TTL\n const version = data.dateUpdated || \"\";\n const staleAt = new Date(Date.now() + cacheSettings.staleTTL);\n const existing = cache.get(cacheKey);\n if (existing && version && existing.version === version) {\n existing.staleAt = staleAt;\n updatePersistentCache();\n return;\n }\n\n // Update in-memory cache\n cache.set(cacheKey, {\n data,\n version,\n staleAt,\n sse: supportsSSE.has(key)\n });\n cleanupCache();\n // Update local storage (don't await this, just update asynchronously)\n updatePersistentCache();\n\n // Update features for all subscribed GrowthBook instances\n const instances = subscribedInstances.get(key);\n instances && instances.forEach(instance => refreshInstance(instance, data));\n}\nasync function refreshInstance(instance, data) {\n data = await instance.decryptPayload(data, undefined, polyfills.SubtleCrypto);\n await instance.refreshStickyBuckets(data);\n instance.setFeatures(data.features || instance.getFeatures());\n instance.setExperiments(data.experiments || instance.getExperiments());\n}\nasync function fetchFeatures(instance) {\n const {\n apiHost,\n apiRequestHeaders\n } = instance.getApiHosts();\n const clientKey = instance.getClientKey();\n const remoteEval = instance.isRemoteEval();\n const key = getKey(instance);\n const cacheKey = getCacheKey(instance);\n let promise = activeFetches.get(cacheKey);\n if (!promise) {\n const fetcher = remoteEval ? helpers.fetchRemoteEvalCall({\n host: apiHost,\n clientKey,\n payload: {\n attributes: instance.getAttributes(),\n forcedVariations: instance.getForcedVariations(),\n forcedFeatures: Array.from(instance.getForcedFeatures().entries()),\n url: instance.getUrl()\n },\n headers: apiRequestHeaders\n }) : helpers.fetchFeaturesCall({\n host: apiHost,\n clientKey,\n headers: apiRequestHeaders\n });\n\n // TODO: auto-retry if status code indicates a temporary error\n promise = fetcher.then(res => {\n if (!res.ok) {\n throw new Error(\"HTTP error: \".concat(res.status));\n }\n if (res.headers.get(\"x-sse-support\") === \"enabled\") {\n supportsSSE.add(key);\n }\n return res.json();\n }).then(data => {\n onNewFeatureData(key, cacheKey, data);\n startAutoRefresh(instance);\n activeFetches.delete(cacheKey);\n return data;\n }).catch(e => {\n process.env.NODE_ENV !== \"production\" && instance.log(\"Error fetching features\", {\n apiHost,\n clientKey,\n error: e ? e.message : null\n });\n activeFetches.delete(cacheKey);\n return Promise.resolve({});\n });\n activeFetches.set(cacheKey, promise);\n }\n return await promise;\n}\n\n// Watch a feature endpoint for changes\n// Will prefer SSE if enabled, otherwise fall back to cron\nfunction startAutoRefresh(instance) {\n const key = getKey(instance);\n const cacheKey = getCacheKey(instance);\n const {\n streamingHost,\n streamingHostRequestHeaders\n } = instance.getApiHosts();\n const clientKey = instance.getClientKey();\n if (cacheSettings.backgroundSync && supportsSSE.has(key) && polyfills.EventSource) {\n if (streams.has(key)) return;\n const channel = {\n src: null,\n host: streamingHost,\n clientKey,\n headers: streamingHostRequestHeaders,\n cb: event => {\n try {\n if (event.type === \"features-updated\") {\n const instances = subscribedInstances.get(key);\n instances && instances.forEach(instance => {\n fetchFeatures(instance);\n });\n } else if (event.type === \"features\") {\n const json = JSON.parse(event.data);\n onNewFeatureData(key, cacheKey, json);\n }\n // Reset error count on success\n channel.errors = 0;\n } catch (e) {\n process.env.NODE_ENV !== \"production\" && instance.log(\"SSE Error\", {\n streamingHost,\n clientKey,\n error: e ? e.message : null\n });\n onSSEError(channel);\n }\n },\n errors: 0,\n state: \"active\"\n };\n streams.set(key, channel);\n enableChannel(channel);\n }\n}\nfunction onSSEError(channel) {\n if (channel.state === \"idle\") return;\n channel.errors++;\n if (channel.errors > 3 || channel.src && channel.src.readyState === 2) {\n // exponential backoff after 4 errors, with jitter\n const delay = Math.pow(3, channel.errors - 3) * (1000 + Math.random() * 1000);\n disableChannel(channel);\n setTimeout(() => {\n if ([\"idle\", \"active\"].includes(channel.state)) return;\n enableChannel(channel);\n }, Math.min(delay, 300000)); // 5 minutes max\n }\n}\n\nfunction disableChannel(channel) {\n if (!channel.src) return;\n channel.src.onopen = null;\n channel.src.onerror = null;\n channel.src.close();\n channel.src = null;\n if (channel.state === \"active\") {\n channel.state = \"disabled\";\n }\n}\nfunction enableChannel(channel) {\n channel.src = helpers.eventSourceCall({\n host: channel.host,\n clientKey: channel.clientKey,\n headers: channel.headers\n });\n channel.state = \"active\";\n channel.src.addEventListener(\"features\", channel.cb);\n channel.src.addEventListener(\"features-updated\", channel.cb);\n channel.src.onerror = () => onSSEError(channel);\n channel.src.onopen = () => {\n channel.errors = 0;\n };\n}\nfunction destroyChannel(channel, key) {\n disableChannel(channel);\n streams.delete(key);\n}\nfunction clearAutoRefresh() {\n // Clear list of which keys are auto-updated\n supportsSSE.clear();\n\n // Stop listening for any SSE events\n streams.forEach(destroyChannel);\n\n // Remove all references to GrowthBook instances\n subscribedInstances.clear();\n\n // Run the idle stream cleanup function\n helpers.stopIdleListener();\n}\n//# sourceMappingURL=feature-repository.js.map","import mutate from \"dom-mutator\";\nimport { chooseVariation, decrypt, getBucketRanges, getQueryStringOverride, getUrlRegExp, hash, inNamespace, inRange, isIncluded, isURLTargeted, loadSDKVersion, mergeQueryStrings, toString } from \"./util\";\nimport { evalCondition } from \"./mongrule\";\nimport { refreshFeatures, subscribe, unsubscribe } from \"./feature-repository\";\nconst isBrowser = typeof window !== \"undefined\" && typeof document !== \"undefined\";\nconst SDK_VERSION = loadSDKVersion();\nexport class GrowthBook {\n // context is technically private, but some tools depend on it so we can't mangle the name\n // _ctx below is a clone of this property that we use internally\n\n // Properties and methods that start with \"_\" are mangled by Terser (saves ~150 bytes)\n\n // eslint-disable-next-line\n\n constructor(context) {\n context = context || {};\n // These properties are all initialized in the constructor instead of above\n // This saves ~80 bytes in the final output\n this.version = SDK_VERSION;\n this._ctx = this.context = context;\n this._renderer = null;\n this._trackedExperiments = new Set();\n this._trackedFeatures = {};\n this.debug = false;\n this._subscriptions = new Set();\n this._rtQueue = [];\n this._rtTimer = 0;\n this.ready = false;\n this._assigned = new Map();\n this._forcedFeatureValues = new Map();\n this._attributeOverrides = {};\n this._activeAutoExperiments = new Map();\n this._triggeredExpKeys = new Set();\n this._loadFeaturesCalled = false;\n this._redirectedUrl = \"\";\n this._deferredTrackingCalls = [];\n if (context.renderer) {\n this._renderer = context.renderer;\n }\n if (context.remoteEval) {\n if (context.decryptionKey) {\n throw new Error(\"Encryption is not available for remoteEval\");\n }\n if (!context.clientKey) {\n throw new Error(\"Missing clientKey\");\n }\n let isGbHost = false;\n try {\n isGbHost = !!new URL(context.apiHost || \"\").hostname.match(/growthbook\\.io$/i);\n } catch (e) {\n // ignore invalid URLs\n }\n if (isGbHost) {\n throw new Error(\"Cannot use remoteEval on GrowthBook Cloud\");\n }\n } else {\n if (context.cacheKeyAttributes) {\n throw new Error(\"cacheKeyAttributes are only used for remoteEval\");\n }\n }\n if (context.features) {\n this.ready = true;\n }\n if (isBrowser && context.enableDevMode) {\n window._growthbook = this;\n document.dispatchEvent(new Event(\"gbloaded\"));\n }\n if (context.experiments) {\n this.ready = true;\n this._updateAllAutoExperiments();\n } else if (context.antiFlicker) {\n this._setAntiFlicker();\n }\n if (context.clientKey && !context.remoteEval) {\n this._refresh({}, true, false);\n }\n }\n async loadFeatures(options) {\n if (options && options.autoRefresh) {\n // interpret deprecated autoRefresh option as subscribeToChanges\n this._ctx.subscribeToChanges = true;\n }\n this._loadFeaturesCalled = true;\n await this._refresh(options, true, true);\n if (this._canSubscribe()) {\n subscribe(this);\n }\n }\n async refreshFeatures(options) {\n await this._refresh(options, false, true);\n }\n getApiInfo() {\n return [this.getApiHosts().apiHost, this.getClientKey()];\n }\n getApiHosts() {\n const defaultHost = this._ctx.apiHost || \"https://cdn.growthbook.io\";\n return {\n apiHost: defaultHost.replace(/\\/*$/, \"\"),\n streamingHost: (this._ctx.streamingHost || defaultHost).replace(/\\/*$/, \"\"),\n apiRequestHeaders: this._ctx.apiHostRequestHeaders,\n streamingHostRequestHeaders: this._ctx.streamingHostRequestHeaders\n };\n }\n getClientKey() {\n return this._ctx.clientKey || \"\";\n }\n isRemoteEval() {\n return this._ctx.remoteEval || false;\n }\n getCacheKeyAttributes() {\n return this._ctx.cacheKeyAttributes;\n }\n async _refresh(options, allowStale, updateInstance) {\n options = options || {};\n if (!this._ctx.clientKey) {\n throw new Error(\"Missing clientKey\");\n }\n await refreshFeatures(this, options.timeout, options.skipCache || this._ctx.enableDevMode, allowStale, updateInstance, this._ctx.backgroundSync !== false);\n }\n _render() {\n if (this._renderer) {\n try {\n this._renderer();\n } catch (e) {\n console.error(\"Failed to render\", e);\n }\n }\n }\n setFeatures(features) {\n this._ctx.features = features;\n this.ready = true;\n this._render();\n }\n async setEncryptedFeatures(encryptedString, decryptionKey, subtle) {\n const featuresJSON = await decrypt(encryptedString, decryptionKey || this._ctx.decryptionKey, subtle);\n this.setFeatures(JSON.parse(featuresJSON));\n }\n setExperiments(experiments) {\n this._ctx.experiments = experiments;\n this.ready = true;\n this._updateAllAutoExperiments();\n }\n async setEncryptedExperiments(encryptedString, decryptionKey, subtle) {\n const experimentsJSON = await decrypt(encryptedString, decryptionKey || this._ctx.decryptionKey, subtle);\n this.setExperiments(JSON.parse(experimentsJSON));\n }\n async decryptPayload(data, decryptionKey, subtle) {\n if (data.encryptedFeatures) {\n data.features = JSON.parse(await decrypt(data.encryptedFeatures, decryptionKey || this._ctx.decryptionKey, subtle));\n delete data.encryptedFeatures;\n }\n if (data.encryptedExperiments) {\n data.experiments = JSON.parse(await decrypt(data.encryptedExperiments, decryptionKey || this._ctx.decryptionKey, subtle));\n delete data.encryptedExperiments;\n }\n return data;\n }\n async setAttributes(attributes) {\n this._ctx.attributes = attributes;\n if (this._ctx.stickyBucketService) {\n await this.refreshStickyBuckets();\n }\n if (this._ctx.remoteEval) {\n await this._refreshForRemoteEval();\n return;\n }\n this._render();\n this._updateAllAutoExperiments();\n }\n async updateAttributes(attributes) {\n return this.setAttributes({\n ...this._ctx.attributes,\n ...attributes\n });\n }\n async setAttributeOverrides(overrides) {\n this._attributeOverrides = overrides;\n if (this._ctx.stickyBucketService) {\n await this.refreshStickyBuckets();\n }\n if (this._ctx.remoteEval) {\n await this._refreshForRemoteEval();\n return;\n }\n this._render();\n this._updateAllAutoExperiments();\n }\n async setForcedVariations(vars) {\n this._ctx.forcedVariations = vars || {};\n if (this._ctx.remoteEval) {\n await this._refreshForRemoteEval();\n return;\n }\n this._render();\n this._updateAllAutoExperiments();\n }\n\n // eslint-disable-next-line\n setForcedFeatures(map) {\n this._forcedFeatureValues = map;\n this._render();\n }\n async setURL(url) {\n this._ctx.url = url;\n this._redirectedUrl = \"\";\n if (this._ctx.remoteEval) {\n await this._refreshForRemoteEval();\n this._updateAllAutoExperiments(true);\n return;\n }\n this._updateAllAutoExperiments(true);\n }\n getAttributes() {\n return {\n ...this._ctx.attributes,\n ...this._attributeOverrides\n };\n }\n getForcedVariations() {\n return this._ctx.forcedVariations || {};\n }\n getForcedFeatures() {\n // eslint-disable-next-line\n return this._forcedFeatureValues || new Map();\n }\n getStickyBucketAssignmentDocs() {\n return this._ctx.stickyBucketAssignmentDocs || {};\n }\n getUrl() {\n return this._ctx.url || \"\";\n }\n getFeatures() {\n return this._ctx.features || {};\n }\n getExperiments() {\n return this._ctx.experiments || [];\n }\n subscribe(cb) {\n this._subscriptions.add(cb);\n return () => {\n this._subscriptions.delete(cb);\n };\n }\n _canSubscribe() {\n return this._ctx.backgroundSync !== false && this._ctx.subscribeToChanges;\n }\n async _refreshForRemoteEval() {\n if (!this._ctx.remoteEval) return;\n if (!this._loadFeaturesCalled) return;\n await this._refresh({}, false, true).catch(() => {\n // Ignore errors\n });\n }\n getAllResults() {\n return new Map(this._assigned);\n }\n destroy() {\n // Release references to save memory\n this._subscriptions.clear();\n this._assigned.clear();\n this._trackedExperiments.clear();\n this._trackedFeatures = {};\n this._rtQueue = [];\n if (this._rtTimer) {\n clearTimeout(this._rtTimer);\n }\n unsubscribe(this);\n if (isBrowser && window._growthbook === this) {\n delete window._growthbook;\n }\n\n // Undo any active auto experiments\n this._activeAutoExperiments.forEach(exp => {\n exp.undo();\n });\n this._activeAutoExperiments.clear();\n this._triggeredExpKeys.clear();\n }\n setRenderer(renderer) {\n this._renderer = renderer;\n }\n forceVariation(key, variation) {\n this._ctx.forcedVariations = this._ctx.forcedVariations || {};\n this._ctx.forcedVariations[key] = variation;\n if (this._ctx.remoteEval) {\n this._refreshForRemoteEval();\n return;\n }\n this._updateAllAutoExperiments();\n this._render();\n }\n run(experiment) {\n const result = this._run(experiment, null);\n this._fireSubscriptions(experiment, result);\n return result;\n }\n triggerExperiment(key) {\n this._triggeredExpKeys.add(key);\n if (!this._ctx.experiments) return null;\n const experiments = this._ctx.experiments.filter(exp => exp.key === key);\n return experiments.map(exp => {\n if (!exp.manual) return null;\n return this._runAutoExperiment(exp);\n }).filter(res => res !== null);\n }\n _runAutoExperiment(experiment, forceRerun) {\n const existing = this._activeAutoExperiments.get(experiment);\n\n // If this is a manual experiment and it's not already running, skip\n if (experiment.manual && !this._triggeredExpKeys.has(experiment.key) && !existing) return null;\n\n // Run the experiment\n const result = this.run(experiment);\n\n // A hash to quickly tell if the assigned value changed\n const valueHash = JSON.stringify(result.value);\n\n // If the changes are already active, no need to re-apply them\n if (!forceRerun && result.inExperiment && existing && existing.valueHash === valueHash) {\n return result;\n }\n\n // Undo any existing changes\n if (existing) this._undoActiveAutoExperiment(experiment);\n\n // Apply new changes\n if (result.inExperiment) {\n if (result.value.urlRedirect && experiment.urlPatterns) {\n const url = experiment.persistQueryString ? mergeQueryStrings(this._getContextUrl(), result.value.urlRedirect) : result.value.urlRedirect;\n if (isURLTargeted(url, experiment.urlPatterns)) {\n this.log(\"Skipping redirect because original URL matches redirect URL\", {\n id: experiment.key\n });\n return result;\n }\n this._redirectedUrl = url;\n const navigate = this._getNavigateFunction();\n if (navigate) {\n if (isBrowser) {\n var _this$_ctx$navigateDe;\n this._setAntiFlicker();\n window.setTimeout(() => {\n try {\n navigate(url);\n } catch (e) {\n console.error(e);\n }\n }, (_this$_ctx$navigateDe = this._ctx.navigateDelay) !== null && _this$_ctx$navigateDe !== void 0 ? _this$_ctx$navigateDe : 100);\n } else {\n try {\n navigate(url);\n } catch (e) {\n console.error(e);\n }\n }\n }\n } else {\n const undo = this._applyDOMChanges(result.value);\n if (undo) {\n this._activeAutoExperiments.set(experiment, {\n undo,\n valueHash\n });\n }\n }\n }\n return result;\n }\n _undoActiveAutoExperiment(exp) {\n const data = this._activeAutoExperiments.get(exp);\n if (data) {\n data.undo();\n this._activeAutoExperiments.delete(exp);\n }\n }\n _isRedirectExperiment(exp) {\n return exp.variations.some(v => Object.keys(v).includes(\"urlRedirect\"));\n }\n _updateAllAutoExperiments(forceRerun) {\n const experiments = this._ctx.experiments || [];\n\n // Stop any experiments that are no longer defined\n const keys = new Set(experiments);\n this._activeAutoExperiments.forEach((v, k) => {\n if (!keys.has(k)) {\n v.undo();\n this._activeAutoExperiments.delete(k);\n }\n });\n\n // Re-run all new/updated experiments\n for (const exp of experiments) {\n const result = this._runAutoExperiment(exp, forceRerun);\n\n // Once you're in a redirect experiment, break out of the loop and don't run any further experiments\n if (result !== null && result !== void 0 && result.inExperiment && this._isRedirectExperiment(exp)) {\n break;\n }\n }\n }\n _fireSubscriptions(experiment, result) {\n const key = experiment.key;\n\n // If assigned variation has changed, fire subscriptions\n const prev = this._assigned.get(key);\n // TODO: what if the experiment definition has changed?\n if (!prev || prev.result.inExperiment !== result.inExperiment || prev.result.variationId !== result.variationId) {\n this._assigned.set(key, {\n experiment,\n result\n });\n this._subscriptions.forEach(cb => {\n try {\n cb(experiment, result);\n } catch (e) {\n console.error(e);\n }\n });\n }\n }\n _trackFeatureUsage(key, res) {\n // Don't track feature usage that was forced via an override\n if (res.source === \"override\") return;\n\n // Only track a feature once, unless the assigned value changed\n const stringifiedValue = JSON.stringify(res.value);\n if (this._trackedFeatures[key] === stringifiedValue) return;\n this._trackedFeatures[key] = stringifiedValue;\n\n // Fire user-supplied callback\n if (this._ctx.onFeatureUsage) {\n try {\n this._ctx.onFeatureUsage(key, res);\n } catch (e) {\n // Ignore feature usage callback errors\n }\n }\n\n // In browser environments, queue up feature usage to be tracked in batches\n if (!isBrowser || !window.fetch) return;\n this._rtQueue.push({\n key,\n on: res.on\n });\n if (!this._rtTimer) {\n this._rtTimer = window.setTimeout(() => {\n // Reset the queue\n this._rtTimer = 0;\n const q = [...this._rtQueue];\n this._rtQueue = [];\n\n // Skip logging if a real-time usage key is not configured\n if (!this._ctx.realtimeKey) return;\n window.fetch(\"https://rt.growthbook.io/?key=\".concat(this._ctx.realtimeKey, \"&events=\").concat(encodeURIComponent(JSON.stringify(q))), {\n cache: \"no-cache\",\n mode: \"no-cors\"\n }).catch(() => {\n // TODO: retry in case of network errors?\n });\n }, this._ctx.realtimeInterval || 2000);\n }\n }\n _getFeatureResult(key, value, source, ruleId, experiment, result) {\n const ret = {\n value,\n on: !!value,\n off: !value,\n source,\n ruleId: ruleId || \"\"\n };\n if (experiment) ret.experiment = experiment;\n if (result) ret.experimentResult = result;\n\n // Track the usage of this feature in real-time\n this._trackFeatureUsage(key, ret);\n return ret;\n }\n isOn(key) {\n return this.evalFeature(key).on;\n }\n isOff(key) {\n return this.evalFeature(key).off;\n }\n getFeatureValue(key, defaultValue) {\n const value = this.evalFeature(key).value;\n return value === null ? defaultValue : value;\n }\n\n /**\n * @deprecated Use {@link evalFeature}\n * @param id\n */\n // eslint-disable-next-line\n feature(id) {\n return this.evalFeature(id);\n }\n evalFeature(id) {\n return this._evalFeature(id);\n }\n _evalFeature(id, evalCtx) {\n evalCtx = evalCtx || {\n evaluatedFeatures: new Set()\n };\n if (evalCtx.evaluatedFeatures.has(id)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"evalFeature: circular dependency detected: \".concat(evalCtx.id, \" -> \").concat(id), {\n from: evalCtx.id,\n to: id\n });\n return this._getFeatureResult(id, null, \"cyclicPrerequisite\");\n }\n evalCtx.evaluatedFeatures.add(id);\n evalCtx.id = id;\n\n // Global override\n if (this._forcedFeatureValues.has(id)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Global override\", {\n id,\n value: this._forcedFeatureValues.get(id)\n });\n return this._getFeatureResult(id, this._forcedFeatureValues.get(id), \"override\");\n }\n\n // Unknown feature id\n if (!this._ctx.features || !this._ctx.features[id]) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Unknown feature\", {\n id\n });\n return this._getFeatureResult(id, null, \"unknownFeature\");\n }\n\n // Get the feature\n const feature = this._ctx.features[id];\n\n // Loop through the rules\n if (feature.rules) {\n rules: for (const rule of feature.rules) {\n // If there are prerequisite flag(s), evaluate them\n if (rule.parentConditions) {\n for (const parentCondition of rule.parentConditions) {\n const parentResult = this._evalFeature(parentCondition.id, evalCtx);\n // break out for cyclic prerequisites\n if (parentResult.source === \"cyclicPrerequisite\") {\n return this._getFeatureResult(id, null, \"cyclicPrerequisite\");\n }\n const evalObj = {\n value: parentResult.value\n };\n const evaled = evalCondition(evalObj, parentCondition.condition || {});\n if (!evaled) {\n // blocking prerequisite eval failed: feature evaluation fails\n if (parentCondition.gate) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Feature blocked by prerequisite\", {\n id,\n rule\n });\n return this._getFeatureResult(id, null, \"prerequisite\");\n }\n // non-blocking prerequisite eval failed: break out of parentConditions loop, jump to the next rule\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip rule because prerequisite evaluation fails\", {\n id,\n rule\n });\n continue rules;\n }\n }\n }\n\n // If there are filters for who is included (e.g. namespaces)\n if (rule.filters && this._isFilteredOut(rule.filters)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip rule because of filters\", {\n id,\n rule\n });\n continue;\n }\n\n // Feature value is being forced\n if (\"force\" in rule) {\n // If it's a conditional rule, skip if the condition doesn't pass\n if (rule.condition && !this._conditionPasses(rule.condition)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip rule because of condition ff\", {\n id,\n rule\n });\n continue;\n }\n\n // If this is a percentage rollout, skip if not included\n if (!this._isIncludedInRollout(rule.seed || id, rule.hashAttribute, this._ctx.stickyBucketService && !rule.disableStickyBucketing ? rule.fallbackAttribute : undefined, rule.range, rule.coverage, rule.hashVersion)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip rule because user not included in rollout\", {\n id,\n rule\n });\n continue;\n }\n process.env.NODE_ENV !== \"production\" && this.log(\"Force value from rule\", {\n id,\n rule\n });\n\n // If this was a remotely evaluated experiment, fire the tracking callbacks\n if (rule.tracks) {\n rule.tracks.forEach(t => {\n this._track(t.experiment, t.result);\n });\n }\n return this._getFeatureResult(id, rule.force, \"force\", rule.id);\n }\n if (!rule.variations) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip invalid rule\", {\n id,\n rule\n });\n continue;\n }\n\n // For experiment rules, run an experiment\n const exp = {\n variations: rule.variations,\n key: rule.key || id\n };\n if (\"coverage\" in rule) exp.coverage = rule.coverage;\n if (rule.weights) exp.weights = rule.weights;\n if (rule.hashAttribute) exp.hashAttribute = rule.hashAttribute;\n if (rule.fallbackAttribute) exp.fallbackAttribute = rule.fallbackAttribute;\n if (rule.disableStickyBucketing) exp.disableStickyBucketing = rule.disableStickyBucketing;\n if (rule.bucketVersion !== undefined) exp.bucketVersion = rule.bucketVersion;\n if (rule.minBucketVersion !== undefined) exp.minBucketVersion = rule.minBucketVersion;\n if (rule.namespace) exp.namespace = rule.namespace;\n if (rule.meta) exp.meta = rule.meta;\n if (rule.ranges) exp.ranges = rule.ranges;\n if (rule.name) exp.name = rule.name;\n if (rule.phase) exp.phase = rule.phase;\n if (rule.seed) exp.seed = rule.seed;\n if (rule.hashVersion) exp.hashVersion = rule.hashVersion;\n if (rule.filters) exp.filters = rule.filters;\n if (rule.condition) exp.condition = rule.condition;\n\n // Only return a value if the user is part of the experiment\n const res = this._run(exp, id);\n this._fireSubscriptions(exp, res);\n if (res.inExperiment && !res.passthrough) {\n return this._getFeatureResult(id, res.value, \"experiment\", rule.id, exp, res);\n }\n }\n }\n process.env.NODE_ENV !== \"production\" && this.log(\"Use default value\", {\n id,\n value: feature.defaultValue\n });\n\n // Fall back to using the default value\n return this._getFeatureResult(id, feature.defaultValue === undefined ? null : feature.defaultValue, \"defaultValue\");\n }\n _isIncludedInRollout(seed, hashAttribute, fallbackAttribute, range, coverage, hashVersion) {\n if (!range && coverage === undefined) return true;\n const {\n hashValue\n } = this._getHashAttribute(hashAttribute, fallbackAttribute);\n if (!hashValue) {\n return false;\n }\n const n = hash(seed, hashValue, hashVersion || 1);\n if (n === null) return false;\n return range ? inRange(n, range) : coverage !== undefined ? n <= coverage : true;\n }\n _conditionPasses(condition) {\n return evalCondition(this.getAttributes(), condition);\n }\n _isFilteredOut(filters) {\n return filters.some(filter => {\n const {\n hashValue\n } = this._getHashAttribute(filter.attribute);\n if (!hashValue) return true;\n const n = hash(filter.seed, hashValue, filter.hashVersion || 2);\n if (n === null) return true;\n return !filter.ranges.some(r => inRange(n, r));\n });\n }\n _run(experiment, featureId) {\n const key = experiment.key;\n const numVariations = experiment.variations.length;\n\n // 1. If experiment has less than 2 variations, return immediately\n if (numVariations < 2) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Invalid experiment\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 2. If the context is disabled, return immediately\n if (this._ctx.enabled === false) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Context disabled\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 2.5. Merge in experiment overrides from the context\n experiment = this._mergeOverrides(experiment);\n\n // 2.6 New, more powerful URL targeting\n if (experiment.urlPatterns && !isURLTargeted(this._getContextUrl(), experiment.urlPatterns)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of url targeting\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 3. If a variation is forced from a querystring, return the forced variation\n const qsOverride = getQueryStringOverride(key, this._getContextUrl(), numVariations);\n if (qsOverride !== null) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Force via querystring\", {\n id: key,\n variation: qsOverride\n });\n return this._getResult(experiment, qsOverride, false, featureId);\n }\n\n // 4. If a variation is forced in the context, return the forced variation\n if (this._ctx.forcedVariations && key in this._ctx.forcedVariations) {\n const variation = this._ctx.forcedVariations[key];\n process.env.NODE_ENV !== \"production\" && this.log(\"Force via dev tools\", {\n id: key,\n variation\n });\n return this._getResult(experiment, variation, false, featureId);\n }\n\n // 5. Exclude if a draft experiment or not active\n if (experiment.status === \"draft\" || experiment.active === false) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because inactive\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 6. Get the hash attribute and return if empty\n const {\n hashAttribute,\n hashValue\n } = this._getHashAttribute(experiment.hashAttribute, this._ctx.stickyBucketService && !experiment.disableStickyBucketing ? experiment.fallbackAttribute : undefined);\n if (!hashValue) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because missing hashAttribute\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n let assigned = -1;\n let foundStickyBucket = false;\n let stickyBucketVersionIsBlocked = false;\n if (this._ctx.stickyBucketService && !experiment.disableStickyBucketing) {\n const {\n variation,\n versionIsBlocked\n } = this._getStickyBucketVariation(experiment.key, experiment.bucketVersion, experiment.minBucketVersion, experiment.meta);\n foundStickyBucket = variation >= 0;\n assigned = variation;\n stickyBucketVersionIsBlocked = !!versionIsBlocked;\n }\n\n // Some checks are not needed if we already have a sticky bucket\n if (!foundStickyBucket) {\n // 7. Exclude if user is filtered out (used to be called \"namespace\")\n if (experiment.filters) {\n if (this._isFilteredOut(experiment.filters)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of filters\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n } else if (experiment.namespace && !inNamespace(hashValue, experiment.namespace)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of namespace\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 7.5. Exclude if experiment.include returns false or throws\n if (experiment.include && !isIncluded(experiment.include)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of include function\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 8. Exclude if condition is false\n if (experiment.condition && !this._conditionPasses(experiment.condition)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of condition exp\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 8.05. Exclude if prerequisites are not met\n if (experiment.parentConditions) {\n for (const parentCondition of experiment.parentConditions) {\n const parentResult = this._evalFeature(parentCondition.id);\n // break out for cyclic prerequisites\n if (parentResult.source === \"cyclicPrerequisite\") {\n return this._getResult(experiment, -1, false, featureId);\n }\n const evalObj = {\n value: parentResult.value\n };\n if (!evalCondition(evalObj, parentCondition.condition || {})) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because prerequisite evaluation fails\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n }\n }\n\n // 8.1. Exclude if user is not in a required group\n if (experiment.groups && !this._hasGroupOverlap(experiment.groups)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of groups\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n }\n\n // 8.2. Old style URL targeting\n if (experiment.url && !this._urlIsValid(experiment.url)) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of url\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 9. Get the variation from the sticky bucket or get bucket ranges and choose variation\n const n = hash(experiment.seed || key, hashValue, experiment.hashVersion || 1);\n if (n === null) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of invalid hash version\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n if (!foundStickyBucket) {\n const ranges = experiment.ranges || getBucketRanges(numVariations, experiment.coverage === undefined ? 1 : experiment.coverage, experiment.weights);\n assigned = chooseVariation(n, ranges);\n }\n\n // 9.5 Unenroll if any prior sticky buckets are blocked by version\n if (stickyBucketVersionIsBlocked) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because sticky bucket version is blocked\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId, undefined, true);\n }\n\n // 10. Return if not in experiment\n if (assigned < 0) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because of coverage\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 11. Experiment has a forced variation\n if (\"force\" in experiment) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Force variation\", {\n id: key,\n variation: experiment.force\n });\n return this._getResult(experiment, experiment.force === undefined ? -1 : experiment.force, false, featureId);\n }\n\n // 12. Exclude if in QA mode\n if (this._ctx.qaMode) {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because QA mode\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 12.5. Exclude if experiment is stopped\n if (experiment.status === \"stopped\") {\n process.env.NODE_ENV !== \"production\" && this.log(\"Skip because stopped\", {\n id: key\n });\n return this._getResult(experiment, -1, false, featureId);\n }\n\n // 13. Build the result object\n const result = this._getResult(experiment, assigned, true, featureId, n, foundStickyBucket);\n\n // 13.5. Persist sticky bucket\n if (this._ctx.stickyBucketService && !experiment.disableStickyBucketing) {\n const {\n changed,\n key: attrKey,\n doc\n } = this._generateStickyBucketAssignmentDoc(hashAttribute, toString(hashValue), {\n [this._getStickyBucketExperimentKey(experiment.key, experiment.bucketVersion)]: result.key\n });\n if (changed) {\n // update local docs\n this._ctx.stickyBucketAssignmentDocs = this._ctx.stickyBucketAssignmentDocs || {};\n this._ctx.stickyBucketAssignmentDocs[attrKey] = doc;\n // save doc\n this._ctx.stickyBucketService.saveAssignments(doc);\n }\n }\n\n // 14. Fire the tracking callback\n this._track(experiment, result);\n\n // 15. Return the result\n process.env.NODE_ENV !== \"production\" && this.log(\"In experiment\", {\n id: key,\n variation: result.variationId\n });\n return result;\n }\n log(msg, ctx) {\n if (!this.debug) return;\n if (this._ctx.log) this._ctx.log(msg, ctx);else console.log(msg, ctx);\n }\n getDeferredTrackingCalls() {\n return this._deferredTrackingCalls;\n }\n setDeferredTrackingCalls(calls) {\n this._deferredTrackingCalls = calls;\n }\n fireDeferredTrackingCalls() {\n let hasInvalidTrackingCall = false;\n this._deferredTrackingCalls.forEach(call => {\n if (!call || !call.experiment || !call.result) {\n console.error(\"Invalid deferred tracking call\", {\n call: call\n });\n hasInvalidTrackingCall = true;\n } else {\n this._track(call.experiment, call.result);\n }\n });\n this._deferredTrackingCalls = [];\n if (hasInvalidTrackingCall) {\n throw new Error(\"Invalid tracking data\");\n }\n }\n setTrackingCallback(callback) {\n this._ctx.trackingCallback = callback;\n try {\n this.fireDeferredTrackingCalls();\n } catch (e) {\n console.error(e);\n }\n }\n _track(experiment, result) {\n if (!this._ctx.trackingCallback) {\n this._deferredTrackingCalls.push({\n experiment,\n result\n });\n return;\n }\n const key = experiment.key;\n\n // Make sure a tracking callback is only fired once per unique experiment\n const k = result.hashAttribute + result.hashValue + key + result.variationId;\n if (this._trackedExperiments.has(k)) return;\n this._trackedExperiments.add(k);\n try {\n this._ctx.trackingCallback(experiment, result);\n } catch (e) {\n console.error(e);\n }\n }\n _mergeOverrides(experiment) {\n const key = experiment.key;\n const o = this._ctx.overrides;\n if (o && o[key]) {\n experiment = Object.assign({}, experiment, o[key]);\n if (typeof experiment.url === \"string\") {\n experiment.url = getUrlRegExp(\n // eslint-disable-next-line\n experiment.url);\n }\n }\n return experiment;\n }\n _getHashAttribute(attr, fallback) {\n let hashAttribute = attr || \"id\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let hashValue = \"\";\n if (this._attributeOverrides[hashAttribute]) {\n hashValue = this._attributeOverrides[hashAttribute];\n } else if (this._ctx.attributes) {\n hashValue = this._ctx.attributes[hashAttribute] || \"\";\n } else if (this._ctx.user) {\n hashValue = this._ctx.user[hashAttribute] || \"\";\n }\n\n // if no match, try fallback\n if (!hashValue && fallback) {\n if (this._attributeOverrides[fallback]) {\n hashValue = this._attributeOverrides[fallback];\n } else if (this._ctx.attributes) {\n hashValue = this._ctx.attributes[fallback] || \"\";\n } else if (this._ctx.user) {\n hashValue = this._ctx.user[fallback] || \"\";\n }\n if (hashValue) {\n hashAttribute = fallback;\n }\n }\n return {\n hashAttribute,\n hashValue\n };\n }\n _getResult(experiment, variationIndex, hashUsed, featureId, bucket, stickyBucketUsed) {\n let inExperiment = true;\n // If assigned variation is not valid, use the baseline and mark the user as not in the experiment\n if (variationIndex < 0 || variationIndex >= experiment.variations.length) {\n variationIndex = 0;\n inExperiment = false;\n }\n const {\n hashAttribute,\n hashValue\n } = this._getHashAttribute(experiment.hashAttribute, this._ctx.stickyBucketService && !experiment.disableStickyBucketing ? experiment.fallbackAttribute : undefined);\n const meta = experiment.meta ? experiment.meta[variationIndex] : {};\n const res = {\n key: meta.key || \"\" + variationIndex,\n featureId,\n inExperiment,\n hashUsed,\n variationId: variationIndex,\n value: experiment.variations[variationIndex],\n hashAttribute,\n hashValue,\n stickyBucketUsed: !!stickyBucketUsed\n };\n if (meta.name) res.name = meta.name;\n if (bucket !== undefined) res.bucket = bucket;\n if (meta.passthrough) res.passthrough = meta.passthrough;\n return res;\n }\n _getContextUrl() {\n return this._ctx.url || (isBrowser ? window.location.href : \"\");\n }\n _urlIsValid(urlRegex) {\n const url = this._getContextUrl();\n if (!url) return false;\n const pathOnly = url.replace(/^https?:\\/\\//, \"\").replace(/^[^/]*\\//, \"/\");\n if (urlRegex.test(url)) return true;\n if (urlRegex.test(pathOnly)) return true;\n return false;\n }\n _hasGroupOverlap(expGroups) {\n const groups = this._ctx.groups || {};\n for (let i = 0; i < expGroups.length; i++) {\n if (groups[expGroups[i]]) return true;\n }\n return false;\n }\n getRedirectUrl() {\n return this._redirectedUrl;\n }\n _getNavigateFunction() {\n if (this._ctx.navigate) {\n return this._ctx.navigate;\n } else if (isBrowser) {\n return url => {\n window.location.replace(url);\n };\n }\n return null;\n }\n _setAntiFlicker() {\n if (!this._ctx.antiFlicker || !isBrowser) return;\n try {\n var _this$_ctx$antiFlicke;\n const styleTag = document.createElement(\"style\");\n styleTag.innerHTML = \".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }\";\n document.head.appendChild(styleTag);\n document.documentElement.classList.add(\"gb-anti-flicker\");\n\n // Fallback if GrowthBook fails to load in specified time or 3.5 seconds\n setTimeout(() => {\n document.documentElement.classList.remove(\"gb-anti-flicker\");\n }, (_this$_ctx$antiFlicke = this._ctx.antiFlickerTimeout) !== null && _this$_ctx$antiFlicke !== void 0 ? _this$_ctx$antiFlicke : 3500);\n } catch (e) {\n console.error(e);\n }\n }\n _applyDOMChanges(changes) {\n if (!isBrowser) return;\n const undo = [];\n if (changes.css) {\n const s = document.createElement(\"style\");\n s.innerHTML = changes.css;\n document.head.appendChild(s);\n undo.push(() => s.remove());\n }\n if (changes.js) {\n const script = document.createElement(\"script\");\n script.innerHTML = changes.js;\n document.head.appendChild(script);\n undo.push(() => script.remove());\n }\n if (changes.domMutations) {\n changes.domMutations.forEach(mutation => {\n undo.push(mutate.declarative(mutation).revert);\n });\n }\n return () => {\n undo.forEach(fn => fn());\n };\n }\n _deriveStickyBucketIdentifierAttributes(data) {\n const attributes = new Set();\n const features = data && data.features ? data.features : this.getFeatures();\n const experiments = data && data.experiments ? data.experiments : this.getExperiments();\n Object.keys(features).forEach(id => {\n const feature = features[id];\n if (feature.rules) {\n for (const rule of feature.rules) {\n if (rule.variations) {\n attributes.add(rule.hashAttribute || \"id\");\n if (rule.fallbackAttribute) {\n attributes.add(rule.fallbackAttribute);\n }\n }\n }\n }\n });\n experiments.map(experiment => {\n attributes.add(experiment.hashAttribute || \"id\");\n if (experiment.fallbackAttribute) {\n attributes.add(experiment.fallbackAttribute);\n }\n });\n return Array.from(attributes);\n }\n async refreshStickyBuckets(data) {\n if (this._ctx.stickyBucketService) {\n const attributes = this._getStickyBucketAttributes(data);\n this._ctx.stickyBucketAssignmentDocs = await this._ctx.stickyBucketService.getAllAssignments(attributes);\n }\n }\n _getStickyBucketAssignments() {\n const mergedAssignments = {};\n Object.values(this._ctx.stickyBucketAssignmentDocs || {}).forEach(doc => {\n if (doc.assignments) Object.assign(mergedAssignments, doc.assignments);\n });\n return mergedAssignments;\n }\n _getStickyBucketVariation(experimentKey, experimentBucketVersion, minExperimentBucketVersion, meta) {\n experimentBucketVersion = experimentBucketVersion || 0;\n minExperimentBucketVersion = minExperimentBucketVersion || 0;\n meta = meta || [];\n const id = this._getStickyBucketExperimentKey(experimentKey, experimentBucketVersion);\n const assignments = this._getStickyBucketAssignments();\n\n // users with any blocked bucket version (0 to minExperimentBucketVersion) are excluded from the test\n if (minExperimentBucketVersion > 0) {\n for (let i = 0; i <= minExperimentBucketVersion; i++) {\n const blockedKey = this._getStickyBucketExperimentKey(experimentKey, i);\n if (assignments[blockedKey] !== undefined) {\n return {\n variation: -1,\n versionIsBlocked: true\n };\n }\n }\n }\n const variationKey = assignments[id];\n if (variationKey === undefined)\n // no assignment found\n return {\n variation: -1\n };\n const variation = meta.findIndex(m => m.key === variationKey);\n if (variation < 0)\n // invalid assignment, treat as \"no assignment found\"\n return {\n variation: -1\n };\n return {\n variation\n };\n }\n _getStickyBucketExperimentKey(experimentKey, experimentBucketVersion) {\n experimentBucketVersion = experimentBucketVersion || 0;\n return \"\".concat(experimentKey, \"__\").concat(experimentBucketVersion);\n }\n _getStickyBucketAttributes(data) {\n const attributes = {};\n this._ctx.stickyBucketIdentifierAttributes = !this._ctx.stickyBucketIdentifierAttributes ? this._deriveStickyBucketIdentifierAttributes(data) : this._ctx.stickyBucketIdentifierAttributes;\n this._ctx.stickyBucketIdentifierAttributes.forEach(attr => {\n const {\n hashValue\n } = this._getHashAttribute(attr);\n attributes[attr] = toString(hashValue);\n });\n return attributes;\n }\n _generateStickyBucketAssignmentDoc(attributeName, attributeValue, assignments) {\n const key = \"\".concat(attributeName, \"||\").concat(attributeValue);\n const existingAssignments = this._ctx.stickyBucketAssignmentDocs && this._ctx.stickyBucketAssignmentDocs[key] ? this._ctx.stickyBucketAssignmentDocs[key].assignments || {} : {};\n const newAssignments = {\n ...existingAssignments,\n ...assignments\n };\n const changed = JSON.stringify(existingAssignments) !== JSON.stringify(newAssignments);\n return {\n key,\n doc: {\n attributeName,\n attributeValue,\n assignments: newAssignments\n },\n changed\n };\n }\n}\n//# sourceMappingURL=GrowthBook.js.map"],"names":["validAttributeName","nullController","revert","Map","mutations","Set","getElementRecord","element","record","get","attributes","set","createElementPropertyRecord","el","attr","getCurrentValue","setValue","mutationRunner","currentValue","isDirty","originalValue","virtualValue","_positionTimeout","observer","MutationObserver","setTimeout","parentNode","insertBeforeNode","observe","childList","subtree","characterData","attributeFilter","getObserverInit","queueIfNeeded","val","currentVal","runDOMUpdates","htmlMutationRunner","forEach","m","mutate","html","transformContainer","document","createElement","innerHTML","getTransformedHTML","classMutationRunner","split","filter","Boolean","Array","from","join","attrMutationRunner","positionMutationRunner","newNodes","_ref","parentSelector","insertBeforeSelector","querySelector","_loadDOMNodes","getHTMLValue","setHTMLValue","value","getElementHTMLRecord","elementRecord","getElementPosition","parentElement","nextElementSibling","setElementPosition","contains","insertBefore","getElementPositionRecord","position","setClassValue","className","removeAttribute","getClassValue","getElementClassRecord","classes","getAttrValue","attrName","_el$getAttribute","getAttribute","setAttrValue","setAttribute","getElementAttributeRecord","setPropertyValue","length","_element$html","_element$html$observe","disconnect","_element$classes","_element$classes$obse","_element$position","_element$position$obs","_element$attributes","_element$attributes$a","_element$attributes$a2","deleteElementPropertyRecord","Object","keys","refreshElementsSet","mutation","kind","elements","size","existingElements","querySelectorAll","selector","has","add","attribute","push","startMutating","revertMutation","index","indexOf","splice","stopMutating","clear","refreshAllElementSets","newMutation","test","classnames","mutatedClassnames","c","documentElement","declarative","_ref2","action","hashFnv32a","str","hval","l","i","charCodeAt","hash","seed","version","inRange","n","range","getUrlRegExp","regexString","escaped","replace","RegExp","e","console","error","isURLTargeted","url","targets","hasIncludeRules","isIncluded","match","_evalURLTarget","type","pattern","include","_evalSimpleUrlTarget","actual","expected","URL","comps","host","pathname","searchParams","v","k","some","data","isPath","_evalSimpleUrlPart","parsed","regex","href","substring","origin","getBucketRanges","numVariations","coverage","weights","undefined","equal","fill","totalWeight","reduce","w","sum","cumulative","map","start","base64ToBuf","b","Uint8Array","atob","async","decrypt","encryptedString","decryptionKey","subtle","globalThis","crypto","Error","key","importKey","name","iv","cipherText","plainTextBuffer","TextDecoder","decode","input","JSON","stringify","paddedVersionString","parts","padStart","_regexCache","evalCondition","obj","condition","evalOr","conditions","evalAnd","entries","evalConditionValue","getPath","path","current","isArray","isOperatorObject","op","evalOperatorCondition","isIn","includes","operator","check","elemMatch","passed","j","t","getType","cacheSettings","staleTTL","maxAge","cacheKey","backgroundSync","maxEntries","disableIdleStreams","idleStreamInterval","polyfills","fetch","bind","SubtleCrypto","EventSource","helpers","fetchFeaturesCall","clientKey","headers","concat","fetchRemoteEvalCall","payload","options","method","body","eventSourceCall","_ref3","startIdleListener","idleTimeout","window","onVisibilityChange","visibilityState","clearTimeout","streams","channel","state","enableChannel","onHidden","addEventListener","removeEventListener","stopIdleListener","localStorage","subscribedInstances","cacheInitialized","cache","activeFetches","supportsSSE","refreshFeatures","instance","timeout","skipCache","allowStale","updateInstance","getKey","getCacheKey","now","Date","minStaleAt","getTime","getItem","parse","_ref4","staleAt","cleanupCache","cleanupFn","initializeCache","existing","sse","fetchFeatures","startAutoRefresh","promise","Promise","resolve","timer","resolved","finish","then","catch","promiseTimeout","fetchFeaturesWithCache","refreshInstance","disableChannel","updatePersistentCache","setItem","apiHost","getApiInfo","baseKey","isRemoteEval","getAttributes","cacheKeyAttributes","getCacheKeyAttributes","ca","fv","getForcedVariations","getUrl","entriesWithTimestamps","_ref5","sort","a","entriesToRemoveCount","Math","min","max","delete","onNewFeatureData","dateUpdated","instances","decryptPayload","refreshStickyBuckets","setFeatures","features","getFeatures","setExperiments","experiments","getExperiments","apiRequestHeaders","getApiHosts","getClientKey","remoteEval","forcedVariations","forcedFeatures","getForcedFeatures","res","ok","status","json","streamingHost","streamingHostRequestHeaders","src","cb","event","errors","onSSEError","readyState","delay","pow","random","onopen","onerror","close","isBrowser","SDK_VERSION","loadSDKVersion","GrowthBook","constructor","context","this","_ctx","_renderer","_trackedExperiments","_trackedFeatures","debug","_subscriptions","_rtQueue","_rtTimer","ready","_assigned","_forcedFeatureValues","_attributeOverrides","_activeAutoExperiments","_triggeredExpKeys","_loadFeaturesCalled","_redirectedUrl","_deferredTrackingCalls","renderer","isGbHost","hostname","enableDevMode","_growthbook","dispatchEvent","Event","_updateAllAutoExperiments","antiFlicker","_setAntiFlicker","_refresh","loadFeatures","autoRefresh","subscribeToChanges","_canSubscribe","subs","subscribe","defaultHost","apiHostRequestHeaders","_render","setEncryptedFeatures","featuresJSON","setEncryptedExperiments","experimentsJSON","encryptedFeatures","encryptedExperiments","setAttributes","stickyBucketService","_refreshForRemoteEval","updateAttributes","setAttributeOverrides","overrides","setForcedVariations","vars","setForcedFeatures","setURL","getStickyBucketAssignmentDocs","stickyBucketAssignmentDocs","getAllResults","destroy","s","exp","undo","setRenderer","forceVariation","variation","run","experiment","result","_run","_fireSubscriptions","triggerExperiment","manual","_runAutoExperiment","forceRerun","valueHash","inExperiment","_undoActiveAutoExperiment","urlRedirect","urlPatterns","persistQueryString","oldUrl","newUrl","currUrl","redirectUrl","toString","mergeQueryStrings","_getContextUrl","log","id","navigate","_getNavigateFunction","_this$_ctx$navigateDe","navigateDelay","_applyDOMChanges","_isRedirectExperiment","variations","prev","variationId","_trackFeatureUsage","source","stringifiedValue","onFeatureUsage","on","q","realtimeKey","encodeURIComponent","mode","realtimeInterval","_getFeatureResult","ruleId","ret","off","experimentResult","isOn","evalFeature","isOff","getFeatureValue","defaultValue","feature","_evalFeature","evalCtx","evaluatedFeatures","rules","rule","parentConditions","parentCondition","parentResult","gate","filters","_isFilteredOut","_conditionPasses","_isIncludedInRollout","hashAttribute","disableStickyBucketing","fallbackAttribute","hashVersion","tracks","_track","force","bucketVersion","minBucketVersion","namespace","meta","ranges","phase","passthrough","hashValue","_getHashAttribute","r","featureId","_getResult","enabled","_mergeOverrides","qsOverride","search","kv","parseInt","getQueryStringOverride","active","assigned","foundStickyBucket","stickyBucketVersionIsBlocked","versionIsBlocked","_getStickyBucketVariation","inNamespace","groups","_hasGroupOverlap","_urlIsValid","chooseVariation","qaMode","changed","attrKey","doc","_generateStickyBucketAssignmentDoc","_getStickyBucketExperimentKey","saveAssignments","msg","ctx","getDeferredTrackingCalls","setDeferredTrackingCalls","calls","fireDeferredTrackingCalls","hasInvalidTrackingCall","call","setTrackingCallback","callback","trackingCallback","o","assign","fallback","user","variationIndex","hashUsed","bucket","stickyBucketUsed","location","urlRegex","pathOnly","expGroups","getRedirectUrl","_this$_ctx$antiFlicke","styleTag","head","appendChild","classList","remove","antiFlickerTimeout","changes","css","js","script","domMutations","fn","_deriveStickyBucketIdentifierAttributes","_getStickyBucketAttributes","getAllAssignments","_getStickyBucketAssignments","mergedAssignments","values","assignments","experimentKey","experimentBucketVersion","minExperimentBucketVersion","variationKey","findIndex","stickyBucketIdentifierAttributes","attributeName","attributeValue","existingAssignments","newAssignments"],"sourceRoot":""}