@picked/client 0.0.1-dev.1776662399138 → 0.0.1-dev.1776837084253

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 (54) hide show
  1. package/dist/{api-C5p0q172.js → api-6oxKA__k.js} +1 -1
  2. package/dist/{api-CE3ISEsc.cjs → api-CIC-Uysx.cjs} +1 -1
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  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/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  9. package/dist/cjs/plugins/web-components/index.js +1 -1
  10. package/dist/cjs/plugins/window-object/index.js +1 -1
  11. package/dist/cjs/server/index.js +1 -1
  12. package/dist/docs/pickedql/data-sources.md +61 -2
  13. package/dist/docs/pickedql/examples.md +84 -0
  14. package/dist/docs/pickedql/index.md +1 -0
  15. package/dist/docs/pickedql/schema.md +28 -0
  16. package/dist/docs/pickedql/virtual-functions.md +40 -3
  17. package/dist/docs/sdk/actions.md +31 -1
  18. package/dist/docs/sdk/conditions.md +14 -8
  19. package/dist/docs/sdk/experiences.md +21 -18
  20. package/dist/docs/sdk/features.md +8 -8
  21. package/dist/docs/sdk/fields.md +9 -9
  22. package/dist/docs/sdk/steps.md +12 -12
  23. package/dist/esm/form/index.js +1 -1
  24. package/dist/esm/index.js +158 -284
  25. package/dist/esm/plugins/create-experience/index.js +1 -1
  26. package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
  27. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  28. package/dist/esm/plugins/single-page-app/index.js +28 -14
  29. package/dist/esm/plugins/web-components/index.js +1 -1
  30. package/dist/esm/plugins/window-object/index.js +1 -1
  31. package/dist/esm/server/index.js +1 -1
  32. package/dist/experience-CNIhapU2.js +136 -0
  33. package/dist/experience-CTEBY-it.cjs +1 -0
  34. package/dist/experience-instance-Cu8oGGr9.cjs +1 -0
  35. package/dist/experience-instance-DIpWYaA6.js +387 -0
  36. package/dist/nodes-2fst8XKi.js +101 -0
  37. package/dist/nodes-DBK4N9YY.cjs +1 -0
  38. package/dist/rules-logic-D7dL30U1.js +263 -0
  39. package/dist/rules-logic-DJhGFqhC.cjs +1 -0
  40. package/dist/types/plugins/single-page-app/plugin.d.ts +15 -4
  41. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/experience-instance-DG9HFNSE.cjs +0 -1
  44. package/dist/experience-instance-DffMstSs.js +0 -486
  45. package/dist/object-C82v79xc.js +0 -25
  46. package/dist/object-CUJOjanb.cjs +0 -1
  47. package/dist/rules-logic-B--rEvGw.js +0 -240
  48. package/dist/rules-logic-D_dZ52-Q.cjs +0 -1
  49. /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
  50. /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
  51. /package/dist/{logger-6z_gb4rA.js → logger-C44jSdYl.js} +0 -0
  52. /package/dist/{logger-fbvQC40v.cjs → logger-CJUj90QX.cjs} +0 -0
  53. /package/dist/{supports-0XIfd4-R.js → supports-B_trw6lj.js} +0 -0
  54. /package/dist/{supports-Dsjg-82e.cjs → supports-CKSVYpQx.cjs} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,142 +1,16 @@
