@growthbook/edge-utils 0.1.2 → 0.1.4
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.
- package/README.md +1 -1
- package/dist/app.js +5 -4
- package/dist/app.js.map +1 -1
- package/dist/generated/sdkWrapper.d.ts +1 -1
- package/dist/generated/sdkWrapper.js +1 -1
- package/dist/generated/sdkWrapper.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/package.json +2 -2
- package/src/app.ts +6 -4
- package/src/generated/sdkWrapper.ts +1 -1
- package/src/types.ts +5 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The **GrowthBook Edge App** provides turnkey Visual Editor and URL Redirect expe
|
|
|
10
10
|
|
|
11
11
|
> [!NOTE]
|
|
12
12
|
>
|
|
13
|
-
> This is a vendor-agnostic **base app** for the GrowthBook Edge App. It is used by our vendor-specific Edge Apps (
|
|
13
|
+
> This is a vendor-agnostic **base app** for the GrowthBook Edge App. It is used by our vendor-specific Edge Apps (Cloudflare Workers, Lambda@Edge). You can also easily build a custom implementation for your edge provider.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
package/dist/app.js
CHANGED
|
@@ -56,13 +56,14 @@ next) {
|
|
|
56
56
|
const resetDomChanges = () => (domChanges = []);
|
|
57
57
|
let preRedirectChangeIds = [];
|
|
58
58
|
const setPreRedirectChangeIds = (changeIds) => (preRedirectChangeIds = changeIds);
|
|
59
|
-
context.config.localStorage
|
|
59
|
+
if (context.config.localStorage)
|
|
60
60
|
(0, growthbook_1.setPolyfills)({ localStorage: context.config.localStorage });
|
|
61
|
-
context.config.crypto
|
|
61
|
+
if (context.config.crypto)
|
|
62
62
|
(0, growthbook_1.setPolyfills)({ SubtleCrypto: context.config.crypto });
|
|
63
|
-
if (context.config.staleTTL !== undefined)
|
|
63
|
+
if (context.config.staleTTL !== undefined)
|
|
64
64
|
(0, growthbook_1.configureCache)({ staleTTL: context.config.staleTTL });
|
|
65
|
-
|
|
65
|
+
if (context.config.fetchFeaturesCall)
|
|
66
|
+
growthbook_1.helpers.fetchFeaturesCall = context.config.fetchFeaturesCall;
|
|
66
67
|
let stickyBucketService = undefined;
|
|
67
68
|
if (context.config.enableStickyBucketing) {
|
|
68
69
|
stickyBucketService =
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAMgC;AAEhC,6CAAiD;AACjD,qCAAoD;AACpD,iDAAmD;AACnD,0DAAkC;AAClC,uCAAqC;AACrC,+DAAgE;AAEhE,SAAsB,OAAO,CAC3B,OAA0B,EAC1B,GAAQ,EACR,GAAS;AACT,8DAA8D;AAC9D,IAAU;;;QAEV,IAAI,GAAG,GAAG,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,aAAa,mDAAG,GAAG,CAAC,KAAI,EAAE,CAAC;QAErD,8DAA8D;QAC9D,IAAI,OAAO,GAAwB;YACjC,cAAc,EAAE,WAAW;SAC5B,CAAC;QACF,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;YAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACvB,CAAC,CAAC;QACF,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAA,mBAAU,EAAC,OAAoC,CAAC,CAAC;QACxE,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,yBAAyB,CAAC,GAAG,GAAG,CAAC;SAC1C;QACD,IAAI,IAAI,GAAG,EAAE,CAAC;QAEd,+BAA+B;QAC/B,IAAI,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,gBAAgB,mDAAG,GAAG,CAAC,MAAK,KAAK,EAAE;YACrD,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,YAAY,mDAAG,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SAChE;QACD,kEAAkE;QAClE,MAAM,KAAK,GAAG,IAAA,kBAAQ,EAAC,OAAoC,EAAE,GAAG,CAAC,CAAC;QAClE,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC9B,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,YAAY,mDACjC,OAAO,EACP,GAAG,EACH,OAAO,EACP,KAAK,CAAC,IAAI,IAAI,EAAE,EAChB,OAAO,EACP,KAAK,CAAC,UAAU,CACjB,CAAC;SACH;QACD,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC9B,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,YAAY,mDAAG,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;SAChE;QAED,MAAM,UAAU,GAAG,IAAA,8BAAiB,EAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAEnE,IAAI,UAAU,GAA8B,EAAE,CAAC;QAC/C,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QAEhD,IAAI,oBAAoB,GAAa,EAAE,CAAC;QACxC,MAAM,uBAAuB,GAAG,CAAC,SAAmB,EAAE,EAAE,CACtD,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAAC;QAErC,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY;YAC7B,IAAA,yBAAY,EAAC,EAAE,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM;YACvB,IAAA,yBAAY,EAAC,EAAE,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS;YACvC,IAAA,2BAAc,EAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB;YAClC,oBAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAE/D,IAAI,mBAAmB,GAGP,SAAS,CAAC;QAC1B,IAAI,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACxC,mBAAmB;gBACjB,MAAA,OAAO,CAAC,MAAM,CAAC,uBAAuB,mCACtC,IAAI,6CAAuB,CAAW;oBACpC,OAAO;oBACP,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB;oBACzC,GAAG;iBACJ,CAAC,CAAC;SACN;QACD,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC;YAChC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;YAC/B,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS;YACnC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa;YAC3C,UAAU;YACV,uBAAuB,EAAE,CAAC,OAAgC,EAAE,EAAE;gBAC5D,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;YAClB,CAAC;YACD,GAAG;YACH,wBAAwB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CACpD,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAC1C;YACD,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB;YACrD,6BAA6B,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CACzD,OAAO,CAAC,MAAM,CAAC,yBAAyB,CACzC;YACD,wCAAwC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CACpE,OAAO,CAAC,MAAM,CAAC,oCAAoC,CACpD;YACD,mBAAmB;YACnB,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB;SACtD,CAAC,CAAC;QAEH,MAAM,UAAU,CAAC,IAAI,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;SAChC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,GAAG,CAAC;QACnB,GAAG,GAAG,MAAM,IAAA,kBAAQ,EAAC;YACnB,OAAO,EAAE,OAAoC;YAC7C,GAAG;YACH,SAAS;YACT,UAAU;YACV,WAAW,EAAE,GAAG;YAChB,eAAe;YACf,uBAAuB,EAAE,uBAAuB;SACjD,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,YAAY,CAAC,OAAoC,EAAE,GAAG,CAAC,CAAC;QAE1E,uDAAuD;QACvD,IAAI,eAAe,GAEH,SAAS,CAAC;QAC1B,IAAI;YACF,eAAe,GAAG,CAAC,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,KAAK,mDAC5C,OAA4B,EAC5B,SAAS,CAEV,CAAA,CAAmE,CAAC;YACrE,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,EAAE,CAAA,EAAE;gBACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,YAAY,mDACjC,OAAO,EACP,GAAG,EACH,OAAO,EACP,qBAAqB,EACrB,OAAO,EACP,GAAG,CACJ,CAAC;SACH;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,mBAAmB,KAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,CAAA,EAAE;YAClE,OAAO,mCAAQ,eAAe,CAAC,OAAO,GAAK,OAAO,CAAE,CAAC;SACtD;QACD,IAAI,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,CAAC;QAEpC,IAAI,GAAG,MAAM,IAAA,gCAAiB,EAAC;YAC7B,IAAI;YACJ,KAAK;YACL,UAAU;SACX,CAAC,CAAC;QAEH,IAAI,GAAG,IAAA,qBAAY,EAAC;YAClB,OAAO,EAAE,OAAoC;YAC7C,IAAI;YACJ,KAAK;YACL,UAAU;YACV,UAAU;YACV,oBAAoB;YACpB,GAAG;YACH,MAAM;SACP,CAAC,CAAC;QAEH,OAAO,MAAA,MAAA,OAAO,CAAC,OAAO,EAAC,YAAY,mDAAG,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;;CAC7E;AAlKD,0BAkKC;AAED,SAAgB,YAAY,CAAC,OAAgB,EAAE,UAAkB;IAC/D,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;IAC/C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAE5C,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ;QACtC,CAAC,CAAC,cAAc,CAAC,QAAQ;QACzB,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAC9B,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ;QACtC,CAAC,CAAC,cAAc,CAAC,QAAQ;QACzB,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAC9B,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI;QAC9B,CAAC,CAAC,cAAc,CAAC,IAAI;QACrB,CAAC,CAAC,QAAQ,KAAK,OAAO;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,KAAK,CAAC;IAEV,IAAI,MAAM,GAAG,GAAG,QAAQ,KAAK,QAAQ,EAAE,CAAC;IACxC,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,KAAK,EAAE;QAC5D,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;KACtB;IACD,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC;IACzC,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;KACnC;IACD,IAAI,gBAAgB,CAAC,IAAI,EAAE;QACzB,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC;KACjC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA9BD,oCA8BC"}
|
|
@@ -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:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,i={revert:function(){}},r=new Map,s=new Set;function o(t){var e=r.get(t);return e||r.set(t,e={element:t,attributes:{}}),e}function u(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 c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.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)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function l(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},v=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function m(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,v,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function A(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,h)),e.classes}function _(t,e){var n,i=o(t);return i.attributes[e]||(i.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),l)),i.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,s=r.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(i=n.observer)||i.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var h,l,f;null==(h=s.attributes)||null==(l=h[e])||null==(f=l.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,i)}}function E(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function C(){r.forEach(E)}function O(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function $(){s.forEach(O)}function R(t){return\"undefined\"==typeof document?i:(s.add(t),O(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function B(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function T(t,e,r){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=r(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:r,selector:t}):i}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){$()}))),$(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function M(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 U(t,e,n){return 2===n?M(M(t+e)+\"\")%1e4/1e4:1===n?M(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function I(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function D(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=J(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 J(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=I(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 j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function K(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const i=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(r)},i,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function H(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function P(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const z={};function G(t,e){if(\"$or\"in e)return tt(t,e.$or);if(\"$nor\"in e)return!tt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!G(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!G(t,e.$not);for(const[n,i]of Object.entries(e))if(!Q(i,Z(t,n)))return!1;return!0}function Z(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 Q(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)||!W(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!Y(n,e,t[n]))return!1;return!0}function W(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function X(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function Y(t,e,n){switch(t){case\"$veq\":return H(e)===H(n);case\"$vne\":return H(e)!==H(n);case\"$vgt\":return H(e)>H(n);case\"$vgte\":return H(e)>=H(n);case\"$vlt\":return H(e)<H(n);case\"$vlte\":return H(e)<=H(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)&&X(e,n);case\"$nin\":return!!Array.isArray(n)&&!X(e,n);case\"$not\":return!Q(n,e);case\"$size\":return!!Array.isArray(e)&&Q(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=W(e)?t=>Q(e,t):t=>G(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(Q(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,z[i]||(z[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),z[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 tt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(G(t,e[n]))return!0;return!1}const et=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,nt=function(){let t;try{t=\"1.0.0\"}catch(e){t=\"\"}return t}(),it={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},rt=N,st={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return rt.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 rt.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new rt.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new rt.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),ht.forEach((t=>{t&&\"idle\"===t.state&&At(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(dt,it.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(rt.localStorage=globalThis.localStorage)}catch(t){}const ot=new Map;let ut=!1;const ct=new Map,at=new Map,ht=new Map,lt=new Set;function ft(t){const e=yt(t),n=ot.get(e)||new Set;n.add(t),ot.set(e,n)}function dt(){ht.forEach((t=>{t&&(t.state=\"idle\",St(t))}))}async function wt(){try{if(!rt.localStorage)return;await rt.localStorage.setItem(it.cacheKey,JSON.stringify(Array.from(ct.entries())))}catch(t){}}function yt(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function pt(t){const e=yt(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 vt(){const t=Array.from(ct.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,ct.size-it.maxEntries),ct.size);for(let n=0;n<e;n++)ct.delete(t[n].key)}function mt(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+it.staleTTL),s=ct.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void wt();ct.set(e,{data:n,version:i,staleAt:r,sse:lt.has(t)}),vt(),wt();const o=ot.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function gt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=yt(t),o=pt(t);let u=at.get(o);return u||(u=(r?st.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):st.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=>(mt(s,o,e),bt(t),at.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(at.delete(o),{data:null,source:\"error\",success:!1,error:t}))),at.set(o,u)),u}function bt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=yt(t),i=pt(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&<.add(n),it.backgroundSync&<.has(n)&&rt.EventSource){if(ht.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=ot.get(n);t&&t.forEach((t=>{gt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);mt(n,i,t)}t.errors=0}catch(e){kt(t)}},errors:0,state:\"active\"};ht.set(n,t),At(t)}}function kt(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());St(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||At(t)}),Math.min(e,3e5))}}function St(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function At(t){t.src=st.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=()=>kt(t),t.src.onopen=()=>{t.errors=0}}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=nt,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),et&&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\");bt(this,!0),ft(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\");bt(this,!0),ft(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&ft(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()&&ft(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||(it.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=yt(e),o=pt(e),u=new Date,c=new Date(u.getTime()-it.maxAge+it.staleTTL);await async function(){if(!ut){ut=!0;try{if(rt.localStorage){const t=await rt.localStorage.getItem(it.cacheKey);if(!it.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;ct.set(e,{...n,staleAt:new Date(n.staleAt)})})),vt()}}}catch(t){}{const t=st.startIdleListener();t&&(st.stopIdleListener=t)}}}();const a=it.disableCache||r?void 0:ct.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&<.add(s),a.staleAt<u?gt(e):bt(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()))}))}(gt(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 K(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 K(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 K(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await K(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,ot.forEach((e=>e.delete(t))),et&&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=P(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(D(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(et)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\"===P(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){}et&&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(!G({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,r,s){if(!i&&void 0===r)return!0;if(!i&&0===r)return!1;const{hashValue:o}=this.it(e,n);if(!o)return!1;const u=U(t,o,s||1);return null!==u&&(i?V(u,i):void 0===r||u<=r)}tt(t){return G(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=U(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>V(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&&!D(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const r=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!==r)return this.L(t,r,!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:s,hashValue:o}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!o)return this.L(t,-1,!1,e);let u=-1,c=!1,a=!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});c=e>=0,u=e,a=!!n}if(!c){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=U(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(o,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(!G({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 h=U(t.seed||n,o,t.hashVersion||1);if(null===h)return this.L(t,-1,!1,e);if(c||(u=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(h,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))),a)return this.L(t,-1,!1,e,void 0,!0);if(u<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 l=this.L(t,u,!0,e,h,c);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(s,L(o),{[this.ht(t.key,t.bucketVersion)]:l.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,l),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),l}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=I(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||(et?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=P(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:et?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&et)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(!et)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,r=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return B(e,(function(t){return t+(null!=r?r:\"\")}));if(\"set\"===n)return B(e,(function(){return null!=r?r:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){r&&t.add(r)}));if(\"remove\"===n)return F(e,(function(t){r&&t.delete(r)}));if(\"set\"===n)return F(e,(function(t){t.clear(),r&&t.add(r)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return T(e,s,(function(t){return null!==t?t+(null!=r?r:\"\"):null!=r?r:\"\"}));if(\"set\"===n)return T(e,s,(function(){return null!=r?r:\"\"}));if(\"remove\"===n)return T(e,s,(function(){return null}))}return i}(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\"}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)&>(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,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:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,i={revert:function(){}},r=new Map,s=new Set;function o(t){var e=r.get(t);return e||r.set(t,e={element:t,attributes:{}}),e}function u(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 c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.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)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function l(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},v=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function m(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,v,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function A(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,h)),e.classes}function _(t,e){var n,i=o(t);return i.attributes[e]||(i.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),l)),i.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,s=r.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(i=n.observer)||i.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var h,l,f;null==(h=s.attributes)||null==(l=h[e])||null==(f=l.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,i)}}function E(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function C(){r.forEach(E)}function O(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function $(){s.forEach(O)}function R(t){return\"undefined\"==typeof document?i:(s.add(t),O(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function B(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function T(t,e,r){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=r(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:r,selector:t}):i}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){$()}))),$(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function M(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 U(t,e,n){return 2===n?M(M(t+e)+\"\")%1e4/1e4:1===n?M(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function I(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function D(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=J(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 J(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=I(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 j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function K(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const i=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(r)},i,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function H(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function P(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const z={};function G(t,e){if(\"$or\"in e)return tt(t,e.$or);if(\"$nor\"in e)return!tt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!G(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!G(t,e.$not);for(const[n,i]of Object.entries(e))if(!Q(i,Z(t,n)))return!1;return!0}function Z(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 Q(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)||!W(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!Y(n,e,t[n]))return!1;return!0}function W(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function X(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function Y(t,e,n){switch(t){case\"$veq\":return H(e)===H(n);case\"$vne\":return H(e)!==H(n);case\"$vgt\":return H(e)>H(n);case\"$vgte\":return H(e)>=H(n);case\"$vlt\":return H(e)<H(n);case\"$vlte\":return H(e)<=H(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)&&X(e,n);case\"$nin\":return!!Array.isArray(n)&&!X(e,n);case\"$not\":return!Q(n,e);case\"$size\":return!!Array.isArray(e)&&Q(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=W(e)?t=>Q(e,t):t=>G(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(Q(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,z[i]||(z[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),z[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 tt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(G(t,e[n]))return!0;return!1}const et=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,nt=function(){let t;try{t=\"1.0.0\"}catch(e){t=\"\"}return t}(),it={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},rt=N,st={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return rt.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 rt.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new rt.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new rt.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),ht.forEach((t=>{t&&\"idle\"===t.state&&At(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(dt,it.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(rt.localStorage=globalThis.localStorage)}catch(t){}const ot=new Map;let ut=!1;const ct=new Map,at=new Map,ht=new Map,lt=new Set;function ft(t){const e=yt(t),n=ot.get(e)||new Set;n.add(t),ot.set(e,n)}function dt(){ht.forEach((t=>{t&&(t.state=\"idle\",St(t))}))}async function wt(){try{if(!rt.localStorage)return;await rt.localStorage.setItem(it.cacheKey,JSON.stringify(Array.from(ct.entries())))}catch(t){}}function yt(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function pt(t){const e=yt(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 vt(){const t=Array.from(ct.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,ct.size-it.maxEntries),ct.size);for(let n=0;n<e;n++)ct.delete(t[n].key)}function mt(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+it.staleTTL),s=ct.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void wt();ct.set(e,{data:n,version:i,staleAt:r,sse:lt.has(t)}),vt(),wt();const o=ot.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function gt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=yt(t),o=pt(t);let u=at.get(o);return u||(u=(r?st.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):st.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=>(mt(s,o,e),bt(t),at.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(at.delete(o),{data:null,source:\"error\",success:!1,error:t}))),at.set(o,u)),u}function bt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=yt(t),i=pt(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&<.add(n),it.backgroundSync&<.has(n)&&rt.EventSource){if(ht.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=ot.get(n);t&&t.forEach((t=>{gt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);mt(n,i,t)}t.errors=0}catch(e){kt(t)}},errors:0,state:\"active\"};ht.set(n,t),At(t)}}function kt(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());St(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||At(t)}),Math.min(e,3e5))}}function St(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function At(t){t.src=st.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=()=>kt(t),t.src.onopen=()=>{t.errors=0}}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=nt,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),et&&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\");bt(this,!0),ft(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\");bt(this,!0),ft(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&ft(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()&&ft(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||(it.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=yt(e),o=pt(e),u=new Date,c=new Date(u.getTime()-it.maxAge+it.staleTTL);await async function(){if(!ut){ut=!0;try{if(rt.localStorage){const t=await rt.localStorage.getItem(it.cacheKey);if(!it.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;ct.set(e,{...n,staleAt:new Date(n.staleAt)})})),vt()}}}catch(t){}{const t=st.startIdleListener();t&&(st.stopIdleListener=t)}}}();const a=it.disableCache||r?void 0:ct.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&<.add(s),a.staleAt<u?gt(e):bt(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()))}))}(gt(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 K(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 K(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 K(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await K(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,ot.forEach((e=>e.delete(t))),et&&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=P(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(D(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(et)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\"===P(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){}et&&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(!G({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,r,s){if(!i&&void 0===r)return!0;if(!i&&0===r)return!1;const{hashValue:o}=this.it(e,n);if(!o)return!1;const u=U(t,o,s||1);return null!==u&&(i?V(u,i):void 0===r||u<=r)}tt(t){return G(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=U(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>V(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&&!D(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const r=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!==r)return this.L(t,r,!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:s,hashValue:o}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!o)return this.L(t,-1,!1,e);let u=-1,c=!1,a=!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});c=e>=0,u=e,a=!!n}if(!c){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=U(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(o,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(!G({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 h=U(t.seed||n,o,t.hashVersion||1);if(null===h)return this.L(t,-1,!1,e);if(c||(u=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(h,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))),a)return this.L(t,-1,!1,e,void 0,!0);if(u<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 l=this.L(t,u,!0,e,h,c);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(s,L(o),{[this.ht(t.key,t.bucketVersion)]:l.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,l),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),l}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=I(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||(et?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=P(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:et?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&et)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(!et)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,r=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return B(e,(function(t){return t+(null!=r?r:\"\")}));if(\"set\"===n)return B(e,(function(){return null!=r?r:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){r&&t.add(r)}));if(\"remove\"===n)return F(e,(function(t){r&&t.delete(r)}));if(\"set\"===n)return F(e,(function(t){t.clear(),r&&t.add(r)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return T(e,s,(function(t){return null!==t?t+(null!=r?r:\"\"):null!=r?r:\"\"}));if(\"set\"===n)return T(e,s,(function(){return null!=r?r:\"\"}));if(\"remove\"===n)return T(e,s,(function(){return null}))}return i}(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\"}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)&>(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";
|
|
5
5
|
//# sourceMappingURL=sdkWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkWrapper.js","sourceRoot":"","sources":["../../src/generated/sdkWrapper.ts"],"names":[],"mappings":";;;AACa,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"sdkWrapper.js","sourceRoot":"","sources":["../../src/generated/sdkWrapper.ts"],"names":[],"mappings":";;;AACa,QAAA,UAAU,GAAG,+h0CAA+h0C,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface Config {
|
|
|
25
25
|
crypto?: any;
|
|
26
26
|
localStorage?: LocalStorageCompat;
|
|
27
27
|
staleTTL?: number;
|
|
28
|
+
fetchFeaturesCall?: ({ host, clientKey, headers }: {
|
|
29
|
+
host: string;
|
|
30
|
+
clientKey: string;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
}) => Promise<any>;
|
|
28
33
|
apiHost: string;
|
|
29
34
|
clientKey: string;
|
|
30
35
|
decryptionKey?: string;
|
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
|
+
"version": "0.1.4",
|
|
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.
|
|
22
|
+
"@growthbook/growthbook": "^1.0.1",
|
|
23
23
|
"node-html-parser": "^6.1.13"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
package/src/app.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AutoExperimentVariation, configureCache,
|
|
3
3
|
GrowthBook,
|
|
4
|
+
helpers,
|
|
4
5
|
setPolyfills,
|
|
5
6
|
StickyBucketService
|
|
6
7
|
} from "@growthbook/growthbook";
|
|
@@ -64,13 +65,14 @@ export async function edgeApp<Req, Res>(
|
|
|
64
65
|
const setPreRedirectChangeIds = (changeIds: string[]) =>
|
|
65
66
|
(preRedirectChangeIds = changeIds);
|
|
66
67
|
|
|
67
|
-
context.config.localStorage
|
|
68
|
+
if (context.config.localStorage)
|
|
68
69
|
setPolyfills({ localStorage: context.config.localStorage });
|
|
69
|
-
context.config.crypto
|
|
70
|
+
if (context.config.crypto)
|
|
70
71
|
setPolyfills({ SubtleCrypto: context.config.crypto });
|
|
71
|
-
if (context.config.staleTTL !== undefined)
|
|
72
|
+
if (context.config.staleTTL !== undefined)
|
|
72
73
|
configureCache({ staleTTL: context.config.staleTTL });
|
|
73
|
-
|
|
74
|
+
if (context.config.fetchFeaturesCall)
|
|
75
|
+
helpers.fetchFeaturesCall = context.config.fetchFeaturesCall;
|
|
74
76
|
|
|
75
77
|
let stickyBucketService:
|
|
76
78
|
| EdgeStickyBucketService<Req, Res>
|
|
@@ -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:\"/\"}),n=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,i={revert:function(){}},r=new Map,s=new Set;function o(t){var e=r.get(t);return e||r.set(t,e={element:t,attributes:{}}),e}function u(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 c(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&\"string\"!=typeof t?n&&t.parentNode===n.parentNode&&t.insertBeforeNode===n.insertBeforeNode||(e.isDirty=!0,C()):t!==n&&(e.isDirty=!0,C())}function a(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(function(t){return g||(g=document.createElement(\"div\")),g.innerHTML=t,g.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)})),c(Array.from(e).filter(Boolean).join(\" \"),t)}function l(t){var e=t.originalValue;t.mutations.forEach((function(t){return e=t.mutate(e)})),c(e,t)}function f(t){var e=t.originalValue;t.mutations.forEach((function(t){var n=function(t){var e=t.insertBeforeSelector,n=document.querySelector(t.parentSelector);if(!n)return null;var i=e?document.querySelector(e):null;return e&&!i?null:{parentNode:n,insertBeforeNode:i}}(t.mutate());e=n||e})),c(e,t)}var d=function(t){return t.innerHTML},w=function(t,e){return t.innerHTML=e};function y(t){var e=o(t);return e.html||(e.html=u(t,\"html\",d,w,a)),e.html}var p=function(t){return{parentNode:t.parentElement,insertBeforeNode:t.nextElementSibling}},v=function(t,e){e.insertBeforeNode&&!e.parentNode.contains(e.insertBeforeNode)||e.parentNode.insertBefore(t,e.insertBeforeNode)};function m(t){var e=o(t);return e.position||(e.position=u(t,\"position\",p,v,f)),e.position}var g,b,k=function(t,e){return e?t.className=e:t.removeAttribute(\"class\")},S=function(t){return t.className};function A(t){var e=o(t);return e.classes||(e.classes=u(t,\"class\",S,k,h)),e.classes}function _(t,e){var n,i=o(t);return i.attributes[e]||(i.attributes[e]=u(t,e,(n=e,function(t){var e;return null!=(e=t.getAttribute(n))?e:null}),function(t){return function(e,n){return null!==n?e.setAttribute(t,n):e.removeAttribute(t)}}(e),l)),i.attributes[e]}function x(t,e,n){if(n.isDirty){n.isDirty=!1;var i=n.virtualValue;n.mutations.length||function(t,e){var n,i,s=r.get(t);if(s)if(\"html\"===e)null==(n=s.html)||null==(i=n.observer)||i.disconnect(),delete s.html;else if(\"class\"===e){var o,u;null==(o=s.classes)||null==(u=o.observer)||u.disconnect(),delete s.classes}else if(\"position\"===e){var c,a;null==(c=s.position)||null==(a=c.observer)||a.disconnect(),delete s.position}else{var h,l,f;null==(h=s.attributes)||null==(l=h[e])||null==(f=l.observer)||f.disconnect(),delete s.attributes[e]}}(t,e),n.setValue(t,i)}}function E(t,e){t.html&&x(e,\"html\",t.html),t.classes&&x(e,\"class\",t.classes),t.position&&x(e,\"position\",t.position),Object.keys(t.attributes).forEach((function(n){x(e,n,t.attributes[n])}))}function C(){r.forEach(E)}function O(t){if(\"position\"!==t.kind||1!==t.elements.size){var e=new Set(t.elements);document.querySelectorAll(t.selector).forEach((function(n){e.has(n)||(t.elements.add(n),function(t,e){var n=null;\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}(t,n))}))}}function $(){s.forEach(O)}function R(t){return\"undefined\"==typeof document?i:(s.add(t),O(t),{revert:function(){var e;(e=t).elements.forEach((function(t){return function(t,e){var n=null;if(\"html\"===t.kind?n=y(e):\"class\"===t.kind?n=A(e):\"attribute\"===t.kind?n=_(e,t.attribute):\"position\"===t.kind&&(n=m(e)),n){var i=n.mutations.indexOf(t);-1!==i&&n.mutations.splice(i,1),n.mutationRunner(n)}}(e,t)})),e.elements.clear(),s.delete(e)}})}function B(t,e){return R({kind:\"html\",elements:new Set,mutate:e,selector:t})}function F(t,e){return R({kind:\"class\",elements:new Set,mutate:e,selector:t})}function T(t,e,r){return n.test(e)?\"class\"===e||\"className\"===e?F(t,(function(t){var e=r(Array.from(t).join(\" \"));t.clear(),e&&e.split(/\\s+/g).filter(Boolean).forEach((function(e){return t.add(e)}))})):R({kind:\"attribute\",attribute:e,elements:new Set,mutate:r,selector:t}):i}\"undefined\"!=typeof document&&(b||(b=new MutationObserver((function(){$()}))),$(),b.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}));const N={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function M(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 U(t,e,n){return 2===n?M(M(t+e)+\"\")%1e4/1e4:1===n?M(e+t)%1e3/1e3:null}function V(t,e){return t>=e[0]&&t<e[1]}function I(t){try{const e=t.replace(/([^\\\\])\\//g,\"$1\\\\/\");return new RegExp(e)}catch(t){return void console.error(t)}}function D(t,e){if(!e.length)return!1;let n=!1,i=!1;for(let r=0;r<e.length;r++){const s=J(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 J(t,e,n){try{const i=new URL(t,\"https://_\");if(\"regex\"===e){const t=I(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 j=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function K(t,e,n){if(e=e||\"\",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||N.SubtleCrypto))throw new Error(\"No SubtleCrypto implementation found\");try{const i=await n.importKey(\"raw\",j(e),{name:\"AES-CBC\",length:128},!0,[\"encrypt\",\"decrypt\"]),[r,s]=t.split(\".\"),o=await n.decrypt({name:\"AES-CBC\",iv:j(r)},i,j(s));return(new TextDecoder).decode(o)}catch(t){throw new Error(\"Failed to decrypt\")}}function L(t){return\"string\"==typeof t?t:JSON.stringify(t)}function H(t){\"number\"==typeof t&&(t+=\"\"),t&&\"string\"==typeof t||(t=\"0\");const e=t.replace(/(^v|\\+.*$)/g,\"\").split(/[-.]/);return 3===e.length&&e.push(\"~\"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5,\" \"):t)).join(\"-\")}function q(t){return\"object\"==typeof t&&null!==t}function P(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&\"urlRedirect\"in t))?\"redirect\":t.variations.some((t=>q(t)&&(t.domMutations||\"js\"in t||\"css\"in t)))?\"visual\":\"unknown\"}const z={};function G(t,e){if(\"$or\"in e)return tt(t,e.$or);if(\"$nor\"in e)return!tt(t,e.$nor);if(\"$and\"in e)return function(t,e){for(let n=0;n<e.length;n++)if(!G(t,e[n]))return!1;return!0}(t,e.$and);if(\"$not\"in e)return!G(t,e.$not);for(const[n,i]of Object.entries(e))if(!Q(i,Z(t,n)))return!1;return!0}function Z(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 Q(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)||!W(t))return JSON.stringify(e)===JSON.stringify(t);for(const n in t)if(!Y(n,e,t[n]))return!1;return!0}function W(t){const e=Object.keys(t);return e.length>0&&e.filter((t=>\"$\"===t[0])).length===e.length}function X(t,e){return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function Y(t,e,n){switch(t){case\"$veq\":return H(e)===H(n);case\"$vne\":return H(e)!==H(n);case\"$vgt\":return H(e)>H(n);case\"$vgte\":return H(e)>=H(n);case\"$vlt\":return H(e)<H(n);case\"$vlte\":return H(e)<=H(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)&&X(e,n);case\"$nin\":return!!Array.isArray(n)&&!X(e,n);case\"$not\":return!Q(n,e);case\"$size\":return!!Array.isArray(e)&&Q(n,e.length);case\"$elemMatch\":return function(t,e){if(!Array.isArray(t))return!1;const n=W(e)?t=>Q(e,t):t=>G(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(Q(n[t],e[r])){i=!0;break}if(!i)return!1}return!0;case\"$regex\":try{return(i=n,z[i]||(z[i]=new RegExp(i.replace(/([^\\\\])\\//g,\"$1\\\\/\"))),z[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 tt(t,e){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(G(t,e[n]))return!0;return!1}const et=\"undefined\"!=typeof window&&\"undefined\"!=typeof document,nt=function(){let t;try{t=\"1.0.0\"}catch(e){t=\"\"}return t}(),it={staleTTL:6e4,maxAge:864e5,cacheKey:\"gbFeaturesCache\",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},rt=N,st={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:i}=t;return rt.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 rt.fetch(\"\".concat(e,\"/api/eval/\").concat(n),s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:i}=t;return i?new rt.EventSource(\"\".concat(e,\"/sub/\").concat(n),{headers:i}):new rt.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),ht.forEach((t=>{t&&\"idle\"===t.state&&At(t)}))):\"hidden\"===document.visibilityState&&(t=window.setTimeout(dt,it.idleStreamInterval))};return document.addEventListener(\"visibilitychange\",e),()=>document.removeEventListener(\"visibilitychange\",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(rt.localStorage=globalThis.localStorage)}catch(t){}const ot=new Map;let ut=!1;const ct=new Map,at=new Map,ht=new Map,lt=new Set;function ft(t){const e=yt(t),n=ot.get(e)||new Set;n.add(t),ot.set(e,n)}function dt(){ht.forEach((t=>{t&&(t.state=\"idle\",St(t))}))}async function wt(){try{if(!rt.localStorage)return;await rt.localStorage.setItem(it.cacheKey,JSON.stringify(Array.from(ct.entries())))}catch(t){}}function yt(t){const[e,n]=t.getApiInfo();return\"\".concat(e,\"||\").concat(n)}function pt(t){const e=yt(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 vt(){const t=Array.from(ct.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,ct.size-it.maxEntries),ct.size);for(let n=0;n<e;n++)ct.delete(t[n].key)}function mt(t,e,n){const i=n.dateUpdated||\"\",r=new Date(Date.now()+it.staleTTL),s=ct.get(e);if(s&&i&&s.version===i)return s.staleAt=r,void wt();ct.set(e,{data:n,version:i,staleAt:r,sse:lt.has(t)}),vt(),wt();const o=ot.get(t);o&&o.forEach((t=>async function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function gt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),i=t.getClientKey(),r=t.isRemoteEval(),s=yt(t),o=pt(t);let u=at.get(o);return u||(u=(r?st.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):st.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=>(mt(s,o,e),bt(t),at.delete(o),{data:e,success:!0,source:\"network\"}))).catch((t=>(at.delete(o),{data:null,source:\"error\",success:!1,error:t}))),at.set(o,u)),u}function bt(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=yt(t),i=pt(t),{streamingHost:r,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&<.add(n),it.backgroundSync&<.has(n)&&rt.EventSource){if(ht.has(n))return;const t={src:null,host:r,clientKey:o,headers:s,cb:e=>{try{if(\"features-updated\"===e.type){const t=ot.get(n);t&&t.forEach((t=>{gt(t)}))}else if(\"features\"===e.type){const t=JSON.parse(e.data);mt(n,i,t)}t.errors=0}catch(e){kt(t)}},errors:0,state:\"active\"};ht.set(n,t),At(t)}}function kt(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());St(t),setTimeout((()=>{[\"idle\",\"active\"].includes(t.state)||At(t)}),Math.min(e,3e5))}}function St(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,\"active\"===t.state&&(t.state=\"disabled\"))}function At(t){t.src=st.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=()=>kt(t),t.src.onopen=()=>{t.errors=0}}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=nt,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),et&&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\");bt(this,!0),ft(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\");bt(this,!0),ft(this)}return{success:!0,source:\"init\"}}{const{data:e,...n}=await this.U({...t,allowStale:!0});return t.streaming&&ft(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()&&ft(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||(it.backgroundSync=!1),async function(t){let{instance:e,allowStale:n,timeout:i,skipCache:r}=t;const s=yt(e),o=pt(e),u=new Date,c=new Date(u.getTime()-it.maxAge+it.staleTTL);await async function(){if(!ut){ut=!0;try{if(rt.localStorage){const t=await rt.localStorage.getItem(it.cacheKey);if(!it.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((t=>{let[e,n]=t;ct.set(e,{...n,staleAt:new Date(n.staleAt)})})),vt()}}}catch(t){}{const t=st.startIdleListener();t&&(st.stopIdleListener=t)}}}();const a=it.disableCache||r?void 0:ct.get(o);if(a&&(n||a.staleAt>u)&&a.staleAt>c)return a.sse&<.add(s),a.staleAt<u?gt(e):bt(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()))}))}(gt(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 K(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 K(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 K(t.encryptedFeatures,e||this.i.decryptionKey,n)),delete t.encryptedFeatures),t.encryptedExperiments&&(t.experiments=JSON.parse(await K(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,ot.forEach((e=>e.delete(t))),et&&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=P(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(D(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(et)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\"===P(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){}et&&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(!G({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,r,s){if(!i&&void 0===r)return!0;if(!i&&0===r)return!1;const{hashValue:o}=this.it(e,n);if(!o)return!1;const u=U(t,o,s||1);return null!==u&&(i?V(u,i):void 0===r||u<=r)}tt(t){return G(this.getAttributes(),t)}Y(t){return t.some((t=>{const{hashValue:e}=this.it(t.attribute);if(!e)return!0;const n=U(t.seed,e,t.hashVersion||2);return null===n||!t.ranges.some((t=>V(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&&!D(this.q(),t.urlPatterns))return this.L(t,-1,!1,e);const r=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!==r)return this.L(t,r,!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:s,hashValue:o}=this.it(t.hashAttribute,this.i.stickyBucketService&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!o)return this.L(t,-1,!1,e);let u=-1,c=!1,a=!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});c=e>=0,u=e,a=!!n}if(!c){if(t.filters){if(this.Y(t.filters))return this.L(t,-1,!1,e)}else if(t.namespace&&!function(t,e){const n=U(\"__\"+e[0],t,1);return null!==n&&n>=e[1]&&n<e[2]}(o,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(!G({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 h=U(t.seed||n,o,t.hashVersion||1);if(null===h)return this.L(t,-1,!1,e);if(c||(u=function(t,e){for(let n=0;n<e.length;n++)if(V(t,e[n]))return n;return-1}(h,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))),a)return this.L(t,-1,!1,e,void 0,!0);if(u<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 l=this.L(t,u,!0,e,h,c);if(this.i.stickyBucketService&&!t.disableStickyBucketing){const{changed:e,key:n,doc:i}=this.ct(s,L(o),{[this.ht(t.key,t.bucketVersion)]:l.key});e&&(this.i.stickyBucketAssignmentDocs=this.i.stickyBucketAssignmentDocs||{},this.i.stickyBucketAssignmentDocs[n]=i,this.i.stickyBucketService.saveAssignments(i))}return this.nt(t,l),\"changeId\"in t&&t.changeId&&this.h.add(t.changeId),l}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=I(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||(et?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=P(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:et?t=>{window.location.replace(t)}:null}F(){if(this.i.antiFlicker&&et)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(!et)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,r=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if(\"html\"===s){if(\"append\"===n)return B(e,(function(t){return t+(null!=r?r:\"\")}));if(\"set\"===n)return B(e,(function(){return null!=r?r:\"\"}))}else if(\"class\"===s){if(\"append\"===n)return F(e,(function(t){r&&t.add(r)}));if(\"remove\"===n)return F(e,(function(t){r&&t.delete(r)}));if(\"set\"===n)return F(e,(function(t){t.clear(),r&&t.add(r)}))}else if(\"position\"===s){if(\"set\"===n&&o)return function(t,e){return R({kind:\"position\",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if(\"append\"===n)return T(e,s,(function(t){return null!==t?t+(null!=r?r:\"\"):null!=r?r:\"\"}));if(\"set\"===n)return T(e,s,(function(){return null!=r?r:\"\"}));if(\"remove\"===n)return T(e,s,(function(){return null}))}return i}(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\"}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)&>(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";
|
package/src/types.ts
CHANGED
|
@@ -41,6 +41,11 @@ export interface Config {
|
|
|
41
41
|
crypto?: any;
|
|
42
42
|
localStorage?: LocalStorageCompat;
|
|
43
43
|
staleTTL?: number;
|
|
44
|
+
fetchFeaturesCall?: ({host, clientKey, headers}: {
|
|
45
|
+
host: string;
|
|
46
|
+
clientKey: string;
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
}) => Promise<any>;
|
|
44
49
|
|
|
45
50
|
// growthbook
|
|
46
51
|
apiHost: string;
|