@picked/client 0.0.1-dev.1764952778408 → 0.0.1-dev.1764956808030
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/cjs/index.js +1 -1
- package/dist/esm/index.js +106 -106
- package/dist/types/utils/user-session.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var V=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>V(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("effector"),S=require("@withease/factories"),F=require("../experience-instance-DjjpHk0t.cjs"),I=require("../logger-BsmHUUw1.cjs"),k=require("../storage-YlR83AWP.cjs"),N=require("../id-BKIWbSTy.cjs"),z=require("../object-BbFTsGh3.cjs"),w=require("../supports-YvpQZxbh.cjs"),U=f.createDomain("experience"),_=S.createFactory(({client:t,experience:e})=>{const r=U.store(e),n=f.createApi(r,{merge(l,y){return{...l,...y.experience}}}),o=r.map(l=>({name:l.name,decisionLogic:l.condition??l.decide,targetSelectors:l.targets,initializeOpenLogic:e.initializeOpen})),c=t.components.listStore.map(l=>l.find(y=>y.name===`experience:${e.id}`)||l.find(y=>y.name==="experience"),{skipVoid:!1}),s=r.map(l=>({steps:l.steps,nodes:l.nodes,edges:l.edges,conditionals:l.conditionals})),i=e.actions??[];return{id:e.id,configStore:o,treeStore:s,componentStore:c,actions:i,merge:n.merge}});function q(t){return S.invoke(_,t)}const K=S.createFactory(({client:t})=>{const e=U.store({}),r=f.createApi(e,{register(s,i){return{...s,[i.id]:i}}});function n(s){const i=e.getState()[s.id];if(i){i.merge({experience:s,strategy:"override"});return}const l=q({client:t,experience:s});r.register(l)}const o=e.map(s=>Object.values(s));function c(s){return e.map(i=>i[s],{skipVoid:!1})}return{register:n,getById:c,listStore:o}});function H(t){return S.invoke(K,t)}const W=(t,e)=>{e.register(t)},L=(t,e)=>{const{targetSelectors:r}=e.configStore.getState(),n=F.getTargetElements(r,e.id);n.forEach(({elements:c})=>c.forEach(s=>F.tagTargetElement(s,e.id))),F.createAppHosts(n,e.id).forEach(c=>{t.experienceInstances.spawn(e,c)})},B=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await G(t,e)&&L(t,e)}))},G=async(t,e)=>{const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return F.getTargetElements(n,e.id).length<1||n.length===0?!1:r&&F.isRulesLogic(r)?await F.evaluateRuleLogic(t,r)===!0:!0},Y=(t,e,r)=>{const n=e.name,o=e.setup(t);if(o){const c=r[n]??{};r[n]=Object.freeze({...c,...o})}},J=f.createDomain("component"),Q=S.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function X(t){return S.invoke(Q,t)}const Z=S.createFactory(({client:t})=>{const e=J.store({}),r=f.createApi(e,{register(s,i){return{...s,[i.name]:i}}});function n(s,i){e.getState()[s]&&I.logger("warn",`Component '${s}' already registered. Registering again will override the previous registration.`);const y=X({client:t,name:s,component:i});r.register(y)}const o=e.map(s=>Object.values(s));function c(s){return e.map(i=>i[s],{skipVoid:!1})}return{register:n,getByName:c,listStore:o}});function ee(t){return S.invoke(Z,t)}const j=(t,e,r)=>{r.register(t,e)},te=f.createDomain("framework"),re=S.createFactory(({client:t})=>{const e=te.store({}),r=f.createApi(e,{register(s,i){return{...s,[i.name]:i.framework}}});function n(s,i){e.getState()[s]&&I.logger("warn",`Framework '${s}' already registered. Registering again will override the previous registration.`),r.register({name:s,framework:i})}const o=e.map(s=>Object.values(s));function c(s){return e.map(i=>i[s],{skipVoid:!1})}return{register:n,getByName:c,listStore:o}});function se(t){return S.invoke(re,t)}const ne=(t,e)=>{e.register(t.name,t)},oe=6e3,ie=k.createStorageKey("last_ping","global"),ae=t=>`${t}/api/v1/ping`,ce=async t=>{try{const e=Date.now(),r=k.localStore.get(ie);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<oe)return!0;const o=ae(t.apiUrl),c={projectId:t.projectId,path:window.location.pathname},s=JSON.stringify(c),i={"Content-Type":"application/json"},l=document.getElementById("picked_script"),y=l==null?void 0:l.dataset.verceltoken;y&&(i["x-vercel-protection-bypass"]=y);const d=(await fetch(o,{method:"POST",headers:i,body:s})).ok;return d&&r.set(e),d}catch(e){return I.logger("error",e),!1}};function ue(t){const e=typeof window<"u",r={client:t,responses:t.responses.listStore.getState(),fields:t.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(r)}const le=f.createDomain("predicate"),de=S.createFactory(({client:t})=>{const e=le.store({}),r=f.createApi(e,{register(s,i){return{...s,[i.name]:{name:i.name,predicate:i.predicate}}}});function n(s,i){e.getState()[s]&&I.logger("warn",`Predicate '${s}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:s,predicate:i}))}const o=e.map(s=>Object.values(s));function c(s){return e.map(i=>i[s],{skipVoid:!1})}return{register:n,getByName:c,listStore:o}});function pe(t){return S.invoke(de,t)}const ge=(t,e,r)=>{r.register(t,e)},$=f.createDomain("feature"),fe=S.createFactory(({client:t})=>{const e=$.store({}),r=$.store([]),n=f.createApi(e,{register(d,u){return{...d,[u.id]:u.feature}}});function o(d,u){e.getState()[d]&&I.logger("warn",`Feature '${d}' already registered. Registering again will override the previous registration.`);const p={id:d,feature:{...u,id:d}};n.register(Object.freeze({id:d,feature:p}))}const c=f.createEffect(async({id:d,key:u,storage:a="local"})=>{const p=k.createStorageKey(`feature:${d}:${u}`,"global"),g=(a==="session"?k.sessionStore:k.localStore).get(p).boolean();return g===null?null:{id:d,key:u,bucket:g,storage:a}}),s=f.createEffect(d=>{if(!d)return null;const u=k.createStorageKey(`feature:${d.id}:${d.key}`,"global");(d.storage==="session"?k.sessionStore:k.localStore).set(u,d.bucket)}),i=new Map,l=f.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:d,resolvedFeaturesStore:u},{id:a,decide:p,key:m})=>{const g=u.find(A=>A.id===a&&A.key===m);if(g)return g;const v=d[a];if(!v)throw new Error(`Feature with id '${a}' not found`);const x=i.get(`${a}:${m}`);if(x!==void 0){const A=await x;return{id:v.id,bucket:A,key:m,storage:v.feature.storage}}const P=p();i.set(`${a}:${m}`,P);const E=await P;return{id:v.id,bucket:E,key:m,storage:v.feature.storage}}});f.sample({clock:n.register,fn:d=>{const{id:u,feature:a}=d;return{id:u,key:a.feature.key,storage:a.feature.storage}},target:c}),f.sample({source:e,clock:l.doneData,fn:(d,u)=>{var v;const{id:a,bucket:p,storage:m}=u,g=(v=d[a])==null?void 0:v.feature.key;return g?{key:g,id:a,bucket:p,storage:m}:null},target:s});const y=f.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:d,resolvedFeaturesStore:u})=>Object.values(d).map(a=>{const p=u.find(m=>m.id===a.id&&m.key===a.feature.key);return p?{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:()=>({id:a.id,bucket:p.bucket}),isResolved:!0}:{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:async()=>await l(a.feature),isResolved:!1}}));f.sample({clock:l.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:d},{id:u,key:a})=>!d.some(m=>m.id===u&&m.key===a),fn:(d,u)=>u,target:t.eventBus.prepend(d=>({type:"feature_decide",feature:d}))}),f.sample({clock:[c.doneData,l.doneData],source:r,fn:(d,u)=>!u||d.some(p=>p.id===u.id&&p.key===u.key)?d:[...d,u],target:r});function b(d){return e.map(u=>u[d],{skipVoid:!1})}return{register:o,getByName:b,listStore:y}});function me(t){return S.invoke(fe,t)}const he=(t,e,r)=>{r.register(t,e)},R=f.createDomain("history");function C(t,e){return{id:N.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ye=S.createFactory(()=>{const t=R.store({entries:[]}),e=R.event(),r=R.event(),n=R.event(),o=R.event();t.on(e,(s,i)=>({entries:[...s.entries,C(i.experienceId,i.node)]})),t.on(r,(s,i)=>({entries:[...s.entries.slice(0,-1),C(i.experienceId,i.node)]})),t.on(o,(s,i)=>i);function c(s,i){const l={lastStepIndex:-1,secondLastStepIndex:-1};for(let y=s.length-1;y>=0;y--){const b=s[y],d=b==null?void 0:b.node;if(!(!d||!F.isStepNode(d))&&!(i&&(b==null?void 0:b.experienceId)!==i))if(l.lastStepIndex===-1)l.lastStepIndex=y;else{l.secondLastStepIndex=y;break}}return l}return t.on(n,(s,i)=>{const{secondLastStepIndex:l}=c(s.entries,i.experienceId),y=l!==-1?s.entries.slice(0,l+1):s.entries;return{...s,entries:y}}),{push:e,replace:r,back:n,restore:o,entriesStore:t.map(s=>s.entries)}});function Se(){return S.invoke(ye)}const ve=()=>f.createEvent(),ke=f.createDomain("field"),we=S.createFactory(()=>{const t=ke.store({}),e=f.createApi(t,{register(s,i){return{...s,[i.field.id]:i.field}}});function r(s){e.register({field:s})}const n=t.map(s=>Object.values(s));function o(s){return t.map(i=>i[s]||null)}function c(s){return t.map(i=>Object.values(i).find(l=>l.name===s)||null)}return{register:r,getById:o,listStore:n,getByName:c}});function Fe(){return S.invoke(we)}const be=(t,e)=>{e.register(t)},Ie=f.createDomain("action"),xe=S.createFactory(()=>{const t=Ie.store({}),e=f.createApi(t,{register(c,s){return{...c,[s.name]:{name:s.name,action:s.action}}}});function r(c,s){e.register({name:c,action:s})}const n=t.map(c=>Object.values(c));function o(c){return t.map(s=>s[c],{skipVoid:!1})}return{register:r,getByName:o,listStore:n}});function Ee(){return S.invoke(xe)}const Re=(t,e,r)=>{r.register(t,e)};function O(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}const Pe=f.createDomain("response"),Ae=S.createFactory(({client:t})=>{const e=Pe.store({}),r=f.createEvent(),n=f.createEvent(),o=f.createApi(e,{register(u,a){return{...u,[a.fieldId]:a.response}},registerBatch(u,a){return{...u,...a}},clear(u,a){const{[a]:p,...m}=u;return m},clearAll(){return{}}});function c(u,a){o.register({fieldId:u,response:a})}async function s(u){const a=[];return await Promise.allSettled(Object.entries(u).map(async([p,m])=>{let g=m;const v=t.fields.getById(p).getState();if(!v){a.push({fieldId:p,userMessage:`Field '${p}' not found`,systemMessage:`No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:g});return}if(v.multiple&&(typeof g=="string"||typeof g=="number"||typeof g=="boolean")&&(g=[g]),v.validation&&!z.isEmpty(v.validation)&&!O(g)){const x=await F.evaluateRuleLogic(t,v.validation,{$input:g});if(typeof x=="string"){a.push({fieldId:p,userMessage:x,systemMessage:`Field validation resulted in an error: ${x}.`,value:g});return}if(x===!1){a.push({fieldId:p,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:g});return}}if(v.required&&O(g)){a.push({fieldId:p,userMessage:"This field is required",systemMessage:"Field is required.",value:g});return}if(!v.multiple&&Array.isArray(g)&&g.length>1){a.push({fieldId:p,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:g});return}if(v.options){const x=v.options.map(E=>E.value),P=Array.isArray(g)?g:[g];Array.isArray(g)&&(P.every(E=>x.includes(E))||a.push({fieldId:p,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${x.join(", ")}`,value:g}))}})),{responsesToCommit:u,validationErrors:a}}async function i(u){const{responsesToCommit:a,validationErrors:p}=await s(u);return p.length?{errors:p}:(o.registerBatch(a),{errors:[]})}const l=e.map(u=>u),y=e.map(u=>Object.keys(u).map(p=>({fieldId:p,value:u[p]})));function b(u){const a=t.fields.getById(u),p=e.map(m=>m[u]||null);return f.combine({f:a,r:p},({f:m,r:g})=>g||(m!=null&&m.defaultValue?m.defaultValue:null))}function d(u){const a=t.fields.getByName(u);return f.combine({f:a,s:e},({f:p,s:m})=>{const g=p&&m[p.id]||null;return g||(p!=null&&p.defaultValue?p.defaultValue:null)})}return f.sample({clock:r,target:o.clearAll}),f.sample({clock:n,target:o.clear}),{register:c,clearAll:r,clear:n,commit:i,getResponsesToCommit:s,listStore:y,getAllStore:l,getByFieldId:b,getByFieldName:d}});function De(t){return S.invoke(Ae,t)}const Be=()=>"0.0.1-dev.1764952778408";function je(){if(w.supportsDocument()){const t=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of t)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function $e(){if(!w.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[o]of t.entries())o.startsWith("picked-")&&r.add(o);for(const o of r){const c=o.replace("picked-","");e[c]=t.getAll(o)}const n=k.createStorageKey("s");if(r.size>0)k.sessionStore.set(n,e);else{const o=k.sessionStore.get(n);if(o)return o.json()||{}}return e}function Ce(){if(w.supportsCryptoRandomUUID())return crypto.randomUUID();const t=Date.now().toString(36),e=Math.random().toString(36).substring(2,15),r=Math.random().toString(36).substring(2,15),n=Math.random().toString(36).substring(2,15);return`${t}-${e}-${r}-${n}`}const Oe=k.createStorageKey("session","global"),Ue=()=>{const t=k.localStore.get(Oe);let e;t.isSet()&&(e=t.json());const r=o=>t.set({id:o.id,isUser:o.isUser,identifiers:o.identifiers}),n={id:(e==null?void 0:e.id)??Ce(),isUser:(e==null?void 0:e.isUser)??void 0,identifiers:(e==null?void 0:e.identifiers)??void 0,setIsUser(o){this.isUser=o,r(this)},setIdentifier(o,c){this.identifiers={...this.identifiers??{},[o]:c},r(this)},removeIdentifier(o){if(!this.identifiers)return;const{[o]:c,...s}=this.identifiers;this.identifiers=Object.keys(s).length?s:void 0,r(this)}};return r(n),n},Le=()=>w.supportsLocalStorage()?Ue():null;class D{constructor(e){h(this,"options");h(this,"isReady",!1);h(this,"project");h(this,"plugins",{});h(this,"eventBus",ve());h(this,"organizationId");h(this,"projectId");h(this,"apiUrl");h(this,"session");h(this,"precondition");h(this,"condition");h(this,"searchParams",$e());h(this,"history",Se());h(this,"components",ee({client:this}));h(this,"experienceInstances",F.createExperienceInstanceIndex({client:this}));h(this,"experiences",H({client:this}));h(this,"frameworks",se({client:this}));h(this,"predicates",pe({client:this}));h(this,"features",me({client:this}));h(this,"responses",De({client:this}));h(this,"fields",Fe());h(this,"actions",Ee());I.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||je(),this.session=Le(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:Be()}),I.logger("info","Picked client initialized.")}start(){ce(this),(async()=>{if(!w.supportsDocument())return;let r;typeof this.precondition>"u"?r=!0:typeof this.precondition=="boolean"?r=this.precondition:r=await F.evaluateRuleLogic(this,this.precondition)===!0;let n;r&&(this.condition===void 0?n=!0:typeof this.condition=="boolean"?n=this.condition:n=await F.evaluateRuleLogic(this,this.condition)===!0);const o=r&&n===!0;if(typeof n=="boolean"&&this.session){const c=n;this.session.setIsUser(c),this.eventBus({type:"user_decide",value:c})}this.eventBus({type:"initialize"}),document.body&&o&&B(this),await F.domInteractive(),o&&B(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session})})()}registerFramework(e){ne(e,this.frameworks)}registerComponent(e,r){j(e,r,this.components)}registerPlugin(e){Y(this,e,this.plugins)}registerFeature(e,r){he(e,r,this.features)}registerPredicate(e,r){ge(e,r,this.predicates)}registerField(e){be(e,this.fields)}registerAction(e,r){Re(e,r,this.actions)}registerExperience(e){e.component&&j(`experience:${e.id}`,e.component,this.components),W(e,this.experiences)}getStateSnapshot(){return ue(this)}async launchExperienceById(e){const r=this.experiences.getById(e).getState();if(!r){I.logger("warn",`Experience with id '${e}' not found.`);return}L(this,r)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(r=>{if(Array.isArray(r)){r.forEach(o=>{this.registerPlugin(o)});return}const n=typeof r=="function"?r():r;if(Array.isArray(n)){n.forEach(o=>this.registerPlugin(o));return}this.registerPlugin(n)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,n])=>{const o=typeof n=="function"?n():n;this.registerFeature(r,o)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[n,o]=r.split(":");if(!n||!o)return;let c=o;c==="true"&&(c=!0),c==="false"&&(c=!1),this.registerFeature(n,{key:`${c}`,name:n,decide:()=>c,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){I.logger("warn",`Predicate "${r}" is not a function.`);return}this.registerPredicate(r,n)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){I.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,n)})}getPluginConfig(e){return this.plugins[e]??{}}}h(D,"logger",I.logger);function M(t){var e;return((e=t.options)==null?void 0:e.some(r=>"condition"in r))??!1}function Me(t){return t.some(e=>e.condition||M(e))}async function Te(t,e){return e.length===0||!Me(e)?e:(await Promise.all(e.map(async n=>{if(!(n.condition?await F.evaluateRuleLogic(t,n.condition):!0))return null;if(!n.options||!M(n))return n;const s=(await Promise.all(n.options.map(async l=>l.condition?await F.evaluateRuleLogic(t,l.condition)?l:null:l))).filter(l=>l!==null);return s.length===n.options.length?n:s.length===0?null:{...n,options:s}}))).filter(n=>n!==null)}const Ve=t=>{const e=new D(t);return w.bindClient(e),e};exports.evaluateRuleLogic=F.evaluateRuleLogic;exports.isPickedRoot=F.isPickedRoot;exports.createStorageKey=k.createStorageKey;exports.localStore=k.localStore;exports.sessionStore=k.sessionStore;exports.subscribe=k.subscribe;exports.supportsCookies=w.supportsCookies;exports.supportsCryptoRandomUUID=w.supportsCryptoRandomUUID;exports.supportsDocument=w.supportsDocument;exports.supportsHistory=w.supportsHistory;exports.supportsIntersectionObserver=w.supportsIntersectionObserver;exports.supportsLocalStorage=w.supportsLocalStorage;exports.supportsLocation=w.supportsLocation;exports.supportsSessionStorage=w.supportsSessionStorage;exports.supportsShadowRoot=w.supportsShadowRoot;exports.supportsWebComponents=w.supportsWebComponents;exports.supportsWindow=w.supportsWindow;exports.Picked=D;exports.createClient=Ve;exports.getStepFields=Te;
|
|
1
|
+
"use strict";var T=Object.defineProperty;var V=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>V(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("effector"),S=require("@withease/factories"),b=require("../experience-instance-DjjpHk0t.cjs"),I=require("../logger-BsmHUUw1.cjs"),k=require("../storage-YlR83AWP.cjs"),N=require("../id-BKIWbSTy.cjs"),z=require("../object-BbFTsGh3.cjs"),w=require("../supports-YvpQZxbh.cjs"),U=f.createDomain("experience"),_=S.createFactory(({client:t,experience:e})=>{const r=U.store(e),n=f.createApi(r,{merge(l,y){return{...l,...y.experience}}}),i=r.map(l=>({name:l.name,decisionLogic:l.condition??l.decide,targetSelectors:l.targets,initializeOpenLogic:e.initializeOpen})),a=t.components.listStore.map(l=>l.find(y=>y.name===`experience:${e.id}`)||l.find(y=>y.name==="experience"),{skipVoid:!1}),s=r.map(l=>({steps:l.steps,nodes:l.nodes,edges:l.edges,conditionals:l.conditionals})),o=e.actions??[];return{id:e.id,configStore:i,treeStore:s,componentStore:a,actions:o,merge:n.merge}});function q(t){return S.invoke(_,t)}const K=S.createFactory(({client:t})=>{const e=U.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.id]:o}}});function n(s){const o=e.getState()[s.id];if(o){o.merge({experience:s,strategy:"override"});return}const l=q({client:t,experience:s});r.register(l)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getById:a,listStore:i}});function H(t){return S.invoke(K,t)}const W=(t,e)=>{e.register(t)},L=(t,e)=>{const{targetSelectors:r}=e.configStore.getState(),n=b.getTargetElements(r,e.id);n.forEach(({elements:a})=>a.forEach(s=>b.tagTargetElement(s,e.id))),b.createAppHosts(n,e.id).forEach(a=>{t.experienceInstances.spawn(e,a)})},D=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await G(t,e)&&L(t,e)}))},G=async(t,e)=>{const{decisionLogic:r,targetSelectors:n}=e.configStore.getState();return b.getTargetElements(n,e.id).length<1||n.length===0?!1:r&&b.isRulesLogic(r)?await b.evaluateRuleLogic(t,r)===!0:!0},Y=(t,e,r)=>{const n=e.name,i=e.setup(t);if(i){const a=r[n]??{};r[n]=Object.freeze({...a,...i})}},J=f.createDomain("component"),Q=S.createFactory(({client:t,component:e,name:r})=>{const n=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:n}});function X(t){return S.invoke(Q,t)}const Z=S.createFactory(({client:t})=>{const e=J.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o}}});function n(s,o){e.getState()[s]&&I.logger("warn",`Component '${s}' already registered. Registering again will override the previous registration.`);const y=X({client:t,name:s,component:o});r.register(y)}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function ee(t){return S.invoke(Z,t)}const B=(t,e,r)=>{r.register(t,e)},te=f.createDomain("framework"),re=S.createFactory(({client:t})=>{const e=te.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:o.framework}}});function n(s,o){e.getState()[s]&&I.logger("warn",`Framework '${s}' already registered. Registering again will override the previous registration.`),r.register({name:s,framework:o})}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function se(t){return S.invoke(re,t)}const ne=(t,e)=>{e.register(t.name,t)},ie=6e3,oe=k.createStorageKey("last_ping","global"),ae=t=>`${t}/api/v1/ping`,ce=async t=>{try{const e=Date.now(),r=k.localStore.get(oe);let n=0;if(r.isSet()&&(n=r.json()??0),n&&e-n<ie)return!0;const i=ae(t.apiUrl),a={projectId:t.projectId,path:window.location.pathname},s=JSON.stringify(a),o={"Content-Type":"application/json"},l=document.getElementById("picked_script"),y=l==null?void 0:l.dataset.verceltoken;y&&(o["x-vercel-protection-bypass"]=y);const d=(await fetch(i,{method:"POST",headers:o,body:s})).ok;return d&&r.set(e),d}catch(e){return I.logger("error",e),!1}};function ue(t){const e=typeof window<"u",r={client:t,responses:t.responses.listStore.getState(),fields:t.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(r)}const le=f.createDomain("predicate"),de=S.createFactory(({client:t})=>{const e=le.store({}),r=f.createApi(e,{register(s,o){return{...s,[o.name]:{name:o.name,predicate:o.predicate}}}});function n(s,o){e.getState()[s]&&I.logger("warn",`Predicate '${s}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:s,predicate:o}))}const i=e.map(s=>Object.values(s));function a(s){return e.map(o=>o[s],{skipVoid:!1})}return{register:n,getByName:a,listStore:i}});function pe(t){return S.invoke(de,t)}const ge=(t,e,r)=>{r.register(t,e)},$=f.createDomain("feature"),fe=S.createFactory(({client:t})=>{const e=$.store({}),r=$.store([]),n=f.createApi(e,{register(d,u){return{...d,[u.id]:u.feature}}});function i(d,u){e.getState()[d]&&I.logger("warn",`Feature '${d}' already registered. Registering again will override the previous registration.`);const p={id:d,feature:{...u,id:d}};n.register(Object.freeze({id:d,feature:p}))}const a=f.createEffect(async({id:d,key:u,storage:c="local"})=>{const p=k.createStorageKey(`feature:${d}:${u}`,"global"),g=(c==="session"?k.sessionStore:k.localStore).get(p).boolean();return g===null?null:{id:d,key:u,bucket:g,storage:c}}),s=f.createEffect(d=>{if(!d)return null;const u=k.createStorageKey(`feature:${d.id}:${d.key}`,"global");(d.storage==="session"?k.sessionStore:k.localStore).set(u,d.bucket)}),o=new Map,l=f.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:d,resolvedFeaturesStore:u},{id:c,decide:p,key:m})=>{const g=u.find(A=>A.id===c&&A.key===m);if(g)return g;const v=d[c];if(!v)throw new Error(`Feature with id '${c}' not found`);const x=o.get(`${c}:${m}`);if(x!==void 0){const A=await x;return{id:v.id,bucket:A,key:m,storage:v.feature.storage}}const P=p();o.set(`${c}:${m}`,P);const E=await P;return{id:v.id,bucket:E,key:m,storage:v.feature.storage}}});f.sample({clock:n.register,fn:d=>{const{id:u,feature:c}=d;return{id:u,key:c.feature.key,storage:c.feature.storage}},target:a}),f.sample({source:e,clock:l.doneData,fn:(d,u)=>{var v;const{id:c,bucket:p,storage:m}=u,g=(v=d[c])==null?void 0:v.feature.key;return g?{key:g,id:c,bucket:p,storage:m}:null},target:s});const y=f.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:d,resolvedFeaturesStore:u})=>Object.values(d).map(c=>{const p=u.find(m=>m.id===c.id&&m.key===c.feature.key);return p?{id:c.id,name:c.feature.name,key:c.feature.key,getBucket:()=>({id:c.id,bucket:p.bucket}),isResolved:!0}:{id:c.id,name:c.feature.name,key:c.feature.key,getBucket:async()=>await l(c.feature),isResolved:!1}}));f.sample({clock:l.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:d},{id:u,key:c})=>!d.some(m=>m.id===u&&m.key===c),fn:(d,u)=>u,target:t.eventBus.prepend(d=>({type:"feature_decide",feature:d}))}),f.sample({clock:[a.doneData,l.doneData],source:r,fn:(d,u)=>!u||d.some(p=>p.id===u.id&&p.key===u.key)?d:[...d,u],target:r});function F(d){return e.map(u=>u[d],{skipVoid:!1})}return{register:i,getByName:F,listStore:y}});function me(t){return S.invoke(fe,t)}const he=(t,e,r)=>{r.register(t,e)},R=f.createDomain("history");function O(t,e){return{id:N.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ye=S.createFactory(()=>{const t=R.store({entries:[]}),e=R.event(),r=R.event(),n=R.event(),i=R.event();t.on(e,(s,o)=>({entries:[...s.entries,O(o.experienceId,o.node)]})),t.on(r,(s,o)=>({entries:[...s.entries.slice(0,-1),O(o.experienceId,o.node)]})),t.on(i,(s,o)=>o);function a(s,o){const l={lastStepIndex:-1,secondLastStepIndex:-1};for(let y=s.length-1;y>=0;y--){const F=s[y],d=F==null?void 0:F.node;if(!(!d||!b.isStepNode(d))&&!(o&&(F==null?void 0:F.experienceId)!==o))if(l.lastStepIndex===-1)l.lastStepIndex=y;else{l.secondLastStepIndex=y;break}}return l}return t.on(n,(s,o)=>{const{secondLastStepIndex:l}=a(s.entries,o.experienceId),y=l!==-1?s.entries.slice(0,l+1):s.entries;return{...s,entries:y}}),{push:e,replace:r,back:n,restore:i,entriesStore:t.map(s=>s.entries)}});function Se(){return S.invoke(ye)}const ve=()=>f.createEvent(),ke=f.createDomain("field"),we=S.createFactory(()=>{const t=ke.store({}),e=f.createApi(t,{register(s,o){return{...s,[o.field.id]:o.field}}});function r(s){e.register({field:s})}const n=t.map(s=>Object.values(s));function i(s){return t.map(o=>o[s]||null)}function a(s){return t.map(o=>Object.values(o).find(l=>l.name===s)||null)}return{register:r,getById:i,listStore:n,getByName:a}});function be(){return S.invoke(we)}const Fe=(t,e)=>{e.register(t)},Ie=f.createDomain("action"),xe=S.createFactory(()=>{const t=Ie.store({}),e=f.createApi(t,{register(a,s){return{...a,[s.name]:{name:s.name,action:s.action}}}});function r(a,s){e.register({name:a,action:s})}const n=t.map(a=>Object.values(a));function i(a){return t.map(s=>s[a],{skipVoid:!1})}return{register:r,getByName:i,listStore:n}});function Ee(){return S.invoke(xe)}const Re=(t,e,r)=>{r.register(t,e)};function C(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}const Pe=f.createDomain("response"),Ae=S.createFactory(({client:t})=>{const e=Pe.store({}),r=f.createEvent(),n=f.createEvent(),i=f.createApi(e,{register(u,c){return{...u,[c.fieldId]:c.response}},registerBatch(u,c){return{...u,...c}},clear(u,c){const{[c]:p,...m}=u;return m},clearAll(){return{}}});function a(u,c){i.register({fieldId:u,response:c})}async function s(u){const c=[];return await Promise.allSettled(Object.entries(u).map(async([p,m])=>{let g=m;const v=t.fields.getById(p).getState();if(!v){c.push({fieldId:p,userMessage:`Field '${p}' not found`,systemMessage:`No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:g});return}if(v.multiple&&(typeof g=="string"||typeof g=="number"||typeof g=="boolean")&&(g=[g]),v.validation&&!z.isEmpty(v.validation)&&!C(g)){const x=await b.evaluateRuleLogic(t,v.validation,{$input:g});if(typeof x=="string"){c.push({fieldId:p,userMessage:x,systemMessage:`Field validation resulted in an error: ${x}.`,value:g});return}if(x===!1){c.push({fieldId:p,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:g});return}}if(v.required&&C(g)){c.push({fieldId:p,userMessage:"This field is required",systemMessage:"Field is required.",value:g});return}if(!v.multiple&&Array.isArray(g)&&g.length>1){c.push({fieldId:p,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:g});return}if(v.options){const x=v.options.map(E=>E.value),P=Array.isArray(g)?g:[g];Array.isArray(g)&&(P.every(E=>x.includes(E))||c.push({fieldId:p,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${x.join(", ")}`,value:g}))}})),{responsesToCommit:u,validationErrors:c}}async function o(u){const{responsesToCommit:c,validationErrors:p}=await s(u);return p.length?{errors:p}:(i.registerBatch(c),{errors:[]})}const l=e.map(u=>u),y=e.map(u=>Object.keys(u).map(p=>({fieldId:p,value:u[p]})));function F(u){const c=t.fields.getById(u),p=e.map(m=>m[u]||null);return f.combine({f:c,r:p},({f:m,r:g})=>g||(m!=null&&m.defaultValue?m.defaultValue:null))}function d(u){const c=t.fields.getByName(u);return f.combine({f:c,s:e},({f:p,s:m})=>{const g=p&&m[p.id]||null;return g||(p!=null&&p.defaultValue?p.defaultValue:null)})}return f.sample({clock:r,target:i.clearAll}),f.sample({clock:n,target:i.clear}),{register:a,clearAll:r,clear:n,commit:o,getResponsesToCommit:s,listStore:y,getAllStore:l,getByFieldId:F,getByFieldName:d}});function je(t){return S.invoke(Ae,t)}const De=()=>"0.0.1-dev.1764956808030";function Be(){if(w.supportsDocument()){const t=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of t)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function $e(){if(!w.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},r=new Set;for(const[i]of t.entries())i.startsWith("picked-")&&r.add(i);for(const i of r){const a=i.replace("picked-","");e[a]=t.getAll(i)}const n=k.createStorageKey("s");if(r.size>0)k.sessionStore.set(n,e);else{const i=k.sessionStore.get(n);if(i)return i.json()||{}}return e}function Oe(){if(w.supportsCryptoRandomUUID())return crypto.randomUUID();const t=Date.now().toString(36),e=Math.random().toString(36).substring(2,15),r=Math.random().toString(36).substring(2,15),n=Math.random().toString(36).substring(2,15);return`${t}-${e}-${r}-${n}`}const Ce=k.createStorageKey("session","global"),Ue=()=>{const t=k.localStore.get(Ce);let e;t.isSet()&&(e=t.json());const r=i=>t.set({id:i.id,isUser:i.isUser,identifiers:i.identifiers}),n={id:(e==null?void 0:e.id)??Oe(),isUser:(e==null?void 0:e.isUser)??void 0,identifiers:(e==null?void 0:e.identifiers)??void 0,setIsUser(i){this.isUser=i,r(this)},setIdentifier(i,a){this.identifiers=Object.assign({},this.identifiers,{[i]:a}),r(this)},removeIdentifier(i){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([a])=>a!==i)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(n),n},Le=()=>w.supportsLocalStorage()?Ue():null;class j{constructor(e){h(this,"options");h(this,"isReady",!1);h(this,"project");h(this,"plugins",{});h(this,"eventBus",ve());h(this,"organizationId");h(this,"projectId");h(this,"apiUrl");h(this,"session");h(this,"precondition");h(this,"condition");h(this,"searchParams",$e());h(this,"history",Se());h(this,"components",ee({client:this}));h(this,"experienceInstances",b.createExperienceInstanceIndex({client:this}));h(this,"experiences",H({client:this}));h(this,"frameworks",se({client:this}));h(this,"predicates",pe({client:this}));h(this,"features",me({client:this}));h(this,"responses",je({client:this}));h(this,"fields",be());h(this,"actions",Ee());I.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Be(),this.session=Le(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:De()}),I.logger("info","Picked client initialized.")}start(){ce(this),(async()=>{if(!w.supportsDocument())return;let r;typeof this.precondition>"u"?r=!0:typeof this.precondition=="boolean"?r=this.precondition:r=await b.evaluateRuleLogic(this,this.precondition)===!0;let n;r&&(this.condition===void 0?n=!0:typeof this.condition=="boolean"?n=this.condition:n=await b.evaluateRuleLogic(this,this.condition)===!0);const i=r&&n===!0;if(typeof n=="boolean"&&this.session){const a=n;this.session.setIsUser(a),this.eventBus({type:"user_decide",value:a})}this.eventBus({type:"initialize"}),document.body&&i&&D(this),await b.domInteractive(),i&&D(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session})})()}registerFramework(e){ne(e,this.frameworks)}registerComponent(e,r){B(e,r,this.components)}registerPlugin(e){Y(this,e,this.plugins)}registerFeature(e,r){he(e,r,this.features)}registerPredicate(e,r){ge(e,r,this.predicates)}registerField(e){Fe(e,this.fields)}registerAction(e,r){Re(e,r,this.actions)}registerExperience(e){e.component&&B(`experience:${e.id}`,e.component,this.components),W(e,this.experiences)}getStateSnapshot(){return ue(this)}async launchExperienceById(e){const r=this.experiences.getById(e).getState();if(!r){I.logger("warn",`Experience with id '${e}' not found.`);return}L(this,r)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(r=>{if(Array.isArray(r)){r.forEach(i=>{this.registerPlugin(i)});return}const n=typeof r=="function"?r():r;if(Array.isArray(n)){n.forEach(i=>this.registerPlugin(i));return}this.registerPlugin(n)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,n])=>{const i=typeof n=="function"?n():n;this.registerFeature(r,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[n,i]=r.split(":");if(!n||!i)return;let a=i;a==="true"&&(a=!0),a==="false"&&(a=!1),this.registerFeature(n,{key:`${a}`,name:n,decide:()=>a,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){I.logger("warn",`Predicate "${r}" is not a function.`);return}this.registerPredicate(r,n)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([r,n])=>{if(typeof n!="function"){I.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,n)})}getPluginConfig(e){return this.plugins[e]??{}}}h(j,"logger",I.logger);function M(t){var e;return((e=t.options)==null?void 0:e.some(r=>"condition"in r))??!1}function Me(t){return t.some(e=>e.condition||M(e))}async function Te(t,e){return e.length===0||!Me(e)?e:(await Promise.all(e.map(async n=>{if(!(n.condition?await b.evaluateRuleLogic(t,n.condition):!0))return null;if(!n.options||!M(n))return n;const s=(await Promise.all(n.options.map(async l=>l.condition?await b.evaluateRuleLogic(t,l.condition)?l:null:l))).filter(l=>l!==null);return s.length===n.options.length?n:s.length===0?null:{...n,options:s}}))).filter(n=>n!==null)}const Ve=t=>{const e=new j(t);return w.bindClient(e),e};exports.evaluateRuleLogic=b.evaluateRuleLogic;exports.isPickedRoot=b.isPickedRoot;exports.createStorageKey=k.createStorageKey;exports.localStore=k.localStore;exports.sessionStore=k.sessionStore;exports.subscribe=k.subscribe;exports.supportsCookies=w.supportsCookies;exports.supportsCryptoRandomUUID=w.supportsCryptoRandomUUID;exports.supportsDocument=w.supportsDocument;exports.supportsHistory=w.supportsHistory;exports.supportsIntersectionObserver=w.supportsIntersectionObserver;exports.supportsLocalStorage=w.supportsLocalStorage;exports.supportsLocation=w.supportsLocation;exports.supportsSessionStorage=w.supportsSessionStorage;exports.supportsShadowRoot=w.supportsShadowRoot;exports.supportsWebComponents=w.supportsWebComponents;exports.supportsWindow=w.supportsWindow;exports.Picked=j;exports.createClient=Ve;exports.getStepFields=Te;
|
package/dist/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createFactory as k, invoke as w } from "@withease/factories";
|
|
|
6
6
|
import { g as _, t as Q, c as X, i as Z, e as E, a as ee, b as te, d as se } from "../experience-instance-C4INDX6a.js";
|
|
7
7
|
import { f as vt } from "../experience-instance-C4INDX6a.js";
|
|
8
8
|
import { l as S } from "../logger-C9a75KZn.js";
|
|
9
|
-
import { c as
|
|
9
|
+
import { c as j, l as $, s as O } from "../storage-BLmAhfhl.js";
|
|
10
10
|
import { a as kt } from "../storage-BLmAhfhl.js";
|
|
11
11
|
import { g as re } from "../id-BW-g3y32.js";
|
|
12
12
|
import { i as ne } from "../object-JwZ58NOH.js";
|
|
@@ -26,7 +26,7 @@ const H = I("experience"), ue = k(
|
|
|
26
26
|
decisionLogic: l.condition ?? l.decide,
|
|
27
27
|
targetSelectors: l.targets,
|
|
28
28
|
initializeOpenLogic: e.initializeOpen
|
|
29
|
-
})),
|
|
29
|
+
})), a = t.components.listStore.map(
|
|
30
30
|
(l) => l.find((h) => h.name === `experience:${e.id}`) || l.find((h) => h.name === "experience"),
|
|
31
31
|
{ skipVoid: !1 }
|
|
32
32
|
), r = s.map((l) => ({
|
|
@@ -39,7 +39,7 @@ const H = I("experience"), ue = k(
|
|
|
39
39
|
id: e.id,
|
|
40
40
|
configStore: i,
|
|
41
41
|
treeStore: r,
|
|
42
|
-
componentStore:
|
|
42
|
+
componentStore: a,
|
|
43
43
|
actions: o,
|
|
44
44
|
merge: n.merge
|
|
45
45
|
};
|
|
@@ -67,12 +67,12 @@ const de = k(({ client: t }) => {
|
|
|
67
67
|
s.register(l);
|
|
68
68
|
}
|
|
69
69
|
const i = e.map((r) => Object.values(r));
|
|
70
|
-
function
|
|
70
|
+
function a(r) {
|
|
71
71
|
return e.map((o) => o[r], { skipVoid: !1 });
|
|
72
72
|
}
|
|
73
73
|
return {
|
|
74
74
|
register: n,
|
|
75
|
-
getById:
|
|
75
|
+
getById: a,
|
|
76
76
|
listStore: i
|
|
77
77
|
};
|
|
78
78
|
});
|
|
@@ -84,9 +84,9 @@ const fe = (t, e) => {
|
|
|
84
84
|
}, G = (t, e) => {
|
|
85
85
|
const { targetSelectors: s } = e.configStore.getState(), n = _(s, e.id);
|
|
86
86
|
n.forEach(
|
|
87
|
-
({ elements:
|
|
88
|
-
), X(n, e.id).forEach((
|
|
89
|
-
t.experienceInstances.spawn(e,
|
|
87
|
+
({ elements: a }) => a.forEach((r) => Q(r, e.id))
|
|
88
|
+
), X(n, e.id).forEach((a) => {
|
|
89
|
+
t.experienceInstances.spawn(e, a);
|
|
90
90
|
});
|
|
91
91
|
}, M = async (t) => {
|
|
92
92
|
await Promise.all(
|
|
@@ -100,8 +100,8 @@ const fe = (t, e) => {
|
|
|
100
100
|
}, me = (t, e, s) => {
|
|
101
101
|
const n = e.name, i = e.setup(t);
|
|
102
102
|
if (i) {
|
|
103
|
-
const
|
|
104
|
-
s[n] = Object.freeze({ ...
|
|
103
|
+
const a = s[n] ?? {};
|
|
104
|
+
s[n] = Object.freeze({ ...a, ...i });
|
|
105
105
|
}
|
|
106
106
|
}, he = I("component"), ye = k(
|
|
107
107
|
({ client: t, component: e, name: s }) => {
|
|
@@ -134,12 +134,12 @@ const Se = k(({ client: t }) => {
|
|
|
134
134
|
s.register(h);
|
|
135
135
|
}
|
|
136
136
|
const i = e.map((r) => Object.values(r));
|
|
137
|
-
function
|
|
137
|
+
function a(r) {
|
|
138
138
|
return e.map((o) => o[r], { skipVoid: !1 });
|
|
139
139
|
}
|
|
140
140
|
return {
|
|
141
141
|
register: n,
|
|
142
|
-
getByName:
|
|
142
|
+
getByName: a,
|
|
143
143
|
listStore: i
|
|
144
144
|
};
|
|
145
145
|
});
|
|
@@ -164,12 +164,12 @@ const V = (t, e, s) => {
|
|
|
164
164
|
), s.register({ name: r, framework: o });
|
|
165
165
|
}
|
|
166
166
|
const i = e.map((r) => Object.values(r));
|
|
167
|
-
function
|
|
167
|
+
function a(r) {
|
|
168
168
|
return e.map((o) => o[r], { skipVoid: !1 });
|
|
169
169
|
}
|
|
170
170
|
return {
|
|
171
171
|
register: n,
|
|
172
|
-
getByName:
|
|
172
|
+
getByName: a,
|
|
173
173
|
listStore: i
|
|
174
174
|
};
|
|
175
175
|
});
|
|
@@ -178,16 +178,16 @@ function Ie(t) {
|
|
|
178
178
|
}
|
|
179
179
|
const Fe = (t, e) => {
|
|
180
180
|
e.register(t.name, t);
|
|
181
|
-
}, xe = 6e3, Ee =
|
|
181
|
+
}, xe = 6e3, Ee = j("last_ping", "global"), Pe = (t) => `${t}/api/v1/ping`, Re = async (t) => {
|
|
182
182
|
try {
|
|
183
183
|
const e = Date.now(), s = $.get(Ee);
|
|
184
184
|
let n = 0;
|
|
185
185
|
if (s.isSet() && (n = s.json() ?? 0), n && e - n < xe)
|
|
186
186
|
return !0;
|
|
187
|
-
const i = Pe(t.apiUrl),
|
|
187
|
+
const i = Pe(t.apiUrl), a = {
|
|
188
188
|
projectId: t.projectId,
|
|
189
189
|
path: window.location.pathname
|
|
190
|
-
}, r = JSON.stringify(
|
|
190
|
+
}, r = JSON.stringify(a), o = {
|
|
191
191
|
"Content-Type": "application/json"
|
|
192
192
|
}, l = document.getElementById("picked_script"), h = l == null ? void 0 : l.dataset.verceltoken;
|
|
193
193
|
h && (o["x-vercel-protection-bypass"] = h);
|
|
@@ -201,7 +201,7 @@ const Fe = (t, e) => {
|
|
|
201
201
|
return S("error", e), !1;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
function
|
|
204
|
+
function je(t) {
|
|
205
205
|
const e = typeof window < "u", s = {
|
|
206
206
|
client: t,
|
|
207
207
|
responses: t.responses.listStore.getState(),
|
|
@@ -213,8 +213,8 @@ function Be(t) {
|
|
|
213
213
|
};
|
|
214
214
|
return Object.freeze(s);
|
|
215
215
|
}
|
|
216
|
-
const
|
|
217
|
-
const e =
|
|
216
|
+
const Be = I("predicate"), Ae = k(({ client: t }) => {
|
|
217
|
+
const e = Be.store({}), s = F(e, {
|
|
218
218
|
register(r, o) {
|
|
219
219
|
return {
|
|
220
220
|
...r,
|
|
@@ -232,12 +232,12 @@ const je = I("predicate"), Ae = k(({ client: t }) => {
|
|
|
232
232
|
), s.register(Object.freeze({ name: r, predicate: o }));
|
|
233
233
|
}
|
|
234
234
|
const i = e.map((r) => Object.values(r));
|
|
235
|
-
function
|
|
235
|
+
function a(r) {
|
|
236
236
|
return e.map((o) => o[r], { skipVoid: !1 });
|
|
237
237
|
}
|
|
238
238
|
return {
|
|
239
239
|
register: n,
|
|
240
|
-
getByName:
|
|
240
|
+
getByName: a,
|
|
241
241
|
listStore: i
|
|
242
242
|
};
|
|
243
243
|
});
|
|
@@ -274,56 +274,56 @@ const Oe = (t, e, s) => {
|
|
|
274
274
|
})
|
|
275
275
|
);
|
|
276
276
|
}
|
|
277
|
-
const
|
|
277
|
+
const a = U(
|
|
278
278
|
async ({
|
|
279
279
|
id: d,
|
|
280
280
|
key: u,
|
|
281
|
-
storage:
|
|
281
|
+
storage: c = "local"
|
|
282
282
|
}) => {
|
|
283
|
-
const p =
|
|
284
|
-
return f === null ? null : { id: d, key: u, bucket: f, storage:
|
|
283
|
+
const p = j(`feature:${d}:${u}`, "global"), f = (c === "session" ? O : $).get(p).boolean();
|
|
284
|
+
return f === null ? null : { id: d, key: u, bucket: f, storage: c };
|
|
285
285
|
}
|
|
286
286
|
), r = U((d) => {
|
|
287
287
|
if (!d)
|
|
288
288
|
return null;
|
|
289
|
-
const u =
|
|
289
|
+
const u = j(`feature:${d.id}:${d.key}`, "global");
|
|
290
290
|
(d.storage === "session" ? O : $).set(u, d.bucket);
|
|
291
291
|
}), o = /* @__PURE__ */ new Map(), l = J({
|
|
292
292
|
source: { allFeaturesStore: e, resolvedFeaturesStore: s },
|
|
293
|
-
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: u }, { id:
|
|
293
|
+
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: u }, { id: c, decide: p, key: g }) => {
|
|
294
294
|
const f = u.find(
|
|
295
|
-
(A) => A.id ===
|
|
295
|
+
(A) => A.id === c && A.key === g
|
|
296
296
|
);
|
|
297
297
|
if (f)
|
|
298
298
|
return f;
|
|
299
|
-
const y = d[
|
|
299
|
+
const y = d[c];
|
|
300
300
|
if (!y)
|
|
301
|
-
throw new Error(`Feature with id '${
|
|
302
|
-
const b = o.get(`${
|
|
301
|
+
throw new Error(`Feature with id '${c}' not found`);
|
|
302
|
+
const b = o.get(`${c}:${g}`);
|
|
303
303
|
if (b !== void 0) {
|
|
304
304
|
const A = await b;
|
|
305
305
|
return { id: y.id, bucket: A, key: g, storage: y.feature.storage };
|
|
306
306
|
}
|
|
307
|
-
const
|
|
308
|
-
o.set(`${
|
|
309
|
-
const P = await
|
|
307
|
+
const B = p();
|
|
308
|
+
o.set(`${c}:${g}`, B);
|
|
309
|
+
const P = await B;
|
|
310
310
|
return { id: y.id, bucket: P, key: g, storage: y.feature.storage };
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
x({
|
|
314
314
|
clock: n.register,
|
|
315
315
|
fn: (d) => {
|
|
316
|
-
const { id: u, feature:
|
|
317
|
-
return { id: u, key:
|
|
316
|
+
const { id: u, feature: c } = d;
|
|
317
|
+
return { id: u, key: c.feature.key, storage: c.feature.storage };
|
|
318
318
|
},
|
|
319
|
-
target:
|
|
319
|
+
target: a
|
|
320
320
|
}), x({
|
|
321
321
|
source: e,
|
|
322
322
|
clock: l.doneData,
|
|
323
323
|
fn: (d, u) => {
|
|
324
324
|
var y;
|
|
325
|
-
const { id:
|
|
326
|
-
return f ? { key: f, id:
|
|
325
|
+
const { id: c, bucket: p, storage: g } = u, f = (y = d[c]) == null ? void 0 : y.feature.key;
|
|
326
|
+
return f ? { key: f, id: c, bucket: p, storage: g } : null;
|
|
327
327
|
},
|
|
328
328
|
target: r
|
|
329
329
|
});
|
|
@@ -331,21 +331,21 @@ const Oe = (t, e, s) => {
|
|
|
331
331
|
({
|
|
332
332
|
allFeaturesStore: d,
|
|
333
333
|
resolvedFeaturesStore: u
|
|
334
|
-
}) => Object.values(d).map((
|
|
334
|
+
}) => Object.values(d).map((c) => {
|
|
335
335
|
const p = u.find(
|
|
336
|
-
(g) => g.id ===
|
|
336
|
+
(g) => g.id === c.id && g.key === c.feature.key
|
|
337
337
|
);
|
|
338
338
|
return p ? {
|
|
339
|
-
id:
|
|
340
|
-
name:
|
|
341
|
-
key:
|
|
342
|
-
getBucket: () => ({ id:
|
|
339
|
+
id: c.id,
|
|
340
|
+
name: c.feature.name,
|
|
341
|
+
key: c.feature.key,
|
|
342
|
+
getBucket: () => ({ id: c.id, bucket: p.bucket }),
|
|
343
343
|
isResolved: !0
|
|
344
344
|
} : {
|
|
345
|
-
id:
|
|
346
|
-
name:
|
|
347
|
-
key:
|
|
348
|
-
getBucket: async () => await l(
|
|
345
|
+
id: c.id,
|
|
346
|
+
name: c.feature.name,
|
|
347
|
+
key: c.feature.key,
|
|
348
|
+
getBucket: async () => await l(c.feature),
|
|
349
349
|
isResolved: !1
|
|
350
350
|
};
|
|
351
351
|
})
|
|
@@ -353,8 +353,8 @@ const Oe = (t, e, s) => {
|
|
|
353
353
|
x({
|
|
354
354
|
clock: l.doneData,
|
|
355
355
|
source: { resolvedFeatures: s },
|
|
356
|
-
filter: ({ resolvedFeatures: d }, { id: u, key:
|
|
357
|
-
(g) => g.id === u && g.key ===
|
|
356
|
+
filter: ({ resolvedFeatures: d }, { id: u, key: c }) => !d.some(
|
|
357
|
+
(g) => g.id === u && g.key === c
|
|
358
358
|
),
|
|
359
359
|
fn: (d, u) => u,
|
|
360
360
|
target: t.eventBus.prepend((d) => ({
|
|
@@ -362,7 +362,7 @@ const Oe = (t, e, s) => {
|
|
|
362
362
|
feature: d
|
|
363
363
|
}))
|
|
364
364
|
}), x({
|
|
365
|
-
clock: [
|
|
365
|
+
clock: [a.doneData, l.doneData],
|
|
366
366
|
source: s,
|
|
367
367
|
fn: (d, u) => !u || d.some(
|
|
368
368
|
(p) => p.id === u.id && p.key === u.key
|
|
@@ -403,7 +403,7 @@ const Me = k(() => {
|
|
|
403
403
|
N(o.experienceId, o.node)
|
|
404
404
|
]
|
|
405
405
|
})), t.on(i, (r, o) => o);
|
|
406
|
-
function
|
|
406
|
+
function a(r, o) {
|
|
407
407
|
const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
408
408
|
for (let h = r.length - 1; h >= 0; h--) {
|
|
409
409
|
const v = r[h], d = v == null ? void 0 : v.node;
|
|
@@ -418,7 +418,7 @@ const Me = k(() => {
|
|
|
418
418
|
return l;
|
|
419
419
|
}
|
|
420
420
|
return t.on(n, (r, o) => {
|
|
421
|
-
const { secondLastStepIndex: l } =
|
|
421
|
+
const { secondLastStepIndex: l } = a(r.entries, o.experienceId), h = l !== -1 ? r.entries.slice(0, l + 1) : r.entries;
|
|
422
422
|
return {
|
|
423
423
|
...r,
|
|
424
424
|
entries: h
|
|
@@ -450,14 +450,14 @@ const Te = () => D(), Ne = I("field"), ze = k(() => {
|
|
|
450
450
|
function i(r) {
|
|
451
451
|
return t.map((o) => o[r] || null);
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function a(r) {
|
|
454
454
|
return t.map((o) => Object.values(o).find((l) => l.name === r) || null);
|
|
455
455
|
}
|
|
456
456
|
return {
|
|
457
457
|
register: s,
|
|
458
458
|
getById: i,
|
|
459
459
|
listStore: n,
|
|
460
|
-
getByName:
|
|
460
|
+
getByName: a
|
|
461
461
|
};
|
|
462
462
|
});
|
|
463
463
|
function _e() {
|
|
@@ -467,9 +467,9 @@ const Le = (t, e) => {
|
|
|
467
467
|
e.register(t);
|
|
468
468
|
}, He = I("action"), Ge = k(() => {
|
|
469
469
|
const t = He.store({}), e = F(t, {
|
|
470
|
-
register(
|
|
470
|
+
register(a, r) {
|
|
471
471
|
return {
|
|
472
|
-
...
|
|
472
|
+
...a,
|
|
473
473
|
[r.name]: {
|
|
474
474
|
name: r.name,
|
|
475
475
|
action: r.action
|
|
@@ -477,12 +477,12 @@ const Le = (t, e) => {
|
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
479
|
});
|
|
480
|
-
function s(
|
|
481
|
-
e.register({ name:
|
|
480
|
+
function s(a, r) {
|
|
481
|
+
e.register({ name: a, action: r });
|
|
482
482
|
}
|
|
483
|
-
const n = t.map((
|
|
484
|
-
function i(
|
|
485
|
-
return t.map((r) => r[
|
|
483
|
+
const n = t.map((a) => Object.values(a));
|
|
484
|
+
function i(a) {
|
|
485
|
+
return t.map((r) => r[a], { skipVoid: !1 });
|
|
486
486
|
}
|
|
487
487
|
return {
|
|
488
488
|
register: s,
|
|
@@ -501,37 +501,37 @@ function z(t) {
|
|
|
501
501
|
}
|
|
502
502
|
const We = I("response"), Ye = k(({ client: t }) => {
|
|
503
503
|
const e = We.store({}), s = D(), n = D(), i = F(e, {
|
|
504
|
-
register(u,
|
|
504
|
+
register(u, c) {
|
|
505
505
|
return {
|
|
506
506
|
...u,
|
|
507
|
-
[
|
|
507
|
+
[c.fieldId]: c.response
|
|
508
508
|
};
|
|
509
509
|
},
|
|
510
|
-
registerBatch(u,
|
|
510
|
+
registerBatch(u, c) {
|
|
511
511
|
return {
|
|
512
512
|
...u,
|
|
513
|
-
...
|
|
513
|
+
...c
|
|
514
514
|
};
|
|
515
515
|
},
|
|
516
|
-
clear(u,
|
|
517
|
-
const { [
|
|
516
|
+
clear(u, c) {
|
|
517
|
+
const { [c]: p, ...g } = u;
|
|
518
518
|
return g;
|
|
519
519
|
},
|
|
520
520
|
clearAll() {
|
|
521
521
|
return {};
|
|
522
522
|
}
|
|
523
523
|
});
|
|
524
|
-
function
|
|
525
|
-
i.register({ fieldId: u, response:
|
|
524
|
+
function a(u, c) {
|
|
525
|
+
i.register({ fieldId: u, response: c });
|
|
526
526
|
}
|
|
527
527
|
async function r(u) {
|
|
528
|
-
const
|
|
528
|
+
const c = [];
|
|
529
529
|
return await Promise.allSettled(
|
|
530
530
|
Object.entries(u).map(async ([p, g]) => {
|
|
531
531
|
let f = g;
|
|
532
532
|
const y = t.fields.getById(p).getState();
|
|
533
533
|
if (!y) {
|
|
534
|
-
|
|
534
|
+
c.push({
|
|
535
535
|
fieldId: p,
|
|
536
536
|
userMessage: `Field '${p}' not found`,
|
|
537
537
|
systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
@@ -544,7 +544,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
544
544
|
$input: f
|
|
545
545
|
});
|
|
546
546
|
if (typeof b == "string") {
|
|
547
|
-
|
|
547
|
+
c.push({
|
|
548
548
|
fieldId: p,
|
|
549
549
|
userMessage: b,
|
|
550
550
|
systemMessage: `Field validation resulted in an error: ${b}.`,
|
|
@@ -553,7 +553,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
555
555
|
if (b === !1) {
|
|
556
|
-
|
|
556
|
+
c.push({
|
|
557
557
|
fieldId: p,
|
|
558
558
|
userMessage: "This field is invalid",
|
|
559
559
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
@@ -563,7 +563,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
if (y.required && z(f)) {
|
|
566
|
-
|
|
566
|
+
c.push({
|
|
567
567
|
fieldId: p,
|
|
568
568
|
userMessage: "This field is required",
|
|
569
569
|
systemMessage: "Field is required.",
|
|
@@ -572,7 +572,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
574
|
if (!y.multiple && Array.isArray(f) && f.length > 1) {
|
|
575
|
-
|
|
575
|
+
c.push({
|
|
576
576
|
fieldId: p,
|
|
577
577
|
userMessage: "This field expects a single response",
|
|
578
578
|
systemMessage: "Field expects a single response.",
|
|
@@ -581,8 +581,8 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
583
|
if (y.options) {
|
|
584
|
-
const b = y.options.map((P) => P.value),
|
|
585
|
-
Array.isArray(f) && (
|
|
584
|
+
const b = y.options.map((P) => P.value), B = Array.isArray(f) ? f : [f];
|
|
585
|
+
Array.isArray(f) && (B.every((P) => b.includes(P)) || c.push({
|
|
586
586
|
fieldId: p,
|
|
587
587
|
userMessage: "This field expects a valid option",
|
|
588
588
|
systemMessage: `Field expects a valid option. Valid options are: ${b.join(", ")}`,
|
|
@@ -590,23 +590,23 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
590
590
|
}));
|
|
591
591
|
}
|
|
592
592
|
})
|
|
593
|
-
), { responsesToCommit: u, validationErrors:
|
|
593
|
+
), { responsesToCommit: u, validationErrors: c };
|
|
594
594
|
}
|
|
595
595
|
async function o(u) {
|
|
596
|
-
const { responsesToCommit:
|
|
597
|
-
return p.length ? { errors: p } : (i.registerBatch(
|
|
596
|
+
const { responsesToCommit: c, validationErrors: p } = await r(u);
|
|
597
|
+
return p.length ? { errors: p } : (i.registerBatch(c), { errors: [] });
|
|
598
598
|
}
|
|
599
599
|
const l = e.map((u) => u), h = e.map((u) => Object.keys(u).map((p) => ({
|
|
600
600
|
fieldId: p,
|
|
601
601
|
value: u[p]
|
|
602
602
|
})));
|
|
603
603
|
function v(u) {
|
|
604
|
-
const
|
|
605
|
-
return C({ f:
|
|
604
|
+
const c = t.fields.getById(u), p = e.map((g) => g[u] || null);
|
|
605
|
+
return C({ f: c, r: p }, ({ f: g, r: f }) => f || (g != null && g.defaultValue ? g.defaultValue : null));
|
|
606
606
|
}
|
|
607
607
|
function d(u) {
|
|
608
|
-
const
|
|
609
|
-
return C({ f:
|
|
608
|
+
const c = t.fields.getByName(u);
|
|
609
|
+
return C({ f: c, s: e }, ({ f: p, s: g }) => {
|
|
610
610
|
const f = p && g[p.id] || null;
|
|
611
611
|
return f || (p != null && p.defaultValue ? p.defaultValue : null);
|
|
612
612
|
});
|
|
@@ -618,7 +618,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
618
618
|
clock: n,
|
|
619
619
|
target: i.clear
|
|
620
620
|
}), {
|
|
621
|
-
register:
|
|
621
|
+
register: a,
|
|
622
622
|
clearAll: s,
|
|
623
623
|
clear: n,
|
|
624
624
|
commit: o,
|
|
@@ -632,7 +632,7 @@ const We = I("response"), Ye = k(({ client: t }) => {
|
|
|
632
632
|
function Je(t) {
|
|
633
633
|
return w(Ye, t);
|
|
634
634
|
}
|
|
635
|
-
const Qe = () => "0.0.1-dev.
|
|
635
|
+
const Qe = () => "0.0.1-dev.1764956808030";
|
|
636
636
|
function Xe() {
|
|
637
637
|
if (L()) {
|
|
638
638
|
const t = [
|
|
@@ -655,10 +655,10 @@ function Ze() {
|
|
|
655
655
|
for (const [i] of t.entries())
|
|
656
656
|
i.startsWith("picked-") && s.add(i);
|
|
657
657
|
for (const i of s) {
|
|
658
|
-
const
|
|
659
|
-
e[
|
|
658
|
+
const a = i.replace("picked-", "");
|
|
659
|
+
e[a] = t.getAll(i);
|
|
660
660
|
}
|
|
661
|
-
const n =
|
|
661
|
+
const n = j("s");
|
|
662
662
|
if (s.size > 0)
|
|
663
663
|
O.set(n, e);
|
|
664
664
|
else {
|
|
@@ -674,7 +674,7 @@ function et() {
|
|
|
674
674
|
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15), n = Math.random().toString(36).substring(2, 15);
|
|
675
675
|
return `${t}-${e}-${s}-${n}`;
|
|
676
676
|
}
|
|
677
|
-
const tt =
|
|
677
|
+
const tt = j("session", "global"), st = () => {
|
|
678
678
|
const t = $.get(tt);
|
|
679
679
|
let e;
|
|
680
680
|
t.isSet() && (e = t.json());
|
|
@@ -689,13 +689,13 @@ const tt = B("session", "global"), st = () => {
|
|
|
689
689
|
setIsUser(i) {
|
|
690
690
|
this.isUser = i, s(this);
|
|
691
691
|
},
|
|
692
|
-
setIdentifier(i,
|
|
693
|
-
this.identifiers = {
|
|
692
|
+
setIdentifier(i, a) {
|
|
693
|
+
this.identifiers = Object.assign({}, this.identifiers, { [i]: a }), s(this);
|
|
694
694
|
},
|
|
695
695
|
removeIdentifier(i) {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
this.identifiers = Object.keys(
|
|
696
|
+
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
697
|
+
Object.entries(this.identifiers).filter(([a]) => a !== i)
|
|
698
|
+
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, s(this));
|
|
699
699
|
}
|
|
700
700
|
};
|
|
701
701
|
return s(n), n;
|
|
@@ -736,8 +736,8 @@ class K {
|
|
|
736
736
|
s && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await E(this, this.condition) === !0);
|
|
737
737
|
const i = s && n === !0;
|
|
738
738
|
if (typeof n == "boolean" && this.session) {
|
|
739
|
-
const
|
|
740
|
-
this.session.setIsUser(
|
|
739
|
+
const a = n;
|
|
740
|
+
this.session.setIsUser(a), this.eventBus({ type: "user_decide", value: a });
|
|
741
741
|
}
|
|
742
742
|
this.eventBus({ type: "initialize" }), document.body && i && M(this), await se(), i && M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
743
743
|
})();
|
|
@@ -767,7 +767,7 @@ class K {
|
|
|
767
767
|
e.component && V(`experience:${e.id}`, e.component, this.components), fe(e, this.experiences);
|
|
768
768
|
}
|
|
769
769
|
getStateSnapshot() {
|
|
770
|
-
return
|
|
770
|
+
return je(this);
|
|
771
771
|
}
|
|
772
772
|
async launchExperienceById(e) {
|
|
773
773
|
const s = this.experiences.getById(e).getState();
|
|
@@ -813,13 +813,13 @@ class K {
|
|
|
813
813
|
const [n, i] = s.split(":");
|
|
814
814
|
if (!n || !i)
|
|
815
815
|
return;
|
|
816
|
-
let
|
|
817
|
-
|
|
818
|
-
key: `${
|
|
816
|
+
let a = i;
|
|
817
|
+
a === "true" && (a = !0), a === "false" && (a = !1), this.registerFeature(n, {
|
|
818
|
+
key: `${a}`,
|
|
819
819
|
// use the assigned bucket value as the key
|
|
820
820
|
name: n,
|
|
821
821
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
822
|
-
decide: () =>
|
|
822
|
+
decide: () => a,
|
|
823
823
|
storage: "session"
|
|
824
824
|
});
|
|
825
825
|
} catch {
|
|
@@ -879,7 +879,7 @@ const mt = (t) => {
|
|
|
879
879
|
export {
|
|
880
880
|
K as Picked,
|
|
881
881
|
mt as createClient,
|
|
882
|
-
|
|
882
|
+
j as createStorageKey,
|
|
883
883
|
E as evaluateRuleLogic,
|
|
884
884
|
gt as getStepFields,
|
|
885
885
|
vt as isPickedRoot,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/utils/user-session.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,YAAa,SAAQ,OAAO;IAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;
|
|
1
|
+
{"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/utils/user-session.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,YAAa,SAAQ,OAAO;IAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAmED,eAAO,MAAM,iBAAiB,2BAI7B,CAAA"}
|