1
- import { n as e, t } from "../rules-logic-B--rEvGw.js";
2
- import { t as n } from "../object-C82v79xc.js";
3
- import { t as r } from "../logger-6z_gb4rA.js";
4
- import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
5
- import { a as g, c as _, i as v, l as ee, n as te, o as ne, r as re, s as y } from "../experience-instance-DffMstSs.js";
6
- import { i as ie, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
7
- import { n as ae, r as oe } from "../api-C5p0q172.js";
8
- import { t as se } from "../id-CRqy981z.js";
1
+ import { r as e, t } from "../rules-logic-D7dL30U1.js";
2
+ import { t as n } from "../logger-C44jSdYl.js";
3
+ import { a as r, c as i, d as a, i as o, l as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "../supports-B_trw6lj.js";
4
+ import { a as h, c as g, u as _ } from "../nodes-2fst8XKi.js";
5
+ import { n as v, t as ee } from "../experience-CNIhapU2.js";
6
+ import { i as te, n as y, r as b, t as x } from "../storage-6Xk0uAxB.js";
7
+ import { n as ne, r as re } from "../api-6oxKA__k.js";
8
+ import { n as ie } from "../experience-instance-DIpWYaA6.js";
9
+ import { t as S } from "../id-n2yrHvNo.js";
9
10
  import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
10
11
  import { createFactory as j, invoke as M } from "@withease/factories";
11
- //#region src/entities/experience/experience.ts
12
- var N = E("experience"), ce = j(({ client: e, experience: t }) => {
13
- let n = N.store(t), r = T(n, { merge(e, t) {
14
- return {
15
- ...e,
16
- ...t.experience
17
- };
18
- } }), i = n.map((e) => ({
19
- name: e.name,
20
- decisionLogic: e.condition,
21
- targetSelectors: e.targets,
22
- initializeOpenLogic: e.initializeOpen
23
- })), a = w(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 }), o = w(n, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
24
- let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
25
- return {
26
- steps: r,
27
- nodes: e.nodes,
28
- edges: e.edges,
29
- conditions: i
30
- };
31
- }), s = t.actions ?? [];
32
- return {
33
- id: t.id,
34
- key: t.key,
35
- name: t.name,
36
- configStore: i,
37
- treeStore: o,
38
- componentStore: a,
39
- actions: s,
40
- merge: r.merge
41
- };
42
- });
43
- function le(e) {
44
- return M(ce, e);
45
- }
46
- var ue = j(({ client: e }) => {
47
- let t = N.store({}), n = T(t, { register(e, t) {
48
- return {
49
- ...e,
50
- [t.id]: t
51
- };
52
- } });
53
- function r(r) {
54
- let i = t.getState()[r.id];
55
- if (i) {
56
- i.merge({
57
- experience: r,
58
- strategy: "override"
59
- });
60
- return;
61
- }
62
- let a = le({
63
- client: e,
64
- experience: r
65
- });
66
- n.register(a);
67
- }
68
- let i = t.map((e) => Object.values(e));
69
- function a(e) {
70
- return t.map((t) => t[e], { skipVoid: !1 });
71
- }
72
- function o(e) {
73
- return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
74
- }
75
- let s = C({
76
- source: t,
77
- effect: async (t, n) => {
78
- let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
79
- if (!r) {
80
- "key" in n ? `${n.key}` : `${n.id}`;
81
- return;
82
- }
83
- let { options: i } = n;
84
- if (i?.bypassCondition) {
85
- P(e, r, i);
86
- return;
87
- }
88
- await I(e, r) && P(e, r, i);
89
- }
90
- });
91
- return {
92
- register: r,
93
- get: a,
94
- getById: a,
95
- getByKey: o,
96
- launch: s,
97
- open: C({
98
- source: {
99
- experiences: t,
100
- instances: e.experienceInstances.listStore
101
- },
102
- effect: ({ experiences: e, instances: t }, n) => {
103
- 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);
104
- if (i.length > 0) for (let e of i) e.open();
105
- else s("key" in n ? {
106
- key: n.key,
107
- options: {
108
- ...n.options,
109
- initialiseOpen: !0
110
- }
111
- } : {
112
- id: n.id,
113
- options: {
114
- ...n.options,
115
- initialiseOpen: !0
116
- }
117
- });
118
- }
119
- }),
120
- listStore: i
121
- };
122
- });
123
- function de(e) {
124
- return M(ue, e);
125
- }
126
- var P = (e, t, n) => {
127
- let { targetSelectors: r } = t.configStore.getState(), i = y(r, t.id);
128
- i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), g(i, t.id, t.key).forEach((r) => {
129
- n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
130
- });
131
- }, F = async (e) => {
132
- await Promise.all(e.experiences.listStore.getState().map(async (t) => {
133
- await I(e, t) && P(e, t);
134
- }));
135
- }, I = async (n, r) => {
136
- if (!n.preconditionPassed || !n.session?.isUser) return !1;
137
- let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
138
- return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
139
- }, fe = (e, t, n) => {
12
+ //#region src/entities/plugin/plugin.ts
13
+ var ae = (e, t, n) => {
140
14
  let r = t.name, i = t.setup(e);
141
15
  if (i) {
142
16
  let e = n[r] ?? {};
@@ -145,16 +19,16 @@ var P = (e, t, n) => {
145
19
  ...i
146
20
  });
147
21
  }
148
- }, L = E("component"), R = j(({ client: e, component: t, name: n }) => ({
22
+ }, oe = E("component"), se = j(({ client: e, component: t, name: n }) => ({
149
23
  name: n,
150
24
  component: t,
151
25
  frameworkStore: e.frameworks.getByName(t.frameworkName)
152
26
  }));
153
- function z(e) {
154
- return M(R, e);
27
+ function ce(e) {
28
+ return M(se, e);
155
29
  }
156
- var B = j(({ client: e }) => {
157
- let t = L.store({}), n = T(t, { register(e, t) {
30
+ var le = j(({ client: e }) => {
31
+ let t = oe.store({}), n = T(t, { register(e, t) {
158
32
  return {
159
33
  ...e,
160
34
  [t.name]: t
@@ -162,7 +36,7 @@ var B = j(({ client: e }) => {
162
36
  } });
163
37
  function r(r, i) {
164
38
  t.getState()[r] && `${r}`;
165
- let a = z({
39
+ let a = ce({
166
40
  client: e,
167
41
  name: r,
168
42
  component: i
@@ -179,13 +53,13 @@ var B = j(({ client: e }) => {
179
53
  listStore: i
180
54
  };
181
55
  });
182
- function V(e) {
183
- return M(B, e);
56
+ function ue(e) {
57
+ return M(le, e);
184
58
  }
185
- var H = (e, t, n) => {
59
+ var N = (e, t, n) => {
186
60
  n.register(e, t);
187
- }, pe = E("framework"), me = j(({ client: e }) => {
188
- let t = pe.store({}), n = T(t, { register(e, t) {
61
+ }, P = E("framework"), F = j(({ client: e }) => {
62
+ let t = P.store({}), n = T(t, { register(e, t) {
189
63
  return {
190
64
  ...e,
191
65
  [t.name]: t.framework
@@ -207,21 +81,21 @@ var H = (e, t, n) => {
207
81
  listStore: i
208
82
  };
209
83
  });
210
- function he(e) {
211
- return M(me, e);
84
+ function I(e) {
85
+ return M(F, e);
212
86
  }
213
- var ge = (e, t) => {
87
+ var L = (e, t) => {
214
88
  t.register(e.name, e);
215
- }, _e = 6e3, ve = S("last_ping", "global"), ye = async (e) => {
89
+ }, R = 6e3, z = x("last_ping", "global"), B = async (e) => {
216
90
  try {
217
- let t = Date.now(), n = b.get(ve), r = 0;
218
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
91
+ let t = Date.now(), n = y.get(z), r = 0;
92
+ if (n.isSet() && (r = n.json() ?? 0), r && t - r < R) return !0;
219
93
  let i = {
220
94
  projectId: e.projectId,
221
95
  path: window.location.pathname
222
96
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
223
97
  o && (a["x-vercel-protection-bypass"] = o);
224
- let s = (await ae(e.apiUrl, "ping", i, a)).ok;
98
+ let s = (await ne(e.apiUrl, "ping", i, a)).ok;
225
99
  return s && n.set(t), s;
226
100
  } catch {
227
101
  return !1;
@@ -229,7 +103,7 @@ var ge = (e, t) => {
229
103
  };
230
104
  //#endregion
231
105
  //#region src/utils/state-snaphot.ts
232
- function U(e) {
106
+ function V(e) {
233
107
  let t = typeof window < "u", n = {
234
108
  client: e,
235
109
  responses: e.responses.listStore.getState(),
@@ -243,8 +117,8 @@ function U(e) {
243
117
  }
244
118
  //#endregion
245
119
  //#region src/entities/predicate/predicate.ts
246
- var be = E("predicate"), xe = j(({ client: e }) => {
247
- let t = be.store({}), n = T(t, { register(e, t) {
120
+ var H = E("predicate"), U = j(({ client: e }) => {
121
+ let t = H.store({}), n = T(t, { register(e, t) {
248
122
  return {
249
123
  ...e,
250
124
  [t.name]: {
@@ -267,7 +141,7 @@ var be = E("predicate"), xe = j(({ client: e }) => {
267
141
  let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
268
142
  let n = a(t).getState();
269
143
  if (!n) return;
270
- let r = U(e);
144
+ let r = V(e);
271
145
  return (...e) => n({
272
146
  ...r,
273
147
  args: e
@@ -292,12 +166,12 @@ var be = E("predicate"), xe = j(({ client: e }) => {
292
166
  getEvokablePredicate: o
293
167
  };
294
168
  });
295
- function Se(e) {
296
- return M(xe, e);
169
+ function de(e) {
170
+ return M(U, e);
297
171
  }
298
- var Ce = (e, t, n) => {
172
+ var fe = (e, t, n) => {
299
173
  n.register(e, t);
300
- }, W = E("feature"), we = j(({ client: e }) => {
174
+ }, W = E("feature"), pe = j(({ client: e }) => {
301
175
  let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
302
176
  return {
303
177
  ...e,
@@ -319,7 +193,7 @@ var Ce = (e, t, n) => {
319
193
  }));
320
194
  }
321
195
  let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
322
- let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
196
+ let r = x(`feature:${e}:${t}`, "global"), i = (n === "session" ? b : y).get(r).boolean();
323
197
  return i === null ? null : {
324
198
  id: e,
325
199
  key: t,
@@ -328,8 +202,8 @@ var Ce = (e, t, n) => {
328
202
  };
329
203
  }), o = D((e) => {
330
204
  if (!e) return null;
331
- let t = S(`feature:${e.id}:${e.key}`, "global");
332
- (e.storage === "session" ? x : b).set(t, e.bucket);
205
+ let t = x(`feature:${e.id}:${e.key}`, "global");
206
+ (e.storage === "session" ? b : y).set(t, e.bucket);
333
207
  }), s = /* @__PURE__ */ new Map(), c = C({
334
208
  source: {
335
209
  allFeaturesStore: t,
@@ -452,21 +326,21 @@ var Ce = (e, t, n) => {
452
326
  getEvokableFeature: f
453
327
  };
454
328
  });
455
- function Te(e) {
456
- return M(we, e);
329
+ function me(e) {
330
+ return M(pe, e);
457
331
  }
458
- var Ee = (e, t, n) => {
332
+ var he = (e, t, n) => {
459
333
  n.register(e, t);
460
334
  }, G = E("history");
461
335
  function K(e, t) {
462
336
  return {
463
- id: se(`history-entry-${Date.now()}-${Math.random()}}`),
337
+ id: S(`history-entry-${Date.now()}-${Math.random()}}`),
464
338
  node: t,
465
339
  at: Date.now(),
466
340
  experienceId: e
467
341
  };
468
342
  }
469
- var De = j(() => {
343
+ var ge = j(() => {
470
344
  let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
471
345
  e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
472
346
  function a(e, t) {
@@ -476,7 +350,7 @@ var De = j(() => {
476
350
  };
477
351
  for (let r = e.length - 1; r >= 0; r--) {
478
352
  let i = e[r], a = i?.node;
479
- if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
353
+ if (!(!a || !h(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
480
354
  else {
481
355
  n.secondLastStepIndex = r;
482
356
  break;
@@ -498,25 +372,25 @@ var De = j(() => {
498
372
  entriesStore: e.map((e) => e.entries)
499
373
  };
500
374
  });
501
- function Oe() {
502
- return M(De);
375
+ function _e() {
376
+ return M(ge);
503
377
  }
504
378
  //#endregion
505
379
  //#region src/utils/events.ts
506
- var ke = 0, Ae = (e) => {
380
+ var ve = 0, ye = (e) => {
507
381
  let t = k([]);
508
382
  return A({
509
383
  clock: e,
510
384
  source: t,
511
385
  fn: (e, t) => [...e, {
512
- id: ke++,
386
+ id: ve++,
513
387
  at: /* @__PURE__ */ new Date(),
514
388
  payload: t
515
389
  }],
516
390
  target: t
517
391
  }), t;
518
- }, je = E("field"), Me = j(() => {
519
- let e = je.store({}), t = T(e, {
392
+ }, be = E("field"), xe = j(() => {
393
+ let e = be.store({}), t = T(e, {
520
394
  register(e, t) {
521
395
  return {
522
396
  ...e,
@@ -560,13 +434,13 @@ var ke = 0, Ae = (e) => {
560
434
  getByName: s
561
435
  };
562
436
  });
563
- function Ne() {
564
- return M(Me);
437
+ function Se() {
438
+ return M(xe);
565
439
  }
566
440
  //#endregion
567
441
  //#region src/entities/step/step.ts
568
- var Pe = E("step"), Fe = j(() => {
569
- let e = Pe.store({}), t = T(e, { register(e, t) {
442
+ var Ce = E("step"), we = j(() => {
443
+ let e = Ce.store({}), t = T(e, { register(e, t) {
570
444
  return {
571
445
  ...e,
572
446
  [t.step.id]: t.step
@@ -590,16 +464,16 @@ var Pe = E("step"), Fe = j(() => {
590
464
  indexStore: e
591
465
  };
592
466
  });
593
- function Ie() {
594
- return M(Fe);
467
+ function Te() {
468
+ return M(we);
595
469
  }
596
- function Le(e, t) {
470
+ function Ee(e, t) {
597
471
  t.register(e);
598
472
  }
599
473
  //#endregion
600
474
  //#region src/entities/action/action.ts
601
- var Re = E("action"), ze = j(({ client: e }) => {
602
- let t = Re.store({}), n = T(t, { register(e, t) {
475
+ var De = E("action"), Oe = j(({ client: e }) => {
476
+ let t = De.store({}), n = T(t, { register(e, t) {
603
477
  return {
604
478
  ...e,
605
479
  [t.key]: {
@@ -622,7 +496,7 @@ var Re = E("action"), ze = j(({ client: e }) => {
622
496
  let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
623
497
  let n = a(t).getState();
624
498
  if (!n) return;
625
- let r = U(e);
499
+ let r = V(e);
626
500
  return (...e) => n({
627
501
  ...r,
628
502
  args: e
@@ -647,10 +521,10 @@ var Re = E("action"), ze = j(({ client: e }) => {
647
521
  getEvokableAction: o
648
522
  };
649
523
  });
650
- function Be(e) {
651
- return M(ze, e);
524
+ function ke(e) {
525
+ return M(Oe, e);
652
526
  }
653
- var Ve = (e, t, n) => {
527
+ var Ae = (e, t, n) => {
654
528
  n.register(e, t);
655
529
  };
656
530
  //#endregion
@@ -666,7 +540,7 @@ function q(e, t, n, r) {
666
540
  function J(e) {
667
541
  return e == null || e === "" || Array.isArray(e) && !e.length;
668
542
  }
669
- function He(e) {
543
+ function je(e) {
670
544
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
671
545
  }
672
546
  function Y(e) {
@@ -676,13 +550,13 @@ function Y(e) {
676
550
  return !1;
677
551
  }
678
552
  }
679
- function Ue(e, t) {
553
+ function Me(e, t) {
680
554
  return t.find((t) => t.key === e) ?? null;
681
555
  }
682
- function We(e, t) {
556
+ function Ne(e, t) {
683
557
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
684
558
  }
685
- function Ge(e, t) {
559
+ function Pe(e, t) {
686
560
  if (e.type !== "object" || J(t)) return null;
687
561
  if (e.multiple) {
688
562
  if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
@@ -694,7 +568,7 @@ function Ge(e, t) {
694
568
  }
695
569
  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.).");
696
570
  }
697
- function Ke(e, t) {
571
+ function Fe(e, t) {
698
572
  if (!Array.isArray(e.options) || e.options.length === 0) return null;
699
573
  let n = Array.isArray(t) ? t : [t];
700
574
  if (e.type === "object") {
@@ -702,23 +576,23 @@ function Ke(e, t) {
702
576
  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.");
703
577
  }
704
578
  let r = e.options.map((e) => e.value);
705
- return n.every((e) => !He(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(", ")}`);
579
+ return n.every((e) => !je(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(", ")}`);
706
580
  }
707
- async function qe(e, t, r, i) {
708
- if (t.validation && !n(t.validation) && !J(r)) {
709
- let n = i ? {
581
+ async function Ie(t, n, r, i) {
582
+ if (n.validation && !e(n.validation) && !J(r)) {
583
+ let e = i ? {
710
584
  $input: r,
711
585
  responses: i
712
- } : { $input: r }, a = await e(t.validation, n);
713
- if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
714
- if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
586
+ } : { $input: r }, a = await t(n.validation, e);
587
+ if (typeof a == "string") return q(n, r, a, `Field validation resulted in an error: ${a}.`);
588
+ if (a === !1) return q(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
715
589
  }
716
- return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
590
+ 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;
717
591
  }
718
592
  //#endregion
719
593
  //#region src/entities/response/response.ts
720
- var Je = E("response"), Ye = j(({ client: e }) => {
721
- let n = Je.store({}), r = O(), i = O(), a = T(n, {
594
+ var Le = E("response"), Re = j(({ client: e }) => {
595
+ let n = Le.store({}), r = O(), i = O(), a = T(n, {
722
596
  register(e, t) {
723
597
  return {
724
598
  ...e,
@@ -757,7 +631,7 @@ var Je = E("response"), Ye = j(({ client: e }) => {
757
631
  ...t,
758
632
  ...n
759
633
  }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
760
- let o = Ue(t, e);
634
+ let o = Me(t, e);
761
635
  if (!o) {
762
636
  r.push({
763
637
  fieldKey: t,
@@ -767,17 +641,17 @@ var Je = E("response"), Ye = j(({ client: e }) => {
767
641
  });
768
642
  return;
769
643
  }
770
- let c = We(o, n), l = await qe(s, o, c, a);
644
+ let c = Ne(o, n), l = await Ie(s, o, c, a);
771
645
  if (l) {
772
646
  r.push(l);
773
647
  return;
774
648
  }
775
- let u = Ge(o, c);
649
+ let u = Pe(o, c);
776
650
  if (u) {
777
651
  r.push(u);
778
652
  return;
779
653
  }
780
- let d = Ke(o, c);
654
+ let d = Fe(o, c);
781
655
  if (d) {
782
656
  r.push(d);
783
657
  return;
@@ -856,13 +730,13 @@ var Je = E("response"), Ye = j(({ client: e }) => {
856
730
  getByFieldName: _
857
731
  };
858
732
  });
859
- function Xe(e) {
860
- return M(Ye, e);
733
+ function ze(e) {
734
+ return M(Re, e);
861
735
  }
862
736
  //#endregion
863
737
  //#region src/entities/condition/condition.ts
864
- var Ze = E("condition"), Qe = j(() => {
865
- let e = Ze.store({}), t = T(e, { register(e, t) {
738
+ var Be = E("condition"), Ve = j(() => {
739
+ let e = Be.store({}), t = T(e, { register(e, t) {
866
740
  return {
867
741
  ...e,
868
742
  [t.condition.id]: t.condition
@@ -886,13 +760,13 @@ var Ze = E("condition"), Qe = j(() => {
886
760
  indexStore: e
887
761
  };
888
762
  });
889
- function $e() {
890
- return M(Qe);
763
+ function He() {
764
+ return M(Ve);
891
765
  }
892
766
  //#endregion
893
767
  //#region src/utils/api-url.ts
894
- function et() {
895
- if (f()) {
768
+ function Ue() {
769
+ if (d()) {
896
770
  let e = [
897
771
  document.currentScript,
898
772
  document.getElementById("picked_script"),
@@ -906,36 +780,36 @@ function et() {
906
780
  }
907
781
  //#endregion
908
782
  //#region src/utils/search-params.ts
909
- function tt() {
910
- if (!o()) return {};
783
+ function We() {
784
+ if (!a()) return {};
911
785
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
912
786
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
913
787
  for (let r of n) {
914
788
  let n = r.replace("picked-", "");
915
789
  t[n] = e.getAll(r);
916
790
  }
917
- let r = S("s");
918
- if (n.size > 0) x.set(r, t);
791
+ let r = x("s");
792
+ if (n.size > 0) b.set(r, t);
919
793
  else {
920
- let e = x.get(r);
794
+ let e = b.get(r);
921
795
  if (e) return e.json() || {};
922
796
  }
923
797
  return t;
924
798
  }
925
799
  //#endregion
926
800
  //#region src/utils/user-session.ts
927
- function nt() {
928
- return l() ? 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)}`;
801
+ function Ge() {
802
+ return c() ? 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)}`;
929
803
  }
930
- var rt = S("session", "global"), it = () => {
931
- let e = b.get(rt), t;
804
+ var Ke = x("session", "global"), qe = () => {
805
+ let e = y.get(Ke), t;
932
806
  e.isSet() && (t = e.json());
933
807
  let n = (t) => e.set({
934
808
  id: t.id,
935
809
  isUser: t.isUser,
936
810
  identifiers: t.identifiers
937
811
  }), r = {
938
- id: t?.id ?? nt(),
812
+ id: t?.id ?? Ge(),
939
813
  isUser: t?.isUser ?? void 0,
940
814
  identifiers: t?.identifiers ?? void 0,
941
815
  setIsUser(e) {
@@ -952,22 +826,22 @@ var rt = S("session", "global"), it = () => {
952
826
  }
953
827
  };
954
828
  return n(r), r;
955
- }, X = () => u() ? it() : null;
829
+ }, Je = () => l() ? qe() : null;
956
830
  //#endregion
957
831
  //#region src/utils/picked-config.ts
958
- function Z() {
959
- if (o()) return globalThis.window.pickedConfig;
832
+ function X() {
833
+ if (a()) return globalThis.window.pickedConfig;
960
834
  }
961
- function at() {
962
- if (!o()) return;
963
- let e = Z(), t = e?.organizationId, n = e?.projectId;
835
+ function Ye() {
836
+ if (!a()) return;
837
+ let e = X(), t = e?.organizationId, n = e?.projectId;
964
838
  return t && n ? {
965
839
  organizationId: t,
966
840
  projectId: n
967
841
  } : void 0;
968
842
  }
969
- function ot() {
970
- if (!f()) return;
843
+ function Xe() {
844
+ if (!d()) return;
971
845
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
972
846
  if (!e) return;
973
847
  let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
@@ -976,15 +850,15 @@ function ot() {
976
850
  projectId: n
977
851
  } : void 0;
978
852
  }
979
- function st(e) {
853
+ function Z(e) {
980
854
  let { organizationId: t, projectId: n } = e;
981
855
  if (t && n) return {
982
856
  organizationId: t,
983
857
  projectId: n
984
858
  };
985
- let r = at();
859
+ let r = Ye();
986
860
  if (r) return r;
987
- let i = ot();
861
+ let i = Xe();
988
862
  if (i) return i;
989
863
  throw Error("organizationId and projectId are required. You can provide them via one of:\n (1) createClient({ organizationId, projectId }) options;\n (2) window.pickedConfig = { organizationId, projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.");
990
864
  }
@@ -993,7 +867,7 @@ function st(e) {
993
867
  function Q(e) {
994
868
  return e == null || e === "" || Number.isNaN(e);
995
869
  }
996
- var ct = {
870
+ var Ze = {
997
871
  default: (e, t) => Q(e) ? String(t ?? "") : String(e),
998
872
  append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
999
873
  prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
@@ -1014,24 +888,24 @@ var ct = {
1014
888
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
1015
889
  }
1016
890
  };
1017
- function lt(e) {
891
+ function Qe(e) {
1018
892
  return typeof e == "object" && !!e;
1019
893
  }
1020
- function ut(e, t) {
894
+ function $e(e, t) {
1021
895
  let n = t;
1022
- for (let t of e.split(".")) if (lt(n) && t in n) n = n[t];
896
+ for (let t of e.split(".")) if (Qe(n) && t in n) n = n[t];
1023
897
  else return;
1024
898
  return typeof n == "function" ? n() : n;
1025
899
  }
1026
- function dt(e, t) {
1027
- let n = e.split("|").map((e) => e.trim()), r = ut(n.shift() ?? "", t);
900
+ function et(e, t) {
901
+ let n = e.split("|").map((e) => e.trim()), r = $e(n.shift() ?? "", t);
1028
902
  for (let e of n) {
1029
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = ct[i];
903
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ze[i];
1030
904
  o && (r = o(r, a));
1031
905
  }
1032
906
  return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
1033
907
  }
1034
- function ft(e, t) {
908
+ function tt(e, t) {
1035
909
  let n = "", r = 0;
1036
910
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
1037
911
  r += 2;
@@ -1043,14 +917,14 @@ function ft(e, t) {
1043
917
  }
1044
918
  i += e[r++];
1045
919
  }
1046
- n += dt(i.trim(), t);
920
+ n += et(i.trim(), t);
1047
921
  } else n += e[r++];
1048
922
  return n;
1049
923
  }
1050
924
  //#endregion
1051
925
  //#region src/picked.ts
1052
926
  var $ = class {
1053
- static logger = r;
927
+ static logger = n;
1054
928
  options;
1055
929
  isReady = !1;
1056
930
  plugins = {};
@@ -1066,30 +940,30 @@ var $ = class {
1066
940
  precondition;
1067
941
  condition;
1068
942
  preconditionPassed;
1069
- searchParams = tt();
1070
- history = Oe();
1071
- components = V({ client: this });
1072
- experienceInstances = te({ client: this });
1073
- experiences = de({ client: this });
1074
- frameworks = he({ client: this });
1075
- predicates = Se({ client: this });
1076
- features = Te({ client: this });
1077
- conditions = $e();
1078
- fields = Ne();
1079
- responses = Xe({ client: this });
1080
- steps = Ie();
1081
- actions = Be({ client: this });
943
+ searchParams = We();
944
+ history = _e();
945
+ components = ue({ client: this });
946
+ experienceInstances = ie({ client: this });
947
+ experiences = ee({ client: this });
948
+ frameworks = I({ client: this });
949
+ predicates = de({ client: this });
950
+ features = me({ client: this });
951
+ conditions = He();
952
+ fields = Se();
953
+ responses = ze({ client: this });
954
+ steps = Te();
955
+ actions = ke({ client: this });
1082
956
  constructor(e) {
1083
- this.events = Ae(this.eventBus);
1084
- let { organizationId: t, projectId: n } = st(e);
1085
- this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = X(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
957
+ this.events = ye(this.eventBus);
958
+ let { organizationId: t, projectId: n } = Z(e);
959
+ this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Je(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
1086
960
  type: "load",
1087
- version: oe()
961
+ version: re()
1088
962
  });
1089
963
  }
1090
964
  start = () => {
1091
- ye(this), (async () => {
1092
- if (!f()) return;
965
+ B(this), (async () => {
966
+ if (!d()) return;
1093
967
  await this.runPluginStartHooks();
1094
968
  let e = await this.evaluateGate(this.precondition);
1095
969
  this.preconditionPassed = e;
@@ -1103,7 +977,7 @@ var $ = class {
1103
977
  value: e
1104
978
  });
1105
979
  }
1106
- if (this.eventBus({ type: "initialize" }), n && F(this), await ne(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
980
+ if (this.eventBus({ type: "initialize" }), n && v(this), await g(), n && v(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1107
981
  let { id: e, isUser: t, identifiers: n } = this.session;
1108
982
  this.eventBus({
1109
983
  type: "session",
@@ -1115,21 +989,21 @@ var $ = class {
1115
989
  })();
1116
990
  };
1117
991
  registerFramework = (e) => {
1118
- ge(e, this.frameworks);
992
+ L(e, this.frameworks);
1119
993
  };
1120
994
  registerComponent = (e, t) => {
1121
- H(e, t, this.components);
995
+ N(e, t, this.components);
1122
996
  };
1123
997
  registerPlugin = (e) => {
1124
- fe(this, e, this.plugins);
998
+ ae(this, e, this.plugins);
1125
999
  let t = this.plugins[e.name];
1126
1000
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1127
1001
  };
1128
1002
  registerFeature = (e, t) => {
1129
- Ee(e, t, this.features);
1003
+ he(e, t, this.features);
1130
1004
  };
1131
1005
  registerPredicate = (e, t) => {
1132
- Ce(e, t, this.predicates);
1006
+ fe(e, t, this.predicates);
1133
1007
  };
1134
1008
  registerCondition = (e) => {
1135
1009
  this.conditions.register(e);
@@ -1138,15 +1012,15 @@ var $ = class {
1138
1012
  this.fields.register(e);
1139
1013
  };
1140
1014
  registerStep = (e) => {
1141
- Le(e, this.steps);
1015
+ Ee(e, this.steps);
1142
1016
  };
1143
1017
  registerAction = (e, t) => {
1144
- Ve(e, t, this.actions);
1018
+ Ae(e, t, this.actions);
1145
1019
  };
1146
1020
  registerExperience = (e) => {
1147
- e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1021
+ e.component && N(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1148
1022
  };
1149
- getStateSnapshot = () => U(this);
1023
+ getStateSnapshot = () => V(this);
1150
1024
  launchExperienceById = async (e, t) => {
1151
1025
  this.experiences.launch({
1152
1026
  id: e,
@@ -1235,7 +1109,7 @@ var $ = class {
1235
1109
  getPluginConfig = (e) => this.plugins[e] ?? {};
1236
1110
  renderString = (e, t) => {
1237
1111
  let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
1238
- return ft(e, {
1112
+ return tt(e, {
1239
1113
  ...t,
1240
1114
  responses: n
1241
1115
  });
@@ -1243,20 +1117,20 @@ var $ = class {
1243
1117
  };
1244
1118
  //#endregion
1245
1119
  //#region src/entities/component/lazyComponent.ts
1246
- function pt(e) {
1120
+ function nt(e) {
1247
1121
  return {
1248
1122
  $$type: "lazy-component",
1249
1123
  load: e
1250
1124
  };
1251
1125
  }
1252
- function mt(e) {
1126
+ function rt(e) {
1253
1127
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1254
1128
  }
1255
1129
  //#endregion
1256
1130
  //#region src/exports.ts
1257
- var ht = (e) => {
1131
+ var it = (e) => {
1258
1132
  let t = new $(e);
1259
- return d(t), t;
1133
+ return u(t), t;
1260
1134
  };
1261
1135
  //#endregion
1262
- export { $ as Picked, ht as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, mt as isLazyLoader, _ as isPickedRoot, pt as lazyComponent, b as localStore, x as sessionStore, ie as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
1136
+ export { $ as Picked, it as createClient, x as createStorageKey, t as evaluateRuleLogic, X as getPickedConfig, rt as isLazyLoader, _ as isPickedRoot, nt as lazyComponent, y as localStore, b as sessionStore, te as subscribe, p as supportsCookies, c as supportsCryptoRandomUUID, d as supportsDocument, o as supportsHistory, r as supportsIntersectionObserver, l as supportsLocalStorage, f as supportsLocation, i as supportsSessionStorage, s as supportsShadowRoot, m as supportsWebComponents, a as supportsWindow };