@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475

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 (79) hide show
  1. package/dist/{api-BEXzPJHZ.cjs → api-B-wGEgt8.cjs} +1 -1
  2. package/dist/{api-oudcFuUX.js → api-DwERBrAZ.js} +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/responses-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/web-components/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/esm/form/index.js +128 -84
  11. package/dist/esm/index.js +393 -334
  12. package/dist/esm/plugins/create-experience/index.js +183 -151
  13. package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
  14. package/dist/esm/plugins/responses-browser-storage/index.js +47 -20
  15. package/dist/esm/plugins/web-components/index.js +1 -1
  16. package/dist/esm/server/index.js +1 -1
  17. package/dist/{experience-instance-DZiAwXph.js → experience-instance-CwwrKUI8.js} +50 -46
  18. package/dist/experience-instance-DdFUcVRd.cjs +1 -0
  19. package/dist/{rules-logic-B7vJrWyO.js → rules-logic-BIkBWZmf.js} +4 -2
  20. package/dist/rules-logic-DDxCiq4P.cjs +1 -0
  21. package/dist/types/entities/condition/condition.d.ts +17 -0
  22. package/dist/types/entities/condition/condition.d.ts.map +1 -0
  23. package/dist/types/entities/experience/experience.d.ts +40 -35
  24. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  25. package/dist/types/entities/experience-instance/experience-instance.d.ts +21 -2
  26. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  27. package/dist/types/entities/field/field.d.ts +13 -2
  28. package/dist/types/entities/field/field.d.ts.map +1 -1
  29. package/dist/types/entities/response/response-validation.d.ts +76 -0
  30. package/dist/types/entities/response/response-validation.d.ts.map +1 -0
  31. package/dist/types/entities/response/response.d.ts +24 -17
  32. package/dist/types/entities/response/response.d.ts.map +1 -1
  33. package/dist/types/entities/step/step.d.ts +36 -0
  34. package/dist/types/entities/step/step.d.ts.map +1 -0
  35. package/dist/types/form/build-responses.d.ts +12 -9
  36. package/dist/types/form/build-responses.d.ts.map +1 -1
  37. package/dist/types/form/create-field-evaluator.d.ts +11 -3
  38. package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
  39. package/dist/types/form/create-field-validation.d.ts +21 -6
  40. package/dist/types/form/create-field-validation.d.ts.map +1 -1
  41. package/dist/types/form/create-form.d.ts +42 -11
  42. package/dist/types/form/create-form.d.ts.map +1 -1
  43. package/dist/types/form/create-submit-pipeline.d.ts +21 -9
  44. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
  45. package/dist/types/form/get-step-fields.d.ts +13 -0
  46. package/dist/types/form/get-step-fields.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +2 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/logic-engine.d.ts +10 -2
  50. package/dist/types/logic-engine.d.ts.map +1 -1
  51. package/dist/types/picked.d.ts +68 -32
  52. package/dist/types/picked.d.ts.map +1 -1
  53. package/dist/types/plugins/create-experience/create-experience.d.ts +51 -29
  54. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  55. package/dist/types/plugins/create-experience/index.d.ts +2 -2
  56. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  57. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  58. package/dist/types/plugins/create-experience/serialization.d.ts +1 -0
  59. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
  60. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
  61. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  62. package/dist/types/plugins/dynamic-experiences/types.d.ts +41 -0
  63. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  64. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  65. package/dist/types/utils/events.d.ts +1 -1
  66. package/dist/types/utils/events.d.ts.map +1 -1
  67. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
  68. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
  69. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +10 -6
  70. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  71. package/dist/types/utils/nodes.d.ts +74 -2
  72. package/dist/types/utils/nodes.d.ts.map +1 -1
  73. package/dist/types/utils/rules-logic.d.ts +31 -0
  74. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  75. package/package.json +32 -6
  76. package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
  77. package/dist/rules-logic-CXr4wXcG.cjs +0 -1
  78. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
  79. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { n as e, t } from "../rules-logic-B7vJrWyO.js";
1
+ import { n as e, t } from "../rules-logic-BIkBWZmf.js";
2
2
  import { t as n } from "../object-C82v79xc.js";
3
3
  import { t as r } from "../logger-6z_gb4rA.js";
