@picked/client 0.0.1-dev.1773364848747 → 0.0.1-dev.1773365725739
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-CMwQlyo0.js → api-B3JRgxph.js} +1 -1
- package/dist/{api-DQC5OMTN.cjs → api-F0IOGUor.cjs} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugins/create-experience/index.js +72 -68
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const a="Picked-Client",d="Picked-Version";function s(e,t){return{[a]:e,[d]:t}}const o=()=>"0.0.1-dev.
|
|
1
|
+
"use strict";const a="Picked-Client",d="Picked-Version";function s(e,t){return{[a]:e,[d]:t}}const o=()=>"0.0.1-dev.1773365725739",E="v1";function c(e,t){return new URL(`/api/${E}/${t}`,e).toString()}function i(e){return{...s("sdk",o()),...e}}async function f(e,t,n){const r=c(e,t);return fetch(r,{headers:i(n)})}async function l(e,t,n,r){const u=c(e,t);return fetch(u,{method:"POST",headers:{"Content-Type":"application/json",...i(r)},body:JSON.stringify(n)})}exports.createClientHeaders=s;exports.get=f;exports.getVersion=o;exports.post=l;
|
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"),E=require("../logger-BsmHUUw1.cjs"),w=require("../storage-Be5xWNPC.cjs"),U=require("../api-DQC5OMTN.cjs"),H=require("../id-BKIWbSTy.cjs"),G=require("../object-BbFTsGh3.cjs"),W=require("../to-kebab-case-BsOQ8CON.cjs"),k=require("../supports-YvpQZxbh.cjs"),L=g.createDomain("experience"),J=S.createFactory(({client:t,experience:e})=>{const r=L.store(e),s=g.createApi(r,{merge(u,m){return{...u,...m.experience}}}),n=r.map(u=>({name:u.name,decisionLogic:u.condition,targetSelectors:u.targets,initializeOpenLogic:e.initializeOpen})),p=t.components.listStore.map(u=>(e.componentName?u.find(m=>m.name===e.componentName):void 0)||u.find(m=>m.name===`experience:${e.id}`)||u.find(m=>m.name==="experience"),{skipVoid:!1}),o=r.map(u=>({steps:u.steps,nodes:u.nodes,edges:u.edges,conditionals:u.conditionals})),c=r.map(u=>u.fields),a=e.actions??[];return{id:e.id,configStore:n,treeStore:o,fieldsStore:c,componentStore:p,actions:a,merge:s.merge}});function Y(t){return S.invoke(J,t)}const Q=S.createFactory(({client:t})=>{const e=L.store({}),r=g.createApi(e,{register(a,u){return{...a,[u.id]:u}}});function s(a){const u=e.getState()[a.id];if(u){u.merge({experience:a,strategy:"override"});return}const m=Y({client:t,experience:a});r.register(m)}const n=e.map(a=>Object.values(a));function p(a){return e.map(u=>u[a],{skipVoid:!1})}const o=g.attach({source:e,effect:async(a,{id:u,options:m})=>{const b=a[u];if(!b){E.logger("warn",`Experience with id '${u}' not found.`);return}if(m?.bypassCondition){$(t,b,m);return}await V(t,b)&&$(t,b,m)}}),c=g.attach({source:t.experienceInstances.listStore,effect:(a,{id:u,options:m})=>{const b=a.filter(y=>y.experienceId===u);if(b.length>0)for(const y of b)y.open();else o({id:u,options:{...m,initialiseOpen:!0}})}});return{register:s,get:p,getById:p,launch:o,open:c,listStore:n}});function X(t){return S.invoke(Q,t)}const Z=(t,e)=>{e.register(t)},$=(t,e,r)=>{const{targetSelectors:s}=e.configStore.getState(),n=I.getTargetElements(s,e.id);n.forEach(({elements:o})=>o.forEach(c=>I.tagTargetElement(c,e.id))),I.createAppHosts(n,e.id).forEach(o=>{r?t.experienceInstances.spawn(e,o,r):t.experienceInstances.spawn(e,o)})},z=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await V(t,e)&&$(t,e)}))},V=async(t,e)=>{if(!t.preconditionPassed||!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===void 0?!0:I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},ee=(t,e,r)=>{const s=e.name,n=e.setup(t);if(n){const p=r[s]??{};r[s]=Object.freeze({...p,...n})}},te=g.createDomain("component"),re=S.createFactory(({client:t,component:e,name:r})=>{const s=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:s}});function se(t){return S.invoke(re,t)}const ne=S.createFactory(({client:t})=>{const e=te.store({}),r=g.createApi(e,{register(o,c){return{...o,[c.name]:c}}});function s(o,c){e.getState()[o]&&E.logger("warn",`Component '${o}' already registered. Registering again will override the previous registration.`);const u=se({client:t,name:o,component:c});r.register(u)}const n=e.map(o=>Object.values(o));function p(o){return e.map(c=>c[o],{skipVoid:!1})}return{register:s,getByName:p,listStore:n}});function ie(t){return S.invoke(ne,t)}const B=(t,e,r)=>{r.register(t,e)},oe=g.createDomain("framework"),ae=S.createFactory(({client:t})=>{const e=oe.store({}),r=g.createApi(e,{register(o,c){return{...o,[c.name]:c.framework}}});function s(o,c){e.getState()[o]&&E.logger("warn",`Framework '${o}' already registered. Registering again will override the previous registration.`),r.register({name:o,framework:c})}const n=e.map(o=>Object.values(o));function p(o){return e.map(c=>c[o],{skipVoid:!1})}return{register:s,getByName:p,listStore:n}});function ce(t){return S.invoke(ae,t)}const ue=(t,e)=>{e.register(t.name,t)},le=6e3,de=w.createStorageKey("last_ping","global"),pe=async t=>{try{const e=Date.now(),r=w.localStore.get(de);let s=0;if(r.isSet()&&(s=r.json()??0),s&&e-s<le)return!0;const n={projectId:t.projectId,path:window.location.pathname},p={},c=document.getElementById("picked_script")?.dataset.verceltoken;c&&(p["x-vercel-protection-bypass"]=c);const u=(await U.post(t.apiUrl,"ping",n,p)).ok;return u&&r.set(e),u}catch(e){return E.logger("error",e),!1}};function N(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 fe=g.createDomain("predicate"),ge=S.createFactory(({client:t})=>{const e=fe.store({}),r=g.createApi(e,{register(c,a){return{...c,[a.name]:{name:a.name,predicate:a.predicate}}}});function s(c,a){e.getState()[c]&&E.logger("warn",`Predicate '${c}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:c,predicate:a}))}const n=e.map(c=>Object.values(c));function p(c){return e.map(a=>a[c]?.predicate,{skipVoid:!1})}function o(c){const a=g.createStore(()=>{},{skipVoid:!1}),u=g.createEffect(async()=>{const m=p(c).getState();if(!m)return;const b=N(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:a}),u(),a}return{register:s,getByName:p,listStore:n,getEvokablePredicate:o}});function me(t){return S.invoke(ge,t)}const ye=(t,e,r)=>{r.register(t,e)},D=g.createDomain("feature"),he=S.createFactory(({client:t})=>{const e=D.store({}),r=D.store([]),s=g.createApi(e,{register(i,l){return{...i,[l.id]:l.feature}}});function n(i,l){e.getState()[i]&&E.logger("warn",`Feature '${i}' already registered. Registering again will override the previous registration.`);const d={id:i,feature:{...l,id:i}};s.register(Object.freeze({id:i,feature:d}))}const p=g.createEffect(async({id:i,key:l,storage:f="local"})=>{const d=w.createStorageKey(`feature:${i}:${l}`,"global"),v=(f==="session"?w.sessionStore:w.localStore).get(d).boolean();return v===null?null:{id:i,key:l,bucket:v,storage:f}}),o=g.createEffect(i=>{if(!i)return null;const l=w.createStorageKey(`feature:${i.id}:${i.key}`,"global");(i.storage==="session"?w.sessionStore:w.localStore).set(l,i.bucket)}),c=new Map,a=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:i,resolvedFeaturesStore:l},{id:f,decide:d,key:h})=>{const v=l.find(P=>P.id===f&&P.key===h);if(v)return v;const x=i[f];if(!x)throw new Error(`Feature with id '${f}' not found`);const A=c.get(`${f}:${h}`);if(A!==void 0){const P=await A;return{id:x.id,bucket:P,key:h,storage:x.feature.storage}}const F=d();c.set(`${f}:${h}`,F);const q=await F;return{id:x.id,bucket:q,key:h,storage:x.feature.storage}}});g.sample({clock:s.register,fn:i=>{const{id:l,feature:f}=i;return{id:l,key:f.feature.key,storage:f.feature.storage}},target:p}),g.sample({source:e,clock:a.doneData,fn:(i,l)=>{const{id:f,bucket:d,storage:h}=l,v=i[f]?.feature.key;return v?{key:v,id:f,bucket:d,storage:h}:null},target:o});const u=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:i,resolvedFeaturesStore:l})=>Object.values(i).map(f=>{const d=l.find(h=>h.id===f.id&&h.key===f.feature.key);return d?{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:()=>({id:f.id,bucket:d.bucket}),isResolved:!0}:{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:async()=>await a(f.feature),isResolved:!1}}));g.sample({clock:a.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:i},{id:l,key:f})=>!i.some(h=>h.id===l&&h.key===f),fn:(i,l)=>l,target:t.eventBus.prepend(i=>({type:"feature_decide",feature:i}))}),g.sample({clock:[p.doneData,a.doneData],source:r,fn:(i,l)=>!l||i.some(d=>d.id===l.id&&d.key===l.key)?i:[...i,l],target:r});function m(i){return u.map(l=>l.find(f=>f.id===i))}function b(i){return e.map(l=>l[i],{skipVoid:!1})}function y(i){const l=g.createStore(async()=>{},{skipVoid:!1}),f=g.createEffect(async()=>{const d=m(i).getState();if(d)return async()=>(await d.getBucket()).bucket});return g.sample({source:r,filter:d=>d.some(h=>h.id===i),target:f}),g.sample({clock:f.doneData,filter:d=>d!==void 0,target:l}),f(),l}return{register:n,getById:m,getByName:b,listStore:u,getEvokableFeature:y}});function Se(t){return S.invoke(he,t)}const ve=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function O(t,e){return{id:H.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ke=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),s=j.event(),n=j.event();t.on(e,(o,c)=>({entries:[...o.entries,O(c.experienceId,c.node)]})),t.on(r,(o,c)=>({entries:[...o.entries.slice(0,-1),O(c.experienceId,c.node)]})),t.on(n,(o,c)=>c);function p(o,c){const a={lastStepIndex:-1,secondLastStepIndex:-1};for(let u=o.length-1;u>=0;u--){const m=o[u],b=m?.node;if(!(!b||!I.isStepNode(b))&&!(c&&m?.experienceId!==c))if(a.lastStepIndex===-1)a.lastStepIndex=u;else{a.secondLastStepIndex=u;break}}return a}return t.on(s,(o,c)=>{const{secondLastStepIndex:a}=p(o.entries,c.experienceId),u=a!==-1?o.entries.slice(0,a+1):o.entries;return{...o,entries:u}}),{push:e,replace:r,back:s,restore:n,entriesStore:t.map(o=>o.entries)}});function be(){return S.invoke(ke)}let we=0;const Ie=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},Fe=g.createDomain("field"),Ee=S.createFactory(()=>{const t=Fe.store({}),e=g.createApi(t,{register(a,u){return{...a,[u.resolvedKey]:{...u.field,key:u.resolvedKey}}}});function r(a){e.register({field:a,resolvedKey:a.key})}function s(a,u){const m=p(a).getState();if(!m)return;const b=Object.assign({},m,{...u});e.register({field:{...b},resolvedKey:a})}const n=t.map(a=>Object.values(a));function p(a){return t.map(u=>u[a]||null)}function o(a){return t.map(u=>Object.values(u).find(m=>m.id===a)||null)}function c(a){return t.map(u=>Object.values(u).find(m=>m.name===a)||null)}return{register:r,update:s,getByKey:p,getById:o,listStore:n,getByName:c}});function xe(){return S.invoke(Ee)}const je=(t,e)=>{e.register(t)},Ae=g.createDomain("action"),Pe=S.createFactory(()=>{const t=Ae.store({}),e=g.createApi(t,{register(o,c){return{...o,[c.name]:{name:c.name,action:c.action}}}});function r(o,c){e.register({name:o,action:c})}const s=t.map(o=>Object.values(o));function n(o){return t.map(c=>c[o],{skipVoid:!1})}function p(o){return t.map(c=>{const a=c[o];return a?a.action:void 0},{skipVoid:!1})}return{register:r,getByName:n,listStore:s,getEvokableAction:p}});function Re(){return S.invoke(Pe)}const Ce=(t,e,r)=>{r.register(t,e)};function C(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 ze=g.createDomain("response"),Be=S.createFactory(({client:t})=>{const e=ze.store({}),r=g.createEvent(),s=g.createEvent(),n=g.createApi(e,{register(y,i){return{...y,[i.fieldId]:i.response}},registerBatch(y,i){return{...y,...i}},clear(y,i){const{[i]:l,...f}=y;return f},clearAll(){return{}}});function p(y,i){if(typeof y=="string"){if(i===void 0)throw new Error("Response is required when registering a single field");n.register({fieldId:y,response:i})}else n.registerBatch(y)}async function o(y){const i=[];return await Promise.allSettled(Object.entries(y).map(async([l,f])=>{let d=f;const h=t.fields.getByKey(l).getState();if(!h){i.push({fieldId:l,userMessage:`Field '${l}' not found`,systemMessage:`No field with ID '${l}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:d});return}if(h.multiple&&(typeof d=="string"||typeof d=="number"||typeof d=="boolean")&&(d=[d]),h.validation&&!G.isEmpty(h.validation)&&!C(d)){const v=await I.evaluateRuleLogic(t,h.validation,{$input:d});if(typeof v=="string"){i.push({fieldId:l,userMessage:v,systemMessage:`Field validation resulted in an error: ${v}.`,value:d});return}if(v===!1){i.push({fieldId:l,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:d});return}}if(h.required&&C(d)){i.push({fieldId:l,userMessage:"This field is required",systemMessage:"Field is required.",value:d});return}if(!h.multiple&&Array.isArray(d)&&d.length>1){i.push({fieldId:l,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:d});return}if(h.type==="object"&&!C(d))if(h.multiple){if(!Array.isArray(d)){i.push({fieldId:l,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:d});return}for(const v of d){if(typeof v!="object"||v===null){i.push({fieldId:l,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:d});return}if(!M(v)){i.push({fieldId:l,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:d});return}}}else{if(Array.isArray(d)){i.push({fieldId:l,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:d});return}if(typeof d!="object"||d===null){i.push({fieldId:l,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:d});return}if(!M(d)){i.push({fieldId:l,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:d});return}}if(Array.isArray(h.options)&&h.options.length>0){const v=Array.isArray(d)?d:[d];if(h.type==="object"){const x=h.options.map(F=>JSON.stringify(F.value));v.every(F=>x.includes(JSON.stringify(F)))||i.push({fieldId:l,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:d})}else{const x=h.options.map(F=>F.value);v.every(F=>!$e(F)||F===null?!1:x.includes(F))||i.push({fieldId:l,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${x.join(", ")}`,value:d})}}})),{responsesToCommit:y,validationErrors:i}}async function c(y){const{responsesToCommit:i,validationErrors:l}=await o(y);return l.length?{errors:l}:(n.registerBatch(i),{errors:[]})}const a=e.map(y=>y),u=e.map(y=>Object.keys(y).map(l=>({fieldId:l,value:y[l]})));function m(y){const i=t.fields.getByKey(y),l=e.map(f=>f[y]||null);return g.combine({f:i,r:l},({f,r:d})=>d||(f?.defaultValue?f.defaultValue:null))}function b(y){const i=t.fields.getByName(y);return g.combine({f:i,s:e},({f:l,s:f})=>{const d=l&&f[l.key??W.toKebabCase(l.name)]||null;return d||(l?.defaultValue?l.defaultValue:null)})}return g.sample({clock:r,target:n.clearAll}),g.sample({clock:s,target:n.clear}),{register:p,clearAll:r,clear:s,commit:c,getResponsesToCommit:o,listStore:u,getAllStore:a,getByFieldId:m,getByFieldName:b}});function De(t){return S.invoke(Be,t)}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[n]of t.entries())n.startsWith("picked-")&&r.add(n);for(const n of r){const p=n.replace("picked-","");e[p]=t.getAll(n)}const s=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(s,e);else{const n=w.sessionStore.get(s);if(n)return n.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=n=>t.set({id:n.id,isUser:n.isUser,identifiers:n.identifiers}),s={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(n){this.isUser=n,r(this)},setIdentifier(n,p){this.identifiers={...this.identifiers,[n]:p},r(this)},removeIdentifier(n){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([p])=>p!==n)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(s),s},Ne=()=>k.supportsLocalStorage()?Ve():null;function T(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!k.supportsWindow())return;const t=T(),e=t?.organizationId,r=t?.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function Ke(){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 _e(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const s=Te();if(s)return s;const n=Ke();if(n)return n;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"),E=require("../logger-BsmHUUw1.cjs"),w=require("../storage-Be5xWNPC.cjs"),U=require("../api-F0IOGUor.cjs"),H=require("../id-BKIWbSTy.cjs"),G=require("../object-BbFTsGh3.cjs"),W=require("../to-kebab-case-BsOQ8CON.cjs"),k=require("../supports-YvpQZxbh.cjs"),L=g.createDomain("experience"),J=S.createFactory(({client:t,experience:e})=>{const r=L.store(e),s=g.createApi(r,{merge(u,m){return{...u,...m.experience}}}),n=r.map(u=>({name:u.name,decisionLogic:u.condition,targetSelectors:u.targets,initializeOpenLogic:e.initializeOpen})),p=t.components.listStore.map(u=>(e.componentName?u.find(m=>m.name===e.componentName):void 0)||u.find(m=>m.name===`experience:${e.id}`)||u.find(m=>m.name==="experience"),{skipVoid:!1}),o=r.map(u=>({steps:u.steps,nodes:u.nodes,edges:u.edges,conditionals:u.conditionals})),c=r.map(u=>u.fields),a=e.actions??[];return{id:e.id,configStore:n,treeStore:o,fieldsStore:c,componentStore:p,actions:a,merge:s.merge}});function Y(t){return S.invoke(J,t)}const Q=S.createFactory(({client:t})=>{const e=L.store({}),r=g.createApi(e,{register(a,u){return{...a,[u.id]:u}}});function s(a){const u=e.getState()[a.id];if(u){u.merge({experience:a,strategy:"override"});return}const m=Y({client:t,experience:a});r.register(m)}const n=e.map(a=>Object.values(a));function p(a){return e.map(u=>u[a],{skipVoid:!1})}const o=g.attach({source:e,effect:async(a,{id:u,options:m})=>{const b=a[u];if(!b){E.logger("warn",`Experience with id '${u}' not found.`);return}if(m?.bypassCondition){$(t,b,m);return}await V(t,b)&&$(t,b,m)}}),c=g.attach({source:t.experienceInstances.listStore,effect:(a,{id:u,options:m})=>{const b=a.filter(y=>y.experienceId===u);if(b.length>0)for(const y of b)y.open();else o({id:u,options:{...m,initialiseOpen:!0}})}});return{register:s,get:p,getById:p,launch:o,open:c,listStore:n}});function X(t){return S.invoke(Q,t)}const Z=(t,e)=>{e.register(t)},$=(t,e,r)=>{const{targetSelectors:s}=e.configStore.getState(),n=I.getTargetElements(s,e.id);n.forEach(({elements:o})=>o.forEach(c=>I.tagTargetElement(c,e.id))),I.createAppHosts(n,e.id).forEach(o=>{r?t.experienceInstances.spawn(e,o,r):t.experienceInstances.spawn(e,o)})},z=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await V(t,e)&&$(t,e)}))},V=async(t,e)=>{if(!t.preconditionPassed||!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===void 0?!0:I.isRulesLogic(r)?await I.evaluateRuleLogic(t,r)===!0:!0},ee=(t,e,r)=>{const s=e.name,n=e.setup(t);if(n){const p=r[s]??{};r[s]=Object.freeze({...p,...n})}},te=g.createDomain("component"),re=S.createFactory(({client:t,component:e,name:r})=>{const s=t.frameworks.getByName(e.frameworkName);return{name:r,component:e,frameworkStore:s}});function se(t){return S.invoke(re,t)}const ne=S.createFactory(({client:t})=>{const e=te.store({}),r=g.createApi(e,{register(o,c){return{...o,[c.name]:c}}});function s(o,c){e.getState()[o]&&E.logger("warn",`Component '${o}' already registered. Registering again will override the previous registration.`);const u=se({client:t,name:o,component:c});r.register(u)}const n=e.map(o=>Object.values(o));function p(o){return e.map(c=>c[o],{skipVoid:!1})}return{register:s,getByName:p,listStore:n}});function ie(t){return S.invoke(ne,t)}const B=(t,e,r)=>{r.register(t,e)},oe=g.createDomain("framework"),ae=S.createFactory(({client:t})=>{const e=oe.store({}),r=g.createApi(e,{register(o,c){return{...o,[c.name]:c.framework}}});function s(o,c){e.getState()[o]&&E.logger("warn",`Framework '${o}' already registered. Registering again will override the previous registration.`),r.register({name:o,framework:c})}const n=e.map(o=>Object.values(o));function p(o){return e.map(c=>c[o],{skipVoid:!1})}return{register:s,getByName:p,listStore:n}});function ce(t){return S.invoke(ae,t)}const ue=(t,e)=>{e.register(t.name,t)},le=6e3,de=w.createStorageKey("last_ping","global"),pe=async t=>{try{const e=Date.now(),r=w.localStore.get(de);let s=0;if(r.isSet()&&(s=r.json()??0),s&&e-s<le)return!0;const n={projectId:t.projectId,path:window.location.pathname},p={},c=document.getElementById("picked_script")?.dataset.verceltoken;c&&(p["x-vercel-protection-bypass"]=c);const u=(await U.post(t.apiUrl,"ping",n,p)).ok;return u&&r.set(e),u}catch(e){return E.logger("error",e),!1}};function N(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 fe=g.createDomain("predicate"),ge=S.createFactory(({client:t})=>{const e=fe.store({}),r=g.createApi(e,{register(c,a){return{...c,[a.name]:{name:a.name,predicate:a.predicate}}}});function s(c,a){e.getState()[c]&&E.logger("warn",`Predicate '${c}' already registered. Registering again will override the previous registration.`),r.register(Object.freeze({name:c,predicate:a}))}const n=e.map(c=>Object.values(c));function p(c){return e.map(a=>a[c]?.predicate,{skipVoid:!1})}function o(c){const a=g.createStore(()=>{},{skipVoid:!1}),u=g.createEffect(async()=>{const m=p(c).getState();if(!m)return;const b=N(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:a}),u(),a}return{register:s,getByName:p,listStore:n,getEvokablePredicate:o}});function me(t){return S.invoke(ge,t)}const ye=(t,e,r)=>{r.register(t,e)},D=g.createDomain("feature"),he=S.createFactory(({client:t})=>{const e=D.store({}),r=D.store([]),s=g.createApi(e,{register(i,l){return{...i,[l.id]:l.feature}}});function n(i,l){e.getState()[i]&&E.logger("warn",`Feature '${i}' already registered. Registering again will override the previous registration.`);const d={id:i,feature:{...l,id:i}};s.register(Object.freeze({id:i,feature:d}))}const p=g.createEffect(async({id:i,key:l,storage:f="local"})=>{const d=w.createStorageKey(`feature:${i}:${l}`,"global"),v=(f==="session"?w.sessionStore:w.localStore).get(d).boolean();return v===null?null:{id:i,key:l,bucket:v,storage:f}}),o=g.createEffect(i=>{if(!i)return null;const l=w.createStorageKey(`feature:${i.id}:${i.key}`,"global");(i.storage==="session"?w.sessionStore:w.localStore).set(l,i.bucket)}),c=new Map,a=g.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:r},effect:async({allFeaturesStore:i,resolvedFeaturesStore:l},{id:f,decide:d,key:h})=>{const v=l.find(P=>P.id===f&&P.key===h);if(v)return v;const x=i[f];if(!x)throw new Error(`Feature with id '${f}' not found`);const A=c.get(`${f}:${h}`);if(A!==void 0){const P=await A;return{id:x.id,bucket:P,key:h,storage:x.feature.storage}}const F=d();c.set(`${f}:${h}`,F);const q=await F;return{id:x.id,bucket:q,key:h,storage:x.feature.storage}}});g.sample({clock:s.register,fn:i=>{const{id:l,feature:f}=i;return{id:l,key:f.feature.key,storage:f.feature.storage}},target:p}),g.sample({source:e,clock:a.doneData,fn:(i,l)=>{const{id:f,bucket:d,storage:h}=l,v=i[f]?.feature.key;return v?{key:v,id:f,bucket:d,storage:h}:null},target:o});const u=g.combine({allFeaturesStore:e,resolvedFeaturesStore:r}).map(({allFeaturesStore:i,resolvedFeaturesStore:l})=>Object.values(i).map(f=>{const d=l.find(h=>h.id===f.id&&h.key===f.feature.key);return d?{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:()=>({id:f.id,bucket:d.bucket}),isResolved:!0}:{id:f.id,name:f.feature.name,key:f.feature.key,getBucket:async()=>await a(f.feature),isResolved:!1}}));g.sample({clock:a.doneData,source:{resolvedFeatures:r},filter:({resolvedFeatures:i},{id:l,key:f})=>!i.some(h=>h.id===l&&h.key===f),fn:(i,l)=>l,target:t.eventBus.prepend(i=>({type:"feature_decide",feature:i}))}),g.sample({clock:[p.doneData,a.doneData],source:r,fn:(i,l)=>!l||i.some(d=>d.id===l.id&&d.key===l.key)?i:[...i,l],target:r});function m(i){return u.map(l=>l.find(f=>f.id===i))}function b(i){return e.map(l=>l[i],{skipVoid:!1})}function y(i){const l=g.createStore(async()=>{},{skipVoid:!1}),f=g.createEffect(async()=>{const d=m(i).getState();if(d)return async()=>(await d.getBucket()).bucket});return g.sample({source:r,filter:d=>d.some(h=>h.id===i),target:f}),g.sample({clock:f.doneData,filter:d=>d!==void 0,target:l}),f(),l}return{register:n,getById:m,getByName:b,listStore:u,getEvokableFeature:y}});function Se(t){return S.invoke(he,t)}const ve=(t,e,r)=>{r.register(t,e)},j=g.createDomain("history");function O(t,e){return{id:H.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ke=S.createFactory(()=>{const t=j.store({entries:[]}),e=j.event(),r=j.event(),s=j.event(),n=j.event();t.on(e,(o,c)=>({entries:[...o.entries,O(c.experienceId,c.node)]})),t.on(r,(o,c)=>({entries:[...o.entries.slice(0,-1),O(c.experienceId,c.node)]})),t.on(n,(o,c)=>c);function p(o,c){const a={lastStepIndex:-1,secondLastStepIndex:-1};for(let u=o.length-1;u>=0;u--){const m=o[u],b=m?.node;if(!(!b||!I.isStepNode(b))&&!(c&&m?.experienceId!==c))if(a.lastStepIndex===-1)a.lastStepIndex=u;else{a.secondLastStepIndex=u;break}}return a}return t.on(s,(o,c)=>{const{secondLastStepIndex:a}=p(o.entries,c.experienceId),u=a!==-1?o.entries.slice(0,a+1):o.entries;return{...o,entries:u}}),{push:e,replace:r,back:s,restore:n,entriesStore:t.map(o=>o.entries)}});function be(){return S.invoke(ke)}let we=0;const Ie=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},Fe=g.createDomain("field"),Ee=S.createFactory(()=>{const t=Fe.store({}),e=g.createApi(t,{register(a,u){return{...a,[u.resolvedKey]:{...u.field,key:u.resolvedKey}}}});function r(a){e.register({field:a,resolvedKey:a.key})}function s(a,u){const m=p(a).getState();if(!m)return;const b=Object.assign({},m,{...u});e.register({field:{...b},resolvedKey:a})}const n=t.map(a=>Object.values(a));function p(a){return t.map(u=>u[a]||null)}function o(a){return t.map(u=>Object.values(u).find(m=>m.id===a)||null)}function c(a){return t.map(u=>Object.values(u).find(m=>m.name===a)||null)}return{register:r,update:s,getByKey:p,getById:o,listStore:n,getByName:c}});function xe(){return S.invoke(Ee)}const je=(t,e)=>{e.register(t)},Ae=g.createDomain("action"),Pe=S.createFactory(()=>{const t=Ae.store({}),e=g.createApi(t,{register(o,c){return{...o,[c.name]:{name:c.name,action:c.action}}}});function r(o,c){e.register({name:o,action:c})}const s=t.map(o=>Object.values(o));function n(o){return t.map(c=>c[o],{skipVoid:!1})}function p(o){return t.map(c=>{const a=c[o];return a?a.action:void 0},{skipVoid:!1})}return{register:r,getByName:n,listStore:s,getEvokableAction:p}});function Re(){return S.invoke(Pe)}const Ce=(t,e,r)=>{r.register(t,e)};function C(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 ze=g.createDomain("response"),Be=S.createFactory(({client:t})=>{const e=ze.store({}),r=g.createEvent(),s=g.createEvent(),n=g.createApi(e,{register(y,i){return{...y,[i.fieldId]:i.response}},registerBatch(y,i){return{...y,...i}},clear(y,i){const{[i]:l,...f}=y;return f},clearAll(){return{}}});function p(y,i){if(typeof y=="string"){if(i===void 0)throw new Error("Response is required when registering a single field");n.register({fieldId:y,response:i})}else n.registerBatch(y)}async function o(y){const i=[];return await Promise.allSettled(Object.entries(y).map(async([l,f])=>{let d=f;const h=t.fields.getByKey(l).getState();if(!h){i.push({fieldId:l,userMessage:`Field '${l}' not found`,systemMessage:`No field with ID '${l}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:d});return}if(h.multiple&&(typeof d=="string"||typeof d=="number"||typeof d=="boolean")&&(d=[d]),h.validation&&!G.isEmpty(h.validation)&&!C(d)){const v=await I.evaluateRuleLogic(t,h.validation,{$input:d});if(typeof v=="string"){i.push({fieldId:l,userMessage:v,systemMessage:`Field validation resulted in an error: ${v}.`,value:d});return}if(v===!1){i.push({fieldId:l,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:d});return}}if(h.required&&C(d)){i.push({fieldId:l,userMessage:"This field is required",systemMessage:"Field is required.",value:d});return}if(!h.multiple&&Array.isArray(d)&&d.length>1){i.push({fieldId:l,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:d});return}if(h.type==="object"&&!C(d))if(h.multiple){if(!Array.isArray(d)){i.push({fieldId:l,userMessage:"This field expects multiple values",systemMessage:"Field expects an array of objects.",value:d});return}for(const v of d){if(typeof v!="object"||v===null){i.push({fieldId:l,userMessage:"This field expects object values",systemMessage:"Field expects an array of objects, but received non-object value.",value:d});return}if(!M(v)){i.push({fieldId:l,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:d});return}}}else{if(Array.isArray(d)){i.push({fieldId:l,userMessage:"This field expects a single value",systemMessage:"Field expects a single object, not an array.",value:d});return}if(typeof d!="object"||d===null){i.push({fieldId:l,userMessage:"This field expects an object value",systemMessage:"Field expects an object value.",value:d});return}if(!M(d)){i.push({fieldId:l,userMessage:"This field contains non-serializable data",systemMessage:"Field value contains non-JSON-serializable data (functions, circular references, etc.).",value:d});return}}if(Array.isArray(h.options)&&h.options.length>0){const v=Array.isArray(d)?d:[d];if(h.type==="object"){const x=h.options.map(F=>JSON.stringify(F.value));v.every(F=>x.includes(JSON.stringify(F)))||i.push({fieldId:l,userMessage:"This field expects a valid option",systemMessage:"Field expects a valid option from the defined choices.",value:d})}else{const x=h.options.map(F=>F.value);v.every(F=>!$e(F)||F===null?!1:x.includes(F))||i.push({fieldId:l,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${x.join(", ")}`,value:d})}}})),{responsesToCommit:y,validationErrors:i}}async function c(y){const{responsesToCommit:i,validationErrors:l}=await o(y);return l.length?{errors:l}:(n.registerBatch(i),{errors:[]})}const a=e.map(y=>y),u=e.map(y=>Object.keys(y).map(l=>({fieldId:l,value:y[l]})));function m(y){const i=t.fields.getByKey(y),l=e.map(f=>f[y]||null);return g.combine({f:i,r:l},({f,r:d})=>d||(f?.defaultValue?f.defaultValue:null))}function b(y){const i=t.fields.getByName(y);return g.combine({f:i,s:e},({f:l,s:f})=>{const d=l&&f[l.key??W.toKebabCase(l.name)]||null;return d||(l?.defaultValue?l.defaultValue:null)})}return g.sample({clock:r,target:n.clearAll}),g.sample({clock:s,target:n.clear}),{register:p,clearAll:r,clear:s,commit:c,getResponsesToCommit:o,listStore:u,getAllStore:a,getByFieldId:m,getByFieldName:b}});function De(t){return S.invoke(Be,t)}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[n]of t.entries())n.startsWith("picked-")&&r.add(n);for(const n of r){const p=n.replace("picked-","");e[p]=t.getAll(n)}const s=w.createStorageKey("s");if(r.size>0)w.sessionStore.set(s,e);else{const n=w.sessionStore.get(s);if(n)return n.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=n=>t.set({id:n.id,isUser:n.isUser,identifiers:n.identifiers}),s={id:e?.id??Ue(),isUser:e?.isUser??void 0,identifiers:e?.identifiers??void 0,setIsUser(n){this.isUser=n,r(this)},setIdentifier(n,p){this.identifiers={...this.identifiers,[n]:p},r(this)},removeIdentifier(n){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([p])=>p!==n)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,r(this))}};return r(s),s},Ne=()=>k.supportsLocalStorage()?Ve():null;function T(){if(k.supportsWindow())return globalThis.window.pickedConfig}function Te(){if(!k.supportsWindow())return;const t=T(),e=t?.organizationId,r=t?.projectId;return e&&r?{organizationId:e,projectId:r}:void 0}function Ke(){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 _e(t){const{organizationId:e,projectId:r}=t;if(e&&r)return{organizationId:e,projectId:r};const s=Te();if(s)return s;const n=Ke();if(n)return n;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
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 qe={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,n])=>`${s}: ${n}`);return e.format(r)}return t instanceof Set?e.format(Array.from(t).map(String)):t}};function He(t){return typeof t=="object"&&t!==null}function Ge(t,e){let r=e;for(const s of t.split("."))if(He(r)&&s in r)r=r[s];else return;return typeof r=="function"?r():r}function We(t,e){const r=t.split("|").map(p=>p.trim()),s=r.shift()??"";let n=Ge(s,e);for(const p of r){const[o,...c]=p.split(":"),a=o?.trim()??"",u=c.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g,""),m=qe[a];m&&(n=m(n,u))}return R(n)?"":typeof n=="object"?JSON.stringify(n):String(n)}function Je(t,e){let r="",s=0;for(;s<t.length;)if(t[s]==="{"&&t[s+1]==="{"){s+=2;let n="";for(;s<t.length;){if(t[s]==="}"&&t[s+1]==="}"){s+=2;break}n+=t[s++]}r+=We(n.trim(),e)}else r+=t[s++];return r}class K{static logger=E.logger;options;isReady=!1;project;plugins={};pluginStartHooks=[];eventBus=g.createEvent();events;organizationId;projectId;apiUrl;dashboardUrl;documentationSiteUrl;session;precondition;condition;preconditionPassed;searchParams=Me();history=be();components=ie({client:this});experienceInstances=I.createExperienceInstanceIndex({client:this});experiences=X({client:this});frameworks=ce({client:this});predicates=me({client:this});features=Se({client:this});responses=De({client:this});fields=xe();actions=Re();constructor(e){E.logger("info","Picked client initializing."),this.events=Ie(this.eventBus);const{organizationId:r,projectId:s}=_e(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=Ne(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.setupComponents(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:"load",version:U.getVersion()}),E.logger("info","Picked client initialized.")}start=()=>{pe(this),(async()=>{if(!k.supportsDocument())return;await this.runPluginStartHooks();const r=await this.evaluateGate(this.precondition);this.preconditionPassed=r;let s;r&&(s=await this.evaluateGate(this.condition));const n=r&&s===!0;if(typeof s=="boolean"&&this.session){const p=s;this.session.setIsUser(p),this.eventBus({type:"user_decide",value:p})}if(this.eventBus({type:"initialize"}),n&&z(this),await I.domInteractive(),n&&z(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session){const{id:p,isUser:o,identifiers:c}=this.session;this.eventBus({type:"session",id:p,isUser:o,identifiers:c})}})()};registerFramework=e=>{ue(e,this.frameworks)};registerComponent=(e,r)=>{B(e,r,this.components)};registerPlugin=e=>{ee(this,e,this.plugins);const r=this.plugins[e.name];r?.onStart&&this.pluginStartHooks.push(r.onStart)};registerFeature=(e,r)=>{ve(e,r,this.features)};registerPredicate=(e,r)=>{ye(e,r,this.predicates)};registerField=e=>{je(e,this.fields)};registerAction=(e,r)=>{Ce(e,r,this.actions)};registerExperience=e=>{e.component&&B(`experience:${e.id}`,e.component,this.components),Z(e,this.experiences)};getStateSnapshot=()=>N(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 n=typeof s=="function"?s():s;this.registerFeature(r,n)}),this.searchParams.feature&&this.searchParams.feature.forEach(r=>{try{const[s,n]=r.split(":");if(!s||!n)return;let p=n;p==="true"&&(p=!0),p==="false"&&(p=!1),this.registerFeature(s,{key:`${p}`,name:s,decide:()=>p,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([r,s])=>{if(typeof s!="function"){E.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"){E.logger("warn",`Action "${r}" is not a function.`);return}this.registerAction(r,s)})}setupComponents(){const e=this.options.components;e&&Object.entries(e).forEach(([r,s])=>{this.registerComponent(r,s)})}getPluginConfig=e=>this.plugins[e]??{};renderString=(e,r)=>{const s=this.responses.listStore.getState().reduce((n,p)=>(n[p.fieldId]=p.value,n),{});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 o=(await Promise.all(s.options.map(async a=>a.condition?await I.evaluateRuleLogic(t,a.condition)?a:null:a))).filter(a=>a!==null);return o.length===s.options.length?s:o.length===0?null:{...s,options:o}}))).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 K(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=K;exports.createClient=et;exports.getPickedConfig=T;exports.getStepFields=Qe;exports.isLazyLoader=Ze;exports.lazyComponent=Xe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../../id-BKIWbSTy.cjs"),m=require("../../../to-kebab-case-BsOQ8CON.cjs"),r={serialize(i){return JSON.stringify(i)},deserialize(i){return JSON.parse(i)}},N=i=>({name:"create-experience",setup:o=>{i.experiences.forEach(t=>{const s=t.serialize(),a=r.deserialize(s);a.component=t.component,o.registerExperience(a),a.fields.forEach(f=>{o.registerField(f)})})}}),b=(i,o)=>({id:h.generateId("node"),experience:o,type:"action",action:i.action,addNext(s){if(!s.node)throw new Error("Cannot connect to node");const a=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:null},o);o.edges.push(a)},onSuccess(s){if(!s.node)throw new Error("Cannot connect to node");const a=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"true"},o);o.edges.push(a)},onFail(s){if(!s.node)throw new Error("Cannot connect to node");const a=c({sourceNode:this,destinationNode:s.node,sourceNodeHandle:"false"},o);o.edges.push(a)},serialize(){return r.serialize({id:this.id,type:this.type,action:this.action})}}),z=i=>({id:i.id??h.generateId("step"),key:i.key??m.toKebabCase(i.name),name:i.name,fields:i.fields??[],addField(o){const t="serialize"in o?o:y(o);return this.fields.includes(t)||this.fields.push(t),t}}),v=(i,o)=>{const t={id:i.id??h.generateId("step"),key:i.key??m.toKebabCase(i.name),name:i.name,experience:o,fields:i.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 r.serialize({id:this.id,key:m.toKebabCase(this.name),name:this.name,fieldIds:this.fields.map(s=>s.id)})}};return p({step:t,type:"step"},o),t},p=(i,o)=>{const t={id:h.generateId("node"),experience:o};if(i.type==="step"){const a={...t,type:"step",connectedStep:i.step,serialize(){return r.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,name:this.connectedStep.name})}};return a.connectedStep.node=a,a}if(i.type==="conditional"){const a={...t,type:"conditional",connectedConditional:i.conditional,serialize(){return r.serialize({id:this.id,type:this.type,conditionalId:this.connectedConditional.id})}};return a.connectedConditional.node=a,a}return i.type==="experience"?{...t,type:"experience",connectedExperience:i.experience,serialize(){return r.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id})}}:{...t,type:"origin",serialize(){return r.serialize({id:this.id,type:this.type})}}},c=(i,o)=>({id:h.generateId("edge"),sourceNode:i.sourceNode,sourceNodeHandle:i.sourceNodeHandle,destinationNode:i.destinationNode,experience:o,serialize(){return r.serialize({id:this.id,sourceNodeHandle:this.sourceNodeHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),g=(i,o)=>{const t={id:h.generateId("conditional"),label:i.label,condition:i.condition,node:null,experience:o,addTrue(s){if(!this.node||!s.node)throw new Error("todo no node");const a=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"true"},this.experience);this.experience.edges.push(a)},addFalse(s){if(!this.node||!s.node)throw new Error("todo no node");const a=c({sourceNode:this.node,destinationNode:s.node,sourceNodeHandle:"false"},this.experience);this.experience.edges.push(a)},serialize(){return r.serialize({id:this.id,label:this.label,condition:this.condition})}};return p({conditional:t,type:"conditional"},o),t},y=i=>({id:i.id??h.generateId("field"),key:i.key??m.toKebabCase(i.name),name:i.name,type:i.type,label:i.label,placeholder:i.placeholder,description:i.description,helpText:i.helpText,defaultValue:i.defaultValue??null,multiple:i.multiple,validation:i.validation??{},condition:i.condition,required:i.required,options:i.options?.map(t=>({id:"id"in t?t.id:h.generateId("option"),...t}))??null,policies:i.policies,serialize(){const t={id:this.id,key:this.key,name:this.name,label:this.label,placeholder:this.placeholder,required:this.required,description:this.description,helpText:this.helpText,validation:this.validation,condition:this.condition,policies:this.policies},s=typeof this.defaultValue=="string"?this.defaultValue:void 0,a=typeof this.defaultValue=="number"?this.defaultValue:void 0,f=typeof this.defaultValue=="boolean"?this.defaultValue:void 0;switch(this.type){case"text":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const n of this.defaultValue)typeof n=="string"&&e.push(n);e.length===0&&(e=void 0)}return r.serialize({...t,type:"text",multiple:!0,defaultValue:e,options:this.options?this.options.map(n=>({id:n.id,label:n.label,value:`${n.value}`,condition:n.condition})):null})}return r.serialize({...t,type:"text",multiple:!1,defaultValue:s,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`,condition:e.condition})):null});case"number":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const n of this.defaultValue)typeof n=="number"&&e.push(n);e.length===0&&(e=void 0)}return r.serialize({...t,type:"number",multiple:!0,defaultValue:e,options:this.options?this.options.map(n=>({id:n.id,label:n.label,value:Number(n.value),condition:n.condition})):null})}return r.serialize({...t,type:"number",multiple:!1,defaultValue:a,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value),condition:e.condition})):null});case"boolean":if(this.multiple){let e;if(Array.isArray(this.defaultValue)){e=[];for(const n of this.defaultValue)typeof n=="boolean"&&e.push(n);e.length===0&&(e=void 0)}return r.serialize({...t,type:"boolean",multiple:!0,defaultValue:e,options:this.options?this.options.map(n=>({id:n.id,label:n.label,value:!!n.value,condition:n.condition})):null})}return r.serialize({...t,type:"boolean",multiple:!1,defaultValue:f,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value,condition:e.condition})):null});case"object":return this.multiple?r.serialize({...t,type:"object",multiple:!0,defaultValue:this.defaultValue,options:this.options?this.options.map(e=>({id:e.id,label:e.label,description:e.description,value:e.value,condition:e.condition})):null}):r.serialize({...t,type:"object",multiple:!1,defaultValue:this.defaultValue,options:this.options?this.options.map(e=>({id:e.id,label:e.label,description:e.description,value:e.value,condition:e.condition})):null});default:throw new Error("Unsupported field type")}}}),x=i=>{const o=[],t=[],s=[],a=[],f=[];return{id:i.id,component:i.component,name:i.name,initializeOpen:i.initializeOpen,condition:i.condition,targets:i.targets,steps:o,nodes:t,edges:s,fields:f,conditionals:a,addStep(e,n){let l=n?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));let d="serialize"in e?e:v(e,this);if(d={...d,id:d.id??h.generateId("step"),key:d.key??m.toKebabCase(d.name)},l){if(!d.node)throw new Error("todo no node");const u=c({sourceNode:l,destinationNode:d.node,sourceNodeHandle:null},this);this.edges.push(u)}return d.fields.length>0&&d.fields.forEach(u=>{this.fields.includes(u)||this.fields.push(u)}),this.steps.includes(d)||(this.steps.push(d),d.node&&this.nodes.push(d.node)),d},addAction(e,n){let l=n?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const d="serialize"in e?e:b(e,this);if(l){const u=c({sourceNode:l,destinationNode:d,sourceNodeHandle:null},this);this.edges.push(u)}return this.nodes.push(d),d},addConditional(e,n){let l=n?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const d="serialize"in e?e:g(e,this);if(l){if(!d.node)throw new Error("todo no node");const u=c({sourceNode:l,destinationNode:d.node,sourceNodeHandle:null},this);this.edges.push(u)}return this.conditionals.includes(d)||(this.conditionals.push(d),d.node&&this.nodes.push(d.node)),d},addExperience(e,n){let l=n?.node;this.nodes.length===0&&(l=p({type:"origin"},this),this.nodes.push(l));const d=p({type:"experience",experience:e},this);if(this.nodes.push(d),l){const u=c({sourceNode:l,destinationNode:d,sourceNodeHandle:null},this);this.edges.push(u)}return e},addField(e,n){const l="serialize"in e?e:y(e);return n&&n.fields.push(l),this.fields.includes(l)||this.fields.push(l),l},serialize(){return r.serialize({id:this.id,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition,targets:this.targets,steps:this.steps.map(e=>r.deserialize(e.serialize())),nodes:this.nodes.map(e=>r.deserialize(e.serialize())),edges:this.edges.map(e=>r.deserialize(e.serialize())),conditionals:this.conditionals.map(e=>r.deserialize(e.serialize())),fields:this.fields.map(e=>r.deserialize(e.serialize()))})}}};exports.createConditional=g;exports.createEdge=c;exports.createExperience=x;exports.createExperiencePlugin=N;exports.createField=y;exports.createNode=p;exports.createStep=z;exports.serialization=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../api-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../api-F0IOGUor.cjs"),a=require("../../../logger-BsmHUUw1.cjs");function g(e){let r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619);return r>>>0}function d(e){return g(e)%100}function p(e,r){return r<=0?!1:r>=100?!0:e<r}function h(e){return typeof e!="object"||e===null||!("key"in e&&"name"in e&&"enabled"in e&&"weight"in e&&"version"in e)?!1:typeof e.key=="string"&&typeof e.name=="string"&&typeof e.enabled=="boolean"&&typeof e.weight=="number"&&typeof e.version=="number"}function l(e){return typeof e!="object"||e===null||!("features"in e)||!Array.isArray(e.features)?!1:e.features.every(h)}function y(e){const r=e.searchParams["preview-token"];if(r&&r.length>0)return r[0]}function m(e){const r=new Set,n=e.searchParams.feature;if(!n)return r;for(const o of n){const t=o.indexOf(":");t>0&&r.add(o.substring(0,t))}return r}function c(e,r,n){const o=m(e),t=e.session?.id;if(!t)throw new Error("Session ID is required for feature registration");const i=d(t);for(const s of r.features)o.has(s.key)||v(e,s,n,i)}function v(e,r,n,o){e.registerFeature(r.key,{key:`v${r.version}`,name:r.name,storage:n?"session":"local",decide:()=>r.enabled?p(o,r.weight):!1})}function w(){let e;try{e=__PICKED_PROJECT_CONFIG__}catch{return}if(e===void 0)return;let r;if(typeof e=="string")try{r=JSON.parse(e)}catch{a.logger("warn","Build-time project config is not valid JSON");return}else r=e;if(l(r))return r;a.logger("warn","Build-time project config has invalid shape, falling back to runtime fetch")}function j(e){try{const r=new URL(e).hostname;return r==="localhost"||r==="127.0.0.1"||r==="::1"}catch{return!1}}function b(e){if(typeof e!="object"||e===null||!("cause"in e))return!1;const{cause:r}=e;return typeof r!="object"||r===null||!("code"in r)?!1:r.code==="ECONNREFUSED"}async function u(e,r,n){const o=n?.previewToken?`projects/${r}?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${r}`;let t;try{t=await f.get(e,o,n?.headers)}catch(s){return j(e)&&b(s)||a.logger("warn","Failed to fetch project config",s),null}if(!t.ok)return a.logger("warn",`Project config request failed with status ${t.status.toString()}`),null;let i;try{i=await t.json()}catch{return a.logger("warn","Failed to parse project config response"),null}return l(i)?i:(a.logger("warn","Invalid project config response shape"),null)}function P(e){return{name:"dynamic-experiences",setup:r=>{const n=e?.apiUrl??r.apiUrl;return{onStart:async()=>{const o=y(r);if(o){const s=await u(n,r.projectId,{previewToken:o});s&&c(r,s,!0);return}const t=e?.projectConfig??w();if(t){c(r,t,!1);return}const i=await u(n,r.projectId);i&&c(r,i,!1)}}}}}exports.createClientHeaders=f.createClientHeaders;exports.dynamicExperiencesPlugin=P;exports.fetchProject=u;
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { f as Ot } from "../experience-instance-fvSEb72i.js";
|
|
|
5
5
|
import { l as w } from "../logger-C9a75KZn.js";
|
|
6
6
|
import { c as A, l as C, s as O } from "../storage-Co_LbKr_.js";
|
|
7
7
|
import { a as Ut } from "../storage-Co_LbKr_.js";
|
|
8
|
-
import { p as ae, g as ce } from "../api-
|
|
8
|
+
import { p as ae, g as ce } from "../api-B3JRgxph.js";
|
|
9
9
|
import { g as ue } from "../id-BW-g3y32.js";
|
|
10
10
|
import { i as de } from "../object-JwZ58NOH.js";
|
|
11
11
|
import { t as le } from "../to-kebab-case-BPnCZjhB.js";
|
|
@@ -9,42 +9,42 @@ const r = {
|
|
|
9
9
|
}
|
|
10
10
|
}, x = (i) => ({
|
|
11
11
|
name: "create-experience",
|
|
12
|
-
setup: (
|
|
12
|
+
setup: (o) => {
|
|
13
13
|
i.experiences.forEach((t) => {
|
|
14
|
-
const s = t.serialize(),
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const s = t.serialize(), l = r.deserialize(s);
|
|
15
|
+
l.component = t.component, o.registerExperience(l), l.fields.forEach((f) => {
|
|
16
|
+
o.registerField(f);
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
}), N = (i,
|
|
20
|
+
}), N = (i, o) => ({
|
|
21
21
|
id: h("node"),
|
|
22
|
-
experience:
|
|
22
|
+
experience: o,
|
|
23
23
|
type: "action",
|
|
24
24
|
action: i.action,
|
|
25
25
|
addNext(s) {
|
|
26
26
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
27
|
-
const
|
|
27
|
+
const l = c(
|
|
28
28
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: null },
|
|
29
|
-
|
|
29
|
+
o
|
|
30
30
|
);
|
|
31
|
-
|
|
31
|
+
o.edges.push(l);
|
|
32
32
|
},
|
|
33
33
|
onSuccess(s) {
|
|
34
34
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
35
|
-
const
|
|
35
|
+
const l = c(
|
|
36
36
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: "true" },
|
|
37
|
-
|
|
37
|
+
o
|
|
38
38
|
);
|
|
39
|
-
|
|
39
|
+
o.edges.push(l);
|
|
40
40
|
},
|
|
41
41
|
onFail(s) {
|
|
42
42
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
43
|
-
const
|
|
43
|
+
const l = c(
|
|
44
44
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: "false" },
|
|
45
|
-
|
|
45
|
+
o
|
|
46
46
|
);
|
|
47
|
-
|
|
47
|
+
o.edges.push(l);
|
|
48
48
|
},
|
|
49
49
|
serialize() {
|
|
50
50
|
return r.serialize({
|
|
@@ -58,16 +58,16 @@ const r = {
|
|
|
58
58
|
key: i.key ?? m(i.name),
|
|
59
59
|
name: i.name,
|
|
60
60
|
fields: i.fields ?? [],
|
|
61
|
-
addField(
|
|
62
|
-
const t = "serialize" in
|
|
61
|
+
addField(o) {
|
|
62
|
+
const t = "serialize" in o ? o : y(o);
|
|
63
63
|
return this.fields.includes(t) || this.fields.push(t), t;
|
|
64
64
|
}
|
|
65
|
-
}), z = (i,
|
|
65
|
+
}), z = (i, o) => {
|
|
66
66
|
const t = {
|
|
67
67
|
id: i.id ?? h("step"),
|
|
68
68
|
key: i.key ?? m(i.name),
|
|
69
69
|
name: i.name,
|
|
70
|
-
experience:
|
|
70
|
+
experience: o,
|
|
71
71
|
fields: i.fields ?? [],
|
|
72
72
|
node: null,
|
|
73
73
|
nextStep(s) {
|
|
@@ -91,14 +91,14 @@ const r = {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
return p({ step: t, type: "step" },
|
|
95
|
-
}, p = (i,
|
|
94
|
+
return p({ step: t, type: "step" }, o), t;
|
|
95
|
+
}, p = (i, o) => {
|
|
96
96
|
const t = {
|
|
97
97
|
id: h("node"),
|
|
98
|
-
experience:
|
|
98
|
+
experience: o
|
|
99
99
|
};
|
|
100
100
|
if (i.type === "step") {
|
|
101
|
-
const
|
|
101
|
+
const l = {
|
|
102
102
|
...t,
|
|
103
103
|
type: "step",
|
|
104
104
|
connectedStep: i.step,
|
|
@@ -111,10 +111,10 @@ const r = {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
return
|
|
114
|
+
return l.connectedStep.node = l, l;
|
|
115
115
|
}
|
|
116
116
|
if (i.type === "conditional") {
|
|
117
|
-
const
|
|
117
|
+
const l = {
|
|
118
118
|
...t,
|
|
119
119
|
type: "conditional",
|
|
120
120
|
connectedConditional: i.conditional,
|
|
@@ -126,7 +126,7 @@ const r = {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
|
-
return
|
|
129
|
+
return l.connectedConditional.node = l, l;
|
|
130
130
|
}
|
|
131
131
|
return i.type === "experience" ? {
|
|
132
132
|
...t,
|
|
@@ -149,12 +149,12 @@ const r = {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
}, c = (i,
|
|
152
|
+
}, c = (i, o) => ({
|
|
153
153
|
id: h("edge"),
|
|
154
154
|
sourceNode: i.sourceNode,
|
|
155
155
|
sourceNodeHandle: i.sourceNodeHandle,
|
|
156
156
|
destinationNode: i.destinationNode,
|
|
157
|
-
experience:
|
|
157
|
+
experience: o,
|
|
158
158
|
serialize() {
|
|
159
159
|
return r.serialize({
|
|
160
160
|
id: this.id,
|
|
@@ -163,30 +163,30 @@ const r = {
|
|
|
163
163
|
destinationNodeId: this.destinationNode.id
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
}), g = (i,
|
|
166
|
+
}), g = (i, o) => {
|
|
167
167
|
const t = {
|
|
168
168
|
id: h("conditional"),
|
|
169
169
|
label: i.label,
|
|
170
170
|
condition: i.condition,
|
|
171
171
|
node: null,
|
|
172
|
-
experience:
|
|
172
|
+
experience: o,
|
|
173
173
|
addTrue(s) {
|
|
174
174
|
if (!this.node || !s.node)
|
|
175
175
|
throw new Error("todo no node");
|
|
176
|
-
const
|
|
176
|
+
const l = c(
|
|
177
177
|
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
|
|
178
178
|
this.experience
|
|
179
179
|
);
|
|
180
|
-
this.experience.edges.push(
|
|
180
|
+
this.experience.edges.push(l);
|
|
181
181
|
},
|
|
182
182
|
addFalse(s) {
|
|
183
183
|
if (!this.node || !s.node)
|
|
184
184
|
throw new Error("todo no node");
|
|
185
|
-
const
|
|
185
|
+
const l = c(
|
|
186
186
|
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
|
|
187
187
|
this.experience
|
|
188
188
|
);
|
|
189
|
-
this.experience.edges.push(
|
|
189
|
+
this.experience.edges.push(l);
|
|
190
190
|
},
|
|
191
191
|
serialize() {
|
|
192
192
|
return r.serialize({
|
|
@@ -196,7 +196,7 @@ const r = {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
-
return p({ conditional: t, type: "conditional" },
|
|
199
|
+
return p({ conditional: t, type: "conditional" }, o), t;
|
|
200
200
|
}, y = (i) => ({
|
|
201
201
|
id: i.id ?? h("field"),
|
|
202
202
|
key: i.key ?? m(i.name),
|
|
@@ -230,7 +230,7 @@ const r = {
|
|
|
230
230
|
validation: this.validation,
|
|
231
231
|
condition: this.condition,
|
|
232
232
|
policies: this.policies
|
|
233
|
-
}, s = typeof this.defaultValue == "string" ? this.defaultValue : void 0,
|
|
233
|
+
}, s = typeof this.defaultValue == "string" ? this.defaultValue : void 0, l = typeof this.defaultValue == "number" ? this.defaultValue : void 0, f = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
|
|
234
234
|
switch (this.type) {
|
|
235
235
|
case "text":
|
|
236
236
|
if (this.multiple) {
|
|
@@ -292,7 +292,7 @@ const r = {
|
|
|
292
292
|
...t,
|
|
293
293
|
type: "number",
|
|
294
294
|
multiple: !1,
|
|
295
|
-
defaultValue:
|
|
295
|
+
defaultValue: l,
|
|
296
296
|
options: this.options ? this.options.map((e) => ({
|
|
297
297
|
id: e.id,
|
|
298
298
|
label: e.label,
|
|
@@ -365,7 +365,7 @@ const r = {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}), E = (i) => {
|
|
368
|
-
const
|
|
368
|
+
const o = [], t = [], s = [], l = [], f = [];
|
|
369
369
|
return {
|
|
370
370
|
id: i.id,
|
|
371
371
|
component: i.component,
|
|
@@ -373,66 +373,70 @@ const r = {
|
|
|
373
373
|
initializeOpen: i.initializeOpen,
|
|
374
374
|
condition: i.condition,
|
|
375
375
|
targets: i.targets,
|
|
376
|
-
steps:
|
|
376
|
+
steps: o,
|
|
377
377
|
nodes: t,
|
|
378
378
|
edges: s,
|
|
379
379
|
fields: f,
|
|
380
|
-
conditionals:
|
|
380
|
+
conditionals: l,
|
|
381
381
|
addStep(e, n) {
|
|
382
|
-
let
|
|
383
|
-
this.nodes.length === 0 && (
|
|
384
|
-
|
|
385
|
-
if (
|
|
386
|
-
|
|
382
|
+
let a = n?.node;
|
|
383
|
+
this.nodes.length === 0 && (a = p({ type: "origin" }, this), this.nodes.push(a));
|
|
384
|
+
let d = "serialize" in e ? e : z(e, this);
|
|
385
|
+
if (d = {
|
|
386
|
+
...d,
|
|
387
|
+
id: d.id ?? h("step"),
|
|
388
|
+
key: d.key ?? m(d.name)
|
|
389
|
+
}, a) {
|
|
390
|
+
if (!d.node)
|
|
387
391
|
throw new Error("todo no node");
|
|
388
392
|
const u = c(
|
|
389
|
-
{ sourceNode:
|
|
393
|
+
{ sourceNode: a, destinationNode: d.node, sourceNodeHandle: null },
|
|
390
394
|
this
|
|
391
395
|
);
|
|
392
396
|
this.edges.push(u);
|
|
393
397
|
}
|
|
394
|
-
return
|
|
398
|
+
return d.fields.length > 0 && d.fields.forEach((u) => {
|
|
395
399
|
this.fields.includes(u) || this.fields.push(u);
|
|
396
|
-
}), this.steps.includes(
|
|
400
|
+
}), this.steps.includes(d) || (this.steps.push(d), d.node && this.nodes.push(d.node)), d;
|
|
397
401
|
},
|
|
398
402
|
addAction(e, n) {
|
|
399
|
-
let
|
|
400
|
-
this.nodes.length === 0 && (
|
|
401
|
-
const
|
|
402
|
-
if (
|
|
403
|
+
let a = n?.node;
|
|
404
|
+
this.nodes.length === 0 && (a = p({ type: "origin" }, this), this.nodes.push(a));
|
|
405
|
+
const d = "serialize" in e ? e : N(e, this);
|
|
406
|
+
if (a) {
|
|
403
407
|
const u = c(
|
|
404
|
-
{ sourceNode:
|
|
408
|
+
{ sourceNode: a, destinationNode: d, sourceNodeHandle: null },
|
|
405
409
|
this
|
|
406
410
|
);
|
|
407
411
|
this.edges.push(u);
|
|
408
412
|
}
|
|
409
|
-
return this.nodes.push(
|
|
413
|
+
return this.nodes.push(d), d;
|
|
410
414
|
},
|
|
411
415
|
addConditional(e, n) {
|
|
412
|
-
let
|
|
413
|
-
this.nodes.length === 0 && (
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
if (!
|
|
416
|
+
let a = n?.node;
|
|
417
|
+
this.nodes.length === 0 && (a = p({ type: "origin" }, this), this.nodes.push(a));
|
|
418
|
+
const d = "serialize" in e ? e : g(e, this);
|
|
419
|
+
if (a) {
|
|
420
|
+
if (!d.node)
|
|
417
421
|
throw new Error("todo no node");
|
|
418
422
|
const u = c(
|
|
419
|
-
{ sourceNode:
|
|
423
|
+
{ sourceNode: a, destinationNode: d.node, sourceNodeHandle: null },
|
|
420
424
|
this
|
|
421
425
|
);
|
|
422
426
|
this.edges.push(u);
|
|
423
427
|
}
|
|
424
|
-
return this.conditionals.includes(
|
|
428
|
+
return this.conditionals.includes(d) || (this.conditionals.push(d), d.node && this.nodes.push(d.node)), d;
|
|
425
429
|
},
|
|
426
430
|
addExperience(e, n) {
|
|
427
|
-
let
|
|
428
|
-
this.nodes.length === 0 && (
|
|
429
|
-
const
|
|
431
|
+
let a = n?.node;
|
|
432
|
+
this.nodes.length === 0 && (a = p({ type: "origin" }, this), this.nodes.push(a));
|
|
433
|
+
const d = p(
|
|
430
434
|
{ type: "experience", experience: e },
|
|
431
435
|
this
|
|
432
436
|
);
|
|
433
|
-
if (this.nodes.push(
|
|
437
|
+
if (this.nodes.push(d), a) {
|
|
434
438
|
const u = c(
|
|
435
|
-
{ sourceNode:
|
|
439
|
+
{ sourceNode: a, destinationNode: d, sourceNodeHandle: null },
|
|
436
440
|
this
|
|
437
441
|
);
|
|
438
442
|
this.edges.push(u);
|
|
@@ -440,8 +444,8 @@ const r = {
|
|
|
440
444
|
return e;
|
|
441
445
|
},
|
|
442
446
|
addField(e, n) {
|
|
443
|
-
const
|
|
444
|
-
return n && n.fields.push(
|
|
447
|
+
const a = "serialize" in e ? e : y(e);
|
|
448
|
+
return n && n.fields.push(a), this.fields.includes(a) || this.fields.push(a), a;
|
|
445
449
|
},
|
|
446
450
|
serialize() {
|
|
447
451
|
return r.serialize({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as l } from "../../../api-
|
|
2
|
-
import { c as S } from "../../../api-
|
|
1
|
+
import { a as l } from "../../../api-B3JRgxph.js";
|
|
2
|
+
import { c as S } from "../../../api-B3JRgxph.js";
|
|
3
3
|
import { l as a } from "../../../logger-C9a75KZn.js";
|
|
4
4
|
function d(e) {
|
|
5
5
|
let r = 2166136261;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,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,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACV,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB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U,GAAI,aAAa,iBAAiB,KAAG,UAiB3D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,GAAG,UAAU,EAC3C,YAAY,sBAAsB,KACjC,gBAiCF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA0EF,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,uBA4CF,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EACzD,cAAc,kBAAkB,KAC/B,iBAAiB,CAAC,CAAC,CAoOrB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,uBAAuB,KAAG,
|
|
1
|
+
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,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,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACV,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACv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