@uniformdev/context 16.2.4 → 17.0.0

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/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 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)},p=(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:()=>Ve,TransitionDataStore:()=>N,UNIFORM_DEFAULT_COOKIE_NAME:()=>ae,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Ct,cookieEvaluator:()=>xt,createConsoleLogDrain:()=>Ce,createDebugConsoleLogDrain:()=>Ee,createLinearDecay:()=>ze,currentPageEvaluator:()=>Tt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>_e,enableContextDevTools:()=>He,enableDebugConsoleLogDrain:()=>Fe,evaluateVariantMatch:()=>zt,eventEvaluator:()=>Vt,explainStringMatch:()=>P,explainStringMatchCriteria:()=>ut,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>lt,pageViewCountEvaluator:()=>ct,parseQuickConnect:()=>We,personalizeVariations:()=>Gt,queryStringEvaluator:()=>bt,quirkEvaluator:()=>Et,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 s;let n=0;for(let o of i[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&i[o.dim]){if(r.has(o.dim))continue;let l=new Set(r);l.add(o.dim),u=Jt(e,o.dim,i,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.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,p(this,K,i),p(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)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.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&&i.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,J,O,B=class{constructor({manifest:t,evaluator:i=new A({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,E,void 0);d(this,J,void 0);d(this,O,void 0);var n,s,o;p(this,E,(n=t.project)!=null?n:{}),this.data=t,p(this,J,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new at({...c,id:u},i,r))),p(this,O,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,E).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,E).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,E).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,s,o;let i=t.indexOf(st);return i<=0?(n=(r=a(this,E).pz)==null?void 0:r.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,i)]}};E=new WeakMap,J=new WeakMap,O=new WeakMap;var Xt=require("dequal/lite");function x(e,t){var o,u,c,l,f,m;let i=(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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":Wt(e)).toString(),s=(r?t.rhs:Wt(t.rhs)).toString();switch(i){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(),r?"":"i").test((f=e==null?void 0:e.toString())!=null?f:"");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],o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};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,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[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(o,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:Mt(o,t.match)}]),u};ct.alwaysExecute=!0;var bt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,f,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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};var Et=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var f;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],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 r==null||r(["debug",203,{criteria:t,result:l,explanation:P(o,t.match)}]),l};var Vt=({update:e,criteria:t,onLogMessage:i})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!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()),o={result:x(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(r,t.path)}]),o};var Y,A=class{constructor(t){d(this,Y,void 0);p(this,Y,t)}evaluate(t,i,r,n,s){let o=i.clauses.length>1;o&&(s==null||s(["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,s);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:s})}S.changed&&(l=!0),!c&&S.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 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&&(p(this,U,t),p(this,Z,t))}get data(){return a(this,U)}get initialData(){return a(this,Z)}updateData(t,i){return p(this,U,i),this.handleUpdateData(t,i)}async delete(t){p(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,te.dequal)(this.data,t)||(p(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);p(this,G,r),p(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.slice(1).join("-")),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 ft,de,$t=class extends N{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,ft);n.initialData||v(this,ft,de).call(this).catch(s=>{console.error(s)})}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)}};ft=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:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(fe(u,D),fe(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function fe(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}var he=$(require("mitt")),L=require("dequal/lite");var pt=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 pe=$(require("rfdc"));var Ie=(0,pe.default)();function me(e,t,i){let r=t?Ie(t):X();return e.forEach(n=>{var s,o;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=(s=r.scores[n.data.dimension])!=null?s: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 f=(o=r.sessionScores[n.data.dimension])!=null?o:0;r.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var mt="ufvisitor",V,I,j,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,V,(0,he.default)());d(this,I,new pt);d(this,j,void 0);d(this,g,void 0);y(this,"events",{on:a(this,V).on,off:a(this,V).off});if(p(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,...s}=t.visitorData;return v(this,R,z).call(this,{...s,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,s,o;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=me(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(mt,!0),v(this,R,z).call(this,i),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var i,r,n,s,o;(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{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};V=new WeakMap,I=new WeakMap,j=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 f,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=(f=a(this,g)).decay)==null||m.call(f,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!(0,L.dequal)(r==null?void 0:r.visitorData.scores,t.scores),o=!(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||((s||o)&&a(this,V).emit("scoresUpdated",t),u&&a(this,V).emit("quirksUpdated",t),c&&a(this,V).emit("testsUpdated",t),((ot=r==null?void 0:r.visitorData)==null?void 0:ot.consent)!==t.consent&&a(this,V).emit("consentUpdated",t),((Qt=r==null?void 0:r.visitorData)==null?void 0:Qt.controlGroup)!==t.controlGroup&&(a(this,V).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,j)&&window.clearTimeout(a(this,j)),p(this,j,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 s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.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 s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],f=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||zt(S.id,S.pz,m,n)&&(f=!0,l.push(S))}return{personalized:f,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(s=>Se(s,i,r)):n=t.crit.some(s=>Se(s,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,s=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===s&&s>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))===s&&s>0;return i==null||i(["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 i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=s>o;return _(i,l,e,s,o),l}else if(r===">="){let l=s>=o;return _(i,l,e,s,o),l}else if(r==="<"){let l=s<o;return _(i,l,e,s,o),l}else if(r==="<="){let l=s<=o;return _(i,l,e,s,o),l}else if(r==="="){let l=s===o;return _(i,l,e,s,o),l}else if(r==="!="){let l=s!==o;return _(i,l,e,s,o),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 qe=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.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 s=(100-i)/r;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=i.find(o=>o.id===s),n||r==null||r(["warn",402,{missingVariant:s,variants:i.map(o=>o.id)}])),!n){let o=qe(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,f)=>{let m=o[f];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:!s}}finally{r==null||r(["info",400,"ENDGROUP"])}};var It=require("dequal/lite"),C,T,k,rt,h,nt,jt,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,s;let{manifest:i,...r}=t;p(this,k,{}),(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:i,evaluator:new A({CK:xt,QS:bt,QK:Et,PVC:ct,EVT:Vt,PV:Tt})}),this.storage=new tt({...r,manifest:this.manifest,onServerTransitionReceived:o=>{p(this,C,o),o.ssv&&(p(this,T,o.ssv),a(this,h).emit("log",["debug",130,o]))},onLogMessage:o=>a(this,h).emit("log",o)}),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",o=>{let u=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),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,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 n,s,o;let i=[],r={};if((n=a(this,C))!=null&&n.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(s=a(this,C))!=null&&s.tests){let u=Object.entries(a(this,C).tests);if(u.length>0){let c=[];u.forEach(([l,f])=>{this.storage.data.tests[l]||(c.push([l,f]),r[l]=f)}),i.push(...c.map(([l,f])=>({type:"settest",data:{test:l,variant:f}})))}}try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(o=t.url)==null?void 0:o.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([u,c])=>({type:"setquirk",data:{key:u,value:c}}))),t.enrichments&&t.enrichments.forEach(u=>{let c=W(u.cat,u.key);this.manifest.getDimensionByKey(c)?i.push({type:"modscore",data:{dimension:c,delta:u.str}}):a(this,h).emit("log",["warn",5,u])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),p(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,Q,St).call(this,this.storage.data),Object.entries(r).forEach(([u,c])=>{v(this,nt,jt).call(this,{name:u,variantId:c,variantAssigned:!0})}),p(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r,n,s,o;let i=this.manifest.getTest(t);return i?(o=(s=i.wv)!=null?s:(n=(r=a(this,C))==null?void 0:r.tests)==null?void 0:n[t])!=null?o: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:s=>a(this,h).emit("log",s)});return v(this,nt,jt).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:s=>a(this,h).emit("log",s)}),r=a(this,rt)[t.name],n={name:t.name,variantIds:i.variations.map(s=>{var o;return(o=s.id)!=null?o:"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){p(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 s,o,u;((u=(o=(s=this.storage.options.transitionStore)==null?void 0:s.initialData)==null?void 0:o.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,jt=function(t){a(this,h).emit("testResult",t)},Q=new WeakSet,St=function(t){var n;let i={...t.scores};for(let s in t.sessionScores)i[s]=((n=i[s])!=null?n:0)+t.sessionScores[s];i=this.manifest.computeAggregateDimensions(i),!(0,It.dequal)(i,a(this,T))&&(p(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 je=(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}
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)},p=(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:()=>Ve,TransitionDataStore:()=>N,UNIFORM_DEFAULT_COOKIE_NAME:()=>ae,VisitorDataStore:()=>tt,computeAggregateDimensions:()=>Ct,cookieEvaluator:()=>xt,createConsoleLogDrain:()=>Ce,createDebugConsoleLogDrain:()=>Ee,createLinearDecay:()=>ze,currentPageEvaluator:()=>Tt,emptyVisitorData:()=>X,enableConsoleLogDrain:()=>_e,enableContextDevTools:()=>He,enableDebugConsoleLogDrain:()=>Fe,evaluateVariantMatch:()=>zt,eventEvaluator:()=>Vt,explainStringMatch:()=>P,explainStringMatchCriteria:()=>ut,getEnrichmentVectorKey:()=>W,isStringMatch:()=>x,pageViewCountDimension:()=>lt,pageViewCountEvaluator:()=>ct,parseQuickConnect:()=>We,personalizeVariations:()=>Gt,queryStringEvaluator:()=>bt,quirkEvaluator:()=>Et,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 s;let n=0;for(let o of i[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&i[o.dim]){if(r.has(o.dim))continue;let l=new Set(r);l.add(o.dim),u=Jt(e,o.dim,i,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.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,p(this,K,i),p(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)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.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&&i.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};K=new WeakMap,H=new WeakMap;var E,J,O,B=class{constructor({manifest:t,evaluator:i=new A({}),onLogMessage:r=()=>{}}){y(this,"data");d(this,E,void 0);d(this,J,void 0);d(this,O,void 0);var n,s,o;p(this,E,(n=t.project)!=null?n:{}),this.data=t,p(this,J,Object.entries((o=(s=a(this,E).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new at({...c,id:u},i,r))),p(this,O,r)}rollForControlGroup(){var t,i;return Math.random()<((i=(t=a(this,E).pz)==null?void 0:t.control)!=null?i:0)}getTest(t){var i;return(i=a(this,E).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,E).pz)==null?void 0:i.agg)!=null?r:{})}getDimensionByKey(t){var r,n,s,o;let i=t.indexOf(st);return i<=0?(n=(r=a(this,E).pz)==null?void 0:r.sig)==null?void 0:n[t]:(o=(s=a(this,E).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,i)]}};E=new WeakMap,J=new WeakMap,O=new WeakMap;var Xt=require("dequal/lite");function x(e,t){var o,u,c,l,f,m;let i=(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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":Wt(e)).toString(),s=(r?t.rhs:Wt(t.rhs)).toString();switch(i){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(),r?"":"i").test((f=e==null?void 0:e.toString())!=null?f:"");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],o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};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,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[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(o,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:Mt(o,t.match)}]),u};ct.alwaysExecute=!0;var bt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,f,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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:x(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(n,t.match)}]),o};var Et=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var f;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],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 r==null||r(["debug",203,{criteria:t,result:l,explanation:P(o,t.match)}]),l};var Vt=({update:e,criteria:t,onLogMessage:i})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(o=(s=e.state.events)==null?void 0:s.some(c=>x(c.event,t.event)))!=null?o:!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()),o={result:x(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:o,explanation:P(r,t.path)}]),o};var Y,A=class{constructor(t){d(this,Y,void 0);p(this,Y,t)}evaluate(t,i,r,n,s){let o=i.clauses.length>1;o&&(s==null||s(["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,s);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:s})}S.changed&&(l=!0),!c&&S.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 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&&(p(this,U,t),p(this,Z,t))}get data(){return a(this,U)}get initialData(){return a(this,Z)}updateData(t,i){return p(this,U,i),this.handleUpdateData(t,i)}async delete(t){p(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){(0,te.dequal)(this.data,t)||(p(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);p(this,G,r),p(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.slice(1).join("-")),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 ft,de,$t=class extends N{constructor({serverCookieValue:i,visitorIdCookieName:r="ufvi",...n}){super(n);d(this,ft);n.initialData||v(this,ft,de).call(this).catch(s=>{console.error(s)})}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)}};ft=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:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,D=1-Math.min(r,S*i);return D<=0?!1:(fe(u,D),fe(c,D),l==null||l(["info",140,`linear decay factor ${D.toPrecision(6)}`]),!0)}}function fe(e,t){for(let i in e)i.startsWith("$")||(e[i]*=t)}var he=$(require("mitt")),L=require("dequal/lite");var pt=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 pe=$(require("rfdc"));var Ie=(0,pe.default)();function me(e,t,i){let r=t?Ie(t):X();return e.forEach(n=>{var s,o;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=(s=r.scores[n.data.dimension])!=null?s: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 f=(o=r.sessionScores[n.data.dimension])!=null?o:0;r.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var mt="ufvisitor",V,I,j,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,V,(0,he.default)());d(this,I,new pt);d(this,j,void 0);d(this,g,void 0);y(this,"events",{on:a(this,V).on,off:a(this,V).off});if(p(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,...s}=t.visitorData;return v(this,R,z).call(this,{...s,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,s,o;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=me(t,this.data,(s=a(this,b,w))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,I).delete(mt,!0),v(this,R,z).call(this,i),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,b,w).visitorData))}async delete(t){var i,r,n,s,o;(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{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};V=new WeakMap,I=new WeakMap,j=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 f,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=(f=a(this,g)).decay)==null||m.call(f,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!(0,L.dequal)(r==null?void 0:r.visitorData.scores,t.scores),o=!(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||((s||o)&&a(this,V).emit("scoresUpdated",t),u&&a(this,V).emit("quirksUpdated",t),c&&a(this,V).emit("testsUpdated",t),((ot=r==null?void 0:r.visitorData)==null?void 0:ot.consent)!==t.consent&&a(this,V).emit("consentUpdated",t),((Qt=r==null?void 0:r.visitorData)==null?void 0:Qt.controlGroup)!==t.controlGroup&&(a(this,V).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,j)&&window.clearTimeout(a(this,j)),p(this,j,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 s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.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 s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],f=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||zt(S.id,S.pz,m,n)&&(f=!0,l.push(S))}return{personalized:f,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(s=>Se(s,i,r)):n=t.crit.some(s=>Se(s,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,s=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===s&&s>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))===s&&s>0;return i==null||i(["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 i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=s>o;return _(i,l,e,s,o),l}else if(r===">="){let l=s>=o;return _(i,l,e,s,o),l}else if(r==="<"){let l=s<o;return _(i,l,e,s,o),l}else if(r==="<="){let l=s<=o;return _(i,l,e,s,o),l}else if(r==="="){let l=s===o;return _(i,l,e,s,o),l}else if(r==="!="){let l=s!==o;return _(i,l,e,s,o),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 qe=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.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 s=(100-i)/r;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=i.find(o=>o.id===s),n||r==null||r(["warn",402,{missingVariant:s,variants:i.map(o=>o.id)}])),!n){let o=qe(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,f)=>{let m=o[f];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:!s}}finally{r==null||r(["info",400,"ENDGROUP"])}};var It=require("dequal/lite"),C,T,k,rt,h,nt,jt,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,s;let{manifest:i,...r}=t;p(this,k,{}),(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:i,evaluator:new A({CK:xt,QS:bt,QK:Et,PVC:ct,EVT:Vt,PV:Tt})}),this.storage=new tt({...r,manifest:this.manifest,onServerTransitionReceived:o=>{p(this,C,o),o.ssv&&(p(this,T,o.ssv),a(this,h).emit("log",["debug",130,o]))},onLogMessage:o=>a(this,h).emit("log",o)}),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",o=>{let u=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),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,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 n,s,o;let i=[],r={};if((n=a(this,C))!=null&&n.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(s=a(this,C))!=null&&s.tests){let u=Object.entries(a(this,C).tests);if(u.length>0){let c=[];u.forEach(([l,f])=>{this.storage.data.tests[l]||(c.push([l,f]),r[l]=f)}),i.push(...c.map(([l,f])=>({type:"settest",data:{test:l,variant:f}})))}}try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(o=t.url)==null?void 0:o.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([u,c])=>({type:"setquirk",data:{key:u,value:c}}))),t.enrichments&&t.enrichments.forEach(u=>{let c=W(u.cat,u.key);this.manifest.getDimensionByKey(c)?i.push({type:"modscore",data:{dimension:c,delta:u.str}}):a(this,h).emit("log",["warn",5,u])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),p(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,Q,St).call(this,this.storage.data),Object.entries(r).forEach(([u,c])=>{v(this,nt,jt).call(this,{name:u,variantId:c,variantAssigned:!0})}),p(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r,n,s,o;let i=this.manifest.getTest(t);return i?(o=(s=i.wv)!=null?s:(n=(r=a(this,C))==null?void 0:r.tests)==null?void 0:n[t])!=null?o: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:s=>a(this,h).emit("log",s)});return v(this,nt,jt).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:s=>a(this,h).emit("log",s)}),r=a(this,rt)[t.name],n={name:t.name,variantIds:i.variations.map(s=>{var o;return(o=s.id)!=null?o:"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){p(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 s,o,u;((u=(o=(s=this.storage.options.transitionStore)==null?void 0:s.initialData)==null?void 0:o.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,jt=function(t){a(this,h).emit("testResult",t)},Q=new WeakSet,St=function(t){var n;let i={...t.scores};for(let s in t.sessionScores)i[s]=((n=i[s])!=null?n:0)+t.sessionScores[s];i=this.manifest.computeAggregateDimensions(i),!(0,It.dequal)(i,a(this,T))&&(p(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 je=(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
2
  `,...n.map(je))}}function _e(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 Ee(e,t){let i=typeof document=="undefined",{enableOnServer:r=!1}=t!=null?t:{};return([n,...s])=>{if(!yt(e,n)||i&&!r)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=xe[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 m=f;if(!l){c(`${m} unknown event ID ${o}. 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:Ee(e,t)}}var Ve=(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))(Ve||{}),Ke="nesitag";var _t=typeof top!="undefined";function He(){return{logDrain:e=>{!_t||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!_t||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=o=>{!o.changed||(t.push(o),r())},s=o=>{!o.variantAssigned||(i.push(o),r())};if(_t){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Be(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),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),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",s)}}}}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});
3
+ `,...ot.map(Qe))}}function Fe(e,t){return{logDrain:Ee(e,t)}}var Ve=(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))(Ve||{}),Ke="nesitag";var _t=typeof top!="undefined";function He(){return{logDrain:e=>{!_t||top==null||top.postMessage({type:"uniform:context:log",message:e},window.location.origin)},init:e=>{let t=[],i=[],r=()=>{!_t||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=o=>{!o.changed||t.push(o)},s=o=>{!o.variantAssigned||i.push(o)};if(_t){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Be(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),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),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",s)}}}}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
1
  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),pt=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var a=(e,t,i)=>(pt(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)},p=(e,t,i,r)=>(pt(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i);var v=(e,t,i)=>(pt(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 s;let n=0;for(let o of i[t].inputs){let u=(s=e[o.dim])!=null?s:0;if(!u&&i[o.dim]){if(r.has(o.dim))continue;let l=new Set(r);l.add(o.dim),u=$t(e,o.dim,i,l)}if(u!==0)if(o.sign==="c"){n=0;break}else o.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,p(this,Q,i),p(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)),s=this.signal.dur==="s"||this.signal.dur==="t"?"modscoreS":"modscore";if(!!n.changed){if(n.result)i.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&&i.push({type:s,data:{dimension:this.signal.id,delta:-o}})}}}};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,s,o;p(this,b,(n=t.project)!=null?n:{}),this.data=t,p(this,K,Object.entries((o=(s=a(this,b).pz)==null?void 0:s.sig)!=null?o:[]).map(([u,c])=>new tt({...c,id:u},i,r))),p(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,s,o;let i=t.indexOf(L);return i<=0?(n=(r=a(this,b).pz)==null?void 0:r.sig)==null?void 0:n[t]:(o=(s=a(this,b).pz)==null?void 0:s.enr)==null?void 0:o[t.substring(0,i)]}};b=new WeakMap,K=new WeakMap,R=new WeakMap;import{dequal as fe}from"dequal/lite";function E(e,t){var o,u,c,l,f,m;let i=(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 ${i}`);let r=(u=t.cs)!=null?u:!1,n=(r?e!=null?e:"":At(e)).toString(),s=(r?t.rhs:At(t.rhs)).toString();switch(i){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(),r?"":"i").test((f=e==null?void 0:e.toString())!=null?f:"");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=!fe(Nt(e.state.cookies),Nt((u=e.previousState)==null?void 0:u.cookies)),n=(c=e.state.cookies)==null?void 0:c[t.cookieName],o={result:E(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};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} ${pe(t)}`}function pe(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,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[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(o,t.match)&&(u.result=!0),r==null||r(["debug",203,{criteria:t,result:u,explanation:It(o,t.match)}]),u};gt.alwaysExecute=!0;var qt=({update:e,criteria:t,onLogMessage:i})=>{var u,c,l,f,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())!==((f=(l=e.previousState.url)==null?void 0:l.searchParams)==null?void 0:f.toString()),n=(m=e.state.url)==null?void 0:m.searchParams.get(t.queryName),o={result:E(n,t.match),changed:r};return i==null||i(["debug",203,{criteria:t,result:o,explanation:O(n,t.match)}]),o};var jt=({update:e,criteria:t,signal:i,onLogMessage:r})=>{var f;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],s=(f=e.state.quirks)==null?void 0:f[t.key],o=s!=null?s:n,u=Boolean(s&&n!==s),l={result:E(o,t.match),changed:u};return r==null||r(["debug",203,{criteria:t,result:l,explanation:O(o,t.match)}]),l};var _t=({update:e,criteria:t,onLogMessage:i})=>{var s,o,u;if(t.type!=="EVT")return{result:!1,changed:!1};let r=(o=(s=e.state.events)==null?void 0:s.some(c=>E(c.event,t.event)))!=null?o:!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()),o={result:E(r,t.path),changed:n};return i==null||i(["debug",203,{criteria:t,result:o,explanation:O(r,t.path)}]),o};var H,G=class{constructor(t){d(this,H,void 0);p(this,H,t)}evaluate(t,i,r,n,s){let o=i.clauses.length>1;o&&(s==null||s(["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,s);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:s})}S.changed&&(l=!0),!c&&S.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 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&&(p(this,U,t),p(this,B,t))}get data(){return a(this,U)}get initialData(){return a(this,B)}updateData(t,i){return p(this,U,i),this.handleUpdateData(t,i)}async delete(t){p(this,U,void 0),await this.handleDelete(t)}signalAsyncDataUpdate(t){he(this.data,t)||(p(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);p(this,$,r),p(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.slice(1).join("-")),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(s=>{console.error(s)})}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:s,lastUpd:o,scores:u,sessionScores:c,onLogMessage:l}){if(typeof o!="number")return!1;let m=s-o-t;if(m<=0)return!1;let S=m/864e5,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 s,o;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=(s=r.scores[n.data.dimension])!=null?s: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 f=(o=r.sessionScores[n.data.dimension])!=null?o:0;r.sessionScores[n.data.dimension]=f+l;break;case"identify":break;case"setcontrol":r.controlGroup=n.data;break;default:throw new Error("Unknown command")}}),r}var at="ufvisitor",V,N,q,g,x,P,w,A,lt,ie,ct,re,W,bt,Y,Et,ut=class{constructor(t){d(this,x);d(this,w);d(this,lt);d(this,ct);d(this,W);d(this,Y);d(this,V,xe());d(this,N,new ot);d(this,q,void 0);d(this,g,void 0);y(this,"events",{on:a(this,V).on,off:a(this,V).off});if(p(this,g,t),a(this,x,P)||v(this,w,A).call(this,v(this,Y,Et).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,...s}=t.visitorData;return v(this,w,A).call(this,{...s,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,s,o;if(t.length===0)return;(n=(r=a(this,g)).onLogMessage)==null||n.call(r,["debug",101,t]);let i=ee(t,this.data,(s=a(this,x,P))==null?void 0:s.visitorData.controlGroup);t.some(u=>u.type==="consent"&&!u.data)&&a(this,N).delete(at,!0),v(this,w,A).call(this,i),await((o=a(this,g).transitionStore)==null?void 0:o.updateData(t,a(this,x,P).visitorData))}async delete(t){var i,r,n,s,o;(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,Et).call(this))}finally{(o=(s=a(this,g)).onLogMessage)==null||o.call(s,["info",103,"ENDGROUP"])}}};V=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 f,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=(f=a(this,g)).decay)==null||m.call(f,{now:n,lastUpd:r==null?void 0:r.updated,scores:t.scores,sessionScores:t.sessionScores,onLogMessage:a(this,g).onLogMessage}));let s=!st(r==null?void 0:r.visitorData.scores,t.scores),o=!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||((s||o)&&a(this,V).emit("scoresUpdated",t),u&&a(this,V).emit("quirksUpdated",t),c&&a(this,V).emit("testsUpdated",t),((M=r==null?void 0:r.visitorData)==null?void 0:M.consent)!==t.consent&&a(this,V).emit("consentUpdated",t),((Pt=r==null?void 0:r.visitorData)==null?void 0:Pt.controlGroup)!==t.controlGroup&&(a(this,V).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)),p(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 s=t[n],o=a(this,g).manifest.getDimensionByKey(n);!o||s>o.cap&&((r=(i=a(this,g)).onLogMessage)==null||r.call(i,["debug",110,{dim:n,score:s,cap:o.cap}]),t[n]=o.cap)}},Y=new WeakSet,Et=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 Ee from"mitt";function ne({name:e,context:t,variations:i,take:r=1,onLogMessage:n}){var s,o,u;n==null||n(["info",300,"GROUP",{name:e,take:r}]);try{let c=(s=t.storage.data.controlGroup)!=null?s:!1,l=[],f=!1,m=t.scores;for(let S of i){if(l.length===r)break;if(!((o=S.pz)!=null&&o.crit.length)){n==null||n(["info",301,"GROUP",{id:S.id,op:(u=S.pz)==null?void 0:u.op}]),n==null||n(["info",302,{matched:!0,description:"default variation"}]),n==null||n(["info",303,!0]),n==null||n(["info",301,"ENDGROUP"]),l.push(S);continue}c||oe(S.id,S.pz,m,n)&&(f=!0,l.push(S))}return{personalized:f,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(s=>se(s,i,r)):n=t.crit.some(s=>se(s,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,s=(u=t[n])!=null?u:0;if(r==="+"){let l=Math.max(...Object.values(t))===s&&s>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))===s&&s>0;return i==null||i(["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 i==null||i(["info",302,{matched:!1,description:`${(c=e.rDim)!=null?c:e.r} has no score value`}]),!1;if(r===">"){let l=s>o;return j(i,l,e,s,o),l}else if(r===">="){let l=s>=o;return j(i,l,e,s,o),l}else if(r==="<"){let l=s<o;return j(i,l,e,s,o),l}else if(r==="<="){let l=s<=o;return j(i,l,e,s,o),l}else if(r==="="){let l=s===o;return j(i,l,e,s,o),l}else if(r==="!="){let l=s!==o;return j(i,l,e,s,o),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 be=e=>{let{values:t,total:i,missingDistribution:r}=e.reduce((n,s)=>(s.testDistribution?n.total+=s.testDistribution:++n.missingDistribution,n.values.push(s.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 s=(100-i)/r;t.forEach((o,u)=>{typeof o=="undefined"&&(t[u]=s)})}return t},Vt=({name:e,context:t,variations:i,onLogMessage:r})=>{r==null||r(["info",400,"GROUP",e]);try{let n,s=t.getTestVariantId(e);if(s===null)return r==null||r(["error",401,e]),{result:void 0,variantAssigned:!1};if(s&&(n=i.find(o=>o.id===s),n||r==null||r(["warn",402,{missingVariant:s,variants:i.map(o=>o.id)}])),!n){let o=be(i),u=Math.floor(Math.random()*100),c=0;n=i.find((l,f)=>{let m=o[f];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:!s}}finally{r==null||r(["info",400,"ENDGROUP"])}};import{dequal as ae}from"dequal/lite";var C,T,k,X,h,Z,Tt,_,dt,ue=class{constructor(t){d(this,Z);d(this,_);y(this,"manifest");d(this,C,void 0);d(this,T,{});d(this,k,void 0);d(this,X,{});d(this,h,Ee());y(this,"events",{on:a(this,h).on,off:a(this,h).off});y(this,"storage");var n,s;let{manifest:i,...r}=t;p(this,k,{}),(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 et({onLogMessage:o=>a(this,h).emit("log",o),manifest:i,evaluator:new G({CK:Gt,QS:qt,QK:jt,PVC:gt,EVT:_t,PV:Qt})}),this.storage=new ut({...r,manifest:this.manifest,onServerTransitionReceived:o=>{p(this,C,o),o.ssv&&(p(this,T,o.ssv),a(this,h).emit("log",["debug",130,o]))},onLogMessage:o=>a(this,h).emit("log",o)}),this.storage.events.on("scoresUpdated",v(this,_,dt).bind(this)),a(this,C)||v(this,_,dt).call(this,this.storage.data),this.storage.events.on("quirksUpdated",o=>{let u=this.manifest.computeSignals({scores:a(this,T),state:a(this,k),previousState:a(this,k),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,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 n,s,o;let i=[],r={};if((n=a(this,C))!=null&&n.quirks&&(t={...t,quirks:{...a(this,C).quirks,...t.quirks||{}}}),(s=a(this,C))!=null&&s.tests){let u=Object.entries(a(this,C).tests);if(u.length>0){let c=[];u.forEach(([l,f])=>{this.storage.data.tests[l]||(c.push([l,f]),r[l]=f)}),i.push(...c.map(([l,f])=>({type:"settest",data:{test:l,variant:f}})))}}try{a(this,h).emit("log",["info",2,"GROUP",{...t,url:(o=t.url)==null?void 0:o.toString()}]),t.quirks&&i.push(...Object.entries(t.quirks).map(([u,c])=>({type:"setquirk",data:{key:u,value:c}}))),t.enrichments&&t.enrichments.forEach(u=>{let c=it(u.cat,u.key);this.manifest.getDimensionByKey(c)?i.push({type:"modscore",data:{dimension:c,delta:u.str}}):a(this,h).emit("log",["warn",5,u])}),i.push(...this.manifest.computeSignals({state:t,previousState:a(this,k),visitor:this.storage.data,scores:a(this,T)})),p(this,k,{...a(this,k),...t}),await this.storage.updateData(i),a(this,C)&&(v(this,_,dt).call(this,this.storage.data),Object.entries(r).forEach(([u,c])=>{v(this,Z,Tt).call(this,{name:u,variantId:c,variantAssigned:!0})}),p(this,C,void 0),a(this,h).emit("log",["debug",131]))}finally{a(this,h).emit("log",["info",2,"ENDGROUP"])}}getTestVariantId(t){var r,n,s,o;let i=this.manifest.getTest(t);return i?(o=(s=i.wv)!=null?s:(n=(r=a(this,C))==null?void 0:r.tests)==null?void 0:n[t])!=null?o: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:s=>a(this,h).emit("log",s)});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:s=>a(this,h).emit("log",s)}),r=a(this,X)[t.name],n={name:t.name,variantIds:i.variations.map(s=>{var o;return(o=s.id)!=null?o:"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){p(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 s,o,u;((u=(o=(s=this.storage.options.transitionStore)==null?void 0:s.initialData)==null?void 0:o.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)},_=new WeakSet,dt=function(t){var n;let i={...t.scores};for(let s in t.sessionScores)i[s]=((n=i[s])!=null?n:0)+t.sessionScores[s];i=this.manifest.computeAggregateDimensions(i),!ae(i,a(this,T))&&(p(this,T,i),a(this,h).emit("scoresUpdated",i),a(this,h).emit("log",["info",3,i]))};import Ve from"rfdc";function ft(e,t){if(e==="none")return!1;switch(t){case"debug":return e==="debug";case"info":return e==="info"||e==="debug";case"warn":return e==="warn"||e==="info"||e==="debug";case"error":return e==="debug"||"info";default:return!1}}var Te=Ve();function ke(e){return([t,...i])=>{if(!ft(e,t))return;let[r,...n]=i;console[t](`\u{1F94B} [${t}] Uniform event ID ${r}
2
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,...s])=>{if(!ft(e,n)||i&&!r)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=le[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 m=f;if(!l){c(`${m} unknown event ID ${o}. 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 Vr(){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=o=>{!o.changed||(t.push(o),r())},s=o=>{!o.variantAssigned||(i.push(o),r())};if(kt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Ue(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),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),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",s)}}}}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,Vr as enableContextDevTools,Cr as enableDebugConsoleLogDrain,oe as evaluateVariantMatch,_t as eventEvaluator,O as explainStringMatch,mt as explainStringMatchCriteria,it as getEnrichmentVectorKey,E as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,Pr as parseQuickConnect,ne as personalizeVariations,qt as queryStringEvaluator,jt as quirkEvaluator,kr as serializeQuickConnect,Vt as testVariations};
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 Vr(){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=o=>{!o.changed||t.push(o)},s=o=>{!o.variantAssigned||i.push(o)};if(kt){window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__=e;try{top==null||top.addEventListener("message",async o=>{if(!o.data)return;let u=o.data;await Ue(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),r()}return e.events.on("personalizationResult",n),e.events.on("testResult",s),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",s)}}}}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,Vr as enableContextDevTools,Cr as enableDebugConsoleLogDrain,oe as evaluateVariantMatch,_t as eventEvaluator,O as explainStringMatch,mt as explainStringMatchCriteria,it as getEnrichmentVectorKey,E as isStringMatch,ht as pageViewCountDimension,gt as pageViewCountEvaluator,Pr as parseQuickConnect,ne as personalizeVariations,qt as queryStringEvaluator,jt as quirkEvaluator,kr as serializeQuickConnect,Vt as testVariations};
@@ -1,5 +1,5 @@
1
1
  import * as mitt from 'mitt';
2
- import { c as components, e as external } from './v2-manifest.swagger-ff2af13e.js';
2
+ import { c as components, e as external } from './v2-manifest.swagger-a1738c9a.js';
3
3
 
4
4
  declare type StorageCommand<TID extends string = string, TData = unknown> = {
5
5
  type: TID;
@@ -35,6 +35,13 @@ interface paths {
35
35
  500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
36
36
  };
37
37
  };
38
+ /** Handles preflight requests. This endpoint allows CORS. */
39
+ options: {
40
+ responses: {
41
+ /** OK */
42
+ 204: never;
43
+ };
44
+ };
38
45
  };
39
46
  }
40
47
  interface components {
@@ -136,12 +143,17 @@ interface external {
136
143
  * 's' = current session (expires after a period of inactivity)
137
144
  * 'p' = permanent (expires as far in the future as possible, may be limited by browser security settings)
138
145
  * 't' = transient (score tracks the current state of the criteria every time scores are updated)
146
+ *
147
+ * @enum {string}
139
148
  */
140
149
  dur: "s" | "p" | "t";
141
150
  crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
142
151
  };
143
152
  RootSignalCriteriaGroup: {
144
- /** @description Criteria type (Group of other criteria) */
153
+ /**
154
+ * @description Criteria type (Group of other criteria)
155
+ * @enum {string}
156
+ */
145
157
  type: "G";
146
158
  /**
147
159
  * @description The logical operator to apply to the criteria groups
@@ -151,13 +163,17 @@ interface external {
151
163
  * Default is `&` if unspecified.
152
164
  *
153
165
  * @default &
166
+ * @enum {string}
154
167
  */
155
168
  op?: "&" | "|";
156
169
  /** @description The criteria clauses that make up this grouping of criteria */
157
170
  clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
158
171
  };
159
172
  SignalCriteriaGroup: {
160
- /** @description Criteria type (Group of other criteria) */
173
+ /**
174
+ * @description Criteria type (Group of other criteria)
175
+ * @enum {string}
176
+ */
161
177
  type: "G";
162
178
  /**
163
179
  * @description The logical operator to apply to the criteria groups
@@ -165,6 +181,8 @@ interface external {
165
181
  * | = OR
166
182
  *
167
183
  * Default is `&` if unspecified.
184
+ *
185
+ * @enum {string}
168
186
  */
169
187
  op?: "&" | "|";
170
188
  /** @description The criteria clauses that make up this grouping of criteria */
@@ -173,6 +191,7 @@ interface external {
173
191
  SignalCriteria: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CookieCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QueryStringCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QuirkCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EventCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CurrentPageCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["PageViewCountCriteria"];
174
192
  /** @description Matches a URL query string parameter value */
175
193
  QueryStringCriteria: {
194
+ /** @enum {string} */
176
195
  type: "QS";
177
196
  /** @description The name of the query string parameter to match */
178
197
  queryName: string;
@@ -181,6 +200,7 @@ interface external {
181
200
  };
182
201
  /** @description Matches a web cookie value */
183
202
  CookieCriteria: {
203
+ /** @enum {string} */
184
204
  type: "CK";
185
205
  /** @description The name of the cookie to match */
186
206
  cookieName: string;
@@ -189,6 +209,7 @@ interface external {
189
209
  };
190
210
  /** @description Matches a visitor quirk key and value */
191
211
  QuirkCriteria: {
212
+ /** @enum {string} */
192
213
  type: "QK";
193
214
  /** @description The name of the quirk key to match */
194
215
  key: string;
@@ -197,6 +218,7 @@ interface external {
197
218
  };
198
219
  /** @description Matches an analytics event name being fired */
199
220
  EventCriteria: {
221
+ /** @enum {string} */
200
222
  type: "EVT";
201
223
  /** @description How to match the event name */
202
224
  event: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
@@ -206,11 +228,13 @@ interface external {
206
228
  * Does not include the query string or protocol and hostname (i.e. NOT https://foo.com/path/to/page.html?query=something)
207
229
  */
208
230
  CurrentPageCriteria: {
231
+ /** @enum {string} */
209
232
  type: "PV";
210
233
  /** @description The page/route path to match as a page that has been visited */
211
234
  path: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
212
235
  };
213
236
  PageViewCountCriteria: {
237
+ /** @enum {string} */
214
238
  type: "PVC";
215
239
  /** @description The expression to match the page view count against */
216
240
  match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["NumberMatch"];
@@ -226,6 +250,8 @@ interface external {
226
250
  * '//' = regular expression match
227
251
  *
228
252
  * Any of the above can be prefixed with '!' to invert the match (i.e. != for 'not an exact match')
253
+ *
254
+ * @enum {string}
229
255
  */
230
256
  op: "=" | "~" | "//" | "!=" | "!~" | "!//";
231
257
  /** @description The case sensitivity of the match. Defaults to false if unspecified. */
@@ -235,6 +261,8 @@ interface external {
235
261
  * @description The type of match to perform
236
262
  * '*' = exists with any value
237
263
  * '!*' = does not exist
264
+ *
265
+ * @enum {string}
238
266
  */
239
267
  op: "*" | "!*";
240
268
  };
@@ -248,6 +276,8 @@ interface external {
248
276
  * '!=' = not an exact match
249
277
  * '<' = less than match expression
250
278
  * '>' = greater than match expression
279
+ *
280
+ * @enum {string}
251
281
  */
252
282
  op: "=" | "<" | ">" | "!=";
253
283
  };
@@ -278,6 +308,7 @@ interface external {
278
308
  * Default if unspecified: '+'
279
309
  *
280
310
  * @default +
311
+ * @enum {string}
281
312
  */
282
313
  sign?: "+" | "-" | "c";
283
314
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "16.2.4",
3
+ "version": "17.0.0",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -44,26 +44,27 @@
44
44
  },
45
45
  "sideEffects": false,
46
46
  "scripts": {
47
- "build": "tsup --minify",
48
- "dev": "tsup --watch",
47
+ "build": "run-s update-openapi build:ts",
48
+ "build:ts": "tsup --minify",
49
+ "dev": "run-s update-openapi dev:ts",
50
+ "dev:ts": "tsup --watch",
49
51
  "clean": "rimraf dist",
50
52
  "test": "jest --maxWorkers=1",
51
53
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
52
54
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
53
- "update-openapi": "node ./update-openapi.cjs",
55
+ "update-openapi": "tsx ./scripts/update-openapi.cts",
54
56
  "benchmark:build": "tsup src/storage/__benchmarks__/storage.benchmark.ts",
55
57
  "benchmark:run": "node ./dist/storage.benchmark.js"
56
58
  },
57
59
  "devDependencies": {
58
60
  "@types/js-cookie": "3.0.2",
59
61
  "@types/yargs": "17.0.10",
60
- "@uniformdev/cli": "^16.2.4",
62
+ "@uniformdev/cli": "^17.0.0",
61
63
  "benny": "3.7.1",
62
64
  "yargs": "17.5.1"
63
65
  },
64
66
  "dependencies": {
65
67
  "dequal": "^2.0.2",
66
- "isomorphic-unfetch": "^3.1.0",
67
68
  "js-cookie": "3.0.1",
68
69
  "mitt": "^3.0.0",
69
70
  "p-limit": "^3.1.0",
@@ -75,5 +76,5 @@
75
76
  "publishConfig": {
76
77
  "access": "public"
77
78
  },
78
- "gitHead": "b2ed666efec0c0e255c2a1b8561ff7899834a2d5"
79
+ "gitHead": "d15f59e5cc80184d983b8c1ca67b1ee390158672"
79
80
  }