4
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 ee, i as te, n as _, o as v, r as y, s as ne } from "../experience-instance-DZiAwXph.js";
6
- import { i as re, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
7
- import { n as ie, r as ae } from "../api-oudcFuUX.js";
8
- import { t as oe } from "../id-CRqy981z.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 ie, u as ae } from "../experience-instance-CwwrKUI8.js";
6
+ import { i as y, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
7
+ import { n as oe, r as se } from "../api-DwERBrAZ.js";
8
+ import { t as ce } from "../id-CRqy981z.js";
9
9
  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
10
  import { createFactory as j, invoke as M } from "@withease/factories";
11
11
  //#region src/entities/experience/experience.ts
12
- var N = E("experience"), se = j(({ client: e, experience: t }) => {
12
+ var N = E("experience"), le = j(({ client: e, experience: t }) => {
13
13
  let n = N.store(t), r = T(n, { merge(e, t) {
14
14
  return {
15
15
  ...e,
@@ -19,34 +19,41 @@ var N = E("experience"), se = j(({ client: e, experience: t }) => {
19
19
  name: e.name,
20
20
  decisionLogic: e.condition,
21
21
  targetSelectors: e.targets,
22
- initializeOpenLogic: t.initializeOpen
23
- })), a = e.components.listStore.map((e) => (t.componentName ? e.find((e) => e.name === t.componentName) : void 0) || e.find((e) => e.name === `experience:${t.id}`) || e.find((e) => e.name === "experience"), { skipVoid: !1 }), o = n.map((e) => ({
24
- steps: e.steps,
25
- nodes: e.nodes,
26
- edges: e.edges,
27
- conditionals: e.conditionals
28
- })), s = n.map((e) => e.fields), c = t.actions ?? [];
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.listStore, e.conditions.listStore, (e, t, n) => {
24
+ let r = e.nodes.filter(v).map((e) => {
25
+ let n = e.stepId;
26
+ return t.find((e) => e.id === n || e.key === n);
27
+ }).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n.find((t) => t.id === g(e))).filter((e) => e !== void 0);
28
+ return {
29
+ steps: r,
30
+ nodes: e.nodes,
31
+ edges: e.edges,
32
+ conditions: i
33
+ };
34
+ }), s = t.actions ?? [];
29
35
  return {
30
36
  id: t.id,
37
+ key: t.key,
38
+ name: t.name,
31
39
  configStore: i,
32
40
  treeStore: o,
33
- fieldsStore: s,
34
41
  componentStore: a,
35
- actions: c,
42
+ actions: s,
36
43
  merge: r.merge
37
44
  };
38
45
  });
39
- function ce(e) {
40
- return M(se, e);
46
+ function ue(e) {
47
+ return M(le, e);
41
48
  }
42
- var le = j(({ client: e }) => {
49
+ var de = j(({ client: e }) => {
43
50
  let t = N.store({}), n = T(t, { register(e, t) {
44
51
  return {
45
52
  ...e,
46
53
  [t.id]: t
47
54
  };
48
- } });
49
- function r(r) {
55
+ } }), r = t.map((e) => Object.fromEntries(Object.values(e).map((e) => [e.key, e.id])));
56
+ function i(r) {
50
57
  let i = t.getState()[r.id];
51
58
  if (i) {
52
59
  i.merge({
@@ -55,61 +62,65 @@ var le = j(({ client: e }) => {
55
62
  });
56
63
  return;
57
64
  }
58
- let a = ce({
65
+ let a = ue({
59
66
  client: e,
60
67
  experience: r
61
68
  });
62
69
  n.register(a);
63
70
  }
64
- let i = t.map((e) => Object.values(e));
65
- function a(e) {
66
- return t.map((t) => t[e], { skipVoid: !1 });
71
+ let a = t.map((e) => Object.values(e));
72
+ function o(e) {
73
+ return w(t, r, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
67
74
  }
68
- let o = C({
69
- source: t,
70
- effect: async (t, { id: n, options: r }) => {
71
- let i = t[n];
72
- if (!i) {
73
- `${n}`;
75
+ let s = C({
76
+ source: {
77
+ experiences: t,
78
+ keys: r
79
+ },
80
+ effect: async ({ experiences: t, keys: n }, { key: r, id: i, options: a }) => {
81
+ let o = r ?? i ?? "", s = t[n[o] ?? ""] ?? t[o];
82
+ if (!s) {
83
+ `${o}`;
74
84
  return;
75
85
  }
76
- if (r?.bypassCondition) {
77
- P(e, i, r);
86
+ if (a?.bypassCondition) {
87
+ P(e, s, a);
78
88
  return;
79
89
  }
80
- await I(e, i) && P(e, i, r);
90
+ await I(e, s) && P(e, s, a);
81
91
  }
82
92
  });
83
93
  return {
84
- register: r,
85
- get: a,
86
- getById: a,
87
- launch: o,
94
+ register: i,
95
+ get: o,
96
+ getById: o,
97
+ launch: s,
88
98
  open: C({
89
- source: e.experienceInstances.listStore,
90
- effect: (e, { id: t, options: n }) => {
91
- let r = e.filter((e) => e.experienceId === t);
92
- if (r.length > 0) for (let e of r) e.open();
93
- else o({
94
- id: t,
99
+ source: {
100
+ instances: e.experienceInstances.listStore,
101
+ keys: r
102
+ },
103
+ effect: ({ instances: e, keys: t }, { key: n, id: r, options: i }) => {
104
+ let a = n ?? r ?? "", o = t[a] ?? a, c = e.filter((e) => e.experienceId === o);
105
+ if (c.length > 0) for (let e of c) e.open();
106
+ else s({
107
+ key: o,
95
108
  options: {
96
- ...n,
109
+ ...i,
97
110
  initialiseOpen: !0
98
111
  }
99
112
  });
100
113
  }
101
114
  }),
102
- listStore: i
115
+ listStore: a
103
116
  };
104
117
  });
105
- function ue(e) {
106
- return M(le, e);
118
+ function fe(e) {
119
+ return M(de, e);
107
120
  }
108
- var de = (e, t) => {
109
- t.register(e);
110
- }, P = (e, t, n) => {
111
- let { targetSelectors: r } = t.configStore.getState(), i = v(r, t.id);
112
- i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), te(i, t.id).forEach((r) => {
121
+ var P = (e, t, n) => {
122
+ let { targetSelectors: r } = t.configStore.getState(), i = _(r, t.id);
123
+ i.forEach(({ elements: e }) => e.forEach((e) => ae(e, t.id))), ne(i, t.id).forEach((r) => {
113
124
  n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
114
125
  });
115
126
  }, F = async (e) => {
@@ -119,7 +130,7 @@ var de = (e, t) => {
119
130
  }, I = async (n, r) => {
120
131
  if (!n.preconditionPassed || !n.session?.isUser) return !1;
121
132
  let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
122
- return v(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
133
+ return _(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
123
134
  }, L = (e, t, n) => {
124
135
  let r = t.name, i = t.setup(e);
125
136
  if (i) {
@@ -163,13 +174,13 @@ var V = j(({ client: e }) => {
163
174
  listStore: i
164
175
  };
165
176
  });
166
- function H(e) {
177
+ function pe(e) {
167
178
  return M(V, e);
168
179
  }
169
- var U = (e, t, n) => {
180
+ var H = (e, t, n) => {
170
181
  n.register(e, t);
171
- }, fe = E("framework"), pe = j(({ client: e }) => {
172
- let t = fe.store({}), n = T(t, { register(e, t) {
182
+ }, me = E("framework"), he = j(({ client: e }) => {
183
+ let t = me.store({}), n = T(t, { register(e, t) {
173
184
  return {
174
185
  ...e,
175
186
  [t.name]: t.framework
@@ -191,21 +202,21 @@ var U = (e, t, n) => {
191
202
  listStore: i
192
203
  };
193
204
  });
194
- function me(e) {
195
- return M(pe, e);
205
+ function ge(e) {
206
+ return M(he, e);
196
207
  }
197
- var he = (e, t) => {
208
+ var _e = (e, t) => {
198
209
  t.register(e.name, e);
199
- }, ge = 6e3, _e = S("last_ping", "global"), ve = async (e) => {
210
+ }, ve = 6e3, ye = S("last_ping", "global"), be = async (e) => {
200
211
  try {
201
- let t = Date.now(), n = b.get(_e), r = 0;
202
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < ge) return !0;
212
+ let t = Date.now(), n = b.get(ye), r = 0;
213
+ if (n.isSet() && (r = n.json() ?? 0), r && t - r < ve) return !0;
203
214
  let i = {
204
215
  projectId: e.projectId,
205
216
  path: window.location.pathname
206
217
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
207
218
  o && (a["x-vercel-protection-bypass"] = o);
208
- let s = (await ie(e.apiUrl, "ping", i, a)).ok;
219
+ let s = (await oe(e.apiUrl, "ping", i, a)).ok;
209
220
  return s && n.set(t), s;
210
221
  } catch {
211
222
  return !1;
@@ -213,7 +224,7 @@ var he = (e, t) => {
213
224
  };
214
225
  //#endregion
215
226
  //#region src/utils/state-snaphot.ts
216
- function W(e) {
227
+ function U(e) {
217
228
  let t = typeof window < "u", n = {
218
229
  client: e,
219
230
  responses: e.responses.listStore.getState(),
@@ -227,8 +238,8 @@ function W(e) {
227
238
  }
228
239
  //#endregion
229
240
  //#region src/entities/predicate/predicate.ts
230
- var ye = E("predicate"), be = j(({ client: e }) => {
231
- let t = ye.store({}), n = T(t, { register(e, t) {
241
+ var xe = E("predicate"), Se = j(({ client: e }) => {
242
+ let t = xe.store({}), n = T(t, { register(e, t) {
232
243
  return {
233
244
  ...e,
234
245
  [t.name]: {
@@ -251,7 +262,7 @@ var ye = E("predicate"), be = j(({ client: e }) => {
251
262
  let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
252
263
  let n = a(t).getState();
253
264
  if (!n) return;
254
- let r = W(e);
265
+ let r = U(e);
255
266
  return (...e) => n({
256
267
  ...r,
257
268
  args: e
@@ -276,13 +287,13 @@ var ye = E("predicate"), be = j(({ client: e }) => {
276
287
  getEvokablePredicate: o
277
288
  };
278
289
  });
279
- function xe(e) {
280
- return M(be, e);
290
+ function Ce(e) {
291
+ return M(Se, e);
281
292
  }
282
- var Se = (e, t, n) => {
293
+ var we = (e, t, n) => {
283
294
  n.register(e, t);
284
- }, G = E("feature"), Ce = j(({ client: e }) => {
285
- let t = G.store({}), n = G.store([]), r = T(t, { register(e, t) {
295
+ }, W = E("feature"), Te = j(({ client: e }) => {
296
+ let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
286
297
  return {
287
298
  ...e,
288
299
  [t.id]: t.feature
@@ -436,23 +447,23 @@ var Se = (e, t, n) => {
436
447
  getEvokableFeature: f
437
448
  };
438
449
  });
439
- function we(e) {
440
- return M(Ce, e);
450
+ function Ee(e) {
451
+ return M(Te, e);
441
452
  }
442
- var Te = (e, t, n) => {
453
+ var De = (e, t, n) => {
443
454
  n.register(e, t);
444
- }, K = E("history");
445
- function q(e, t) {
455
+ }, G = E("history");
456
+ function K(e, t) {
446
457
  return {
447
- id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
458
+ id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
448
459
  node: t,
449
460
  at: Date.now(),
450
461
  experienceId: e
451
462
  };
452
463
  }
453
- var Ee = j(() => {
454
- let e = K.store({ entries: [] }), t = K.event(), n = K.event(), r = K.event(), i = K.event();
455
- e.on(t, (e, t) => ({ entries: [...e.entries, q(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), q(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
464
+ var Oe = j(() => {
465
+ let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
466
+ 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);
456
467
  function a(e, t) {
457
468
  let n = {
458
469
  lastStepIndex: -1,
@@ -460,7 +471,7 @@ var Ee = j(() => {
460
471
  };
461
472
  for (let r = e.length - 1; r >= 0; r--) {
462
473
  let i = e[r], a = i?.node;
463
- if (!(!a || !y(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
474
+ if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
464
475
  else {
465
476
  n.secondLastStepIndex = r;
466
477
  break;
@@ -482,25 +493,25 @@ var Ee = j(() => {
482
493
  entriesStore: e.map((e) => e.entries)
483
494
  };
484
495
  });
485
- function J() {
486
- return M(Ee);
496
+ function ke() {
497
+ return M(Oe);
487
498
  }
488
499
  //#endregion
489
500
  //#region src/utils/events.ts
490
- var De = 0, Oe = (e) => {
501
+ var Ae = 0, je = (e) => {
491
502
  let t = k([]);
492
503
  return A({
493
504
  clock: e,
494
505
  source: t,
495
506
  fn: (e, t) => [...e, {
496
- id: De++,
507
+ id: Ae++,
497
508
  at: /* @__PURE__ */ new Date(),
498
509
  payload: t
499
510
  }],
500
511
  target: t
501
512
  }), t;
502
- }, ke = E("field"), Ae = j(() => {
503
- let e = ke.store({}), t = T(e, {
513
+ }, Me = E("field"), Ne = j(() => {
514
+ let e = Me.store({}), t = T(e, {
504
515
  register(e, t) {
505
516
  return {
506
517
  ...e,
@@ -518,34 +529,67 @@ var De = 0, Oe = (e) => {
518
529
  function n(e) {
519
530
  t.register({ field: e });
520
531
  }
521
- function r(e, n) {
532
+ function r(n, r) {
533
+ let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.id ?? n;
522
534
  t.updateById({
523
- fieldId: e,
524
- updates: n
535
+ fieldId: a,
536
+ updates: r
525
537
  });
526
538
  }
527
539
  let i = e.map((e) => Object.values(e));
528
540
  function a(t) {
529
- return e.map((e) => e[t] || null);
541
+ return e.map((e) => e[t] ?? null);
530
542
  }
531
543
  function o(t) {
532
- return e.map((e) => Object.values(e).find((e) => e.name === t) || null);
544
+ return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
545
+ }
546
+ function s(t) {
547
+ return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null);
533
548
  }
534
549
  return {
535
550
  register: n,
536
551
  update: r,
537
552
  getById: a,
553
+ getByKey: o,
538
554
  listStore: i,
539
- getByName: o
555
+ getByName: s
540
556
  };
541
557
  });
542
- function je() {
543
- return M(Ae);
558
+ function Pe() {
559
+ return M(Ne);
544
560
  }
545
- var Me = (e, t) => {
561
+ //#endregion
562
+ //#region src/entities/step/step.ts
563
+ var Fe = E("step"), Ie = j(() => {
564
+ let e = Fe.store({}), t = T(e, { register(e, t) {
565
+ return {
566
+ ...e,
567
+ [t.step.id]: t.step
568
+ };
569
+ } });
570
+ function n(e) {
571
+ t.register({ step: e });
572
+ }
573
+ let r = e.map((e) => Object.values(e));
574
+ function i(t) {
575
+ return e.map((e) => e[t] ?? null);
576
+ }
577
+ return {
578
+ register: n,
579
+ getById: i,
580
+ listStore: r
581
+ };
582
+ });
583
+ function Le() {
584
+ return M(Ie);
585
+ }
586
+ function Re(e, t) {
546
587
  t.register(e);
547
- }, Ne = E("action"), Pe = j(() => {
548
- let e = Ne.store({}), t = T(e, { register(e, t) {
588
+ }
589
+ //#endregion
590
+ //#region src/entities/action/action.ts
591
+ var ze = E("action"), Be = j(() => {
592
+ let e = ze.store({}), t = T(e, { register(e, t) {
549
593
  return {
550
594
  ...e,
551
595
  [t.name]: {
@@ -577,33 +621,83 @@ var Me = (e, t) => {
577
621
  getEvokableAction: a
578
622
  };
579
623
  });
580
- function Fe() {
581
- return M(Pe);
624
+ function Ve() {
625
+ return M(Be);
582
626
  }
583
- var Ie = (e, t, n) => {
627
+ var He = (e, t, n) => {
584
628
  n.register(e, t);
585
629
  };
586
630
  //#endregion
587
- //#region src/entities/response/response.ts
588
- function Y(e) {
631
+ //#region src/entities/response/response-validation.ts
632
+ function q(e, t, n, r) {
633
+ return {
634
+ fieldKey: e.key,
635
+ fieldId: e.id,
636
+ userMessage: n,
637
+ systemMessage: r,
638
+ value: t
639
+ };
640
+ }
641
+ function J(e) {
589
642
  return e == null || e === "" || Array.isArray(e) && !e.length;
590
643
  }
591
- function Le(e) {
644
+ function Ue(e) {
592
645
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
593
646
  }
594
- function X(e) {
647
+ function Y(e) {
595
648
  try {
596
649
  return JSON.stringify(e), !0;
597
650
  } catch {
598
651
  return !1;
599
652
  }
600
653
  }
601
- var Re = E("response"), ze = j(({ client: e }) => {
602
- let r = Re.store({}), i = O(), a = O(), o = T(r, {
654
+ function We(e, t) {
655
+ return t.find((t) => t.id === e) ?? t.find((t) => t.key === e) ?? null;
656
+ }
657
+ function Ge(e, t) {
658
+ return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
659
+ }
660
+ function Ke(e, t) {
661
+ if (e.type !== "object" || J(t)) return null;
662
+ if (e.multiple) {
663
+ if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
664
+ for (let n of t) {
665
+ 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.");
666
+ if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
667
+ }
668
+ return null;
669
+ }
670
+ 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.).");
671
+ }
672
+ function qe(e, t) {
673
+ if (!Array.isArray(e.options) || e.options.length === 0) return null;
674
+ let n = Array.isArray(t) ? t : [t];
675
+ if (e.type === "object") {
676
+ let r = e.options.map((e) => JSON.stringify(e.value));
677
+ 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.");
678
+ }
679
+ let r = e.options.map((e) => e.value);
680
+ return n.every((e) => !Ue(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(", ")}`);
681
+ }
682
+ async function Je(e, t, r, i) {
683
+ if (t.validation && !n(t.validation) && !J(r)) {
684
+ let n = i ? {
685
+ $input: r,
686
+ responses: i
687
+ } : { $input: r }, a = await e(t.validation, n);
688
+ if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
689
+ if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
690
+ }
691
+ 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;
692
+ }
693
+ //#endregion
694
+ //#region src/entities/response/response.ts
695
+ var Ye = E("response"), Xe = j(({ client: e }) => {
696
+ let n = Ye.store({}), r = O(), i = O(), a = T(n, {
603
697
  register(e, t) {
604
698
  return {
605
699
  ...e,
606
- [t.fieldId]: t.response
700
+ [t.fieldKey]: t.response
607
701
  };
608
702
  },
609
703
  registerBatch(e, t) {
@@ -613,221 +707,178 @@ var Re = E("response"), ze = j(({ client: e }) => {
613
707
  };
614
708
  },
615
709
  clear(e, t) {
616
- let { [t]: n, ...r } = e;
617
- return r;
710
+ return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
618
711
  },
619
712
  clearAll() {
620
713
  return {};
621
714
  }
622
715
  });
623
- function s(e, t) {
716
+ function o(e, t) {
624
717
  if (typeof e == "string") {
625
718
  if (t === void 0) throw Error("Response is required when registering a single field");
626
- o.register({
627
- fieldId: e,
719
+ a.register({
720
+ fieldKey: e,
628
721
  response: t
629
722
  });
630
- } else o.registerBatch(e);
723
+ } else a.registerBatch(e);
631
724
  }
632
- async function c(r, i) {
633
- let a = [];
634
- return await Promise.allSettled(Object.entries(i).map(async ([o, s]) => {
635
- let c = s, l = e.fields.getById(o).getState();
636
- if (!l) {
637
- a.push({
638
- fieldId: o,
639
- userMessage: `Field '${o}' not found`,
640
- systemMessage: `No field with ID '${o}' exists. Available field IDs are: ${Object.keys(e.fields.listStore.getState()).join(",")}.`,
641
- value: c
642
- });
643
- return;
644
- }
645
- if (l.multiple && (typeof c == "string" || typeof c == "number" || typeof c == "boolean") && (c = [c]), l.validation && !n(l.validation) && !Y(c)) {
646
- let n = {
647
- ...r,
648
- ...i
649
- }, s = await t(e, l.validation, {
650
- $input: c,
651
- responses: n
652
- });
653
- if (typeof s == "string") {
654
- a.push({
655
- fieldId: o,
656
- userMessage: s,
657
- systemMessage: `Field validation resulted in an error: ${s}.`,
658
- value: c
659
- });
660
- return;
661
- }
662
- if (s === !1) {
663
- a.push({
664
- fieldId: o,
665
- userMessage: "This field is invalid",
666
- systemMessage: "Field validation resulted in an unspecified error.",
667
- value: c
725
+ let s = (n, r) => t(e, n, r), c = C({
726
+ source: {
727
+ allFields: e.fields.listStore,
728
+ existingResponses: n
729
+ },
730
+ effect: async ({ allFields: e, existingResponses: t }, n) => {
731
+ let r = [], i = {}, a = {
732
+ ...t,
733
+ ...n
734
+ }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
735
+ let o = We(t, e);
736
+ if (!o) {
737
+ r.push({
738
+ fieldKey: t,
739
+ userMessage: `Field '${t}' not found`,
740
+ systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
741
+ value: n
668
742
  });
669
743
  return;
670
744
  }
671
- }
672
- if (l.required && Y(c)) {
673
- a.push({
674
- fieldId: o,
675
- userMessage: "This field is required",
676
- systemMessage: "Field is required.",
677
- value: c
678
- });
679
- return;
680
- }
681
- if (!l.multiple && Array.isArray(c) && c.length > 1) {
682
- a.push({
683
- fieldId: o,
684
- userMessage: "This field expects a single response",
685
- systemMessage: "Field expects a single response.",
686
- value: c
687
- });
688
- return;
689
- }
690
- if (l.type === "object" && !Y(c)) if (l.multiple) {
691
- if (!Array.isArray(c)) {
692
- a.push({
693
- fieldId: o,
694
- userMessage: "This field expects multiple values",
695
- systemMessage: "Field expects an array of objects.",
696
- value: c
697
- });
745
+ let c = Ge(o, n), l = await Je(s, o, c, a);
746
+ if (l) {
747
+ r.push(l);
698
748
  return;
699
749
  }
700
- for (let e of c) {
701
- if (typeof e != "object" || !e) {
702
- a.push({
703
- fieldId: o,
704
- userMessage: "This field expects object values",
705
- systemMessage: "Field expects an array of objects, but received non-object value.",
706
- value: c
707
- });
708
- return;
709
- }
710
- if (!X(e)) {
711
- a.push({
712
- fieldId: o,
713
- userMessage: "This field contains non-serializable data",
714
- systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
715
- value: c
716
- });
717
- return;
718
- }
719
- }
720
- } else {
721
- if (Array.isArray(c)) {
722
- a.push({
723
- fieldId: o,
724
- userMessage: "This field expects a single value",
725
- systemMessage: "Field expects a single object, not an array.",
726
- value: c
727
- });
750
+ let u = Ke(o, c);
751
+ if (u) {
752
+ r.push(u);
728
753
  return;
729
754
  }
730
- if (typeof c != "object" || !c) {
731
- a.push({
732
- fieldId: o,
733
- userMessage: "This field expects an object value",
734
- systemMessage: "Field expects an object value.",
735
- value: c
736
- });
737
- return;
738
- }
739
- if (!X(c)) {
740
- a.push({
741
- fieldId: o,
742
- userMessage: "This field contains non-serializable data",
743
- systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
744
- value: c
745
- });
755
+ let d = qe(o, c);
756
+ if (d) {
757
+ r.push(d);
746
758
  return;
747
759
  }
760
+ i[o.key] = n;
761
+ }));
762
+ for (let [e, t] of c.entries()) {
763
+ if (t.status !== "rejected") continue;
764
+ let n = o[e];
765
+ if (!n) continue;
766
+ let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
767
+ r.push({
768
+ fieldKey: i,
769
+ userMessage: "An unexpected error occurred validating this field",
770
+ systemMessage: `Validation threw for field '${i}': ${s}`,
771
+ value: a
772
+ });
748
773
  }
749
- if (Array.isArray(l.options) && l.options.length > 0) {
750
- let e = Array.isArray(c) ? c : [c];
751
- if (l.type === "object") {
752
- let t = l.options.map((e) => JSON.stringify(e.value));
753
- e.every((e) => t.includes(JSON.stringify(e))) || a.push({
754
- fieldId: o,
755
- userMessage: "This field expects a valid option",
756
- systemMessage: "Field expects a valid option from the defined choices.",
757
- value: c
758
- });
759
- } else {
760
- let t = l.options.map((e) => e.value);
761
- e.every((e) => !Le(e) || e === null ? !1 : t.includes(e)) || a.push({
762
- fieldId: o,
763
- userMessage: "This field expects a valid option",
764
- systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
765
- value: c
766
- });
767
- }
768
- }
769
- })), {
770
- responsesToCommit: i,
771
- validationErrors: a
772
- };
773
- }
774
- let l = C({
775
- source: r,
776
- effect: (e, t) => c(e, t)
774
+ return {
775
+ responsesToCommit: i,
776
+ validationErrors: r
777
+ };
778
+ }
777
779
  });
778
- async function u(e) {
779
- return l(e);
780
+ async function l(e) {
781
+ return c(e);
780
782
  }
781
- let d = C({
782
- source: r,
783
+ let u = C({
784
+ source: n,
783
785
  effect: async (e, t) => {
784
- let { responsesToCommit: n, validationErrors: r } = await c(e, t);
785
- return r.length ? { errors: r } : (o.registerBatch(n), { errors: [] });
786
+ let { responsesToCommit: n, validationErrors: r } = await c(t);
787
+ return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
786
788
  }
787
789
  });
788
- async function f(e) {
789
- return d(e);
790
+ async function d(e) {
791
+ return u(e);
790
792
  }
791
- let p = r.map((e) => e), m = r.map((e) => Object.keys(e).map((t) => ({
792
- fieldId: t,
793
- value: e[t]
793
+ let f = n.map((e) => e), p = w({
794
+ responses: n,
795
+ fields: e.fields.listStore
796
+ }, ({ responses: e, fields: t }) => Object.entries(e).map(([e, n]) => ({
797
+ fieldId: t.find((t) => t.key === e)?.id ?? e,
798
+ fieldKey: e,
799
+ value: n
794
800
  })));
801
+ function m(t) {
802
+ return w({
803
+ f: e.fields.listStore.map((e) => e.find((e) => e.id === t || e.key === t) ?? null),
804
+ s: n
805
+ }, ({ f: e, s: t }) => {
806
+ let n = e ? t[e.key] ?? null : null;
807
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
808
+ });
809
+ }
795
810
  function h(t) {
796
811
  return w({
797
- f: e.fields.getById(t),
798
- r: r.map((e) => e[t] || null)
799
- }, ({ f: e, r: t }) => t || (e?.defaultValue ? e.defaultValue : null));
812
+ f: e.fields.getByKey(t),
813
+ s: n
814
+ }, ({ f: e, s: t }) => {
815
+ let n = e ? t[e.key] ?? null : null;
816
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
817
+ });
800
818
  }
801
819
  function g(t) {
802
820
  return w({
803
821
  f: e.fields.getByName(t),
804
- s: r
805
- }, ({ f: e, s: t }) => e && t[e.id] || (e?.defaultValue ? e.defaultValue : null));
822
+ s: n
823
+ }, ({ f: e, s: t }) => {
824
+ let n = e ? t[e.key] ?? null : null;
825
+ return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
826
+ });
806
827
  }
807
828
  return A({
808
- clock: i,
809
- target: o.clearAll
829
+ clock: r,
830
+ target: a.clearAll
810
831
  }), A({
811
- clock: a,
812
- target: o.clear
832
+ clock: i,
833
+ target: a.clear
813
834
  }), {
814
- register: s,
815
- clearAll: i,
816
- clear: a,
817
- commit: f,
818
- getResponsesToCommit: u,
819
- listStore: m,
820
- getAllStore: p,
821
- getByFieldId: h,
835
+ register: o,
836
+ clearAll: r,
837
+ clear: i,
838
+ commit: d,
839
+ getResponsesToCommit: l,
840
+ listStore: p,
841
+ getAllStore: f,
842
+ getByFieldId: m,
843
+ getByFieldKey: h,
822
844
  getByFieldName: g
823
845
  };
824
846
  });
825
- function Be(e) {
826
- return M(ze, e);
847
+ function Ze(e) {
848
+ return M(Xe, e);
849
+ }
850
+ //#endregion
851
+ //#region src/entities/condition/condition.ts
852
+ var Qe = E("condition"), $e = j(() => {
853
+ let e = Qe.store({}), t = T(e, { register(e, t) {
854
+ return {
855
+ ...e,
856
+ [t.condition.id]: t.condition
857
+ };
858
+ } });
859
+ function n(e) {
860
+ t.register({ condition: e });
861
+ }
862
+ let r = e.map((e) => Object.values(e));
863
+ function i(t) {
864
+ return e.map((e) => e[t] ?? null);
865
+ }
866
+ function a(t) {
867
+ return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null);
868
+ }
869
+ return {
870
+ register: n,
871
+ getById: i,
872
+ getByKey: a,
873
+ listStore: r
874
+ };
875
+ });
876
+ function et() {
877
+ return M($e);
827
878
  }
828
879
  //#endregion
829
880
  //#region src/utils/api-url.ts
830
- function Ve() {
881
+ function tt() {
831
882
  if (f()) {
832
883
  let e = [
833
884
  document.currentScript,
@@ -842,7 +893,7 @@ function Ve() {
842
893
  }
843
894
  //#endregion
844
895
  //#region src/utils/search-params.ts
845
- function He() {
896
+ function nt() {
846
897
  if (!o()) return {};
847
898
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
848
899
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
@@ -860,18 +911,18 @@ function He() {
860
911
  }
861
912
  //#endregion
862
913
  //#region src/utils/user-session.ts
863
- function Ue() {
914
+ function rt() {
864
915
  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)}`;
865
916
  }
866
- var We = S("session", "global"), Ge = () => {
867
- let e = b.get(We), t;
917
+ var it = S("session", "global"), X = () => {
918
+ let e = b.get(it), t;
868
919
  e.isSet() && (t = e.json());
869
920
  let n = (t) => e.set({
870
921
  id: t.id,
871
922
  isUser: t.isUser,
872
923
  identifiers: t.identifiers
873
924
  }), r = {
874
- id: t?.id ?? Ue(),
925
+ id: t?.id ?? rt(),
875
926
  isUser: t?.isUser ?? void 0,
876
927
  identifiers: t?.identifiers ?? void 0,
877
928
  setIsUser(e) {
@@ -888,13 +939,13 @@ var We = S("session", "global"), Ge = () => {
888
939
  }
889
940
  };
890
941
  return n(r), r;
891
- }, Ke = () => u() ? Ge() : null;
942
+ }, at = () => u() ? X() : null;
892
943
  //#endregion
893
944
  //#region src/utils/picked-config.ts
894
945
  function Z() {
895
946
  if (o()) return globalThis.window.pickedConfig;
896
947
  }
897
- function qe() {
948
+ function ot() {
898
949
  if (!o()) return;
899
950
  let e = Z(), t = e?.organizationId, n = e?.projectId;
900
951
  return t && n ? {
@@ -902,7 +953,7 @@ function qe() {
902
953
  projectId: n
903
954
  } : void 0;
904
955
  }
905
- function Je() {
956
+ function st() {
906
957
  if (!f()) return;
907
958
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
908
959
  if (!e) return;
@@ -912,15 +963,15 @@ function Je() {
912
963
  projectId: n
913
964
  } : void 0;
914
965
  }
915
- function Ye(e) {
966
+ function ct(e) {
916
967
  let { organizationId: t, projectId: n } = e;
917
968
  if (t && n) return {
918
969
  organizationId: t,
919
970
  projectId: n
920
971
  };
921
- let r = qe();
972
+ let r = ot();
922
973
  if (r) return r;
923
- let i = Je();
974
+ let i = st();
924
975
  if (i) return i;
925
976
  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.");
926
977
  }
@@ -929,7 +980,7 @@ function Ye(e) {
929
980
  function Q(e) {
930
981
  return e == null || e === "" || Number.isNaN(e);
931
982
  }
932
- var Xe = {
983
+ var lt = {
933
984
  default: (e, t) => Q(e) ? String(t ?? "") : String(e),
934
985
  append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
935
986
  prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
@@ -950,24 +1001,24 @@ var Xe = {
950
1001
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
951
1002
  }
952
1003
  };
953
- function Ze(e) {
1004
+ function ut(e) {
954
1005
  return typeof e == "object" && !!e;
955
1006
  }
956
- function Qe(e, t) {
1007
+ function dt(e, t) {
957
1008
  let n = t;
958
- for (let t of e.split(".")) if (Ze(n) && t in n) n = n[t];
1009
+ for (let t of e.split(".")) if (ut(n) && t in n) n = n[t];
959
1010
  else return;
960
1011
  return typeof n == "function" ? n() : n;
961
1012
  }
962
- function $e(e, t) {
963
- let n = e.split("|").map((e) => e.trim()), r = Qe(n.shift() ?? "", t);
1013
+ function ft(e, t) {
1014
+ let n = e.split("|").map((e) => e.trim()), r = dt(n.shift() ?? "", t);
964
1015
  for (let e of n) {
965
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Xe[i];
1016
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = lt[i];
966
1017
  o && (r = o(r, a));
967
1018
  }
968
1019
  return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
969
1020
  }
970
- function et(e, t) {
1021
+ function pt(e, t) {
971
1022
  let n = "", r = 0;
972
1023
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
973
1024
  r += 2;
@@ -979,7 +1030,7 @@ function et(e, t) {
979
1030
  }
980
1031
  i += e[r++];
981
1032
  }
982
- n += $e(i.trim(), t);
1033
+ n += ft(i.trim(), t);
983
1034
  } else n += e[r++];
984
1035
  return n;
985
1036
  }
@@ -1002,27 +1053,29 @@ var $ = class {
1002
1053
  precondition;
1003
1054
  condition;
1004
1055
  preconditionPassed;
1005
- searchParams = He();
1006
- history = J();
1007
- components = H({ client: this });
1008
- experienceInstances = _({ client: this });
1009
- experiences = ue({ client: this });
1010
- frameworks = me({ client: this });
1011
- predicates = xe({ client: this });
1012
- features = we({ client: this });
1013
- responses = Be({ client: this });
1014
- fields = je();
1015
- actions = Fe();
1056
+ searchParams = nt();
1057
+ history = ke();
1058
+ components = pe({ client: this });
1059
+ experienceInstances = te({ client: this });
1060
+ experiences = fe({ client: this });
1061
+ frameworks = ge({ client: this });
1062
+ predicates = Ce({ client: this });
1063
+ features = Ee({ client: this });
1064
+ conditions = et();
1065
+ fields = Pe();
1066
+ responses = Ze({ client: this });
1067
+ steps = Le();
1068
+ actions = Ve();
1016
1069
  constructor(e) {
1017
- this.events = Oe(this.eventBus);
1018
- let { organizationId: t, projectId: n } = Ye(e);
1019
- this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ve(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Ke(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
1070
+ this.events = je(this.eventBus);
1071
+ let { organizationId: t, projectId: n } = ct(e);
1072
+ this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
1020
1073
  type: "load",
1021
- version: ae()
1074
+ version: se()
1022
1075
  });
1023
1076
  }
1024
1077
  start = () => {
1025
- ve(this), (async () => {
1078
+ be(this), (async () => {
1026
1079
  if (!f()) return;
1027
1080
  await this.runPluginStartHooks();
1028
1081
  let e = await this.evaluateGate(this.precondition);
@@ -1037,7 +1090,7 @@ var $ = class {
1037
1090
  value: e
1038
1091
  });
1039
1092
  }
1040
- if (this.eventBus({ type: "initialize" }), n && F(this), await g(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1093
+ if (this.eventBus({ type: "initialize" }), n && F(this), await ie(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1041
1094
  let { id: e, isUser: t, identifiers: n } = this.session;
1042
1095
  this.eventBus({
1043
1096
  type: "session",
@@ -1049,10 +1102,10 @@ var $ = class {
1049
1102
  })();
1050
1103
  };
1051
1104
  registerFramework = (e) => {
1052
- he(e, this.frameworks);
1105
+ _e(e, this.frameworks);
1053
1106
  };
1054
1107
  registerComponent = (e, t) => {
1055
- U(e, t, this.components);
1108
+ H(e, t, this.components);
1056
1109
  };
1057
1110
  registerPlugin = (e) => {
1058
1111
  L(this, e, this.plugins);
@@ -1060,29 +1113,35 @@ var $ = class {
1060
1113
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1061
1114
  };
1062
1115
  registerFeature = (e, t) => {
1063
- Te(e, t, this.features);
1116
+ De(e, t, this.features);
1064
1117
  };
1065
1118
  registerPredicate = (e, t) => {
1066
- Se(e, t, this.predicates);
1119
+ we(e, t, this.predicates);
1120
+ };
1121
+ registerCondition = (e) => {
1122
+ this.conditions.register(e);
1067
1123
  };
1068
1124
  registerField = (e) => {
1069
- Me(e, this.fields);
1125
+ this.fields.register(e);
1126
+ };
1127
+ registerStep = (e) => {
1128
+ Re(e, this.steps);
1070
1129
  };
1071
1130
  registerAction = (e, t) => {
1072
- Ie(e, t, this.actions);
1131
+ He(e, t, this.actions);
1073
1132
  };
1074
1133
  registerExperience = (e) => {
1075
- e.component && U(`experience:${e.id}`, e.component, this.components), de(e, this.experiences);
1134
+ e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1076
1135
  };
1077
- getStateSnapshot = () => W(this);
1136
+ getStateSnapshot = () => U(this);
1078
1137
  launchExperienceById = async (e, t) => {
1079
1138
  this.experiences.launch({
1080
- id: e,
1139
+ key: e,
1081
1140
  options: t
1082
1141
  });
1083
1142
  };
1084
1143
  openExperienceById = async (e) => {
1085
- this.experiences.open({ id: e });
1144
+ this.experiences.open({ key: e });
1086
1145
  };
1087
1146
  async runPluginStartHooks() {
1088
1147
  for (let e of this.pluginStartHooks) await e();
@@ -1154,7 +1213,7 @@ var $ = class {
1154
1213
  getPluginConfig = (e) => this.plugins[e] ?? {};
1155
1214
  renderString = (e, t) => {
1156
1215
  let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldId] = t.value, e), {});
1157
- return et(e, {
1216
+ return pt(e, {
1158
1217
  ...t,
1159
1218
  responses: n
1160
1219
  });
@@ -1162,20 +1221,20 @@ var $ = class {
1162
1221
  };
1163
1222
  //#endregion
1164
1223
  //#region src/entities/component/lazyComponent.ts
1165
- function tt(e) {
1224
+ function mt(e) {
1166
1225
  return {
1167
1226
  $$type: "lazy-component",
1168
1227
  load: e
1169
1228
  };
1170
1229
  }
1171
- function nt(e) {
1230
+ function ht(e) {
1172
1231
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1173
1232
  }
1174
1233
  //#endregion
1175
1234
  //#region src/exports.ts
1176
- var rt = (e) => {
1235
+ var gt = (e) => {
1177
1236
  let t = new $(e);
1178
1237
  return d(t), t;
1179
1238
  };
1180
1239
  //#endregion
1181
- export { $ as Picked, rt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, nt as isLazyLoader, ne as isPickedRoot, tt as lazyComponent, b as localStore, x as sessionStore, re 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 };
1240
+ export { $ as Picked, gt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, ee as isPickedRoot, mt as lazyComponent, b as localStore, x as sessionStore, y 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 };