@picked/client 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var T=Object.defineProperty;var V=(t,e,s)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var y=(t,e,s)=>V(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("effector"),h=require("@withease/factories"),b=require("../experience-instance-DwO_yZK0.cjs"),I=require("../logger-BsmHUUw1.cjs"),k=require("../storage-BPJwmlva.cjs"),M=require("../id-BKIWbSTy.cjs"),N=require("../object-BbFTsGh3.cjs"),w=require("../supports-B6KShYPU.cjs"),O=d.createDomain("experience"),z=h.createFactory(({client:t,experience:e})=>{const s=O.store(e),o=d.createApi(s,{merge(n,f){return{...n,...f.experience}}}),i=s.map(n=>({type:n.type,name:n.name,decisionLogic:n.decide,targetSelectors:n.targets})),p=t.components.listStore.map(n=>n.find(f=>f.name===`experience:${e.id}`)||n.find(f=>f.name==="experience"),{skipVoid:!1}),r=s.map(n=>({steps:n.steps,nodes:n.nodes,edges:n.edges,conditionals:n.conditionals}));return{id:e.id,configStore:i,treeStore:r,componentStore:p,merge:o.merge}});function q(t){return h.invoke(z,t)}const K=h.createFactory(({client:t})=>{const e=O.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.id]:n}}});function o(r){const n=e.getState()[r.id];if(n){n.merge({experience:r,strategy:"override"});return}const f=q({client:t,experience:r});s.register(f)}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getById:p,listStore:i}});function _(t){return h.invoke(K,t)}const H=(t,e)=>{e.register(t)},L=(t,e)=>{const{targetSelectors:s}=e.configStore.getState(),o=b.getTargetElements(s,e.id);o.forEach(({elements:p})=>p.forEach(r=>b.tagTargetElement(r,e.id))),b.createAppHosts(o,e.id).forEach(p=>{t.experienceInstances.spawn(e,p)})},B=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await U(t,e)&&L(t,e)}))},U=async(t,e)=>{const{type:s,decisionLogic:o,targetSelectors:i}=e.configStore.getState();return b.getTargetElements(i,e.id).length<1?!1:s==="funnel"?o?await b.evaluateRuleLogic(t,o)===!0:!1:i.length===0?!1:b.isRulesLogic(o)?await b.evaluateRuleLogic(t,o)===!0:!0},W=(t,e,s)=>{const o=e.name,i=e.setup(t);if(i){const p=s[o]??{};s[o]=Object.freeze({...p,...i})}},G=d.createDomain("component"),J=h.createFactory(({client:t,component:e,name:s})=>{const o=t.frameworks.getByName(e.frameworkName);return{name:s,component:e,frameworkStore:o}});function Y(t){return h.invoke(J,t)}const Q=h.createFactory(({client:t})=>{const e=G.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:n}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Component '${r}' already registered. Registering again will override the previous registration.`);const v=Y({client:t,name:r,component:n});s.register(v)}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function X(t){return h.invoke(Q,t)}const D=(t,e,s)=>{s.register(t,e)},Z=d.createDomain("framework"),ee=h.createFactory(({client:t})=>{const e=Z.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:n.framework}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Framework '${r}' already registered. Registering again will override the previous registration.`),s.register({name:r,framework:n})}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function te(t){return h.invoke(ee,t)}const re=(t,e)=>{e.register(t.name,t)},se=6e3,R=k.createStorageKey("last_ping","global"),ne=t=>`${t}/api/v1/ping`,oe=async t=>{try{const e=Date.now(),s=localStorage.getItem(R);if(s&&e-parseInt(s)<se)return!0;const o=ne(t.apiUrl),i={projectId:t.projectId,path:window.location.pathname},p=JSON.stringify(i),r={"Content-Type":"application/json"},n=document.getElementById("picked_script"),f=n==null?void 0:n.dataset.verceltoken;f&&(r["x-vercel-protection-bypass"]=f);const u=(await fetch(o,{method:"POST",headers:r,body:p})).ok;return u&&localStorage.setItem(R,e.toString()),u}catch(e){return I.logger("error",e),!1}};function ie(t){const e=typeof window<"u",s={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(s)}const ae=d.createDomain("predicate"),ce=h.createFactory(({client:t})=>{const e=ae.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:{name:n.name,predicate:n.predicate}}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Predicate '${r}' already registered. Registering again will override the previous registration.`),s.register(Object.freeze({name:r,predicate:n}))}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function ue(t){return h.invoke(ce,t)}const le=(t,e,s)=>{s.register(t,e)},$=d.createDomain("feature"),pe=h.createFactory(()=>{const t=$.store({}),e=$.store([]),s=d.createApi(t,{register(u,c){return{...u,[c.id]:c.feature}}});function o(u,c){t.getState()[u]&&I.logger("warn",`Feature '${u}' already registered. Registering again will override the previous registration.`);const g={id:u,feature:{...c,id:u}};s.register(Object.freeze({id:u,feature:g}))}const i=d.createEffect(async({id:u,key:c,storage:a="local"})=>{const g=k.createStorageKey(`feature:${u}:${c}`,"global"),l=(a==="session"?k.sessionStore:k.localStore).get(g).boolean();if(l!==null)return{id:u,bucket:l}}),p=d.createEffect(u=>{if(!u)return null;const c=k.createStorageKey(`feature:${u.id}:${u.key}`,"global");(u.storage==="session"?k.sessionStore:k.localStore).set(c,u.bucket)}),r=new Map,n=d.attach({source:{allFeaturesStore:t,resolvedFeaturesStore:e},effect:async({allFeaturesStore:u,resolvedFeaturesStore:c},{id:a,decide:g,key:m})=>{const l=c.find(j=>j.id===a);if(l)return l;const S=u[a];if(!S)throw new Error(`Feature with id '${a}' not found`);const F=r.get(`${a}:${m}`);if(F){const j=await F;return{id:S.id,bucket:j,storage:S.feature.storage}}const P=g();r.set(`${a}:${m}`,P);const x=await P;return{id:S.id,bucket:x,storage:S.feature.storage}}});d.sample({clock:s.register,fn:u=>{const{id:c,feature:a}=u;return{id:c,key:a.feature.key,storage:a.feature.storage}},target:i}),d.sample({source:e,clock:[i.doneData,n.doneData],fn:(u,c)=>!c||u.some(a=>a.id===c.id)?u:[...u,c],target:e}),d.sample({source:t,clock:n.doneData,fn:(u,c)=>{var S;const{id:a,bucket:g,storage:m}=c,l=(S=u[a])==null?void 0:S.feature.key;return l?{key:l,id:a,bucket:g,storage:m}:null},target:p});const f=d.combine({allFeaturesStore:t,resolvedFeaturesStore:e}).map(({allFeaturesStore:u,resolvedFeaturesStore:c})=>Object.values(u).map(a=>{const g=c.find(m=>m.id===a.id);return g?{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:()=>({id:a.id,bucket:g.bucket}),isResolved:!0}:{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:async()=>await n(a.feature),isResolved:!1}}));function v(u){return t.map(c=>c[u],{skipVoid:!1})}return{register:o,getByName:v,listStore:f}});function ge(){return h.invoke(pe)}const de=(t,e,s)=>{s.register(t,e)},E=d.createDomain("history");function C(t,e){return{id:M.generateId("history-entry"),node:e,at:Date.now(),experienceId:t}}const fe=h.createFactory(()=>{const t=E.store({entries:[]}),e=E.event(),s=E.event(),o=E.event(),i=E.event();t.on(e,(r,n)=>({entries:[...r.entries,C(n.experienceId,n.node)]})),t.on(s,(r,n)=>({entries:[...r.entries.slice(0,-1),C(n.experienceId,n.node)]})),t.on(i,(r,n)=>n);function p(r,n){const f={lastStepIndex:-1,secondLastStepIndex:-1};for(let v=r.length-1;v>=0;v--){const u=r[v],c=u==null?void 0:u.node;if(!(!c||!b.isStepNode(c))&&!(n&&(u==null?void 0:u.experienceId)!==n))if(f.lastStepIndex===-1)f.lastStepIndex=v;else{f.secondLastStepIndex=v;break}}return f}return t.on(o,(r,n)=>{const{secondLastStepIndex:f}=p(r.entries,n.experienceId),v=f!==-1?r.entries.slice(0,f+1):r.entries;return{...r,entries:v}}),{push:e,replace:s,back:o,restore:i,entriesStore:t.map(r=>r.entries)}});function me(){return h.invoke(fe)}const ye=()=>d.createEvent(),he=d.createDomain("field"),Se=h.createFactory(()=>{const t=he.store({}),e=d.createApi(t,{register(r,n){return{...r,[n.field.id]:n.field}}});function s(r){e.register({field:r})}const o=t.map(r=>Object.values(r));function i(r){return t.map(n=>n[r]||null)}function p(r){return t.map(n=>Object.values(n).find(f=>f.name===r)||null)}return{register:s,getById:i,listStore:o,getByName:p}});function ve(){return h.invoke(Se)}const ke=(t,e)=>{e.register(t)},we=d.createDomain("response"),be=h.createFactory(({client:t})=>{const e=we.store({}),s=d.createEvent(),o=d.createEvent(),i=d.createApi(e,{register(c,a){return{...c,[a.fieldId]:a.response}},clear(c,a){const{[a]:g,...m}=c;return m},clearAll(){return{}}});function p(c,a){i.register({fieldId:c,response:a})}async function r(c){const a=[];return await Promise.allSettled(Object.entries(c).map(async([g,m])=>{let l=m;const S=t.fields.getById(g).getState();if(!S){a.push({fieldId:g,userMessage:`Field '${g}' not found`,systemMessage:`No field with ID '${g}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:l});return}if(S.multiple&&(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&(l=[l]),!N.isEmpty(S.validation)){const F=await b.evaluateRuleLogic(t,S.validation,{$input:l});if(typeof F=="string"){a.push({fieldId:g,userMessage:F,systemMessage:`Field validation resulted in an error: ${F}.`,value:l});return}if(F===!1){a.push({fieldId:g,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:l});return}}if(S.required&&(typeof l>"u"||l===null||l===""||Array.isArray(l)&&!l.length)){a.push({fieldId:g,userMessage:"This field is required",systemMessage:"Field is required.",value:l});return}if(!S.multiple&&Array.isArray(l)&&l.length>1){a.push({fieldId:g,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:l});return}if(S.options){const F=S.options.map(x=>x.value),P=Array.isArray(l)?l:[l];Array.isArray(l)&&(P.every(x=>F.includes(x))||a.push({fieldId:g,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${F.join(", ")}`,value:l}))}})),a.length?{errors:a}:(Object.entries(c).forEach(([g,m])=>{p(g,m)}),{errors:[]})}const n=e.map(c=>c),f=e.map(c=>Object.keys(c).map(g=>({fieldId:g,value:c[g]})));function v(c){const a=t.fields.getById(c),g=e.map(m=>m[c]||null);return d.combine({f:a,r:g},({f:m,r:l})=>l||(m!=null&&m.defaultValue?m.defaultValue:null))}function u(c){const a=t.fields.getByName(c);return d.combine({f:a,s:e},({f:g,s:m})=>{const l=g&&m[g.id]||null;return l||(g!=null&&g.defaultValue?g.defaultValue:null)})}return d.sample({clock:s,target:i.clearAll}),d.sample({clock:o,target:i.clear}),{register:p,clearAll:s,clear:o,commit:r,listStore:f,getAllStore:n,getByFieldId:v,getByFieldName:u}});function Fe(t){return h.invoke(be,t)}const Ie=()=>"0.0.3";function xe(){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 Ee(){if(!w.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},s=new Set;for(const[i]of t.entries())i.startsWith("picked-")&&s.add(i);for(const i of s){const p=i.replace("picked-","");e[p]=t.getAll(i)}const o=k.createStorageKey("s");if(s.size>0)k.sessionStore.set(o,e);else{const i=k.sessionStore.get(o);if(i)return i.json()||{}}return e}class A{constructor(e){y(this,"options");y(this,"isReady",!1);y(this,"project");y(this,"plugins",{});y(this,"eventBus",ye());y(this,"organizationId");y(this,"projectId");y(this,"apiUrl");y(this,"searchParams",Ee());y(this,"history",me());y(this,"components",X({client:this}));y(this,"experienceInstances",b.createExperienceInstanceIndex({client:this}));y(this,"experiences",_({client:this}));y(this,"frameworks",te({client:this}));y(this,"predicates",ue({client:this}));y(this,"features",ge());y(this,"fields",ve());y(this,"responses",Fe({client:this}));I.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||xe(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.eventBus({type:"initialized",version:Ie()}),I.logger("info","Picked client initialized.")}start(){oe(this),(async()=>{w.supportsDocument()&&(document.body&&await B(this),await b.domInteractive(),await B(this),this.eventBus({type:"ready"}),this.isReady=!0)})()}registerFramework(e){re(e,this.frameworks)}registerComponent(e,s){D(e,s,this.components)}registerPlugin(e){W(this,e,this.plugins)}registerFeature(e,s){de(e,s,this.features)}registerPredicate(e,s){le(e,s,this.predicates)}registerField(e){ke(e,this.fields)}registerExperience(e){e.component&&D(`experience:${e.id}`,e.component,this.components),H(e,this.experiences)}getStateSnapshot(){return ie(this)}async launchExperienceById(e){const s=this.experiences.getById(e).getState();if(!s){I.logger("warn",`Experience with id '${e}' not found.`);return}L(this,s)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(s=>{if(Array.isArray(s)){s.forEach(i=>{this.registerPlugin(i)});return}const o=typeof s=="function"?s():s;if(Array.isArray(o)){o.forEach(i=>this.registerPlugin(i));return}this.registerPlugin(o)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([s,o])=>{const i=typeof o=="function"?o():o;this.registerFeature(s,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(s=>{try{const[o,i]=s.split(":");if(!o||!i)return;let p=i;p==="true"&&(p=!0),p==="false"&&(p=!1),this.registerFeature(o,{key:"*",name:o,decide:()=>p,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([s,o])=>{if(typeof o!="function"){I.logger("warn",`Predicate "${s}" is not a function.`);return}this.registerPredicate(s,o)})}getPluginConfig(e){return this.plugins[e]??{}}}y(A,"logger",I.logger);const Pe=t=>{const e=new A(t);return w.bindClient(e),e};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.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=A;exports.createClient=Pe;
1
+ "use strict";var M=Object.defineProperty;var T=(t,e,s)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var y=(t,e,s)=>T(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("effector"),h=require("@withease/factories"),b=require("../experience-instance-DwO_yZK0.cjs"),I=require("../logger-BsmHUUw1.cjs"),k=require("../storage-BPJwmlva.cjs"),V=require("../id-BKIWbSTy.cjs"),N=require("../object-BbFTsGh3.cjs"),w=require("../supports-B6KShYPU.cjs"),O=d.createDomain("experience"),z=h.createFactory(({client:t,experience:e})=>{const s=O.store(e),o=d.createApi(s,{merge(n,f){return{...n,...f.experience}}}),i=s.map(n=>({type:n.type,name:n.name,decisionLogic:n.decide,targetSelectors:n.targets})),p=t.components.listStore.map(n=>n.find(f=>f.name===`experience:${e.id}`)||n.find(f=>f.name==="experience"),{skipVoid:!1}),r=s.map(n=>({steps:n.steps,nodes:n.nodes,edges:n.edges,conditionals:n.conditionals}));return{id:e.id,configStore:i,treeStore:r,componentStore:p,merge:o.merge}});function q(t){return h.invoke(z,t)}const K=h.createFactory(({client:t})=>{const e=O.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.id]:n}}});function o(r){const n=e.getState()[r.id];if(n){n.merge({experience:r,strategy:"override"});return}const f=q({client:t,experience:r});s.register(f)}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getById:p,listStore:i}});function _(t){return h.invoke(K,t)}const H=(t,e)=>{e.register(t)},L=(t,e)=>{const{targetSelectors:s}=e.configStore.getState(),o=b.getTargetElements(s,e.id);o.forEach(({elements:p})=>p.forEach(r=>b.tagTargetElement(r,e.id))),b.createAppHosts(o,e.id).forEach(p=>{t.experienceInstances.spawn(e,p)})},D=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await U(t,e)&&L(t,e)}))},U=async(t,e)=>{const{type:s,decisionLogic:o,targetSelectors:i}=e.configStore.getState();return b.getTargetElements(i,e.id).length<1?!1:s==="funnel"?o?await b.evaluateRuleLogic(t,o)===!0:!1:i.length===0?!1:b.isRulesLogic(o)?await b.evaluateRuleLogic(t,o)===!0:!0},W=(t,e,s)=>{const o=e.name,i=e.setup(t);if(i){const p=s[o]??{};s[o]=Object.freeze({...p,...i})}},G=d.createDomain("component"),J=h.createFactory(({client:t,component:e,name:s})=>{const o=t.frameworks.getByName(e.frameworkName);return{name:s,component:e,frameworkStore:o}});function Y(t){return h.invoke(J,t)}const Q=h.createFactory(({client:t})=>{const e=G.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:n}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Component '${r}' already registered. Registering again will override the previous registration.`);const v=Y({client:t,name:r,component:n});s.register(v)}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function X(t){return h.invoke(Q,t)}const B=(t,e,s)=>{s.register(t,e)},Z=d.createDomain("framework"),ee=h.createFactory(({client:t})=>{const e=Z.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:n.framework}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Framework '${r}' already registered. Registering again will override the previous registration.`),s.register({name:r,framework:n})}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function te(t){return h.invoke(ee,t)}const re=(t,e)=>{e.register(t.name,t)},se=6e3,R=k.createStorageKey("last_ping","global"),ne=t=>`${t}/api/v1/ping`,oe=async t=>{try{const e=Date.now(),s=localStorage.getItem(R);if(s&&e-parseInt(s)<se)return!0;const o=ne(t.apiUrl),i={projectId:t.projectId,path:window.location.pathname},p=JSON.stringify(i),r={"Content-Type":"application/json"},n=document.getElementById("picked_script"),f=n==null?void 0:n.dataset.verceltoken;f&&(r["x-vercel-protection-bypass"]=f);const u=(await fetch(o,{method:"POST",headers:r,body:p})).ok;return u&&localStorage.setItem(R,e.toString()),u}catch(e){return I.logger("error",e),!1}};function ie(t){const e=typeof window<"u",s={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(s)}const ae=d.createDomain("predicate"),ce=h.createFactory(({client:t})=>{const e=ae.store({}),s=d.createApi(e,{register(r,n){return{...r,[n.name]:{name:n.name,predicate:n.predicate}}}});function o(r,n){e.getState()[r]&&I.logger("warn",`Predicate '${r}' already registered. Registering again will override the previous registration.`),s.register(Object.freeze({name:r,predicate:n}))}const i=e.map(r=>Object.values(r));function p(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:o,getByName:p,listStore:i}});function ue(t){return h.invoke(ce,t)}const le=(t,e,s)=>{s.register(t,e)},$=d.createDomain("feature"),pe=h.createFactory(()=>{const t=$.store({}),e=$.store([]),s=d.createApi(t,{register(u,c){return{...u,[c.id]:c.feature}}});function o(u,c){t.getState()[u]&&I.logger("warn",`Feature '${u}' already registered. Registering again will override the previous registration.`);const g={id:u,feature:{...c,id:u}};s.register(Object.freeze({id:u,feature:g}))}const i=d.createEffect(async({id:u,key:c,storage:a="local"})=>{const g=k.createStorageKey(`feature:${u}:${c}`,"global"),l=(a==="session"?k.sessionStore:k.localStore).get(g).boolean();if(l!==null)return{id:u,bucket:l}}),p=d.createEffect(u=>{if(!u)return null;const c=k.createStorageKey(`feature:${u.id}:${u.key}`,"global");(u.storage==="session"?k.sessionStore:k.localStore).set(c,u.bucket)}),r=new Map,n=d.attach({source:{allFeaturesStore:t,resolvedFeaturesStore:e},effect:async({allFeaturesStore:u,resolvedFeaturesStore:c},{id:a,decide:g,key:m})=>{const l=c.find(j=>j.id===a);if(l)return l;const S=u[a];if(!S)throw new Error(`Feature with id '${a}' not found`);const F=r.get(`${a}:${m}`);if(F){const j=await F;return{id:S.id,bucket:j,storage:S.feature.storage}}const P=g();r.set(`${a}:${m}`,P);const x=await P;return{id:S.id,bucket:x,storage:S.feature.storage}}});d.sample({clock:s.register,fn:u=>{const{id:c,feature:a}=u;return{id:c,key:a.feature.key,storage:a.feature.storage}},target:i}),d.sample({source:e,clock:[i.doneData,n.doneData],fn:(u,c)=>!c||u.some(a=>a.id===c.id)?u:[...u,c],target:e}),d.sample({source:t,clock:n.doneData,fn:(u,c)=>{var S;const{id:a,bucket:g,storage:m}=c,l=(S=u[a])==null?void 0:S.feature.key;return l?{key:l,id:a,bucket:g,storage:m}:null},target:p});const f=d.combine({allFeaturesStore:t,resolvedFeaturesStore:e}).map(({allFeaturesStore:u,resolvedFeaturesStore:c})=>Object.values(u).map(a=>{const g=c.find(m=>m.id===a.id);return g?{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:()=>({id:a.id,bucket:g.bucket}),isResolved:!0}:{id:a.id,name:a.feature.name,key:a.feature.key,getBucket:async()=>await n(a.feature),isResolved:!1}}));function v(u){return t.map(c=>c[u],{skipVoid:!1})}return{register:o,getByName:v,listStore:f}});function ge(){return h.invoke(pe)}const de=(t,e,s)=>{s.register(t,e)},E=d.createDomain("history");function C(t,e){return{id:V.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const fe=h.createFactory(()=>{const t=E.store({entries:[]}),e=E.event(),s=E.event(),o=E.event(),i=E.event();t.on(e,(r,n)=>({entries:[...r.entries,C(n.experienceId,n.node)]})),t.on(s,(r,n)=>({entries:[...r.entries.slice(0,-1),C(n.experienceId,n.node)]})),t.on(i,(r,n)=>n);function p(r,n){const f={lastStepIndex:-1,secondLastStepIndex:-1};for(let v=r.length-1;v>=0;v--){const u=r[v],c=u==null?void 0:u.node;if(!(!c||!b.isStepNode(c))&&!(n&&(u==null?void 0:u.experienceId)!==n))if(f.lastStepIndex===-1)f.lastStepIndex=v;else{f.secondLastStepIndex=v;break}}return f}return t.on(o,(r,n)=>{const{secondLastStepIndex:f}=p(r.entries,n.experienceId),v=f!==-1?r.entries.slice(0,f+1):r.entries;return{...r,entries:v}}),{push:e,replace:s,back:o,restore:i,entriesStore:t.map(r=>r.entries)}});function me(){return h.invoke(fe)}const ye=()=>d.createEvent(),he=d.createDomain("field"),Se=h.createFactory(()=>{const t=he.store({}),e=d.createApi(t,{register(r,n){return{...r,[n.field.id]:n.field}}});function s(r){e.register({field:r})}const o=t.map(r=>Object.values(r));function i(r){return t.map(n=>n[r]||null)}function p(r){return t.map(n=>Object.values(n).find(f=>f.name===r)||null)}return{register:s,getById:i,listStore:o,getByName:p}});function ve(){return h.invoke(Se)}const ke=(t,e)=>{e.register(t)},we=d.createDomain("response"),be=h.createFactory(({client:t})=>{const e=we.store({}),s=d.createEvent(),o=d.createEvent(),i=d.createApi(e,{register(c,a){return{...c,[a.fieldId]:a.response}},clear(c,a){const{[a]:g,...m}=c;return m},clearAll(){return{}}});function p(c,a){i.register({fieldId:c,response:a})}async function r(c){const a=[];return await Promise.allSettled(Object.entries(c).map(async([g,m])=>{let l=m;const S=t.fields.getById(g).getState();if(!S){a.push({fieldId:g,userMessage:`Field '${g}' not found`,systemMessage:`No field with ID '${g}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:l});return}if(S.multiple&&(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&(l=[l]),!N.isEmpty(S.validation)){const F=await b.evaluateRuleLogic(t,S.validation,{$input:l});if(typeof F=="string"){a.push({fieldId:g,userMessage:F,systemMessage:`Field validation resulted in an error: ${F}.`,value:l});return}if(F===!1){a.push({fieldId:g,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:l});return}}if(S.required&&(typeof l>"u"||l===null||l===""||Array.isArray(l)&&!l.length)){a.push({fieldId:g,userMessage:"This field is required",systemMessage:"Field is required.",value:l});return}if(!S.multiple&&Array.isArray(l)&&l.length>1){a.push({fieldId:g,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:l});return}if(S.options){const F=S.options.map(x=>x.value),P=Array.isArray(l)?l:[l];Array.isArray(l)&&(P.every(x=>F.includes(x))||a.push({fieldId:g,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${F.join(", ")}`,value:l}))}})),a.length?{errors:a}:(Object.entries(c).forEach(([g,m])=>{p(g,m)}),{errors:[]})}const n=e.map(c=>c),f=e.map(c=>Object.keys(c).map(g=>({fieldId:g,value:c[g]})));function v(c){const a=t.fields.getById(c),g=e.map(m=>m[c]||null);return d.combine({f:a,r:g},({f:m,r:l})=>l||(m!=null&&m.defaultValue?m.defaultValue:null))}function u(c){const a=t.fields.getByName(c);return d.combine({f:a,s:e},({f:g,s:m})=>{const l=g&&m[g.id]||null;return l||(g!=null&&g.defaultValue?g.defaultValue:null)})}return d.sample({clock:s,target:i.clearAll}),d.sample({clock:o,target:i.clear}),{register:p,clearAll:s,clear:o,commit:r,listStore:f,getAllStore:n,getByFieldId:v,getByFieldName:u}});function Fe(t){return h.invoke(be,t)}const Ie=()=>"0.0.4";function xe(){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 Ee(){if(!w.supportsWindow())return{};const t=new URLSearchParams(window.location.search),e={},s=new Set;for(const[i]of t.entries())i.startsWith("picked-")&&s.add(i);for(const i of s){const p=i.replace("picked-","");e[p]=t.getAll(i)}const o=k.createStorageKey("s");if(s.size>0)k.sessionStore.set(o,e);else{const i=k.sessionStore.get(o);if(i)return i.json()||{}}return e}class A{constructor(e){y(this,"options");y(this,"isReady",!1);y(this,"project");y(this,"plugins",{});y(this,"eventBus",ye());y(this,"organizationId");y(this,"projectId");y(this,"apiUrl");y(this,"searchParams",Ee());y(this,"history",me());y(this,"components",X({client:this}));y(this,"experienceInstances",b.createExperienceInstanceIndex({client:this}));y(this,"experiences",_({client:this}));y(this,"frameworks",te({client:this}));y(this,"predicates",ue({client:this}));y(this,"features",ge());y(this,"fields",ve());y(this,"responses",Fe({client:this}));I.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||xe(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.eventBus({type:"initialized",version:Ie()}),I.logger("info","Picked client initialized.")}start(){oe(this),(async()=>{w.supportsDocument()&&(document.body&&await D(this),await b.domInteractive(),await D(this),this.eventBus({type:"ready"}),this.isReady=!0)})()}registerFramework(e){re(e,this.frameworks)}registerComponent(e,s){B(e,s,this.components)}registerPlugin(e){W(this,e,this.plugins)}registerFeature(e,s){de(e,s,this.features)}registerPredicate(e,s){le(e,s,this.predicates)}registerField(e){ke(e,this.fields)}registerExperience(e){e.component&&B(`experience:${e.id}`,e.component,this.components),H(e,this.experiences)}getStateSnapshot(){return ie(this)}async launchExperienceById(e){const s=this.experiences.getById(e).getState();if(!s){I.logger("warn",`Experience with id '${e}' not found.`);return}L(this,s)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(s=>{if(Array.isArray(s)){s.forEach(i=>{this.registerPlugin(i)});return}const o=typeof s=="function"?s():s;if(Array.isArray(o)){o.forEach(i=>this.registerPlugin(i));return}this.registerPlugin(o)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([s,o])=>{const i=typeof o=="function"?o():o;this.registerFeature(s,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(s=>{try{const[o,i]=s.split(":");if(!o||!i)return;let p=i;p==="true"&&(p=!0),p==="false"&&(p=!1),this.registerFeature(o,{key:`${p}`,name:o,decide:()=>p,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([s,o])=>{if(typeof o!="function"){I.logger("warn",`Predicate "${s}" is not a function.`);return}this.registerPredicate(s,o)})}getPluginConfig(e){return this.plugins[e]??{}}}y(A,"logger",I.logger);const Pe=t=>{const e=new A(t);return w.bindClient(e),e};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.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=A;exports.createClient=Pe;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../../id-BKIWbSTy.cjs"),o={serialize(i){return JSON.stringify(i)},deserialize(i){return JSON.parse(i)}},N=i=>({name:"create-experience",setup:a=>{i.experiences.forEach(d=>{const s=d.serialize(),l=o.deserialize(s);l.component=d.component,a.registerExperience(l),l.fields.forEach(p=>{a.registerField(p)})})}}),y=(i,a)=>{const d={id:h.generateId("step"),label:i.label,experience:a,fields:[],node:null,nextStep(s){return this.experience.addStep(s,this)},nextConditional(s){return this.experience.addConditional(s,this)},addNextExperience(s){return this.experience.addExperience(s,this)},addField(s){return this.experience.addField(s,this)},serialize(){return o.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(s=>s.id)})}};return u({step:d,type:"step"},a),d},z=()=>[0,0],u=(i,a)=>{const d={id:h.generateId("node"),position:z(),experience:a};if(i.type==="step"){const l={...d,type:"step",connectedStep:i.step,serialize(){return o.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,position:this.position,label:this.connectedStep.label})}};return l.connectedStep.node=l,l}if(i.type==="conditional"){const l={...d,type:"conditional",connectedConditional:i.conditional,serialize(){return o.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id,position:this.position})}};return l.connectedConditional.node=l,l}return i.type==="experience"?{...d,type:"experience",connectedExperience:i.experience,serialize(){return o.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,position:this.position})}}:{...d,type:"origin",serialize(){return o.serialize({id:this.id,type:this.type,position:this.position})}}},c=(i,a)=>({id:h.generateId("edge"),sourceNode:i.sourceNode,sourceNodeHandle:i.sourceNodeHandle,destinationNode:i.destinationNode,experience:a,serialize(){return o.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),m=(i,a)=>{const d={id:h.generateId("conditional"),condition:i.condition,node:null,experience:a,addTrue(s){if(!this.node||!s.node)throw new Error("todo no node");const l=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(l)},addFalse(s){if(!this.node||!s.node)throw new Error("todo no node");const l=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(l)},serialize(){return o.serialize({id:this.id,condition:this.condition})}};return u({conditional:d,type:"conditional"},a),d},g=i=>{var d;return{id:h.generateId("field"),name:i.name,type:i.type,label:i.label,placeholder:i.placeholder,description:i.description,helpText:i.helpText,defaultValue:i.defaultValue,multiple:i.multiple,validation:i.validation,required:i.required,options:((d=i.options)==null?void 0:d.map(s=>({...s,id:h.generateId("option")})))||null,policies:i.policies,serialize(){const s={id:this.id,name:this.name,label:this.label,placeholder:this.placeholder,required:this.required,description:this.description,helpText:this.helpText,validation:this.validation,policies:this.policies},l=typeof this.defaultValue=="string"?this.defaultValue:null,p=typeof this.defaultValue=="number"?this.defaultValue:null,n=typeof this.defaultValue=="boolean"?this.defaultValue:null;switch(this.type){case"text":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="string"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"text",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:`${t.value}`})):null})}return o.serialize({...s,type:"text",multiple:!1,defaultValue:l,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`})):null});case"number":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="number"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"number",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:Number(t.value)})):null})}return o.serialize({...s,type:"number",multiple:!1,defaultValue:p,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value)})):null});case"boolean":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="boolean"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"boolean",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:!!t.value})):null})}return o.serialize({...s,type:"boolean",multiple:!1,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value})):null});default:throw new Error("Unsupported field type")}}}},b=i=>{const a=[],d=[],s=[],l=[],p=[];return{id:i.id,component:i.component,type:i.type,name:i.name,decide:i.decide,targets:i.targets,steps:a,nodes:d,edges:s,fields:p,conditionals:l,addStep(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r="serialize"in n?n:y(n,this);if(t){if(!r.node)throw new Error("todo no node");const f=c({sourceNode:t,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(f)}return this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addConditional(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r="serialize"in n?n:m(n,this);if(t){if(!r.node)throw new Error("todo no node");const f=c({sourceNode:t,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(f)}return this.conditionals.includes(r)||(this.conditionals.push(r),r.node&&this.nodes.push(r.node)),r},addExperience(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r=u({type:"experience",experience:n},this);if(this.nodes.push(r),t){const f=c({sourceNode:t,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(f)}return n},addField(n,e){const t="serialize"in n?n:g(n);return e&&e.fields.push(t),this.fields.includes(t)||this.fields.push(t),t},serialize(){return o.serialize({id:this.id,type:this.type,component:this.component,name:this.name,decide:this.decide,targets:this.targets,steps:this.steps.map(n=>o.deserialize(n.serialize())),nodes:this.nodes.map(n=>o.deserialize(n.serialize())),edges:this.edges.map(n=>o.deserialize(n.serialize())),conditionals:this.conditionals.map(n=>o.deserialize(n.serialize())),fields:this.fields.map(n=>o.deserialize(n.serialize()))})}}};exports.createConditional=m;exports.createEdge=c;exports.createExperience=b;exports.createExperiencePlugin=N;exports.createField=g;exports.createNode=u;exports.createStep=y;exports.serialization=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../id-BKIWbSTy.cjs"),o={serialize(i){return JSON.stringify(i)},deserialize(i){return JSON.parse(i)}},N=i=>({name:"create-experience",setup:a=>{i.experiences.forEach(d=>{const s=d.serialize(),l=o.deserialize(s);l.component=d.component,a.registerExperience(l),l.fields.forEach(h=>{a.registerField(h)})})}}),y=(i,a)=>{const d={id:f.generateId("step"),label:i.label,experience:a,fields:[],node:null,nextStep(s){return this.experience.addStep(s,this)},nextConditional(s){return this.experience.addConditional(s,this)},addNextExperience(s){return this.experience.addExperience(s,this)},addField(s){return this.experience.addField(s,this)},serialize(){return o.serialize({id:this.id,label:this.label,fieldIds:this.fields.map(s=>s.id)})}};return u({step:d,type:"step"},a),d},z=()=>[0,0],u=(i,a)=>{const d={id:f.generateId("node"),position:z(),experience:a};if(i.type==="step"){const l={...d,type:"step",connectedStep:i.step,serialize(){return o.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,position:this.position,label:this.connectedStep.label})}};return l.connectedStep.node=l,l}if(i.type==="conditional"){const l={...d,type:"conditional",connectedConditional:i.conditional,serialize(){return o.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id,position:this.position})}};return l.connectedConditional.node=l,l}return i.type==="experience"?{...d,type:"experience",connectedExperience:i.experience,serialize(){return o.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,position:this.position})}}:{...d,type:"origin",serialize(){return o.serialize({id:this.id,type:this.type,position:this.position})}}},c=(i,a)=>({id:f.generateId("edge"),sourceNode:i.sourceNode,sourceNodeHandle:i.sourceNodeHandle,destinationNode:i.destinationNode,experience:a,serialize(){return o.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),m=(i,a)=>{const d={id:f.generateId("conditional"),condition:i.condition,node:null,experience:a,addTrue(s){if(!this.node||!s.node)throw new Error("todo no node");const l=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(l)},addFalse(s){if(!this.node||!s.node)throw new Error("todo no node");const l=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(l)},serialize(){return o.serialize({id:this.id,condition:this.condition})}};return u({conditional:d,type:"conditional"},a),d},g=i=>{var d;return{id:i.id,name:i.name,type:i.type,label:i.label,placeholder:i.placeholder,description:i.description,helpText:i.helpText,defaultValue:i.defaultValue,multiple:i.multiple,validation:i.validation,required:i.required,options:((d=i.options)==null?void 0:d.map(s=>({...s})))||null,policies:i.policies,serialize(){const s={id:this.id,name:this.name,label:this.label,placeholder:this.placeholder,required:this.required,description:this.description,helpText:this.helpText,validation:this.validation,policies:this.policies},l=typeof this.defaultValue=="string"?this.defaultValue:null,h=typeof this.defaultValue=="number"?this.defaultValue:null,n=typeof this.defaultValue=="boolean"?this.defaultValue:null;switch(this.type){case"text":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="string"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"text",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:`${t.value}`})):null})}return o.serialize({...s,type:"text",multiple:!1,defaultValue:l,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`})):null});case"number":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="number"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"number",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:Number(t.value)})):null})}return o.serialize({...s,type:"number",multiple:!1,defaultValue:h,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value)})):null});case"boolean":if(this.multiple){let e=null;if(Array.isArray(this.defaultValue)){e=[];for(const t of this.defaultValue)typeof t=="boolean"&&e.push(t);e.length===0&&(e=null)}return o.serialize({...s,type:"boolean",multiple:!0,defaultValue:e,options:this.options?this.options.map(t=>({id:t.id,label:t.label,value:!!t.value})):null})}return o.serialize({...s,type:"boolean",multiple:!1,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value})):null});default:throw new Error("Unsupported field type")}}}},b=i=>{const a=[],d=[],s=[],l=[],h=[];return{id:i.id,component:i.component,type:i.type,name:i.name,decide:i.decide,targets:i.targets,steps:a,nodes:d,edges:s,fields:h,conditionals:l,addStep(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r="serialize"in n?n:y(n,this);if(t){if(!r.node)throw new Error("todo no node");const p=c({sourceNode:t,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(p)}return this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addConditional(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r="serialize"in n?n:m(n,this);if(t){if(!r.node)throw new Error("todo no node");const p=c({sourceNode:t,destinationNode:r.node,sourceNodeHandle:null},this);this.edges.push(p)}return this.conditionals.includes(r)||(this.conditionals.push(r),r.node&&this.nodes.push(r.node)),r},addExperience(n,e){let t=e==null?void 0:e.node;this.nodes.length===0&&(t=u({type:"origin"},this),this.nodes.push(t));const r=u({type:"experience",experience:n},this);if(this.nodes.push(r),t){const p=c({sourceNode:t,destinationNode:r,sourceNodeHandle:null},this);this.edges.push(p)}return n},addField(n,e){const t="serialize"in n?n:g(n);return e&&e.fields.push(t),this.fields.includes(t)||this.fields.push(t),t},serialize(){return o.serialize({id:this.id,type:this.type,component:this.component,name:this.name,decide:this.decide,targets:this.targets,steps:this.steps.map(n=>o.deserialize(n.serialize())),nodes:this.nodes.map(n=>o.deserialize(n.serialize())),edges:this.edges.map(n=>o.deserialize(n.serialize())),conditionals:this.conditionals.map(n=>o.deserialize(n.serialize())),fields:this.fields.map(n=>o.deserialize(n.serialize()))})}}};exports.createConditional=m;exports.createEdge=c;exports.createExperience=b;exports.createExperiencePlugin=N;exports.createField=g;exports.createNode=u;exports.createStep=y;exports.serialization=o;
package/dist/esm/index.js CHANGED
@@ -367,7 +367,8 @@ const Re = (t, e, s) => {
367
367
  }, I = x("history");
368
368
  function L(t, e) {
369
369
  return {
370
- id: te("history-entry"),
370
+ // eslint-disable-next-line sonarjs/pseudo-random
371
+ id: te(`history-entry-${Date.now()}-${Math.random()}}`),
371
372
  node: e,
372
373
  at: Date.now(),
373
374
  experienceId: t
@@ -569,7 +570,7 @@ const Ne = (t, e) => {
569
570
  function ze(t) {
570
571
  return k(Le, t);
571
572
  }
572
- const _e = () => "0.0.3";
573
+ const _e = () => "0.0.4";
573
574
  function Ue() {
574
575
  if (_()) {
575
576
  const t = [
@@ -702,7 +703,8 @@ class K {
702
703
  return;
703
704
  let d = i;
704
705
  d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(o, {
705
- key: "*",
706
+ key: `${d}`,
707
+ // use the assigned bucket value as the key
706
708
  name: o,
707
709
  // eslint-disable-next-line sonarjs/function-return-type
708
710
  decide: () => d,
@@ -1,4 +1,4 @@
1
- import { g as h } from "../../../id-BW-g3y32.js";
1
+ import { g as f } from "../../../id-BW-g3y32.js";
2
2
  const l = {
3
3
  serialize(i) {
4
4
  return JSON.stringify(i);
@@ -11,14 +11,14 @@ const l = {
11
11
  setup: (a) => {
12
12
  i.experiences.forEach((d) => {
13
13
  const s = d.serialize(), o = l.deserialize(s);
14
- o.component = d.component, a.registerExperience(o), o.fields.forEach((c) => {
15
- a.registerField(c);
14
+ o.component = d.component, a.registerExperience(o), o.fields.forEach((h) => {
15
+ a.registerField(h);
16
16
  });
17
17
  });
18
18
  }
19
19
  }), m = (i, a) => {
20
20
  const d = {
21
- id: h("step"),
21
+ id: f("step"),
22
22
  label: i.label,
23
23
  experience: a,
24
24
  fields: [],
@@ -46,7 +46,7 @@ const l = {
46
46
  return u({ step: d, type: "step" }, a), d;
47
47
  }, y = () => [0, 0], u = (i, a) => {
48
48
  const d = {
49
- id: h("node"),
49
+ id: f("node"),
50
50
  position: y(),
51
51
  experience: a
52
52
  };
@@ -106,8 +106,8 @@ const l = {
106
106
  });
107
107
  }
108
108
  };
109
- }, f = (i, a) => ({
110
- id: h("edge"),
109
+ }, p = (i, a) => ({
110
+ id: f("edge"),
111
111
  sourceNode: i.sourceNode,
112
112
  sourceNodeHandle: i.sourceNodeHandle,
113
113
  destinationNode: i.destinationNode,
@@ -122,14 +122,14 @@ const l = {
122
122
  }
123
123
  }), N = (i, a) => {
124
124
  const d = {
125
- id: h("conditional"),
125
+ id: f("conditional"),
126
126
  condition: i.condition,
127
127
  node: null,
128
128
  experience: a,
129
129
  addTrue(s) {
130
130
  if (!this.node || !s.node)
131
131
  throw new Error("todo no node");
132
- const o = f(
132
+ const o = p(
133
133
  { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
134
134
  this.experience
135
135
  );
@@ -138,7 +138,7 @@ const l = {
138
138
  addFalse(s) {
139
139
  if (!this.node || !s.node)
140
140
  throw new Error("todo no node");
141
- const o = f(
141
+ const o = p(
142
142
  { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
143
143
  this.experience
144
144
  );
@@ -155,7 +155,7 @@ const l = {
155
155
  }, z = (i) => {
156
156
  var d;
157
157
  return {
158
- id: h("field"),
158
+ id: i.id,
159
159
  name: i.name,
160
160
  type: i.type,
161
161
  label: i.label,
@@ -167,8 +167,7 @@ const l = {
167
167
  validation: i.validation,
168
168
  required: i.required,
169
169
  options: ((d = i.options) == null ? void 0 : d.map((s) => ({
170
- ...s,
171
- id: h("option")
170
+ ...s
172
171
  }))) || null,
173
172
  policies: i.policies,
174
173
  serialize() {
@@ -182,7 +181,7 @@ const l = {
182
181
  helpText: this.helpText,
183
182
  validation: this.validation,
184
183
  policies: this.policies
185
- }, o = typeof this.defaultValue == "string" ? this.defaultValue : null, c = typeof this.defaultValue == "number" ? this.defaultValue : null, n = typeof this.defaultValue == "boolean" ? this.defaultValue : null;
184
+ }, o = typeof this.defaultValue == "string" ? this.defaultValue : null, h = typeof this.defaultValue == "number" ? this.defaultValue : null, n = typeof this.defaultValue == "boolean" ? this.defaultValue : null;
186
185
  switch (this.type) {
187
186
  case "text":
188
187
  if (this.multiple) {
@@ -241,7 +240,7 @@ const l = {
241
240
  ...s,
242
241
  type: "number",
243
242
  multiple: !1,
244
- defaultValue: c,
243
+ defaultValue: h,
245
244
  options: this.options ? this.options.map((e) => ({
246
245
  id: e.id,
247
246
  label: e.label,
@@ -304,7 +303,7 @@ const l = {
304
303
  }
305
304
  };
306
305
  }, x = (i) => {
307
- const a = [], d = [], s = [], o = [], c = [];
306
+ const a = [], d = [], s = [], o = [], h = [];
308
307
  return {
309
308
  id: i.id,
310
309
  component: i.component,
@@ -315,7 +314,7 @@ const l = {
315
314
  steps: a,
316
315
  nodes: d,
317
316
  edges: s,
318
- fields: c,
317
+ fields: h,
319
318
  conditionals: o,
320
319
  addStep(n, e) {
321
320
  let t = e == null ? void 0 : e.node;
@@ -324,11 +323,11 @@ const l = {
324
323
  if (t) {
325
324
  if (!r.node)
326
325
  throw new Error("todo no node");
327
- const p = f(
326
+ const c = p(
328
327
  { sourceNode: t, destinationNode: r.node, sourceNodeHandle: null },
329
328
  this
330
329
  );
331
- this.edges.push(p);
330
+ this.edges.push(c);
332
331
  }
333
332
  return this.steps.includes(r) || (this.steps.push(r), r.node && this.nodes.push(r.node)), r;
334
333
  },
@@ -339,11 +338,11 @@ const l = {
339
338
  if (t) {
340
339
  if (!r.node)
341
340
  throw new Error("todo no node");
342
- const p = f(
341
+ const c = p(
343
342
  { sourceNode: t, destinationNode: r.node, sourceNodeHandle: null },
344
343
  this
345
344
  );
346
- this.edges.push(p);
345
+ this.edges.push(c);
347
346
  }
348
347
  return this.conditionals.includes(r) || (this.conditionals.push(r), r.node && this.nodes.push(r.node)), r;
349
348
  },
@@ -355,11 +354,11 @@ const l = {
355
354
  this
356
355
  );
357
356
  if (this.nodes.push(r), t) {
358
- const p = f(
357
+ const c = p(
359
358
  { sourceNode: t, destinationNode: r, sourceNodeHandle: null },
360
359
  this
361
360
  );
362
- this.edges.push(p);
361
+ this.edges.push(c);
363
362
  }
364
363
  return n;
365
364
  },
@@ -388,7 +387,7 @@ const l = {
388
387
  };
389
388
  export {
390
389
  N as createConditional,
391
- f as createEdge,
390
+ p as createEdge,
392
391
  x as createExperience,
393
392
  b as createExperiencePlugin,
394
393
  z as createField,
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/entities/history/history.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAM9D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;CACrB;AA0FD,wBAAgB,aAAa;;sBA1EsB,MAAM;cAAQ,cAAc;;;sBACzB,MAAM;cAAQ,cAAc;;;uBAC9B,MAAM;;;iBACT,YAAY,EAAE;;;EAyE9D"}
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../src/entities/history/history.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAM9D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;CACrB;AA2FD,wBAAgB,aAAa;;sBA1EsB,MAAM;cAAQ,cAAc;;;sBACzB,MAAM;cAAQ,cAAc;;;uBAC9B,MAAM;;;iBACT,YAAY,EAAE;;;EAyE9D"}
@@ -78,8 +78,8 @@ export interface SerializableConditional extends Nodeable {
78
78
  export interface CreateConditionalOptions {
79
79
  condition: LogicRule;
80
80
  }
81
- export type CreateFieldOptions = Omit<Field, 'id' | 'options'> & {
82
- options: Omit<NonNullable<FieldTextSingular['options']>[number], 'id'>[] | Omit<NonNullable<FieldTextMultiple['options']>[number], 'id'>[] | Omit<NonNullable<FieldNumberSingular['options']>[number], 'id'>[] | Omit<NonNullable<FieldNumberMultiple['options']>[number], 'id'>[] | Omit<NonNullable<FieldBooleanSingular['options']>[number], 'id'>[] | Omit<NonNullable<FieldBooleanMultiple['options']>[number], 'id'>[] | null;
81
+ export type CreateFieldOptions = Omit<Field, 'options'> & {
82
+ options: NonNullable<FieldTextSingular['options']>[number][] | NonNullable<FieldTextMultiple['options']>[number][] | NonNullable<FieldNumberSingular['options']>[number][] | NonNullable<FieldNumberMultiple['options']>[number][] | NonNullable<FieldBooleanSingular['options']>[number][] | NonNullable<FieldBooleanMultiple['options']>[number][] | null;
83
83
  };
84
84
  export type SerializableField = {
85
85
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,UAAU,EAAE,sBAAsB,CAAA;IAClC,QAAQ,EAAE,CAAC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB,KAAK,gBAAgB,CAAA;IACjF,eAAe,EAAE,CACf,kBAAkB,EAAE,wBAAwB,GA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AE,SAAS,CAAA;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA+BF,CAAA;AAID,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA+EF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBAkBF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,wBAAwB,EAC5C,YAAY,sBAAsB,KACjC,uBA0CF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc,kBAAkB,KAAG,iBA0M9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,uBAAuB,KAAG,sBAmJtE,CAAA"}
1
+ {"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9B;AAED,MAAM,WAAW,gBA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uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,CAAA;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA+BF,CAAA;AAID,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA+EF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBAkBF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,wBAAwB,EAC5C,YAAY,sBAAsB,KACjC,uBA0CF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc,kBAAkB,KAAG,iBAyM9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,uBAAuB,KAAG,sBAmJtE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },