@picked/client 0.0.1-dev.1772162264282 → 0.0.1-dev.1772165084341
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 +2 -2
- package/dist/esm/index.js +9 -9
- package/dist/types/entities/experience/experience.d.ts +6 -1
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts +5 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("effector"),S=require("@withease/factories"),I=require("../experience-instance-BsXG5XJ4.cjs"),x=require("../logger-BsmHUUw1.cjs"),b=require("../storage-Be5xWNPC.cjs"),H=require("../api-DzSCgBQ2.cjs"),K=require("../id-BKIWbSTy.cjs"),G=require("../object-BbFTsGh3.cjs"),k=require("../supports-YvpQZxbh.cjs"),U=g.createDomain("experience"),W=S.createFactory(({client:t,experience:e})=>{const r=U.store(e),s=g.createApi(r,{merge(u,m){return{...u,...m.experience}}}),i=r.map(u=>({name:u.name,decisionLogic:u.condition??u.decide,targetSelectors:u.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(u=>u.find(m=>m.name===`experience:${e.id}`)||u.find(m=>m.name==="experience"),{skipVoid:!1}),a=r.map(u=>({steps:u.steps,nodes:u.nodes,edges:u.edges,conditionals:u.conditionals})),n=r.map(u=>u.fields),p=e.actions??[];return{id:e.id,configStore:i,treeStore:a,fieldsStore:n,componentStore:d,actions:p,merge:s.merge}});function J(t){return S.invoke(W,t)}const Y=S.createFactory(({client:t})=>{const e=U.store({}),r=g.createApi(e,{register(u,m){return{...u,[m.id]:m}}});function s(u){const m=e.getState()[u.id];if(m){m.merge({experience:u,strategy:"override"});return}const w=J({client:t,experience:u});r.register(w)}const i=e.map(u=>Object.values(u));function d(u){return e.map(m=>m[u],{skipVoid:!1})}const a=d,n=g.attach({source:e,effect:async(u,{id:m,options:w})=>{const y=u[m];if(!y){x.logger("warn",`Experience with id '${m}' not found.`);return}if(w?.bypassCondition){C(t,y,w);return}await L(t,y)&&C(t,y,w)}}),p=g.attach({source:t.experienceInstances.listStore,effect:(u,m)=>{const w=u.filter(y=>y.experienceId===m);if(w.length>0)for(const y of w)y.open();else n({id:m,options:{initialiseOpen:!0}})}});return{register:s,get:d,getById:a,launch:n,open:p,listStore:i}});function Q(t){return S.invoke(Y,t)}const X=(t,e)=>{e.register(t)},C=(t,e,r)=>{const{targetSelectors:s}=e.configStore.getState(),i=I.getTargetElements(s,e.id);i.forEach(({elements:a})=>a.forEach(n=>I.tagTargetElement(n,e.id))),I.createAppHosts(i,e.id).forEach(a=>{r?t.experienceInstances.spawn(e,a,r):t.experienceInstances.spawn(e,a)})},z=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await L(t,e)&&C(t,e)}))},L=async(t,e)=>{if(!t.session?.isUser)return!1;const{decisionLogic:r,targetSelectors:s}=e.configStore.getState();return I.getTargetElements(s,e.id).length<1||s.length===0?!1:r&&I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},Z=(t,e,r)=>{const s=e.name,i=e.setup(t);if(i){const d=r[s]??{};r[s]=Object.freeze({...d,...i})}},ee=g.createDomain("component"),te=S.createFactory(({client:t,component:e,name:r})=>{const s=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:s}});function re(t){return S.invoke(te,t)}const se=S.createFactory(({client:t})=>{const e=ee.store({}),r=g.createApi(e,{register(a,n){return{...a,[n.name]:n}}});function s(a,n){e.getState()[a]&&x.logger("warn",`Component '${a}' already registered. Registering again will override the previous registration.`);const u=re({client:t,name:a,component:n});r.register(u)}const i=e.map(a=>Object.values(a));function d(a){return e.map(n=>n[a],{skipVoid:!1})}return{register:s,getByName:d,listStore:i}});function ne(t){return S.invoke(se,t)}const D=(t,e,r)=>{r.register(t,e)},ie=g.createDomain("framework"),oe=S.createFactory(({client:t})=>{const e=ie.store({}),r=g.createApi(e,{register(a,n){return{...a,[n.name]:n.framework}}});function s(a,n){e.getState()[a]&&x.logger("warn",`Framework '${a}' already registered. Registering again will override the previous registration.`),r.register({name:a,framework:n})}const i=e.map(a=>Object.values(a));function d(a){return e.map(n=>n[a],{skipVoid:!1})}return{register:s,getByName:d,listStore:i}});function ae(t){return S.invoke(oe,t)}const ce=(t,e)=>{e.register(t.name,t)},ue=6e3,le=b.createStorageKey("last_ping","global"),de=async t=>{try{const e=Date.now(),r=b.localStore.get(le);let s=0;if(r.isSet()&&(s=r.json()??0),s&&e-s<ue)return!0;const i={projectId:t.projectId,path:window.location.pathname},d={},n=document.getElementById("picked_script")?.dataset.verceltoken;n&&(d["x-vercel-protection-bypass"]=n);const u=(await H.post(t.apiUrl,"ping",i,d)).ok;return u&&r.set(e),u}catch(e){return x.logger("error",e),!1}};function V(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 pe=g.createDomain("predicate"),fe=S.createFactory(({client:t})=>{const e=pe.store({}),r=g.createApi(e,{register(n,p){return{...n,[p.name]:{name:p.name,predicate:p.predicate}}}});function s(n,p){e.getState()[n]&&x.logger("warn",`Predicate '${n}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:n,predicate:p}))}const i=e.map(n=>Object.values(n));function d(n){return e.map(p=>p[n]?.predicate,{skipVoid:!1})}function a(n){const p=g.createStore(()=>{},{skipVoid:!1}),u=g.createEffect(async()=>{const m=d(n).getState();if(!m)return;const w=V(t);return(...y)=>m({...w,args:y})});return g.sample({source:{responses:t.responses.listStore,fields:t.fields.listStore},target:u}),g.sample({clock:u.doneData,filter:m=>m!==void 0,target:p}),u(),p}return{register:s,getByName:d,listStore:i,getEvokablePredicate:a}});function ge(t){return S.invoke(fe,t)}const me=(t,e,r)=>{r.register(t,e)},B=g.createDomain("feature"),ye=S.createFactory(({client:t})=>{const e=B.store({}),r=B.store([]),s=g.createApi(e,{register(o,c){return{...o,[c.id]:c.feature}}});function i(o,c){e.getState()[o]&&x.logger("warn",`Feature '${o}' already registered. Registering again will override the previous registration.`);const l={id:o,feature:{...c,id:o}};s.register(Object.freeze({id:o,feature:l}))}const d=g.createEffect(async({id:o,key:c,storage:f="local"})=>{const l=b.createStorageKey(`feature:${o}:${c}`,"global"),v=(f==="session"?b.sessionStore:b.localStore).get(l).boolean();return v===null?null:{id:o,key:c,bucket:v,storage:f}}),a=g.createEffect(o=>{if(!o)return null;const c=b.createStorageKey(`feature:${o.id}:${o.key}`,"global");(o.storage==="session"?b.sessionStore:b.localStore).set(c,o.bucket)}),n=new Map,p=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:o,resolvedFeaturesStore:c},{id:f,decide:l,key:h})=>{const v=c.find(P=>P.id===f&&P.key===h);if(v)return v;const E=o[f];if(!E)throw new Error(`Feature with id '${f}' not found`);const A=n.get(`${f}:${h}`);if(A!==void 0){const P=await A;return{id:E.id,bucket:P,key:h,storage:E.feature.storage}}const F=l();n.set(`${f}:${h}`,F);const q=await F;return{id:E.id,bucket:q,key:h,storage:E.feature.storage}}});g.sample({clock:s.register,fn:o=>{const{id:c,feature:f}=o;return{id:c,key:f.feature.key,storage:f.feature.storage}},target:d}),g.sample({source:e,clock:p.doneData,fn:(o,c)=>{const{id:f,bucket:l,storage:h}=c,v=o[f]?.feature.key;return v?{key:v,id:f,bucket:l,storage:h}:null},target:a});const u=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:o,resolvedFeaturesStore:c})=>Object.values(o).map(f=>{const l=c.find(h=>h.id===f.id&&h.key===f.feature.key);return l?{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:()=>({id:f.id,bucket:l.bucket}),isResolved:!0}:{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:async()=>await p(f.feature),isResolved:!1}}));g.sample({clock:p.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:o},{id:c,key:f})=>!o.some(h=>h.id===c&&h.key===f),fn:(o,c)=>c,target:t.eventBus.prepend(o=>({type:"feature_decide",feature:o}))}),g.sample({clock:[d.doneData,p.doneData],source:r,fn:(o,c)=>!c||o.some(l=>l.id===c.id&&l.key===c.key)?o:[...o,c],target:r});function m(o){return u.map(c=>c.find(f=>f.id===o))}function w(o){return e.map(c=>c[o],{skipVoid:!1})}function y(o){const c=g.createStore(async()=>{},{skipVoid:!1}),f=g.createEffect(async()=>{const l=m(o).getState();if(l)return async()=>(await l.getBucket()).bucket});return g.sample({source:r,filter:l=>l.some(h=>h.id===o),target:f}),g.sample({clock:f.doneData,filter:l=>l!==void 0,target:c}),f(),c}return{register:i,getById:m,getByName:w,listStore:u,getEvokableFeature:y}});function he(t){return S.invoke(ye,t)}const Se=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function O(t,e){return{id:K.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ve=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),s=j.event(),i=j.event();t.on(e,(a,n)=>({entries:[...a.entries,O(n.experienceId,n.node)]})),t.on(r,(a,n)=>({entries:[...a.entries.slice(0,-1),O(n.experienceId,n.node)]})),t.on(i,(a,n)=>n);function d(a,n){const p={lastStepIndex:-1,secondLastStepIndex:-1};for(let u=a.length-1;u>=0;u--){const m=a[u],w=m?.node;if(!(!w||!I.isStepNode(w))&&!(n&&m?.experienceId!==n))if(p.lastStepIndex===-1)p.lastStepIndex=u;else{p.secondLastStepIndex=u;break}}return p}return t.on(s,(a,n)=>{const{secondLastStepIndex:p}=d(a.entries,n.experienceId),u=p!==-1?a.entries.slice(0,p+1):a.entries;return{...a,entries:u}}),{push:e,replace:r,back:s,restore:i,entriesStore:t.map(a=>a.entries)}});function ke(){return S.invoke(ve)}let we=0;const be=t=>{const e=g.createStore([]);return g.sample({clock:t,source:e,fn:(r,s)=>[...r,{id:we++,at:new Date,payload:s}],target:e}),e},Ie=g.createDomain("field"),Fe=S.createFactory(()=>{const t=Ie.store({}),e=g.createApi(t,{register(n,p){return{...n,[p.field.id]:p.field}}});function r(n){e.register({field:n})}function s(n,p){const u=d(n).getState();if(!u)return;const m=Object.assign({},u,{...p});e.register({field:{...m}})}const i=t.map(n=>Object.values(n));function d(n){return t.map(p=>p[n]||null)}function a(n){return t.map(p=>Object.values(p).find(u=>u.name===n)||null)}return{register:r,update:s,getById:d,listStore:i,getByName:a}});function xe(){return S.invoke(Fe)}const Ee=(t,e)=>{e.register(t)},je=g.createDomain("action"),Ae=S.createFactory(()=>{const t=je.store({}),e=g.createApi(t,{register(a,n){return{...a,[n.name]:{name:n.name,action:n.action}}}});function r(a,n){e.register({name:a,action:n})}const s=t.map(a=>Object.values(a));function i(a){return t.map(n=>n[a],{skipVoid:!1})}function d(a){return t.map(n=>{const p=n[a];return p?p.action:void 0},{skipVoid:!1})}return{register:r,getByName:i,listStore:s,getEvokableAction:d}});function Pe(){return S.invoke(Ae)}const Re=(t,e,r)=>{r.register(t,e)};function $(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}function $e(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null}function M(t){try{return JSON.stringify(t),!0}catch{return!1}}const Ce=g.createDomain("response"),ze=S.createFactory(({client:t})=>{const e=Ce.store({}),r=g.createEvent(),s=g.createEvent(),i=g.createApi(e,{register(y,o){return{...y,[o.fieldId]:o.response}},registerBatch(y,o){return{...y,...o}},clear(y,o){const{[o]:c,...f}=y;return f},clearAll(){return{}}});function d(y,o){if(typeof y=="string"){if(o===void 0)throw new Error("Response is required when registering a single field");i.register({fieldId:y,response:o})}else i.registerBatch(y)}async function a(y){const o=[];return await Promise.allSettled(Object.entries(y).map(async([c,f])=>{let l=f;const h=t.fields.getById(c).getState();if(!h){o.push({fieldId:c,userMessage:`Field '${c}' not found`,systemMessage:`No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:l});return}if(h.multiple&&(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&(l=[l]),h.validation&&!G.isEmpty(h.validation)&&!$(l)){const v=await I.evaluateRuleLogic(t,h.validation,{$input:l});if(typeof v=="string"){o.push({fieldId:c,userMessage:v,systemMessage:`Field validation resulted in an error: ${v}.`,value:l});return}if(v===!1){o.push({fieldId:c,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:l});return}}if(h.required&&$(l)){o.push({fieldId:c,userMessage:"This field is required",systemMessage:"Field is required.",value:l});return}if(!h.multiple&&Array.isArray(l)&&l.length>1){o.push({fieldId:c,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:l});return}if(h.type==="object"&&!$(l))if(h.multiple){if(!Array.isArray(l)){o.push({fieldId:c,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:l});return}for(const v of l){if(typeof v!="object"||v===null){o.push({fieldId:c,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:l});return}if(!M(v)){o.push({fieldId:c,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:l});return}}}else{if(Array.isArray(l)){o.push({fieldId:c,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:l});return}if(typeof l!="object"||l===null){o.push({fieldId:c,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:l});return}if(!M(l)){o.push({fieldId:c,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:l});return}}if(Array.isArray(h.options)&&h.options.length>0){const v=Array.isArray(l)?l:[l];if(h.type==="object"){const E=h.options.map(F=>JSON.stringify(F.value));v.every(F=>E.includes(JSON.stringify(F)))||o.push({fieldId:c,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:l})}else{const E=h.options.map(F=>F.value);v.every(F=>!$e(F)||F===null?!1:E.includes(F))||o.push({fieldId:c,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${E.join(", ")}`,value:l})}}})),{responsesToCommit:y,validationErrors:o}}async function n(y){const{responsesToCommit:o,validationErrors:c}=await a(y);return c.length?{errors:c}:(i.registerBatch(o),{errors:[]})}const p=e.map(y=>y),u=e.map(y=>Object.keys(y).map(c=>({fieldId:c,value:y[c]})));function m(y){const o=t.fields.getById(y),c=e.map(f=>f[y]||null);return g.combine({f:o,r:c},({f,r:l})=>l||(f?.defaultValue?f.defaultValue:null))}function w(y){const o=t.fields.getByName(y);return g.combine({f:o,s:e},({f:c,s:f})=>{const l=c&&f[c.id]||null;return l||(c?.defaultValue?c.defaultValue:null)})}return g.sample({clock:r,target:i.clearAll}),g.sample({clock:s,target:i.clear}),{register:d,clearAll:r,clear:s,commit:n,getResponsesToCommit:a,listStore:u,getAllStore:p,getByFieldId:m,getByFieldName:w}});function De(t){return S.invoke(ze,t)}const Be=()=>"0.0.1-dev.1772162264282";function Oe(){if(k.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?.dataset.api)return e.dataset.api}return"https://api.picked.app"}function Me(){if(!k.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 d=i.replace("picked-","");e[d]=t.getAll(i)}const s=b.createStorageKey("s");if(r.size>0)b.sessionStore.set(s,e);else{const i=b.sessionStore.get(s);if(i)return i.json()||{}}return e}function Ue(){if(k.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),s=Math.random().toString(36).substring(2,15);return`${t}-${e}-${r}-${s}`}const Le=b.createStorageKey("session","global"),Ve=()=>{const t=b.localStore.get(Le);let e;t.isSet()&&(e=t.json());const r=i=>t.set({id:i.id,isUser:i.isUser,identifiers:i.identifiers}),s={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(i){this.isUser=i,r(this)},setIdentifier(i,d){this.identifiers={...this.identifiers,[i]:d},r(this)},removeIdentifier(i){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([d])=>d!==i)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(s),s},Te=()=>k.supportsLocalStorage()?Ve():null;function T(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Ne(){if(!k.supportsWindow())return;const t=T(),e=t?.organizationId,r=t?.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function _e(){if(!k.supportsDocument())return;const t=document.getElementById("picked_script")||document.querySelector("script#picked")||document.getElementById("cvly");if(!t)return;const e=t.dataset.organizationid||t.getAttribute("organization-id"),r=t.dataset.projectid||t.getAttribute("project-id");return e&&r?{organizationId:e,projectId:r}:void 0}function qe(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const s=Ne();if(s)return s;const i=_e();if(i)return i;throw new Error(`organizationId and projectId are required. You can provide them via one of:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("effector"),S=require("@withease/factories"),I=require("../experience-instance-BsXG5XJ4.cjs"),x=require("../logger-BsmHUUw1.cjs"),w=require("../storage-Be5xWNPC.cjs"),H=require("../api-DzSCgBQ2.cjs"),K=require("../id-BKIWbSTy.cjs"),G=require("../object-BbFTsGh3.cjs"),k=require("../supports-YvpQZxbh.cjs"),U=g.createDomain("experience"),W=S.createFactory(({client:t,experience:e})=>{const r=U.store(e),s=g.createApi(r,{merge(u,m){return{...u,...m.experience}}}),i=r.map(u=>({name:u.name,decisionLogic:u.condition??u.decide,targetSelectors:u.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(u=>u.find(m=>m.name===`experience:${e.id}`)||u.find(m=>m.name==="experience"),{skipVoid:!1}),a=r.map(u=>({steps:u.steps,nodes:u.nodes,edges:u.edges,conditionals:u.conditionals})),n=r.map(u=>u.fields),p=e.actions??[];return{id:e.id,configStore:i,treeStore:a,fieldsStore:n,componentStore:d,actions:p,merge:s.merge}});function J(t){return S.invoke(W,t)}const Y=S.createFactory(({client:t})=>{const e=U.store({}),r=g.createApi(e,{register(u,m){return{...u,[m.id]:m}}});function s(u){const m=e.getState()[u.id];if(m){m.merge({experience:u,strategy:"override"});return}const b=J({client:t,experience:u});r.register(b)}const i=e.map(u=>Object.values(u));function d(u){return e.map(m=>m[u],{skipVoid:!1})}const a=d,n=g.attach({source:e,effect:async(u,{id:m,options:b})=>{const y=u[m];if(!y){x.logger("warn",`Experience with id '${m}' not found.`);return}if(b?.bypassCondition){C(t,y,b);return}await L(t,y)&&C(t,y,b)}}),p=g.attach({source:t.experienceInstances.listStore,effect:(u,{id:m,options:b})=>{const y=u.filter(o=>o.experienceId===m);if(y.length>0)for(const o of y)o.open();else n({id:m,options:{...b,initialiseOpen:!0}})}});return{register:s,get:d,getById:a,launch:n,open:p,listStore:i}});function Q(t){return S.invoke(Y,t)}const X=(t,e)=>{e.register(t)},C=(t,e,r)=>{const{targetSelectors:s}=e.configStore.getState(),i=I.getTargetElements(s,e.id);i.forEach(({elements:a})=>a.forEach(n=>I.tagTargetElement(n,e.id))),I.createAppHosts(i,e.id).forEach(a=>{r?t.experienceInstances.spawn(e,a,r):t.experienceInstances.spawn(e,a)})},z=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await L(t,e)&&C(t,e)}))},L=async(t,e)=>{if(!t.session?.isUser)return!1;const{decisionLogic:r,targetSelectors:s}=e.configStore.getState();return I.getTargetElements(s,e.id).length<1||s.length===0?!1:r&&I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},Z=(t,e,r)=>{const s=e.name,i=e.setup(t);if(i){const d=r[s]??{};r[s]=Object.freeze({...d,...i})}},ee=g.createDomain("component"),te=S.createFactory(({client:t,component:e,name:r})=>{const s=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:s}});function re(t){return S.invoke(te,t)}const se=S.createFactory(({client:t})=>{const e=ee.store({}),r=g.createApi(e,{register(a,n){return{...a,[n.name]:n}}});function s(a,n){e.getState()[a]&&x.logger("warn",`Component '${a}' already registered. Registering again will override the previous registration.`);const u=re({client:t,name:a,component:n});r.register(u)}const i=e.map(a=>Object.values(a));function d(a){return e.map(n=>n[a],{skipVoid:!1})}return{register:s,getByName:d,listStore:i}});function ne(t){return S.invoke(se,t)}const D=(t,e,r)=>{r.register(t,e)},ie=g.createDomain("framework"),oe=S.createFactory(({client:t})=>{const e=ie.store({}),r=g.createApi(e,{register(a,n){return{...a,[n.name]:n.framework}}});function s(a,n){e.getState()[a]&&x.logger("warn",`Framework '${a}' already registered. Registering again will override the previous registration.`),r.register({name:a,framework:n})}const i=e.map(a=>Object.values(a));function d(a){return e.map(n=>n[a],{skipVoid:!1})}return{register:s,getByName:d,listStore:i}});function ae(t){return S.invoke(oe,t)}const ce=(t,e)=>{e.register(t.name,t)},ue=6e3,le=w.createStorageKey("last_ping","global"),de=async t=>{try{const e=Date.now(),r=w.localStore.get(le);let s=0;if(r.isSet()&&(s=r.json()??0),s&&e-s<ue)return!0;const i={projectId:t.projectId,path:window.location.pathname},d={},n=document.getElementById("picked_script")?.dataset.verceltoken;n&&(d["x-vercel-protection-bypass"]=n);const u=(await H.post(t.apiUrl,"ping",i,d)).ok;return u&&r.set(e),u}catch(e){return x.logger("error",e),!1}};function V(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 pe=g.createDomain("predicate"),fe=S.createFactory(({client:t})=>{const e=pe.store({}),r=g.createApi(e,{register(n,p){return{...n,[p.name]:{name:p.name,predicate:p.predicate}}}});function s(n,p){e.getState()[n]&&x.logger("warn",`Predicate '${n}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:n,predicate:p}))}const i=e.map(n=>Object.values(n));function d(n){return e.map(p=>p[n]?.predicate,{skipVoid:!1})}function a(n){const p=g.createStore(()=>{},{skipVoid:!1}),u=g.createEffect(async()=>{const m=d(n).getState();if(!m)return;const b=V(t);return(...y)=>m({...b,args:y})});return g.sample({source:{responses:t.responses.listStore,fields:t.fields.listStore},target:u}),g.sample({clock:u.doneData,filter:m=>m!==void 0,target:p}),u(),p}return{register:s,getByName:d,listStore:i,getEvokablePredicate:a}});function ge(t){return S.invoke(fe,t)}const me=(t,e,r)=>{r.register(t,e)},B=g.createDomain("feature"),ye=S.createFactory(({client:t})=>{const e=B.store({}),r=B.store([]),s=g.createApi(e,{register(o,c){return{...o,[c.id]:c.feature}}});function i(o,c){e.getState()[o]&&x.logger("warn",`Feature '${o}' already registered. Registering again will override the previous registration.`);const l={id:o,feature:{...c,id:o}};s.register(Object.freeze({id:o,feature:l}))}const d=g.createEffect(async({id:o,key:c,storage:f="local"})=>{const l=w.createStorageKey(`feature:${o}:${c}`,"global"),v=(f==="session"?w.sessionStore:w.localStore).get(l).boolean();return v===null?null:{id:o,key:c,bucket:v,storage:f}}),a=g.createEffect(o=>{if(!o)return null;const c=w.createStorageKey(`feature:${o.id}:${o.key}`,"global");(o.storage==="session"?w.sessionStore:w.localStore).set(c,o.bucket)}),n=new Map,p=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:o,resolvedFeaturesStore:c},{id:f,decide:l,key:h})=>{const v=c.find(P=>P.id===f&&P.key===h);if(v)return v;const E=o[f];if(!E)throw new Error(`Feature with id '${f}' not found`);const A=n.get(`${f}:${h}`);if(A!==void 0){const P=await A;return{id:E.id,bucket:P,key:h,storage:E.feature.storage}}const F=l();n.set(`${f}:${h}`,F);const q=await F;return{id:E.id,bucket:q,key:h,storage:E.feature.storage}}});g.sample({clock:s.register,fn:o=>{const{id:c,feature:f}=o;return{id:c,key:f.feature.key,storage:f.feature.storage}},target:d}),g.sample({source:e,clock:p.doneData,fn:(o,c)=>{const{id:f,bucket:l,storage:h}=c,v=o[f]?.feature.key;return v?{key:v,id:f,bucket:l,storage:h}:null},target:a});const u=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:o,resolvedFeaturesStore:c})=>Object.values(o).map(f=>{const l=c.find(h=>h.id===f.id&&h.key===f.feature.key);return l?{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:()=>({id:f.id,bucket:l.bucket}),isResolved:!0}:{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:async()=>await p(f.feature),isResolved:!1}}));g.sample({clock:p.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:o},{id:c,key:f})=>!o.some(h=>h.id===c&&h.key===f),fn:(o,c)=>c,target:t.eventBus.prepend(o=>({type:"feature_decide",feature:o}))}),g.sample({clock:[d.doneData,p.doneData],source:r,fn:(o,c)=>!c||o.some(l=>l.id===c.id&&l.key===c.key)?o:[...o,c],target:r});function m(o){return u.map(c=>c.find(f=>f.id===o))}function b(o){return e.map(c=>c[o],{skipVoid:!1})}function y(o){const c=g.createStore(async()=>{},{skipVoid:!1}),f=g.createEffect(async()=>{const l=m(o).getState();if(l)return async()=>(await l.getBucket()).bucket});return g.sample({source:r,filter:l=>l.some(h=>h.id===o),target:f}),g.sample({clock:f.doneData,filter:l=>l!==void 0,target:c}),f(),c}return{register:i,getById:m,getByName:b,listStore:u,getEvokableFeature:y}});function he(t){return S.invoke(ye,t)}const Se=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function O(t,e){return{id:K.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ve=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),s=j.event(),i=j.event();t.on(e,(a,n)=>({entries:[...a.entries,O(n.experienceId,n.node)]})),t.on(r,(a,n)=>({entries:[...a.entries.slice(0,-1),O(n.experienceId,n.node)]})),t.on(i,(a,n)=>n);function d(a,n){const p={lastStepIndex:-1,secondLastStepIndex:-1};for(let u=a.length-1;u>=0;u--){const m=a[u],b=m?.node;if(!(!b||!I.isStepNode(b))&&!(n&&m?.experienceId!==n))if(p.lastStepIndex===-1)p.lastStepIndex=u;else{p.secondLastStepIndex=u;break}}return p}return t.on(s,(a,n)=>{const{secondLastStepIndex:p}=d(a.entries,n.experienceId),u=p!==-1?a.entries.slice(0,p+1):a.entries;return{...a,entries:u}}),{push:e,replace:r,back:s,restore:i,entriesStore:t.map(a=>a.entries)}});function ke(){return S.invoke(ve)}let we=0;const be=t=>{const e=g.createStore([]);return g.sample({clock:t,source:e,fn:(r,s)=>[...r,{id:we++,at:new Date,payload:s}],target:e}),e},Ie=g.createDomain("field"),Fe=S.createFactory(()=>{const t=Ie.store({}),e=g.createApi(t,{register(n,p){return{...n,[p.field.id]:p.field}}});function r(n){e.register({field:n})}function s(n,p){const u=d(n).getState();if(!u)return;const m=Object.assign({},u,{...p});e.register({field:{...m}})}const i=t.map(n=>Object.values(n));function d(n){return t.map(p=>p[n]||null)}function a(n){return t.map(p=>Object.values(p).find(u=>u.name===n)||null)}return{register:r,update:s,getById:d,listStore:i,getByName:a}});function xe(){return S.invoke(Fe)}const Ee=(t,e)=>{e.register(t)},je=g.createDomain("action"),Ae=S.createFactory(()=>{const t=je.store({}),e=g.createApi(t,{register(a,n){return{...a,[n.name]:{name:n.name,action:n.action}}}});function r(a,n){e.register({name:a,action:n})}const s=t.map(a=>Object.values(a));function i(a){return t.map(n=>n[a],{skipVoid:!1})}function d(a){return t.map(n=>{const p=n[a];return p?p.action:void 0},{skipVoid:!1})}return{register:r,getByName:i,listStore:s,getEvokableAction:d}});function Pe(){return S.invoke(Ae)}const Re=(t,e,r)=>{r.register(t,e)};function $(t){return typeof t>"u"||t===null||t===""||Array.isArray(t)&&!t.length}function $e(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null}function M(t){try{return JSON.stringify(t),!0}catch{return!1}}const Ce=g.createDomain("response"),ze=S.createFactory(({client:t})=>{const e=Ce.store({}),r=g.createEvent(),s=g.createEvent(),i=g.createApi(e,{register(y,o){return{...y,[o.fieldId]:o.response}},registerBatch(y,o){return{...y,...o}},clear(y,o){const{[o]:c,...f}=y;return f},clearAll(){return{}}});function d(y,o){if(typeof y=="string"){if(o===void 0)throw new Error("Response is required when registering a single field");i.register({fieldId:y,response:o})}else i.registerBatch(y)}async function a(y){const o=[];return await Promise.allSettled(Object.entries(y).map(async([c,f])=>{let l=f;const h=t.fields.getById(c).getState();if(!h){o.push({fieldId:c,userMessage:`Field '${c}' not found`,systemMessage:`No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:l});return}if(h.multiple&&(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&(l=[l]),h.validation&&!G.isEmpty(h.validation)&&!$(l)){const v=await I.evaluateRuleLogic(t,h.validation,{$input:l});if(typeof v=="string"){o.push({fieldId:c,userMessage:v,systemMessage:`Field validation resulted in an error: ${v}.`,value:l});return}if(v===!1){o.push({fieldId:c,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:l});return}}if(h.required&&$(l)){o.push({fieldId:c,userMessage:"This field is required",systemMessage:"Field is required.",value:l});return}if(!h.multiple&&Array.isArray(l)&&l.length>1){o.push({fieldId:c,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:l});return}if(h.type==="object"&&!$(l))if(h.multiple){if(!Array.isArray(l)){o.push({fieldId:c,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:l});return}for(const v of l){if(typeof v!="object"||v===null){o.push({fieldId:c,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:l});return}if(!M(v)){o.push({fieldId:c,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:l});return}}}else{if(Array.isArray(l)){o.push({fieldId:c,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:l});return}if(typeof l!="object"||l===null){o.push({fieldId:c,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:l});return}if(!M(l)){o.push({fieldId:c,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:l});return}}if(Array.isArray(h.options)&&h.options.length>0){const v=Array.isArray(l)?l:[l];if(h.type==="object"){const E=h.options.map(F=>JSON.stringify(F.value));v.every(F=>E.includes(JSON.stringify(F)))||o.push({fieldId:c,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:l})}else{const E=h.options.map(F=>F.value);v.every(F=>!$e(F)||F===null?!1:E.includes(F))||o.push({fieldId:c,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${E.join(", ")}`,value:l})}}})),{responsesToCommit:y,validationErrors:o}}async function n(y){const{responsesToCommit:o,validationErrors:c}=await a(y);return c.length?{errors:c}:(i.registerBatch(o),{errors:[]})}const p=e.map(y=>y),u=e.map(y=>Object.keys(y).map(c=>({fieldId:c,value:y[c]})));function m(y){const o=t.fields.getById(y),c=e.map(f=>f[y]||null);return g.combine({f:o,r:c},({f,r:l})=>l||(f?.defaultValue?f.defaultValue:null))}function b(y){const o=t.fields.getByName(y);return g.combine({f:o,s:e},({f:c,s:f})=>{const l=c&&f[c.id]||null;return l||(c?.defaultValue?c.defaultValue:null)})}return g.sample({clock:r,target:i.clearAll}),g.sample({clock:s,target:i.clear}),{register:d,clearAll:r,clear:s,commit:n,getResponsesToCommit:a,listStore:u,getAllStore:p,getByFieldId:m,getByFieldName:b}});function De(t){return S.invoke(ze,t)}const Be=()=>"0.0.1-dev.1772165084341";function Oe(){if(k.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?.dataset.api)return e.dataset.api}return"https://api.picked.app"}function Me(){if(!k.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 d=i.replace("picked-","");e[d]=t.getAll(i)}const s=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(s,e);else{const i=w.sessionStore.get(s);if(i)return i.json()||{}}return e}function Ue(){if(k.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),s=Math.random().toString(36).substring(2,15);return`${t}-${e}-${r}-${s}`}const Le=w.createStorageKey("session","global"),Ve=()=>{const t=w.localStore.get(Le);let e;t.isSet()&&(e=t.json());const r=i=>t.set({id:i.id,isUser:i.isUser,identifiers:i.identifiers}),s={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(i){this.isUser=i,r(this)},setIdentifier(i,d){this.identifiers={...this.identifiers,[i]:d},r(this)},removeIdentifier(i){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([d])=>d!==i)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(s),s},Te=()=>k.supportsLocalStorage()?Ve():null;function T(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Ne(){if(!k.supportsWindow())return;const t=T(),e=t?.organizationId,r=t?.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function _e(){if(!k.supportsDocument())return;const t=document.getElementById("picked_script")||document.querySelector("script#picked")||document.getElementById("cvly");if(!t)return;const e=t.dataset.organizationid||t.getAttribute("organization-id"),r=t.dataset.projectid||t.getAttribute("project-id");return e&&r?{organizationId:e,projectId:r}:void 0}function qe(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const s=Ne();if(s)return s;const i=_e();if(i)return i;throw new Error(`organizationId and projectId are required. You can provide them via one of:
|
|
2
2
|
(1) createClient({ organizationId, projectId }) options;
|
|
3
3
|
(2) window.pickedConfig = { organizationId, projectId };
|
|
4
|
-
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`)}function R(t){return t==null||t===""||Number.isNaN(t)}const He={default:(t,e)=>R(t)?String(e??""):String(t),append:(t,e)=>e&&!R(t)?`${t} ${e}`:t,prepend:(t,e)=>e&&!R(t)?`${e} ${t}`:t,upper:t=>typeof t=="string"?t.toUpperCase():t,lower:t=>typeof t=="string"?t.toLowerCase():t,capitalize:t=>typeof t=="string"?t.charAt(0).toUpperCase()+t.slice(1):t,list:t=>{if(!t||typeof t!="object")return t;const e=new Intl.ListFormat("en",{style:"long",type:"conjunction"});if(Array.isArray(t))return e.format(t.map(String));if(t instanceof Map){const r=Array.from(t.entries()).map(([s,i])=>`${s}: ${i}`);return e.format(r)}return t instanceof Set?e.format(Array.from(t).map(String)):t}};function Ke(t){return typeof t=="object"&&t!==null}function Ge(t,e){let r=e;for(const s of t.split("."))if(Ke(r)&&s in r)r=r[s];else return;return typeof r=="function"?r():r}function We(t,e){const r=t.split("|").map(d=>d.trim()),s=r.shift()??"";let i=Ge(s,e);for(const d of r){const[a,...n]=d.split(":"),p=a?.trim()??"",u=n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),m=He[p];m&&(i=m(i,u))}return R(i)?"":typeof i=="object"?JSON.stringify(i):String(i)}function Je(t,e){let r="",s=0;for(;s<t.length;)if(t[s]==="{"&&t[s+1]==="{"){s+=2;let i="";for(;s<t.length;){if(t[s]==="}"&&t[s+1]==="}"){s+=2;break}i+=t[s++]}r+=We(i.trim(),e)}else r+=t[s++];return r}class N{static logger=x.logger;options;isReady=!1;project;plugins={};pluginStartHooks=[];eventBus=g.createEvent();events;organizationId;projectId;apiUrl;dashboardUrl;documentationSiteUrl;session;precondition;condition;searchParams=Me();history=ke();components=ne({client:this});experienceInstances=I.createExperienceInstanceIndex({client:this});experiences=Q({client:this});frameworks=ae({client:this});predicates=ge({client:this});features=he({client:this});responses=De({client:this});fields=xe();actions=Pe();constructor(e){x.logger("info","Picked client initializing."),this.events=be(this.eventBus);const{organizationId:r,projectId:s}=qe(e);this.organizationId=r,this.projectId=s,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Oe(),this.dashboardUrl=e.dashboardUrl??"https://dashboard.picked.app",this.documentationSiteUrl=e.documentationSiteUrl??"https://docs.picked.app",this.session=Te(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:Be()}),x.logger("info","Picked client initialized.")}start=()=>{de(this),(async()=>{if(!k.supportsDocument())return;await this.runPluginStartHooks();const r=await this.evaluateGate(this.precondition);let s;r&&(s=await this.evaluateGate(this.condition));const i=r&&s===!0;if(typeof s=="boolean"&&this.session){const d=s;this.session.setIsUser(d),this.eventBus({type:"user_decide",value:d})}if(this.eventBus({type:"initialize"}),i&&z(this),await I.domInteractive(),i&&z(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session){const{id:d,isUser:a,identifiers:n}=this.session;this.eventBus({type:"session",id:d,isUser:a,identifiers:n})}})()};registerFramework=e=>{ce(e,this.frameworks)};registerComponent=(e,r)=>{D(e,r,this.components)};registerPlugin=e=>{Z(this,e,this.plugins);const r=this.plugins[e.name];r?.onStart&&this.pluginStartHooks.push(r.onStart)};registerFeature=(e,r)=>{Se(e,r,this.features)};registerPredicate=(e,r)=>{me(e,r,this.predicates)};registerField=e=>{Ee(e,this.fields)};registerAction=(e,r)=>{Re(e,r,this.actions)};registerExperience=e=>{e.component&&D(`experience:${e.id}`,e.component,this.components),X(e,this.experiences)};getStateSnapshot=()=>V(this);launchExperienceById=async(e,r)=>{this.experiences.launch({id:e,options:r})};openExperienceById=async e=>{this.experiences.open(e)};async runPluginStartHooks(){for(const e of this.pluginStartHooks)await e()}async evaluateGate(e){return e===void 0?!0:typeof e=="boolean"?e:await I.evaluateRuleLogic(this,e)===!0}setupPlugins(){this.options.plugins?.forEach(e=>{if(Array.isArray(e)){e.forEach(s=>{this.registerPlugin(s)});return}const r=typeof e=="function"?e():e;if(Array.isArray(r)){r.forEach(s=>this.registerPlugin(s));return}this.registerPlugin(r)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,s])=>{const i=typeof s=="function"?s():s;this.registerFeature(r,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[s,i]=r.split(":");if(!s||!i)return;let d=i;d==="true"&&(d=!0),d==="false"&&(d=!1),this.registerFeature(s,{key:`${d}`,name:s,decide:()=>d,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,s])=>{if(typeof s!="function"){x.logger("warn",`Predicate "${r}" is not a function.`);return}this.registerPredicate(r,s)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([r,s])=>{if(typeof s!="function"){x.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,s)})}getPluginConfig=e=>this.plugins[e]??{};renderString=(e,r)=>{const s=this.responses.listStore.getState().reduce((i,d)=>(i[d.fieldId]=d.value,i),{});return Je(e,{...r,responses:s})}}function _(t){return t.options?.some(e=>"condition"in e)??!1}function Ye(t){return t.some(e=>e.condition||_(e))}async function Qe(t,e){return e.length===0||!Ye(e)?e:(await Promise.all(e.map(async s=>{if(!(s.condition?await I.evaluateRuleLogic(t,s.condition):!0))return null;if(!s.options||!_(s))return s;const a=(await Promise.all(s.options.map(async p=>p.condition?await I.evaluateRuleLogic(t,p.condition)?p:null:p))).filter(p=>p!==null);return a.length===s.options.length?s:a.length===0?null:{...s,options:a}}))).filter(s=>s!==null)}function Xe(t){return{$$type:"lazy-component",load:t}}function Ze(t){return typeof t=="object"&&t!==null&&"$$type"in t&&t.$$type==="lazy-component"}const et=t=>{const e=new N(t);return k.bindClient(e),e};exports.evaluateRuleLogic=I.evaluateRuleLogic;exports.isPickedRoot=I.isPickedRoot;exports.createStorageKey=
|
|
4
|
+
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`)}function R(t){return t==null||t===""||Number.isNaN(t)}const He={default:(t,e)=>R(t)?String(e??""):String(t),append:(t,e)=>e&&!R(t)?`${t} ${e}`:t,prepend:(t,e)=>e&&!R(t)?`${e} ${t}`:t,upper:t=>typeof t=="string"?t.toUpperCase():t,lower:t=>typeof t=="string"?t.toLowerCase():t,capitalize:t=>typeof t=="string"?t.charAt(0).toUpperCase()+t.slice(1):t,list:t=>{if(!t||typeof t!="object")return t;const e=new Intl.ListFormat("en",{style:"long",type:"conjunction"});if(Array.isArray(t))return e.format(t.map(String));if(t instanceof Map){const r=Array.from(t.entries()).map(([s,i])=>`${s}: ${i}`);return e.format(r)}return t instanceof Set?e.format(Array.from(t).map(String)):t}};function Ke(t){return typeof t=="object"&&t!==null}function Ge(t,e){let r=e;for(const s of t.split("."))if(Ke(r)&&s in r)r=r[s];else return;return typeof r=="function"?r():r}function We(t,e){const r=t.split("|").map(d=>d.trim()),s=r.shift()??"";let i=Ge(s,e);for(const d of r){const[a,...n]=d.split(":"),p=a?.trim()??"",u=n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),m=He[p];m&&(i=m(i,u))}return R(i)?"":typeof i=="object"?JSON.stringify(i):String(i)}function Je(t,e){let r="",s=0;for(;s<t.length;)if(t[s]==="{"&&t[s+1]==="{"){s+=2;let i="";for(;s<t.length;){if(t[s]==="}"&&t[s+1]==="}"){s+=2;break}i+=t[s++]}r+=We(i.trim(),e)}else r+=t[s++];return r}class N{static logger=x.logger;options;isReady=!1;project;plugins={};pluginStartHooks=[];eventBus=g.createEvent();events;organizationId;projectId;apiUrl;dashboardUrl;documentationSiteUrl;session;precondition;condition;searchParams=Me();history=ke();components=ne({client:this});experienceInstances=I.createExperienceInstanceIndex({client:this});experiences=Q({client:this});frameworks=ae({client:this});predicates=ge({client:this});features=he({client:this});responses=De({client:this});fields=xe();actions=Pe();constructor(e){x.logger("info","Picked client initializing."),this.events=be(this.eventBus);const{organizationId:r,projectId:s}=qe(e);this.organizationId=r,this.projectId=s,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Oe(),this.dashboardUrl=e.dashboardUrl??"https://dashboard.picked.app",this.documentationSiteUrl=e.documentationSiteUrl??"https://docs.picked.app",this.session=Te(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:Be()}),x.logger("info","Picked client initialized.")}start=()=>{de(this),(async()=>{if(!k.supportsDocument())return;await this.runPluginStartHooks();const r=await this.evaluateGate(this.precondition);let s;r&&(s=await this.evaluateGate(this.condition));const i=r&&s===!0;if(typeof s=="boolean"&&this.session){const d=s;this.session.setIsUser(d),this.eventBus({type:"user_decide",value:d})}if(this.eventBus({type:"initialize"}),i&&z(this),await I.domInteractive(),i&&z(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session){const{id:d,isUser:a,identifiers:n}=this.session;this.eventBus({type:"session",id:d,isUser:a,identifiers:n})}})()};registerFramework=e=>{ce(e,this.frameworks)};registerComponent=(e,r)=>{D(e,r,this.components)};registerPlugin=e=>{Z(this,e,this.plugins);const r=this.plugins[e.name];r?.onStart&&this.pluginStartHooks.push(r.onStart)};registerFeature=(e,r)=>{Se(e,r,this.features)};registerPredicate=(e,r)=>{me(e,r,this.predicates)};registerField=e=>{Ee(e,this.fields)};registerAction=(e,r)=>{Re(e,r,this.actions)};registerExperience=e=>{e.component&&D(`experience:${e.id}`,e.component,this.components),X(e,this.experiences)};getStateSnapshot=()=>V(this);launchExperienceById=async(e,r)=>{this.experiences.launch({id:e,options:r})};openExperienceById=async e=>{this.experiences.open({id:e})};async runPluginStartHooks(){for(const e of this.pluginStartHooks)await e()}async evaluateGate(e){return e===void 0?!0:typeof e=="boolean"?e:await I.evaluateRuleLogic(this,e)===!0}setupPlugins(){this.options.plugins?.forEach(e=>{if(Array.isArray(e)){e.forEach(s=>{this.registerPlugin(s)});return}const r=typeof e=="function"?e():e;if(Array.isArray(r)){r.forEach(s=>this.registerPlugin(s));return}this.registerPlugin(r)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([r,s])=>{const i=typeof s=="function"?s():s;this.registerFeature(r,i)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[s,i]=r.split(":");if(!s||!i)return;let d=i;d==="true"&&(d=!0),d==="false"&&(d=!1),this.registerFeature(s,{key:`${d}`,name:s,decide:()=>d,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,s])=>{if(typeof s!="function"){x.logger("warn",`Predicate "${r}" is not a function.`);return}this.registerPredicate(r,s)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([r,s])=>{if(typeof s!="function"){x.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,s)})}getPluginConfig=e=>this.plugins[e]??{};renderString=(e,r)=>{const s=this.responses.listStore.getState().reduce((i,d)=>(i[d.fieldId]=d.value,i),{});return Je(e,{...r,responses:s})}}function _(t){return t.options?.some(e=>"condition"in e)??!1}function Ye(t){return t.some(e=>e.condition||_(e))}async function Qe(t,e){return e.length===0||!Ye(e)?e:(await Promise.all(e.map(async s=>{if(!(s.condition?await I.evaluateRuleLogic(t,s.condition):!0))return null;if(!s.options||!_(s))return s;const a=(await Promise.all(s.options.map(async p=>p.condition?await I.evaluateRuleLogic(t,p.condition)?p:null:p))).filter(p=>p!==null);return a.length===s.options.length?s:a.length===0?null:{...s,options:a}}))).filter(s=>s!==null)}function Xe(t){return{$$type:"lazy-component",load:t}}function Ze(t){return typeof t=="object"&&t!==null&&"$$type"in t&&t.$$type==="lazy-component"}const et=t=>{const e=new N(t);return k.bindClient(e),e};exports.evaluateRuleLogic=I.evaluateRuleLogic;exports.isPickedRoot=I.isPickedRoot;exports.createStorageKey=w.createStorageKey;exports.localStore=w.localStore;exports.sessionStore=w.sessionStore;exports.subscribe=w.subscribe;exports.supportsCookies=k.supportsCookies;exports.supportsCryptoRandomUUID=k.supportsCryptoRandomUUID;exports.supportsDocument=k.supportsDocument;exports.supportsHistory=k.supportsHistory;exports.supportsIntersectionObserver=k.supportsIntersectionObserver;exports.supportsLocalStorage=k.supportsLocalStorage;exports.supportsLocation=k.supportsLocation;exports.supportsSessionStorage=k.supportsSessionStorage;exports.supportsShadowRoot=k.supportsShadowRoot;exports.supportsWebComponents=k.supportsWebComponents;exports.supportsWindow=k.supportsWindow;exports.Picked=N;exports.createClient=et;exports.getPickedConfig=T;exports.getStepFields=Qe;exports.isLazyLoader=Ze;exports.lazyComponent=Xe;
|
package/dist/esm/index.js
CHANGED
|
@@ -85,13 +85,13 @@ const me = b(({ client: t }) => {
|
|
|
85
85
|
}
|
|
86
86
|
}), p = U({
|
|
87
87
|
source: t.experienceInstances.listStore,
|
|
88
|
-
effect: (u, g) => {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
for (const
|
|
92
|
-
|
|
88
|
+
effect: (u, { id: g, options: S }) => {
|
|
89
|
+
const m = u.filter((o) => o.experienceId === g);
|
|
90
|
+
if (m.length > 0)
|
|
91
|
+
for (const o of m)
|
|
92
|
+
o.open();
|
|
93
93
|
else
|
|
94
|
-
n({ id: g, options: { initialiseOpen: !0 } });
|
|
94
|
+
n({ id: g, options: { ...S, initialiseOpen: !0 } });
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
return {
|
|
@@ -828,7 +828,7 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
|
828
828
|
function Ze(t) {
|
|
829
829
|
return I(Xe, t);
|
|
830
830
|
}
|
|
831
|
-
const et = () => "0.0.1-dev.
|
|
831
|
+
const et = () => "0.0.1-dev.1772165084341";
|
|
832
832
|
function tt() {
|
|
833
833
|
if (L()) {
|
|
834
834
|
const t = [
|
|
@@ -1078,9 +1078,9 @@ class ht {
|
|
|
1078
1078
|
launchExperienceById = async (e, r) => {
|
|
1079
1079
|
this.experiences.launch({ id: e, options: r });
|
|
1080
1080
|
};
|
|
1081
|
-
/** @deprecated Use `client.experiences.open(experienceId)` instead. */
|
|
1081
|
+
/** @deprecated Use `client.experiences.open({ id: experienceId })` instead. */
|
|
1082
1082
|
openExperienceById = async (e) => {
|
|
1083
|
-
this.experiences.open(e);
|
|
1083
|
+
this.experiences.open({ id: e });
|
|
1084
1084
|
};
|
|
1085
1085
|
async runPluginStartHooks() {
|
|
1086
1086
|
for (const e of this.pluginStartHooks)
|
|
@@ -41,6 +41,8 @@ export interface LaunchExperienceOptions {
|
|
|
41
41
|
/** When true, the experience's condition logic is skipped and it is launched unconditionally. */
|
|
42
42
|
bypassCondition?: boolean;
|
|
43
43
|
}
|
|
44
|
+
/** Options for opening an experience. Same as {@link LaunchExperienceOptions} without `initialiseOpen`. */
|
|
45
|
+
export type OpenExperienceOptions = Omit<LaunchExperienceOptions, 'initialiseOpen'>;
|
|
44
46
|
declare const createExperienceIndexFactory: ({ client }: {
|
|
45
47
|
client: Picked;
|
|
46
48
|
}) => {
|
|
@@ -106,7 +108,10 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
106
108
|
options?: LaunchExperienceOptions;
|
|
107
109
|
}, void, Error>;
|
|
108
110
|
/** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
|
|
109
|
-
open: import('effector').Effect<
|
|
111
|
+
open: import('effector').Effect<{
|
|
112
|
+
id: string;
|
|
113
|
+
options?: OpenExperienceOptions;
|
|
114
|
+
}, void, Error>;
|
|
110
115
|
/** Derived store containing all registered experiences as an array. */
|
|
111
116
|
listStore: import('effector').Store<{
|
|
112
117
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":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,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EACd,YAAY,eAAe,EAC3B,UAAU,uBAAuB,SAkBlC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,kBASzD,CAAA;AAsBD,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,EACd,YAAY,eAAe,KAC1B,OAAO,CAAC,OAAO,CA2BjB,CAAA"}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export { lazyComponent, isLazyLoader } from './entities/component/lazyComponent'
|
|
|
15
15
|
* @returns The initialized Picked client instance
|
|
16
16
|
*/
|
|
17
17
|
export declare const createClient: (options: CreateClientOptions) => Picked;
|
|
18
|
-
export type { LaunchExperienceOptions } from './entities/experience/experience';
|
|
18
|
+
export type { LaunchExperienceOptions, OpenExperienceOptions, } from './entities/experience/experience';
|
|
19
19
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,WAIxD,CAAA;AAED,YAAY,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,WAIxD,CAAA;AAED,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kCAAkC,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -121,7 +121,10 @@ export declare class Picked {
|
|
|
121
121
|
id: string;
|
|
122
122
|
options?: LaunchExperienceOptions;
|
|
123
123
|
}, void, Error>;
|
|
124
|
-
open: import('effector').Effect<
|
|
124
|
+
open: import('effector').Effect<{
|
|
125
|
+
id: string;
|
|
126
|
+
options?: import('./exports').OpenExperienceOptions;
|
|
127
|
+
}, void, Error>;
|
|
125
128
|
listStore: import('effector').Store<{
|
|
126
129
|
id: string;
|
|
127
130
|
configStore: import('effector').Store<{
|
|
@@ -223,7 +226,7 @@ export declare class Picked {
|
|
|
223
226
|
getStateSnapshot: () => StateSnapshot;
|
|
224
227
|
/** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
|
|
225
228
|
launchExperienceById: (experienceId: string, options?: LaunchExperienceOptions) => Promise<void>;
|
|
226
|
-
/** @deprecated Use `client.experiences.open(experienceId)` instead. */
|
|
229
|
+
/** @deprecated Use `client.experiences.open({ id: experienceId })` instead. */
|
|
227
230
|
openExperienceById: (experienceId: string) => Promise<void>;
|
|
228
231
|
private runPluginStartHooks;
|
|
229
232
|
private evaluateGate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAEf,KAAK,uBAAuB,EAE7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AAGvC,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAKzD,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAOtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK/C,qBAAa,MAAM;IACjB,MAAM,CAAC,QAAQ,CAAC,MAAM,0FAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,OAAO,UAAQ;IAEf,OAAO,CAAC,OAA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