@uniformdev/context 16.0.1-nuxt.157 → 16.0.1-nuxt.166

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/dist/api/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as AggregateGetParameters, b as AggregateGetResponse, c as AggregatePutParameters, d as AggregateDeleteParameters, D as DimensionGetParameters, e as DimensionGetResponse, f as EnrichmentGetParameters, g as EnrichmentGetResponse, h as EnrichmentPutParameters, i as EnrichmentDeleteParameters, j as EnrichmentValuePutParameters, k as EnrichmentValueDeleteParameters, M as ManifestGetParameters, l as ManifestGetResponse, m as QuirkGetParameters, n as QuirkGetResponse, o as QuirkPutParameters, p as QuirkDeleteParameters, q as SignalGetParameters, r as SignalGetResponse, s as SignalPutParameters, t as SignalDeleteParameters, u as TestGetParameters, v as TestGetResponse, w as TestPutParameters, x as TestDeleteParameters, y as DimensionDefinition } from '../contextTypes-572b0d33.js';
2
2
  export { A as Aggregate, d as AggregateDeleteParameters, a as AggregateGetParameters, b as AggregateGetResponse, c as AggregatePutParameters, C as CookieCriteria, I as CurrentPageCriteria, y as DimensionDefinition, D as DimensionGetParameters, e as DimensionGetResponse, z as EnrichmentCategory, E as EnrichmentCategoryWithValues, i as EnrichmentDeleteParameters, f as EnrichmentGetParameters, g as EnrichmentGetResponse, h as EnrichmentPutParameters, B as EnrichmentValue, k as EnrichmentValueDeleteParameters, j as EnrichmentValuePutParameters, H as EventCriteria, M as ManifestGetParameters, l as ManifestGetResponse, P as PageViewCountCriteria, F as QueryStringCriteria, Q as Quirk, G as QuirkCriteria, p as QuirkDeleteParameters, m as QuirkGetParameters, n as QuirkGetResponse, o as QuirkPutParameters, R as RootSignalCriteriaGroup, t as SignalDeleteParameters, q as SignalGetParameters, r as SignalGetResponse, s as SignalPutParameters, S as SignalWithId, T as Test, x as TestDeleteParameters, u as TestGetParameters, v as TestGetResponse, w as TestPutParameters } from '../contextTypes-572b0d33.js';
3
- import { g as ManifestV2 } from '../types-876fb8b8.js';
3
+ import { g as ManifestV2 } from '../types-76b5592d.js';
4
4
  import '../v2-manifest.swagger-ff2af13e.js';
5
5
  import 'mitt';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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-876fb8b8.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-876fb8b8.js';
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-76b5592d.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-76b5592d.js';
3
3
  import Cookies from 'js-cookie';
4
4
  import './v2-manifest.swagger-ff2af13e.js';
5
5
  import 'mitt';
package/dist/index.esm.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var ae=Object.defineProperty;var ue=(e,t,r)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var y=(e,t,r)=>(ue(e,typeof t!="symbol"?t+"":t,r),r),dt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(dt(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)},m=(e,t,r,i)=>(dt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var S=(e,t,r)=>(dt(e,t,"access private method"),r);function wt(e,t){let r={...e};for(let i in t){let n=Rt(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Rt(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=Rt(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 Z="_";var Q,F,M=class{constructor(t,r,i){d(this,Q,void 0);d(this,F,void 0);y(this,"signal");this.signal=t,m(this,Q,r),m(this,F,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,r,this.signal,a(this,F)),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}})}}}};Q=new WeakMap,F=new WeakMap;var b,K,R,L=class{constructor({manifest:t,evaluator:r=new G({}),onLogMessage:i=()=>{}}){y(this,"data");d(this,b,void 0);d(this,K,void 0);d(this,R,void 0);var n,s,o;m(this,b,(n=t.project)!=null?n:{}),this.data=t,m(this,K,Object.entries((o=(s=a(this,b).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new M({...c,id:u},r,i))),m(this,R,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,b).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,b).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,K).forEach(i=>{a(this,R).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return wt(t,(i=(r=a(this,b).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(Z);return r<=0?(n=(i=a(this,b).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,b).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};b=new WeakMap,K=new WeakMap,R=new WeakMap;import{dequal as le}from"dequal/lite";function V(e,t){var o,u,c,l,f,p;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:"":Ot(e)).toString(),s=(i?t.rhs:Ot(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((f=e==null?void 0:e.toString())!=null?f:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");default:throw new Error(`Unknown match type ${r}.`)}}function O(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ft(t)}`}function ft(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Ot(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var $t=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!le(Ut(e.state.cookies),Ut((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:V(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};function Ut(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Nt(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 At(e,t){return`${e} ${ce(t)}`}function ce(e){return`${e.op} ${e.rhs}`}function tt(e,t){return`${e}${Z}${t}`}var pt=tt("$pvc","v"),mt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,f;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())!==((f=e.previousState.url)==null?void 0:f.toString()))),o=(e.visitor.sessionScores[pt]||0)+1,u={result:!1,changed:n},c=r.some(p=>p.type==="modscoreS"&&p.data.dimension===pt);return n&&!c&&r.push({type:"modscoreS",data:{dimension:pt,delta:1}}),Nt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:At(o,t.match)}]),u};mt.alwaysExecute=!0;var Gt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,f,p;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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(p=e.state.url)==null?void 0:p.searchParams.get(t.queryName),o={result:V(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};var zt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var f;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=(f=e.state.quirks)==null?void 0:f[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:V(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:O(o,t.match)}]),l};var It=({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=>V(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("', '")}' ${ft(t.event)}`}]),n};var qt=({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:V(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(i,t.path)}]),o};var H,G=class{constructor(t){d(this,H,void 0);m(this,H,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 p of r.clauses){let v;if(p.type==="G")v=this.evaluate(t,p,i,n,s);else{let D=a(this,H)[p.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${p.type} signal criteria not registered`);v=D({update:t,criteria:p,commands:i,signal:n,onLogMessage:s})}v.changed&&(l=!0),!c&&v.result===u&&(c={result:u,changed:l})}let f=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,f])),f}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};H=new WeakMap;var et=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import de from"mitt";import{dequal as fe}from"dequal/lite";var pe="__UNIFORM_DATA__",U,z,I=class{constructor({initialData:t}){d(this,U,void 0);d(this,z,de());y(this,"events",{on:a(this,z).on,off:a(this,z).off});t&&m(this,U,t)}get data(){return a(this,U)}updateData(t,r){return m(this,U,r),this.handleUpdateData(t,r)}async delete(t){m(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){fe(this.data,t)||(m(this,U,t),a(this,z).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(pe);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,z=new WeakMap;var ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_t=ht.split(""),jt=new Array(123);for(let e=0;e<ht.length;e++)jt[ht.charCodeAt(e)]=e;var gt=e=>{if(e<0)return`-${gt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=_t[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=_t[63&t]+n,t>>>=6;while(t>0);return n+i},Qt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+jt[e.charCodeAt(i)];return r?-t:t};import vt from"js-cookie";var St=typeof document=="undefined",me="ufvd",$,B,Ft=class extends I{constructor({serverCookieValue:r,cookieName:i=me,cookieAttributes:n={sameSite:"lax"}}){super({initialData:St?he(r):void 0});d(this,$,void 0);d(this,B,void 0);m(this,$,i),m(this,B,n)}handleDelete(){return St||vt.remove(a(this,$)),Promise.resolve()}async handleUpdateData(r,i){St||(i.consent?vt.set(a(this,$),ge(i),a(this,B)):vt.remove(a(this,$)))}};$=new WeakMap,B=new WeakMap;var Bt="~",Jt="!",Wt="-";function he(e){if(!e)return;let t=e.split(Bt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Kt(yt(i)),scores:Kt(yt(n)),tests:yt(r)}}function yt(e){return e.split(Jt).map(r=>r.split(Wt)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Kt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Qt(i),t),{})}function ge(e){return[Dt(e.tests),Dt(Ht(e.sessionScores)),Dt(Ht(e.scores))].join(Bt)}function Ht(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=gt(i),t),{})}function Dt(e){return Object.entries(e).map(t=>t.join(Wt)).join(Jt)}var rt,Xt,Yt=class extends I{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,rt);n.initialData||S(this,rt,Xt).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)}};rt=new WeakSet,Xt=async function(){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)};function kr(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 p=s-o-t;if(p<=0)return!1;let v=p/864e5,D=1-Math.min(i,v*r);return D<=0?!1:(Zt(u,D),Zt(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function Zt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}import ye from"mitt";import{dequal as nt}from"dequal/lite";var it=class{constructor(){y(this,"inMemoryFallback",{});y(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 ve from"rfdc";var Se=ve();function Mt(e,t,r){let i=t?Se(t):et();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 f=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ot="ufvisitor",E,A,q,g,x,k,P,N,at,Lt,ut,te,J,Ct,W,xt,st=class{constructor(t){d(this,x);d(this,P);d(this,at);d(this,ut);d(this,J);d(this,W);d(this,E,ye());d(this,A,new it);d(this,q,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(m(this,g,t),a(this,x,k)||S(this,P,N).call(this,S(this,W,xt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{S(this,P,N).call(this,{...a(this,x,k).visitorData,...n})});let i=t.transitionStore.data;i&&S(this,P,N).call(this,{...a(this,x,k).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,x,k);if(S(this,ut,te).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return S(this,P,N).call(this,{...s,sessionScores:{}}),(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",120]),a(this,x,k).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,g)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=Mt(t,this.data,(s=a(this,x,k))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,A).delete(ot,!0),S(this,P,N).call(this,r),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,x,k).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,A).delete(ot,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),S(this,P,N).call(this,S(this,W,xt).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};E=new WeakMap,A=new WeakMap,q=new WeakMap,g=new WeakMap,x=new WeakSet,k=function(){return a(this,A).get(ot)},P=new WeakSet,N=function(t,r=!1){var f,p,v,D,X,Et,Tt,kt,Pt;let i=a(this,x,k),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,J,Ct).call(this,t.scores),S(this,J,Ct).call(this,t.sessionScores),(p=(f=a(this,g)).decay)==null||p.call(f,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!nt(i==null?void 0:i.visitorData.scores,t.scores),o=!nt(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!nt(i==null?void 0:i.visitorData.quirks,t.quirks),c=!nt(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};S(this,at,Lt).call(this),a(this,A).set(ot,l,!!t.consent),(D=(v=a(this,g)).onLogMessage)==null||D.call(v,["debug",102,t]),r||((s||o)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((X=i==null?void 0:i.visitorData)==null?void 0:X.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Et=i==null?void 0:i.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Pt=(kt=a(this,g)).onLogMessage)==null||Pt.call(kt,["debug",104,(Tt=t.controlGroup)!=null?Tt:!1])))},at=new WeakSet,Lt=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,q)&&window.clearTimeout(a(this,q)),m(this,q,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},ut=new WeakSet,te=function(t){let r=a(this,g).visitLifespan;return r?t.updated+r<Date.now():!1},J=new WeakSet,Ct=function(t){var r,i;if(!!a(this,g).manifest)for(let n in t){let s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,g)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},W=new WeakSet,xt=function(){var t,r,i;return{...et(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,g).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};import Ce from"mitt";function ee({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=[],f=!1,p=t.scores;for(let v of r){if(l.length===i)break;if(!((o=v.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:v.id,op:(u=v.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(v);continue}c||re(v.id,v.pz,p,n)&&(f=!0,l.push(v))}return{personalized:f,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function re(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=>ie(s,r,i)):n=t.crit.some(s=>ie(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 ie(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=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(o))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 _(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return _(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return _(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return _(r,l,e,s,o),l}else if(i==="="){let l=s===o;return _(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return _(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function _(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 De=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},bt=({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=De(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,f)=>{let p=o[f];if(u>c&&u<=c+p)return l;c+=p}),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 ne}from"dequal/lite";var C,w,T,Y,h,j,lt,oe=class{constructor(t){d(this,j);y(this,"manifest");d(this,C,void 0);d(this,w,{});d(this,T,void 0);d(this,Y,{});d(this,h,Ce());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:r,...i}=t;m(this,T,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,h).on("log",o.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new L({onLogMessage:o=>a(this,h).emit("log",o),manifest:r,evaluator:new G({CK:$t,QS:Gt,QK:zt,PVC:mt,EVT:It,PV:qt})}),this.storage=new st({...i,manifest:this.manifest,onServerTransitionReceived:o=>{m(this,C,o),o.ssv&&(m(this,w,o.ssv),a(this,h).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",S(this,j,lt).bind(this)),a(this,C)||S(this,j,lt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,w),state:a(this,T),previousState:a(this,T),visitor:this.storage.data});this.storage.updateData(u),a(this,h).emit("quirksUpdated",o.quirks),a(this,h).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,w)}get quirks(){var t,r;return(r=(t=a(this,C))==null?void 0:t.quirks)!=null?r:this.storage.data.quirks}async update(t){var i,n,s;let r=[];(i=a(this,C))!=null&&i.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(n=a(this,C))!=null&&n.tests&&r.push(...Object.entries(a(this,C).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,h).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=tt(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,T),visitor:this.storage.data,scores:a(this,w)})),m(this,T,{...a(this,T),...t}),await this.storage.updateData(r),a(this,C)&&(S(this,j,lt).call(this,this.storage.data),m(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).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,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,h).emit("log",t)}test(t){var i,n;let r=bt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)});return a(this,h).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=ee({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)}),i=a(this,Y)[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&&ne(n.variantIds,i)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,Y)[t.name]=n.variantIds,r}async forget(t){m(this,T,{}),await this.storage.delete(t)}};C=new WeakMap,w=new WeakMap,T=new WeakMap,Y=new WeakMap,h=new WeakMap,j=new WeakSet,lt=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),!ne(r,a(this,w))&&(m(this,w,r),a(this,h).emit("scoresUpdated",r),a(this,h).emit("log",["info",3,r]))};import xe from"rfdc";function ct(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 be=xe();function Ve(e){return([t,...r])=>{if(!ct(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
- `,...n.map(be))}}function fi(e){return{logDrain:Ve(e)}}var se={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 Ee from"rfdc";var Te=Ee();function ke(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ct(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=se[o],f="";switch(n){case"debug":f="\u{1F41E}";break;case"info":f="\u{1F4AC}";break;case"warn":f="\u26A0\uFE0F";break;case"error":f="\u{1F4A5}";break}let p=f;if(!l){c(`${p} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[v,D,...X]=l(...u);c(`${p}[${v}] ${D}
3
- `,...X.map(Te))}}function Si(e,t){return{logDrain:ke(e,t)}}var Pe=(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))(Pe||{}),Di="nesitag";var Vt=typeof top!="undefined";function xi(){return{logDrain:e=>{!Vt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!Vt||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(Vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await we(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 we(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 Vi(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function Ei(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{oe as Context,Ft as CookieTransitionDataStore,Di as EdgeNodeTagName,Yt as EdgeTransitionDataStore,G as GroupCriteriaEvaluator,L as ManifestInstance,pe as SERVER_STATE_ID,Pe as ScriptType,I as TransitionDataStore,me as UNIFORM_DEFAULT_COOKIE_NAME,st as VisitorDataStore,wt as computeAggregateDimensions,$t as cookieEvaluator,Ve as createConsoleLogDrain,ke as createDebugConsoleLogDrain,kr as createLinearDecay,qt as currentPageEvaluator,et as emptyVisitorData,fi as enableConsoleLogDrain,xi as enableContextDevTools,Si as enableDebugConsoleLogDrain,re as evaluateVariantMatch,It as eventEvaluator,O as explainStringMatch,ft as explainStringMatchCriteria,tt as getEnrichmentVectorKey,V as isStringMatch,pt as pageViewCountDimension,mt as pageViewCountEvaluator,Ei as parseQuickConnect,ee as personalizeVariations,Gt as queryStringEvaluator,zt as quirkEvaluator,Vi as serializeQuickConnect,bt as testVariations};
1
+ "use strict";var ce=Object.defineProperty;var de=(e,t,i)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var y=(e,t,i)=>(de(e,typeof t!="symbol"?t+"":t,i),i),ft=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(ft(e,t,"read from private field"),i?i.call(e):t.get(e)),d=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},f=(e,t,i,r)=>(ft(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(ft(e,t,"access private method"),i);function Ut(e,t){let i={...e};for(let r in t){let n=$t(e,r,t,new Set([r]));n!==0&&(i[r]=n)}return i}function $t(e,t,i,r){var o;let n=0;for(let s of i[t].inputs){let u=(o=e[s.dim])!=null?o:0;if(!u&&i[s.dim]){if(r.has(s.dim))continue;let l=new Set(r);l.add(s.dim),u=$t(e,s.dim,i,l)}if(u!==0)if(s.sign==="c"){n=0;break}else s.sign==="-"?n-=u:n+=u}return n}var L="_";var Q,F,tt=class{constructor(t,i,r){d(this,Q,void 0);d(this,F,void 0);y(this,"signal");this.signal=t,f(this,Q,i),f(this,F,r)}computeSignal(t,i){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,i,this.signal,a(this,F)),o=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.push({type:o,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let s=t.visitor.sessionScores[this.signal.id];s&&i.push({type:o,data:{dimension:this.signal.id,delta:-s}})}}}};Q=new WeakMap,F=new WeakMap;var b,K,R,et=class{constructor({manifest:t,evaluator:i=new G({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,b,void 0);d(this,K,void 0);d(this,R,void 0);var n,o,s;f(this,b,(n=t.project)!=null?n:{}),this.data=t,f(this,K,Object.entries((s=(o=a(this,b).pz)==null?void 0:o.sig)!=null?s:[]).map(([u,c])=>new tt({...c,id:u},i,r))),f(this,R,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,b).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,b).test)==null?void 0:i[t]}computeSignals(t){let i=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,K).forEach(r=>{a(this,R).call(this,["debug",201,"GROUP",r.signal]);try{r.computeSignal(t,i)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return i}computeAggregateDimensions(t){var i,r;return Ut(t,(r=(i=a(this,b).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,o,s;let i=t.indexOf(L);return i<=0?(n=(r=a(this,b).pz)==null?void 0:r.sig)==null?void 0:n[t]:(s=(o=a(this,b).pz)==null?void 0:o.enr)==null?void 0:s[t.substring(0,i)]}};b=new WeakMap,K=new WeakMap,R=new WeakMap;import{dequal as pe}from"dequal/lite";function V(e,t){var s,u,c,l,p,m;let i=(s=t==null?void 0:t.op)!=null?s:"=";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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":At(e)).toString(),o=(r?t.rhs:At(t.rhs)).toString();switch(i){case"=":return n===o;case"!=":return n!==o;case"~":return(c=n.includes(o))!=null?c:!1;case"!~":return!((l=n.includes(o))==null||l);case"//":return new RegExp(t.rhs.toString(),r?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");case"!//":return!new RegExp(t.rhs.toString(),r?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${i}.`)}}function O(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 At(e){var t,i;return(i=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?i:""}var Gt=({update:e,criteria:t,onLogMessage:i})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let r=!pe(Nt(e.state.cookies),Nt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],s={result:V(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(n,t.match)}]),s};function Nt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...i}=e;return i}function zt(e,t){var r;if(typeof e=="undefined"||e===null)return!1;let i=Number(e);if(isNaN(i))return!1;switch((r=t==null?void 0:t.op)!=null?r:"="){case"=":return i===t.rhs;case"!=":return i!==t.rhs;case">":return i>t.rhs;case"<":return i<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function It(e,t){return`${e} ${fe(t)}`}function fe(e){return`${e.op} ${e.rhs}`}function it(e,t){return`${e}${L}${t}`}var ht=it("$pvc","v"),gt=({update:e,criteria:t,commands:i,onLogMessage:r})=>{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()))),s=(e.visitor.sessionScores[ht]||0)+1,u={result:!1,changed:n},c=i.some(m=>m.type==="modscoreS"&&m.data.dimension===ht);return n&&!c&&i.push({type:"modscoreS",data:{dimension:ht,delta:1}}),zt(s,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:It(s,t.match)}]),u};gt.alwaysExecute=!0;var qt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,p,m;if(t.type!=="QS")return{result:!1,changed:!1};let r=!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),s={result:V(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(n,t.match)}]),s};var _t=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var p;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&i.dur==="t"&&e.scores[i.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],o=(p=e.state.quirks)==null?void 0:p[t.key],s=o!=null?o:n,u=Boolean(o&&n!==o),l={result:V(s,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:O(s,t.match)}]),l};var jt=({update:e,criteria:t,onLogMessage:i})=>{var o,s,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(s=(o=e.state.events)==null?void 0:o.some(c=>V(c.event,t.event)))!=null?s:!1,n={result:r,changed:r};return i==null||i(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${mt(t.event)}`}]),n};var Qt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let r=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(r==null?void 0:r.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),s={result:V(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(r,t.path)}]),s};var H,G=class{constructor(t){d(this,H,void 0);f(this,H,t)}evaluate(t,i,r,n,o){let s=i.clauses.length>1;s&&(o==null||o(["debug",202,"GROUP",i]));try{let u=!(i.op==="&"||!i.op),c=null,l=!1;for(let m of i.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,r,n,o);else{let D=a(this,H)[m.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${m.type} signal criteria not registered`);S=D({update:t,criteria:m,commands:r,signal:n,onLogMessage:o})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let p=c!=null?c:{result:!u,changed:l};return s&&(o==null||o(["debug",204,p])),p}finally{s&&(o==null||o(["debug",202,"ENDGROUP"]))}}};H=new WeakMap;var rt=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import me from"mitt";import{dequal as he}from"dequal/lite";var ge="__UNIFORM_DATA__",U,B,z,I=class{constructor({initialData:t}){d(this,U,void 0);d(this,B,void 0);d(this,z,me());y(this,"events",{on:a(this,z).on,off:a(this,z).off});t&&(f(this,U,t),f(this,B,t))}get data(){return a(this,U)}get initialData(){return a(this,B)}updateData(t,i){return f(this,U,i),this.handleUpdateData(t,i)}async delete(t){f(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){he(this.data,t)||(f(this,U,t),a(this,z).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(ge);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,B=new WeakMap,z=new WeakMap;var vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ft=vt.split(""),Kt=new Array(123);for(let e=0;e<vt.length;e++)Kt[vt.charCodeAt(e)]=e;var St=e=>{if(e<0)return`-${St(-e)}`;let t=e>>>0,i=e/4294967296>>>0,r="";for(;i>0;)r=Ft[63&t]+r,t>>>=6,t|=(63&i)<<26,i>>>=6;let n="";do n=Ft[63&t]+n,t>>>=6;while(t>0);return n+r},Ht=e=>{let t=0,i=e.charAt(0)==="-"?1:0;for(let r=i;r<e.length;r++)t=t*64+Kt[e.charCodeAt(r)];return i?-t:t};import yt from"js-cookie";var Dt=typeof document=="undefined",ve="ufvd",$,J,Bt=class extends I{constructor({serverCookieValue:i,cookieName:r=ve,cookieAttributes:n={sameSite:"lax"}}){super({initialData:Dt?Se(i):void 0});d(this,$,void 0);d(this,J,void 0);f(this,$,r),f(this,J,n)}handleDelete(){return Dt||yt.remove(a(this,$)),Promise.resolve()}async handleUpdateData(i,r){Dt||(r.consent?yt.set(a(this,$),ye(r),a(this,J)):yt.remove(a(this,$)))}};$=new WeakMap,J=new WeakMap;var Yt="~",Xt="!",Zt="-";function Se(e){if(!e)return;let t=e.split(Yt);if(t.length>3)return;let[i,r,n]=t;return{consent:!0,sessionScores:Jt(Ct(r)),scores:Jt(Ct(n)),tests:Ct(i)}}function Ct(e){return e.split(Xt).map(i=>i.split(Zt)).reduce((i,r)=>(r.length!==2||(i[r[0]]=r[1]),i),{})}function Jt(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=Ht(r),t),{})}function ye(e){return[xt(e.tests),xt(Wt(e.sessionScores)),xt(Wt(e.scores))].join(Yt)}function Wt(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=St(r),t),{})}function xt(e){return Object.entries(e).map(t=>t.join(Zt)).join(Xt)}var nt,Lt,Mt=class extends I{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,nt);n.initialData||v(this,nt,Lt).call(this).catch(o=>{console.error(o)})}handleDelete(i){throw new Error("Method not implemented.")}async handleUpdateData(i){let r=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};nt=new WeakSet,Lt=async function(){let i=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)};function Ri(e){let{gracePeriod:t=864e5,decayRate:i=1/30,decayCap:r=.95}=e!=null?e:{};return function({now:o,lastUpd:s,scores:u,sessionScores:c,onLogMessage:l}){if(typeof s!="number")return!1;let m=o-s-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(te(u,D),te(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function te(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}import xe from"mitt";import{dequal as st}from"dequal/lite";var ot=class{constructor(){y(this,"inMemoryFallback",{});y(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let i=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||i)return i;try{let r=localStorage.getItem(t);return r?JSON.parse(r):void 0}catch(r){return i}}set(t,i,r){if(this.inMemoryFallback[t]=i,!(!this.hasLocalStorageObject||!r))try{localStorage.setItem(t,JSON.stringify(i))}catch(n){console.warn(n)}}delete(t,i){i||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(r){}}};import De from"rfdc";var Ce=De();function ee(e,t,i){let r=t?Ce(t):rt();return e.forEach(n=>{var o,s;switch(n.type){case"consent":r.consent=n.data;break;case"setquirk":r.quirks[n.data.key]=n.data.value;break;case"settest":r.tests[n.data.test]=n.data.variant;break;case"modscore":if(i)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(o=r.scores[n.data.dimension])!=null?o:0;r.scores[n.data.dimension]=c+u;break;case"modscoreS":if(i)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let p=(s=r.sessionScores[n.data.dimension])!=null?s:0;r.sessionScores[n.data.dimension]=p+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var at="ufvisitor",E,N,q,g,x,P,w,A,lt,ie,ct,re,W,bt,Y,Vt,ut=class{constructor(t){d(this,x);d(this,w);d(this,lt);d(this,ct);d(this,W);d(this,Y);d(this,E,xe());d(this,N,new ot);d(this,q,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(f(this,g,t),a(this,x,P)||v(this,w,A).call(this,v(this,Y,Vt).call(this),!0),t.transitionStore){let i=t.transitionStore.getClientTransitionState();i&&t.onServerTransitionReceived&&t.onServerTransitionReceived(i),t.transitionStore.events.on("dataUpdatedAsync",n=>{v(this,w,A).call(this,{...a(this,x,P).visitorData,...n})});let r=t.transitionStore.data;r&&v(this,w,A).call(this,{...a(this,x,P).visitorData,...r},!0)}}get data(){var i,r;let t=a(this,x,P);if(v(this,ct,re).call(this,t)){let{sessionScores:n,...o}=t.visitorData;return v(this,w,A).call(this,{...o,sessionScores:{}}),(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",120]),a(this,x,P).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}get options(){return a(this,g)}async updateData(t){var r,n,o,s;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=ee(t,this.data,(o=a(this,x,P))==null?void 0:o.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,N).delete(at,!0),v(this,w,A).call(this,i),await((s=a(this,g).transitionStore)==null?void 0:s.updateData(t,a(this,x,P).visitorData))}async delete(t){var i,r,n,o,s;(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",103,"GROUP",t]);try{a(this,N).delete(at,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),v(this,w,A).call(this,v(this,Y,Vt).call(this))}finally{(s=(o=a(this,g)).onLogMessage)==null||s.call(o,["info",103,"ENDGROUP"])}}};E=new WeakMap,N=new WeakMap,q=new WeakMap,g=new WeakMap,x=new WeakSet,P=function(){return a(this,N).get(at)},w=new WeakSet,A=function(t,i=!1){var p,m,S,D,M,Pt,wt,Rt,Ot;let r=a(this,x,P),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,W,bt).call(this,t.scores),v(this,W,bt).call(this,t.sessionScores),(m=(p=a(this,g)).decay)==null||m.call(p,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let o=!st(r==null?void 0:r.visitorData.scores,t.scores),s=!st(r==null?void 0:r.visitorData.sessionScores,t.sessionScores),u=!st(r==null?void 0:r.visitorData.quirks,t.quirks),c=!st(r==null?void 0:r.visitorData.tests,t.tests),l={updated:n,visitorData:t};v(this,lt,ie).call(this),a(this,N).set(at,l,!!t.consent),(D=(S=a(this,g)).onLogMessage)==null||D.call(S,["debug",102,t]),i||((o||s)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((M=r==null?void 0:r.visitorData)==null?void 0:M.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Pt=r==null?void 0:r.visitorData)==null?void 0:Pt.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Ot=(Rt=a(this,g)).onLogMessage)==null||Ot.call(Rt,["debug",104,(wt=t.controlGroup)!=null?wt:!1])))},lt=new WeakSet,ie=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,q)&&window.clearTimeout(a(this,q)),f(this,q,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},ct=new WeakSet,re=function(t){let i=a(this,g).visitLifespan;return i?t.updated+i<Date.now():!1},W=new WeakSet,bt=function(t){var i,r;if(!!a(this,g).manifest)for(let n in t){let o=t[n],s=a(this,g).manifest.getDimensionByKey(n);!s||o>s.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:o,cap:s.cap}]),t[n]=s.cap)}},Y=new WeakSet,Vt=function(){var t,i,r;return{...rt(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(r=(i=a(this,g).manifest)==null?void 0:i.rollForControlGroup())!=null?r:!1}};import Ve from"mitt";function ne({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var o,s,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(o=t.storage.data.controlGroup)!=null?o:!1,l=[],p=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((s=S.pz)!=null&&s.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||oe(S.id,S.pz,m,n)&&(p=!0,l.push(S))}return{personalized:p,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function oe(e,t,i,r){r==null||r(["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(o=>se(o,i,r)):n=t.crit.some(o=>se(o,i,r)):(r==null||r(["info",302,{matched:!0,description:"default variation"}]),n=!0),r==null||r(["info",303,n])}finally{r==null||r(["info",301,"ENDGROUP"])}return n}function se(e,t,i){var u,c;let{op:r,l:n}=e,o=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(r==="-"){let l=Math.min(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let s=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(s))return i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=o>s;return _(i,l,e,o,s),l}else if(r===">="){let l=o>=s;return _(i,l,e,o,s),l}else if(r==="<"){let l=o<s;return _(i,l,e,o,s),l}else if(r==="<="){let l=o<=s;return _(i,l,e,o,s),l}else if(r==="="){let l=o===s;return _(i,l,e,o,s),l}else if(r==="!="){let l=o!==s;return _(i,l,e,o,s),l}else throw new Error(`Unknown op: ${r}`)}function _(e,t,i,r,n){e==null||e(["info",302,{matched:t,description:`${i.l}[${r}] ${i.op} ${i.rDim?`${i.rDim}[${n}]`:i.r}`}])}var be=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,o)=>(o.testDistribution?n.total+=o.testDistribution:++n.missingDistribution,n.values.push(o.testDistribution),n),{values:[],total:0,missingDistribution:0});if(i>100)throw new Error(`Total distribution ${i} is over the maximum 100.`);if(i<100){let o=(100-i)/r;t.forEach((s,u)=>{typeof s=="undefined"&&(t[u]=o)})}return t},Et=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,o=t.getTestVariantId(e);if(o===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(o&&(n=i.find(s=>s.id===o),n||r==null||r(["warn",402,{missingVariant:o,variants:i.map(s=>s.id)}])),!n){let s=be(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,p)=>{let m=s[p];if(u>c&&u<=c+m)return l;c+=m}),n&&(r==null||r(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(r==null||r(["info",404,n.id])),{result:n,variantAssigned:!o}}finally{r==null||r(["info",400,"ENDGROUP"])}};import{dequal as ae}from"dequal/lite";var C,T,k,X,h,Z,Tt,j,dt,ue=class{constructor(t){d(this,Z);d(this,j);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,X,{});d(this,h,Ve());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,o,s,u;let{manifest:i,...r}=t;f(this,k,{}),(n=t.plugins)==null||n.forEach(c=>{!c.logDrain||a(this,h).on("log",c.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new et({onLogMessage:c=>a(this,h).emit("log",c),manifest:i,evaluator:new G({CK:Gt,QS:qt,QK:_t,PVC:gt,EVT:jt,PV:Qt})}),this.storage=new ut({...r,manifest:this.manifest,onServerTransitionReceived:c=>{f(this,C,c),c.ssv&&(f(this,T,c.ssv),a(this,h).emit("log",["debug",130,c.ssv]))},onLogMessage:c=>a(this,h).emit("log",c)}),this.storage.events.on("scoresUpdated",v(this,j,dt).bind(this)),a(this,C)||v(this,j,dt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",c=>{let l=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(l),a(this,h).emit("quirksUpdated",c.quirks),a(this,h).emit("log",["info",4,c.quirks])}),(o=t.plugins)==null||o.forEach(c=>{!c.init||c.init(this)}),(s=a(this,C))!=null&&s.tests&&Object.entries((u=a(this,C))==null?void 0:u.tests).map(([c,l])=>{this.storage.data.tests[c]=l,v(this,Z,Tt).call(this,{name:c,variantId:l,variantAssigned:!0})})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,T)}get quirks(){var t,i;return(i=(t=a(this,C))==null?void 0:t.quirks)!=null?i:this.storage.data.quirks}async update(t){var r,n;let i=[];(r=a(this,C))!=null&&r.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}});try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(n=t.url)==null?void 0:n.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([o,s])=>({type:"setquirk",data:{key:o,value:s}}))),t.enrichments&&t.enrichments.forEach(o=>{let s=it(o.cat,o.key);this.manifest.getDimensionByKey(s)?i.push({type:"modscore",data:{dimension:s,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),f(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,j,dt).call(this,this.storage.data),f(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r;let i=this.manifest.getTest(t);return i?(r=i.wv)!=null?r:this.storage.data.tests[t]:(a(this,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,i){this.storage.updateData([{type:"settest",data:{test:t,variant:i}}])}log(...t){a(this,h).emit("log",t)}test(t){var r,n;let i=Et({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)});return v(this,Z,Tt).call(this,{name:t.name,variantId:(n=(r=i.result)==null?void 0:r.id)!=null?n:void 0,variantAssigned:i.variantAssigned}),i}personalize(t){let i=ne({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)}),r=a(this,X)[t.name],n={name:t.name,variantIds:i.variations.map(o=>{var s;return(s=o.id)!=null?s:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return r&&ae(n.variantIds,r)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,X)[t.name]=n.variantIds,i}async forget(t){f(this,k,{}),await this.storage.delete(t)}getServerToClientTransitionState(){let t={quirks:this.storage.data.quirks,ssv:a(this,T),tests:{}},i=this.storage.data.tests;return Object.entries(i).map(([r,n])=>{var o,s,u;((u=(s=(o=this.storage.options.transitionStore)==null?void 0:o.initialData)==null?void 0:s.tests)==null?void 0:u[r])!==i[r]&&t.tests&&(t.tests[r]=n)}),t}};C=new WeakMap,T=new WeakMap,k=new WeakMap,X=new WeakMap,h=new WeakMap,Z=new WeakSet,Tt=function(t){a(this,h).emit("testResult",t)},j=new WeakSet,dt=function(t){var n;let i={...t.scores};for(let o in t.sessionScores)i[o]=((n=i[o])!=null?n:0)+t.sessionScores[o];i=this.manifest.computeAggregateDimensions(i),!ae(i,a(this,T))&&(f(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};import Ee from"rfdc";function pt(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 Te=Ee();function ke(e){return([t,...i])=>{if(!pt(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
2
+ `,...n.map(Te))}}function hr(e){return{logDrain:ke(e)}}var le={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:i})=>["storage",`${e} score ${i} 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:i})=>["signals",`${e.type}: ${i} 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 Pe from"rfdc";var we=Pe();function Re(e,t){let i=typeof document=="undefined",{enableOnServer:r=!1}=t!=null?t:{};return([n,...o])=>{if(!pt(e,n)||i&&!r)return;let[s,...u]=o,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=le[s],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 ${s}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,D,...M]=l(...u);c(`${m}[${S}] ${D}
3
+ `,...M.map(we))}}function Cr(e,t){return{logDrain:Re(e,t)}}var Oe=(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))(Oe||{}),br="nesitag";var kt=typeof top!="undefined";function Er(){return{logDrain:e=>{!kt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!kt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:i}},window.location.origin)},n=s=>{!s.changed||(t.push(s),r())},o=s=>{!s.variantAssigned||(i.push(s),r())};if(kt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async s=>{if(!s.data)return;let u=s.data;await Ue(u,e)})}catch(s){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",s)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",o),e.events.on("scoresUpdated",r),e.storage.events.on("*",r),()=>{e.events.off("scoresUpdated",r),e.storage.events.off("*",r),e.events.off("personalizationResult",n),e.events.off("testResult",o)}}}}async function Ue(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 kr(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function Pr(e){let[t,i,r]=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(i))throw new Error("Invalid project ID");return{apiKey:t,projectId:i,apiHost:r||"https://uniform.app"}}export{ue as Context,Bt as CookieTransitionDataStore,br as EdgeNodeTagName,Mt as EdgeTransitionDataStore,G as GroupCriteriaEvaluator,et as ManifestInstance,ge as SERVER_STATE_ID,Oe as ScriptType,I as TransitionDataStore,ve as UNIFORM_DEFAULT_COOKIE_NAME,ut as VisitorDataStore,Ut as computeAggregateDimensions,Gt as cookieEvaluator,ke as createConsoleLogDrain,Re as createDebugConsoleLogDrain,Ri as createLinearDecay,Qt as currentPageEvaluator,rt as emptyVisitorData,hr as enableConsoleLogDrain,Er as enableContextDevTools,Cr as enableDebugConsoleLogDrain,oe as evaluateVariantMatch,jt as eventEvaluator,O as explainStringMatch,mt as explainStringMatchCriteria,it as getEnrichmentVectorKey,V as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,Pr as parseQuickConnect,ne as personalizeVariations,qt as queryStringEvaluator,_t as quirkEvaluator,kr as serializeQuickConnect,Et as testVariations};
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var be=Object.create;var F=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var Pe=(e,t,r)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var we=(e,t)=>{for(var r in t)F(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ee(t))!ke.call(e,n)&&n!==r&&F(e,n,{get:()=>t[n],enumerable:!(i=Ve(t,n))||i.enumerable});return e};var $=(e,t,r)=>(r=e!=null?be(Te(e)):{},Ft(t||!e||!e.__esModule?F(r,"default",{value:e,enumerable:!0}):r,e)),Re=e=>Ft(F({},"__esModule",{value:!0}),e);var y=(e,t,r)=>(Pe(e,typeof t!="symbol"?t+"":t,r),r),St=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(St(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)},m=(e,t,r,i)=>(St(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var S=(e,t,r)=>(St(e,t,"access private method"),r);var Be={};we(Be,{Context:()=>zt,CookieTransitionDataStore:()=>Rt,EdgeNodeTagName:()=>je,EdgeTransitionDataStore:()=>Ot,GroupCriteriaEvaluator:()=>N,ManifestInstance:()=>B,SERVER_STATE_ID:()=>Mt,ScriptType:()=>xe,TransitionDataStore:()=>A,UNIFORM_DEFAULT_COOKIE_NAME:()=>ne,VisitorDataStore:()=>L,computeAggregateDimensions:()=>yt,cookieEvaluator:()=>Dt,createConsoleLogDrain:()=>Se,createDebugConsoleLogDrain:()=>Ce,createLinearDecay:()=>Ne,currentPageEvaluator:()=>Vt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>Ie,enableContextDevTools:()=>Qe,enableDebugConsoleLogDrain:()=>_e,evaluateVariantMatch:()=>At,eventEvaluator:()=>bt,explainStringMatch:()=>k,explainStringMatchCriteria:()=>st,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>at,pageViewCountEvaluator:()=>ut,parseQuickConnect:()=>He,personalizeVariations:()=>Nt,queryStringEvaluator:()=>Ct,quirkEvaluator:()=>xt,serializeQuickConnect:()=>Ke,testVariations:()=>ht});module.exports=Re(Be);function yt(e,t){let r={...e};for(let i in t){let n=Kt(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Kt(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=Kt(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 nt="_";var K,H,ot=class{constructor(t,r,i){d(this,K,void 0);d(this,H,void 0);y(this,"signal");this.signal=t,m(this,K,r),m(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 V,J,O,B=class{constructor({manifest:t,evaluator:r=new N({}),onLogMessage:i=()=>{}}){y(this,"data");d(this,V,void 0);d(this,J,void 0);d(this,O,void 0);var n,s,o;m(this,V,(n=t.project)!=null?n:{}),this.data=t,m(this,J,Object.entries((o=(s=a(this,V).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new ot({...c,id:u},r,i))),m(this,O,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,V).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,V).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,O).call(this,["debug",200,"GROUP"]);try{a(this,J).forEach(i=>{a(this,O).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,O).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,O).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return yt(t,(i=(r=a(this,V).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(nt);return r<=0?(n=(i=a(this,V).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,V).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};V=new WeakMap,J=new WeakMap,O=new WeakMap;var Jt=require("dequal/lite");function x(e,t){var o,u,c,l,f,p;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:"":Ht(e)).toString(),s=(i?t.rhs:Ht(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((f=e==null?void 0:e.toString())!=null?f:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");default:throw new Error(`Unknown match type ${r}.`)}}function k(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${st(t)}`}function st(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Ht(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var Dt=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!(0,Jt.dequal)(Bt(e.state.cookies),Bt((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:k(n,t.match)}]),o};function Bt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Wt(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 Yt(e,t){return`${e} ${Oe(t)}`}function Oe(e){return`${e.op} ${e.rhs}`}function W(e,t){return`${e}${nt}${t}`}var at=W("$pvc","v"),ut=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,f;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())!==((f=e.previousState.url)==null?void 0:f.toString()))),o=(e.visitor.sessionScores[at]||0)+1,u={result:!1,changed:n},c=r.some(p=>p.type==="modscoreS"&&p.data.dimension===at);return n&&!c&&r.push({type:"modscoreS",data:{dimension:at,delta:1}}),Wt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:Yt(o,t.match)}]),u};ut.alwaysExecute=!0;var Ct=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,f,p;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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(p=e.state.url)==null?void 0:p.searchParams.get(t.queryName),o={result:x(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:k(n,t.match)}]),o};var xt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var f;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=(f=e.state.quirks)==null?void 0:f[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:k(o,t.match)}]),l};var bt=({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("', '")}' ${st(t.event)}`}]),n};var Vt=({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:k(i,t.path)}]),o};var Y,N=class{constructor(t){d(this,Y,void 0);m(this,Y,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 p of r.clauses){let v;if(p.type==="G")v=this.evaluate(t,p,i,n,s);else{let D=a(this,Y)[p.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${p.type} signal criteria not registered`);v=D({update:t,criteria:p,commands:i,signal:n,onLogMessage:s})}v.changed&&(l=!0),!c&&v.result===u&&(c={result:u,changed:l})}let f=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,f])),f}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};Y=new WeakMap;var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Xt=$(require("mitt")),Zt=require("dequal/lite"),Mt="__UNIFORM_DATA__",U,q,A=class{constructor({initialData:t}){d(this,U,void 0);d(this,q,(0,Xt.default)());y(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&m(this,U,t)}get data(){return a(this,U)}updateData(t,r){return m(this,U,r),this.handleUpdateData(t,r)}async delete(t){m(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,Zt.dequal)(this.data,t)||(m(this,U,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(Mt);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,q=new WeakMap;var Et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lt=Et.split(""),te=new Array(123);for(let e=0;e<Et.length;e++)te[Et.charCodeAt(e)]=e;var Tt=e=>{if(e<0)return`-${Tt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=Lt[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=Lt[63&t]+n,t>>>=6;while(t>0);return n+i},ee=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+te[e.charCodeAt(i)];return r?-t:t};var lt=$(require("js-cookie")),kt=typeof document=="undefined",ne="ufvd",G,Z,Rt=class extends A{constructor({serverCookieValue:r,cookieName:i=ne,cookieAttributes:n={sameSite:"lax"}}){super({initialData:kt?Ue(r):void 0});d(this,G,void 0);d(this,Z,void 0);m(this,G,i),m(this,Z,n)}handleDelete(){return kt||lt.default.remove(a(this,G)),Promise.resolve()}async handleUpdateData(r,i){kt||(i.consent?lt.default.set(a(this,G),$e(i),a(this,Z)):lt.default.remove(a(this,G)))}};G=new WeakMap,Z=new WeakMap;var oe="~",se="!",ae="-";function Ue(e){if(!e)return;let t=e.split(oe);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:re(Pt(i)),scores:re(Pt(n)),tests:Pt(r)}}function Pt(e){return e.split(se).map(r=>r.split(ae)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function re(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=ee(i),t),{})}function $e(e){return[wt(e.tests),wt(ie(e.sessionScores)),wt(ie(e.scores))].join(oe)}function ie(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Tt(i),t),{})}function wt(e){return Object.entries(e).map(t=>t.join(ae)).join(se)}var ct,ue,Ot=class extends A{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,ct);n.initialData||S(this,ct,ue).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)}};ct=new WeakSet,ue=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 p=s-o-t;if(p<=0)return!1;let v=p/864e5,D=1-Math.min(i,v*r);return D<=0?!1:(le(u,D),le(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function le(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}var fe=$(require("mitt")),M=require("dequal/lite");var dt=class{constructor(){y(this,"inMemoryFallback",{});y(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 ce=$(require("rfdc"));var Ae=(0,ce.default)();function de(e,t,r){let i=t?Ae(t):X();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 f=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ft="ufvisitor",E,I,_,g,b,P,w,z,pt,pe,mt,me,tt,Ut,et,$t,L=class{constructor(t){d(this,b);d(this,w);d(this,pt);d(this,mt);d(this,tt);d(this,et);d(this,E,(0,fe.default)());d(this,I,new dt);d(this,_,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(m(this,g,t),a(this,b,P)||S(this,w,z).call(this,S(this,et,$t).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{S(this,w,z).call(this,{...a(this,b,P).visitorData,...n})});let i=t.transitionStore.data;i&&S(this,w,z).call(this,{...a(this,b,P).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,b,P);if(S(this,mt,me).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return S(this,w,z).call(this,{...s,sessionScores:{}}),(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",120]),a(this,b,P).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,g)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=de(t,this.data,(s=a(this,b,P))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(ft,!0),S(this,w,z).call(this,r),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,b,P).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,I).delete(ft,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),S(this,w,z).call(this,S(this,et,$t).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};E=new WeakMap,I=new WeakMap,_=new WeakMap,g=new WeakMap,b=new WeakSet,P=function(){return a(this,I).get(ft)},w=new WeakSet,z=function(t,r=!1){var f,p,v,D,it,qt,_t,jt,Qt;let i=a(this,b,P),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,tt,Ut).call(this,t.scores),S(this,tt,Ut).call(this,t.sessionScores),(p=(f=a(this,g)).decay)==null||p.call(f,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!(0,M.dequal)(i==null?void 0:i.visitorData.scores,t.scores),o=!(0,M.dequal)(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!(0,M.dequal)(i==null?void 0:i.visitorData.quirks,t.quirks),c=!(0,M.dequal)(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};S(this,pt,pe).call(this),a(this,I).set(ft,l,!!t.consent),(D=(v=a(this,g)).onLogMessage)==null||D.call(v,["debug",102,t]),r||((s||o)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((it=i==null?void 0:i.visitorData)==null?void 0:it.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((qt=i==null?void 0:i.visitorData)==null?void 0:qt.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Qt=(jt=a(this,g)).onLogMessage)==null||Qt.call(jt,["debug",104,(_t=t.controlGroup)!=null?_t:!1])))},pt=new WeakSet,pe=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,_)&&window.clearTimeout(a(this,_)),m(this,_,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},mt=new WeakSet,me=function(t){let r=a(this,g).visitLifespan;return r?t.updated+r<Date.now():!1},tt=new WeakSet,Ut=function(t){var r,i;if(!!a(this,g).manifest)for(let n in t){let s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,g)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},et=new WeakSet,$t=function(){var t,r,i;return{...X(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,g).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};var ge=$(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=[],f=!1,p=t.scores;for(let v of r){if(l.length===i)break;if(!((o=v.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:v.id,op:(u=v.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(v);continue}c||At(v.id,v.pz,p,n)&&(f=!0,l.push(v))}return{personalized:f,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function At(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=>he(s,r,i)):n=t.crit.some(s=>he(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 he(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=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(o))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 j(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return j(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return j(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return j(r,l,e,s,o),l}else if(i==="="){let l=s===o;return j(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return j(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function j(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 Ge=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},ht=({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=Ge(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,f)=>{let p=o[f];if(u>c&&u<=c+p)return l;c+=p}),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 Gt=require("dequal/lite"),C,R,T,rt,h,Q,gt,zt=class{constructor(t){d(this,Q);y(this,"manifest");d(this,C,void 0);d(this,R,{});d(this,T,void 0);d(this,rt,{});d(this,h,(0,ge.default)());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:r,...i}=t;m(this,T,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,h).on("log",o.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new B({onLogMessage:o=>a(this,h).emit("log",o),manifest:r,evaluator:new N({CK:Dt,QS:Ct,QK:xt,PVC:ut,EVT:bt,PV:Vt})}),this.storage=new L({...i,manifest:this.manifest,onServerTransitionReceived:o=>{m(this,C,o),o.ssv&&(m(this,R,o.ssv),a(this,h).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",S(this,Q,gt).bind(this)),a(this,C)||S(this,Q,gt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,R),state:a(this,T),previousState:a(this,T),visitor:this.storage.data});this.storage.updateData(u),a(this,h).emit("quirksUpdated",o.quirks),a(this,h).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,R)}get quirks(){var t,r;return(r=(t=a(this,C))==null?void 0:t.quirks)!=null?r:this.storage.data.quirks}async update(t){var i,n,s;let r=[];(i=a(this,C))!=null&&i.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(n=a(this,C))!=null&&n.tests&&r.push(...Object.entries(a(this,C).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,h).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=W(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,T),visitor:this.storage.data,scores:a(this,R)})),m(this,T,{...a(this,T),...t}),await this.storage.updateData(r),a(this,C)&&(S(this,Q,gt).call(this,this.storage.data),m(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).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,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,h).emit("log",t)}test(t){var i,n;let r=ht({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)});return a(this,h).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,h).emit("log",s)}),i=a(this,rt)[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,Gt.dequal)(n.variantIds,i)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,rt)[t.name]=n.variantIds,r}async forget(t){m(this,T,{}),await this.storage.delete(t)}};C=new WeakMap,R=new WeakMap,T=new WeakMap,rt=new WeakMap,h=new WeakMap,Q=new WeakSet,gt=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,Gt.dequal)(r,a(this,R))&&(m(this,R,r),a(this,h).emit("scoresUpdated",r),a(this,h).emit("log",["info",3,r]))};var ve=$(require("rfdc"));function vt(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 ze=(0,ve.default)();function Se(e){return([t,...r])=>{if(!vt(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
- `,...n.map(ze))}}function Ie(e){return{logDrain:Se(e)}}var ye={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 De=$(require("rfdc")),qe=(0,De.default)();function Ce(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!vt(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=ye[o],f="";switch(n){case"debug":f="\u{1F41E}";break;case"info":f="\u{1F4AC}";break;case"warn":f="\u26A0\uFE0F";break;case"error":f="\u{1F4A5}";break}let p=f;if(!l){c(`${p} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[v,D,...it]=l(...u);c(`${p}[${v}] ${D}
3
- `,...it.map(qe))}}function _e(e,t){return{logDrain:Ce(e,t)}}var xe=(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))(xe||{}),je="nesitag";var It=typeof top!="undefined";function Qe(){return{logDrain:e=>{!It||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!It||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(It){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Fe(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 Fe(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 Ke(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function He(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});
1
+ "use strict";var Te=Object.create;var F=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Oe=(e,t,i)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ue=(e,t)=>{for(var i in t)F(e,i,{get:t[i],enumerable:!0})},Bt=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Re.call(e,n)&&n!==i&&F(e,n,{get:()=>t[n],enumerable:!(r=ke(t,n))||r.enumerable});return e};var $=(e,t,i)=>(i=e!=null?Te(we(e)):{},Bt(t||!e||!e.__esModule?F(i,"default",{value:e,enumerable:!0}):i,e)),$e=e=>Bt(F({},"__esModule",{value:!0}),e);var y=(e,t,i)=>(Oe(e,typeof t!="symbol"?t+"":t,i),i),Dt=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(Dt(e,t,"read from private field"),i?i.call(e):t.get(e)),d=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},f=(e,t,i,r)=>(Dt(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(Dt(e,t,"access private method"),i);var Ye={};Ue(Ye,{Context:()=>qt,CookieTransitionDataStore:()=>Ut,EdgeNodeTagName:()=>Ke,EdgeTransitionDataStore:()=>$t,GroupCriteriaEvaluator:()=>A,ManifestInstance:()=>B,SERVER_STATE_ID:()=>ee,ScriptType:()=>Ee,TransitionDataStore:()=>N,UNIFORM_DEFAULT_COOKIE_NAME:()=>ae,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Ct,cookieEvaluator:()=>xt,createConsoleLogDrain:()=>Ce,createDebugConsoleLogDrain:()=>Ve,createLinearDecay:()=>ze,currentPageEvaluator:()=>Tt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>je,enableContextDevTools:()=>He,enableDebugConsoleLogDrain:()=>Fe,evaluateVariantMatch:()=>zt,eventEvaluator:()=>Et,explainStringMatch:()=>P,explainStringMatchCriteria:()=>ut,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>lt,pageViewCountEvaluator:()=>ct,parseQuickConnect:()=>We,personalizeVariations:()=>Gt,queryStringEvaluator:()=>bt,quirkEvaluator:()=>Vt,serializeQuickConnect:()=>Je,testVariations:()=>vt});module.exports=$e(Ye);function Ct(e,t){let i={...e};for(let r in t){let n=Jt(e,r,t,new Set([r]));n!==0&&(i[r]=n)}return i}function Jt(e,t,i,r){var o;let n=0;for(let s of i[t].inputs){let u=(o=e[s.dim])!=null?o:0;if(!u&&i[s.dim]){if(r.has(s.dim))continue;let l=new Set(r);l.add(s.dim),u=Jt(e,s.dim,i,l)}if(u!==0)if(s.sign==="c"){n=0;break}else s.sign==="-"?n-=u:n+=u}return n}var st="_";var K,H,at=class{constructor(t,i,r){d(this,K,void 0);d(this,H,void 0);y(this,"signal");this.signal=t,f(this,K,i),f(this,H,r)}computeSignal(t,i){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,K).evaluate(t,this.signal.crit,i,this.signal,a(this,H)),o=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.push({type:o,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let s=t.visitor.sessionScores[this.signal.id];s&&i.push({type:o,data:{dimension:this.signal.id,delta:-s}})}}}};K=new WeakMap,H=new WeakMap;var V,J,O,B=class{constructor({manifest:t,evaluator:i=new A({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,V,void 0);d(this,J,void 0);d(this,O,void 0);var n,o,s;f(this,V,(n=t.project)!=null?n:{}),this.data=t,f(this,J,Object.entries((s=(o=a(this,V).pz)==null?void 0:o.sig)!=null?s:[]).map(([u,c])=>new at({...c,id:u},i,r))),f(this,O,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,V).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,V).test)==null?void 0:i[t]}computeSignals(t){let i=[];a(this,O).call(this,["debug",200,"GROUP"]);try{a(this,J).forEach(r=>{a(this,O).call(this,["debug",201,"GROUP",r.signal]);try{r.computeSignal(t,i)}finally{a(this,O).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,O).call(this,["debug",200,"ENDGROUP"])}return i}computeAggregateDimensions(t){var i,r;return Ct(t,(r=(i=a(this,V).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,o,s;let i=t.indexOf(st);return i<=0?(n=(r=a(this,V).pz)==null?void 0:r.sig)==null?void 0:n[t]:(s=(o=a(this,V).pz)==null?void 0:o.enr)==null?void 0:s[t.substring(0,i)]}};V=new WeakMap,J=new WeakMap,O=new WeakMap;var Xt=require("dequal/lite");function x(e,t){var s,u,c,l,p,m;let i=(s=t==null?void 0:t.op)!=null?s:"=";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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":Wt(e)).toString(),o=(r?t.rhs:Wt(t.rhs)).toString();switch(i){case"=":return n===o;case"!=":return n!==o;case"~":return(c=n.includes(o))!=null?c:!1;case"!~":return!((l=n.includes(o))==null||l);case"//":return new RegExp(t.rhs.toString(),r?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");case"!//":return!new RegExp(t.rhs.toString(),r?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${i}.`)}}function P(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ut(t)}`}function ut(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Wt(e){var t,i;return(i=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?i:""}var xt=({update:e,criteria:t,onLogMessage:i})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let r=!(0,Xt.dequal)(Yt(e.state.cookies),Yt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],s={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:P(n,t.match)}]),s};function Yt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...i}=e;return i}function Zt(e,t){var r;if(typeof e=="undefined"||e===null)return!1;let i=Number(e);if(isNaN(i))return!1;switch((r=t==null?void 0:t.op)!=null?r:"="){case"=":return i===t.rhs;case"!=":return i!==t.rhs;case">":return i>t.rhs;case"<":return i<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function Mt(e,t){return`${e} ${Ae(t)}`}function Ae(e){return`${e.op} ${e.rhs}`}function W(e,t){return`${e}${st}${t}`}var lt=W("$pvc","v"),ct=({update:e,criteria:t,commands:i,onLogMessage:r})=>{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()))),s=(e.visitor.sessionScores[lt]||0)+1,u={result:!1,changed:n},c=i.some(m=>m.type==="modscoreS"&&m.data.dimension===lt);return n&&!c&&i.push({type:"modscoreS",data:{dimension:lt,delta:1}}),Zt(s,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:Mt(s,t.match)}]),u};ct.alwaysExecute=!0;var bt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,p,m;if(t.type!=="QS")return{result:!1,changed:!1};let r=!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),s={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:P(n,t.match)}]),s};var Vt=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var p;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&i.dur==="t"&&e.scores[i.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],o=(p=e.state.quirks)==null?void 0:p[t.key],s=o!=null?o:n,u=Boolean(o&&n!==o),l={result:x(s,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:P(s,t.match)}]),l};var Et=({update:e,criteria:t,onLogMessage:i})=>{var o,s,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(s=(o=e.state.events)==null?void 0:o.some(c=>x(c.event,t.event)))!=null?s:!1,n={result:r,changed:r};return i==null||i(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${ut(t.event)}`}]),n};var Tt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let r=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(r==null?void 0:r.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),s={result:x(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:s,explanation:P(r,t.path)}]),s};var Y,A=class{constructor(t){d(this,Y,void 0);f(this,Y,t)}evaluate(t,i,r,n,o){let s=i.clauses.length>1;s&&(o==null||o(["debug",202,"GROUP",i]));try{let u=!(i.op==="&"||!i.op),c=null,l=!1;for(let m of i.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,r,n,o);else{let D=a(this,Y)[m.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${m.type} signal criteria not registered`);S=D({update:t,criteria:m,commands:r,signal:n,onLogMessage:o})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let p=c!=null?c:{result:!u,changed:l};return s&&(o==null||o(["debug",204,p])),p}finally{s&&(o==null||o(["debug",202,"ENDGROUP"]))}}};Y=new WeakMap;var X=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});var Lt=$(require("mitt")),te=require("dequal/lite"),ee="__UNIFORM_DATA__",U,Z,q,N=class{constructor({initialData:t}){d(this,U,void 0);d(this,Z,void 0);d(this,q,(0,Lt.default)());y(this,"events",{on:a(this,q).on,off:a(this,q).off});t&&(f(this,U,t),f(this,Z,t))}get data(){return a(this,U)}get initialData(){return a(this,Z)}updateData(t,i){return f(this,U,i),this.handleUpdateData(t,i)}async delete(t){f(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,te.dequal)(this.data,t)||(f(this,U,t),a(this,q).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(ee);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,Z=new WeakMap,q=new WeakMap;var kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ie=kt.split(""),re=new Array(123);for(let e=0;e<kt.length;e++)re[kt.charCodeAt(e)]=e;var Pt=e=>{if(e<0)return`-${Pt(-e)}`;let t=e>>>0,i=e/4294967296>>>0,r="";for(;i>0;)r=ie[63&t]+r,t>>>=6,t|=(63&i)<<26,i>>>=6;let n="";do n=ie[63&t]+n,t>>>=6;while(t>0);return n+r},ne=e=>{let t=0,i=e.charAt(0)==="-"?1:0;for(let r=i;r<e.length;r++)t=t*64+re[e.charCodeAt(r)];return i?-t:t};var dt=$(require("js-cookie")),wt=typeof document=="undefined",ae="ufvd",G,M,Ut=class extends N{constructor({serverCookieValue:i,cookieName:r=ae,cookieAttributes:n={sameSite:"lax"}}){super({initialData:wt?Ne(i):void 0});d(this,G,void 0);d(this,M,void 0);f(this,G,r),f(this,M,n)}handleDelete(){return wt||dt.default.remove(a(this,G)),Promise.resolve()}async handleUpdateData(i,r){wt||(r.consent?dt.default.set(a(this,G),Ge(r),a(this,M)):dt.default.remove(a(this,G)))}};G=new WeakMap,M=new WeakMap;var ue="~",le="!",ce="-";function Ne(e){if(!e)return;let t=e.split(ue);if(t.length>3)return;let[i,r,n]=t;return{consent:!0,sessionScores:oe(Rt(r)),scores:oe(Rt(n)),tests:Rt(i)}}function Rt(e){return e.split(le).map(i=>i.split(ce)).reduce((i,r)=>(r.length!==2||(i[r[0]]=r[1]),i),{})}function oe(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=ne(r),t),{})}function Ge(e){return[Ot(e.tests),Ot(se(e.sessionScores)),Ot(se(e.scores))].join(ue)}function se(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=Pt(r),t),{})}function Ot(e){return Object.entries(e).map(t=>t.join(ce)).join(le)}var pt,de,$t=class extends N{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,pt);n.initialData||v(this,pt,de).call(this).catch(o=>{console.error(o)})}handleDelete(i){throw new Error("Method not implemented.")}async handleUpdateData(i){let r=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};pt=new WeakSet,de=async function(){let i=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)};function ze(e){let{gracePeriod:t=864e5,decayRate:i=1/30,decayCap:r=.95}=e!=null?e:{};return function({now:o,lastUpd:s,scores:u,sessionScores:c,onLogMessage:l}){if(typeof s!="number")return!1;let m=o-s-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(pe(u,D),pe(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function pe(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}var he=$(require("mitt")),L=require("dequal/lite");var ft=class{constructor(){y(this,"inMemoryFallback",{});y(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let i=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||i)return i;try{let r=localStorage.getItem(t);return r?JSON.parse(r):void 0}catch(r){return i}}set(t,i,r){if(this.inMemoryFallback[t]=i,!(!this.hasLocalStorageObject||!r))try{localStorage.setItem(t,JSON.stringify(i))}catch(n){console.warn(n)}}delete(t,i){i||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(r){}}};var fe=$(require("rfdc"));var Ie=(0,fe.default)();function me(e,t,i){let r=t?Ie(t):X();return e.forEach(n=>{var o,s;switch(n.type){case"consent":r.consent=n.data;break;case"setquirk":r.quirks[n.data.key]=n.data.value;break;case"settest":r.tests[n.data.test]=n.data.variant;break;case"modscore":if(i)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(o=r.scores[n.data.dimension])!=null?o:0;r.scores[n.data.dimension]=c+u;break;case"modscoreS":if(i)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let p=(s=r.sessionScores[n.data.dimension])!=null?s:0;r.sessionScores[n.data.dimension]=p+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var mt="ufvisitor",E,I,_,g,b,w,R,z,ht,ge,gt,ve,et,At,it,Nt,tt=class{constructor(t){d(this,b);d(this,R);d(this,ht);d(this,gt);d(this,et);d(this,it);d(this,E,(0,he.default)());d(this,I,new ft);d(this,_,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(f(this,g,t),a(this,b,w)||v(this,R,z).call(this,v(this,it,Nt).call(this),!0),t.transitionStore){let i=t.transitionStore.getClientTransitionState();i&&t.onServerTransitionReceived&&t.onServerTransitionReceived(i),t.transitionStore.events.on("dataUpdatedAsync",n=>{v(this,R,z).call(this,{...a(this,b,w).visitorData,...n})});let r=t.transitionStore.data;r&&v(this,R,z).call(this,{...a(this,b,w).visitorData,...r},!0)}}get data(){var i,r;let t=a(this,b,w);if(v(this,gt,ve).call(this,t)){let{sessionScores:n,...o}=t.visitorData;return v(this,R,z).call(this,{...o,sessionScores:{}}),(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",120]),a(this,b,w).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}get options(){return a(this,g)}async updateData(t){var r,n,o,s;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=me(t,this.data,(o=a(this,b,w))==null?void 0:o.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(mt,!0),v(this,R,z).call(this,i),await((s=a(this,g).transitionStore)==null?void 0:s.updateData(t,a(this,b,w).visitorData))}async delete(t){var i,r,n,o,s;(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",103,"GROUP",t]);try{a(this,I).delete(mt,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),v(this,R,z).call(this,v(this,it,Nt).call(this))}finally{(s=(o=a(this,g)).onLogMessage)==null||s.call(o,["info",103,"ENDGROUP"])}}};E=new WeakMap,I=new WeakMap,_=new WeakMap,g=new WeakMap,b=new WeakSet,w=function(){return a(this,I).get(mt)},R=new WeakSet,z=function(t,i=!1){var p,m,S,D,ot,Qt,Ft,Kt,Ht;let r=a(this,b,w),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,et,At).call(this,t.scores),v(this,et,At).call(this,t.sessionScores),(m=(p=a(this,g)).decay)==null||m.call(p,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let o=!(0,L.dequal)(r==null?void 0:r.visitorData.scores,t.scores),s=!(0,L.dequal)(r==null?void 0:r.visitorData.sessionScores,t.sessionScores),u=!(0,L.dequal)(r==null?void 0:r.visitorData.quirks,t.quirks),c=!(0,L.dequal)(r==null?void 0:r.visitorData.tests,t.tests),l={updated:n,visitorData:t};v(this,ht,ge).call(this),a(this,I).set(mt,l,!!t.consent),(D=(S=a(this,g)).onLogMessage)==null||D.call(S,["debug",102,t]),i||((o||s)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((ot=r==null?void 0:r.visitorData)==null?void 0:ot.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Qt=r==null?void 0:r.visitorData)==null?void 0:Qt.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Ht=(Kt=a(this,g)).onLogMessage)==null||Ht.call(Kt,["debug",104,(Ft=t.controlGroup)!=null?Ft:!1])))},ht=new WeakSet,ge=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,_)&&window.clearTimeout(a(this,_)),f(this,_,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},gt=new WeakSet,ve=function(t){let i=a(this,g).visitLifespan;return i?t.updated+i<Date.now():!1},et=new WeakSet,At=function(t){var i,r;if(!!a(this,g).manifest)for(let n in t){let o=t[n],s=a(this,g).manifest.getDimensionByKey(n);!s||o>s.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:o,cap:s.cap}]),t[n]=s.cap)}},it=new WeakSet,Nt=function(){var t,i,r;return{...X(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(r=(i=a(this,g).manifest)==null?void 0:i.rollForControlGroup())!=null?r:!1}};var ye=$(require("mitt"));function Gt({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var o,s,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(o=t.storage.data.controlGroup)!=null?o:!1,l=[],p=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((s=S.pz)!=null&&s.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||zt(S.id,S.pz,m,n)&&(p=!0,l.push(S))}return{personalized:p,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function zt(e,t,i,r){r==null||r(["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(o=>Se(o,i,r)):n=t.crit.some(o=>Se(o,i,r)):(r==null||r(["info",302,{matched:!0,description:"default variation"}]),n=!0),r==null||r(["info",303,n])}finally{r==null||r(["info",301,"ENDGROUP"])}return n}function Se(e,t,i){var u,c;let{op:r,l:n}=e,o=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(r==="-"){let l=Math.min(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let s=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(s))return i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=o>s;return j(i,l,e,o,s),l}else if(r===">="){let l=o>=s;return j(i,l,e,o,s),l}else if(r==="<"){let l=o<s;return j(i,l,e,o,s),l}else if(r==="<="){let l=o<=s;return j(i,l,e,o,s),l}else if(r==="="){let l=o===s;return j(i,l,e,o,s),l}else if(r==="!="){let l=o!==s;return j(i,l,e,o,s),l}else throw new Error(`Unknown op: ${r}`)}function j(e,t,i,r,n){e==null||e(["info",302,{matched:t,description:`${i.l}[${r}] ${i.op} ${i.rDim?`${i.rDim}[${n}]`:i.r}`}])}var qe=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,o)=>(o.testDistribution?n.total+=o.testDistribution:++n.missingDistribution,n.values.push(o.testDistribution),n),{values:[],total:0,missingDistribution:0});if(i>100)throw new Error(`Total distribution ${i} is over the maximum 100.`);if(i<100){let o=(100-i)/r;t.forEach((s,u)=>{typeof s=="undefined"&&(t[u]=o)})}return t},vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,o=t.getTestVariantId(e);if(o===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(o&&(n=i.find(s=>s.id===o),n||r==null||r(["warn",402,{missingVariant:o,variants:i.map(s=>s.id)}])),!n){let s=qe(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,p)=>{let m=s[p];if(u>c&&u<=c+m)return l;c+=m}),n&&(r==null||r(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(r==null||r(["info",404,n.id])),{result:n,variantAssigned:!o}}finally{r==null||r(["info",400,"ENDGROUP"])}};var It=require("dequal/lite"),C,T,k,rt,h,nt,_t,Q,St,qt=class{constructor(t){d(this,nt);d(this,Q);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,rt,{});d(this,h,(0,ye.default)());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,o,s,u;let{manifest:i,...r}=t;f(this,k,{}),(n=t.plugins)==null||n.forEach(c=>{!c.logDrain||a(this,h).on("log",c.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new B({onLogMessage:c=>a(this,h).emit("log",c),manifest:i,evaluator:new A({CK:xt,QS:bt,QK:Vt,PVC:ct,EVT:Et,PV:Tt})}),this.storage=new tt({...r,manifest:this.manifest,onServerTransitionReceived:c=>{f(this,C,c),c.ssv&&(f(this,T,c.ssv),a(this,h).emit("log",["debug",130,c.ssv]))},onLogMessage:c=>a(this,h).emit("log",c)}),this.storage.events.on("scoresUpdated",v(this,Q,St).bind(this)),a(this,C)||v(this,Q,St).call(this,this.storage.data),this.storage.events.on("quirksUpdated",c=>{let l=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(l),a(this,h).emit("quirksUpdated",c.quirks),a(this,h).emit("log",["info",4,c.quirks])}),(o=t.plugins)==null||o.forEach(c=>{!c.init||c.init(this)}),(s=a(this,C))!=null&&s.tests&&Object.entries((u=a(this,C))==null?void 0:u.tests).map(([c,l])=>{this.storage.data.tests[c]=l,v(this,nt,_t).call(this,{name:c,variantId:l,variantAssigned:!0})})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,T)}get quirks(){var t,i;return(i=(t=a(this,C))==null?void 0:t.quirks)!=null?i:this.storage.data.quirks}async update(t){var r,n;let i=[];(r=a(this,C))!=null&&r.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}});try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(n=t.url)==null?void 0:n.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([o,s])=>({type:"setquirk",data:{key:o,value:s}}))),t.enrichments&&t.enrichments.forEach(o=>{let s=W(o.cat,o.key);this.manifest.getDimensionByKey(s)?i.push({type:"modscore",data:{dimension:s,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),f(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,Q,St).call(this,this.storage.data),f(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r;let i=this.manifest.getTest(t);return i?(r=i.wv)!=null?r:this.storage.data.tests[t]:(a(this,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,i){this.storage.updateData([{type:"settest",data:{test:t,variant:i}}])}log(...t){a(this,h).emit("log",t)}test(t){var r,n;let i=vt({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)});return v(this,nt,_t).call(this,{name:t.name,variantId:(n=(r=i.result)==null?void 0:r.id)!=null?n:void 0,variantAssigned:i.variantAssigned}),i}personalize(t){let i=Gt({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)}),r=a(this,rt)[t.name],n={name:t.name,variantIds:i.variations.map(o=>{var s;return(s=o.id)!=null?s:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return r&&(0,It.dequal)(n.variantIds,r)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,rt)[t.name]=n.variantIds,i}async forget(t){f(this,k,{}),await this.storage.delete(t)}getServerToClientTransitionState(){let t={quirks:this.storage.data.quirks,ssv:a(this,T),tests:{}},i=this.storage.data.tests;return Object.entries(i).map(([r,n])=>{var o,s,u;((u=(s=(o=this.storage.options.transitionStore)==null?void 0:o.initialData)==null?void 0:s.tests)==null?void 0:u[r])!==i[r]&&t.tests&&(t.tests[r]=n)}),t}};C=new WeakMap,T=new WeakMap,k=new WeakMap,rt=new WeakMap,h=new WeakMap,nt=new WeakSet,_t=function(t){a(this,h).emit("testResult",t)},Q=new WeakSet,St=function(t){var n;let i={...t.scores};for(let o in t.sessionScores)i[o]=((n=i[o])!=null?n:0)+t.sessionScores[o];i=this.manifest.computeAggregateDimensions(i),!(0,It.dequal)(i,a(this,T))&&(f(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};var De=$(require("rfdc"));function yt(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 _e=(0,De.default)();function Ce(e){return([t,...i])=>{if(!yt(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
2
+ `,...n.map(_e))}}function je(e){return{logDrain:Ce(e)}}var xe={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:i})=>["storage",`${e} score ${i} 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:i})=>["signals",`${e.type}: ${i} 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 be=$(require("rfdc")),Qe=(0,be.default)();function Ve(e,t){let i=typeof document=="undefined",{enableOnServer:r=!1}=t!=null?t:{};return([n,...o])=>{if(!yt(e,n)||i&&!r)return;let[s,...u]=o,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=xe[s],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 ${s}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,D,...ot]=l(...u);c(`${m}[${S}] ${D}
3
+ `,...ot.map(Qe))}}function Fe(e,t){return{logDrain:Ve(e,t)}}var Ee=(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))(Ee||{}),Ke="nesitag";var jt=typeof top!="undefined";function He(){return{logDrain:e=>{!jt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!jt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:i}},window.location.origin)},n=s=>{!s.changed||(t.push(s),r())},o=s=>{!s.variantAssigned||(i.push(s),r())};if(jt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async s=>{if(!s.data)return;let u=s.data;await Be(u,e)})}catch(s){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",s)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",o),e.events.on("scoresUpdated",r),e.storage.events.on("*",r),()=>{e.events.off("scoresUpdated",r),e.storage.events.off("*",r),e.events.off("personalizationResult",n),e.events.off("testResult",o)}}}}async function Be(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 Je(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function We(e){let[t,i,r]=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(i))throw new Error("Invalid project ID");return{apiKey:t,projectId:i,apiHost:r||"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
- "use strict";var ae=Object.defineProperty;var ue=(e,t,r)=>t in e?ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var y=(e,t,r)=>(ue(e,typeof t!="symbol"?t+"":t,r),r),dt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var a=(e,t,r)=>(dt(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)},m=(e,t,r,i)=>(dt(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r);var S=(e,t,r)=>(dt(e,t,"access private method"),r);function wt(e,t){let r={...e};for(let i in t){let n=Rt(e,i,t,new Set([i]));n!==0&&(r[i]=n)}return r}function Rt(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=Rt(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 Z="_";var Q,F,M=class{constructor(t,r,i){d(this,Q,void 0);d(this,F,void 0);y(this,"signal");this.signal=t,m(this,Q,r),m(this,F,i)}computeSignal(t,r){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,r,this.signal,a(this,F)),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}})}}}};Q=new WeakMap,F=new WeakMap;var b,K,R,L=class{constructor({manifest:t,evaluator:r=new G({}),onLogMessage:i=()=>{}}){y(this,"data");d(this,b,void 0);d(this,K,void 0);d(this,R,void 0);var n,s,o;m(this,b,(n=t.project)!=null?n:{}),this.data=t,m(this,K,Object.entries((o=(s=a(this,b).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new M({...c,id:u},r,i))),m(this,R,i)}rollForControlGroup(){var t,r;return Math.random()<((r=(t=a(this,b).pz)==null?void 0:t.control)!=null?r:0)}getTest(t){var r;return(r=a(this,b).test)==null?void 0:r[t]}computeSignals(t){let r=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,K).forEach(i=>{a(this,R).call(this,["debug",201,"GROUP",i.signal]);try{i.computeSignal(t,r)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return r}computeAggregateDimensions(t){var r,i;return wt(t,(i=(r=a(this,b).pz)==null?void 0:r.agg)!=null?i:{})}getDimensionByKey(t){var i,n,s,o;let r=t.indexOf(Z);return r<=0?(n=(i=a(this,b).pz)==null?void 0:i.sig)==null?void 0:n[t]:(o=(s=a(this,b).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,r)]}};b=new WeakMap,K=new WeakMap,R=new WeakMap;import{dequal as le}from"dequal/lite";function V(e,t){var o,u,c,l,f,p;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:"":Ot(e)).toString(),s=(i?t.rhs:Ot(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((f=e==null?void 0:e.toString())!=null?f:"");case"!//":return!new RegExp(t.rhs.toString(),i?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");default:throw new Error(`Unknown match type ${r}.`)}}function O(e,t){return`'${("cs"in t?t.cs:!1)?e:e==null?void 0:e.toString().toUpperCase()}' ${ft(t)}`}function ft(e){return"rhs"in e?`${e.op} '${e.cs?e.rhs:e.rhs.toString().toUpperCase()}'`:`${e.op==="*"?"exists":"does not exist"}`}function Ot(e){var t,r;return(r=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?r:""}var $t=({update:e,criteria:t,onLogMessage:r})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let i=!le(Ut(e.state.cookies),Ut((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:V(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};function Ut(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...r}=e;return r}function Nt(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 At(e,t){return`${e} ${ce(t)}`}function ce(e){return`${e.op} ${e.rhs}`}function tt(e,t){return`${e}${Z}${t}`}var pt=tt("$pvc","v"),mt=({update:e,criteria:t,commands:r,onLogMessage:i})=>{var l,f;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())!==((f=e.previousState.url)==null?void 0:f.toString()))),o=(e.visitor.sessionScores[pt]||0)+1,u={result:!1,changed:n},c=r.some(p=>p.type==="modscoreS"&&p.data.dimension===pt);return n&&!c&&r.push({type:"modscoreS",data:{dimension:pt,delta:1}}),Nt(o,t.match)&&(u.result=!0),i==null||i(["debug",203,{criteria:t,result:u,explanation:At(o,t.match)}]),u};mt.alwaysExecute=!0;var Gt=({update:e,criteria:t,onLogMessage:r})=>{var u,c,l,f,p;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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(p=e.state.url)==null?void 0:p.searchParams.get(t.queryName),o={result:V(n,t.match),changed:i};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};var zt=({update:e,criteria:t,signal:r,onLogMessage:i})=>{var f;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=(f=e.state.quirks)==null?void 0:f[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:V(o,t.match),changed:u};return i==null||i(["debug",203,{criteria:t,result:l,explanation:O(o,t.match)}]),l};var It=({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=>V(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("', '")}' ${ft(t.event)}`}]),n};var qt=({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:V(i,t.path),changed:n};return r==null||r(["debug",203,{criteria:t,result:o,explanation:O(i,t.path)}]),o};var H,G=class{constructor(t){d(this,H,void 0);m(this,H,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 p of r.clauses){let v;if(p.type==="G")v=this.evaluate(t,p,i,n,s);else{let D=a(this,H)[p.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${p.type} signal criteria not registered`);v=D({update:t,criteria:p,commands:i,signal:n,onLogMessage:s})}v.changed&&(l=!0),!c&&v.result===u&&(c={result:u,changed:l})}let f=c!=null?c:{result:!u,changed:l};return o&&(s==null||s(["debug",204,f])),f}finally{o&&(s==null||s(["debug",202,"ENDGROUP"]))}}};H=new WeakMap;var et=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import de from"mitt";import{dequal as fe}from"dequal/lite";var pe="__UNIFORM_DATA__",U,z,I=class{constructor({initialData:t}){d(this,U,void 0);d(this,z,de());y(this,"events",{on:a(this,z).on,off:a(this,z).off});t&&m(this,U,t)}get data(){return a(this,U)}updateData(t,r){return m(this,U,r),this.handleUpdateData(t,r)}async delete(t){m(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){fe(this.data,t)||(m(this,U,t),a(this,z).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(pe);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,z=new WeakMap;var ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_t=ht.split(""),jt=new Array(123);for(let e=0;e<ht.length;e++)jt[ht.charCodeAt(e)]=e;var gt=e=>{if(e<0)return`-${gt(-e)}`;let t=e>>>0,r=e/4294967296>>>0,i="";for(;r>0;)i=_t[63&t]+i,t>>>=6,t|=(63&r)<<26,r>>>=6;let n="";do n=_t[63&t]+n,t>>>=6;while(t>0);return n+i},Qt=e=>{let t=0,r=e.charAt(0)==="-"?1:0;for(let i=r;i<e.length;i++)t=t*64+jt[e.charCodeAt(i)];return r?-t:t};import vt from"js-cookie";var St=typeof document=="undefined",me="ufvd",$,B,Ft=class extends I{constructor({serverCookieValue:r,cookieName:i=me,cookieAttributes:n={sameSite:"lax"}}){super({initialData:St?he(r):void 0});d(this,$,void 0);d(this,B,void 0);m(this,$,i),m(this,B,n)}handleDelete(){return St||vt.remove(a(this,$)),Promise.resolve()}async handleUpdateData(r,i){St||(i.consent?vt.set(a(this,$),ge(i),a(this,B)):vt.remove(a(this,$)))}};$=new WeakMap,B=new WeakMap;var Bt="~",Jt="!",Wt="-";function he(e){if(!e)return;let t=e.split(Bt);if(t.length>3)return;let[r,i,n]=t;return{consent:!0,sessionScores:Kt(yt(i)),scores:Kt(yt(n)),tests:yt(r)}}function yt(e){return e.split(Jt).map(r=>r.split(Wt)).reduce((r,i)=>(i.length!==2||(r[i[0]]=i[1]),r),{})}function Kt(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=Qt(i),t),{})}function ge(e){return[Dt(e.tests),Dt(Ht(e.sessionScores)),Dt(Ht(e.scores))].join(Bt)}function Ht(e){return Object.entries(e).reduce((t,[r,i])=>(t[r]=gt(i),t),{})}function Dt(e){return Object.entries(e).map(t=>t.join(Wt)).join(Jt)}var rt,Xt,Yt=class extends I{constructor({serverCookieValue:r,visitorIdCookieName:i="ufvi",...n}){super(n);d(this,rt);n.initialData||S(this,rt,Xt).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)}};rt=new WeakSet,Xt=async function(){let r=await new Promise(i=>{setTimeout(()=>{i(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)};function kr(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 p=s-o-t;if(p<=0)return!1;let v=p/864e5,D=1-Math.min(i,v*r);return D<=0?!1:(Zt(u,D),Zt(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function Zt(e,t){for(let r in e)r.startsWith("$")||(e[r]*=t)}import ye from"mitt";import{dequal as nt}from"dequal/lite";var it=class{constructor(){y(this,"inMemoryFallback",{});y(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 ve from"rfdc";var Se=ve();function Mt(e,t,r){let i=t?Se(t):et();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 f=(o=i.sessionScores[n.data.dimension])!=null?o:0;i.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":i.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),i}var ot="ufvisitor",E,A,q,g,x,k,P,N,at,Lt,ut,te,J,Ct,W,xt,st=class{constructor(t){d(this,x);d(this,P);d(this,at);d(this,ut);d(this,J);d(this,W);d(this,E,ye());d(this,A,new it);d(this,q,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(m(this,g,t),a(this,x,k)||S(this,P,N).call(this,S(this,W,xt).call(this),!0),t.transitionStore){let r=t.transitionStore.getClientTransitionState();r&&t.onServerTransitionReceived&&t.onServerTransitionReceived(r),t.transitionStore.events.on("dataUpdatedAsync",n=>{S(this,P,N).call(this,{...a(this,x,k).visitorData,...n})});let i=t.transitionStore.data;i&&S(this,P,N).call(this,{...a(this,x,k).visitorData,...i},!0)}}get data(){var r,i;let t=a(this,x,k);if(S(this,ut,te).call(this,t)){let{sessionScores:n,...s}=t.visitorData;return S(this,P,N).call(this,{...s,sessionScores:{}}),(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",120]),a(this,x,k).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}async updateData(t){var i,n,s,o;if(t.length===0)return;(n=(i=a(this,g)).onLogMessage)==null||n.call(i,["debug",101,t]);let r=Mt(t,this.data,(s=a(this,x,k))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,A).delete(ot,!0),S(this,P,N).call(this,r),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,x,k).visitorData))}async delete(t){var r,i,n,s,o;(i=(r=a(this,g)).onLogMessage)==null||i.call(r,["info",103,"GROUP",t]);try{a(this,A).delete(ot,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),S(this,P,N).call(this,S(this,W,xt).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};E=new WeakMap,A=new WeakMap,q=new WeakMap,g=new WeakMap,x=new WeakSet,k=function(){return a(this,A).get(ot)},P=new WeakSet,N=function(t,r=!1){var f,p,v,D,X,Et,Tt,kt,Pt;let i=a(this,x,k),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(S(this,J,Ct).call(this,t.scores),S(this,J,Ct).call(this,t.sessionScores),(p=(f=a(this,g)).decay)==null||p.call(f,{now:n,lastUpd:i==null?void 0:i.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!nt(i==null?void 0:i.visitorData.scores,t.scores),o=!nt(i==null?void 0:i.visitorData.sessionScores,t.sessionScores),u=!nt(i==null?void 0:i.visitorData.quirks,t.quirks),c=!nt(i==null?void 0:i.visitorData.tests,t.tests),l={updated:n,visitorData:t};S(this,at,Lt).call(this),a(this,A).set(ot,l,!!t.consent),(D=(v=a(this,g)).onLogMessage)==null||D.call(v,["debug",102,t]),r||((s||o)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((X=i==null?void 0:i.visitorData)==null?void 0:X.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Et=i==null?void 0:i.visitorData)==null?void 0:Et.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Pt=(kt=a(this,g)).onLogMessage)==null||Pt.call(kt,["debug",104,(Tt=t.controlGroup)!=null?Tt:!1])))},at=new WeakSet,Lt=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,q)&&window.clearTimeout(a(this,q)),m(this,q,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},ut=new WeakSet,te=function(t){let r=a(this,g).visitLifespan;return r?t.updated+r<Date.now():!1},J=new WeakSet,Ct=function(t){var r,i;if(!!a(this,g).manifest)for(let n in t){let s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((i=(r=a(this,g)).onLogMessage)==null||i.call(r,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},W=new WeakSet,xt=function(){var t,r,i;return{...et(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(i=(r=a(this,g).manifest)==null?void 0:r.rollForControlGroup())!=null?i:!1}};import Ce from"mitt";function ee({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=[],f=!1,p=t.scores;for(let v of r){if(l.length===i)break;if(!((o=v.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:v.id,op:(u=v.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(v);continue}c||re(v.id,v.pz,p,n)&&(f=!0,l.push(v))}return{personalized:f,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function re(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=>ie(s,r,i)):n=t.crit.some(s=>ie(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 ie(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=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(o))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 _(r,l,e,s,o),l}else if(i===">="){let l=s>=o;return _(r,l,e,s,o),l}else if(i==="<"){let l=s<o;return _(r,l,e,s,o),l}else if(i==="<="){let l=s<=o;return _(r,l,e,s,o),l}else if(i==="="){let l=s===o;return _(r,l,e,s,o),l}else if(i==="!="){let l=s!==o;return _(r,l,e,s,o),l}else throw new Error(`Unknown op: ${i}`)}function _(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 De=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},bt=({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=De(r),u=Math.floor(Math.random()*100),c=0;n=r.find((l,f)=>{let p=o[f];if(u>c&&u<=c+p)return l;c+=p}),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 ne}from"dequal/lite";var C,w,T,Y,h,j,lt,oe=class{constructor(t){d(this,j);y(this,"manifest");d(this,C,void 0);d(this,w,{});d(this,T,void 0);d(this,Y,{});d(this,h,Ce());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:r,...i}=t;m(this,T,{}),(n=t.plugins)==null||n.forEach(o=>{!o.logDrain||a(this,h).on("log",o.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new L({onLogMessage:o=>a(this,h).emit("log",o),manifest:r,evaluator:new G({CK:$t,QS:Gt,QK:zt,PVC:mt,EVT:It,PV:qt})}),this.storage=new st({...i,manifest:this.manifest,onServerTransitionReceived:o=>{m(this,C,o),o.ssv&&(m(this,w,o.ssv),a(this,h).emit("log",["debug",130,o.ssv]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",S(this,j,lt).bind(this)),a(this,C)||S(this,j,lt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,w),state:a(this,T),previousState:a(this,T),visitor:this.storage.data});this.storage.updateData(u),a(this,h).emit("quirksUpdated",o.quirks),a(this,h).emit("log",["info",4,o.quirks])}),(s=t.plugins)==null||s.forEach(o=>{!o.init||o.init(this)})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,w)}get quirks(){var t,r;return(r=(t=a(this,C))==null?void 0:t.quirks)!=null?r:this.storage.data.quirks}async update(t){var i,n,s;let r=[];(i=a(this,C))!=null&&i.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(n=a(this,C))!=null&&n.tests&&r.push(...Object.entries(a(this,C).tests).map(([o,u])=>({type:"settest",data:{test:o,variant:u}})));try{a(this,h).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=tt(o.cat,o.key);this.manifest.getDimensionByKey(u)?r.push({type:"modscore",data:{dimension:u,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),r.push(...this.manifest.computeSignals({state:t,previousState:a(this,T),visitor:this.storage.data,scores:a(this,w)})),m(this,T,{...a(this,T),...t}),await this.storage.updateData(r),a(this,C)&&(S(this,j,lt).call(this,this.storage.data),m(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).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,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,r){this.storage.updateData([{type:"settest",data:{test:t,variant:r}}])}log(...t){a(this,h).emit("log",t)}test(t){var i,n;let r=bt({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)});return a(this,h).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=ee({...t,context:this,onLogMessage:s=>a(this,h).emit("log",s)}),i=a(this,Y)[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&&ne(n.variantIds,i)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,Y)[t.name]=n.variantIds,r}async forget(t){m(this,T,{}),await this.storage.delete(t)}};C=new WeakMap,w=new WeakMap,T=new WeakMap,Y=new WeakMap,h=new WeakMap,j=new WeakSet,lt=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),!ne(r,a(this,w))&&(m(this,w,r),a(this,h).emit("scoresUpdated",r),a(this,h).emit("log",["info",3,r]))};import xe from"rfdc";function ct(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 be=xe();function Ve(e){return([t,...r])=>{if(!ct(e,t))return;let[i,...n]=r;console[t](`\u{1F94B} [${t}] Uniform event ID ${i}
2
- `,...n.map(be))}}function fi(e){return{logDrain:Ve(e)}}var se={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 Ee from"rfdc";var Te=Ee();function ke(e,t){let r=typeof document=="undefined",{enableOnServer:i=!1}=t!=null?t:{};return([n,...s])=>{if(!ct(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=se[o],f="";switch(n){case"debug":f="\u{1F41E}";break;case"info":f="\u{1F4AC}";break;case"warn":f="\u26A0\uFE0F";break;case"error":f="\u{1F4A5}";break}let p=f;if(!l){c(`${p} unknown event ID ${o}. Log messages data may be older than Uniform Context package.`,...u);return}let[v,D,...X]=l(...u);c(`${p}[${v}] ${D}
3
- `,...X.map(Te))}}function Si(e,t){return{logDrain:ke(e,t)}}var Pe=(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))(Pe||{}),Di="nesitag";var Vt=typeof top!="undefined";function xi(){return{logDrain:e=>{!Vt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],r=[],i=()=>{!Vt||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(Vt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await we(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 we(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 Vi(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function Ei(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{oe as Context,Ft as CookieTransitionDataStore,Di as EdgeNodeTagName,Yt as EdgeTransitionDataStore,G as GroupCriteriaEvaluator,L as ManifestInstance,pe as SERVER_STATE_ID,Pe as ScriptType,I as TransitionDataStore,me as UNIFORM_DEFAULT_COOKIE_NAME,st as VisitorDataStore,wt as computeAggregateDimensions,$t as cookieEvaluator,Ve as createConsoleLogDrain,ke as createDebugConsoleLogDrain,kr as createLinearDecay,qt as currentPageEvaluator,et as emptyVisitorData,fi as enableConsoleLogDrain,xi as enableContextDevTools,Si as enableDebugConsoleLogDrain,re as evaluateVariantMatch,It as eventEvaluator,O as explainStringMatch,ft as explainStringMatchCriteria,tt as getEnrichmentVectorKey,V as isStringMatch,pt as pageViewCountDimension,mt as pageViewCountEvaluator,Ei as parseQuickConnect,ee as personalizeVariations,Gt as queryStringEvaluator,zt as quirkEvaluator,Vi as serializeQuickConnect,bt as testVariations};
1
+ "use strict";var ce=Object.defineProperty;var de=(e,t,i)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var y=(e,t,i)=>(de(e,typeof t!="symbol"?t+"":t,i),i),ft=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(ft(e,t,"read from private field"),i?i.call(e):t.get(e)),d=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},f=(e,t,i,r)=>(ft(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(ft(e,t,"access private method"),i);function Ut(e,t){let i={...e};for(let r in t){let n=$t(e,r,t,new Set([r]));n!==0&&(i[r]=n)}return i}function $t(e,t,i,r){var o;let n=0;for(let s of i[t].inputs){let u=(o=e[s.dim])!=null?o:0;if(!u&&i[s.dim]){if(r.has(s.dim))continue;let l=new Set(r);l.add(s.dim),u=$t(e,s.dim,i,l)}if(u!==0)if(s.sign==="c"){n=0;break}else s.sign==="-"?n-=u:n+=u}return n}var L="_";var Q,F,tt=class{constructor(t,i,r){d(this,Q,void 0);d(this,F,void 0);y(this,"signal");this.signal=t,f(this,Q,i),f(this,F,r)}computeSignal(t,i){if(t.scores[this.signal.id]>=this.signal.cap&&this.signal.dur!=="t")return;let n=a(this,Q).evaluate(t,this.signal.crit,i,this.signal,a(this,F)),o=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.push({type:o,data:{dimension:this.signal.id,delta:this.signal.str}});else if(this.signal.dur==="t"){let s=t.visitor.sessionScores[this.signal.id];s&&i.push({type:o,data:{dimension:this.signal.id,delta:-s}})}}}};Q=new WeakMap,F=new WeakMap;var b,K,R,et=class{constructor({manifest:t,evaluator:i=new G({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,b,void 0);d(this,K,void 0);d(this,R,void 0);var n,o,s;f(this,b,(n=t.project)!=null?n:{}),this.data=t,f(this,K,Object.entries((s=(o=a(this,b).pz)==null?void 0:o.sig)!=null?s:[]).map(([u,c])=>new tt({...c,id:u},i,r))),f(this,R,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,b).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,b).test)==null?void 0:i[t]}computeSignals(t){let i=[];a(this,R).call(this,["debug",200,"GROUP"]);try{a(this,K).forEach(r=>{a(this,R).call(this,["debug",201,"GROUP",r.signal]);try{r.computeSignal(t,i)}finally{a(this,R).call(this,["debug",201,"ENDGROUP"])}})}finally{a(this,R).call(this,["debug",200,"ENDGROUP"])}return i}computeAggregateDimensions(t){var i,r;return Ut(t,(r=(i=a(this,b).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,o,s;let i=t.indexOf(L);return i<=0?(n=(r=a(this,b).pz)==null?void 0:r.sig)==null?void 0:n[t]:(s=(o=a(this,b).pz)==null?void 0:o.enr)==null?void 0:s[t.substring(0,i)]}};b=new WeakMap,K=new WeakMap,R=new WeakMap;import{dequal as pe}from"dequal/lite";function V(e,t){var s,u,c,l,p,m;let i=(s=t==null?void 0:t.op)!=null?s:"=";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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":At(e)).toString(),o=(r?t.rhs:At(t.rhs)).toString();switch(i){case"=":return n===o;case"!=":return n!==o;case"~":return(c=n.includes(o))!=null?c:!1;case"!~":return!((l=n.includes(o))==null||l);case"//":return new RegExp(t.rhs.toString(),r?"":"i").test((p=e==null?void 0:e.toString())!=null?p:"");case"!//":return!new RegExp(t.rhs.toString(),r?"":"i").test((m=e==null?void 0:e.toString())!=null?m:"");default:throw new Error(`Unknown match type ${i}.`)}}function O(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 At(e){var t,i;return(i=(t=e==null?void 0:e.toString())==null?void 0:t.toUpperCase())!=null?i:""}var Gt=({update:e,criteria:t,onLogMessage:i})=>{var u,c;if(t.type!=="CK")return{result:!1,changed:!1};let r=!pe(Nt(e.state.cookies),Nt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],s={result:V(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(n,t.match)}]),s};function Nt(e){if(!e)return;if(!e.ufvd)return e;let{ufvd:t,...i}=e;return i}function zt(e,t){var r;if(typeof e=="undefined"||e===null)return!1;let i=Number(e);if(isNaN(i))return!1;switch((r=t==null?void 0:t.op)!=null?r:"="){case"=":return i===t.rhs;case"!=":return i!==t.rhs;case">":return i>t.rhs;case"<":return i<t.rhs;default:return console.warn(`Unknown match type ${t.op} is false.`),!1}}function It(e,t){return`${e} ${fe(t)}`}function fe(e){return`${e.op} ${e.rhs}`}function it(e,t){return`${e}${L}${t}`}var ht=it("$pvc","v"),gt=({update:e,criteria:t,commands:i,onLogMessage:r})=>{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()))),s=(e.visitor.sessionScores[ht]||0)+1,u={result:!1,changed:n},c=i.some(m=>m.type==="modscoreS"&&m.data.dimension===ht);return n&&!c&&i.push({type:"modscoreS",data:{dimension:ht,delta:1}}),zt(s,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:It(s,t.match)}]),u};gt.alwaysExecute=!0;var qt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,p,m;if(t.type!=="QS")return{result:!1,changed:!1};let r=!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),s={result:V(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(n,t.match)}]),s};var _t=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var p;if(t.type!=="QK")return{result:!1,changed:!1};if(typeof document=="undefined"&&i.dur==="t"&&e.scores[i.id]>0)return{result:!0,changed:!1};let n=e.visitor.quirks[t.key],o=(p=e.state.quirks)==null?void 0:p[t.key],s=o!=null?o:n,u=Boolean(o&&n!==o),l={result:V(s,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:O(s,t.match)}]),l};var jt=({update:e,criteria:t,onLogMessage:i})=>{var o,s,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(s=(o=e.state.events)==null?void 0:o.some(c=>V(c.event,t.event)))!=null?s:!1,n={result:r,changed:r};return i==null||i(["debug",203,{criteria:t,result:n,explanation:`'${(u=e.state.events)==null?void 0:u.join("', '")}' ${mt(t.event)}`}]),n};var Qt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l;if(t.type!=="PV")return{result:!1,changed:!1};let r=(u=e.state.url)==null?void 0:u.pathname,n=!e.previousState||(r==null?void 0:r.toString())!==((l=(c=e.previousState.url)==null?void 0:c.pathname)==null?void 0:l.toString()),s={result:V(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:s,explanation:O(r,t.path)}]),s};var H,G=class{constructor(t){d(this,H,void 0);f(this,H,t)}evaluate(t,i,r,n,o){let s=i.clauses.length>1;s&&(o==null||o(["debug",202,"GROUP",i]));try{let u=!(i.op==="&"||!i.op),c=null,l=!1;for(let m of i.clauses){let S;if(m.type==="G")S=this.evaluate(t,m,r,n,o);else{let D=a(this,H)[m.type];if(c&&!D.alwaysExecute)continue;if(!D)throw new Error(`${m.type} signal criteria not registered`);S=D({update:t,criteria:m,commands:r,signal:n,onLogMessage:o})}S.changed&&(l=!0),!c&&S.result===u&&(c={result:u,changed:l})}let p=c!=null?c:{result:!u,changed:l};return s&&(o==null||o(["debug",204,p])),p}finally{s&&(o==null||o(["debug",202,"ENDGROUP"]))}}};H=new WeakMap;var rt=()=>({quirks:{},scores:{},sessionScores:{},tests:{},consent:!1,controlGroup:!1});import me from"mitt";import{dequal as he}from"dequal/lite";var ge="__UNIFORM_DATA__",U,B,z,I=class{constructor({initialData:t}){d(this,U,void 0);d(this,B,void 0);d(this,z,me());y(this,"events",{on:a(this,z).on,off:a(this,z).off});t&&(f(this,U,t),f(this,B,t))}get data(){return a(this,U)}get initialData(){return a(this,B)}updateData(t,i){return f(this,U,i),this.handleUpdateData(t,i)}async delete(t){f(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){he(this.data,t)||(f(this,U,t),a(this,z).emit("dataUpdatedAsync",t))}getClientTransitionState(){if(typeof document=="undefined")return;let t=document.getElementById(ge);return t!=null&&t.textContent?JSON.parse(t.textContent):void 0}};U=new WeakMap,B=new WeakMap,z=new WeakMap;var vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ft=vt.split(""),Kt=new Array(123);for(let e=0;e<vt.length;e++)Kt[vt.charCodeAt(e)]=e;var St=e=>{if(e<0)return`-${St(-e)}`;let t=e>>>0,i=e/4294967296>>>0,r="";for(;i>0;)r=Ft[63&t]+r,t>>>=6,t|=(63&i)<<26,i>>>=6;let n="";do n=Ft[63&t]+n,t>>>=6;while(t>0);return n+r},Ht=e=>{let t=0,i=e.charAt(0)==="-"?1:0;for(let r=i;r<e.length;r++)t=t*64+Kt[e.charCodeAt(r)];return i?-t:t};import yt from"js-cookie";var Dt=typeof document=="undefined",ve="ufvd",$,J,Bt=class extends I{constructor({serverCookieValue:i,cookieName:r=ve,cookieAttributes:n={sameSite:"lax"}}){super({initialData:Dt?Se(i):void 0});d(this,$,void 0);d(this,J,void 0);f(this,$,r),f(this,J,n)}handleDelete(){return Dt||yt.remove(a(this,$)),Promise.resolve()}async handleUpdateData(i,r){Dt||(r.consent?yt.set(a(this,$),ye(r),a(this,J)):yt.remove(a(this,$)))}};$=new WeakMap,J=new WeakMap;var Yt="~",Xt="!",Zt="-";function Se(e){if(!e)return;let t=e.split(Yt);if(t.length>3)return;let[i,r,n]=t;return{consent:!0,sessionScores:Jt(Ct(r)),scores:Jt(Ct(n)),tests:Ct(i)}}function Ct(e){return e.split(Xt).map(i=>i.split(Zt)).reduce((i,r)=>(r.length!==2||(i[r[0]]=r[1]),i),{})}function Jt(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=Ht(r),t),{})}function ye(e){return[xt(e.tests),xt(Wt(e.sessionScores)),xt(Wt(e.scores))].join(Yt)}function Wt(e){return Object.entries(e).reduce((t,[i,r])=>(t[i]=St(r),t),{})}function xt(e){return Object.entries(e).map(t=>t.join(Zt)).join(Xt)}var nt,Lt,Mt=class extends I{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,nt);n.initialData||v(this,nt,Lt).call(this).catch(o=>{console.error(o)})}handleDelete(i){throw new Error("Method not implemented.")}async handleUpdateData(i){let r=await new Promise(n=>{setTimeout(()=>{n(void 0)},2e3)});r&&this.signalAsyncDataUpdate(r)}};nt=new WeakSet,Lt=async function(){let i=await new Promise(r=>{setTimeout(()=>{r(void 0)},2e3)});i&&this.signalAsyncDataUpdate(i)};function Ri(e){let{gracePeriod:t=864e5,decayRate:i=1/30,decayCap:r=.95}=e!=null?e:{};return function({now:o,lastUpd:s,scores:u,sessionScores:c,onLogMessage:l}){if(typeof s!="number")return!1;let m=o-s-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(te(u,D),te(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function te(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}import xe from"mitt";import{dequal as st}from"dequal/lite";var ot=class{constructor(){y(this,"inMemoryFallback",{});y(this,"hasLocalStorageObject",typeof localStorage!="undefined")}get(t){let i=this.inMemoryFallback[t];if(!this.hasLocalStorageObject||i)return i;try{let r=localStorage.getItem(t);return r?JSON.parse(r):void 0}catch(r){return i}}set(t,i,r){if(this.inMemoryFallback[t]=i,!(!this.hasLocalStorageObject||!r))try{localStorage.setItem(t,JSON.stringify(i))}catch(n){console.warn(n)}}delete(t,i){i||delete this.inMemoryFallback[t];try{localStorage.removeItem(t)}catch(r){}}};import De from"rfdc";var Ce=De();function ee(e,t,i){let r=t?Ce(t):rt();return e.forEach(n=>{var o,s;switch(n.type){case"consent":r.consent=n.data;break;case"setquirk":r.quirks[n.data.key]=n.data.value;break;case"settest":r.tests[n.data.test]=n.data.variant;break;case"modscore":if(i)break;let u=Number(n.data.delta);if(isNaN(u))throw new Error("Non-number delta received");let c=(o=r.scores[n.data.dimension])!=null?o:0;r.scores[n.data.dimension]=c+u;break;case"modscoreS":if(i)break;let l=Number(n.data.delta);if(isNaN(l))throw new Error("Non-number delta received");let p=(s=r.sessionScores[n.data.dimension])!=null?s:0;r.sessionScores[n.data.dimension]=p+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var at="ufvisitor",E,N,q,g,x,P,w,A,lt,ie,ct,re,W,bt,Y,Vt,ut=class{constructor(t){d(this,x);d(this,w);d(this,lt);d(this,ct);d(this,W);d(this,Y);d(this,E,xe());d(this,N,new ot);d(this,q,void 0);d(this,g,void 0);y(this,"events",{on:a(this,E).on,off:a(this,E).off});if(f(this,g,t),a(this,x,P)||v(this,w,A).call(this,v(this,Y,Vt).call(this),!0),t.transitionStore){let i=t.transitionStore.getClientTransitionState();i&&t.onServerTransitionReceived&&t.onServerTransitionReceived(i),t.transitionStore.events.on("dataUpdatedAsync",n=>{v(this,w,A).call(this,{...a(this,x,P).visitorData,...n})});let r=t.transitionStore.data;r&&v(this,w,A).call(this,{...a(this,x,P).visitorData,...r},!0)}}get data(){var i,r;let t=a(this,x,P);if(v(this,ct,re).call(this,t)){let{sessionScores:n,...o}=t.visitorData;return v(this,w,A).call(this,{...o,sessionScores:{}}),(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",120]),a(this,x,P).visitorData}return t.visitorData}get decayEnabled(){return!!a(this,g).decay}get options(){return a(this,g)}async updateData(t){var r,n,o,s;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=ee(t,this.data,(o=a(this,x,P))==null?void 0:o.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,N).delete(at,!0),v(this,w,A).call(this,i),await((s=a(this,g).transitionStore)==null?void 0:s.updateData(t,a(this,x,P).visitorData))}async delete(t){var i,r,n,o,s;(r=(i=a(this,g)).onLogMessage)==null||r.call(i,["info",103,"GROUP",t]);try{a(this,N).delete(at,!1),await((n=a(this,g).transitionStore)==null?void 0:n.delete(t)),v(this,w,A).call(this,v(this,Y,Vt).call(this))}finally{(s=(o=a(this,g)).onLogMessage)==null||s.call(o,["info",103,"ENDGROUP"])}}};E=new WeakMap,N=new WeakMap,q=new WeakMap,g=new WeakMap,x=new WeakSet,P=function(){return a(this,N).get(at)},w=new WeakSet,A=function(t,i=!1){var p,m,S,D,M,Pt,wt,Rt,Ot;let r=a(this,x,P),n=Date.now();t.controlGroup?(t.scores={},t.sessionScores={}):(v(this,W,bt).call(this,t.scores),v(this,W,bt).call(this,t.sessionScores),(m=(p=a(this,g)).decay)==null||m.call(p,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let o=!st(r==null?void 0:r.visitorData.scores,t.scores),s=!st(r==null?void 0:r.visitorData.sessionScores,t.sessionScores),u=!st(r==null?void 0:r.visitorData.quirks,t.quirks),c=!st(r==null?void 0:r.visitorData.tests,t.tests),l={updated:n,visitorData:t};v(this,lt,ie).call(this),a(this,N).set(at,l,!!t.consent),(D=(S=a(this,g)).onLogMessage)==null||D.call(S,["debug",102,t]),i||((o||s)&&a(this,E).emit("scoresUpdated",t),u&&a(this,E).emit("quirksUpdated",t),c&&a(this,E).emit("testsUpdated",t),((M=r==null?void 0:r.visitorData)==null?void 0:M.consent)!==t.consent&&a(this,E).emit("consentUpdated",t),((Pt=r==null?void 0:r.visitorData)==null?void 0:Pt.controlGroup)!==t.controlGroup&&(a(this,E).emit("controlGroupUpdated",t),(Ot=(Rt=a(this,g)).onLogMessage)==null||Ot.call(Rt,["debug",104,(wt=t.controlGroup)!=null?wt:!1])))},lt=new WeakSet,ie=function(){typeof document=="undefined"||!a(this,g).visitLifespan||(a(this,q)&&window.clearTimeout(a(this,q)),f(this,q,window.setTimeout(()=>{this.data},a(this,g).visitLifespan+50)))},ct=new WeakSet,re=function(t){let i=a(this,g).visitLifespan;return i?t.updated+i<Date.now():!1},W=new WeakSet,bt=function(t){var i,r;if(!!a(this,g).manifest)for(let n in t){let o=t[n],s=a(this,g).manifest.getDimensionByKey(n);!s||o>s.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:o,cap:s.cap}]),t[n]=s.cap)}},Y=new WeakSet,Vt=function(){var t,i,r;return{...rt(),consent:(t=a(this,g).defaultConsent)!=null?t:!1,controlGroup:(r=(i=a(this,g).manifest)==null?void 0:i.rollForControlGroup())!=null?r:!1}};import Ve from"mitt";function ne({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var o,s,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(o=t.storage.data.controlGroup)!=null?o:!1,l=[],p=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((s=S.pz)!=null&&s.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||oe(S.id,S.pz,m,n)&&(p=!0,l.push(S))}return{personalized:p,variations:l}}finally{n==null||n(["info",300,"ENDGROUP"])}}function oe(e,t,i,r){r==null||r(["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(o=>se(o,i,r)):n=t.crit.some(o=>se(o,i,r)):(r==null||r(["info",302,{matched:!0,description:"default variation"}]),n=!0),r==null||r(["info",303,n])}finally{r==null||r(["info",301,"ENDGROUP"])}return n}function se(e,t,i){var u,c;let{op:r,l:n}=e,o=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the highest score`}]),l}else if(r==="-"){let l=Math.min(...Object.values(t))===o&&o>0;return i==null||i(["info",302,{matched:l,description:`${e.l} has the lowest non-zero score`}]),l}let s=parseInt(e.rDim?t[e.rDim]:e.r,10);if(isNaN(s))return i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=o>s;return _(i,l,e,o,s),l}else if(r===">="){let l=o>=s;return _(i,l,e,o,s),l}else if(r==="<"){let l=o<s;return _(i,l,e,o,s),l}else if(r==="<="){let l=o<=s;return _(i,l,e,o,s),l}else if(r==="="){let l=o===s;return _(i,l,e,o,s),l}else if(r==="!="){let l=o!==s;return _(i,l,e,o,s),l}else throw new Error(`Unknown op: ${r}`)}function _(e,t,i,r,n){e==null||e(["info",302,{matched:t,description:`${i.l}[${r}] ${i.op} ${i.rDim?`${i.rDim}[${n}]`:i.r}`}])}var be=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,o)=>(o.testDistribution?n.total+=o.testDistribution:++n.missingDistribution,n.values.push(o.testDistribution),n),{values:[],total:0,missingDistribution:0});if(i>100)throw new Error(`Total distribution ${i} is over the maximum 100.`);if(i<100){let o=(100-i)/r;t.forEach((s,u)=>{typeof s=="undefined"&&(t[u]=o)})}return t},Et=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,o=t.getTestVariantId(e);if(o===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(o&&(n=i.find(s=>s.id===o),n||r==null||r(["warn",402,{missingVariant:o,variants:i.map(s=>s.id)}])),!n){let s=be(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,p)=>{let m=s[p];if(u>c&&u<=c+m)return l;c+=m}),n&&(r==null||r(["info",403,n.id]),t.setTestVariantId(e,n.id))}return n&&(r==null||r(["info",404,n.id])),{result:n,variantAssigned:!o}}finally{r==null||r(["info",400,"ENDGROUP"])}};import{dequal as ae}from"dequal/lite";var C,T,k,X,h,Z,Tt,j,dt,ue=class{constructor(t){d(this,Z);d(this,j);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,X,{});d(this,h,Ve());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,o,s,u;let{manifest:i,...r}=t;f(this,k,{}),(n=t.plugins)==null||n.forEach(c=>{!c.logDrain||a(this,h).on("log",c.logDrain)}),a(this,h).emit("log",["info",1,"GROUP"]);try{this.manifest=new et({onLogMessage:c=>a(this,h).emit("log",c),manifest:i,evaluator:new G({CK:Gt,QS:qt,QK:_t,PVC:gt,EVT:jt,PV:Qt})}),this.storage=new ut({...r,manifest:this.manifest,onServerTransitionReceived:c=>{f(this,C,c),c.ssv&&(f(this,T,c.ssv),a(this,h).emit("log",["debug",130,c.ssv]))},onLogMessage:c=>a(this,h).emit("log",c)}),this.storage.events.on("scoresUpdated",v(this,j,dt).bind(this)),a(this,C)||v(this,j,dt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",c=>{let l=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),visitor:this.storage.data});this.storage.updateData(l),a(this,h).emit("quirksUpdated",c.quirks),a(this,h).emit("log",["info",4,c.quirks])}),(o=t.plugins)==null||o.forEach(c=>{!c.init||c.init(this)}),(s=a(this,C))!=null&&s.tests&&Object.entries((u=a(this,C))==null?void 0:u.tests).map(([c,l])=>{this.storage.data.tests[c]=l,v(this,Z,Tt).call(this,{name:c,variantId:l,variantAssigned:!0})})}finally{a(this,h).emit("log",["info",1,"ENDGROUP"])}}get scores(){return a(this,T)}get quirks(){var t,i;return(i=(t=a(this,C))==null?void 0:t.quirks)!=null?i:this.storage.data.quirks}async update(t){var r,n;let i=[];(r=a(this,C))!=null&&r.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}});try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(n=t.url)==null?void 0:n.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([o,s])=>({type:"setquirk",data:{key:o,value:s}}))),t.enrichments&&t.enrichments.forEach(o=>{let s=it(o.cat,o.key);this.manifest.getDimensionByKey(s)?i.push({type:"modscore",data:{dimension:s,delta:o.str}}):a(this,h).emit("log",["warn",5,o])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),f(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,j,dt).call(this,this.storage.data),f(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r;let i=this.manifest.getTest(t);return i?(r=i.wv)!=null?r:this.storage.data.tests[t]:(a(this,h).emit("log",["warn",401,t]),null)}setTestVariantId(t,i){this.storage.updateData([{type:"settest",data:{test:t,variant:i}}])}log(...t){a(this,h).emit("log",t)}test(t){var r,n;let i=Et({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)});return v(this,Z,Tt).call(this,{name:t.name,variantId:(n=(r=i.result)==null?void 0:r.id)!=null?n:void 0,variantAssigned:i.variantAssigned}),i}personalize(t){let i=ne({...t,context:this,onLogMessage:o=>a(this,h).emit("log",o)}),r=a(this,X)[t.name],n={name:t.name,variantIds:i.variations.map(o=>{var s;return(s=o.id)!=null?s:"Unknown"}),control:this.storage.data.controlGroup,changed:!0};return r&&ae(n.variantIds,r)&&(n.changed=!1),a(this,h).emit("personalizationResult",n),a(this,X)[t.name]=n.variantIds,i}async forget(t){f(this,k,{}),await this.storage.delete(t)}getServerToClientTransitionState(){let t={quirks:this.storage.data.quirks,ssv:a(this,T),tests:{}},i=this.storage.data.tests;return Object.entries(i).map(([r,n])=>{var o,s,u;((u=(s=(o=this.storage.options.transitionStore)==null?void 0:o.initialData)==null?void 0:s.tests)==null?void 0:u[r])!==i[r]&&t.tests&&(t.tests[r]=n)}),t}};C=new WeakMap,T=new WeakMap,k=new WeakMap,X=new WeakMap,h=new WeakMap,Z=new WeakSet,Tt=function(t){a(this,h).emit("testResult",t)},j=new WeakSet,dt=function(t){var n;let i={...t.scores};for(let o in t.sessionScores)i[o]=((n=i[o])!=null?n:0)+t.sessionScores[o];i=this.manifest.computeAggregateDimensions(i),!ae(i,a(this,T))&&(f(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};import Ee from"rfdc";function pt(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 Te=Ee();function ke(e){return([t,...i])=>{if(!pt(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
2
+ `,...n.map(Te))}}function hr(e){return{logDrain:ke(e)}}var le={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:i})=>["storage",`${e} score ${i} 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:i})=>["signals",`${e.type}: ${i} 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 Pe from"rfdc";var we=Pe();function Re(e,t){let i=typeof document=="undefined",{enableOnServer:r=!1}=t!=null?t:{};return([n,...o])=>{if(!pt(e,n)||i&&!r)return;let[s,...u]=o,c=console[n];if(u[0]==="GROUP"&&(u.shift(),c=console.groupCollapsed),u[0]==="ENDGROUP"){console.groupEnd();return}let l=le[s],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 ${s}. Log messages data may be older than Uniform Context package.`,...u);return}let[S,D,...M]=l(...u);c(`${m}[${S}] ${D}
3
+ `,...M.map(we))}}function Cr(e,t){return{logDrain:Re(e,t)}}var Oe=(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))(Oe||{}),br="nesitag";var kt=typeof top!="undefined";function Er(){return{logDrain:e=>{!kt||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!kt||top==null||top.postMessage({type:"uniform:context:data",data:{scores:e.scores,data:e.storage.data,manifest:e.manifest.data,personalizations:t,tests:i}},window.location.origin)},n=s=>{!s.changed||(t.push(s),r())},o=s=>{!s.variantAssigned||(i.push(s),r())};if(kt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async s=>{if(!s.data)return;let u=s.data;await Ue(u,e)})}catch(s){console.warn("Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",s)}top==null||top.postMessage({type:"uniform:context:hello",uiVersion:2},window.location.origin),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",o),e.events.on("scoresUpdated",r),e.storage.events.on("*",r),()=>{e.events.off("scoresUpdated",r),e.storage.events.off("*",r),e.events.off("personalizationResult",n),e.events.off("testResult",o)}}}}async function Ue(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 kr(e){return`${e.apiKey}|${e.projectId}${e.apiHost?`|${e.apiHost}`:""}`}function Pr(e){let[t,i,r]=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(i))throw new Error("Invalid project ID");return{apiKey:t,projectId:i,apiHost:r||"https://uniform.app"}}export{ue as Context,Bt as CookieTransitionDataStore,br as EdgeNodeTagName,Mt as EdgeTransitionDataStore,G as GroupCriteriaEvaluator,et as ManifestInstance,ge as SERVER_STATE_ID,Oe as ScriptType,I as TransitionDataStore,ve as UNIFORM_DEFAULT_COOKIE_NAME,ut as VisitorDataStore,Ut as computeAggregateDimensions,Gt as cookieEvaluator,ke as createConsoleLogDrain,Re as createDebugConsoleLogDrain,Ri as createLinearDecay,Qt as currentPageEvaluator,rt as emptyVisitorData,hr as enableConsoleLogDrain,Er as enableContextDevTools,Cr as enableDebugConsoleLogDrain,oe as evaluateVariantMatch,jt as eventEvaluator,O as explainStringMatch,mt as explainStringMatchCriteria,it as getEnrichmentVectorKey,V as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,Pr as parseQuickConnect,ne as personalizeVariations,qt as queryStringEvaluator,_t as quirkEvaluator,kr as serializeQuickConnect,Et as testVariations};