@picked/client 0.0.55 → 0.0.56-next.2

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.
Files changed (65) hide show
  1. package/dist/{api-B1yTKITq.js → api-DHSz_ruC.js} +1 -1
  2. package/dist/api-DVSjNleu.cjs +1 -0
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/docs/actions.md +58 -0
  8. package/dist/docs/api/index.md +32 -0
  9. package/dist/docs/api-keys.md +33 -0
  10. package/dist/docs/conditions.md +52 -0
  11. package/dist/docs/experiences.md +33 -0
  12. package/dist/docs/features.md +51 -0
  13. package/dist/docs/fields.md +70 -0
  14. package/dist/docs/flow-builder/building-flows.md +61 -0
  15. package/dist/docs/flow-builder/condition-builder.md +54 -0
  16. package/dist/docs/flow-builder/keyboard-shortcuts.md +66 -0
  17. package/dist/docs/flow-builder/nodes.md +43 -0
  18. package/dist/docs/flow-builder/overview.md +43 -0
  19. package/dist/docs/index.md +79 -0
  20. package/dist/docs/pickedql/data-sources.md +39 -0
  21. package/dist/docs/pickedql/dimensions.md +23 -0
  22. package/dist/docs/pickedql/examples.md +165 -0
  23. package/dist/docs/pickedql/filtering.md +31 -0
  24. package/dist/docs/pickedql/index.md +34 -0
  25. package/dist/docs/pickedql/schema.md +95 -0
  26. package/dist/docs/pickedql/virtual-functions.md +84 -0
  27. package/dist/docs/projects.md +30 -0
  28. package/dist/docs/reference/index.md +11 -0
  29. package/dist/docs/reports.md +11 -0
  30. package/dist/docs/sdk/actions.md +7 -0
  31. package/dist/docs/sdk/conditions.md +131 -0
  32. package/dist/docs/sdk/content-security-policy.md +31 -0
  33. package/dist/docs/sdk/experiences.md +41 -0
  34. package/dist/docs/sdk/features.md +213 -0
  35. package/dist/docs/sdk/fields.md +263 -0
  36. package/dist/docs/sdk/index.md +74 -0
  37. package/dist/docs/sdk/plugins/create-experience.md +133 -0
  38. package/dist/docs/sdk/plugins/dynamic-experiences.md +59 -0
  39. package/dist/docs/sdk/plugins/index.md +9 -0
  40. package/dist/docs/sdk/plugins/window-object.md +20 -0
  41. package/dist/docs/sdk/predicates.md +113 -0
  42. package/dist/docs/sdk/steps.md +411 -0
  43. package/dist/docs/steps.md +35 -0
  44. package/dist/docs/team-management.md +40 -0
  45. package/dist/docs/tooling/chrome-extension.md +29 -0
  46. package/dist/docs/tooling/gtm-template.md +69 -0
  47. package/dist/docs/tooling/index.md +19 -0
  48. package/dist/docs/tooling/mcp.md +120 -0
  49. package/dist/docs/tooling/vite-plugin.md +82 -0
  50. package/dist/docs/workspaces.md +35 -0
  51. package/dist/esm/form/index.js +2 -2
  52. package/dist/esm/index.js +1 -1
  53. package/dist/esm/plugins/create-experience/index.js +1 -1
  54. package/dist/esm/plugins/dynamic-experiences/index.js +11 -2
  55. package/dist/types/entities/step/step.d.ts +1 -1
  56. package/dist/types/entities/step/step.d.ts.map +1 -1
  57. package/dist/types/form/create-field-evaluator.d.ts +5 -5
  58. package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
  59. package/dist/types/form/create-form.d.ts +7 -7
  60. package/dist/types/form/create-form.d.ts.map +1 -1
  61. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  62. package/dist/types/plugins/dynamic-experiences/types.d.ts +9 -1
  63. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/dist/api-DO5hnUsd.cjs +0 -1
@@ -8,7 +8,7 @@ function n(n, r) {
8
8
  }
9
9
  //#endregion
10
10
  //#region src/utils/version.ts
11
- var r = () => "0.0.55", i = "v1";
11
+ var r = () => "0.0.56-next.2", i = "v1";
12
12
  function a(e, t) {
13
13
  return new URL(`/api/${i}/${t}`, e).toString();
14
14
  }
