@uniformdev/context 14.2.1-alpha.34 → 16.0.1-alpha.164
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/LICENSE.txt +2 -2
- package/dist/api/api.d.ts +7 -5
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +2 -1
- package/dist/cli/cli.d.ts +2 -2
- package/dist/cli/cli.js +51 -51
- package/dist/cli/cli.mjs +53 -52
- package/dist/{contextTypes-7f24fc7c.d.ts → contextTypes-572b0d33.d.ts} +1 -1
- package/dist/index.d.ts +58 -24
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{types-6c6360c2.d.ts → types-c12d92cd.d.ts} +153 -87
- package/dist/{v2-manifest.swagger-d0899723.d.ts → v2-manifest.swagger-ff2af13e.d.ts} +9 -0
- package/package.json +10 -5
- package/dist/chunk-2QBWX3VO.mjs +0 -2
- package/dist/chunk-ORM4ZDHU.mjs +0 -1
- package/dist/chunk-PZGIHZYO.mjs +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,26 +1,47 @@
|
|
1
|
-
import {
|
2
|
-
export { A as AggregateDimension, l as AggregateDimensionInput,
|
3
|
-
import '
|
1
|
+
import { T as TransitionDataStore, S as StorageCommands, V as VisitorData, a as TransitionDataStoreOptions, D as DecayFunction, O as OutputSeverity, L as LogDrain, C as ContextPlugin, b as CriteriaEvaluator, c as StringMatch, d as ScoreVector, A as AggregateDimension, e as VariantMatchCriteria, f as LogMessage } from './types-c12d92cd.js';
|
2
|
+
export { A as AggregateDimension, l as AggregateDimensionInput, ac as BehaviorTag, a0 as Context, $ as ContextEvents, Y as ContextOptions, C as ContextPlugin, t as ContextState, u as ContextStateUpdate, b as CriteriaEvaluator, n as CriteriaEvaluatorParameters, m as CriteriaEvaluatorResult, D as DecayFunction, H as DecayOptions, aj as DevToolsActions, an as DevToolsDataEvent, ak as DevToolsEvent, al as DevToolsEvents, ar as DevToolsForgetEvent, ao as DevToolsHelloEvent, am as DevToolsLogEvent, aq as DevToolsRawCommandsEvent, ai as DevToolsState, ah as DevToolsUiVersion, ap as DevToolsUpdateEvent, ab as DimensionMatch, E as EnrichmentCategory, q as EnrichmentData, r as EventData, G as GroupCriteriaEvaluator, I as IdentifyCommand, L as LogDrain, f as LogMessage, a6 as LogMessageGroup, a5 as LogMessageSingle, a1 as LogMessages, M as ManifestInstance, g as ManifestV2, a3 as MessageCategory, a4 as MessageFunc, w as ModifyScoreCommand, x as ModifySessionScoreCommand, N as NumberMatch, O as OutputSeverity, Z as PersonalizationEvent, P as PersonalizationManifest, a9 as PersonalizeOptions, ae as PersonalizedResult, ad as PersonalizedVariant, Q as Quirks, W as SERVER_STATE_ID, d as ScoreVector, U as ServerToClientTransitionState, y as SetConsentCommand, F as SetControlGroupCommand, z as SetQuirkCommand, B as SetTestCommand, a2 as Severity, h as Signal, j as SignalCriteria, i as SignalCriteriaGroup, o as SignalData, v as StorageCommand, S as StorageCommands, c as StringMatch, k as TestDefinition, _ as TestEvent, a8 as TestOptions, ag as TestResult, af as TestVariant, p as Tests, T as TransitionDataStore, X as TransitionDataStoreEvents, a as TransitionDataStoreOptions, e as VariantMatchCriteria, V as VisitorData, R as VisitorDataStore, K as VisitorDataStoreEvents, J as VisitorDataStoreOptions, s as emptyVisitorData, aa as personalizeVariations, a7 as testVariations } from './types-c12d92cd.js';
|
3
|
+
import Cookies from 'js-cookie';
|
4
|
+
import './v2-manifest.swagger-ff2af13e.js';
|
4
5
|
import 'mitt';
|
5
6
|
|
6
7
|
declare type CookieTransitionDataStoreOptions = {
|
7
|
-
|
8
|
+
/**
|
9
|
+
* The value of the score cookie during server-side rendering.
|
10
|
+
* Should be parsed from the incoming request.
|
11
|
+
* IMPORTANT: If not passed, the transition store will not have any effect during SSR.
|
12
|
+
*/
|
13
|
+
serverCookieValue?: string;
|
14
|
+
/**
|
15
|
+
* The name of the cookie to store client-to-server score information in.
|
16
|
+
* Defaults to UNIFORM_DEFAULT_COOKIE_NAME if not set.
|
17
|
+
*/
|
8
18
|
cookieName?: string;
|
19
|
+
/**
|
20
|
+
* Attributes to set on the transfer cookie.
|
21
|
+
* Persistence is not necessary, because the data is only used for temporary transition;
|
22
|
+
* local storage is the master copy. Defaults to SameSite=Lax.
|
23
|
+
*/
|
24
|
+
cookieAttributes?: Cookies.CookieAttributes;
|
9
25
|
};
|
26
|
+
declare const UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
27
|
+
/**
|
28
|
+
* Handles client-to-server score handoff using an encoded cookie with the visitor score vector.
|
29
|
+
* NOTE: forget me is not supported when on the server side.
|
30
|
+
*/
|
10
31
|
declare class CookieTransitionDataStore extends TransitionDataStore {
|
11
32
|
#private;
|
12
|
-
constructor({
|
33
|
+
constructor({ serverCookieValue, cookieName, cookieAttributes, }: CookieTransitionDataStoreOptions);
|
13
34
|
handleDelete(): Promise<void>;
|
14
35
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
15
36
|
}
|
16
37
|
|
17
38
|
declare type EdgeTransitionDataStoreOptions = TransitionDataStoreOptions & {
|
18
|
-
|
39
|
+
serverCookieValue?: string;
|
19
40
|
visitorIdCookieName?: string;
|
20
41
|
};
|
21
42
|
declare class EdgeTransitionDataStore extends TransitionDataStore {
|
22
43
|
#private;
|
23
|
-
constructor({
|
44
|
+
constructor({ serverCookieValue, visitorIdCookieName, ...base }: EdgeTransitionDataStoreOptions);
|
24
45
|
handleDelete(fromAllDevices?: boolean): Promise<void>;
|
25
46
|
handleUpdateData(commands: StorageCommands[]): Promise<void>;
|
26
47
|
}
|
@@ -65,19 +86,6 @@ declare function createConsoleLogDrain(level: OutputSeverity): LogDrain;
|
|
65
86
|
*/
|
66
87
|
declare function enableConsoleLogDrain(level: OutputSeverity): ContextPlugin;
|
67
88
|
|
68
|
-
/**
|
69
|
-
* Creates a new log drain that will log full debug messages to the console.
|
70
|
-
* The debug log drain adds significant bundle size, but is useful for debugging.
|
71
|
-
*
|
72
|
-
* NOTE: you probably want enableDebugConsoleLogDrain() instead of this function.
|
73
|
-
*/
|
74
|
-
declare function createDebugConsoleLogDrain(level: OutputSeverity): LogDrain;
|
75
|
-
/**
|
76
|
-
* Enables logging Context events to the browser console.
|
77
|
-
* Lightweight events with only the event ID are emitted.
|
78
|
-
*/
|
79
|
-
declare function enableDebugConsoleLogDrain(level: OutputSeverity): ContextPlugin;
|
80
|
-
|
81
89
|
declare const cookieEvaluator: CriteriaEvaluator;
|
82
90
|
|
83
91
|
declare const pageViewCountDimension: string;
|
@@ -89,17 +97,35 @@ declare const quirkEvaluator: CriteriaEvaluator;
|
|
89
97
|
|
90
98
|
declare const eventEvaluator: CriteriaEvaluator;
|
91
99
|
|
92
|
-
declare const
|
100
|
+
declare const currentPageEvaluator: CriteriaEvaluator;
|
93
101
|
|
94
102
|
/** Tests if a StringMatch matches a string value */
|
95
|
-
declare function isStringMatch(lhs: string | null | undefined, match: StringMatch): boolean;
|
103
|
+
declare function isStringMatch(lhs: string | number | null | undefined, match: StringMatch): boolean;
|
104
|
+
declare function explainStringMatch(lhs: string | number | null | undefined, match: StringMatch): string;
|
105
|
+
declare function explainStringMatchCriteria(match: StringMatch): string;
|
106
|
+
|
107
|
+
declare type ConsoleDebugLogDrainOptions = {
|
108
|
+
enableOnServer?: boolean;
|
109
|
+
};
|
110
|
+
/**
|
111
|
+
* Creates a new log drain that will log full debug messages to the console.
|
112
|
+
* The debug log drain adds significant bundle size, but is useful for debugging.
|
113
|
+
*
|
114
|
+
* NOTE: you probably want enableDebugConsoleLogDrain() instead of this function.
|
115
|
+
*/
|
116
|
+
declare function createDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): LogDrain;
|
117
|
+
/**
|
118
|
+
* Enables logging Context events to the browser console.
|
119
|
+
* Lightweight events with only the event ID are emitted.
|
120
|
+
*/
|
121
|
+
declare function enableDebugConsoleLogDrain(level: OutputSeverity, options?: ConsoleDebugLogDrainOptions): ContextPlugin;
|
96
122
|
|
97
123
|
/** Computes aggregated scores based on other dimensions */
|
98
124
|
declare function computeAggregateDimensions(primitiveScores: ScoreVector, aggregates: Record<string, AggregateDimension>): ScoreVector;
|
99
125
|
|
100
126
|
declare function getEnrichmentVectorKey(category: string, value: string): string;
|
101
127
|
|
102
|
-
declare function evaluateVariantMatch(match: VariantMatchCriteria | undefined | null, vec: ScoreVector): boolean;
|
128
|
+
declare function evaluateVariantMatch(variantId: string, match: VariantMatchCriteria | undefined | null, vec: ScoreVector, onLogMessage?: (message: LogMessage) => void): boolean;
|
103
129
|
|
104
130
|
declare enum ScriptType {
|
105
131
|
ListStart = "nesi-list-start",
|
@@ -126,4 +152,12 @@ declare const EdgeNodeTagName = "nesitag";
|
|
126
152
|
*/
|
127
153
|
declare function enableContextDevTools(): ContextPlugin;
|
128
154
|
|
129
|
-
|
155
|
+
declare type QuickConnectConfig = {
|
156
|
+
apiKey: string;
|
157
|
+
projectId: string;
|
158
|
+
apiHost?: string;
|
159
|
+
};
|
160
|
+
declare function serializeQuickConnect(config: QuickConnectConfig): string;
|
161
|
+
declare function parseQuickConnect(serialized: string): Required<QuickConnectConfig>;
|
162
|
+
|
163
|
+
export { ConsoleDebugLogDrainOptions, CookieTransitionDataStore, CookieTransitionDataStoreOptions, EdgeNodeTagName, EdgePersonalizeComponentOptions, EdgeTestComponentOptions, EdgeTransitionDataStore, EdgeTransitionDataStoreOptions, LinearDecayOptions, QuickConnectConfig, ScriptType, UNIFORM_DEFAULT_COOKIE_NAME, computeAggregateDimensions, cookieEvaluator, createConsoleLogDrain, createDebugConsoleLogDrain, createLinearDecay, currentPageEvaluator, enableConsoleLogDrain, enableContextDevTools, enableDebugConsoleLogDrain, evaluateVariantMatch, eventEvaluator, explainStringMatch, explainStringMatchCriteria, getEnrichmentVectorKey, isStringMatch, pageViewCountDimension, pageViewCountEvaluator, parseQuickConnect, queryStringEvaluator, quirkEvaluator, serializeQuickConnect };
|
package/dist/index.esm.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{a as B}from"./chunk-ORM4ZDHU.mjs";import{d as S,e as n,f as m,g,h as y,i as u}from"./chunk-PZGIHZYO.mjs";u();u();u();function ht(r,t){let e={...r};for(let o in t){let i=vt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function vt(r,t,e,o){var s;let i=0;for(let a of e[t].inputs){let c=(s=r[a.dim])!=null?s:0;if(!c&&e[a.dim]){if(o.has(a.dim))continue;let l=new Set(o);l.add(a.dim),c=vt(r,a.dim,e,l)}if(c!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=c:i+=c}return i}u();var N,k,rt=class{constructor(t,e,o){m(this,N,void 0);m(this,k,void 0);S(this,"signal");g(this,k,t),this.signal=e,g(this,N,o)}computeSignals(t,e){if(t.scores[n(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,N).evaluate(t,this.signal.crit,e,this.signal,n(this,k)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)e.push({type:s,data:{dimension:n(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,k)];a&&e.push({type:s,data:{dimension:n(this,k),delta:-a}})}}};N=new WeakMap,k=new WeakMap;var b,$,ot=class{constructor({manifest:t,evaluator:e=new G({})}){S(this,"data");m(this,b,void 0);m(this,$,void 0);var o,i,s;g(this,b,(o=t.project)!=null?o:{}),this.data=t,g(this,$,Object.entries((s=(i=n(this,b).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,c])=>new rt(a,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=n(this,b).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=n(this,b).test)==null?void 0:e[t]}computeSignals(t){let e=[];return n(this,$).forEach(o=>{o.computeSignals(t,e)}),e}computeAggregateDimensions(t){var e,o;return ht(t,(o=(e=n(this,b).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let e=t.indexOf(B);return e<=0?(i=(o=n(this,b).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,b).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,e)]}};b=new WeakMap,$=new WeakMap;u();var St=(r,t)=>{var i;if(t.type!=="CK")return!1;let e=(i=r.state.cookies)==null?void 0:i[t.cookieName];return E(e,t.match)};u();u();function yt(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function J(r,t){return`${r}${B}${t}`}var it=J("$pvc","v"),Dt=(r,t,e)=>{var a,c;if(t.type!=="PVC")return!1;let o=!r.previousState||((a=r.state.url)==null?void 0:a.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),s=(r.visitor.sessionScores[it]||0)+1;if(yt(s,t.match)){let d=e.some(l=>l.type==="modscoreS"&&l.data.dimension===it);return o&&!d&&e.push({type:"modscoreS",data:{dimension:it,delta:1}}),!0}return!1};u();var Ct=(r,t)=>{var o;if(t.type!=="QS")return!1;let e=(o=r.state.url)==null?void 0:o.searchParams.get(t.queryName);return E(e,t.match)};u();var Vt=(r,t,e,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&r.scores[i]>0)return!0;let s=r.visitor.quirks[t.key];return E(s,t.match)};u();var xt=(r,t)=>{var e,o;return t.type!=="EVT"?!1:(o=(e=r.state.events)==null?void 0:e.some(i=>E(i.event,t.event)))!=null?o:!1};u();var bt=(r,t)=>{var e;return t.type!=="PV"?!1:E((e=r.state.url)==null?void 0:e.pathname,t.path)};u();var _,G=class{constructor(t){m(this,_,void 0);g(this,_,t)}evaluate(t,e,o,i,s){let a=!(e.op==="&"||!e.op);for(let c of e.clauses){let d;if(c.type==="G")d=this.evaluate(t,c,o,i,s);else{let l=n(this,_)[c.type];if(!l)throw new Error(`${c.type} signal criteria not registered`);d=l(t,c,o,i,s)}if(d===a)return a}return!a}};_=new WeakMap;u();function E(r,t){var a,c,d,l;let e=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=o?r!=null?r:"":Et(r),s=o?t.rhs:Et(t.rhs);switch(e){case"=":return i===s;case"!=":return i!==s;case"~":return(d=i.includes(s))!=null?d:!1;case"!~":return!((l=i.includes(s))!=null?l:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");default:throw new Error(`Unknown match type ${e}.`)}}function Et(r){var t;return(t=r==null?void 0:r.toUpperCase())!=null?t:""}u();var H=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import jt from"mitt";import{dequal as Ft}from"dequal/lite";var Qt="__UNIFORM_DATA__",P,I,j=class{constructor({initialData:t}){m(this,P,void 0);m(this,I,jt());S(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&g(this,P,t)}get data(){return n(this,P)}updateData(t,e){return g(this,P,e),this.handleUpdateData(t,e)}async delete(t){g(this,P,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Ft(this.data,t)||(g(this,P,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Qt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};P=new WeakMap,I=new WeakMap;u();var nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tt=nt.split(""),kt=new Array(123);for(let r=0;r<nt.length;r++)kt[nt.charCodeAt(r)]=r;var st=r=>{if(r<0)return`-${st(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Tt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Tt[63&t]+i,t>>>=6;while(t>0);return i+o},wt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+kt[r.charCodeAt(o)];return e?-t:t};var Pt=typeof window=="undefined",R,L,Kt=class extends j{constructor({cookieAdapter:t,cookieName:e="ufvd"}){super({initialData:Pt?Bt(t.get(e)):void 0});m(this,R,void 0);m(this,L,void 0);g(this,R,e),g(this,L,t)}handleDelete(){return n(this,L).remove(n(this,R)),Promise.resolve()}async handleUpdateData(t,e){Pt||(e.consent?n(this,L).set(n(this,R),Jt(e)):n(this,L).remove(n(this,R)))}};R=new WeakMap,L=new WeakMap;var Rt="~",Lt="!",At="-";function Bt(r){if(!r)return;let t=r.split(Rt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Ot(at(o)),scores:Ot(at(i)),tests:at(e)}}function at(r){return r.split(Lt).map(e=>e.split(At)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Ot(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=wt(o),t),{})}function Jt(r){return[ut(r.tests),ut(Mt(r.sessionScores)),ut(Mt(r.scores))].join(Rt)}function Mt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=st(o),t),{})}function ut(r){return Object.entries(r).map(t=>t.join(At)).join(Lt)}u();var Y,Yt,Ht=class extends j{constructor({cookieAdapter:t,visitorIdCookieName:e="ufvi",...o}){super(o);m(this,Y);o.initialData||y(this,Y,Yt).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};Y=new WeakSet,Yt=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function er(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:s,lastUpd:a,scores:c,sessionScores:d}){if(typeof a!="number")return!1;let D=s-a-t;if(D<=0)return!1;let C=D/864e5,U=1-Math.min(o,C*e);return U<=0?!1:(Ut(c,U),Ut(d,U),!0)}}function Ut(r,t){for(let e in r)r[e]*=t}u();import Zt from"mitt";import{dequal as X}from"dequal/lite";u();var ct=class{constructor(){S(this,"inMemoryFallback",{});S(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import Xt from"rfdc";var Wt=Xt();function It(r,t,e){let o=t?Wt(t):H();return r.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let d=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=d+c;break;case"modscoreS":if(e)break;let l=Number(i.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let D=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=D+l;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var W="ufvisitor",T,A,q,h,V,O,w,z,Z,te,tt,ee,F,zt,Q,qt,dt=class{constructor(t){m(this,V);m(this,w);m(this,Z);m(this,tt);m(this,F);m(this,Q);m(this,T,Zt());m(this,A,new ct);m(this,q,void 0);m(this,h,void 0);S(this,"events",{on:n(this,T).on,off:n(this,T).off});if(g(this,h,t),n(this,V,O)||y(this,w,z).call(this,y(this,Q,qt).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),e.tests&&i.push(...Object.entries(e.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{y(this,w,z).call(this,{...n(this,V,O).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,V,O).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,V,O);if(y(this,tt,ee).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return y(this,w,z).call(this,{...s,sessionScores:{}}),(o=(e=n(this,h)).onLogMessage)==null||o.call(e,["info",120]),n(this,V,O).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,h).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=It(t,this.data,(s=n(this,V,O))==null?void 0:s.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&n(this,A).delete(W,!0),y(this,w,z).call(this,e),await((a=n(this,h).transitionStore)==null?void 0:a.updateData(t,n(this,V,O).visitorData))}async delete(t){var e,o,i;n(this,A).delete(W,!1),await((e=n(this,h).transitionStore)==null?void 0:e.delete(t)),y(this,w,z).call(this,y(this,Q,qt).call(this)),(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};T=new WeakMap,A=new WeakMap,q=new WeakMap,h=new WeakMap,V=new WeakSet,O=function(){return n(this,A).get(W)},w=new WeakSet,z=function(t,e=!1){var D,C,U,ft,mt,gt;let o=n(this,V,O),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(y(this,F,zt).call(this,t.scores),y(this,F,zt).call(this,t.sessionScores),(C=(D=n(this,h)).decay)==null||C.call(D,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let s=!X(o==null?void 0:o.visitorData.scores,t.scores),a=!X(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!X(o==null?void 0:o.visitorData.quirks,t.quirks),d=!X(o==null?void 0:o.visitorData.tests,t.tests),l={updated:i,visitorData:t};y(this,Z,te).call(this),n(this,A).set(W,l,!!t.consent),(ft=(U=n(this,h)).onLogMessage)==null||ft.call(U,["debug",102,t]),e||((s||a)&&n(this,T).emit("scoresUpdated",t),c&&n(this,T).emit("quirksUpdated",t),d&&n(this,T).emit("testsUpdated",t),((mt=o==null?void 0:o.visitorData)==null?void 0:mt.consent)!==t.consent&&n(this,T).emit("consentUpdated",t),((gt=o==null?void 0:o.visitorData)==null?void 0:gt.controlGroup)!==t.controlGroup&&n(this,T).emit("controlGroupUpdated",t))},Z=new WeakSet,te=function(){typeof window=="undefined"||!n(this,h).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),g(this,q,window.setTimeout(()=>{this.data},n(this,h).visitLifespan+50)))},tt=new WeakSet,ee=function(t){let e=n(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},F=new WeakSet,zt=function(t){var e,o;if(!!n(this,h).manifest)for(let i in t){let s=t[i],a=n(this,h).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(e=n(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},Q=new WeakSet,qt=function(){var t,e,o;return{...H(),consent:(t=n(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=n(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import oe from"mitt";u();u();function Nt({context:r,variations:t,take:e=1}){var c,d;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],s=!1,a=r.scores;for(let l of t){if(i.length===e)break;if(!((d=l.pz)==null?void 0:d.crit.length)){i.push(l);continue}!o&&$t(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}u();function $t(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>Gt(e,t)):r.crit.some(e=>Gt(e,t)):!0}function Gt(r,t){var a;let{op:e,l:o}=r,i=(a=t[o])!=null?a:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let s=r.rDim?t[r.rDim]:r.r;if(s===void 0)return!1;if(e===">")return i>s;if(e===">=")return i>=s;if(e==="<")return i<s;if(e==="<=")return i<=s;if(e==="=")return i===s;if(e==="!=")return i!==s;throw new Error(`Unknown op: ${e}`)}u();var re=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let s=(100-e)/o;t.forEach((a,c)=>{typeof a=="undefined"&&(t[c]=s)})}return t},lt=({name:r,context:t,variations:e})=>{var s;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(a=>a.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let a=re(e),c=Math.floor(Math.random()*100),d=0;o=e.find((l,D)=>{let C=a[D];if(c>d&&c<=d+C)return l;d+=C}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as ie}from"dequal/lite";var M,x,K,v,ne=class{constructor(t){S(this,"manifest");m(this,M,{});m(this,x,void 0);m(this,K,{});m(this,v,oe());S(this,"events",{on:n(this,v).on,off:n(this,v).off});S(this,"storage");var a,c;let{manifest:e,...o}=t;g(this,x,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,v).on("log",d.logDrain)}),this.manifest=new ot({manifest:e,evaluator:new G({CK:St,QS:Ct,QK:Vt,PVC:Dt,EVT:xt,PV:bt})});let i=!1;this.storage=new dt({...o,manifest:this.manifest,onServerTransitionScoresReceived:d=>{g(this,M,d),i=!0,n(this,v).emit("log",["debug",130,d])},onLogMessage:d=>n(this,v).emit("log",d)});let s=d=>{var D;let l={...d.scores};for(let C in d.sessionScores)l[C]=((D=l[C])!=null?D:0)+d.sessionScores[C];l=this.manifest.computeAggregateDimensions(l),g(this,M,l),n(this,v).emit("scoresUpdated",l),n(this,v).emit("log",["info",3,l])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",d=>{let l=this.manifest.computeSignals({scores:n(this,M),state:n(this,x),previousState:n(this,x),visitor:this.storage.data});this.storage.updateData(l),n(this,v).emit("quirksUpdated",d.quirks),n(this,v).emit("log",["info",4,d.quirks])}),n(this,v).emit("log",["debug",1]),(c=t.plugins)==null||c.forEach(d=>{!d.init||d.init(this)})}get scores(){return n(this,M)}async update(t){var i;let e=[];n(this,v).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(e.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(t.enrichments.forEach(s=>{let a=J(s.cat,s.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:s.str}}):n(this,v).emit("log",["warn",5,s])}),t.enrichments=void 0);let o=n(this,x);g(this,x,{...n(this,x),...t}),e.push(...this.manifest.computeSignals({state:n(this,x),previousState:o,visitor:this.storage.data,scores:n(this,M)})),await this.storage.updateData(e)}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(n(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){n(this,v).emit("log",t)}test(t){var o,i;let e=lt({...t,context:this});return n(this,v).emit("testResult",{name:t.name,variantId:(i=(o=e.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:e.variantAssigned}),e}personalize(t){let e=Nt({...t,context:this}),o=n(this,K)[t.name],i={name:t.name,variantIds:e.variations.map(s=>{var a;return(a=s.id)!=null?a:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&ie(i.variantIds,o)&&(i.changed=!1),n(this,v).emit("personalizationResult",i),n(this,K)[t.name]=i.variantIds,e}async forget(t){g(this,x,{}),await this.storage.delete(t)}};M=new WeakMap,x=new WeakMap,K=new WeakMap,v=new WeakMap;u();u();function et(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function se(r){return([t,e,...o])=>{!et(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
|
2
|
-
`,...
|
3
|
-
`,...
|
1
|
+
var le=Object.defineProperty;var ce=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var C=(e,t,r)=>(ce(e,typeof t!="symbol"?t+"":t,r),r),pt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(pt(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},g=(e,t,r,i)=>(pt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var D=(e,t,r)=>(pt(e,t,"access private method"),r);function Ot(e,t){let r={...e};for(let i in t){let n=Ut(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Ut(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let l=new Set(i);l.add(o.dim),u=Ut(e,o.dim,r,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var L="_";var K,H,tt=class{constructor(t,r,i){d(this,K,void 0);d(this,H,void 0);C(this,"signal");this.signal=t,g(this,K,r),g(this,H,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,K).evaluate(t,this.signal.crit,r,this.signal,a(this,H)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,B,U,et=class{constructor({manifest:t,evaluator:r=new I({}),onLogMessage:i=()=>{}}){C(this,"data");d(this,E,void 0);d(this,B,void 0);d(this,U,void 0);var n,s,o;g(this,E,(n=t.project)!=null?n:{}),this.data=t,g(this,B,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new tt({...c,id:u},r,i))),g(this,U,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,E).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,E).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,U).call(this,["debug",200,"GROUP"]);try{a(this,B).forEach(i=>{a(this,U).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,U).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,U).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return Ot(t,(i=(r=a(this,E).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(L);return r<=0?(n=(i=a(this,E).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};E=new WeakMap,B=new WeakMap,U=new WeakMap;import{dequal as de}from"dequal/lite";function T(e,t){var o,u,c,l,m,h;let r=(o=t==null?void 0:t.op)!=null?o:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":$t(e)).toString(),s=(i?t.rhs:$t(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((h=e==null?void 0:e.toString())!=null?h:"");default:throw new Error(`Unknown match type ${r}.`)}}function $(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${mt(t)}`}function mt(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function $t(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Nt=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!de(At(e.state.cookies),At((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(n,t.match)}]),o};function At(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Gt(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function zt(e,t){return`${e} ${fe(t)}`}function fe(e){return`${e.op} ${e.rhs}`}function rt(e,t){return`${e}${L}${t}`}var ht=rt("$pvc","v"),gt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,m;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((m=e.previousState.url)==null?void 0:m.toString()))),o=(e.visitor.sessionScores[ht]||0)+1,u={result:!1,changed:n},c=r.some(h=>h.type==="modscoreS"&&h.data.dimension===ht);return n&&!c&&r.push({type:"modscoreS",data:{dimension:ht,delta:1}}),Gt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:zt(o,t.match)}]),u};gt.alwaysExecute=!0;var It=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,m,h;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((m=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:m.toString()),n=(h=e.state.url)==null?void 0:h.searchParams.get(t.queryName),o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(n,t.match)}]),o};var qt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var m;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(m=e.state.quirks)==null?void 0:m[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:T(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:$(o,t.match)}]),l};var _t=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(c=>T(c.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${mt(t.event)}`}]),n};var jt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:T(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(i,t.path)}]),o};var J,I=class{constructor(t){d(this,J,void 0);g(this,J,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),c=null,l=!1;for(let h of r.clauses){let y;if(h.type==="G")y=this.evaluate(t,h,i,n,s);else{let x=a(this,J)[h.type];if(c&&!x.alwaysExecute)continue;if(!x)throw new Error(`${h.type} signal criteria not registered`);y=x({update:t,criteria:h,commands:i,signal:n,onLogMessage:s})}y.changed&&(l=!0),!c&&y.result===u&&(c={result:u,changed:l})}let m=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,m])),m}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};J=new WeakMap;var it=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import pe from"mitt";import{dequal as me}from"dequal/lite";var he="__UNIFORM_DATA__",A,q,_=class{constructor({initialData:t}){d(this,A,void 0);d(this,q,pe());C(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&g(this,A,t)}get data(){return a(this,A)}updateData(t,r){return g(this,A,r),this.handleUpdateData(t,r)}async delete(t){g(this,A,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){me(this.data,t)||(g(this,A,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(he);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};A=new WeakMap,q=new WeakMap;var vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ft=vt.split(""),Qt=new Array(123);for(let e=0;e<vt.length;e++)Qt[vt.charCodeAt(e)]=e;var St=e=>{if(e<0)return`-${St(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=Ft[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=Ft[63&t]+n,t>>>=6;while(t>0);return n+i},Kt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+Qt[e.charCodeAt(i)];return r?-t:t};import yt from"js-cookie";var Dt=typeof document=="undefined",ge="ufvd",N,W,Ht=class extends _{constructor({serverCookieValue:r,cookieName:i=ge,cookieAttributes:n={sameSite:"lax"}}){super({initialData:Dt?ve(r):void 0});d(this,N,void 0);d(this,W,void 0);g(this,N,i),g(this,W,n)}handleDelete(){return Dt||yt.remove(a(this,N)),Promise.resolve()}async handleUpdateData(r,i){Dt||(i.consent?yt.set(a(this,N),Se(i),a(this,W)):yt.remove(a(this,N)))}};N=new WeakMap,W=new WeakMap;var Wt="~",Yt="!",Xt="-";function ve(e){if(!e)return;let t=e.split(Wt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Bt(Ct(i)),scores:Bt(Ct(n)),tests:Ct(r)}}function Ct(e){return e.split(Yt).map(r=>r.split(Xt)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Bt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Kt(i),t),{})}function Se(e){return[xt(e.tests),xt(Jt(e.sessionScores)),xt(Jt(e.scores))].join(Wt)}function Jt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=St(i),t),{})}function xt(e){return Object.entries(e).map(t=>t.join(Xt)).join(Yt)}var nt,Mt,Zt=class extends _{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,nt);n.initialData||D(this,nt,Mt).call(this).catch(s=>{console.error(s)})}handleDelete(r){throw new Error("Method not implemented.")}async handleUpdateData(r){let i=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)}};nt=new WeakSet,Mt=async function(){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)};function wr(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let h=s-o-t;if(h<=0)return!1;let y=h/864e5,x=1-Math.min(i,y*r);return x<=0?!1:(Lt(u,x),Lt(c,x),l==null||l(["info",140,`linear decay factor ${x.toPrecision(6)}`]),!0)}}function Lt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}import Ce from"mitt";import{dequal as st}from"dequal/lite";var ot=class{constructor(){C(this,"inMemoryFallback",{});C(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};import ye from"rfdc";var De=ye();function te(e,t,r){let i=t?De(t):it();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=c+u;break;case"modscoreS":if(r)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let m=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=m+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var at="ufvisitor",k,z,j,S,b,w,R,G,lt,ee,ct,re,Y,bt,X,Vt,ut=class{constructor(t){d(this,b);d(this,R);d(this,lt);d(this,ct);d(this,Y);d(this,X);d(this,k,Ce());d(this,z,new ot);d(this,j,void 0);d(this,S,void 0);C(this,"events",{on:a(this,k).on,off:a(this,k).off});if(g(this,S,t),a(this,b,w)||D(this,R,G).call(this,D(this,X,Vt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{D(this,R,G).call(this,{...a(this,b,w).visitorData,...n})});let i=t.transitionStore.data;i&&D(this,R,G).call(this,{...a(this,b,w).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,b,w);if(D(this,ct,re).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return D(this,R,G).call(this,{...s,sessionScores:{}}),(i=(r=a(this,S)).onLogMessage)==null||i.call(r,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,S).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,S)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=te(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,z).delete(at,!0),D(this,R,G).call(this,r),await((o=a(this,S).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,S)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,z).delete(at,!1),await((n=a(this,S).transitionStore)==null?void 0:n.delete(t)),D(this,R,G).call(this,D(this,X,Vt).call(this))}finally{(o=(s=a(this,S)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};k=new WeakMap,z=new WeakMap,j=new WeakMap,S=new WeakMap,b=new WeakSet,w=function(){return a(this,z).get(at)},R=new WeakSet,G=function(t,r=!1){var m,h,y,x,M,kt,Pt,wt,Rt;let i=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(D(this,Y,bt).call(this,t.scores),D(this,Y,bt).call(this,t.sessionScores),(h=(m=a(this,S)).decay)==null||h.call(m,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,S).onLogMessage}));let s=!st(i==null?void 0:i.visitorData.scores,t.scores),o=!st(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!st(i==null?void 0:i.visitorData.quirks,t.quirks),c=!st(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};D(this,lt,ee).call(this),a(this,z).set(at,l,!!t.consent),(x=(y=a(this,S)).onLogMessage)==null||x.call(y,["debug",102,t]),r||((s||o)&&a(this,k).emit("scoresUpdated",t),u&&a(this,k).emit("quirksUpdated",t),c&&a(this,k).emit("testsUpdated",t),((M=i==null?void 0:i.visitorData)==null?void 0:M.consent)!==t.consent&&a(this,k).emit("consentUpdated",t),((kt=i==null?void 0:i.visitorData)==null?void 0:kt.controlGroup)!==t.controlGroup&&(a(this,k).emit("controlGroupUpdated",t),(Rt=(wt=a(this,S)).onLogMessage)==null||Rt.call(wt,["debug",104,(Pt=t.controlGroup)!=null?Pt:!1])))},lt=new WeakSet,ee=function(){typeof document=="undefined"||!a(this,S).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),g(this,j,window.setTimeout(()=>{this.data},a(this,S).visitLifespan+50)))},ct=new WeakSet,re=function(t){let r=a(this,S).visitLifespan;return r?t.updated+r<Date.now():!1},Y=new WeakSet,bt=function(t){var r,i;if(!!a(this,S).manifest)for(let n in t){let s=t[n],o=a(this,S).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,S)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},X=new WeakSet,Vt=function(){var t,r,i;return{...it(),consent:(t=a(this,S).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,S).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};import be from"mitt";function ie({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],m=!1,h=t.scores;for(let y of r){if(l.length===i)break;if(!((o=y.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:y.id,op:(u=y.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(y);continue}c||ne(y.id,y.pz,h,n)&&(m=!0,l.push(y))}return{personalized:m,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function ne(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>oe(s,r,i)):n=t.crit.some(s=>oe(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function oe(e,t,r){var u,c;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(i==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(i===">"){let l=s>o;return F(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return F(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return F(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return F(r,l,e,s,o),l}else if(i==="="){let l=s===o;return F(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return F(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function F(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}var xe=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},Et=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=xe(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,m)=>{let h=o[m];if(u>c&&u<=c+h)return l;c+=h}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};import{dequal as se}from"dequal/lite";var V,O,P,Z,v,Q,dt,ae=class{constructor(t){d(this,Q);C(this,"manifest");d(this,V,void 0);d(this,O,{});d(this,P,void 0);d(this,Z,{});d(this,v,be());C(this,"events",{on:a(this,v).on,off:a(this,v).off});C(this,"storage");var n,s;let{manifest:r,...i}=t;g(this,P,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,v).on("log",o.logDrain)}),a(this,v).emit("log",["info",1,"GROUP"]);try{this.manifest=new et({onLogMessage:o=>a(this,v).emit("log",o),manifest:r,evaluator:new I({CK:Nt,QS:It,QK:qt,PVC:gt,EVT:_t,PV:jt})}),this.storage=new ut({...i,manifest:this.manifest,onServerTransitionReceived:o=>{g(this,V,o),o.ssv&&(g(this,O,o.ssv),a(this,v).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,v).emit("log",o)}),this.storage.events.on("scoresUpdated",D(this,Q,dt).bind(this)),a(this,V)||D(this,Q,dt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,O),state:a(this,P),previousState:a(this,P),visitor:this.storage.data});this.storage.updateData(u),a(this,v).emit("quirksUpdated",o.quirks),a(this,v).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,v).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,O)}async update(t){var i,n,s;let r=[];(i=a(this,V))!=null&&i.quirks&&(t={...t,quirks:{...a(this,V).quirks,...t.quirks||{}}}),(n=a(this,V))!=null&&n.tests&&r.push(...Object.entries(a(this,V).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,v).emit("log",["info",2,"GROUP",{...t,url:(s=t.url)==null?void 0:s.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([o,u])=>({type:"setquirk",data:{key:o,value:u}}))),t.enrichments&&t.enrichments.forEach(o=>{let u=rt(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,v).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,P),visitor:this.storage.data,scores:a(this,O)})),g(this,P,{...a(this,P),...t}),await this.storage.updateData(r),a(this,V)&&(D(this,Q,dt).call(this,this.storage.data),g(this,V,void 0),a(this,v).emit("log",["debug",131]))}finally{a(this,v).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,v).emit("log",t)}test(t){var i,n;let r=Et({...t,context:this,onLogMessage:s=>a(this,v).emit("log",s)});return a(this,v).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=ie({...t,context:this,onLogMessage:s=>a(this,v).emit("log",s)}),i=a(this,Z)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&se(n.variantIds,i)&&(n.changed=!1),a(this,v).emit("personalizationResult",n),a(this,Z)[t.name]=n.variantIds,r}async forget(t){g(this,P,{}),await this.storage.delete(t)}};V=new WeakMap,O=new WeakMap,P=new WeakMap,Z=new WeakMap,v=new WeakMap,Q=new WeakSet,dt=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!se(r,a(this,O))&&(g(this,O,r),a(this,v).emit("scoresUpdated",r),a(this,v).emit("log",["info",3,r]))};import Ve from"rfdc";function ft(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var Ee=Ve();function Te(e){return([t,...r])=>{if(!ft(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
|
2
|
+
`,...n.map(Ee))}}function mi(e){return{logDrain:Te(e)}}var ue={1:()=>["context","initializing Uniform Context"],2:e=>["context","received update()",e],3:e=>["context","new score vector",e],4:e=>["context","updated quirks",e],5:e=>["context","ignored enrichment update for unknown enrichment category",e.cat],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],110:({dim:e,cap:t,score:r})=>["storage",`${e} score ${r} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],131:()=>["storage","server to client transition data was discarded"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};import ke from"rfdc";var Pe=ke();function we(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ft(e,n)||r&&!i)return;let[o,...u]=s,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=ue[o],m="";switch(n){case"debug":m="\u{1F41E}";break;case"info":m="\u{1F4AC}";break;case"warn":m="\u26A0\uFE0F";break;case"error":m="\u{1F4A5}";break}let h=m;if(!l){c(`${h} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[y,x,...M]=l(...u);c(`${h}[${y}] ${x}
|
3
|
+
`,...M.map(Pe))}}function Di(e,t){return{logDrain:we(e,t)}}var Re=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(Re||{}),xi="nesitag";var Tt=typeof top!="undefined";function Vi(){return{logDrain:e=>{!Tt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!Tt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:r}},window.location.origin)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(Tt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Oe(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.events.on("scoresUpdated",i),e.storage.events.on("*",i),()=>{e.events.off("scoresUpdated",i),e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Oe(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}function Ti(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function ki(e){let[t,r,i]=e.split("|");if(!t.startsWith("uf"))throw new Error("Invalid API key");if(!/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/i.test(r))throw new Error("Invalid project ID");return{apiKey:t,projectId:r,apiHost:i||"https://uniform.app"}}export{ae as Context,Ht as CookieTransitionDataStore,xi as EdgeNodeTagName,Zt as EdgeTransitionDataStore,I as GroupCriteriaEvaluator,et as ManifestInstance,he as SERVER_STATE_ID,Re as ScriptType,_ as TransitionDataStore,ge as UNIFORM_DEFAULT_COOKIE_NAME,ut as VisitorDataStore,Ot as computeAggregateDimensions,Nt as cookieEvaluator,Te as createConsoleLogDrain,we as createDebugConsoleLogDrain,wr as createLinearDecay,jt as currentPageEvaluator,it as emptyVisitorData,mi as enableConsoleLogDrain,Vi as enableContextDevTools,Di as enableDebugConsoleLogDrain,ne as evaluateVariantMatch,_t as eventEvaluator,$ as explainStringMatch,mt as explainStringMatchCriteria,rt as getEnrichmentVectorKey,T as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,ki as parseQuickConnect,ie as personalizeVariations,It as queryStringEvaluator,qt as quirkEvaluator,Ti as serializeQuickConnect,Et as testVariations};
|
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
var ne=Object.create;var q=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var de=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Tt=e=>q(e,"__esModule",{value:!0});var le=(e,t)=>{for(var r in t)q(e,r,{get:t[r],enumerable:!0})},kt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ae(t))!ce.call(e,i)&&(r||i!=="default")&&q(e,i,{get:()=>t[i],enumerable:!(o=se(t,i))||o.enumerable});return e},H=(e,t)=>kt(Tt(q(e!=null?ne(ue(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),pe=(e=>(t,r)=>e&&e.get(t)||(r=kt(Tt({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var h=(e,t,r)=>(de(e,typeof t!="symbol"?t+"":t,r),r),st=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var n=(e,t,r)=>(st(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},f=(e,t,r,o)=>(st(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var v=(e,t,r)=>(st(e,t,"access private method"),r);var Te={};le(Te,{Context:()=>te,CookieTransitionDataStore:()=>$t,EdgeNodeTagName:()=>Ve,EdgeTransitionDataStore:()=>Ft,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>X,SERVER_STATE_ID:()=>Lt,ScriptType:()=>ie,TransitionDataStore:()=>I,VisitorDataStore:()=>ot,computeAggregateDimensions:()=>at,cookieEvaluator:()=>ct,createConsoleLogDrain:()=>ee,createDebugConsoleLogDrain:()=>oe,createLinearDecay:()=>he,emptyVisitorData:()=>F,enableConsoleLogDrain:()=>Ce,enableContextDevTools:()=>be,enableDebugConsoleLogDrain:()=>xe,evaluateVariantMatch:()=>Ct,eventEvaluator:()=>ft,getEnrichmentVectorKey:()=>_,isStringMatch:()=>D,pageViewCountDimension:()=>W,pageViewCountEvaluator:()=>dt,pageVisitedEvaluator:()=>mt,personalizeVariations:()=>Dt,queryStringEvaluator:()=>lt,quirkEvaluator:()=>pt,testVariations:()=>it});function at(e,t){let r={...e};for(let o in t){let i=wt(e,o,t,new Set([o]));i!==0&&(r[o]=i)}return r}function wt(e,t,r,o){var s;let i=0;for(let a of r[t].inputs){let u=(s=e[a.dim])!=null?s:0;if(!u&&r[a.dim]){if(o.has(a.dim))continue;let d=new Set(o);d.add(a.dim),u=wt(e,a.dim,r,d)}if(u!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=u:i+=u}return i}var Y="_";var $,E,ut=class{constructor(t,r,o){p(this,$,void 0);p(this,E,void 0);h(this,"signal");f(this,E,t),this.signal=r,f(this,$,o)}computeSignals(t,r){if(t.scores[n(this,E)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,$).evaluate(t,this.signal.crit,r,this.signal,n(this,E)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)r.push({type:s,data:{dimension:n(this,E),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,E)];a&&r.push({type:s,data:{dimension:n(this,E),delta:-a}})}}};$=new WeakMap,E=new WeakMap;var V,G,X=class{constructor({manifest:t,evaluator:r=new A({})}){h(this,"data");p(this,V,void 0);p(this,G,void 0);var o,i,s;f(this,V,(o=t.project)!=null?o:{}),this.data=t,f(this,G,Object.entries((s=(i=n(this,V).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,u])=>new ut(a,u,r)))}rollForControlGroup(){var t,r;return Math.random()<((r=(t=n(this,V).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=n(this,V).test)==null?void 0:r[t]}computeSignals(t){let r=[];return n(this,G).forEach(o=>{o.computeSignals(t,r)}),r}computeAggregateDimensions(t){var r,o;return at(t,(o=(r=n(this,V).pz)==null?void 0:r.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let r=t.indexOf(Y);return r<=0?(i=(o=n(this,V).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,V).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,r)]}};V=new WeakMap,G=new WeakMap;var ct=(e,t)=>{var i;if(t.type!=="CK")return!1;let r=(i=e.state.cookies)==null?void 0:i[t.cookieName];return D(r,t.match)};function Pt(e,t){var o;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function _(e,t){return`${e}${Y}${t}`}var W=_("$pvc","v"),dt=(e,t,r)=>{var a,u;if(t.type!=="PVC")return!1;let o=!e.previousState||((a=e.state.url)==null?void 0:a.toString())!==((u=e.previousState.url)==null?void 0:u.toString()),s=(e.visitor.sessionScores[W]||0)+1;if(Pt(s,t.match)){let c=r.some(d=>d.type==="modscoreS"&&d.data.dimension===W);return o&&!c&&r.push({type:"modscoreS",data:{dimension:W,delta:1}}),!0}return!1};var lt=(e,t)=>{var o;if(t.type!=="QS")return!1;let r=(o=e.state.url)==null?void 0:o.searchParams.get(t.queryName);return D(r,t.match)};var pt=(e,t,r,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&e.scores[i]>0)return!0;let s=e.visitor.quirks[t.key];return D(s,t.match)};var ft=(e,t)=>{var r,o;return t.type!=="EVT"?!1:(o=(r=e.state.events)==null?void 0:r.some(i=>D(i.event,t.event)))!=null?o:!1};var mt=(e,t)=>{var r;return t.type!=="PV"?!1:D((r=e.state.url)==null?void 0:r.pathname,t.path)};var j,A=class{constructor(t){p(this,j,void 0);f(this,j,t)}evaluate(t,r,o,i,s){let a=!(r.op==="&"||!r.op);for(let u of r.clauses){let c;if(u.type==="G")c=this.evaluate(t,u,o,i,s);else{let d=n(this,j)[u.type];if(!d)throw new Error(`${u.type} signal criteria not registered`);c=d(t,u,o,i,s)}if(c===a)return a}return!a}};j=new WeakMap;function D(e,t){var a,u,c,d;let r=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let o=(u=t.cs)!=null?u:!1,i=o?e!=null?e:"":Ot(e),s=o?t.rhs:Ot(t.rhs);switch(r){case"=":return i===s;case"!=":return i!==s;case"~":return(c=i.includes(s))!=null?c:!1;case"!~":return!((d=i.includes(s))!=null?d:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(e!=null?e:"");default:throw new Error(`Unknown match type ${r}.`)}}function Ot(e){var t;return(t=e==null?void 0:e.toUpperCase())!=null?t:""}var F=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Mt=H(require("mitt")),Rt=require("dequal/lite"),Lt="__UNIFORM_DATA__",k,U,I=class{constructor({initialData:t}){p(this,k,void 0);p(this,U,(0,Mt.default)());h(this,"events",{on:n(this,U).on,off:n(this,U).off});t&&f(this,k,t)}get data(){return n(this,k)}updateData(t,r){return f(this,k,r),this.handleUpdateData(t,r)}async delete(t){f(this,k,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Rt.dequal)(this.data,t)||(f(this,k,t),n(this,U).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Lt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};k=new WeakMap,U=new WeakMap;var gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",At=gt.split(""),Ut=new Array(123);for(let e=0;e<gt.length;e++)Ut[gt.charCodeAt(e)]=e;var ht=e=>{if(e<0)return`-${ht(-e)}`;let t=e>>>0,r=e/4294967296>>>0,o="";for(;r>0;)o=At[63&t]+o,t>>>=6,t|=(63&r)<<26,r>>>=6;let i="";do i=At[63&t]+i,t>>>=6;while(t>0);return i+o},It=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let o=r;o<e.length;o++)t=t*64+Ut[e.charCodeAt(o)];return r?-t:t};var zt=typeof window=="undefined",O,M,$t=class extends I{constructor({cookieAdapter:t,cookieName:r="ufvd"}){super({initialData:zt?fe(t.get(r)):void 0});p(this,O,void 0);p(this,M,void 0);f(this,O,r),f(this,M,t)}handleDelete(){return n(this,M).remove(n(this,O)),Promise.resolve()}async handleUpdateData(t,r){zt||(r.consent?n(this,M).set(n(this,O),me(r)):n(this,M).remove(n(this,O)))}};O=new WeakMap,M=new WeakMap;var Gt="~",_t="!",jt="-";function fe(e){if(!e)return;let t=e.split(Gt);if(t.length>3)return;let[r,o,i]=t;return{consent:!0,sessionScores:Nt(vt(o)),scores:Nt(vt(i)),tests:vt(r)}}function vt(e){return e.split(_t).map(r=>r.split(jt)).reduce((r,o)=>(o.length!==2||(r[o[0]]=o[1]),r),{})}function Nt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=It(o),t),{})}function me(e){return[St(e.tests),St(qt(e.sessionScores)),St(qt(e.scores))].join(Gt)}function qt(e){return Object.entries(e).reduce((t,[r,o])=>(t[r]=ht(o),t),{})}function St(e){return Object.entries(e).map(t=>t.join(jt)).join(_t)}var Z,ge,Ft=class extends I{constructor({cookieAdapter:t,visitorIdCookieName:r="ufvi",...o}){super(o);p(this,Z);o.initialData||v(this,Z,ge).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let r=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};Z=new WeakSet,ge=async function(){let t=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};function he(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:o=.95}=e!=null?e:{};return function({now:s,lastUpd:a,scores:u,sessionScores:c}){if(typeof a!="number")return!1;let S=s-a-t;if(S<=0)return!1;let y=S/864e5,L=1-Math.min(o,y*r);return L<=0?!1:(Qt(u,L),Qt(c,L),!0)}}function Qt(e,t){for(let r in e)e[r]*=t}var Yt=H(require("mitt")),Q=require("dequal/lite");var yt=class{constructor(){h(this,"inMemoryFallback",{});h(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return r}}set(t,r,o){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(r))}catch(i){console.warn(i)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};var Kt=H(require("rfdc"));var ve=(0,Kt.default)();function Bt(e,t,r){let o=t?ve(t):F();return e.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(r)break;let u=Number(i.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=c+u;break;case"modscoreS":if(r)break;let d=Number(i.data.delta);if(isNaN(d))throw new Error("Non-number delta received");let S=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=S+d;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var tt="ufvisitor",b,R,N,m,C,w,T,z,et,Se,rt,ye,K,Jt,B,Ht,ot=class{constructor(t){p(this,C);p(this,T);p(this,et);p(this,rt);p(this,K);p(this,B);p(this,b,(0,Yt.default)());p(this,R,new yt);p(this,N,void 0);p(this,m,void 0);h(this,"events",{on:n(this,b).on,off:n(this,b).off});if(f(this,m,t),n(this,C,w)||v(this,T,z).call(this,v(this,B,Ht).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();if(r){let i=[];r.quirks&&i.push(...Object.entries(r.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),r.tests&&i.push(...Object.entries(r.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),r.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(r.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{v(this,T,z).call(this,{...n(this,C,w).visitorData,...i})});let o=t.transitionStore.data;o&&v(this,T,z).call(this,{...n(this,C,w).visitorData,...o},!0)}}get data(){var r,o;let t=n(this,C,w);if(v(this,rt,ye).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return v(this,T,z).call(this,{...s,sessionScores:{}}),(o=(r=n(this,m)).onLogMessage)==null||o.call(r,["info",120]),n(this,C,w).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,m).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["debug",101,t]);let r=Bt(t,this.data,(s=n(this,C,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&n(this,R).delete(tt,!0),v(this,T,z).call(this,r),await((a=n(this,m).transitionStore)==null?void 0:a.updateData(t,n(this,C,w).visitorData))}async delete(t){var r,o,i;n(this,R).delete(tt,!1),await((r=n(this,m).transitionStore)==null?void 0:r.delete(t)),v(this,T,z).call(this,v(this,B,Ht).call(this)),(i=(o=n(this,m)).onLogMessage)==null||i.call(o,["info",103,t])}};b=new WeakMap,R=new WeakMap,N=new WeakMap,m=new WeakMap,C=new WeakSet,w=function(){return n(this,R).get(tt)},T=new WeakSet,z=function(t,r=!1){var S,y,L,Vt,bt,Et;let o=n(this,C,w),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,K,Jt).call(this,t.scores),v(this,K,Jt).call(this,t.sessionScores),(y=(S=n(this,m)).decay)==null||y.call(S,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let s=!(0,Q.dequal)(o==null?void 0:o.visitorData.scores,t.scores),a=!(0,Q.dequal)(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),u=!(0,Q.dequal)(o==null?void 0:o.visitorData.quirks,t.quirks),c=!(0,Q.dequal)(o==null?void 0:o.visitorData.tests,t.tests),d={updated:i,visitorData:t};v(this,et,Se).call(this),n(this,R).set(tt,d,!!t.consent),(Vt=(L=n(this,m)).onLogMessage)==null||Vt.call(L,["debug",102,t]),r||((s||a)&&n(this,b).emit("scoresUpdated",t),u&&n(this,b).emit("quirksUpdated",t),c&&n(this,b).emit("testsUpdated",t),((bt=o==null?void 0:o.visitorData)==null?void 0:bt.consent)!==t.consent&&n(this,b).emit("consentUpdated",t),((Et=o==null?void 0:o.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&n(this,b).emit("controlGroupUpdated",t))},et=new WeakSet,Se=function(){typeof window=="undefined"||!n(this,m).visitLifespan||(n(this,N)&&window.clearTimeout(n(this,N)),f(this,N,window.setTimeout(()=>{this.data},n(this,m).visitLifespan+50)))},rt=new WeakSet,ye=function(t){let r=n(this,m).visitLifespan;return r?t.updated+r<Date.now():!1},K=new WeakSet,Jt=function(t){var r,o;if(!!n(this,m).manifest)for(let i in t){let s=t[i],a=n(this,m).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(r=n(this,m)).onLogMessage)==null||o.call(r,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},B=new WeakSet,Ht=function(){var t,r,o;return{...F(),consent:(t=n(this,m).defaultConsent)!=null?t:!1,controlGroup:(o=(r=n(this,m).manifest)==null?void 0:r.rollForControlGroup())!=null?o:!1}};var Wt=H(require("mitt"));function Dt({context:e,variations:t,take:r=1}){var u,c;let o=(u=e.storage.data.controlGroup)!=null?u:!1,i=[],s=!1,a=e.scores;for(let d of t){if(i.length===r)break;if(!((c=d.pz)==null?void 0:c.crit.length)){i.push(d);continue}!o&&Ct(d.pz,a)&&(s=!0,i.push(d))}return{personalized:s,variations:i}}function Ct(e,t){return(e==null?void 0:e.crit)?!e.op||e.op==="&"?e.crit.every(r=>Xt(r,t)):e.crit.some(r=>Xt(r,t)):!0}function Xt(e,t){var a;let{op:r,l:o}=e,i=(a=t[o])!=null?a:0;if(r==="+")return Math.max(...Object.values(t))===i&&i>0;if(r==="-")return Math.min(...Object.values(t))===i&&i>0;let s=e.rDim?t[e.rDim]:e.r;if(s===void 0)return!1;if(r===">")return i>s;if(r===">=")return i>=s;if(r==="<")return i<s;if(r==="<=")return i<=s;if(r==="=")return i===s;if(r==="!=")return i!==s;throw new Error(`Unknown op: ${r}`)}var De=e=>{let{values:t,total:r,missingDistribution:o}=e.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/o;t.forEach((a,u)=>{typeof a=="undefined"&&(t[u]=s)})}return t},it=({name:e,context:t,variations:r})=>{var s;let o,i=t.getTestVariantId(e);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=r.find(a=>a.id===i),o||t.log("warn",401,{test:e,variant:i})),!o){let a=De(r),u=Math.floor(Math.random()*100),c=0;o=r.find((d,S)=>{let y=a[S];if(u>c&&u<=c+y)return d;c+=y}),o&&t.setTestVariantId(e,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};var Zt=require("dequal/lite"),P,x,J,g,te=class{constructor(t){h(this,"manifest");p(this,P,{});p(this,x,void 0);p(this,J,{});p(this,g,(0,Wt.default)());h(this,"events",{on:n(this,g).on,off:n(this,g).off});h(this,"storage");var a,u;let{manifest:r,...o}=t;f(this,x,{}),(a=t.plugins)==null||a.forEach(c=>{!c.logDrain||n(this,g).on("log",c.logDrain)}),this.manifest=new X({manifest:r,evaluator:new A({CK:ct,QS:lt,QK:pt,PVC:dt,EVT:ft,PV:mt})});let i=!1;this.storage=new ot({...o,manifest:this.manifest,onServerTransitionScoresReceived:c=>{f(this,P,c),i=!0,n(this,g).emit("log",["debug",130,c])},onLogMessage:c=>n(this,g).emit("log",c)});let s=c=>{var S;let d={...c.scores};for(let y in c.sessionScores)d[y]=((S=d[y])!=null?S:0)+c.sessionScores[y];d=this.manifest.computeAggregateDimensions(d),f(this,P,d),n(this,g).emit("scoresUpdated",d),n(this,g).emit("log",["info",3,d])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",c=>{let d=this.manifest.computeSignals({scores:n(this,P),state:n(this,x),previousState:n(this,x),visitor:this.storage.data});this.storage.updateData(d),n(this,g).emit("quirksUpdated",c.quirks),n(this,g).emit("log",["info",4,c.quirks])}),n(this,g).emit("log",["debug",1]),(u=t.plugins)==null||u.forEach(c=>{!c.init||c.init(this)})}get scores(){return n(this,P)}async update(t){var i;let r=[];n(this,g).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(r.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(t.enrichments.forEach(s=>{let a=_(s.cat,s.key);this.manifest.getDimensionByKey(a)?r.push({type:"modscore",data:{dimension:a,delta:s.str}}):n(this,g).emit("log",["warn",5,s])}),t.enrichments=void 0);let o=n(this,x);f(this,x,{...n(this,x),...t}),r.push(...this.manifest.computeSignals({state:n(this,x),previousState:o,visitor:this.storage.data,scores:n(this,P)})),await this.storage.updateData(r)}getTestVariantId(t){var o;let r=this.manifest.getTest(t);return r?(o=r.wv)!=null?o:this.storage.data.tests[t]:(n(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){n(this,g).emit("log",t)}test(t){var o,i;let r=it({...t,context:this});return n(this,g).emit("testResult",{name:t.name,variantId:(i=(o=r.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Dt({...t,context:this}),o=n(this,J)[t.name],i={name:t.name,variantIds:r.variations.map(s=>{var a;return(a=s.id)!=null?a:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&(0,Zt.dequal)(i.variantIds,o)&&(i.changed=!1),n(this,g).emit("personalizationResult",i),n(this,J)[t.name]=i.variantIds,r}async forget(t){f(this,x,{}),await this.storage.delete(t)}};P=new WeakMap,x=new WeakMap,J=new WeakMap,g=new WeakMap;function nt(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}function ee(e){return([t,r,...o])=>{!nt(e,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
|
2
|
-
`,...
|
3
|
-
`,...
|
1
|
+
var Ve=Object.create;var K=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var we=(e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Re=(e,t)=>{for(var r in t)K(e,r,{get:t[r],enumerable:!0})},Kt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Te(t))!Pe.call(e,n)&&n!==r&&K(e,n,{get:()=>t[n],enumerable:!(i=Ee(t,n))||i.enumerable});return e};var A=(e,t,r)=>(r=e!=null?Ve(ke(e)):{},Kt(t||!e||!e.__esModule?K(r,"default",{value:e,enumerable:!0}):r,e)),Oe=e=>Kt(K({},"__esModule",{value:!0}),e);var D=(e,t,r)=>(we(e,typeof t!="symbol"?t+"":t,r),r),yt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(yt(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},h=(e,t,r,i)=>(yt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var y=(e,t,r)=>(yt(e,t,"access private method"),r);var Je={};Re(Je,{Context:()=>It,CookieTransitionDataStore:()=>Ot,EdgeNodeTagName:()=>Fe,EdgeTransitionDataStore:()=>Ut,GroupCriteriaEvaluator:()=>N,ManifestInstance:()=>J,SERVER_STATE_ID:()=>Lt,ScriptType:()=>be,TransitionDataStore:()=>G,UNIFORM_DEFAULT_COOKIE_NAME:()=>oe,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Dt,cookieEvaluator:()=>Ct,createConsoleLogDrain:()=>ye,createDebugConsoleLogDrain:()=>xe,createLinearDecay:()=>Ne,currentPageEvaluator:()=>Et,emptyVisitorData:()=>Z,enableConsoleLogDrain:()=>qe,enableContextDevTools:()=>Qe,enableDebugConsoleLogDrain:()=>je,evaluateVariantMatch:()=>Gt,eventEvaluator:()=>Vt,explainStringMatch:()=>P,explainStringMatchCriteria:()=>at,getEnrichmentVectorKey:()=>Y,isStringMatch:()=>x,pageViewCountDimension:()=>ut,pageViewCountEvaluator:()=>lt,parseQuickConnect:()=>Be,personalizeVariations:()=>Nt,queryStringEvaluator:()=>xt,quirkEvaluator:()=>bt,serializeQuickConnect:()=>He,testVariations:()=>gt});module.exports=Oe(Je);function Dt(e,t){let r={...e};for(let i in t){let n=Ht(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Ht(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let l=new Set(i);l.add(o.dim),u=Ht(e,o.dim,r,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var ot="_";var H,B,st=class{constructor(t,r,i){d(this,H,void 0);d(this,B,void 0);D(this,"signal");this.signal=t,h(this,H,r),h(this,B,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,H).evaluate(t,this.signal.crit,r,this.signal,a(this,B)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};H=new WeakMap,B=new WeakMap;var E,W,U,J=class{constructor({manifest:t,evaluator:r=new N({}),onLogMessage:i=()=>{}}){D(this,"data");d(this,E,void 0);d(this,W,void 0);d(this,U,void 0);var n,s,o;h(this,E,(n=t.project)!=null?n:{}),this.data=t,h(this,W,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new st({...c,id:u},r,i))),h(this,U,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,E).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,E).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,U).call(this,["debug",200,"GROUP"]);try{a(this,W).forEach(i=>{a(this,U).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,U).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,U).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return Dt(t,(i=(r=a(this,E).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(ot);return r<=0?(n=(i=a(this,E).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};E=new WeakMap,W=new WeakMap,U=new WeakMap;var Wt=require("dequal/lite");function x(e,t){var o,u,c,l,p,m;let r=(o=t==null?void 0:t.op)!=null?o:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":Bt(e)).toString(),s=(i?t.rhs:Bt(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${r}.`)}}function P(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${at(t)}`}function at(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Bt(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Ct=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!(0,Wt.dequal)(Jt(e.state.cookies),Jt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:x(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};function Jt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Yt(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function Xt(e,t){return`${e} ${Ue(t)}`}function Ue(e){return`${e.op} ${e.rhs}`}function Y(e,t){return`${e}${ot}${t}`}var ut=Y("$pvc","v"),lt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,p;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((p=e.previousState.url)==null?void 0:p.toString()))),o=(e.visitor.sessionScores[ut]||0)+1,u={result:!1,changed:n},c=r.some(m=>m.type==="modscoreS"&&m.data.dimension===ut);return n&&!c&&r.push({type:"modscoreS",data:{dimension:ut,delta:1}}),Yt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:Xt(o,t.match)}]),u};lt.alwaysExecute=!0;var xt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,p,m;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((p=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:p.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};var bt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var p;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(p=e.state.quirks)==null?void 0:p[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:x(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:P(o,t.match)}]),l};var Vt=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${at(t.event)}`}]),n};var Et=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:x(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:P(i,t.path)}]),o};var X,N=class{constructor(t){d(this,X,void 0);h(this,X,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),c=null,l=!1;for(let m of r.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,i,n,s);else{let C=a(this,X)[m.type];if(c&&!C.alwaysExecute)continue;if(!C)throw new Error(`${m.type} signal criteria not registered`);S=C({update:t,criteria:m,commands:i,signal:n,onLogMessage:s})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let p=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,p])),p}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};X=new WeakMap;var Z=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Zt=A(require("mitt")),Mt=require("dequal/lite"),Lt="__UNIFORM_DATA__",$,_,G=class{constructor({initialData:t}){d(this,$,void 0);d(this,_,(0,Zt.default)());D(this,"events",{on:a(this,_).on,off:a(this,_).off});t&&h(this,$,t)}get data(){return a(this,$)}updateData(t,r){return h(this,$,r),this.handleUpdateData(t,r)}async delete(t){h(this,$,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Mt.dequal)(this.data,t)||(h(this,$,t),a(this,_).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Lt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};$=new WeakMap,_=new WeakMap;var Tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",te=Tt.split(""),ee=new Array(123);for(let e=0;e<Tt.length;e++)ee[Tt.charCodeAt(e)]=e;var kt=e=>{if(e<0)return`-${kt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=te[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=te[63&t]+n,t>>>=6;while(t>0);return n+i},re=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+ee[e.charCodeAt(i)];return r?-t:t};var ct=A(require("js-cookie")),Pt=typeof document=="undefined",oe="ufvd",z,M,Ot=class extends G{constructor({serverCookieValue:r,cookieName:i=oe,cookieAttributes:n={sameSite:"lax"}}){super({initialData:Pt?$e(r):void 0});d(this,z,void 0);d(this,M,void 0);h(this,z,i),h(this,M,n)}handleDelete(){return Pt||ct.default.remove(a(this,z)),Promise.resolve()}async handleUpdateData(r,i){Pt||(i.consent?ct.default.set(a(this,z),Ae(i),a(this,M)):ct.default.remove(a(this,z)))}};z=new WeakMap,M=new WeakMap;var se="~",ae="!",ue="-";function $e(e){if(!e)return;let t=e.split(se);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:ie(wt(i)),scores:ie(wt(n)),tests:wt(r)}}function wt(e){return e.split(ae).map(r=>r.split(ue)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function ie(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=re(i),t),{})}function Ae(e){return[Rt(e.tests),Rt(ne(e.sessionScores)),Rt(ne(e.scores))].join(se)}function ne(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=kt(i),t),{})}function Rt(e){return Object.entries(e).map(t=>t.join(ue)).join(ae)}var dt,le,Ut=class extends G{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,dt);n.initialData||y(this,dt,le).call(this).catch(s=>{console.error(s)})}handleDelete(r){throw new Error("Method not implemented.")}async handleUpdateData(r){let i=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)}};dt=new WeakSet,le=async function(){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)};function Ne(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,C=1-Math.min(i,S*r);return C<=0?!1:(ce(u,C),ce(c,C),l==null||l(["info",140,`linear decay factor ${C.toPrecision(6)}`]),!0)}}function ce(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}var pe=A(require("mitt")),L=require("dequal/lite");var ft=class{constructor(){D(this,"inMemoryFallback",{});D(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};var de=A(require("rfdc"));var Ge=(0,de.default)();function fe(e,t,r){let i=t?Ge(t):Z();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=c+u;break;case"modscoreS":if(r)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let p=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=p+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var pt="ufvisitor",T,q,j,v,b,w,R,I,mt,me,ht,he,et,$t,rt,At,tt=class{constructor(t){d(this,b);d(this,R);d(this,mt);d(this,ht);d(this,et);d(this,rt);d(this,T,(0,pe.default)());d(this,q,new ft);d(this,j,void 0);d(this,v,void 0);D(this,"events",{on:a(this,T).on,off:a(this,T).off});if(h(this,v,t),a(this,b,w)||y(this,R,I).call(this,y(this,rt,At).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{y(this,R,I).call(this,{...a(this,b,w).visitorData,...n})});let i=t.transitionStore.data;i&&y(this,R,I).call(this,{...a(this,b,w).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,b,w);if(y(this,ht,he).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return y(this,R,I).call(this,{...s,sessionScores:{}}),(i=(r=a(this,v)).onLogMessage)==null||i.call(r,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,v).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,v)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=fe(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,q).delete(pt,!0),y(this,R,I).call(this,r),await((o=a(this,v).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,v)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,q).delete(pt,!1),await((n=a(this,v).transitionStore)==null?void 0:n.delete(t)),y(this,R,I).call(this,y(this,rt,At).call(this))}finally{(o=(s=a(this,v)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};T=new WeakMap,q=new WeakMap,j=new WeakMap,v=new WeakMap,b=new WeakSet,w=function(){return a(this,q).get(pt)},R=new WeakSet,I=function(t,r=!1){var p,m,S,C,nt,_t,jt,Ft,Qt;let i=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(y(this,et,$t).call(this,t.scores),y(this,et,$t).call(this,t.sessionScores),(m=(p=a(this,v)).decay)==null||m.call(p,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,v).onLogMessage}));let s=!(0,L.dequal)(i==null?void 0:i.visitorData.scores,t.scores),o=!(0,L.dequal)(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!(0,L.dequal)(i==null?void 0:i.visitorData.quirks,t.quirks),c=!(0,L.dequal)(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};y(this,mt,me).call(this),a(this,q).set(pt,l,!!t.consent),(C=(S=a(this,v)).onLogMessage)==null||C.call(S,["debug",102,t]),r||((s||o)&&a(this,T).emit("scoresUpdated",t),u&&a(this,T).emit("quirksUpdated",t),c&&a(this,T).emit("testsUpdated",t),((nt=i==null?void 0:i.visitorData)==null?void 0:nt.consent)!==t.consent&&a(this,T).emit("consentUpdated",t),((_t=i==null?void 0:i.visitorData)==null?void 0:_t.controlGroup)!==t.controlGroup&&(a(this,T).emit("controlGroupUpdated",t),(Qt=(Ft=a(this,v)).onLogMessage)==null||Qt.call(Ft,["debug",104,(jt=t.controlGroup)!=null?jt:!1])))},mt=new WeakSet,me=function(){typeof document=="undefined"||!a(this,v).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),h(this,j,window.setTimeout(()=>{this.data},a(this,v).visitLifespan+50)))},ht=new WeakSet,he=function(t){let r=a(this,v).visitLifespan;return r?t.updated+r<Date.now():!1},et=new WeakSet,$t=function(t){var r,i;if(!!a(this,v).manifest)for(let n in t){let s=t[n],o=a(this,v).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,v)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},rt=new WeakSet,At=function(){var t,r,i;return{...Z(),consent:(t=a(this,v).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,v).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};var ve=A(require("mitt"));function Nt({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],p=!1,m=t.scores;for(let S of r){if(l.length===i)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||Gt(S.id,S.pz,m,n)&&(p=!0,l.push(S))}return{personalized:p,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function Gt(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>ge(s,r,i)):n=t.crit.some(s=>ge(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function ge(e,t,r){var u,c;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(i==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(i===">"){let l=s>o;return F(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return F(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return F(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return F(r,l,e,s,o),l}else if(i==="="){let l=s===o;return F(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return F(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function F(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}var ze=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},gt=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=ze(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,p)=>{let m=o[p];if(u>c&&u<=c+m)return l;c+=m}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};var zt=require("dequal/lite"),V,O,k,it,g,Q,vt,It=class{constructor(t){d(this,Q);D(this,"manifest");d(this,V,void 0);d(this,O,{});d(this,k,void 0);d(this,it,{});d(this,g,(0,ve.default)());D(this,"events",{on:a(this,g).on,off:a(this,g).off});D(this,"storage");var n,s;let{manifest:r,...i}=t;h(this,k,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,g).on("log",o.logDrain)}),a(this,g).emit("log",["info",1,"GROUP"]);try{this.manifest=new J({onLogMessage:o=>a(this,g).emit("log",o),manifest:r,evaluator:new N({CK:Ct,QS:xt,QK:bt,PVC:lt,EVT:Vt,PV:Et})}),this.storage=new tt({...i,manifest:this.manifest,onServerTransitionReceived:o=>{h(this,V,o),o.ssv&&(h(this,O,o.ssv),a(this,g).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,g).emit("log",o)}),this.storage.events.on("scoresUpdated",y(this,Q,vt).bind(this)),a(this,V)||y(this,Q,vt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,O),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(u),a(this,g).emit("quirksUpdated",o.quirks),a(this,g).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,g).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,O)}async update(t){var i,n,s;let r=[];(i=a(this,V))!=null&&i.quirks&&(t={...t,quirks:{...a(this,V).quirks,...t.quirks||{}}}),(n=a(this,V))!=null&&n.tests&&r.push(...Object.entries(a(this,V).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,g).emit("log",["info",2,"GROUP",{...t,url:(s=t.url)==null?void 0:s.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([o,u])=>({type:"setquirk",data:{key:o,value:u}}))),t.enrichments&&t.enrichments.forEach(o=>{let u=Y(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,g).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,O)})),h(this,k,{...a(this,k),...t}),await this.storage.updateData(r),a(this,V)&&(y(this,Q,vt).call(this,this.storage.data),h(this,V,void 0),a(this,g).emit("log",["debug",131]))}finally{a(this,g).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,g).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,g).emit("log",t)}test(t){var i,n;let r=gt({...t,context:this,onLogMessage:s=>a(this,g).emit("log",s)});return a(this,g).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=Nt({...t,context:this,onLogMessage:s=>a(this,g).emit("log",s)}),i=a(this,it)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&(0,zt.dequal)(n.variantIds,i)&&(n.changed=!1),a(this,g).emit("personalizationResult",n),a(this,it)[t.name]=n.variantIds,r}async forget(t){h(this,k,{}),await this.storage.delete(t)}};V=new WeakMap,O=new WeakMap,k=new WeakMap,it=new WeakMap,g=new WeakMap,Q=new WeakSet,vt=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!(0,zt.dequal)(r,a(this,O))&&(h(this,O,r),a(this,g).emit("scoresUpdated",r),a(this,g).emit("log",["info",3,r]))};var Se=A(require("rfdc"));function St(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var Ie=(0,Se.default)();function ye(e){return([t,...r])=>{if(!St(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
|
2
|
+
`,...n.map(Ie))}}function qe(e){return{logDrain:ye(e)}}var De={1:()=>["context","initializing Uniform Context"],2:e=>["context","received update()",e],3:e=>["context","new score vector",e],4:e=>["context","updated quirks",e],5:e=>["context","ignored enrichment update for unknown enrichment category",e.cat],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],110:({dim:e,cap:t,score:r})=>["storage",`${e} score ${r} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],131:()=>["storage","server to client transition data was discarded"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};var Ce=A(require("rfdc")),_e=(0,Ce.default)();function xe(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!St(e,n)||r&&!i)return;let[o,...u]=s,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=De[o],p="";switch(n){case"debug":p="\u{1F41E}";break;case"info":p="\u{1F4AC}";break;case"warn":p="\u26A0\uFE0F";break;case"error":p="\u{1F4A5}";break}let m=p;if(!l){c(`${m} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,C,...nt]=l(...u);c(`${m}[${S}] ${C}
|
3
|
+
`,...nt.map(_e))}}function je(e,t){return{logDrain:xe(e,t)}}var be=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(be||{}),Fe="nesitag";var qt=typeof top!="undefined";function Qe(){return{logDrain:e=>{!qt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!qt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:r}},window.location.origin)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(qt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Ke(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.events.on("scoresUpdated",i),e.storage.events.on("*",i),()=>{e.events.off("scoresUpdated",i),e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Ke(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}function He(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function Be(e){let[t,r,i]=e.split("|");if(!t.startsWith("uf"))throw new Error("Invalid API key");if(!/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/i.test(r))throw new Error("Invalid project ID");return{apiKey:t,projectId:r,apiHost:i||"https://uniform.app"}}0&&(module.exports={Context,CookieTransitionDataStore,EdgeNodeTagName,EdgeTransitionDataStore,GroupCriteriaEvaluator,ManifestInstance,SERVER_STATE_ID,ScriptType,TransitionDataStore,UNIFORM_DEFAULT_COOKIE_NAME,VisitorDataStore,computeAggregateDimensions,cookieEvaluator,createConsoleLogDrain,createDebugConsoleLogDrain,createLinearDecay,currentPageEvaluator,emptyVisitorData,enableConsoleLogDrain,enableContextDevTools,enableDebugConsoleLogDrain,evaluateVariantMatch,eventEvaluator,explainStringMatch,explainStringMatchCriteria,getEnrichmentVectorKey,isStringMatch,pageViewCountDimension,pageViewCountEvaluator,parseQuickConnect,personalizeVariations,queryStringEvaluator,quirkEvaluator,serializeQuickConnect,testVariations});
|
package/dist/index.mjs
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{a as B}from"./chunk-ORM4ZDHU.mjs";import{d as S,e as n,f as m,g,h as y,i as u}from"./chunk-PZGIHZYO.mjs";u();u();u();function ht(r,t){let e={...r};for(let o in t){let i=vt(r,o,t,new Set([o]));i!==0&&(e[o]=i)}return e}function vt(r,t,e,o){var s;let i=0;for(let a of e[t].inputs){let c=(s=r[a.dim])!=null?s:0;if(!c&&e[a.dim]){if(o.has(a.dim))continue;let l=new Set(o);l.add(a.dim),c=vt(r,a.dim,e,l)}if(c!==0)if(a.sign==="c"){i=0;break}else a.sign==="-"?i-=c:i+=c}return i}u();var N,k,rt=class{constructor(t,e,o){m(this,N,void 0);m(this,k,void 0);S(this,"signal");g(this,k,t),this.signal=e,g(this,N,o)}computeSignals(t,e){if(t.scores[n(this,k)]>=this.signal.cap&&this.signal.dur!=="t")return;let i=n(this,N).evaluate(t,this.signal.crit,e,this.signal,n(this,k)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(i)e.push({type:s,data:{dimension:n(this,k),delta:this.signal.str}});else if(this.signal.dur==="t"){let a=t.visitor.sessionScores[n(this,k)];a&&e.push({type:s,data:{dimension:n(this,k),delta:-a}})}}};N=new WeakMap,k=new WeakMap;var b,$,ot=class{constructor({manifest:t,evaluator:e=new G({})}){S(this,"data");m(this,b,void 0);m(this,$,void 0);var o,i,s;g(this,b,(o=t.project)!=null?o:{}),this.data=t,g(this,$,Object.entries((s=(i=n(this,b).pz)==null?void 0:i.sig)!=null?s:[]).map(([a,c])=>new rt(a,c,e)))}rollForControlGroup(){var t,e;return Math.random()<((e=(t=n(this,b).pz)==null?void 0:t.control)!=null?e:0)}getTest(t){var e;return(e=n(this,b).test)==null?void 0:e[t]}computeSignals(t){let e=[];return n(this,$).forEach(o=>{o.computeSignals(t,e)}),e}computeAggregateDimensions(t){var e,o;return ht(t,(o=(e=n(this,b).pz)==null?void 0:e.agg)!=null?o:{})}getDimensionByKey(t){var o,i,s,a;let e=t.indexOf(B);return e<=0?(i=(o=n(this,b).pz)==null?void 0:o.sig)==null?void 0:i[t]:(a=(s=n(this,b).pz)==null?void 0:s.enr)==null?void 0:a[t.substring(0,e)]}};b=new WeakMap,$=new WeakMap;u();var St=(r,t)=>{var i;if(t.type!=="CK")return!1;let e=(i=r.state.cookies)==null?void 0:i[t.cookieName];return E(e,t.match)};u();u();function yt(r,t){var o;if(typeof r=="undefined"||r===null)return!1;let e=Number(r);if(isNaN(e))return!1;switch((o=t==null?void 0:t.op)!=null?o:"="){case"=":return e===t.rhs;case"!=":return e!==t.rhs;case">":return e>t.rhs;case"<":return e<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}u();function J(r,t){return`${r}${B}${t}`}var it=J("$pvc","v"),Dt=(r,t,e)=>{var a,c;if(t.type!=="PVC")return!1;let o=!r.previousState||((a=r.state.url)==null?void 0:a.toString())!==((c=r.previousState.url)==null?void 0:c.toString()),s=(r.visitor.sessionScores[it]||0)+1;if(yt(s,t.match)){let d=e.some(l=>l.type==="modscoreS"&&l.data.dimension===it);return o&&!d&&e.push({type:"modscoreS",data:{dimension:it,delta:1}}),!0}return!1};u();var Ct=(r,t)=>{var o;if(t.type!=="QS")return!1;let e=(o=r.state.url)==null?void 0:o.searchParams.get(t.queryName);return E(e,t.match)};u();var Vt=(r,t,e,o,i)=>{if(t.type!=="QK")return!1;if(typeof window=="undefined"&&o.dur==="t"&&r.scores[i]>0)return!0;let s=r.visitor.quirks[t.key];return E(s,t.match)};u();var xt=(r,t)=>{var e,o;return t.type!=="EVT"?!1:(o=(e=r.state.events)==null?void 0:e.some(i=>E(i.event,t.event)))!=null?o:!1};u();var bt=(r,t)=>{var e;return t.type!=="PV"?!1:E((e=r.state.url)==null?void 0:e.pathname,t.path)};u();var _,G=class{constructor(t){m(this,_,void 0);g(this,_,t)}evaluate(t,e,o,i,s){let a=!(e.op==="&"||!e.op);for(let c of e.clauses){let d;if(c.type==="G")d=this.evaluate(t,c,o,i,s);else{let l=n(this,_)[c.type];if(!l)throw new Error(`${c.type} signal criteria not registered`);d=l(t,c,o,i,s)}if(d===a)return a}return!a}};_=new WeakMap;u();function E(r,t){var a,c,d,l;let e=(a=t==null?void 0:t.op)!=null?a:"=";if(t.op==="*")return r!==null&&typeof r!="undefined";if(t.op==="!*")return r===null||typeof r=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${e}`);let o=(c=t.cs)!=null?c:!1,i=o?r!=null?r:"":Et(r),s=o?t.rhs:Et(t.rhs);switch(e){case"=":return i===s;case"!=":return i!==s;case"~":return(d=i.includes(s))!=null?d:!1;case"!~":return!((l=i.includes(s))!=null?l:!0);case"//":return new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");case"!//":return!new RegExp(t.rhs,o?"":"i").test(r!=null?r:"");default:throw new Error(`Unknown match type ${e}.`)}}function Et(r){var t;return(t=r==null?void 0:r.toUpperCase())!=null?t:""}u();var H=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});u();u();import jt from"mitt";import{dequal as Ft}from"dequal/lite";var Qt="__UNIFORM_DATA__",P,I,j=class{constructor({initialData:t}){m(this,P,void 0);m(this,I,jt());S(this,"events",{on:n(this,I).on,off:n(this,I).off});t&&g(this,P,t)}get data(){return n(this,P)}updateData(t,e){return g(this,P,e),this.handleUpdateData(t,e)}async delete(t){g(this,P,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){Ft(this.data,t)||(g(this,P,t),n(this,I).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Qt);return(t==null?void 0:t.textContent)?JSON.parse(t.textContent):void 0}};P=new WeakMap,I=new WeakMap;u();var nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tt=nt.split(""),kt=new Array(123);for(let r=0;r<nt.length;r++)kt[nt.charCodeAt(r)]=r;var st=r=>{if(r<0)return`-${st(-r)}`;let t=r>>>0,e=r/4294967296>>>0,o="";for(;e>0;)o=Tt[63&t]+o,t>>>=6,t|=(63&e)<<26,e>>>=6;let i="";do i=Tt[63&t]+i,t>>>=6;while(t>0);return i+o},wt=r=>{let t=0,e=r.charAt(0)==="-"?1:0;for(let o=e;o<r.length;o++)t=t*64+kt[r.charCodeAt(o)];return e?-t:t};var Pt=typeof window=="undefined",R,L,Kt=class extends j{constructor({cookieAdapter:t,cookieName:e="ufvd"}){super({initialData:Pt?Bt(t.get(e)):void 0});m(this,R,void 0);m(this,L,void 0);g(this,R,e),g(this,L,t)}handleDelete(){return n(this,L).remove(n(this,R)),Promise.resolve()}async handleUpdateData(t,e){Pt||(e.consent?n(this,L).set(n(this,R),Jt(e)):n(this,L).remove(n(this,R)))}};R=new WeakMap,L=new WeakMap;var Rt="~",Lt="!",At="-";function Bt(r){if(!r)return;let t=r.split(Rt);if(t.length>3)return;let[e,o,i]=t;return{consent:!0,sessionScores:Ot(at(o)),scores:Ot(at(i)),tests:at(e)}}function at(r){return r.split(Lt).map(e=>e.split(At)).reduce((e,o)=>(o.length!==2||(e[o[0]]=o[1]),e),{})}function Ot(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=wt(o),t),{})}function Jt(r){return[ut(r.tests),ut(Mt(r.sessionScores)),ut(Mt(r.scores))].join(Rt)}function Mt(r){return Object.entries(r).reduce((t,[e,o])=>(t[e]=st(o),t),{})}function ut(r){return Object.entries(r).map(t=>t.join(At)).join(Lt)}u();var Y,Yt,Ht=class extends j{constructor({cookieAdapter:t,visitorIdCookieName:e="ufvi",...o}){super(o);m(this,Y);o.initialData||y(this,Y,Yt).call(this).catch(i=>{console.error(i)})}handleDelete(t){throw new Error("Method not implemented.")}async handleUpdateData(t){let e=await new Promise(o=>{setTimeout(()=>{o(void 0)},2e3)});e&&this.signalAsyncDataUpdate(e)}};Y=new WeakSet,Yt=async function(){let t=await new Promise(e=>{setTimeout(()=>{e(void 0)},2e3)});t&&this.signalAsyncDataUpdate(t)};u();function er(r){let{gracePeriod:t=864e5,decayRate:e=1/30,decayCap:o=.95}=r!=null?r:{};return function({now:s,lastUpd:a,scores:c,sessionScores:d}){if(typeof a!="number")return!1;let D=s-a-t;if(D<=0)return!1;let C=D/864e5,U=1-Math.min(o,C*e);return U<=0?!1:(Ut(c,U),Ut(d,U),!0)}}function Ut(r,t){for(let e in r)r[e]*=t}u();import Zt from"mitt";import{dequal as X}from"dequal/lite";u();var ct=class{constructor(){S(this,"inMemoryFallback",{});S(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let e=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||e)return e;try{let o=localStorage.getItem(t);return o?JSON.parse(o):void 0}catch(o){return e}}set(t,e,o){if(this.inMemoryFallback[t]=e,!(!this.hasLocalStorageObject||!o))try{localStorage.setItem(t,JSON.stringify(e))}catch(i){console.warn(i)}}delete(t,e){e||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(o){}}};u();import Xt from"rfdc";var Wt=Xt();function It(r,t,e){let o=t?Wt(t):H();return r.forEach(i=>{var s,a;switch(i.type){case"consent":o.consent=i.data;break;case"setquirk":o.quirks[i.data.key]=i.data.value;break;case"settest":o.tests[i.data.test]=i.data.variant;break;case"modscore":if(e)break;let c=Number(i.data.delta);if(isNaN(c))throw new Error("Non-number delta received");let d=(s=o.scores[i.data.dimension])!=null?s:0;o.scores[i.data.dimension]=d+c;break;case"modscoreS":if(e)break;let l=Number(i.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let D=(a=o.sessionScores[i.data.dimension])!=null?a:0;o.sessionScores[i.data.dimension]=D+l;break;case"identify":break;case"setcontrol":o.controlGroup=i.data;break;default:throw new Error("Unknown command")}}),o}var W="ufvisitor",T,A,q,h,V,O,w,z,Z,te,tt,ee,F,zt,Q,qt,dt=class{constructor(t){m(this,V);m(this,w);m(this,Z);m(this,tt);m(this,F);m(this,Q);m(this,T,Zt());m(this,A,new ct);m(this,q,void 0);m(this,h,void 0);S(this,"events",{on:n(this,T).on,off:n(this,T).off});if(g(this,h,t),n(this,V,O)||y(this,w,z).call(this,y(this,Q,qt).call(this),!0),t.transitionStore){let e=t.transitionStore.getClientTransitionState();if(e){let i=[];e.quirks&&i.push(...Object.entries(e.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),e.tests&&i.push(...Object.entries(e.tests).map(([s,a])=>({type:"settest",data:{test:s,variant:a}}))),this.updateData(i),e.ssv&&t.onServerTransitionScoresReceived&&t.onServerTransitionScoresReceived(e.ssv)}t.transitionStore.events.on("dataUpdatedAsync",i=>{y(this,w,z).call(this,{...n(this,V,O).visitorData,...i})});let o=t.transitionStore.data;o&&y(this,w,z).call(this,{...n(this,V,O).visitorData,...o},!0)}}get data(){var e,o;let t=n(this,V,O);if(y(this,tt,ee).call(this,t)){let{sessionScores:i,...s}=t.visitorData;return y(this,w,z).call(this,{...s,sessionScores:{}}),(o=(e=n(this,h)).onLogMessage)==null||o.call(e,["info",120]),n(this,V,O).visitorData}return t.visitorData}get decayEnabled(){return!!n(this,h).decay}async updateData(t){var o,i,s,a;if(t.length===0)return;(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["debug",101,t]);let e=It(t,this.data,(s=n(this,V,O))==null?void 0:s.visitorData.controlGroup);t.some(c=>c.type==="consent"&&!c.data)&&n(this,A).delete(W,!0),y(this,w,z).call(this,e),await((a=n(this,h).transitionStore)==null?void 0:a.updateData(t,n(this,V,O).visitorData))}async delete(t){var e,o,i;n(this,A).delete(W,!1),await((e=n(this,h).transitionStore)==null?void 0:e.delete(t)),y(this,w,z).call(this,y(this,Q,qt).call(this)),(i=(o=n(this,h)).onLogMessage)==null||i.call(o,["info",103,t])}};T=new WeakMap,A=new WeakMap,q=new WeakMap,h=new WeakMap,V=new WeakSet,O=function(){return n(this,A).get(W)},w=new WeakSet,z=function(t,e=!1){var D,C,U,ft,mt,gt;let o=n(this,V,O),i=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(y(this,F,zt).call(this,t.scores),y(this,F,zt).call(this,t.sessionScores),(C=(D=n(this,h)).decay)==null||C.call(D,{now:i,lastUpd:o==null?void 0:o.updated,scores:t.scores,sessionScores:t.sessionScores}));let s=!X(o==null?void 0:o.visitorData.scores,t.scores),a=!X(o==null?void 0:o.visitorData.sessionScores,t.sessionScores),c=!X(o==null?void 0:o.visitorData.quirks,t.quirks),d=!X(o==null?void 0:o.visitorData.tests,t.tests),l={updated:i,visitorData:t};y(this,Z,te).call(this),n(this,A).set(W,l,!!t.consent),(ft=(U=n(this,h)).onLogMessage)==null||ft.call(U,["debug",102,t]),e||((s||a)&&n(this,T).emit("scoresUpdated",t),c&&n(this,T).emit("quirksUpdated",t),d&&n(this,T).emit("testsUpdated",t),((mt=o==null?void 0:o.visitorData)==null?void 0:mt.consent)!==t.consent&&n(this,T).emit("consentUpdated",t),((gt=o==null?void 0:o.visitorData)==null?void 0:gt.controlGroup)!==t.controlGroup&&n(this,T).emit("controlGroupUpdated",t))},Z=new WeakSet,te=function(){typeof window=="undefined"||!n(this,h).visitLifespan||(n(this,q)&&window.clearTimeout(n(this,q)),g(this,q,window.setTimeout(()=>{this.data},n(this,h).visitLifespan+50)))},tt=new WeakSet,ee=function(t){let e=n(this,h).visitLifespan;return e?t.updated+e<Date.now():!1},F=new WeakSet,zt=function(t){var e,o;if(!!n(this,h).manifest)for(let i in t){let s=t[i],a=n(this,h).manifest.getDimensionByKey(i);!a||s>a.cap&&((o=(e=n(this,h)).onLogMessage)==null||o.call(e,["debug",110,{dim:i,score:s,cap:a.cap}]),t[i]=a.cap)}},Q=new WeakSet,qt=function(){var t,e,o;return{...H(),consent:(t=n(this,h).defaultConsent)!=null?t:!1,controlGroup:(o=(e=n(this,h).manifest)==null?void 0:e.rollForControlGroup())!=null?o:!1}};u();import oe from"mitt";u();u();function Nt({context:r,variations:t,take:e=1}){var c,d;let o=(c=r.storage.data.controlGroup)!=null?c:!1,i=[],s=!1,a=r.scores;for(let l of t){if(i.length===e)break;if(!((d=l.pz)==null?void 0:d.crit.length)){i.push(l);continue}!o&&$t(l.pz,a)&&(s=!0,i.push(l))}return{personalized:s,variations:i}}u();function $t(r,t){return(r==null?void 0:r.crit)?!r.op||r.op==="&"?r.crit.every(e=>Gt(e,t)):r.crit.some(e=>Gt(e,t)):!0}function Gt(r,t){var a;let{op:e,l:o}=r,i=(a=t[o])!=null?a:0;if(e==="+")return Math.max(...Object.values(t))===i&&i>0;if(e==="-")return Math.min(...Object.values(t))===i&&i>0;let s=r.rDim?t[r.rDim]:r.r;if(s===void 0)return!1;if(e===">")return i>s;if(e===">=")return i>=s;if(e==="<")return i<s;if(e==="<=")return i<=s;if(e==="=")return i===s;if(e==="!=")return i!==s;throw new Error(`Unknown op: ${e}`)}u();var re=r=>{let{values:t,total:e,missingDistribution:o}=r.reduce((i,s)=>(s.testDistribution?i.total+=s.testDistribution:++i.missingDistribution,i.values.push(s.testDistribution),i),{values:[],total:0,missingDistribution:0});if(e>100)throw new Error(`Total distribution ${e} is over the maximum 100.`);if(e<100){let s=(100-e)/o;t.forEach((a,c)=>{typeof a=="undefined"&&(t[c]=s)})}return t},lt=({name:r,context:t,variations:e})=>{var s;let o,i=t.getTestVariantId(r);if(i===null)return{result:void 0,variantAssigned:!1};if(i&&(o=e.find(a=>a.id===i),o||t.log("warn",401,{test:r,variant:i})),!o){let a=re(e),c=Math.floor(Math.random()*100),d=0;o=e.find((l,D)=>{let C=a[D];if(c>d&&c<=d+C)return l;d+=C}),o&&t.setTestVariantId(r,(s=o.id)!=null?s:"Unknown")}return{result:o,variantAssigned:!i}};import{dequal as ie}from"dequal/lite";var M,x,K,v,ne=class{constructor(t){S(this,"manifest");m(this,M,{});m(this,x,void 0);m(this,K,{});m(this,v,oe());S(this,"events",{on:n(this,v).on,off:n(this,v).off});S(this,"storage");var a,c;let{manifest:e,...o}=t;g(this,x,{}),(a=t.plugins)==null||a.forEach(d=>{!d.logDrain||n(this,v).on("log",d.logDrain)}),this.manifest=new ot({manifest:e,evaluator:new G({CK:St,QS:Ct,QK:Vt,PVC:Dt,EVT:xt,PV:bt})});let i=!1;this.storage=new dt({...o,manifest:this.manifest,onServerTransitionScoresReceived:d=>{g(this,M,d),i=!0,n(this,v).emit("log",["debug",130,d])},onLogMessage:d=>n(this,v).emit("log",d)});let s=d=>{var D;let l={...d.scores};for(let C in d.sessionScores)l[C]=((D=l[C])!=null?D:0)+d.sessionScores[C];l=this.manifest.computeAggregateDimensions(l),g(this,M,l),n(this,v).emit("scoresUpdated",l),n(this,v).emit("log",["info",3,l])};this.storage.events.on("scoresUpdated",s),i||s(this.storage.data),this.storage.events.on("quirksUpdated",d=>{let l=this.manifest.computeSignals({scores:n(this,M),state:n(this,x),previousState:n(this,x),visitor:this.storage.data});this.storage.updateData(l),n(this,v).emit("quirksUpdated",d.quirks),n(this,v).emit("log",["info",4,d.quirks])}),n(this,v).emit("log",["debug",1]),(c=t.plugins)==null||c.forEach(d=>{!d.init||d.init(this)})}get scores(){return n(this,M)}async update(t){var i;let e=[];n(this,v).emit("log",["info",2,{...t,url:(i=t.url)==null?void 0:i.toString()}]),t.quirks&&(e.push(...Object.entries(t.quirks).map(([s,a])=>({type:"setquirk",data:{key:s,value:a}}))),t.quirks=void 0),t.enrichments&&(t.enrichments.forEach(s=>{let a=J(s.cat,s.key);this.manifest.getDimensionByKey(a)?e.push({type:"modscore",data:{dimension:a,delta:s.str}}):n(this,v).emit("log",["warn",5,s])}),t.enrichments=void 0);let o=n(this,x);g(this,x,{...n(this,x),...t}),e.push(...this.manifest.computeSignals({state:n(this,x),previousState:o,visitor:this.storage.data,scores:n(this,M)})),await this.storage.updateData(e)}getTestVariantId(t){var o;let e=this.manifest.getTest(t);return e?(o=e.wv)!=null?o:this.storage.data.tests[t]:(n(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,e){this.storage.updateData([{type:"settest",data:{test:t,variant:e}}])}log(...t){n(this,v).emit("log",t)}test(t){var o,i;let e=lt({...t,context:this});return n(this,v).emit("testResult",{name:t.name,variantId:(i=(o=e.result)==null?void 0:o.id)!=null?i:void 0,variantAssigned:e.variantAssigned}),e}personalize(t){let e=Nt({...t,context:this}),o=n(this,K)[t.name],i={name:t.name,variantIds:e.variations.map(s=>{var a;return(a=s.id)!=null?a:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return o&&ie(i.variantIds,o)&&(i.changed=!1),n(this,v).emit("personalizationResult",i),n(this,K)[t.name]=i.variantIds,e}async forget(t){g(this,x,{}),await this.storage.delete(t)}};M=new WeakMap,x=new WeakMap,K=new WeakMap,v=new WeakMap;u();u();function et(r,t){if(r==="none")return!1;switch(t){case"debug":return r==="debug";case"info":return r==="info"||r==="debug";case"warn":return r==="warn"||r==="info"||r==="debug";case"error":return r==="debug"||"info";default:return!1}}function se(r){return([t,e,...o])=>{!et(r,t)||console[t](`\u{1F94B} [${t}] Uniform event ID ${e}
|
2
|
-
`,...
|
3
|
-
`,...
|
1
|
+
var le=Object.defineProperty;var ce=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var C=(e,t,r)=>(ce(e,typeof t!="symbol"?t+"":t,r),r),pt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(pt(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},g=(e,t,r,i)=>(pt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var D=(e,t,r)=>(pt(e,t,"access private method"),r);function Ot(e,t){let r={...e};for(let i in t){let n=Ut(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Ut(e,t,r,i){var s;let n=0;for(let o of r[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&r[o.dim]){if(i.has(o.dim))continue;let l=new Set(i);l.add(o.dim),u=Ut(e,o.dim,r,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.sign==="-"?n-=u:n+=u}return n}var L="_";var K,H,tt=class{constructor(t,r,i){d(this,K,void 0);d(this,H,void 0);C(this,"signal");this.signal=t,g(this,K,r),g(this,H,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,K).evaluate(t,this.signal.crit,r,this.signal,a(this,H)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)r.push({type:s,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let o=t.visitor.sessionScores[this.signal.id];o&&r.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,B,U,et=class{constructor({manifest:t,evaluator:r=new I({}),onLogMessage:i=()=>{}}){C(this,"data");d(this,E,void 0);d(this,B,void 0);d(this,U,void 0);var n,s,o;g(this,E,(n=t.project)!=null?n:{}),this.data=t,g(this,B,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new tt({...c,id:u},r,i))),g(this,U,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,E).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,E).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,U).call(this,["debug",200,"GROUP"]);try{a(this,B).forEach(i=>{a(this,U).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,U).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,U).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return Ot(t,(i=(r=a(this,E).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(L);return r<=0?(n=(i=a(this,E).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};E=new WeakMap,B=new WeakMap,U=new WeakMap;import{dequal as de}from"dequal/lite";function T(e,t){var o,u,c,l,m,h;let r=(o=t==null?void 0:t.op)!=null?o:"=";if(t.op==="*")return e!==null&&typeof e!="undefined";if(t.op==="!*")return e===null||typeof e=="undefined";if(!("rhs"in t))throw new Error(`Match expression is required for match type ${r}`);let i=(u=t.cs)!=null?u:!1,n=(i?e!=null?e:"":$t(e)).toString(),s=(i?t.rhs:$t(t.rhs)).toString();switch(r){case"=":return n===s;case"!=":return n!==s;case"~":return(c=n.includes(s))!=null?c:!1;case"!~":return!((l=n.includes(s))==null||l);case"//":return new RegExp(t.rhs.toString(),i?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((h=e==null?void 0:e.toString())!=null?h:"");default:throw new Error(`Unknown match type ${r}.`)}}function $(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${mt(t)}`}function mt(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function $t(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Nt=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!de(At(e.state.cookies),At((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(n,t.match)}]),o};function At(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Gt(e,t){var i;if(typeof e=="undefined"||e===null)return!1;let r=Number(e);if(isNaN(r))return!1;switch((i=t==null?void 0:t.op)!=null?i:"="){case"=":return r===t.rhs;case"!=":return r!==t.rhs;case">":return r>t.rhs;case"<":return r<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function zt(e,t){return`${e} ${fe(t)}`}function fe(e){return`${e.op} ${e.rhs}`}function rt(e,t){return`${e}${L}${t}`}var ht=rt("$pvc","v"),gt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,m;if(t.type!=="PVC")return{result:!1,changed:!1};let n=Boolean(e.state.url&&(!e.previousState||((l=e.state.url)==null?void 0:l.toString())!==((m=e.previousState.url)==null?void 0:m.toString()))),o=(e.visitor.sessionScores[ht]||0)+1,u={result:!1,changed:n},c=r.some(h=>h.type==="modscoreS"&&h.data.dimension===ht);return n&&!c&&r.push({type:"modscoreS",data:{dimension:ht,delta:1}}),Gt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:zt(o,t.match)}]),u};gt.alwaysExecute=!0;var It=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,m,h;if(t.type!=="QS")return{result:!1,changed:!1};let i=!e.previousState||((c=(u=e.state.url)==null?void 0:u.searchParams)==null?void 0:c.toString())!==((m=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:m.toString()),n=(h=e.state.url)==null?void 0:h.searchParams.get(t.queryName),o={result:T(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(n,t.match)}]),o};var qt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var m;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&r.dur==="t"&&e.scores[r.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],s=(m=e.state.quirks)==null?void 0:m[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:T(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:$(o,t.match)}]),l};var _t=({update:e,criteria:t,onLogMessage:r})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let i=(o=(s=e.state.events)==null?void 0:s.some(c=>T(c.event,t.event)))!=null?o:!1,n={result:i,changed:i};return r==null||r(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${mt(t.event)}`}]),n};var jt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let i=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(i==null?void 0:i.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),o={result:T(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:$(i,t.path)}]),o};var J,I=class{constructor(t){d(this,J,void 0);g(this,J,t)}evaluate(t,r,i,n,s){let o=r.clauses.length>1;o&&(s==null||s(["debug",202,"GROUP",r]));try{let u=!(r.op==="&"||!r.op),c=null,l=!1;for(let h of r.clauses){let y;if(h.type==="G")y=this.evaluate(t,h,i,n,s);else{let x=a(this,J)[h.type];if(c&&!x.alwaysExecute)continue;if(!x)throw new Error(`${h.type} signal criteria not registered`);y=x({update:t,criteria:h,commands:i,signal:n,onLogMessage:s})}y.changed&&(l=!0),!c&&y.result===u&&(c={result:u,changed:l})}let m=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,m])),m}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};J=new WeakMap;var it=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import pe from"mitt";import{dequal as me}from"dequal/lite";var he="__UNIFORM_DATA__",A,q,_=class{constructor({initialData:t}){d(this,A,void 0);d(this,q,pe());C(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&g(this,A,t)}get data(){return a(this,A)}updateData(t,r){return g(this,A,r),this.handleUpdateData(t,r)}async delete(t){g(this,A,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){me(this.data,t)||(g(this,A,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(he);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};A=new WeakMap,q=new WeakMap;var vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ft=vt.split(""),Qt=new Array(123);for(let e=0;e<vt.length;e++)Qt[vt.charCodeAt(e)]=e;var St=e=>{if(e<0)return`-${St(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=Ft[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=Ft[63&t]+n,t>>>=6;while(t>0);return n+i},Kt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+Qt[e.charCodeAt(i)];return r?-t:t};import yt from"js-cookie";var Dt=typeof document=="undefined",ge="ufvd",N,W,Ht=class extends _{constructor({serverCookieValue:r,cookieName:i=ge,cookieAttributes:n={sameSite:"lax"}}){super({initialData:Dt?ve(r):void 0});d(this,N,void 0);d(this,W,void 0);g(this,N,i),g(this,W,n)}handleDelete(){return Dt||yt.remove(a(this,N)),Promise.resolve()}async handleUpdateData(r,i){Dt||(i.consent?yt.set(a(this,N),Se(i),a(this,W)):yt.remove(a(this,N)))}};N=new WeakMap,W=new WeakMap;var Wt="~",Yt="!",Xt="-";function ve(e){if(!e)return;let t=e.split(Wt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Bt(Ct(i)),scores:Bt(Ct(n)),tests:Ct(r)}}function Ct(e){return e.split(Yt).map(r=>r.split(Xt)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Bt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Kt(i),t),{})}function Se(e){return[xt(e.tests),xt(Jt(e.sessionScores)),xt(Jt(e.scores))].join(Wt)}function Jt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=St(i),t),{})}function xt(e){return Object.entries(e).map(t=>t.join(Xt)).join(Yt)}var nt,Mt,Zt=class extends _{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,nt);n.initialData||D(this,nt,Mt).call(this).catch(s=>{console.error(s)})}handleDelete(r){throw new Error("Method not implemented.")}async handleUpdateData(r){let i=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)}};nt=new WeakSet,Mt=async function(){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)};function wr(e){let{gracePeriod:t=864e5,decayRate:r=1/30,decayCap:i=.95}=e!=null?e:{};return function({now:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let h=s-o-t;if(h<=0)return!1;let y=h/864e5,x=1-Math.min(i,y*r);return x<=0?!1:(Lt(u,x),Lt(c,x),l==null||l(["info",140,`linear decay factor ${x.toPrecision(6)}`]),!0)}}function Lt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}import Ce from"mitt";import{dequal as st}from"dequal/lite";var ot=class{constructor(){C(this,"inMemoryFallback",{});C(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let r=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||r)return r;try{let i=localStorage.getItem(t);return i?JSON.parse(i):void 0}catch(i){return r}}set(t,r,i){if(this.inMemoryFallback[t]=r,!(!this.hasLocalStorageObject||!i))try{localStorage.setItem(t,JSON.stringify(r))}catch(n){console.warn(n)}}delete(t,r){r||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(i){}}};import ye from"rfdc";var De=ye();function te(e,t,r){let i=t?De(t):it();return e.forEach(n=>{var s,o;switch(n.type){case"consent":i.consent=n.data;break;case"setquirk":i.quirks[n.data.key]=n.data.value;break;case"settest":i.tests[n.data.test]=n.data.variant;break;case"modscore":if(r)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(s=i.scores[n.data.dimension])!=null?s:0;i.scores[n.data.dimension]=c+u;break;case"modscoreS":if(r)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let m=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=m+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var at="ufvisitor",k,z,j,S,b,w,R,G,lt,ee,ct,re,Y,bt,X,Vt,ut=class{constructor(t){d(this,b);d(this,R);d(this,lt);d(this,ct);d(this,Y);d(this,X);d(this,k,Ce());d(this,z,new ot);d(this,j,void 0);d(this,S,void 0);C(this,"events",{on:a(this,k).on,off:a(this,k).off});if(g(this,S,t),a(this,b,w)||D(this,R,G).call(this,D(this,X,Vt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{D(this,R,G).call(this,{...a(this,b,w).visitorData,...n})});let i=t.transitionStore.data;i&&D(this,R,G).call(this,{...a(this,b,w).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,b,w);if(D(this,ct,re).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return D(this,R,G).call(this,{...s,sessionScores:{}}),(i=(r=a(this,S)).onLogMessage)==null||i.call(r,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,S).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,S)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=te(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,z).delete(at,!0),D(this,R,G).call(this,r),await((o=a(this,S).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,S)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,z).delete(at,!1),await((n=a(this,S).transitionStore)==null?void 0:n.delete(t)),D(this,R,G).call(this,D(this,X,Vt).call(this))}finally{(o=(s=a(this,S)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};k=new WeakMap,z=new WeakMap,j=new WeakMap,S=new WeakMap,b=new WeakSet,w=function(){return a(this,z).get(at)},R=new WeakSet,G=function(t,r=!1){var m,h,y,x,M,kt,Pt,wt,Rt;let i=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(D(this,Y,bt).call(this,t.scores),D(this,Y,bt).call(this,t.sessionScores),(h=(m=a(this,S)).decay)==null||h.call(m,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,S).onLogMessage}));let s=!st(i==null?void 0:i.visitorData.scores,t.scores),o=!st(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!st(i==null?void 0:i.visitorData.quirks,t.quirks),c=!st(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};D(this,lt,ee).call(this),a(this,z).set(at,l,!!t.consent),(x=(y=a(this,S)).onLogMessage)==null||x.call(y,["debug",102,t]),r||((s||o)&&a(this,k).emit("scoresUpdated",t),u&&a(this,k).emit("quirksUpdated",t),c&&a(this,k).emit("testsUpdated",t),((M=i==null?void 0:i.visitorData)==null?void 0:M.consent)!==t.consent&&a(this,k).emit("consentUpdated",t),((kt=i==null?void 0:i.visitorData)==null?void 0:kt.controlGroup)!==t.controlGroup&&(a(this,k).emit("controlGroupUpdated",t),(Rt=(wt=a(this,S)).onLogMessage)==null||Rt.call(wt,["debug",104,(Pt=t.controlGroup)!=null?Pt:!1])))},lt=new WeakSet,ee=function(){typeof document=="undefined"||!a(this,S).visitLifespan||(a(this,j)&&window.clearTimeout(a(this,j)),g(this,j,window.setTimeout(()=>{this.data},a(this,S).visitLifespan+50)))},ct=new WeakSet,re=function(t){let r=a(this,S).visitLifespan;return r?t.updated+r<Date.now():!1},Y=new WeakSet,bt=function(t){var r,i;if(!!a(this,S).manifest)for(let n in t){let s=t[n],o=a(this,S).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,S)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},X=new WeakSet,Vt=function(){var t,r,i;return{...it(),consent:(t=a(this,S).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,S).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};import be from"mitt";function ie({name:e,context:t,variations:r,take:i=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:i}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],m=!1,h=t.scores;for(let y of r){if(l.length===i)break;if(!((o=y.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:y.id,op:(u=y.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(y);continue}c||ne(y.id,y.pz,h,n)&&(m=!0,l.push(y))}return{personalized:m,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function ne(e,t,r,i){i==null||i(["info",301,"GROUP",{id:e,op:t==null?void 0:t.op}]);let n;try{t!=null&&t.crit?!t.op||t.op==="&"?n=t.crit.every(s=>oe(s,r,i)):n=t.crit.some(s=>oe(s,r,i)):(i==null||i(["info",302,{matched:!0,description:"default variation"}]),n=!0),i==null||i(["info",303,n])}finally{i==null||i(["info",301,"ENDGROUP"])}return n}function oe(e,t,r){var u,c;let{op:i,l:n}=e,s=(u=t[n])!=null?u:0;if(i==="+"){let l=Math.max(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(i==="-"){let l=Math.min(...Object.values(t))===s&&s>0;return r==null||r(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let o=e.rDim?t[e.rDim]:e.r;if(o===void 0)return r==null||r(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(i===">"){let l=s>o;return F(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return F(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return F(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return F(r,l,e,s,o),l}else if(i==="="){let l=s===o;return F(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return F(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function F(e,t,r,i,n){e==null||e(["info",302,{matched:t,description:`${r.l}[${i}] ${r.op} ${r.rDim?`${r.rDim}[${n}]`:r.r}`}])}var xe=e=>{let{values:t,total:r,missingDistribution:i}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.testDistribution),n),{values:[],total:0,missingDistribution:0});if(r>100)throw new Error(`Total distribution ${r} is over the maximum 100.`);if(r<100){let s=(100-r)/i;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},Et=({name:e,context:t,variations:r,onLogMessage:i})=>{i==null||i(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return i==null||i(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=r.find(o=>o.id===s),n||i==null||i(["warn",402,{missingVariant:s,variants:r.map(o=>o.id)}])),!n){let o=xe(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,m)=>{let h=o[m];if(u>c&&u<=c+h)return l;c+=h}),n&&(i==null||i(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(i==null||i(["info",404,n.id])),{result:n,variantAssigned:!s}}finally{i==null||i(["info",400,"ENDGROUP"])}};import{dequal as se}from"dequal/lite";var V,O,P,Z,v,Q,dt,ae=class{constructor(t){d(this,Q);C(this,"manifest");d(this,V,void 0);d(this,O,{});d(this,P,void 0);d(this,Z,{});d(this,v,be());C(this,"events",{on:a(this,v).on,off:a(this,v).off});C(this,"storage");var n,s;let{manifest:r,...i}=t;g(this,P,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,v).on("log",o.logDrain)}),a(this,v).emit("log",["info",1,"GROUP"]);try{this.manifest=new et({onLogMessage:o=>a(this,v).emit("log",o),manifest:r,evaluator:new I({CK:Nt,QS:It,QK:qt,PVC:gt,EVT:_t,PV:jt})}),this.storage=new ut({...i,manifest:this.manifest,onServerTransitionReceived:o=>{g(this,V,o),o.ssv&&(g(this,O,o.ssv),a(this,v).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,v).emit("log",o)}),this.storage.events.on("scoresUpdated",D(this,Q,dt).bind(this)),a(this,V)||D(this,Q,dt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,O),state:a(this,P),previousState:a(this,P),visitor:this.storage.data});this.storage.updateData(u),a(this,v).emit("quirksUpdated",o.quirks),a(this,v).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,v).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,O)}async update(t){var i,n,s;let r=[];(i=a(this,V))!=null&&i.quirks&&(t={...t,quirks:{...a(this,V).quirks,...t.quirks||{}}}),(n=a(this,V))!=null&&n.tests&&r.push(...Object.entries(a(this,V).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,v).emit("log",["info",2,"GROUP",{...t,url:(s=t.url)==null?void 0:s.toString()}]),t.quirks&&r.push(...Object.entries(t.quirks).map(([o,u])=>({type:"setquirk",data:{key:o,value:u}}))),t.enrichments&&t.enrichments.forEach(o=>{let u=rt(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,v).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,P),visitor:this.storage.data,scores:a(this,O)})),g(this,P,{...a(this,P),...t}),await this.storage.updateData(r),a(this,V)&&(D(this,Q,dt).call(this,this.storage.data),g(this,V,void 0),a(this,v).emit("log",["debug",131]))}finally{a(this,v).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var i;let r=this.manifest.getTest(t);return r?(i=r.wv)!=null?i:this.storage.data.tests[t]:(a(this,v).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,v).emit("log",t)}test(t){var i,n;let r=Et({...t,context:this,onLogMessage:s=>a(this,v).emit("log",s)});return a(this,v).emit("testResult",{name:t.name,variantId:(n=(i=r.result)==null?void 0:i.id)!=null?n:void 0,variantAssigned:r.variantAssigned}),r}personalize(t){let r=ie({...t,context:this,onLogMessage:s=>a(this,v).emit("log",s)}),i=a(this,Z)[t.name],n={name:t.name,variantIds:r.variations.map(s=>{var o;return(o=s.id)!=null?o:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return i&&se(n.variantIds,i)&&(n.changed=!1),a(this,v).emit("personalizationResult",n),a(this,Z)[t.name]=n.variantIds,r}async forget(t){g(this,P,{}),await this.storage.delete(t)}};V=new WeakMap,O=new WeakMap,P=new WeakMap,Z=new WeakMap,v=new WeakMap,Q=new WeakSet,dt=function(t){var n;let r={...t.scores};for(let s in t.sessionScores)r[s]=((n=r[s])!=null?n:0)+t.sessionScores[s];r=this.manifest.computeAggregateDimensions(r),!se(r,a(this,O))&&(g(this,O,r),a(this,v).emit("scoresUpdated",r),a(this,v).emit("log",["info",3,r]))};import Ve from"rfdc";function ft(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var Ee=Ve();function Te(e){return([t,...r])=>{if(!ft(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
|
2
|
+
`,...n.map(Ee))}}function mi(e){return{logDrain:Te(e)}}var ue={1:()=>["context","initializing Uniform Context"],2:e=>["context","received update()",e],3:e=>["context","new score vector",e],4:e=>["context","updated quirks",e],5:e=>["context","ignored enrichment update for unknown enrichment category",e.cat],101:e=>["storage","received update commands",e],102:e=>["storage","data was updated",e],103:e=>["storage",`deleting visitor data ${e?"from all devices":"from this device"}`],104:e=>["context",e?"Visitor assigned to personalization control group":"Visitor assigned to personalization experiment group"],110:({dim:e,cap:t,score:r})=>["storage",`${e} score ${r} exceeded cap ${t}. Rounded down.`],120:()=>["storage","visitor data expired and was cleared"],130:e=>["storage","server to client transition score data was loaded; it will persist until the next update event occurs",e],131:()=>["storage","server to client transition data was discarded"],140:e=>["storage",`score decay was applied: ${e}`],200:()=>["signals","evaluating signals"],201:e=>["signals",`evaluating signal ${e.id} (${e.dur})`],202:e=>["signals",e.op==="|"?"OR":"AND"],203:({criteria:e,result:t,explanation:r})=>["signals",`${e.type}: ${r} is ${t.result} [${t.changed?"CHANGED":"unchanged"}]`],204:e=>["signals",`group result: ${e.result} [${e.changed?"CHANGED":"unchanged"}]`],300:e=>["personalization",`executing personalization '${e.name}'`],301:({id:e,op:t})=>["personalization",`testing variation ${e} (${t==="|"?"OR":"AND"})`],302:({matched:e,description:t})=>["personalization",`${t} is ${e}`],303:e=>["personalization",e?"selected variation":"did not select variation"],400:e=>["testing",`executing A/B test '${e}'`],401:e=>["testing",`${e} is not registered in the manifest; it will not be run.`],402:({missingVariant:e,variants:t})=>["testing",`test variation '${e}' previously assigned to the visitor for this test no longer exists as a variant. It will be removed. This may indicate changing test variations after publishing a test, which will make results invalid. Known variants: ${t.join(", ")}`],403:e=>["testing",`assigned new test variant '${e}'`],404:e=>["testing",`displaying variation '${e}'`],700:()=>["gtag","gtag is not defined, skipping analytics event emission. Ensure you have added the gtag script to your page."],701:()=>["gtag","enabled gtag event signal redirection"]};import ke from"rfdc";var Pe=ke();function we(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ft(e,n)||r&&!i)return;let[o,...u]=s,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=ue[o],m="";switch(n){case"debug":m="\u{1F41E}";break;case"info":m="\u{1F4AC}";break;case"warn":m="\u26A0\uFE0F";break;case"error":m="\u{1F4A5}";break}let h=m;if(!l){c(`${h} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[y,x,...M]=l(...u);c(`${h}[${y}] ${x}
|
3
|
+
`,...M.map(Pe))}}function Di(e,t){return{logDrain:we(e,t)}}var Re=(u=>(u.ListStart="nesi-list-start",u.ListEnd="nesi-list-end",u.ListItem="nesi-list-item-html",u.ListItemSettings="nesi-list-item-settings",u.TestStart="nesi-test-start",u.TestEnd="nesi-test-end",u.Unknown="unknown",u))(Re||{}),xi="nesitag";var Tt=typeof top!="undefined";function Vi(){return{logDrain:e=>{!Tt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!Tt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:r}},window.location.origin)},n=o=>{!o.changed||(t.push(o),i())},s=o=>{!o.variantAssigned||(r.push(o),i())};if(Tt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Oe(u,e)})}catch(o){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",o)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),i()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),e.events.on("scoresUpdated",i),e.storage.events.on("*",i),()=>{e.events.off("scoresUpdated",i),e.storage.events.off("*",i),e.events.off("personalizationResult",n),e.events.off("testResult",s)}}}}async function Oe(e,t){e.type==="uniform-in:context:update"&&e.newData&&await t.update(e.newData),e.type==="uniform-in:context:commands"&&e.commands&&Array.isArray(e.commands)&&await t.storage.updateData(e.commands),e.type==="uniform-in:context:forget"&&await t.forget(!1)}function Ti(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function ki(e){let[t,r,i]=e.split("|");if(!t.startsWith("uf"))throw new Error("Invalid API key");if(!/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/i.test(r))throw new Error("Invalid project ID");return{apiKey:t,projectId:r,apiHost:i||"https://uniform.app"}}export{ae as Context,Ht as CookieTransitionDataStore,xi as EdgeNodeTagName,Zt as EdgeTransitionDataStore,I as GroupCriteriaEvaluator,et as ManifestInstance,he as SERVER_STATE_ID,Re as ScriptType,_ as TransitionDataStore,ge as UNIFORM_DEFAULT_COOKIE_NAME,ut as VisitorDataStore,Ot as computeAggregateDimensions,Nt as cookieEvaluator,Te as createConsoleLogDrain,we as createDebugConsoleLogDrain,wr as createLinearDecay,jt as currentPageEvaluator,it as emptyVisitorData,mi as enableConsoleLogDrain,Vi as enableContextDevTools,Di as enableDebugConsoleLogDrain,ne as evaluateVariantMatch,_t as eventEvaluator,$ as explainStringMatch,mt as explainStringMatchCriteria,rt as getEnrichmentVectorKey,T as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,ki as parseQuickConnect,ie as personalizeVariations,It as queryStringEvaluator,qt as quirkEvaluator,Ti as serializeQuickConnect,Et as testVariations};
|