@@ -0,0 +1 @@
1
+ var e=`Picked-Client`,t=`Picked-Version`;function n(n,r){return{[e]:n,[t]:r}}var r=()=>`0.0.56-next.2`,i=`v1`;function a(e,t){return new URL(`/api/${i}/${t}`,e).toString()}function o(e){return{...n(`sdk`,r()),...e}}async function s(e,t,n){let r=a(e,t);return fetch(r,{headers:o(n)})}async function c(e,t,n,r){let i=a(e,t);return fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...o(r)},body:JSON.stringify(n)})}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../rules-logic-D_dZ52-Q.cjs`);let t=require(`effector`);function n(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)&&Array.isArray(n)&&n.length>0){typeof r[0]==`string`?e[t]=[...r,...n].map(String):typeof r[0]==`number`?e[t]=[...r,...n].map(Number):typeof r[0]==`boolean`?e[t]=[...r,...n].map(e=>!!e):e[t]=n;return}e[t]=n}function r(e,t){let r=Array.from(t.entries()),i={};return e.forEach(e=>{let t=r.filter(([t])=>t===e.key);t.length===0&&(t=[[e.key,``]]),t.forEach(([,t])=>{if(t===``){n(i,e.key,null);return}switch(e.type){case`text`:case`object`:n(i,e.key,e.multiple?[String(t)]:String(t));break;case`number`:n(i,e.key,e.multiple?[Number(t)]:Number(t));break;case`boolean`:n(i,e.key,e.multiple?[t===`true`]:t===`true`);break}})}),i}function i(e){return Array.isArray(e.options)&&e.options.some(e=>`condition`in e)}function a(e){return e.some(e=>e.condition||i(e))}function o(e){return e.condition??null}async function s(t,n,r){return n.length===0||!a(n)?n:(await Promise.all(n.map(async n=>{let a=o(n);if(!(!a||await e.t(t,a,r)))return null;if(!Array.isArray(n.options)||!i(n))return n;let s=(await Promise.all(n.options.map(async n=>n.condition?await e.t(t,n.condition,r)?n:null:n))).filter(e=>e!==null);return s.length===n.options.length?n:s.length===0?null:{...n,options:s}}))).filter(e=>e!==null)}function c(e,n,r){let i=(0,t.createStore)([]),a=(0,t.attach)({source:{allFields:e.fields.listStore,fieldIds:n,staged:r,committed:e.responses.getAllStore},effect:(0,t.createEffect)(async({allFields:t,fieldIds:n,staged:r,committed:i})=>await s(e,t.filter(e=>n.includes(e.id)),{responses:{...i,...r}}))});return(0,t.sample)({clock:a.doneData,target:i}),a(),(0,t.sample)({clock:[e.responses.listStore,n,e.fields.listStore,r],target:a}),{fieldsStore:i}}function l(e){return e===null||e===``||Array.isArray(e)&&e.length===0}function u(n,r,i){let a=(0,t.createEvent)(),o=(0,t.createEvent)(),s=(0,t.createEvent)(),c=(0,t.createStore)({});(0,t.sample)({clock:s,source:c,fn:(e,{fieldKey:t})=>({...e,[t]:!0}),target:c});let u=(0,t.createStore)({}),d=u.map(e=>Object.values(e).filter(e=>e!==void 0)),f=(0,t.attach)({source:{fields:r,staged:i,committed:n.responses.getAllStore},effect:async({fields:t,staged:r,committed:i},{fieldKey:a,value:o,checkRequired:s})=>{let c=t.find(e=>e.key===a);if(!c)return{fieldKey:a,error:null};if(c.validation&&Object.keys(c.validation).length>0){let t={...i,...r},s=await e.t(n,c.validation,{responses:t,$input:o});if(typeof s==`string`)return{fieldKey:a,error:{fieldKey:c.key,userMessage:s,systemMessage:s,value:o}};if(s===!1)return{fieldKey:a,error:{fieldKey:c.key,userMessage:`This field is invalid`,systemMessage:`Field validation rule returned false.`,value:o}}}return s&&c.required&&l(o)?{fieldKey:a,error:{fieldKey:c.key,userMessage:`This field is required`,systemMessage:`Field is required.`,value:o}}:{fieldKey:a,error:null}}});return(0,t.sample)({clock:a,source:c,filter:(e,{fieldKey:t})=>e[t]===!0,fn:(e,{fieldKey:t,value:n})=>({fieldKey:t,value:n,checkRequired:!1}),target:f}),(0,t.sample)({clock:o,source:c,filter:(e,{fieldKey:t})=>e[t]===!0,fn:(e,{fieldKey:t,value:n})=>({fieldKey:t,value:n,checkRequired:!1}),target:f}),(0,t.sample)({clock:s,fn:({fieldKey:e,value:t})=>({fieldKey:e,value:t,checkRequired:!0}),target:f}),i.on(a,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),i.on(o,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),i.on(s,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),u.on(f.doneData,(e,{fieldKey:t,error:n})=>{if(n===null){let n={...e};return delete n[t],n}return{...e,[t]:n}}),{fieldInputEvent:a,fieldChangeEvent:o,fieldBlurEvent:s,touchedStore:c,fieldErrorsStore:u,formErrorsStore:d,stagedValuesStore:i}}function d(e){let n=[];return{executeFx:(0,t.createEffect)(async(...t)=>await e(n,...t)),register:e=>(n.push(e),()=>{n=n.filter(t=>t!==e)})}}function f({client:e,experienceInstance:n,formId:i,title:a,stepStore:o,fieldsStore:s,goToNextStep:c}){let l=(0,t.createEvent)(),u=(0,t.createEvent)(),f=(0,t.createEvent)(),p=(0,t.createEvent)(),m=(0,t.createEvent)(),h=(0,t.createStore)(!1),g=(0,t.createStore)(!1);g.on(p,()=>!0).on(l,()=>!1);let _=l.map(()=>void 0),v=d(async(e,t)=>{await Promise.all(e.map(e=>Promise.resolve(e(t))))}),y=d(async(e,t)=>{await Promise.all(e.map(e=>Promise.resolve(e(t))))}),b=d(async(e,t)=>{let n=t;for(let t of e){let e=await Promise.resolve(t(n));e!==void 0&&(n=e)}return n}),x=(0,t.createEffect)(async t=>({data:t,errors:(await e.responses.commit(t)).errors})),S=(0,t.attach)({source:{step:o,title:a},mapParams:(e,t)=>({step:t.step,title:t.title,data:e.data}),effect:(0,t.createEffect)(async({step:t,title:r,data:a})=>(e.eventBus({type:`form_submit_success`,form:{id:i,title:r},experience:n,step:t??void 0}),a))}),C=(0,t.attach)({source:{step:o,title:a},mapParams:(e,t)=>({step:t.step,title:t.title,errors:e.errors}),effect:(0,t.createEffect)(async({step:t,title:r,errors:a})=>(e.eventBus({type:`form_submit_error`,form:{id:i,title:r},exception:{reason:a},experience:n,step:t??void 0}),a.forEach(r=>{e.eventBus({type:`field_validation_error`,exception:{reason:[r]},experience:n,step:t??void 0})}),a))});return(0,t.sample)({clock:l,fn:()=>!0,target:h}),(0,t.sample)({clock:l,source:{step:o,title:a},fn:({step:e,title:t})=>({formId:i,title:t,step:e}),target:(0,t.createEffect)(({formId:t,title:r,step:i})=>{e.eventBus({type:`form_submit`,form:{id:t,title:r},experience:n,step:i??void 0})})}),(0,t.sample)({clock:l,source:{stepFields:s},fn:({stepFields:e},t)=>(t.preventDefault(),r(e,new FormData(t.currentTarget))),target:b.executeFx}),(0,t.sample)({clock:b.executeFx.doneData,target:x}),(0,t.split)({source:x.doneData,match:{hasErrors:({errors:e})=>e.length>0},cases:{hasErrors:C,__:S}}),(0,t.sample)({clock:S.doneData,target:u}),(0,t.sample)({clock:u,fn:e=>({data:e,stopNavigation:p}),target:v.executeFx}),(0,t.sample)({clock:v.executeFx.done,target:m}),(0,t.sample)({clock:m,source:g,filter:e=>!e,target:c}),(0,t.sample)({clock:C.doneData,target:f}),(0,t.sample)({clock:f,target:y.executeFx}),(0,t.sample)({clock:[m,y.executeFx.done],fn:()=>!1,target:h}),{submitEvent:l,isFormSubmitting:h,onBeforeSubmit:b.register,onSuccess:v.register,onError:y.register,submitStarted:_,validationErrorsReceived:f}}function p(e){let t=e.currentTarget;if(t instanceof HTMLInputElement)return t.type===`checkbox`?t.checked:t.value;if(t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return t.value}function m(e,n,r,i){let{client:a,experienceInstance:o}=e,{currentStepStore:s,goToNextStep:l}=o,d=(0,t.combine)(s,o,(e,t)=>({stepId:e?.id,experienceId:t.id})),m=(0,t.createStore)({}),{fieldsStore:h}=c(a,i,m);(0,t.sample)({clock:h,source:m,fn:(e,t)=>{let n=!1,r={...e};for(let e of t)e.defaultValue!=null&&!(e.key in r)&&(r[e.key]=e.defaultValue,n=!0);return n?r:e},target:m});let{fieldInputEvent:g,fieldChangeEvent:_,fieldBlurEvent:v,touchedStore:y,fieldErrorsStore:b,formErrorsStore:x}=u(a,h,m),S=(0,t.combine)({fields:h,responses:a.responses.listStore,staged:m,fieldErrors:b,touched:y,experienceAndStepId:d},({fields:e,responses:t,staged:n,fieldErrors:r,touched:i,experienceAndStepId:a})=>e.map(e=>{let o=t=>{let n=p(t);n!==void 0&&g({fieldKey:e.key,value:n})},s=t=>{let n=p(t);n!==void 0&&_({fieldKey:e.key,value:n})},c=t=>{let n=p(t);n!==void 0&&v({fieldKey:e.key,value:n})},l=n[e.key]??t.find(t=>t.fieldKey===e.key)?.value??e.defaultValue,u=r[e.key],d=e.type===`number`?`number`:`text`,f=e.type===`boolean`?`checkbox`:d,{experienceId:m,stepId:h}=a,y=`${m}-${h??`step`}-${e.id}`;return{...e,value:l,error:u,touched:i[e.key]??!1,props:{id:y,name:e.key,key:e.key,value:l,type:f,required:e.required,placeholder:e.placeholder,oninput:o,onchange:s,onblur:c}}})),{submitEvent:C,isFormSubmitting:w,onBeforeSubmit:T,onSuccess:E,onError:D,submitStarted:O,validationErrorsReceived:k}=f({client:a,experienceInstance:o,formId:n,title:r,stepStore:s,fieldsStore:h,goToNextStep:l});return(0,t.sample)({clock:O,fn:()=>({}),target:y}),(0,t.sample)({clock:O,fn:()=>({}),target:b}),(0,t.sample)({clock:k,source:h,fn:(e,t)=>Object.fromEntries(t.map(t=>[e.find(e=>e.key===t.fieldKey)?.key??t.fieldKey,t])),target:b}),{form:{props:{onsubmit:C},errors:x,submitting:w,onBeforeSubmit:T,onSuccess:E,onError:D},fields:S}}exports.buildResponsesFromFormData=r,exports.createFieldEvaluator=c,exports.createFieldValidation=u,exports.createForm=m,exports.createSubmitPipeline=f,exports.getEventValue=p,exports.getStepFields=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../rules-logic-D_dZ52-Q.cjs`);let t=require(`effector`);function n(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)&&Array.isArray(n)&&n.length>0){typeof r[0]==`string`?e[t]=[...r,...n].map(String):typeof r[0]==`number`?e[t]=[...r,...n].map(Number):typeof r[0]==`boolean`?e[t]=[...r,...n].map(e=>!!e):e[t]=n;return}e[t]=n}function r(e,t){let r=Array.from(t.entries()),i={};return e.forEach(e=>{let t=r.filter(([t])=>t===e.key);t.length===0&&(t=[[e.key,``]]),t.forEach(([,t])=>{if(t===``){n(i,e.key,null);return}switch(e.type){case`text`:case`object`:n(i,e.key,e.multiple?[String(t)]:String(t));break;case`number`:n(i,e.key,e.multiple?[Number(t)]:Number(t));break;case`boolean`:n(i,e.key,e.multiple?[t===`true`]:t===`true`);break}})}),i}function i(e){return Array.isArray(e.options)&&e.options.some(e=>`condition`in e)}function a(e){return e.some(e=>e.condition||i(e))}function o(e){return e.condition??null}async function s(t,n,r){return n.length===0||!a(n)?n:(await Promise.all(n.map(async n=>{let a=o(n);if(!(!a||await e.t(t,a,r)))return null;if(!Array.isArray(n.options)||!i(n))return n;let s=(await Promise.all(n.options.map(async n=>n.condition?await e.t(t,n.condition,r)?n:null:n))).filter(e=>e!==null);return s.length===n.options.length?n:s.length===0?null:{...n,options:s}}))).filter(e=>e!==null)}function c(e,n,r){let i=(0,t.createStore)([]),a=(0,t.attach)({source:{allFields:e.fields.listStore,fieldKeys:n,staged:r,committed:e.responses.getAllStore},effect:(0,t.createEffect)(async({allFields:t,fieldKeys:n,staged:r,committed:i})=>await s(e,t.filter(e=>n.includes(e.key)),{responses:{...i,...r}}))});return(0,t.sample)({clock:a.doneData,target:i}),a(),(0,t.sample)({clock:[e.responses.listStore,n,e.fields.listStore,r],target:a}),{fieldsStore:i}}function l(e){return e===null||e===``||Array.isArray(e)&&e.length===0}function u(n,r,i){let a=(0,t.createEvent)(),o=(0,t.createEvent)(),s=(0,t.createEvent)(),c=(0,t.createStore)({});(0,t.sample)({clock:s,source:c,fn:(e,{fieldKey:t})=>({...e,[t]:!0}),target:c});let u=(0,t.createStore)({}),d=u.map(e=>Object.values(e).filter(e=>e!==void 0)),f=(0,t.attach)({source:{fields:r,staged:i,committed:n.responses.getAllStore},effect:async({fields:t,staged:r,committed:i},{fieldKey:a,value:o,checkRequired:s})=>{let c=t.find(e=>e.key===a);if(!c)return{fieldKey:a,error:null};if(c.validation&&Object.keys(c.validation).length>0){let t={...i,...r},s=await e.t(n,c.validation,{responses:t,$input:o});if(typeof s==`string`)return{fieldKey:a,error:{fieldKey:c.key,userMessage:s,systemMessage:s,value:o}};if(s===!1)return{fieldKey:a,error:{fieldKey:c.key,userMessage:`This field is invalid`,systemMessage:`Field validation rule returned false.`,value:o}}}return s&&c.required&&l(o)?{fieldKey:a,error:{fieldKey:c.key,userMessage:`This field is required`,systemMessage:`Field is required.`,value:o}}:{fieldKey:a,error:null}}});return(0,t.sample)({clock:a,source:c,filter:(e,{fieldKey:t})=>e[t]===!0,fn:(e,{fieldKey:t,value:n})=>({fieldKey:t,value:n,checkRequired:!1}),target:f}),(0,t.sample)({clock:o,source:c,filter:(e,{fieldKey:t})=>e[t]===!0,fn:(e,{fieldKey:t,value:n})=>({fieldKey:t,value:n,checkRequired:!1}),target:f}),(0,t.sample)({clock:s,fn:({fieldKey:e,value:t})=>({fieldKey:e,value:t,checkRequired:!0}),target:f}),i.on(a,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),i.on(o,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),i.on(s,(e,{fieldKey:t,value:n})=>({...e,[t]:n})),u.on(f.doneData,(e,{fieldKey:t,error:n})=>{if(n===null){let n={...e};return delete n[t],n}return{...e,[t]:n}}),{fieldInputEvent:a,fieldChangeEvent:o,fieldBlurEvent:s,touchedStore:c,fieldErrorsStore:u,formErrorsStore:d,stagedValuesStore:i}}function d(e){let n=[];return{executeFx:(0,t.createEffect)(async(...t)=>await e(n,...t)),register:e=>(n.push(e),()=>{n=n.filter(t=>t!==e)})}}function f({client:e,experienceInstance:n,formId:i,title:a,stepStore:o,fieldsStore:s,goToNextStep:c}){let l=(0,t.createEvent)(),u=(0,t.createEvent)(),f=(0,t.createEvent)(),p=(0,t.createEvent)(),m=(0,t.createEvent)(),h=(0,t.createStore)(!1),g=(0,t.createStore)(!1);g.on(p,()=>!0).on(l,()=>!1);let _=l.map(()=>void 0),v=d(async(e,t)=>{await Promise.all(e.map(e=>Promise.resolve(e(t))))}),y=d(async(e,t)=>{await Promise.all(e.map(e=>Promise.resolve(e(t))))}),b=d(async(e,t)=>{let n=t;for(let t of e){let e=await Promise.resolve(t(n));e!==void 0&&(n=e)}return n}),x=(0,t.createEffect)(async t=>({data:t,errors:(await e.responses.commit(t)).errors})),S=(0,t.attach)({source:{step:o,title:a},mapParams:(e,t)=>({step:t.step,title:t.title,data:e.data}),effect:(0,t.createEffect)(async({step:t,title:r,data:a})=>(e.eventBus({type:`form_submit_success`,form:{id:i,title:r},experience:n,step:t??void 0}),a))}),C=(0,t.attach)({source:{step:o,title:a},mapParams:(e,t)=>({step:t.step,title:t.title,errors:e.errors}),effect:(0,t.createEffect)(async({step:t,title:r,errors:a})=>(e.eventBus({type:`form_submit_error`,form:{id:i,title:r},exception:{reason:a},experience:n,step:t??void 0}),a.forEach(r=>{e.eventBus({type:`field_validation_error`,exception:{reason:[r]},experience:n,step:t??void 0})}),a))});return(0,t.sample)({clock:l,fn:()=>!0,target:h}),(0,t.sample)({clock:l,source:{step:o,title:a},fn:({step:e,title:t})=>({formId:i,title:t,step:e}),target:(0,t.createEffect)(({formId:t,title:r,step:i})=>{e.eventBus({type:`form_submit`,form:{id:t,title:r},experience:n,step:i??void 0})})}),(0,t.sample)({clock:l,source:{stepFields:s},fn:({stepFields:e},t)=>(t.preventDefault(),r(e,new FormData(t.currentTarget))),target:b.executeFx}),(0,t.sample)({clock:b.executeFx.doneData,target:x}),(0,t.split)({source:x.doneData,match:{hasErrors:({errors:e})=>e.length>0},cases:{hasErrors:C,__:S}}),(0,t.sample)({clock:S.doneData,target:u}),(0,t.sample)({clock:u,fn:e=>({data:e,stopNavigation:p}),target:v.executeFx}),(0,t.sample)({clock:v.executeFx.done,target:m}),(0,t.sample)({clock:m,source:g,filter:e=>!e,target:c}),(0,t.sample)({clock:C.doneData,target:f}),(0,t.sample)({clock:f,target:y.executeFx}),(0,t.sample)({clock:[m,y.executeFx.done],fn:()=>!1,target:h}),{submitEvent:l,isFormSubmitting:h,onBeforeSubmit:b.register,onSuccess:v.register,onError:y.register,submitStarted:_,validationErrorsReceived:f}}function p(e){let t=e.currentTarget;if(t instanceof HTMLInputElement)return t.type===`checkbox`?t.checked:t.value;if(t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return t.value}function m(e,n,r,i){let{client:a,experienceInstance:o}=e,{currentStepStore:s,goToNextStep:l}=o,d=(0,t.combine)(s,o,(e,t)=>({stepId:e?.id,experienceId:t.id})),m=(0,t.createStore)({}),{fieldsStore:h}=c(a,i,m);(0,t.sample)({clock:h,source:m,fn:(e,t)=>{let n=!1,r={...e};for(let e of t)e.defaultValue!=null&&!(e.key in r)&&(r[e.key]=e.defaultValue,n=!0);return n?r:e},target:m});let{fieldInputEvent:g,fieldChangeEvent:_,fieldBlurEvent:v,touchedStore:y,fieldErrorsStore:b,formErrorsStore:x}=u(a,h,m),S=(0,t.combine)({fields:h,responses:a.responses.listStore,staged:m,fieldErrors:b,touched:y,experienceAndStepId:d},({fields:e,responses:t,staged:n,fieldErrors:r,touched:i,experienceAndStepId:a})=>e.map(e=>{let o=t=>{let n=p(t);n!==void 0&&g({fieldKey:e.key,value:n})},s=t=>{let n=p(t);n!==void 0&&_({fieldKey:e.key,value:n})},c=t=>{let n=p(t);n!==void 0&&v({fieldKey:e.key,value:n})},l=n[e.key]??t.find(t=>t.fieldKey===e.key)?.value??e.defaultValue,u=r[e.key],d=e.type===`number`?`number`:`text`,f=e.type===`boolean`?`checkbox`:d,{experienceId:m,stepId:h}=a,y=`${m}-${h??`step`}-${e.id}`;return{...e,value:l,error:u,touched:i[e.key]??!1,props:{id:y,name:e.key,key:e.key,value:l,type:f,required:e.required,placeholder:e.placeholder,oninput:o,onchange:s,onblur:c}}})),{submitEvent:C,isFormSubmitting:w,onBeforeSubmit:T,onSuccess:E,onError:D,submitStarted:O,validationErrorsReceived:k}=f({client:a,experienceInstance:o,formId:n,title:r,stepStore:s,fieldsStore:h,goToNextStep:l});return(0,t.sample)({clock:O,fn:()=>({}),target:y}),(0,t.sample)({clock:O,fn:()=>({}),target:b}),(0,t.sample)({clock:k,source:h,fn:(e,t)=>Object.fromEntries(t.map(t=>[e.find(e=>e.key===t.fieldKey)?.key??t.fieldKey,t])),target:b}),{form:{props:{onsubmit:C},errors:x,submitting:w,onBeforeSubmit:T,onSuccess:E,onError:D},fields:S}}exports.buildResponsesFromFormData=r,exports.createFieldEvaluator=c,exports.createFieldValidation=u,exports.createForm=m,exports.createSubmitPipeline=f,exports.getEventValue=p,exports.getStepFields=s;
package/dist/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../rules-logic-D_dZ52-Q.cjs`),t=require(`../object-CUJOjanb.cjs`),n=require(`../logger-fbvQC40v.cjs`),r=require(`../supports-Dsjg-82e.cjs`),i=require(`../experience-instance-DG9HFNSE.cjs`),a=require(`../storage-B6lQtc4-.cjs`),o=require(`../api-DO5hnUsd.cjs`),s=require(`../id-Bv44ilEo.cjs`);let c=require(`effector`),l=require(`@withease/factories`);var u=(0,c.createDomain)(`experience`),d=(0,l.createFactory)(({client:e,experience:t})=>{let n=u.store(t),r=(0,c.createApi)(n,{merge(e,t){return{...e,...t.experience}}}),a=n.map(e=>({name:e.name,decisionLogic:e.condition,targetSelectors:e.targets,initializeOpenLogic:e.initializeOpen})),o=(0,c.combine)(n,e.components.listStore,(e,t)=>(e.componentName?t.find(t=>t.name===e.componentName):void 0)||t.find(t=>t.name===`experience:${e.id}`)||t.find(e=>e.name===`experience`),{skipVoid:!1}),s=(0,c.combine)(n,e.steps.indexStore,e.conditions.indexStore,(e,t,n)=>{let r=e.nodes.filter(i.i).map(e=>t[e.stepId]).filter(e=>e!==void 0),a=e.nodes.filter(i.r).map(e=>n[e.conditionId]).filter(e=>e!==void 0);return{steps:r,nodes:e.nodes,edges:e.edges,conditions:a}}),l=t.actions??[];return{id:t.id,key:t.key,name:t.name,configStore:a,treeStore:s,componentStore:o,actions:l,merge:r.merge}});function f(e){return(0,l.invoke)(d,e)}var p=(0,l.createFactory)(({client:e})=>{let t=u.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.id]:t}}});function r(r){let i=t.getState()[r.id];if(i){i.merge({experience:r,strategy:`override`});return}let a=f({client:e,experience:r});n.register(a)}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}function o(e){return t.map(t=>Object.values(t).find(t=>t.key===e)??t[e],{skipVoid:!1})}let s=(0,c.attach)({source:t,effect:async(t,n)=>{let r=`key`in n?Object.values(t).find(e=>e.key===n.key):t[n.id];if(!r){`key`in n?`${n.key}`:`${n.id}`;return}let{options:i}=n;if(i?.bypassCondition){h(e,r,i);return}await _(e,r)&&h(e,r,i)}});return{register:r,get:a,getById:a,getByKey:o,launch:s,open:(0,c.attach)({source:{experiences:t,instances:e.experienceInstances.listStore},effect:({experiences:e,instances:t},n)=>{let r=`key`in n?Object.values(e).find(e=>e.key===n.key):e[n.id],i=t.filter(e=>r&&e.experienceId===r.id);if(i.length>0)for(let e of i)e.open();else s(`key`in n?{key:n.key,options:{...n.options,initialiseOpen:!0}}:{id:n.id,options:{...n.options,initialiseOpen:!0}})}}),listStore:i}});function m(e){return(0,l.invoke)(p,e)}var h=(e,t,n)=>{let{targetSelectors:r}=t.configStore.getState(),a=i.s(r,t.id);a.forEach(({elements:e})=>e.forEach(e=>i.l(e,t.id))),i.a(a,t.id,t.key).forEach(r=>{n?e.experienceInstances.spawn(t,r,n):e.experienceInstances.spawn(t,r)})},g=async e=>{await Promise.all(e.experiences.listStore.getState().map(async t=>{await _(e,t)&&h(e,t)}))},_=async(t,n)=>{if(!t.preconditionPassed||!t.session?.isUser)return!1;let{decisionLogic:r,targetSelectors:a}=n.configStore.getState();return i.s(a,n.id).length<1||a.length===0?!1:r===void 0?!0:e.n(r)?await e.t(t,r)===!0:!0},v=(e,t,n)=>{let r=t.name,i=t.setup(e);if(i){let e=n[r]??{};n[r]=Object.freeze({...e,...i})}},ee=(0,c.createDomain)(`component`),y=(0,l.createFactory)(({client:e,component:t,name:n})=>({name:n,component:t,frameworkStore:e.frameworks.getByName(t.frameworkName)}));function b(e){return(0,l.invoke)(y,e)}var x=(0,l.createFactory)(({client:e})=>{let t=ee.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:t}}});function r(r,i){t.getState()[r]&&`${r}`;let a=b({client:e,name:r,component:i});n.register(a)}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}return{register:r,getByName:a,listStore:i}});function S(e){return(0,l.invoke)(x,e)}var C=(e,t,n)=>{n.register(e,t)},te=(0,c.createDomain)(`framework`),ne=(0,l.createFactory)(({client:e})=>{let t=te.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:t.framework}}});function r(e,r){t.getState()[e]&&`${e}`,n.register({name:e,framework:r})}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}return{register:r,getByName:a,listStore:i}});function re(e){return(0,l.invoke)(ne,e)}var ie=(e,t)=>{t.register(e.name,e)},ae=6e3,oe=a.t(`last_ping`,`global`),se=async e=>{try{let t=Date.now(),n=a.n.get(oe),r=0;if(n.isSet()&&(r=n.json()??0),r&&t-r<ae)return!0;let i={projectId:e.projectId,path:window.location.pathname},s={},c=document.getElementById(`picked_script`)?.dataset.verceltoken;c&&(s[`x-vercel-protection-bypass`]=c);let l=(await o.n(e.apiUrl,`ping`,i,s)).ok;return l&&n.set(t),l}catch{return!1}};function w(e){let t=typeof window<`u`,n={client:e,responses:e.responses.listStore.getState(),fields:e.fields.listStore.getState(),location:t?window.location:void 0,document:t?window.document:void 0,sessionStorage:t?window.sessionStorage:void 0,localStorage:t?window.localStorage:void 0};return Object.freeze(n)}var T=(0,c.createDomain)(`predicate`),E=(0,l.createFactory)(({client:e})=>{let t=T.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:{name:t.name,predicate:t.predicate}}}});function r(e,r){t.getState()[e]&&`${e}`,n.register(Object.freeze({name:e,predicate:r}))}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e]?.predicate,{skipVoid:!1})}function o(t){let n=(0,c.createStore)(()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let n=a(t).getState();if(!n)return;let r=w(e);return(...e)=>n({...r,args:e})});return(0,c.sample)({source:{responses:e.responses.listStore,fields:e.fields.listStore},target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:n}),r(),n}return{register:r,getByName:a,listStore:i,getEvokablePredicate:o}});function D(e){return(0,l.invoke)(E,e)}var O=(e,t,n)=>{n.register(e,t)},k=(0,c.createDomain)(`feature`),A=(0,l.createFactory)(({client:e})=>{let t=k.store({}),n=k.store([]),r=(0,c.createApi)(t,{register(e,t){return{...e,[t.id]:t.feature}}});function i(e,n){t.getState()[e]&&`${e}`;let i={id:e,feature:{...n,id:e}};r.register(Object.freeze({id:e,feature:i}))}let o=(0,c.createEffect)(async({id:e,key:t,storage:n=`local`})=>{let r=a.t(`feature:${e}:${t}`,`global`),i=(n===`session`?a.r:a.n).get(r).boolean();return i===null?null:{id:e,key:t,bucket:i,storage:n}}),s=(0,c.createEffect)(e=>{if(!e)return null;let t=a.t(`feature:${e.id}:${e.key}`,`global`);(e.storage===`session`?a.r:a.n).set(t,e.bucket)}),l=new Map,u=(0,c.attach)({source:{allFeaturesStore:t,resolvedFeaturesStore:n},effect:async({allFeaturesStore:e,resolvedFeaturesStore:t},{id:n,decide:r,key:i})=>{let a=t.find(e=>e.id===n&&e.key===i);if(a)return a;let o=e[n];if(!o)throw Error(`Feature with id '${n}' not found`);let s=l.get(`${n}:${i}`);if(s!==void 0){let e=await s;return{id:o.id,bucket:e,key:i,storage:o.feature.storage}}let c=r();l.set(`${n}:${i}`,c);let u=await c;return{id:o.id,bucket:u,key:i,storage:o.feature.storage}}});(0,c.sample)({clock:r.register,fn:e=>{let{id:t,feature:n}=e;return{id:t,key:n.feature.key,storage:n.feature.storage}},target:o}),(0,c.sample)({source:t,clock:u.doneData,fn:(e,t)=>{let{id:n,bucket:r,storage:i}=t,a=e[n]?.feature.key;return a?{key:a,id:n,bucket:r,storage:i}:null},target:s});let d=(0,c.combine)({allFeaturesStore:t,resolvedFeaturesStore:n}).map(({allFeaturesStore:e,resolvedFeaturesStore:t})=>Object.values(e).map(e=>{let n=t.find(t=>t.id===e.id&&t.key===e.feature.key);return n?{id:e.id,name:e.feature.name,key:e.feature.key,getBucket:()=>({id:e.id,bucket:n.bucket}),isResolved:!0}:{id:e.id,name:e.feature.name,key:e.feature.key,getBucket:async()=>await u(e.feature),isResolved:!1}}));(0,c.sample)({clock:u.doneData,source:{resolvedFeatures:n},filter:({resolvedFeatures:e},{id:t,key:n})=>!e.some(e=>e.id===t&&e.key===n),fn:(e,t)=>t,target:e.eventBus.prepend(e=>({type:`feature_decide`,feature:e}))}),(0,c.sample)({clock:[o.doneData,u.doneData],source:n,fn:(e,t)=>!t||e.some(e=>e.id===t.id&&e.key===t.key)?e:[...e,t],target:n});function f(e){return d.map(t=>t.find(t=>t.id===e))}function p(e){return t.map(t=>t[e],{skipVoid:!1})}function m(e){let t=(0,c.createStore)(async()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let t=f(e).getState();if(t)return async()=>(await t.getBucket()).bucket});return(0,c.sample)({source:n,filter:t=>t.some(t=>t.id===e),target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:t}),r(),t}return{register:i,getById:f,getByName:p,listStore:d,getEvokableFeature:m}});function j(e){return(0,l.invoke)(A,e)}var M=(e,t,n)=>{n.register(e,t)},N=(0,c.createDomain)(`history`);function P(e,t){return{id:s.t(`history-entry-${Date.now()}-${Math.random()}}`),node:t,at:Date.now(),experienceId:e}}var F=(0,l.createFactory)(()=>{let e=N.store({entries:[]}),t=N.event(),n=N.event(),r=N.event(),a=N.event();e.on(t,(e,t)=>({entries:[...e.entries,P(t.experienceId,t.node)]})),e.on(n,(e,t)=>({entries:[...e.entries.slice(0,-1),P(t.experienceId,t.node)]})),e.on(a,(e,t)=>t);function o(e,t){let n={lastStepIndex:-1,secondLastStepIndex:-1};for(let r=e.length-1;r>=0;r--){let a=e[r],o=a?.node;if(!(!o||!i.i(o))&&!(t&&a.experienceId!==t))if(n.lastStepIndex===-1)n.lastStepIndex=r;else{n.secondLastStepIndex=r;break}}return n}return e.on(r,(e,t)=>{let{secondLastStepIndex:n}=o(e.entries,t.experienceId),r=n===-1?e.entries:e.entries.slice(0,n+1);return{...e,entries:r}}),{push:t,replace:n,back:r,restore:a,entriesStore:e.map(e=>e.entries)}});function I(){return(0,l.invoke)(F)}var L=0,R=e=>{let t=(0,c.createStore)([]);return(0,c.sample)({clock:e,source:t,fn:(e,t)=>[...e,{id:L++,at:new Date,payload:t}],target:t}),t},z=(0,c.createDomain)(`field`),B=(0,l.createFactory)(()=>{let e=z.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.field.id]:t.field}},updateByKey(e,t){let n=Object.values(e).find(e=>e.key===t.fieldKey);return n?{...e,[n.id]:Object.assign({},n,t.updates)}:e}});function n(e){t.register({field:e})}function r(n,r){let i=e.getState(),a=Object.values(i).find(e=>e.key===n)?.key;a&&t.updateByKey({fieldKey:a,updates:r})}let i=e.map(e=>Object.values(e));function a(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function o(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}function s(t){return e.map(e=>Object.values(e).find(e=>e.name===t)??null,{skipVoid:!1})}return{register:n,update:r,getById:a,getByKey:o,listStore:i,getByName:s}});function V(){return(0,l.invoke)(B)}var H=(0,c.createDomain)(`step`),U=(0,l.createFactory)(()=>{let e=H.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.step.id]:t.step}}});function n(e){t.register({step:e})}let r=e.map(e=>Object.values(e));function i(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function a(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}return{register:n,getById:i,getByKey:a,listStore:r,indexStore:e}});function W(){return(0,l.invoke)(U)}function G(e,t){t.register(e)}var K=(0,c.createDomain)(`action`),ce=(0,l.createFactory)(({client:e})=>{let t=K.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.key]:{key:t.key,action:t.action}}}});function r(e,r){t.getState()[e]&&`${e}`,n.register(Object.freeze({key:e,action:r}))}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e]?.action,{skipVoid:!1})}function o(t){let n=(0,c.createStore)(()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let n=a(t).getState();if(!n)return;let r=w(e);return(...e)=>n({...r,args:e})});return(0,c.sample)({source:{responses:e.responses.listStore,fields:e.fields.listStore},target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:n}),r(),n}return{register:r,getByKey:a,listStore:i,getEvokableAction:o}});function le(e){return(0,l.invoke)(ce,e)}var ue=(e,t,n)=>{n.register(e,t)};function q(e,t,n,r){return{fieldKey:e.key,userMessage:n,systemMessage:r,value:t}}function J(e){return e==null||e===``||Array.isArray(e)&&!e.length}function de(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null}function Y(e){try{return JSON.stringify(e),!0}catch{return!1}}function fe(e,t){return t.find(t=>t.key===e)??null}function pe(e,t){return e.multiple&&(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)?[t]:t}function me(e,t){if(e.type!==`object`||J(t))return null;if(e.multiple){if(!Array.isArray(t))return q(e,t,`This field expects multiple values`,`Field expects an array of objects.`);for(let n of t){if(typeof n!=`object`||!n)return q(e,t,`This field expects object values`,`Field expects an array of objects, but received non-object value.`);if(!Y(n))return q(e,t,`This field contains non-serializable data`,`Field value contains non-JSON-serializable data (functions, circular references, etc.).`)}return null}return Array.isArray(t)?q(e,t,`This field expects a single value`,`Field expects a single object, not an array.`):typeof t!=`object`||!t?q(e,t,`This field expects an object value`,`Field expects an object value.`):Y(t)?null:q(e,t,`This field contains non-serializable data`,`Field value contains non-JSON-serializable data (functions, circular references, etc.).`)}function he(e,t){if(!Array.isArray(e.options)||e.options.length===0)return null;let n=Array.isArray(t)?t:[t];if(e.type===`object`){let r=e.options.map(e=>JSON.stringify(e.value));return n.every(e=>r.includes(JSON.stringify(e)))?null:q(e,t,`This field expects a valid option`,`Field expects a valid option from the defined choices.`)}let r=e.options.map(e=>e.value);return n.every(e=>!de(e)||e===null?!1:r.includes(e))?null:q(e,t,`This field expects a valid option`,`Field expects a valid option. Valid options are: ${r.join(`, `)}`)}async function ge(e,n,r,i){if(n.validation&&!t.t(n.validation)&&!J(r)){let t=i?{$input:r,responses:i}:{$input:r},a=await e(n.validation,t);if(typeof a==`string`)return q(n,r,a,`Field validation resulted in an error: ${a}.`);if(a===!1)return q(n,r,`This field is invalid`,`Field validation resulted in an unspecified error.`)}return n.required&&J(r)?q(n,r,`This field is required`,`Field is required.`):!n.multiple&&Array.isArray(r)&&r.length>1?q(n,r,`This field expects a single response`,`Field expects a single response.`):null}var _e=(0,c.createDomain)(`response`),ve=(0,l.createFactory)(({client:t})=>{let n=_e.store({}),r=(0,c.createEvent)(),i=(0,c.createEvent)(),a=(0,c.createApi)(n,{register(e,t){return{...e,[t.fieldKey]:t.response}},registerBatch(e,t){return{...e,...t}},clear(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))},clearAll(){return{}}});function o(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Response is required when registering a single field`);a.register({fieldKey:e,response:t})}else a.registerBatch(e)}let s=(n,r)=>e.t(t,n,r),l=(0,c.attach)({source:{allFields:t.fields.listStore,existingResponses:n},effect:async({allFields:e,existingResponses:t},n)=>{let r=[],i={},a={...t,...n},o=Object.entries(n),c=await Promise.allSettled(o.map(async([t,n])=>{let o=fe(t,e);if(!o){r.push({fieldKey:t,userMessage:`Field '${t}' not found`,systemMessage:`No field with key '${t}' exists. Available field keys are: ${e.map(e=>e.key).join(`,`)}.`,value:n});return}let c=pe(o,n),l=await ge(s,o,c,a);if(l){r.push(l);return}let u=me(o,c);if(u){r.push(u);return}let d=he(o,c);if(d){r.push(d);return}i[o.key]=n}));for(let[e,t]of c.entries()){if(t.status!==`rejected`)continue;let n=o[e];if(!n)continue;let[i,a]=n,s=t.reason instanceof Error?t.reason.message:String(t.reason);r.push({fieldKey:i,userMessage:`An unexpected error occurred validating this field`,systemMessage:`Validation threw for field '${i}': ${s}`,value:a})}return{responsesToCommit:i,validationErrors:r}}});async function u(e){return l(e)}let d=(0,c.attach)({source:n,effect:async(e,t)=>{let{responsesToCommit:n,validationErrors:r}=await l(t);return r.length?{errors:r}:(a.registerBatch(n),{errors:[]})}});async function f(e){return d(e)}let p=n.map(e=>e),m=n.map(e=>Object.entries(e).map(([e,t])=>({fieldKey:e,value:t})));function h(e){return(0,c.combine)({f:e,s:n},({f:e,s:t})=>{let n=e?t[e.key]??null:null;return n===null?e?.defaultValue!==void 0&&e.defaultValue!==null?e.defaultValue:null:n})}function g(e){return h(t.fields.getById(e))}function _(e){return h(t.fields.getByKey(e))}function v(e){return h(t.fields.getByName(e))}return(0,c.sample)({clock:r,target:a.clearAll}),(0,c.sample)({clock:i,target:a.clear}),{register:o,clearAll:r,clear:i,commit:f,getResponsesToCommit:u,listStore:m,getAllStore:p,getByFieldId:g,getByFieldKey:_,getByFieldName:v}});function ye(e){return(0,l.invoke)(ve,e)}var be=(0,c.createDomain)(`condition`),xe=(0,l.createFactory)(()=>{let e=be.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.condition.id]:t.condition}}});function n(e){t.register({condition:e})}let r=e.map(e=>Object.values(e));function i(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function a(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}return{register:n,getById:i,getByKey:a,listStore:r,indexStore:e}});function Se(){return(0,l.invoke)(xe)}function Ce(){if(r.r()){let e=[document.currentScript,document.getElementById(`picked_script`),document.getElementById(`picked`),document.getElementById(`cvly`),document.getElementById(`cvly-x`)];for(let t of e)if(t?.dataset.api)return t.dataset.api}return`https://api.picked.app`}function we(){if(!r.d())return{};let e=new URLSearchParams(window.location.search),t={},n=new Set;for(let[t]of e.entries())t.startsWith(`picked-`)&&n.add(t);for(let r of n){let n=r.replace(`picked-`,``);t[n]=e.getAll(r)}let i=a.t(`s`);if(n.size>0)a.r.set(i,t);else{let e=a.r.get(i);if(e)return e.json()||{}}return t}function Te(){return r.n()?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}var Ee=a.t(`session`,`global`),De=()=>{let e=a.n.get(Ee),t;e.isSet()&&(t=e.json());let n=t=>e.set({id:t.id,isUser:t.isUser,identifiers:t.identifiers}),r={id:t?.id??Te(),isUser:t?.isUser??void 0,identifiers:t?.identifiers??void 0,setIsUser(e){this.isUser=e,n(this)},setIdentifier(e,t){this.identifiers={...this.identifiers,[e]:t},n(this)},removeIdentifier(e){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([t])=>t!==e)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,n(this))}};return n(r),r},Oe=()=>r.o()?De():null;function X(){if(r.d())return globalThis.window.pickedConfig}function ke(){if(!r.d())return;let e=X(),t=e?.organizationId,n=e?.projectId;return t&&n?{organizationId:t,projectId:n}:void 0}function Z(){if(!r.r())return;let e=document.getElementById(`picked_script`)||document.querySelector(`script#picked`)||document.getElementById(`cvly`);if(!e)return;let t=e.dataset.organizationid||e.getAttribute(`organization-id`),n=e.dataset.projectid||e.getAttribute(`project-id`);return t&&n?{organizationId:t,projectId:n}:void 0}function Ae(e){let{organizationId:t,projectId:n}=e;if(t&&n)return{organizationId:t,projectId:n};let r=ke();if(r)return r;let i=Z();if(i)return i;throw Error(`organizationId and projectId are required. You can provide them via one of:
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../rules-logic-D_dZ52-Q.cjs`),t=require(`../object-CUJOjanb.cjs`),n=require(`../logger-fbvQC40v.cjs`),r=require(`../supports-Dsjg-82e.cjs`),i=require(`../experience-instance-DG9HFNSE.cjs`),a=require(`../storage-B6lQtc4-.cjs`),o=require(`../api-DVSjNleu.cjs`),s=require(`../id-Bv44ilEo.cjs`);let c=require(`effector`),l=require(`@withease/factories`);var u=(0,c.createDomain)(`experience`),d=(0,l.createFactory)(({client:e,experience:t})=>{let n=u.store(t),r=(0,c.createApi)(n,{merge(e,t){return{...e,...t.experience}}}),a=n.map(e=>({name:e.name,decisionLogic:e.condition,targetSelectors:e.targets,initializeOpenLogic:e.initializeOpen})),o=(0,c.combine)(n,e.components.listStore,(e,t)=>(e.componentName?t.find(t=>t.name===e.componentName):void 0)||t.find(t=>t.name===`experience:${e.id}`)||t.find(e=>e.name===`experience`),{skipVoid:!1}),s=(0,c.combine)(n,e.steps.indexStore,e.conditions.indexStore,(e,t,n)=>{let r=e.nodes.filter(i.i).map(e=>t[e.stepId]).filter(e=>e!==void 0),a=e.nodes.filter(i.r).map(e=>n[e.conditionId]).filter(e=>e!==void 0);return{steps:r,nodes:e.nodes,edges:e.edges,conditions:a}}),l=t.actions??[];return{id:t.id,key:t.key,name:t.name,configStore:a,treeStore:s,componentStore:o,actions:l,merge:r.merge}});function f(e){return(0,l.invoke)(d,e)}var p=(0,l.createFactory)(({client:e})=>{let t=u.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.id]:t}}});function r(r){let i=t.getState()[r.id];if(i){i.merge({experience:r,strategy:`override`});return}let a=f({client:e,experience:r});n.register(a)}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}function o(e){return t.map(t=>Object.values(t).find(t=>t.key===e)??t[e],{skipVoid:!1})}let s=(0,c.attach)({source:t,effect:async(t,n)=>{let r=`key`in n?Object.values(t).find(e=>e.key===n.key):t[n.id];if(!r){`key`in n?`${n.key}`:`${n.id}`;return}let{options:i}=n;if(i?.bypassCondition){h(e,r,i);return}await _(e,r)&&h(e,r,i)}});return{register:r,get:a,getById:a,getByKey:o,launch:s,open:(0,c.attach)({source:{experiences:t,instances:e.experienceInstances.listStore},effect:({experiences:e,instances:t},n)=>{let r=`key`in n?Object.values(e).find(e=>e.key===n.key):e[n.id],i=t.filter(e=>r&&e.experienceId===r.id);if(i.length>0)for(let e of i)e.open();else s(`key`in n?{key:n.key,options:{...n.options,initialiseOpen:!0}}:{id:n.id,options:{...n.options,initialiseOpen:!0}})}}),listStore:i}});function m(e){return(0,l.invoke)(p,e)}var h=(e,t,n)=>{let{targetSelectors:r}=t.configStore.getState(),a=i.s(r,t.id);a.forEach(({elements:e})=>e.forEach(e=>i.l(e,t.id))),i.a(a,t.id,t.key).forEach(r=>{n?e.experienceInstances.spawn(t,r,n):e.experienceInstances.spawn(t,r)})},g=async e=>{await Promise.all(e.experiences.listStore.getState().map(async t=>{await _(e,t)&&h(e,t)}))},_=async(t,n)=>{if(!t.preconditionPassed||!t.session?.isUser)return!1;let{decisionLogic:r,targetSelectors:a}=n.configStore.getState();return i.s(a,n.id).length<1||a.length===0?!1:r===void 0?!0:e.n(r)?await e.t(t,r)===!0:!0},v=(e,t,n)=>{let r=t.name,i=t.setup(e);if(i){let e=n[r]??{};n[r]=Object.freeze({...e,...i})}},ee=(0,c.createDomain)(`component`),y=(0,l.createFactory)(({client:e,component:t,name:n})=>({name:n,component:t,frameworkStore:e.frameworks.getByName(t.frameworkName)}));function b(e){return(0,l.invoke)(y,e)}var x=(0,l.createFactory)(({client:e})=>{let t=ee.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:t}}});function r(r,i){t.getState()[r]&&`${r}`;let a=b({client:e,name:r,component:i});n.register(a)}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}return{register:r,getByName:a,listStore:i}});function S(e){return(0,l.invoke)(x,e)}var C=(e,t,n)=>{n.register(e,t)},te=(0,c.createDomain)(`framework`),ne=(0,l.createFactory)(({client:e})=>{let t=te.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:t.framework}}});function r(e,r){t.getState()[e]&&`${e}`,n.register({name:e,framework:r})}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e],{skipVoid:!1})}return{register:r,getByName:a,listStore:i}});function re(e){return(0,l.invoke)(ne,e)}var ie=(e,t)=>{t.register(e.name,e)},ae=6e3,oe=a.t(`last_ping`,`global`),se=async e=>{try{let t=Date.now(),n=a.n.get(oe),r=0;if(n.isSet()&&(r=n.json()??0),r&&t-r<ae)return!0;let i={projectId:e.projectId,path:window.location.pathname},s={},c=document.getElementById(`picked_script`)?.dataset.verceltoken;c&&(s[`x-vercel-protection-bypass`]=c);let l=(await o.n(e.apiUrl,`ping`,i,s)).ok;return l&&n.set(t),l}catch{return!1}};function w(e){let t=typeof window<`u`,n={client:e,responses:e.responses.listStore.getState(),fields:e.fields.listStore.getState(),location:t?window.location:void 0,document:t?window.document:void 0,sessionStorage:t?window.sessionStorage:void 0,localStorage:t?window.localStorage:void 0};return Object.freeze(n)}var T=(0,c.createDomain)(`predicate`),E=(0,l.createFactory)(({client:e})=>{let t=T.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.name]:{name:t.name,predicate:t.predicate}}}});function r(e,r){t.getState()[e]&&`${e}`,n.register(Object.freeze({name:e,predicate:r}))}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e]?.predicate,{skipVoid:!1})}function o(t){let n=(0,c.createStore)(()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let n=a(t).getState();if(!n)return;let r=w(e);return(...e)=>n({...r,args:e})});return(0,c.sample)({source:{responses:e.responses.listStore,fields:e.fields.listStore},target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:n}),r(),n}return{register:r,getByName:a,listStore:i,getEvokablePredicate:o}});function D(e){return(0,l.invoke)(E,e)}var O=(e,t,n)=>{n.register(e,t)},k=(0,c.createDomain)(`feature`),A=(0,l.createFactory)(({client:e})=>{let t=k.store({}),n=k.store([]),r=(0,c.createApi)(t,{register(e,t){return{...e,[t.id]:t.feature}}});function i(e,n){t.getState()[e]&&`${e}`;let i={id:e,feature:{...n,id:e}};r.register(Object.freeze({id:e,feature:i}))}let o=(0,c.createEffect)(async({id:e,key:t,storage:n=`local`})=>{let r=a.t(`feature:${e}:${t}`,`global`),i=(n===`session`?a.r:a.n).get(r).boolean();return i===null?null:{id:e,key:t,bucket:i,storage:n}}),s=(0,c.createEffect)(e=>{if(!e)return null;let t=a.t(`feature:${e.id}:${e.key}`,`global`);(e.storage===`session`?a.r:a.n).set(t,e.bucket)}),l=new Map,u=(0,c.attach)({source:{allFeaturesStore:t,resolvedFeaturesStore:n},effect:async({allFeaturesStore:e,resolvedFeaturesStore:t},{id:n,decide:r,key:i})=>{let a=t.find(e=>e.id===n&&e.key===i);if(a)return a;let o=e[n];if(!o)throw Error(`Feature with id '${n}' not found`);let s=l.get(`${n}:${i}`);if(s!==void 0){let e=await s;return{id:o.id,bucket:e,key:i,storage:o.feature.storage}}let c=r();l.set(`${n}:${i}`,c);let u=await c;return{id:o.id,bucket:u,key:i,storage:o.feature.storage}}});(0,c.sample)({clock:r.register,fn:e=>{let{id:t,feature:n}=e;return{id:t,key:n.feature.key,storage:n.feature.storage}},target:o}),(0,c.sample)({source:t,clock:u.doneData,fn:(e,t)=>{let{id:n,bucket:r,storage:i}=t,a=e[n]?.feature.key;return a?{key:a,id:n,bucket:r,storage:i}:null},target:s});let d=(0,c.combine)({allFeaturesStore:t,resolvedFeaturesStore:n}).map(({allFeaturesStore:e,resolvedFeaturesStore:t})=>Object.values(e).map(e=>{let n=t.find(t=>t.id===e.id&&t.key===e.feature.key);return n?{id:e.id,name:e.feature.name,key:e.feature.key,getBucket:()=>({id:e.id,bucket:n.bucket}),isResolved:!0}:{id:e.id,name:e.feature.name,key:e.feature.key,getBucket:async()=>await u(e.feature),isResolved:!1}}));(0,c.sample)({clock:u.doneData,source:{resolvedFeatures:n},filter:({resolvedFeatures:e},{id:t,key:n})=>!e.some(e=>e.id===t&&e.key===n),fn:(e,t)=>t,target:e.eventBus.prepend(e=>({type:`feature_decide`,feature:e}))}),(0,c.sample)({clock:[o.doneData,u.doneData],source:n,fn:(e,t)=>!t||e.some(e=>e.id===t.id&&e.key===t.key)?e:[...e,t],target:n});function f(e){return d.map(t=>t.find(t=>t.id===e))}function p(e){return t.map(t=>t[e],{skipVoid:!1})}function m(e){let t=(0,c.createStore)(async()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let t=f(e).getState();if(t)return async()=>(await t.getBucket()).bucket});return(0,c.sample)({source:n,filter:t=>t.some(t=>t.id===e),target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:t}),r(),t}return{register:i,getById:f,getByName:p,listStore:d,getEvokableFeature:m}});function j(e){return(0,l.invoke)(A,e)}var M=(e,t,n)=>{n.register(e,t)},N=(0,c.createDomain)(`history`);function P(e,t){return{id:s.t(`history-entry-${Date.now()}-${Math.random()}}`),node:t,at:Date.now(),experienceId:e}}var F=(0,l.createFactory)(()=>{let e=N.store({entries:[]}),t=N.event(),n=N.event(),r=N.event(),a=N.event();e.on(t,(e,t)=>({entries:[...e.entries,P(t.experienceId,t.node)]})),e.on(n,(e,t)=>({entries:[...e.entries.slice(0,-1),P(t.experienceId,t.node)]})),e.on(a,(e,t)=>t);function o(e,t){let n={lastStepIndex:-1,secondLastStepIndex:-1};for(let r=e.length-1;r>=0;r--){let a=e[r],o=a?.node;if(!(!o||!i.i(o))&&!(t&&a.experienceId!==t))if(n.lastStepIndex===-1)n.lastStepIndex=r;else{n.secondLastStepIndex=r;break}}return n}return e.on(r,(e,t)=>{let{secondLastStepIndex:n}=o(e.entries,t.experienceId),r=n===-1?e.entries:e.entries.slice(0,n+1);return{...e,entries:r}}),{push:t,replace:n,back:r,restore:a,entriesStore:e.map(e=>e.entries)}});function I(){return(0,l.invoke)(F)}var L=0,R=e=>{let t=(0,c.createStore)([]);return(0,c.sample)({clock:e,source:t,fn:(e,t)=>[...e,{id:L++,at:new Date,payload:t}],target:t}),t},z=(0,c.createDomain)(`field`),B=(0,l.createFactory)(()=>{let e=z.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.field.id]:t.field}},updateByKey(e,t){let n=Object.values(e).find(e=>e.key===t.fieldKey);return n?{...e,[n.id]:Object.assign({},n,t.updates)}:e}});function n(e){t.register({field:e})}function r(n,r){let i=e.getState(),a=Object.values(i).find(e=>e.key===n)?.key;a&&t.updateByKey({fieldKey:a,updates:r})}let i=e.map(e=>Object.values(e));function a(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function o(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}function s(t){return e.map(e=>Object.values(e).find(e=>e.name===t)??null,{skipVoid:!1})}return{register:n,update:r,getById:a,getByKey:o,listStore:i,getByName:s}});function V(){return(0,l.invoke)(B)}var H=(0,c.createDomain)(`step`),U=(0,l.createFactory)(()=>{let e=H.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.step.id]:t.step}}});function n(e){t.register({step:e})}let r=e.map(e=>Object.values(e));function i(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function a(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}return{register:n,getById:i,getByKey:a,listStore:r,indexStore:e}});function W(){return(0,l.invoke)(U)}function G(e,t){t.register(e)}var K=(0,c.createDomain)(`action`),ce=(0,l.createFactory)(({client:e})=>{let t=K.store({}),n=(0,c.createApi)(t,{register(e,t){return{...e,[t.key]:{key:t.key,action:t.action}}}});function r(e,r){t.getState()[e]&&`${e}`,n.register(Object.freeze({key:e,action:r}))}let i=t.map(e=>Object.values(e));function a(e){return t.map(t=>t[e]?.action,{skipVoid:!1})}function o(t){let n=(0,c.createStore)(()=>void 0,{skipVoid:!1}),r=(0,c.createEffect)(async()=>{let n=a(t).getState();if(!n)return;let r=w(e);return(...e)=>n({...r,args:e})});return(0,c.sample)({source:{responses:e.responses.listStore,fields:e.fields.listStore},target:r}),(0,c.sample)({clock:r.doneData,filter:e=>e!==void 0,target:n}),r(),n}return{register:r,getByKey:a,listStore:i,getEvokableAction:o}});function le(e){return(0,l.invoke)(ce,e)}var ue=(e,t,n)=>{n.register(e,t)};function q(e,t,n,r){return{fieldKey:e.key,userMessage:n,systemMessage:r,value:t}}function J(e){return e==null||e===``||Array.isArray(e)&&!e.length}function de(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null}function Y(e){try{return JSON.stringify(e),!0}catch{return!1}}function fe(e,t){return t.find(t=>t.key===e)??null}function pe(e,t){return e.multiple&&(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)?[t]:t}function me(e,t){if(e.type!==`object`||J(t))return null;if(e.multiple){if(!Array.isArray(t))return q(e,t,`This field expects multiple values`,`Field expects an array of objects.`);for(let n of t){if(typeof n!=`object`||!n)return q(e,t,`This field expects object values`,`Field expects an array of objects, but received non-object value.`);if(!Y(n))return q(e,t,`This field contains non-serializable data`,`Field value contains non-JSON-serializable data (functions, circular references, etc.).`)}return null}return Array.isArray(t)?q(e,t,`This field expects a single value`,`Field expects a single object, not an array.`):typeof t!=`object`||!t?q(e,t,`This field expects an object value`,`Field expects an object value.`):Y(t)?null:q(e,t,`This field contains non-serializable data`,`Field value contains non-JSON-serializable data (functions, circular references, etc.).`)}function he(e,t){if(!Array.isArray(e.options)||e.options.length===0)return null;let n=Array.isArray(t)?t:[t];if(e.type===`object`){let r=e.options.map(e=>JSON.stringify(e.value));return n.every(e=>r.includes(JSON.stringify(e)))?null:q(e,t,`This field expects a valid option`,`Field expects a valid option from the defined choices.`)}let r=e.options.map(e=>e.value);return n.every(e=>!de(e)||e===null?!1:r.includes(e))?null:q(e,t,`This field expects a valid option`,`Field expects a valid option. Valid options are: ${r.join(`, `)}`)}async function ge(e,n,r,i){if(n.validation&&!t.t(n.validation)&&!J(r)){let t=i?{$input:r,responses:i}:{$input:r},a=await e(n.validation,t);if(typeof a==`string`)return q(n,r,a,`Field validation resulted in an error: ${a}.`);if(a===!1)return q(n,r,`This field is invalid`,`Field validation resulted in an unspecified error.`)}return n.required&&J(r)?q(n,r,`This field is required`,`Field is required.`):!n.multiple&&Array.isArray(r)&&r.length>1?q(n,r,`This field expects a single response`,`Field expects a single response.`):null}var _e=(0,c.createDomain)(`response`),ve=(0,l.createFactory)(({client:t})=>{let n=_e.store({}),r=(0,c.createEvent)(),i=(0,c.createEvent)(),a=(0,c.createApi)(n,{register(e,t){return{...e,[t.fieldKey]:t.response}},registerBatch(e,t){return{...e,...t}},clear(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))},clearAll(){return{}}});function o(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Response is required when registering a single field`);a.register({fieldKey:e,response:t})}else a.registerBatch(e)}let s=(n,r)=>e.t(t,n,r),l=(0,c.attach)({source:{allFields:t.fields.listStore,existingResponses:n},effect:async({allFields:e,existingResponses:t},n)=>{let r=[],i={},a={...t,...n},o=Object.entries(n),c=await Promise.allSettled(o.map(async([t,n])=>{let o=fe(t,e);if(!o){r.push({fieldKey:t,userMessage:`Field '${t}' not found`,systemMessage:`No field with key '${t}' exists. Available field keys are: ${e.map(e=>e.key).join(`,`)}.`,value:n});return}let c=pe(o,n),l=await ge(s,o,c,a);if(l){r.push(l);return}let u=me(o,c);if(u){r.push(u);return}let d=he(o,c);if(d){r.push(d);return}i[o.key]=n}));for(let[e,t]of c.entries()){if(t.status!==`rejected`)continue;let n=o[e];if(!n)continue;let[i,a]=n,s=t.reason instanceof Error?t.reason.message:String(t.reason);r.push({fieldKey:i,userMessage:`An unexpected error occurred validating this field`,systemMessage:`Validation threw for field '${i}': ${s}`,value:a})}return{responsesToCommit:i,validationErrors:r}}});async function u(e){return l(e)}let d=(0,c.attach)({source:n,effect:async(e,t)=>{let{responsesToCommit:n,validationErrors:r}=await l(t);return r.length?{errors:r}:(a.registerBatch(n),{errors:[]})}});async function f(e){return d(e)}let p=n.map(e=>e),m=n.map(e=>Object.entries(e).map(([e,t])=>({fieldKey:e,value:t})));function h(e){return(0,c.combine)({f:e,s:n},({f:e,s:t})=>{let n=e?t[e.key]??null:null;return n===null?e?.defaultValue!==void 0&&e.defaultValue!==null?e.defaultValue:null:n})}function g(e){return h(t.fields.getById(e))}function _(e){return h(t.fields.getByKey(e))}function v(e){return h(t.fields.getByName(e))}return(0,c.sample)({clock:r,target:a.clearAll}),(0,c.sample)({clock:i,target:a.clear}),{register:o,clearAll:r,clear:i,commit:f,getResponsesToCommit:u,listStore:m,getAllStore:p,getByFieldId:g,getByFieldKey:_,getByFieldName:v}});function ye(e){return(0,l.invoke)(ve,e)}var be=(0,c.createDomain)(`condition`),xe=(0,l.createFactory)(()=>{let e=be.store({}),t=(0,c.createApi)(e,{register(e,t){return{...e,[t.condition.id]:t.condition}}});function n(e){t.register({condition:e})}let r=e.map(e=>Object.values(e));function i(t){return e.map(e=>e[t]??null,{skipVoid:!1})}function a(t){return e.map(e=>Object.values(e).find(e=>e.key===t)??null,{skipVoid:!1})}return{register:n,getById:i,getByKey:a,listStore:r,indexStore:e}});function Se(){return(0,l.invoke)(xe)}function Ce(){if(r.r()){let e=[document.currentScript,document.getElementById(`picked_script`),document.getElementById(`picked`),document.getElementById(`cvly`),document.getElementById(`cvly-x`)];for(let t of e)if(t?.dataset.api)return t.dataset.api}return`https://api.picked.app`}function we(){if(!r.d())return{};let e=new URLSearchParams(window.location.search),t={},n=new Set;for(let[t]of e.entries())t.startsWith(`picked-`)&&n.add(t);for(let r of n){let n=r.replace(`picked-`,``);t[n]=e.getAll(r)}let i=a.t(`s`);if(n.size>0)a.r.set(i,t);else{let e=a.r.get(i);if(e)return e.json()||{}}return t}function Te(){return r.n()?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}var Ee=a.t(`session`,`global`),De=()=>{let e=a.n.get(Ee),t;e.isSet()&&(t=e.json());let n=t=>e.set({id:t.id,isUser:t.isUser,identifiers:t.identifiers}),r={id:t?.id??Te(),isUser:t?.isUser??void 0,identifiers:t?.identifiers??void 0,setIsUser(e){this.isUser=e,n(this)},setIdentifier(e,t){this.identifiers={...this.identifiers,[e]:t},n(this)},removeIdentifier(e){this.identifiers&&(this.identifiers=Object.fromEntries(Object.entries(this.identifiers).filter(([t])=>t!==e)),this.identifiers=Object.keys(this.identifiers).length?this.identifiers:void 0,n(this))}};return n(r),r},Oe=()=>r.o()?De():null;function X(){if(r.d())return globalThis.window.pickedConfig}function ke(){if(!r.d())return;let e=X(),t=e?.organizationId,n=e?.projectId;return t&&n?{organizationId:t,projectId:n}:void 0}function Z(){if(!r.r())return;let e=document.getElementById(`picked_script`)||document.querySelector(`script#picked`)||document.getElementById(`cvly`);if(!e)return;let t=e.dataset.organizationid||e.getAttribute(`organization-id`),n=e.dataset.projectid||e.getAttribute(`project-id`);return t&&n?{organizationId:t,projectId:n}:void 0}function Ae(e){let{organizationId:t,projectId:n}=e;if(t&&n)return{organizationId:t,projectId:n};let r=ke();if(r)return r;let i=Z();if(i)return i;throw 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 Q(e){return e==null||e===``||Number.isNaN(e)}var je={default:(e,t)=>Q(e)?String(t??``):String(e),append:(e,t)=>t&&!Q(e)?`${e} ${t}`:e,prepend:(e,t)=>t&&!Q(e)?`${t} ${e}`:e,upper:e=>typeof e==`string`?e.toUpperCase():e,lower:e=>typeof e==`string`?e.toLowerCase():e,capitalize:e=>typeof e==`string`?e.charAt(0).toUpperCase()+e.slice(1):e,list:e=>{if(!e||typeof e!=`object`)return e;let t=new Intl.ListFormat(`en`,{style:`long`,type:`conjunction`});if(Array.isArray(e))return t.format(e.map(String));if(e instanceof Map){let n=Array.from(e.entries()).map(([e,t])=>`${e}: ${t}`);return t.format(n)}return e instanceof Set?t.format(Array.from(e).map(String)):e}};function Me(e){return typeof e==`object`&&!!e}function Ne(e,t){let n=t;for(let t of e.split(`.`))if(Me(n)&&t in n)n=n[t];else return;return typeof n==`function`?n():n}function Pe(e,t){let n=e.split(`|`).map(e=>e.trim()),r=Ne(n.shift()??``,t);for(let e of n){let[t,...n]=e.split(`:`),i=t?.trim()??``,a=n.join(`:`).trim().replaceAll(/(?:^['"]|['"]$)/g,``),o=je[i];o&&(r=o(r,a))}return Q(r)?``:typeof r==`object`?JSON.stringify(r):String(r)}function Fe(e,t){let n=``,r=0;for(;r<e.length;)if(e[r]===`{`&&e[r+1]===`{`){r+=2;let i=``;for(;r<e.length;){if(e[r]===`}`&&e[r+1]===`}`){r+=2;break}i+=e[r++]}n+=Pe(i.trim(),t)}else n+=e[r++];return n}var $=class{static logger=n.t;options;isReady=!1;plugins={};pluginStartHooks=[];eventBus=(0,c.createEvent)();events;organizationId;projectId;apiUrl;dashboardUrl;documentationSiteUrl;session;precondition;condition;preconditionPassed;searchParams=we();history=I();components=S({client:this});experienceInstances=i.n({client:this});experiences=m({client:this});frameworks=re({client:this});predicates=D({client:this});features=j({client:this});conditions=Se();fields=V();responses=ye({client:this});steps=W();actions=le({client:this});constructor(e){this.events=R(this.eventBus);let{organizationId:t,projectId:n}=Ae(e);this.organizationId=t,this.projectId=n,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||Ce(),this.dashboardUrl=e.dashboardUrl??`https://dashboard.picked.app`,this.documentationSiteUrl=e.documentationSiteUrl??`https://docs.picked.app`,this.session=Oe(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.setupComponents(),this.precondition=e.precondition,this.condition=e.condition,this.eventBus({type:`load`,version:o.r()})}start=()=>{se(this),(async()=>{if(!r.r())return;await this.runPluginStartHooks();let e=await this.evaluateGate(this.precondition);this.preconditionPassed=e;let t;e&&(t=await this.evaluateGate(this.condition));let n=e&&t===!0;if(typeof t==`boolean`&&this.session){let e=t;this.session.setIsUser(e),this.eventBus({type:`user_decide`,value:e})}if(this.eventBus({type:`initialize`}),n&&g(this),await i.o(),n&&g(this),this.eventBus({type:`ready`}),this.isReady=!0,this.session){let{id:e,isUser:t,identifiers:n}=this.session;this.eventBus({type:`session`,id:e,isUser:t,identifiers:n})}})()};registerFramework=e=>{ie(e,this.frameworks)};registerComponent=(e,t)=>{C(e,t,this.components)};registerPlugin=e=>{v(this,e,this.plugins);let t=this.plugins[e.name];t?.onStart&&this.pluginStartHooks.push(t.onStart)};registerFeature=(e,t)=>{M(e,t,this.features)};registerPredicate=(e,t)=>{O(e,t,this.predicates)};registerCondition=e=>{this.conditions.register(e)};registerField=e=>{this.fields.register(e)};registerStep=e=>{G(e,this.steps)};registerAction=(e,t)=>{ue(e,t,this.actions)};registerExperience=e=>{e.component&&C(`experience:${e.id}`,e.component,this.components),this.experiences.register(e)};getStateSnapshot=()=>w(this);launchExperienceById=async(e,t)=>{this.experiences.launch({id:e,options:t})};launchExperienceByKey=async(e,t)=>{this.experiences.launch({key:e,options:t})};openExperienceById=async e=>{this.experiences.open({id:e})};openExperienceByKey=async e=>{this.experiences.open({key:e})};async runPluginStartHooks(){for(let e of this.pluginStartHooks)await e()}async evaluateGate(t){return t===void 0?!0:typeof t==`boolean`?t:await e.t(this,t)===!0}setupPlugins(){this.options.plugins?.forEach(e=>{if(Array.isArray(e)){e.forEach(e=>{this.registerPlugin(e)});return}let t=typeof e==`function`?e():e;if(Array.isArray(t)){t.forEach(e=>this.registerPlugin(e));return}this.registerPlugin(t)})}setupFeatures(){let e=this.options.features;e&&Object.entries(e).forEach(([e,t])=>{let n=typeof t==`function`?t():t;this.registerFeature(e,n)}),this.searchParams.feature&&this.searchParams.feature.forEach(e=>{try{let[t,n]=e.split(`:`);if(!t||!n)return;let r=n;r===`true`&&(r=!0),r===`false`&&(r=!1),this.registerFeature(t,{key:`${r}`,name:t,decide:()=>r,storage:`session`})}catch{}})}setupPredicates(){let e=this.options.predicates;e&&Object.entries(e).forEach(([e,t])=>{if(typeof t!=`function`){`${e}`;return}this.registerPredicate(e,t)})}setupActions(){let e=this.options.actions;e&&Object.entries(e).forEach(([e,t])=>{if(typeof t!=`function`){`${e}`;return}this.registerAction(e,t)})}setupComponents(){let e=this.options.components;e&&Object.entries(e).forEach(([e,t])=>{this.registerComponent(e,t)})}getPluginConfig=e=>this.plugins[e]??{};renderString=(e,t)=>{let n=this.responses.listStore.getState().reduce((e,t)=>(e[t.fieldKey]=t.value,e),{});return Fe(e,{...t,responses:n})}};function Ie(e){return{$$type:`lazy-component`,load:e}}function Le(e){return typeof e==`object`&&!!e&&`$$type`in e&&e.$$type===`lazy-component`}var Re=e=>{let t=new $(e);return r.p(t),t};exports.Picked=$,exports.createClient=Re,exports.createStorageKey=a.t,exports.evaluateRuleLogic=e.t,exports.getPickedConfig=X,exports.isLazyLoader=Le,exports.isPickedRoot=i.c,exports.lazyComponent=Ie,exports.localStore=a.n,exports.sessionStore=a.r,exports.subscribe=a.i,exports.supportsCookies=r.t,exports.supportsCryptoRandomUUID=r.n,exports.supportsDocument=r.r,exports.supportsHistory=r.i,exports.supportsIntersectionObserver=r.a,exports.supportsLocalStorage=r.o,exports.supportsLocation=r.s,exports.supportsSessionStorage=r.c,exports.supportsShadowRoot=r.l,exports.supportsWebComponents=r.u,exports.supportsWindow=r.d;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../../id-Bv44ilEo.cjs`);var t={serialize(e){return JSON.stringify(e)},deserialize(e){return JSON.parse(e)}},n=e=>({name:`create-experience`,setup:n=>{e.experiences.forEach(e=>{let r=e.serialize(),i=t.deserialize(r);i.component=e.component;let{steps:a,conditions:o,fields:s,...c}=i;n.registerExperience(c),s.forEach(e=>{n.registerField(e)}),a.forEach(e=>{n.registerStep(e)}),o.forEach(e=>{n.registerCondition(e)})})}}),r=(n,r)=>({id:e.t(`node`),experience:r,type:`action`,action:n.action,addNext(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:null},r);r.edges.push(t)},onSuccess(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:`true`},r);r.edges.push(t)},onFail(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:`false`},r);r.edges.push(t)},serialize(){return t.serialize({id:this.id,type:this.type,actionKey:this.action})}}),i=t=>{let n=t.name,r=t.id??e.t(`step`);return{id:r,name:n,key:t.key??r,fields:t.fields??[],addField(e){let t=`serialize`in e?e:l(e);return this.fields.includes(t)||this.fields.push(t),t}}},a=(n,r)=>{let i=n.name,a=n.id??e.t(`step`),s={id:a,name:i,key:n.key??a,experience:r,fields:n.fields??[],node:null,nextStep(e){return this.experience.addStep(e,this)},nextCondition(e){return this.experience.addCondition(e,this)},nextConditional(e){return this.nextCondition(e)},addNextExperience(e){return this.experience.addExperience(e,this)},addField(e){return this.experience.addField(e,this)},serialize(){return t.serialize({id:this.id,key:this.key,name:this.name,fieldIds:this.fields.map(e=>e.id)})}};return o({step:s,type:`step`},r),s},o=(n,r)=>{let i={id:e.t(`node`),experience:r};if(n.type===`step`){let e={...i,type:`step`,connectedStep:n.step,serialize(){return t.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,name:this.connectedStep.name})}};return e.connectedStep.node=e,e}if(n.type===`condition`){let e={...i,type:`condition`,connectedCondition:n.condition,serialize(){return t.serialize({id:this.id,type:this.type,conditionId:this.connectedCondition.id})}};return e.connectedCondition.node=e,e}return n.type===`experience`?{...i,type:`experience`,connectedExperience:n.experience,serialize(){return t.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,experienceKey:this.connectedExperience.key})}}:{...i,type:`origin`,serialize(){return t.serialize({id:this.id,type:this.type})}}},s=(n,r)=>({id:e.t(`edge`),sourceNode:n.sourceNode,sourceHandle:n.sourceHandle,destinationNode:n.destinationNode,experience:r,serialize(){return t.serialize({id:this.id,sourceHandle:this.sourceHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),c=(n,r)=>{let i=e.t(`conditional`),a=n.name??n.label??i,c={id:i,key:n.key??i,name:a,label:n.label,logic:n.condition,node:null,experience:r,addTrue(e){if(!this.node||!e.node)throw Error(`todo no node`);let t=s({sourceNode:this.node,destinationNode:e.node,sourceHandle:`true`},this.experience);this.experience.edges.push(t)},addFalse(e){if(!this.node||!e.node)throw Error(`todo no node`);let t=s({sourceNode:this.node,destinationNode:e.node,sourceHandle:`false`},this.experience);this.experience.edges.push(t)},serialize(){return t.serialize({id:this.id,key:this.key,name:this.name,logic:this.logic})}};return o({condition:c,type:`condition`},r),c},l=n=>{let r=n.id??e.t(`field`);return{id:r,key:n.key??r,name:n.name,type:n.type,label:n.label,placeholder:n.placeholder,description:n.description,helpText:n.helpText,defaultValue:n.defaultValue??null,multiple:n.multiple,validation:n.validation??{},condition:n.condition,required:n.required,options:n.options?.map(t=>({id:`id`in t?t.id:e.t(`option`),...t}))??null,policies:n.policies,serialize(){let e={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},n=typeof this.defaultValue==`string`?this.defaultValue:void 0,r=typeof this.defaultValue==`number`?this.defaultValue:void 0,i=typeof this.defaultValue==`boolean`?this.defaultValue:void 0;switch(this.type){case`text`:if(this.multiple){let n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`string`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`text`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`,condition:e.condition})):null})}return t.serialize({...e,type:`text`,multiple:!1,defaultValue:n,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 n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`number`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`number`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value),condition:e.condition})):null})}return t.serialize({...e,type:`number`,multiple:!1,defaultValue:r,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 n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`boolean`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`boolean`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value,condition:e.condition})):null})}return t.serialize({...e,type:`boolean`,multiple:!1,defaultValue:i,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?t.serialize({...e,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}):t.serialize({...e,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 Error(`Unsupported field type`)}}}},u=e=>({id:e.id,key:e.key??e.id,component:e.component,name:e.name,initializeOpen:e.initializeOpen,condition:e.condition,targets:e.targets,steps:[],nodes:[],edges:[],fields:[],conditions:[],addStep(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=`serialize`in e?e:a(e,this);if(n){if(!r.node)throw Error(`todo no node`);let e=s({sourceNode:n,destinationNode:r.node,sourceHandle:null},this);this.edges.push(e)}return r.fields.length>0&&r.fields.forEach(e=>{this.fields.includes(e)||this.fields.push(e)}),this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addAction(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let i=`serialize`in e?e:r(e,this);if(n){let e=s({sourceNode:n,destinationNode:i,sourceHandle:null},this);this.edges.push(e)}return this.nodes.push(i),i},addCondition(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=`serialize`in e?e:c(e,this);if(n){if(!r.node)throw Error(`todo no node`);let e=s({sourceNode:n,destinationNode:r.node,sourceHandle:null},this);this.edges.push(e)}return this.conditions.includes(r)||(this.conditions.push(r),r.node&&this.nodes.push(r.node)),r},addConditional(e,t){return this.addCondition(e,t)},addExperience(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=o({type:`experience`,experience:e},this);if(this.nodes.push(r),n){let e=s({sourceNode:n,destinationNode:r,sourceHandle:null},this);this.edges.push(e)}return e},addField(e,t){let n=`serialize`in e?e:l(e);return t&&t.fields.push(n),this.fields.includes(n)||this.fields.push(n),n},serialize(){return t.serialize({id:this.id,key:this.key,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition,targets:this.targets,steps:this.steps.map(e=>t.deserialize(e.serialize())),nodes:this.nodes.map(e=>t.deserialize(e.serialize())),edges:this.edges.map(e=>t.deserialize(e.serialize())),conditions:this.conditions.map(e=>t.deserialize(e.serialize())),fields:this.fields.map(e=>t.deserialize(e.serialize()))})}});exports.createCondition=c,exports.createEdge=s,exports.createExperience=u,exports.createExperiencePlugin=n,exports.createField=l,exports.createNode=o,exports.createStep=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../../id-Bv44ilEo.cjs`);var t={serialize(e){return JSON.stringify(e)},deserialize(e){return JSON.parse(e)}},n=e=>({name:`create-experience`,setup:n=>{e.experiences.forEach(e=>{let r=e.serialize(),i=t.deserialize(r);i.component=e.component;let{steps:a,conditions:o,fields:s,...c}=i;n.registerExperience(c),s.forEach(e=>{n.registerField(e)}),a.forEach(e=>{n.registerStep(e)}),o.forEach(e=>{n.registerCondition(e)})})}}),r=(n,r)=>({id:e.t(`node`),experience:r,type:`action`,action:n.action,addNext(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:null},r);r.edges.push(t)},onSuccess(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:`true`},r);r.edges.push(t)},onFail(e){if(!e.node)throw Error(`Cannot connect to node`);let t=s({sourceNode:this,destinationNode:e.node,sourceHandle:`false`},r);r.edges.push(t)},serialize(){return t.serialize({id:this.id,type:this.type,actionKey:this.action})}}),i=t=>{let n=t.name,r=t.id??e.t(`step`);return{id:r,name:n,key:t.key??r,fields:t.fields??[],addField(e){let t=`serialize`in e?e:l(e);return this.fields.includes(t)||this.fields.push(t),t}}},a=(n,r)=>{let i=n.name,a=n.id??e.t(`step`),s={id:a,name:i,key:n.key??a,experience:r,fields:n.fields??[],node:null,nextStep(e){return this.experience.addStep(e,this)},nextCondition(e){return this.experience.addCondition(e,this)},nextConditional(e){return this.nextCondition(e)},addNextExperience(e){return this.experience.addExperience(e,this)},addField(e){return this.experience.addField(e,this)},serialize(){return t.serialize({id:this.id,key:this.key,name:this.name,fieldKeys:this.fields.map(e=>e.key)})}};return o({step:s,type:`step`},r),s},o=(n,r)=>{let i={id:e.t(`node`),experience:r};if(n.type===`step`){let e={...i,type:`step`,connectedStep:n.step,serialize(){return t.serialize({id:this.id,type:this.type,stepId:this.connectedStep.id,name:this.connectedStep.name})}};return e.connectedStep.node=e,e}if(n.type===`condition`){let e={...i,type:`condition`,connectedCondition:n.condition,serialize(){return t.serialize({id:this.id,type:this.type,conditionId:this.connectedCondition.id})}};return e.connectedCondition.node=e,e}return n.type===`experience`?{...i,type:`experience`,connectedExperience:n.experience,serialize(){return t.serialize({id:this.id,type:this.type,experienceId:this.connectedExperience.id,experienceKey:this.connectedExperience.key})}}:{...i,type:`origin`,serialize(){return t.serialize({id:this.id,type:this.type})}}},s=(n,r)=>({id:e.t(`edge`),sourceNode:n.sourceNode,sourceHandle:n.sourceHandle,destinationNode:n.destinationNode,experience:r,serialize(){return t.serialize({id:this.id,sourceHandle:this.sourceHandle??void 0,sourceNodeId:this.sourceNode.id,destinationNodeId:this.destinationNode.id})}}),c=(n,r)=>{let i=e.t(`conditional`),a=n.name??n.label??i,c={id:i,key:n.key??i,name:a,label:n.label,logic:n.condition,node:null,experience:r,addTrue(e){if(!this.node||!e.node)throw Error(`todo no node`);let t=s({sourceNode:this.node,destinationNode:e.node,sourceHandle:`true`},this.experience);this.experience.edges.push(t)},addFalse(e){if(!this.node||!e.node)throw Error(`todo no node`);let t=s({sourceNode:this.node,destinationNode:e.node,sourceHandle:`false`},this.experience);this.experience.edges.push(t)},serialize(){return t.serialize({id:this.id,key:this.key,name:this.name,logic:this.logic})}};return o({condition:c,type:`condition`},r),c},l=n=>{let r=n.id??e.t(`field`);return{id:r,key:n.key??r,name:n.name,type:n.type,label:n.label,placeholder:n.placeholder,description:n.description,helpText:n.helpText,defaultValue:n.defaultValue??null,multiple:n.multiple,validation:n.validation??{},condition:n.condition,required:n.required,options:n.options?.map(t=>({id:`id`in t?t.id:e.t(`option`),...t}))??null,policies:n.policies,serialize(){let e={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},n=typeof this.defaultValue==`string`?this.defaultValue:void 0,r=typeof this.defaultValue==`number`?this.defaultValue:void 0,i=typeof this.defaultValue==`boolean`?this.defaultValue:void 0;switch(this.type){case`text`:if(this.multiple){let n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`string`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`text`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:`${e.value}`,condition:e.condition})):null})}return t.serialize({...e,type:`text`,multiple:!1,defaultValue:n,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 n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`number`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`number`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:Number(e.value),condition:e.condition})):null})}return t.serialize({...e,type:`number`,multiple:!1,defaultValue:r,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 n;if(Array.isArray(this.defaultValue)){n=[];for(let e of this.defaultValue)typeof e==`boolean`&&n.push(e);n.length===0&&(n=void 0)}return t.serialize({...e,type:`boolean`,multiple:!0,defaultValue:n,options:this.options?this.options.map(e=>({id:e.id,label:e.label,value:!!e.value,condition:e.condition})):null})}return t.serialize({...e,type:`boolean`,multiple:!1,defaultValue:i,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?t.serialize({...e,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}):t.serialize({...e,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 Error(`Unsupported field type`)}}}},u=e=>({id:e.id,key:e.key??e.id,component:e.component,name:e.name,initializeOpen:e.initializeOpen,condition:e.condition,targets:e.targets,steps:[],nodes:[],edges:[],fields:[],conditions:[],addStep(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=`serialize`in e?e:a(e,this);if(n){if(!r.node)throw Error(`todo no node`);let e=s({sourceNode:n,destinationNode:r.node,sourceHandle:null},this);this.edges.push(e)}return r.fields.length>0&&r.fields.forEach(e=>{this.fields.includes(e)||this.fields.push(e)}),this.steps.includes(r)||(this.steps.push(r),r.node&&this.nodes.push(r.node)),r},addAction(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let i=`serialize`in e?e:r(e,this);if(n){let e=s({sourceNode:n,destinationNode:i,sourceHandle:null},this);this.edges.push(e)}return this.nodes.push(i),i},addCondition(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=`serialize`in e?e:c(e,this);if(n){if(!r.node)throw Error(`todo no node`);let e=s({sourceNode:n,destinationNode:r.node,sourceHandle:null},this);this.edges.push(e)}return this.conditions.includes(r)||(this.conditions.push(r),r.node&&this.nodes.push(r.node)),r},addConditional(e,t){return this.addCondition(e,t)},addExperience(e,t){let n=t?.node;this.nodes.length===0&&(n=o({type:`origin`},this),this.nodes.push(n));let r=o({type:`experience`,experience:e},this);if(this.nodes.push(r),n){let e=s({sourceNode:n,destinationNode:r,sourceHandle:null},this);this.edges.push(e)}return e},addField(e,t){let n=`serialize`in e?e:l(e);return t&&t.fields.push(n),this.fields.includes(n)||this.fields.push(n),n},serialize(){return t.serialize({id:this.id,key:this.key,component:this.component,name:this.name,initializeOpen:this.initializeOpen,condition:this.condition,targets:this.targets,steps:this.steps.map(e=>t.deserialize(e.serialize())),nodes:this.nodes.map(e=>t.deserialize(e.serialize())),edges:this.edges.map(e=>t.deserialize(e.serialize())),conditions:this.conditions.map(e=>t.deserialize(e.serialize())),fields:this.fields.map(e=>t.deserialize(e.serialize()))})}});exports.createCondition=c,exports.createEdge=s,exports.createExperience=u,exports.createExperiencePlugin=n,exports.createField=l,exports.createNode=o,exports.createStep=i;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../../logger-fbvQC40v.cjs`);const e=require(`../../../api-DO5hnUsd.cjs`);function t(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function n(e){return t(e)%100}function r(e,t){return t<=0?!1:t>=100?!0:e<t}function i(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function a(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function o(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function s(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function c(e,t){if(Array.isArray(t.steps))for(let n of t.steps)e.registerStep(n)}function l(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)o(e,n)}function u(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function d(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function f(e,t,r){let i=d(e),a=e.session?.id;if(!a)throw Error(`Session ID is required for feature registration`);let o=n(a);for(let n of t.features)i.has(n.id)||p(e,n,r,o)}function p(e,t,n,i){e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,storage:n?`session`:`local`,decide:()=>t.enabled?r(i,t.weight):!1})}function m(){let e;try{e=__PICKED_PROJECT_CONFIG__}catch{return}if(e===void 0)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else t=e;if(i(t))return t}function h(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function g(e){if(typeof e!=`object`||!e||!(`cause`in e))return!1;let{cause:t}=e;return typeof t!=`object`||!t||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function _(t,n,r){let a=r?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${n}`,o;try{o=await e.t(t,a,r?.headers)}catch(e){return h(t)&&g(e),null}if(!o.ok)return`${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return null}return i(s)?s:null}function v(e){return{name:`dynamic-experiences`,setup:t=>{let n=e?.apiUrl??t.apiUrl;return{onStart:async()=>{let r=u(t);if(r){let e=await _(n,t.projectId,{previewToken:r});e&&(f(t,e,!0),a(t,e),s(t,e),c(t,e),l(t,e));return}let i=e?.projectConfig??m();if(i){f(t,i,!1),a(t,i),s(t,i),c(t,i),l(t,i);return}let o=await _(n,t.projectId);o&&(f(t,o,!1),a(t,o),s(t,o),c(t,o),l(t,o))}}}}}exports.createClientHeaders=e.i,exports.dynamicExperiencesPlugin=v,exports.fetchProject=_;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../../logger-fbvQC40v.cjs`);const e=require(`../../../api-DVSjNleu.cjs`);function t(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function n(e){return t(e)%100}function r(e,t){return t<=0?!1:t>=100?!0:e<t}function i(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function a(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function o(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function s(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function c(e,t){if(!Array.isArray(t.steps))return;let n=new Map;if(Array.isArray(t.fields))for(let e of t.fields)n.set(e.id,e.key);for(let r of t.steps)e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:r.fieldIds.map(e=>n.get(e)??e),layoutName:r.layoutName})}function l(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)o(e,n)}function u(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function d(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function f(e,t,r){let i=d(e),a=e.session?.id;if(!a)throw Error(`Session ID is required for feature registration`);let o=n(a);for(let n of t.features)i.has(n.id)||p(e,n,r,o)}function p(e,t,n,i){e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,storage:n?`session`:`local`,decide:()=>t.enabled?r(i,t.weight):!1})}function m(){let e;try{e=__PICKED_PROJECT_CONFIG__}catch{return}if(e===void 0)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else t=e;if(i(t))return t}function h(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function g(e){if(typeof e!=`object`||!e||!(`cause`in e))return!1;let{cause:t}=e;return typeof t!=`object`||!t||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function _(t,n,r){let a=r?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${n}`,o;try{o=await e.t(t,a,r?.headers)}catch(e){return h(t)&&g(e),null}if(!o.ok)return`${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return null}return i(s)?s:null}function v(e){return{name:`dynamic-experiences`,setup:t=>{let n=e?.apiUrl??t.apiUrl;return{onStart:async()=>{let r=u(t);if(r){let e=await _(n,t.projectId,{previewToken:r});e&&(f(t,e,!0),a(t,e),s(t,e),c(t,e),l(t,e));return}let i=e?.projectConfig??m();if(i){f(t,i,!1),a(t,i),s(t,i),c(t,i),l(t,i);return}let o=await _(n,t.projectId);o&&(f(t,o,!1),a(t,o),s(t,o),c(t,o),l(t,o))}}}}}exports.createClientHeaders=e.i,exports.dynamicExperiencesPlugin=v,exports.fetchProject=_;
@@ -0,0 +1,58 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Actions
6
+
7
+ An action is a side effect that triggers when the flow reaches it. Use actions for tasks like tracking events, sending data to external services, or triggering webhooks.
8
+
9
+ ## Create an action
10
+
11
+ 1. Open your project.
12
+ 2. Click **Actions** in the sidebar.
13
+ 3. Click **New Action**.
14
+ 4. Enter a name and key.
15
+ 5. Click **Create**.
16
+
17
+ The key is a unique identifier used in your application. It's set once and can't be changed later.
18
+
19
+ ## Configure an action
20
+
21
+ **Name**: The display name shown in the dashboard. Not visible to visitors.
22
+
23
+ **Key**: The programmatic identifier your application uses to reference this action. Not visible to visitors.
24
+
25
+ ## Register in your application
26
+
27
+ Actions must be registered when creating the Picked client. Pass an `actions` object where each key matches an action key from the dashboard:
28
+
29
+ ```typescript
30
+ import { createClient } from '@picked/client'
31
+
32
+ const picked = createClient({
33
+ organizationId: 'your-org-id',
34
+ projectId: 'your-project-id',
35
+ actions: {
36
+ 'track-signup': () => {
37
+ analytics.track('signup_completed')
38
+ },
39
+ 'notify': (params) => {
40
+ sendNotification(params)
41
+ },
42
+ },
43
+ })
44
+ ```
45
+
46
+ Each action is a function that receives optional parameters and returns nothing. When the flow reaches an action node, the SDK calls the matching function.
47
+
48
+ See [SDK Actions](/sdk/actions) for more details.
49
+
50
+ ## Use actions in flows
51
+
52
+ In the flow builder, drag an action from the entity browser onto the canvas. Connect it to the point in the flow where you want it to trigger.
53
+
54
+ Actions execute when the flow reaches their node. They don't interrupt the visitor's experience — the flow continues to the next connected node.
55
+
56
+ ## Reuse actions
57
+
58
+ Actions are project-level entities. Use the same action in multiple experience flows. Changes to an action's configuration apply everywhere it's used.
@@ -0,0 +1,32 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # API
6
+
7
+ The Picked API is a GraphQL API that provides programmatic access to all platform features.
8
+
9
+ ## Playground
10
+
11
+ Explore the API and run queries interactively using the [GraphQL Playground](https://api.picked.app/api/graphql).
12
+
13
+ ## Authentication
14
+
15
+ Authenticate requests by including an API key in the `Authorization` header.
16
+
17
+ ```
18
+ Authorization: Bearer your-api-key
19
+ ```
20
+
21
+ See [API Keys](/api-keys) for how to create and manage keys.
22
+
23
+ ## Making requests
24
+
25
+ Send a POST request to the GraphQL endpoint with your query in the request body.
26
+
27
+ ```bash
28
+ curl -X POST https://api.picked.app/api/graphql \
29
+ -H "Content-Type: application/json" \
30
+ -H "Authorization: Bearer your-api-key" \
31
+ -d '{"query": "{ viewer { id email } }"}'
32
+ ```
@@ -0,0 +1,33 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # API keys
6
+
7
+ API keys let you access Picked's API programmatically. Use them for server-side integrations or CI/CD workflows.
8
+
9
+ ## Create an API key
10
+
11
+ 1. Open your organization.
12
+ 2. Click **API Keys**.
13
+ 3. Click **Create Key**.
14
+ 4. Enter a description.
15
+ 5. Click **Create**.
16
+
17
+ Copy the key immediately — it won't be shown again.
18
+
19
+ ## Using an API key
20
+
21
+ Include your API key in the `Authorization` header when making requests to the [Picked API](/api).
22
+
23
+ ```
24
+ Authorization: Bearer your-api-key
25
+ ```
26
+
27
+ ## Scopes
28
+
29
+ API keys can be scoped to limit what they can access. When creating a key, select the scopes that match your integration's needs. A key can only perform actions allowed by its assigned scopes.
30
+
31
+ ## Revoke a key
32
+
33
+ Revoke a key at any time from the API keys list. Click the revoke button next to the key you want to disable. Revoked keys stop working immediately.
@@ -0,0 +1,52 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Conditions
6
+
7
+ A condition evaluates logic and branches the flow into two paths — one for when the condition is true, another for when it's false.
8
+
9
+ ## Create a condition
10
+
11
+ 1. Open your project.
12
+ 2. Click **Conditions** in the sidebar.
13
+ 3. Click **New Condition**.
14
+ 4. Enter a name and key.
15
+ 5. Click **Create**.
16
+
17
+ ## Configure a condition
18
+
19
+ **Name**: The display name shown in the dashboard. Not visible to visitors.
20
+
21
+ **Key**: The programmatic identifier. Set once, can't change. Not visible to visitors.
22
+
23
+ ## Define logic
24
+
25
+ Select a condition node in the flow builder to open its inspector. The **Logic** section contains a visual [condition builder](/flow-builder/condition-builder).
26
+
27
+ The condition builder lets you create rules using AND/OR groups. Each rule compares a data source against an operator and a target value.
28
+
29
+ ### Available data sources
30
+
31
+ **Responses** — values visitors have submitted through form fields. For example, check if a visitor entered a specific email domain or selected a particular option.
32
+
33
+ **Actions** — references to actions that have been triggered during the flow.
34
+
35
+ **Features** — the state of feature flags in your project. Branch based on which variant a visitor is assigned to.
36
+
37
+ **Location** — properties of the visitor's current page URL, including pathname, search parameters, hostname, and hash. For example, show different content based on which page the visitor is on.
38
+
39
+ ### Example
40
+
41
+ To branch based on a visitor's country selection:
42
+
43
+ 1. Add a rule: **Responses → country** equals `US`.
44
+ 2. The green (true) path handles US visitors. The red (false) path handles everyone else.
45
+
46
+ To combine multiple conditions, create an AND or OR group and add rules within it.
47
+
48
+ ## Branching
49
+
50
+ In the flow builder, condition nodes have two output handles. The green handle (true) leads to the path taken when the condition matches. The red handle (false) leads to the alternative path.
51
+
52
+ You can chain conditions. Connect the output of one condition to the input of another to create complex decision trees.
@@ -0,0 +1,33 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Experiences
6
+
7
+ An experience is a personalized UI flow delivered to visitors on your site. Each experience maps to a component registered in your application.
8
+
9
+ ## Create an experience
10
+
11
+ 1. Open your project.
12
+ 2. Click **Experiences** in the sidebar.
13
+ 3. Click **New Experience**.
14
+ 4. Enter a name and a component name. The component name must match a component registered in your application. See [SDK Experiences](/sdk/experiences) for details on registering components.
15
+ 5. Click **Create**.
16
+
17
+ The flow editor opens with an empty canvas. See [Building Flows](/flow-builder/building-flows) to start adding nodes.
18
+
19
+ ## Experience settings
20
+
21
+ Select no nodes on the canvas (or click the canvas background) to open the experience inspector in the right panel.
22
+
23
+ **Name**: The display name shown in the dashboard. Visitors don't see this.
24
+
25
+ **Component Name**: The identifier that maps this experience to a registered component in your application.
26
+
27
+ **Condition**: An optional activation condition. When set, the experience only activates for visitors who match the condition logic. See [Condition Builder](/flow-builder/condition-builder) for details on configuring conditions. Leave blank to activate for all visitors.
28
+
29
+ **Initialize Open**: An optional condition that controls whether the experience opens automatically on page load. When blank, the experience loads but stays closed until opened.
30
+
31
+ ## Experience list
32
+
33
+ The experiences list shows all experiences in the current project. Click any experience to open it in the flow builder.
@@ -0,0 +1,51 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Features
6
+
7
+ Features let you run A/B tests and feature flags. Control which visitors see which variant of your site without deploying code changes.
8
+
9
+ ## Create a feature
10
+
11
+ 1. Open your project.
12
+ 2. Click **Features** in the sidebar.
13
+ 3. Click **New Feature**.
14
+ 4. Enter a name.
15
+ 5. Click **Create**.
16
+
17
+ ## Keys
18
+
19
+ Each feature has a unique key. Use this key in your application to check which variant a visitor is assigned to. The key is set when you create the feature and cannot be changed later.
20
+
21
+ ## Configure variants
22
+
23
+ Each feature has one or more variants. Visitors are assigned to a variant based on the rules you define.
24
+
25
+ Configure variant allocation, targeting rules, and rollout percentages from the feature detail page.
26
+
27
+ ## How visitors are bucketed
28
+
29
+ Visitors are assigned to variants using weight-based probabilistic rollout. Each variant has a weight from 0 to 100, representing the percentage of traffic it receives.
30
+
31
+ For example, with two variants weighted 50/50, roughly half of visitors see each variant. A variant weighted at 0 receives no traffic.
32
+
33
+ Bucketing is deterministic — the same visitor sees the same variant on repeat visits, unless the feature version changes.
34
+
35
+ ## Feature versions
36
+
37
+ Each feature has a version number (starting at 1). Incrementing the version resets all visitor assignments, so every visitor is re-evaluated as if they were seeing the feature for the first time.
38
+
39
+ ### What happens when you increment the version
40
+
41
+ - **All visitors are re-allocated.** Every visitor currently allocated to this feature will be re-evaluated against the new version. A visitor who was in the control group may end up in a variant, and vice versa.
42
+ - **Cached decisions are invalidated.** The SDK caches allocation decisions in browser storage using a key that includes the version. When the version changes, the old cache entry no longer matches, forcing a fresh evaluation on the next page load.
43
+ - **This is irreversible.** You cannot decrement a version. Once incremented, the previous allocation assignments are lost.
44
+
45
+ ### When to increment
46
+
47
+ Increment the version when you have changed the weight or allocation and want all visitors — including those already allocated — to be re-evaluated from scratch.
48
+
49
+ ### When not to increment
50
+
51
+ If you only want changes to affect new visitors (those who haven't been allocated yet), update the weight without incrementing the version. Existing visitors will keep their current assignment.
@@ -0,0 +1,70 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Fields
6
+
7
+ A field is a data input shown to visitors inside a step. Fields collect information like names, email addresses, preferences, or selections.
8
+
9
+ ## Create a field
10
+
11
+ 1. Open your project.
12
+ 2. Click **Fields** in the sidebar.
13
+ 3. Click **New Field**.
14
+ 4. Enter a name, key, and label.
15
+ 5. Select a type.
16
+ 6. Click **Create**.
17
+
18
+ ## Field types
19
+
20
+ Fields support many types. Here are some common examples:
21
+
22
+ `TEXT`: A string input. Use for names, emails, free-form text.
23
+
24
+ `NUMBER`: A numeric input. Use for quantities, ratings, ages.
25
+
26
+ `BOOLEAN`: A true/false toggle. Use for checkboxes, opt-ins, consent.
27
+
28
+ `OBJECT`: A structured data input. Use for complex or nested data.
29
+
30
+ ## Configuration
31
+
32
+ **Name**: Display name in the dashboard. Not visible to visitors.
33
+
34
+ **Key**: Programmatic identifier. Set once, can't change. Not visible to visitors.
35
+
36
+ **Label**: The label visitors see next to the field.
37
+
38
+ **Placeholder**: Hint text shown inside the input when empty.
39
+
40
+ **Description**: A longer description of the field's purpose. Shown in the dashboard, not to visitors.
41
+
42
+ **Help Text**: Assistive text shown to visitors below the field.
43
+
44
+ **Default Value**: The initial value when the field loads.
45
+
46
+ ## Validation
47
+
48
+ **Required**: When enabled, visitors must fill in this field before proceeding.
49
+
50
+ **Validation rules**: Define conditions for advanced constraints like minimum/maximum values, patterns, or custom logic. See [Condition Builder](/flow-builder/condition-builder) for details on building validation rules.
51
+
52
+ ## Multiple values
53
+
54
+ Enable **Multiple** to allow visitors to submit more than one value for this field. Useful for multi-select inputs or tag-style fields.
55
+
56
+ ## Options
57
+
58
+ For fields that present a fixed set of choices (like dropdowns or radio buttons), add options. Each option has a value that gets submitted with the response.
59
+
60
+ Each option can also have a condition applied. When a condition is set, the option only appears to visitors who match the condition logic. See [Condition Builder](/flow-builder/condition-builder) for details.
61
+
62
+ ## Privacy
63
+
64
+ **Do Not Track**: When enabled, this field's data is excluded from analytics tracking.
65
+
66
+ **Do Not Store**: When enabled, this field's data is processed but not persisted. Use for sensitive information like passwords or payment details.
67
+
68
+ ## Reuse fields
69
+
70
+ Fields are project-level entities. Assign the same field to multiple steps across different experiences. Changes to a field's configuration apply everywhere it's used.
@@ -0,0 +1,61 @@
1
+ ---
2
+ layout: docs
3
+ ---
4
+
5
+ # Building flows
6
+
7
+ Build flows by dragging blocks onto the canvas, connecting nodes with arrows, and configuring each node in the inspector.
8
+
9
+ ## Add nodes
10
+
11
+ Drag a step, action, or condition from the entity browser onto the canvas. A new node appears where you drop it.
12
+
13
+ You can also drop a block directly onto an existing arrow. The node inserts inline — the original arrow splits into two arrows with the new node in between. A **+** indicator appears when you hover over a valid arrow.
14
+
15
+ ## Connect nodes
16
+
17
+ Click and drag from a node's output handle (right side) to another node's input handle (left side). An arrow appears connecting them.
18
+
19
+ The flow follows arrows from left to right, starting at the origin. Every node downstream of the origin is part of the experience flow.
20
+
21
+ ## Branch with conditions
22
+
23
+ Connect the origin (or any node) to a condition node. The condition evaluates its logic and routes the flow down one of two paths.
24
+
25
+ Connect the green (true) handle to the nodes that should run when the condition passes. Connect the red (false) handle to the alternative path. Either path can lead to more steps, actions, or further conditions.
26
+
27
+ ## Assign fields to steps
28
+
29
+ Drag a field from the entity browser and drop it onto a step node. The field is now assigned to that step.
30
+
31
+ You can assign multiple fields to a single step. The step node shows a count of assigned fields. To see which fields are assigned, select the step and check the **Assigned Fields** section in the inspector.
32
+
33
+ ## Select nodes
34
+
35
+ Click a node to select it. Its inspector opens in the right panel.
36
+
37
+ Drag on empty canvas to marquee-select multiple nodes. Press `Cmd/Ctrl+A` to select all nodes.
38
+
39
+ When multiple nodes are selected, the inspector shows a count and grouped list. Click any item in the list to navigate to its inspector.
40
+
41
+ ## Move nodes
42
+
43
+ Drag a selected node to reposition it. Nodes snap to the grid automatically.
44
+
45
+ Use arrow keys to nudge selected nodes. Hold `Shift` for larger nudges.
46
+
47
+ ## Delete nodes
48
+
49
+ Select one or more nodes and press `Delete` or `Backspace`. The nodes and their connected arrows are removed.
50
+
51
+ ## Duplicate nodes
52
+
53
+ Select one or more nodes and press `Cmd/Ctrl+D`. Copies appear offset from the originals.
54
+
55
+ ## Undo and redo
56
+
57
+ Press `Cmd/Ctrl+Z` to undo. Press `Cmd/Ctrl+Shift+Z` to redo. The undo stack tracks node additions, deletions, connections, and position changes.
58
+
59
+ ---
60
+
61
+ [Overview](/flow-builder/overview) · [Nodes](/flow-builder/nodes) · **Building Flows** · [Keyboard Shortcuts](/flow-builder/keyboard-shortcuts) · [Condition Builder](/flow-builder/condition-builder)