@picked/client 0.0.50 → 0.0.51-next.1

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 (112) hide show
  1. package/dist/api-A3gUhQJc.cjs +1 -0
  2. package/dist/{api-DWBcrf98.js → api-Brluf3C1.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -0
  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/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  11. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  12. package/dist/cjs/server/index.js +1 -1
  13. package/dist/esm/form/index.js +466 -0
  14. package/dist/esm/index.js +330 -321
  15. package/dist/esm/plugins/create-experience/index.js +25 -19
  16. package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
  17. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  18. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  19. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  20. package/dist/esm/plugins/responses-indexeddb/index.js +5 -9
  21. package/dist/esm/plugins/single-page-app/index.js +4 -4
  22. package/dist/esm/server/index.js +1 -1
  23. package/dist/experience-instance-CIbQp9D7.js +481 -0
  24. package/dist/experience-instance-Dri5yAp1.cjs +1 -0
  25. package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
  26. package/dist/object-CUJOjanb.cjs +1 -0
  27. package/dist/rules-logic-BIkBWZmf.js +233 -0
  28. package/dist/rules-logic-DDxCiq4P.cjs +1 -0
  29. package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
  30. package/dist/storage-B6lQtc4-.cjs +1 -0
  31. package/dist/types/entities/action/action.d.ts.map +1 -1
  32. package/dist/types/entities/experience/experience.d.ts +10 -10
  33. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  34. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  35. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  36. package/dist/types/entities/field/field.d.ts +11 -8
  37. package/dist/types/entities/field/field.d.ts.map +1 -1
  38. package/dist/types/entities/history/history.d.ts.map +1 -1
  39. package/dist/types/entities/response/response.d.ts.map +1 -1
  40. package/dist/types/exports.d.ts +0 -1
  41. package/dist/types/exports.d.ts.map +1 -1
  42. package/dist/types/form/build-responses.d.ts +14 -0
  43. package/dist/types/form/build-responses.d.ts.map +1 -0
  44. package/dist/types/form/create-field-evaluator.d.ts +19 -0
  45. package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
  46. package/dist/types/form/create-field-validation.d.ts +59 -0
  47. package/dist/types/form/create-field-validation.d.ts.map +1 -0
  48. package/dist/types/form/create-form.d.ts +96 -0
  49. package/dist/types/form/create-form.d.ts.map +1 -0
  50. package/dist/types/form/create-submit-pipeline.d.ts +58 -0
  51. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
  52. package/dist/types/form/get-step-fields.d.ts +5 -0
  53. package/dist/types/form/get-step-fields.d.ts.map +1 -0
  54. package/dist/types/form/index.d.ts +10 -0
  55. package/dist/types/form/index.d.ts.map +1 -0
  56. package/dist/types/index.d.ts +1 -1
  57. package/dist/types/index.d.ts.map +1 -1
  58. package/dist/types/logic-engine.d.ts +12 -10
  59. package/dist/types/logic-engine.d.ts.map +1 -1
  60. package/dist/types/picked.d.ts +4 -5
  61. package/dist/types/picked.d.ts.map +1 -1
  62. package/dist/types/plugins/create-experience/create-experience.d.ts +24 -22
  63. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  64. package/dist/types/plugins/create-experience/index.d.ts +1 -1
  65. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  66. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
  67. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  68. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
  69. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  70. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
  71. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  72. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  73. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  74. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  75. package/dist/types/utils/dom.d.ts +0 -3
  76. package/dist/types/utils/dom.d.ts.map +1 -1
  77. package/dist/types/utils/events.d.ts +1 -1
  78. package/dist/types/utils/events.d.ts.map +1 -1
  79. package/dist/types/utils/global-obj.d.ts +0 -1
  80. package/dist/types/utils/global-obj.d.ts.map +1 -1
  81. package/dist/types/utils/indexed-db.d.ts +2 -1
  82. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  83. package/dist/types/utils/logger.d.ts.map +1 -1
  84. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
  85. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
  86. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  87. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  88. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  89. package/dist/types/utils/nodes.d.ts +2 -2
  90. package/dist/types/utils/nodes.d.ts.map +1 -1
  91. package/dist/types/utils/object.d.ts +0 -8
  92. package/dist/types/utils/object.d.ts.map +1 -1
  93. package/dist/types/utils/picked-config.d.ts +1 -1
  94. package/dist/types/utils/picked-config.d.ts.map +1 -1
  95. package/dist/types/utils/rules-logic.d.ts +31 -0
  96. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  97. package/dist/types/utils/search-params.d.ts.map +1 -1
  98. package/dist/types/utils/storage.d.ts.map +1 -1
  99. package/package.json +43 -7
  100. package/dist/api-BwTaomem.cjs +0 -1
  101. package/dist/experience-instance-BRpI9I4s.js +0 -710
  102. package/dist/experience-instance-BUTnwbSJ.cjs +0 -1
  103. package/dist/object-BReQiaSS.cjs +0 -1
  104. package/dist/storage-BFjb8azI.cjs +0 -1
  105. package/dist/types/entities/project/project.d.ts +0 -9
  106. package/dist/types/entities/project/project.d.ts.map +0 -1
  107. package/dist/types/utils/get-step-fields.d.ts +0 -4
  108. package/dist/types/utils/get-step-fields.d.ts.map +0 -1
  109. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
  110. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
  111. /package/dist/{id-CIbS4P60.cjs → id-Bv44ilEo.cjs} +0 -0
  112. /package/dist/{id-BniPxOdF.js → id-CRqy981z.js} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,15 +1,16 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, u as c } from "../experience-instance-BRpI9I4s.js";
2
- import { t as l } from "../object-Clj5zVr1.js";
3
- import { t as u } from "../logger-6z_gb4rA.js";
4
- import { a as d, c as f, d as p, i as ee, l as m, n as h, o as g, p as te, r as _, s as ne, t as re, u as ie } from "../supports-0XIfd4-R.js";
5
- import { i as ae, n as v, r as y, t as b } from "../storage-DyxpJ0pg.js";
6
- import { n as x, r as oe } from "../api-DWBcrf98.js";
7
- import { t as se } from "../id-BniPxOdF.js";
8
- import { attach as S, combine as C, createApi as w, createDomain as T, createEffect as E, createEvent as D, createStore as O, sample as k } from "effector";
9
- import { createFactory as A, invoke as j } from "@withease/factories";
1
+ import { n as e, t } from "../rules-logic-BIkBWZmf.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 ee, i as te, n as _, o as v, r as y, s as ne } from "../experience-instance-CIbQp9D7.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-Brluf3C1.js";
8
+ import { t as oe } from "../id-CRqy981z.js";
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
+ import { createFactory as j, invoke as M } from "@withease/factories";
10
11
  //#region src/entities/experience/experience.ts
11
- var M = T("experience"), ce = A(({ client: e, experience: t }) => {
12
- let n = M.store(t), r = w(n, { merge(e, t) {
12
+ var N = E("experience"), se = j(({ client: e, experience: t }) => {
13
+ let n = N.store(t), r = T(n, { merge(e, t) {
13
14
  return {
14
15
  ...e,
15
16
  ...t.experience
@@ -23,7 +24,7 @@ var M = T("experience"), ce = A(({ client: e, experience: t }) => {
23
24
  steps: e.steps,
24
25
  nodes: e.nodes,
25
26
  edges: e.edges,
26
- conditionals: e.conditionals
27
+ conditions: e.conditions
27
28
  })), s = n.map((e) => e.fields), c = t.actions ?? [];
28
29
  return {
29
30
  id: t.id,
@@ -35,11 +36,11 @@ var M = T("experience"), ce = A(({ client: e, experience: t }) => {
35
36
  merge: r.merge
36
37
  };
37
38
  });
38
- function le(e) {
39
- return j(ce, e);
39
+ function ce(e) {
40
+ return M(se, e);
40
41
  }
41
- var ue = A(({ client: e }) => {
42
- let t = M.store({}), n = w(t, { register(e, t) {
42
+ var le = j(({ client: e }) => {
43
+ let t = N.store({}), n = T(t, { register(e, t) {
43
44
  return {
44
45
  ...e,
45
46
  [t.id]: t
@@ -54,7 +55,7 @@ var ue = A(({ client: e }) => {
54
55
  });
55
56
  return;
56
57
  }
57
- let a = le({
58
+ let a = ce({
58
59
  client: e,
59
60
  experience: r
60
61
  });
@@ -64,7 +65,7 @@ var ue = A(({ client: e }) => {
64
65
  function a(e) {
65
66
  return t.map((t) => t[e], { skipVoid: !1 });
66
67
  }
67
- let o = S({
68
+ let o = C({
68
69
  source: t,
69
70
  effect: async (t, { id: n, options: r }) => {
70
71
  let i = t[n];
@@ -73,10 +74,10 @@ var ue = A(({ client: e }) => {
73
74
  return;
74
75
  }
75
76
  if (r?.bypassCondition) {
76
- N(e, i, r);
77
+ P(e, i, r);
77
78
  return;
78
79
  }
79
- await F(e, i) && N(e, i, r);
80
+ await I(e, i) && P(e, i, r);
80
81
  }
81
82
  });
82
83
  return {
@@ -84,7 +85,7 @@ var ue = A(({ client: e }) => {
84
85
  get: a,
85
86
  getById: a,
86
87
  launch: o,
87
- open: S({
88
+ open: C({
88
89
  source: e.experienceInstances.listStore,
89
90
  effect: (e, { id: t, options: n }) => {
90
91
  let r = e.filter((e) => e.experienceId === t);
@@ -101,25 +102,25 @@ var ue = A(({ client: e }) => {
101
102
  listStore: i
102
103
  };
103
104
  });
104
- function de(e) {
105
- return j(ue, e);
105
+ function ue(e) {
106
+ return M(le, e);
106
107
  }
107
- var fe = (e, t) => {
108
+ var de = (e, t) => {
108
109
  t.register(e);
109
- }, N = (e, r, i) => {
110
- let { targetSelectors: o } = r.configStore.getState(), s = a(o, r.id);
111
- s.forEach(({ elements: e }) => e.forEach((e) => t(e, r.id))), n(s, r.id).forEach((t) => {
112
- i ? e.experienceInstances.spawn(r, t, i) : e.experienceInstances.spawn(r, t);
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) => {
113
+ n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
113
114
  });
114
- }, P = async (e) => {
115
+ }, F = async (e) => {
115
116
  await Promise.all(e.experiences.listStore.getState().map(async (t) => {
116
- await F(e, t) && N(e, t);
117
+ await I(e, t) && P(e, t);
117
118
  }));
118
- }, F = async (e, t) => {
119
- if (!e.preconditionPassed || !e.session?.isUser) return !1;
120
- let { decisionLogic: n, targetSelectors: i } = t.configStore.getState();
121
- return a(i, t.id).length < 1 || i.length === 0 ? !1 : n === void 0 ? !0 : c(n) ? await r(e, n) === !0 : !0;
122
- }, I = (e, t, n) => {
119
+ }, I = async (n, r) => {
120
+ if (!n.preconditionPassed || !n.session?.isUser) return !1;
121
+ 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;
123
+ }, L = (e, t, n) => {
123
124
  let r = t.name, i = t.setup(e);
124
125
  if (i) {
125
126
  let e = n[r] ?? {};
@@ -128,16 +129,16 @@ var fe = (e, t) => {
128
129
  ...i
129
130
  });
130
131
  }
131
- }, L = T("component"), R = A(({ client: e, component: t, name: n }) => ({
132
+ }, R = E("component"), z = j(({ client: e, component: t, name: n }) => ({
132
133
  name: n,
133
134
  component: t,
134
135
  frameworkStore: e.frameworks.getByName(t.frameworkName)
135
136
  }));
136
- function z(e) {
137
- return j(R, e);
137
+ function B(e) {
138
+ return M(z, e);
138
139
  }
139
- var B = A(({ client: e }) => {
140
- let t = L.store({}), n = w(t, { register(e, t) {
140
+ var V = j(({ client: e }) => {
141
+ let t = R.store({}), n = T(t, { register(e, t) {
141
142
  return {
142
143
  ...e,
143
144
  [t.name]: t
@@ -145,7 +146,7 @@ var B = A(({ client: e }) => {
145
146
  } });
146
147
  function r(r, i) {
147
148
  t.getState()[r] && `${r}`;
148
- let a = z({
149
+ let a = B({
149
150
  client: e,
150
151
  name: r,
151
152
  component: i
@@ -162,13 +163,13 @@ var B = A(({ client: e }) => {
162
163
  listStore: i
163
164
  };
164
165
  });
165
- function V(e) {
166
- return j(B, e);
166
+ function H(e) {
167
+ return M(V, e);
167
168
  }
168
- var H = (e, t, n) => {
169
+ var U = (e, t, n) => {
169
170
  n.register(e, t);
170
- }, pe = T("framework"), me = A(({ client: e }) => {
171
- let t = pe.store({}), n = w(t, { register(e, t) {
171
+ }, fe = E("framework"), pe = j(({ client: e }) => {
172
+ let t = fe.store({}), n = T(t, { register(e, t) {
172
173
  return {
173
174
  ...e,
174
175
  [t.name]: t.framework
@@ -190,21 +191,21 @@ var H = (e, t, n) => {
190
191
  listStore: i
191
192
  };
192
193
  });
193
- function he(e) {
194
- return j(me, e);
194
+ function me(e) {
195
+ return M(pe, e);
195
196
  }
196
- var ge = (e, t) => {
197
+ var he = (e, t) => {
197
198
  t.register(e.name, e);
198
- }, _e = 6e3, ve = b("last_ping", "global"), ye = async (e) => {
199
+ }, ge = 6e3, _e = S("last_ping", "global"), ve = async (e) => {
199
200
  try {
200
- let t = Date.now(), n = v.get(ve), r = 0;
201
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
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;
202
203
  let i = {
203
204
  projectId: e.projectId,
204
205
  path: window.location.pathname
205
206
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
206
207
  o && (a["x-vercel-protection-bypass"] = o);
207
- let s = (await x(e.apiUrl, "ping", i, a)).ok;
208
+ let s = (await ie(e.apiUrl, "ping", i, a)).ok;
208
209
  return s && n.set(t), s;
209
210
  } catch {
210
211
  return !1;
@@ -212,7 +213,7 @@ var ge = (e, t) => {
212
213
  };
213
214
  //#endregion
214
215
  //#region src/utils/state-snaphot.ts
215
- function U(e) {
216
+ function W(e) {
216
217
  let t = typeof window < "u", n = {
217
218
  client: e,
218
219
  responses: e.responses.listStore.getState(),
@@ -226,8 +227,8 @@ function U(e) {
226
227
  }
227
228
  //#endregion
228
229
  //#region src/entities/predicate/predicate.ts
229
- var be = T("predicate"), xe = A(({ client: e }) => {
230
- let t = be.store({}), n = w(t, { register(e, t) {
230
+ var ye = E("predicate"), be = j(({ client: e }) => {
231
+ let t = ye.store({}), n = T(t, { register(e, t) {
231
232
  return {
232
233
  ...e,
233
234
  [t.name]: {
@@ -247,22 +248,22 @@ var be = T("predicate"), xe = A(({ client: e }) => {
247
248
  return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
248
249
  }
249
250
  function o(t) {
250
- let n = O(() => void 0, { skipVoid: !1 }), r = E(async () => {
251
+ let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
251
252
  let n = a(t).getState();
252
253
  if (!n) return;
253
- let r = U(e);
254
+ let r = W(e);
254
255
  return (...e) => n({
255
256
  ...r,
256
257
  args: e
257
258
  });
258
259
  });
259
- return k({
260
+ return A({
260
261
  source: {
261
262
  responses: e.responses.listStore,
262
263
  fields: e.fields.listStore
263
264
  },
264
265
  target: r
265
- }), k({
266
+ }), A({
266
267
  clock: r.doneData,
267
268
  filter: (e) => e !== void 0,
268
269
  target: n
@@ -275,13 +276,13 @@ var be = T("predicate"), xe = A(({ client: e }) => {
275
276
  getEvokablePredicate: o
276
277
  };
277
278
  });
278
- function Se(e) {
279
- return j(xe, e);
279
+ function xe(e) {
280
+ return M(be, e);
280
281
  }
281
- var Ce = (e, t, n) => {
282
+ var Se = (e, t, n) => {
282
283
  n.register(e, t);
283
- }, W = T("feature"), we = A(({ client: e }) => {
284
- let t = W.store({}), n = W.store([]), r = w(t, { 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) {
285
286
  return {
286
287
  ...e,
287
288
  [t.id]: t.feature
@@ -301,19 +302,19 @@ var Ce = (e, t, n) => {
301
302
  feature: i
302
303
  }));
303
304
  }
304
- let a = E(async ({ id: e, key: t, storage: n = "local" }) => {
305
- let r = b(`feature:${e}:${t}`, "global"), i = (n === "session" ? y : v).get(r).boolean();
305
+ let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
306
+ let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
306
307
  return i === null ? null : {
307
308
  id: e,
308
309
  key: t,
309
310
  bucket: i,
310
311
  storage: n
311
312
  };
312
- }), o = E((e) => {
313
+ }), o = D((e) => {
313
314
  if (!e) return null;
314
- let t = b(`feature:${e.id}:${e.key}`, "global");
315
- (e.storage === "session" ? y : v).set(t, e.bucket);
316
- }), s = /* @__PURE__ */ new Map(), c = S({
315
+ let t = S(`feature:${e.id}:${e.key}`, "global");
316
+ (e.storage === "session" ? x : b).set(t, e.bucket);
317
+ }), s = /* @__PURE__ */ new Map(), c = C({
317
318
  source: {
318
319
  allFeaturesStore: t,
319
320
  resolvedFeaturesStore: n
@@ -344,7 +345,7 @@ var Ce = (e, t, n) => {
344
345
  };
345
346
  }
346
347
  });
347
- k({
348
+ A({
348
349
  clock: r.register,
349
350
  fn: (e) => {
350
351
  let { id: t, feature: n } = e;
@@ -355,7 +356,7 @@ var Ce = (e, t, n) => {
355
356
  };
356
357
  },
357
358
  target: a
358
- }), k({
359
+ }), A({
359
360
  source: t,
360
361
  clock: c.doneData,
361
362
  fn: (e, t) => {
@@ -369,7 +370,7 @@ var Ce = (e, t, n) => {
369
370
  },
370
371
  target: o
371
372
  });
372
- let l = C({
373
+ let l = w({
373
374
  allFeaturesStore: t,
374
375
  resolvedFeaturesStore: n
375
376
  }).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
@@ -391,7 +392,7 @@ var Ce = (e, t, n) => {
391
392
  isResolved: !1
392
393
  };
393
394
  }));
394
- k({
395
+ A({
395
396
  clock: c.doneData,
396
397
  source: { resolvedFeatures: n },
397
398
  filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
@@ -400,7 +401,7 @@ var Ce = (e, t, n) => {
400
401
  type: "feature_decide",
401
402
  feature: e
402
403
  }))
403
- }), k({
404
+ }), A({
404
405
  clock: [a.doneData, c.doneData],
405
406
  source: n,
406
407
  fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
@@ -413,15 +414,15 @@ var Ce = (e, t, n) => {
413
414
  return t.map((t) => t[e], { skipVoid: !1 });
414
415
  }
415
416
  function f(e) {
416
- let t = O(async () => void 0, { skipVoid: !1 }), r = E(async () => {
417
+ let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
417
418
  let t = u(e).getState();
418
419
  if (t) return async () => (await t.getBucket()).bucket;
419
420
  });
420
- return k({
421
+ return A({
421
422
  source: n,
422
423
  filter: (t) => t.some((t) => t.id === e),
423
424
  target: r
424
- }), k({
425
+ }), A({
425
426
  clock: r.doneData,
426
427
  filter: (e) => e !== void 0,
427
428
  target: t
@@ -435,23 +436,23 @@ var Ce = (e, t, n) => {
435
436
  getEvokableFeature: f
436
437
  };
437
438
  });
438
- function Te(e) {
439
- return j(we, e);
439
+ function we(e) {
440
+ return M(Ce, e);
440
441
  }
441
- var Ee = (e, t, n) => {
442
+ var Te = (e, t, n) => {
442
443
  n.register(e, t);
443
- }, G = T("history");
444
- function K(e, t) {
444
+ }, K = E("history");
445
+ function q(e, t) {
445
446
  return {
446
- id: se(`history-entry-${Date.now()}-${Math.random()}}`),
447
+ id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
447
448
  node: t,
448
449
  at: Date.now(),
449
450
  experienceId: e
450
451
  };
451
452
  }
452
- var De = A(() => {
453
- let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
454
- 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);
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);
455
456
  function a(e, t) {
456
457
  let n = {
457
458
  lastStepIndex: -1,
@@ -459,7 +460,7 @@ var De = A(() => {
459
460
  };
460
461
  for (let r = e.length - 1; r >= 0; r--) {
461
462
  let i = e[r], a = i?.node;
462
- if (!(!a || !o(a)) && !(t && i?.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
463
+ if (!(!a || !y(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
463
464
  else {
464
465
  n.secondLastStepIndex = r;
465
466
  break;
@@ -481,38 +482,47 @@ var De = A(() => {
481
482
  entriesStore: e.map((e) => e.entries)
482
483
  };
483
484
  });
484
- function Oe() {
485
- return j(De);
485
+ function J() {
486
+ return M(Ee);
486
487
  }
487
488
  //#endregion
488
489
  //#region src/utils/events.ts
489
- var ke = 0, Ae = (e) => {
490
- let t = O([]);
491
- return k({
490
+ var De = 0, Oe = (e) => {
491
+ let t = k([]);
492
+ return A({
492
493
  clock: e,
493
494
  source: t,
494
495
  fn: (e, t) => [...e, {
495
- id: ke++,
496
+ id: De++,
496
497
  at: /* @__PURE__ */ new Date(),
497
498
  payload: t
498
499
  }],
499
500
  target: t
500
501
  }), t;
501
- }, je = T("field"), Me = A(() => {
502
- let e = je.store({}), t = w(e, { register(e, t) {
503
- return {
504
- ...e,
505
- [t.field.id]: t.field
506
- };
507
- } });
502
+ }, ke = E("field"), Ae = j(() => {
503
+ let e = ke.store({}), t = T(e, {
504
+ register(e, t) {
505
+ return {
506
+ ...e,
507
+ [t.field.id]: t.field
508
+ };
509
+ },
510
+ updateById(e, t) {
511
+ let n = e[t.fieldId];
512
+ return n ? {
513
+ ...e,
514
+ [t.fieldId]: Object.assign({}, n, t.updates)
515
+ } : e;
516
+ }
517
+ });
508
518
  function n(e) {
509
519
  t.register({ field: e });
510
520
  }
511
521
  function r(e, n) {
512
- let r = a(e).getState();
513
- if (!r) return;
514
- let i = Object.assign({}, r, { ...n });
515
- t.register({ field: { ...i } });
522
+ t.updateById({
523
+ fieldId: e,
524
+ updates: n
525
+ });
516
526
  }
517
527
  let i = e.map((e) => Object.values(e));
518
528
  function a(t) {
@@ -529,13 +539,13 @@ var ke = 0, Ae = (e) => {
529
539
  getByName: o
530
540
  };
531
541
  });
532
- function Ne() {
533
- return j(Me);
542
+ function je() {
543
+ return M(Ae);
534
544
  }
535
- var Pe = (e, t) => {
545
+ var Me = (e, t) => {
536
546
  t.register(e);
537
- }, Fe = T("action"), Ie = A(() => {
538
- let e = Fe.store({}), t = w(e, { register(e, t) {
547
+ }, Ne = E("action"), Pe = j(() => {
548
+ let e = Ne.store({}), t = T(e, { register(e, t) {
539
549
  return {
540
550
  ...e,
541
551
  [t.name]: {
@@ -567,29 +577,29 @@ var Pe = (e, t) => {
567
577
  getEvokableAction: a
568
578
  };
569
579
  });
570
- function Le() {
571
- return j(Ie);
580
+ function Fe() {
581
+ return M(Pe);
572
582
  }
573
- var Re = (e, t, n) => {
583
+ var Ie = (e, t, n) => {
574
584
  n.register(e, t);
575
585
  };
576
586
  //#endregion
577
587
  //#region src/entities/response/response.ts
578
- function q(e) {
588
+ function Y(e) {
579
589
  return e == null || e === "" || Array.isArray(e) && !e.length;
580
590
  }
581
- function ze(e) {
591
+ function Le(e) {
582
592
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
583
593
  }
584
- function J(e) {
594
+ function X(e) {
585
595
  try {
586
596
  return JSON.stringify(e), !0;
587
597
  } catch {
588
598
  return !1;
589
599
  }
590
600
  }
591
- var Be = T("response"), Ve = A(({ client: e }) => {
592
- let t = Be.store({}), n = D(), i = D(), a = w(t, {
601
+ var Re = E("response"), ze = j(({ client: e }) => {
602
+ let r = Re.store({}), i = O(), a = O(), o = T(r, {
593
603
  register(e, t) {
594
604
  return {
595
605
  ...e,
@@ -610,196 +620,215 @@ var Be = T("response"), Ve = A(({ client: e }) => {
610
620
  return {};
611
621
  }
612
622
  });
613
- function o(e, t) {
623
+ function s(e, t) {
614
624
  if (typeof e == "string") {
615
625
  if (t === void 0) throw Error("Response is required when registering a single field");
616
- a.register({
626
+ o.register({
617
627
  fieldId: e,
618
628
  response: t
619
629
  });
620
- } else a.registerBatch(e);
630
+ } else o.registerBatch(e);
621
631
  }
622
- async function s(t) {
623
- let n = [];
624
- return await Promise.allSettled(Object.entries(t).map(async ([t, i]) => {
625
- let a = i, o = e.fields.getById(t).getState();
626
- if (!o) {
627
- n.push({
628
- fieldId: t,
629
- userMessage: `Field '${t}' not found`,
630
- systemMessage: `No field with ID '${t}' exists. Available field IDs are: ${Object.keys(e.fields.listStore.getState()).join(",")}.`,
631
- value: a
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
632
642
  });
633
643
  return;
634
644
  }
635
- if (o.multiple && (typeof a == "string" || typeof a == "number" || typeof a == "boolean") && (a = [a]), o.validation && !l(o.validation) && !q(a)) {
636
- let i = await r(e, o.validation, { $input: a });
637
- if (typeof i == "string") {
638
- n.push({
639
- fieldId: t,
640
- userMessage: i,
641
- systemMessage: `Field validation resulted in an error: ${i}.`,
642
- value: a
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
643
659
  });
644
660
  return;
645
661
  }
646
- if (i === !1) {
647
- n.push({
648
- fieldId: t,
662
+ if (s === !1) {
663
+ a.push({
664
+ fieldId: o,
649
665
  userMessage: "This field is invalid",
650
666
  systemMessage: "Field validation resulted in an unspecified error.",
651
- value: a
667
+ value: c
652
668
  });
653
669
  return;
654
670
  }
655
671
  }
656
- if (o.required && q(a)) {
657
- n.push({
658
- fieldId: t,
672
+ if (l.required && Y(c)) {
673
+ a.push({
674
+ fieldId: o,
659
675
  userMessage: "This field is required",
660
676
  systemMessage: "Field is required.",
661
- value: a
677
+ value: c
662
678
  });
663
679
  return;
664
680
  }
665
- if (!o.multiple && Array.isArray(a) && a.length > 1) {
666
- n.push({
667
- fieldId: t,
681
+ if (!l.multiple && Array.isArray(c) && c.length > 1) {
682
+ a.push({
683
+ fieldId: o,
668
684
  userMessage: "This field expects a single response",
669
685
  systemMessage: "Field expects a single response.",
670
- value: a
686
+ value: c
671
687
  });
672
688
  return;
673
689
  }
674
- if (o.type === "object" && !q(a)) if (o.multiple) {
675
- if (!Array.isArray(a)) {
676
- n.push({
677
- fieldId: t,
690
+ if (l.type === "object" && !Y(c)) if (l.multiple) {
691
+ if (!Array.isArray(c)) {
692
+ a.push({
693
+ fieldId: o,
678
694
  userMessage: "This field expects multiple values",
679
695
  systemMessage: "Field expects an array of objects.",
680
- value: a
696
+ value: c
681
697
  });
682
698
  return;
683
699
  }
684
- for (let e of a) {
700
+ for (let e of c) {
685
701
  if (typeof e != "object" || !e) {
686
- n.push({
687
- fieldId: t,
702
+ a.push({
703
+ fieldId: o,
688
704
  userMessage: "This field expects object values",
689
705
  systemMessage: "Field expects an array of objects, but received non-object value.",
690
- value: a
706
+ value: c
691
707
  });
692
708
  return;
693
709
  }
694
- if (!J(e)) {
695
- n.push({
696
- fieldId: t,
710
+ if (!X(e)) {
711
+ a.push({
712
+ fieldId: o,
697
713
  userMessage: "This field contains non-serializable data",
698
714
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
699
- value: a
715
+ value: c
700
716
  });
701
717
  return;
702
718
  }
703
719
  }
704
720
  } else {
705
- if (Array.isArray(a)) {
706
- n.push({
707
- fieldId: t,
721
+ if (Array.isArray(c)) {
722
+ a.push({
723
+ fieldId: o,
708
724
  userMessage: "This field expects a single value",
709
725
  systemMessage: "Field expects a single object, not an array.",
710
- value: a
726
+ value: c
711
727
  });
712
728
  return;
713
729
  }
714
- if (typeof a != "object" || !a) {
715
- n.push({
716
- fieldId: t,
730
+ if (typeof c != "object" || !c) {
731
+ a.push({
732
+ fieldId: o,
717
733
  userMessage: "This field expects an object value",
718
734
  systemMessage: "Field expects an object value.",
719
- value: a
735
+ value: c
720
736
  });
721
737
  return;
722
738
  }
723
- if (!J(a)) {
724
- n.push({
725
- fieldId: t,
739
+ if (!X(c)) {
740
+ a.push({
741
+ fieldId: o,
726
742
  userMessage: "This field contains non-serializable data",
727
743
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
728
- value: a
744
+ value: c
729
745
  });
730
746
  return;
731
747
  }
732
748
  }
733
- if (Array.isArray(o.options) && o.options.length > 0) {
734
- let e = Array.isArray(a) ? a : [a];
735
- if (o.type === "object") {
736
- let r = o.options.map((e) => JSON.stringify(e.value));
737
- e.every((e) => r.includes(JSON.stringify(e))) || n.push({
738
- fieldId: t,
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,
739
755
  userMessage: "This field expects a valid option",
740
756
  systemMessage: "Field expects a valid option from the defined choices.",
741
- value: a
757
+ value: c
742
758
  });
743
759
  } else {
744
- let r = o.options.map((e) => e.value);
745
- e.every((e) => !ze(e) || e === null ? !1 : r.includes(e)) || n.push({
746
- fieldId: t,
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,
747
763
  userMessage: "This field expects a valid option",
748
- systemMessage: `Field expects a valid option. Valid options are: ${r.join(", ")}`,
749
- value: a
764
+ systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
765
+ value: c
750
766
  });
751
767
  }
752
768
  }
753
769
  })), {
754
- responsesToCommit: t,
755
- validationErrors: n
770
+ responsesToCommit: i,
771
+ validationErrors: a
756
772
  };
757
773
  }
758
- async function c(e) {
759
- let { responsesToCommit: t, validationErrors: n } = await s(e);
760
- return n.length ? { errors: n } : (a.registerBatch(t), { errors: [] });
774
+ let l = C({
775
+ source: r,
776
+ effect: (e, t) => c(e, t)
777
+ });
778
+ async function u(e) {
779
+ return l(e);
780
+ }
781
+ let d = C({
782
+ source: r,
783
+ 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
+ }
787
+ });
788
+ async function f(e) {
789
+ return d(e);
761
790
  }
762
- let u = t.map((e) => e), d = t.map((e) => Object.keys(e).map((t) => ({
791
+ let p = r.map((e) => e), m = r.map((e) => Object.keys(e).map((t) => ({
763
792
  fieldId: t,
764
793
  value: e[t]
765
794
  })));
766
- function f(n) {
767
- return C({
768
- f: e.fields.getById(n),
769
- r: t.map((e) => e[n] || null)
795
+ function h(t) {
796
+ return w({
797
+ f: e.fields.getById(t),
798
+ r: r.map((e) => e[t] || null)
770
799
  }, ({ f: e, r: t }) => t || (e?.defaultValue ? e.defaultValue : null));
771
800
  }
772
- function p(n) {
773
- return C({
774
- f: e.fields.getByName(n),
775
- s: t
801
+ function g(t) {
802
+ return w({
803
+ f: e.fields.getByName(t),
804
+ s: r
776
805
  }, ({ f: e, s: t }) => e && t[e.id] || (e?.defaultValue ? e.defaultValue : null));
777
806
  }
778
- return k({
779
- clock: n,
780
- target: a.clearAll
781
- }), k({
807
+ return A({
782
808
  clock: i,
783
- target: a.clear
809
+ target: o.clearAll
810
+ }), A({
811
+ clock: a,
812
+ target: o.clear
784
813
  }), {
785
- register: o,
786
- clearAll: n,
787
- clear: i,
788
- commit: c,
789
- getResponsesToCommit: s,
790
- listStore: d,
791
- getAllStore: u,
792
- getByFieldId: f,
793
- getByFieldName: p
814
+ register: s,
815
+ clearAll: i,
816
+ clear: a,
817
+ commit: f,
818
+ getResponsesToCommit: u,
819
+ listStore: m,
820
+ getAllStore: p,
821
+ getByFieldId: h,
822
+ getByFieldName: g
794
823
  };
795
824
  });
796
- function He(e) {
797
- return j(Ve, e);
825
+ function Be(e) {
826
+ return M(ze, e);
798
827
  }
799
828
  //#endregion
800
829
  //#region src/utils/api-url.ts
801
- function Ue() {
802
- if (_()) {
830
+ function Ve() {
831
+ if (f()) {
803
832
  let e = [
804
833
  document.currentScript,
805
834
  document.getElementById("picked_script"),
@@ -813,36 +842,36 @@ function Ue() {
813
842
  }
814
843
  //#endregion
815
844
  //#region src/utils/search-params.ts
816
- function We() {
817
- if (!p()) return {};
845
+ function He() {
846
+ if (!o()) return {};
818
847
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
819
848
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
820
849
  for (let r of n) {
821
850
  let n = r.replace("picked-", "");
822
851
  t[n] = e.getAll(r);
823
852
  }
824
- let r = b("s");
825
- if (n.size > 0) y.set(r, t);
853
+ let r = S("s");
854
+ if (n.size > 0) x.set(r, t);
826
855
  else {
827
- let e = y.get(r);
856
+ let e = x.get(r);
828
857
  if (e) return e.json() || {};
829
858
  }
830
859
  return t;
831
860
  }
832
861
  //#endregion
833
862
  //#region src/utils/user-session.ts
834
- function Ge() {
835
- return h() ? 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)}`;
863
+ function Ue() {
864
+ 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)}`;
836
865
  }
837
- var Ke = b("session", "global"), qe = () => {
838
- let e = v.get(Ke), t;
866
+ var We = S("session", "global"), Ge = () => {
867
+ let e = b.get(We), t;
839
868
  e.isSet() && (t = e.json());
840
869
  let n = (t) => e.set({
841
870
  id: t.id,
842
871
  isUser: t.isUser,
843
872
  identifiers: t.identifiers
844
873
  }), r = {
845
- id: t?.id ?? Ge(),
874
+ id: t?.id ?? Ue(),
846
875
  isUser: t?.isUser ?? void 0,
847
876
  identifiers: t?.identifiers ?? void 0,
848
877
  setIsUser(e) {
@@ -859,22 +888,22 @@ var Ke = b("session", "global"), qe = () => {
859
888
  }
860
889
  };
861
890
  return n(r), r;
862
- }, Je = () => g() ? qe() : null;
891
+ }, Ke = () => u() ? Ge() : null;
863
892
  //#endregion
864
893
  //#region src/utils/picked-config.ts
865
- function Y() {
866
- if (p()) return globalThis.window.pickedConfig;
894
+ function Z() {
895
+ if (o()) return globalThis.window.pickedConfig;
867
896
  }
868
- function Ye() {
869
- if (!p()) return;
870
- let e = Y(), t = e?.organizationId, n = e?.projectId;
897
+ function qe() {
898
+ if (!o()) return;
899
+ let e = Z(), t = e?.organizationId, n = e?.projectId;
871
900
  return t && n ? {
872
901
  organizationId: t,
873
902
  projectId: n
874
903
  } : void 0;
875
904
  }
876
- function Xe() {
877
- if (!_()) return;
905
+ function Je() {
906
+ if (!f()) return;
878
907
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
879
908
  if (!e) return;
880
909
  let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
@@ -883,27 +912,27 @@ function Xe() {
883
912
  projectId: n
884
913
  } : void 0;
885
914
  }
886
- function Ze(e) {
915
+ function Ye(e) {
887
916
  let { organizationId: t, projectId: n } = e;
888
917
  if (t && n) return {
889
918
  organizationId: t,
890
919
  projectId: n
891
920
  };
892
- let r = Ye();
921
+ let r = qe();
893
922
  if (r) return r;
894
- let i = Xe();
923
+ let i = Je();
895
924
  if (i) return i;
896
925
  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.");
897
926
  }
898
927
  //#endregion
899
928
  //#region src/utils/render-string.ts
900
- function X(e) {
929
+ function Q(e) {
901
930
  return e == null || e === "" || Number.isNaN(e);
902
931
  }
903
- var Qe = {
904
- default: (e, t) => X(e) ? String(t ?? "") : String(e),
905
- append: (e, t) => t && !X(e) ? `${e} ${t}` : e,
906
- prepend: (e, t) => t && !X(e) ? `${t} ${e}` : e,
932
+ var Xe = {
933
+ default: (e, t) => Q(e) ? String(t ?? "") : String(e),
934
+ append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
935
+ prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
907
936
  upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
908
937
  lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
909
938
  capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
@@ -921,24 +950,24 @@ var Qe = {
921
950
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
922
951
  }
923
952
  };
924
- function $e(e) {
953
+ function Ze(e) {
925
954
  return typeof e == "object" && !!e;
926
955
  }
927
- function et(e, t) {
956
+ function Qe(e, t) {
928
957
  let n = t;
929
- for (let t of e.split(".")) if ($e(n) && t in n) n = n[t];
958
+ for (let t of e.split(".")) if (Ze(n) && t in n) n = n[t];
930
959
  else return;
931
960
  return typeof n == "function" ? n() : n;
932
961
  }
933
- function tt(e, t) {
934
- let n = e.split("|").map((e) => e.trim()), r = et(n.shift() ?? "", t);
962
+ function $e(e, t) {
963
+ let n = e.split("|").map((e) => e.trim()), r = Qe(n.shift() ?? "", t);
935
964
  for (let e of n) {
936
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Qe[i];
965
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Xe[i];
937
966
  o && (r = o(r, a));
938
967
  }
939
- return X(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
968
+ return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
940
969
  }
941
- function Z(e, t) {
970
+ function et(e, t) {
942
971
  let n = "", r = 0;
943
972
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
944
973
  r += 2;
@@ -950,20 +979,19 @@ function Z(e, t) {
950
979
  }
951
980
  i += e[r++];
952
981
  }
953
- n += tt(i.trim(), t);
982
+ n += $e(i.trim(), t);
954
983
  } else n += e[r++];
955
984
  return n;
956
985
  }
957
986
  //#endregion
958
987
  //#region src/picked.ts
959
- var Q = class {
960
- static logger = u;
988
+ var $ = class {
989
+ static logger = r;
961
990
  options;
962
991
  isReady = !1;
963
- project;
964
992
  plugins = {};
965
993
  pluginStartHooks = [];
966
- eventBus = D();
994
+ eventBus = O();
967
995
  events;
968
996
  organizationId;
969
997
  projectId;
@@ -974,42 +1002,42 @@ var Q = class {
974
1002
  precondition;
975
1003
  condition;
976
1004
  preconditionPassed;
977
- searchParams = We();
978
- history = Oe();
979
- components = V({ client: this });
980
- experienceInstances = i({ client: this });
981
- experiences = de({ client: this });
982
- frameworks = he({ client: this });
983
- predicates = Se({ client: this });
984
- features = Te({ client: this });
985
- responses = He({ client: this });
986
- fields = Ne();
987
- actions = Le();
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();
988
1016
  constructor(e) {
989
- this.events = Ae(this.eventBus);
990
- let { organizationId: t, projectId: n } = Ze(e);
991
- 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({
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({
992
1020
  type: "load",
993
- version: oe()
1021
+ version: ae()
994
1022
  });
995
1023
  }
996
1024
  start = () => {
997
- ye(this), (async () => {
998
- if (!_()) return;
1025
+ ve(this), (async () => {
1026
+ if (!f()) return;
999
1027
  await this.runPluginStartHooks();
1000
- let t = await this.evaluateGate(this.precondition);
1001
- this.preconditionPassed = t;
1002
- let n;
1003
- t && (n = await this.evaluateGate(this.condition));
1004
- let r = t && n === !0;
1005
- if (typeof n == "boolean" && this.session) {
1006
- let e = n;
1028
+ let e = await this.evaluateGate(this.precondition);
1029
+ this.preconditionPassed = e;
1030
+ let t;
1031
+ e && (t = await this.evaluateGate(this.condition));
1032
+ let n = e && t === !0;
1033
+ if (typeof t == "boolean" && this.session) {
1034
+ let e = t;
1007
1035
  this.session.setIsUser(e), this.eventBus({
1008
1036
  type: "user_decide",
1009
1037
  value: e
1010
1038
  });
1011
1039
  }
1012
- if (this.eventBus({ type: "initialize" }), r && P(this), await e(), r && P(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1040
+ if (this.eventBus({ type: "initialize" }), n && F(this), await g(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1013
1041
  let { id: e, isUser: t, identifiers: n } = this.session;
1014
1042
  this.eventBus({
1015
1043
  type: "session",
@@ -1021,32 +1049,32 @@ var Q = class {
1021
1049
  })();
1022
1050
  };
1023
1051
  registerFramework = (e) => {
1024
- ge(e, this.frameworks);
1052
+ he(e, this.frameworks);
1025
1053
  };
1026
1054
  registerComponent = (e, t) => {
1027
- H(e, t, this.components);
1055
+ U(e, t, this.components);
1028
1056
  };
1029
1057
  registerPlugin = (e) => {
1030
- I(this, e, this.plugins);
1058
+ L(this, e, this.plugins);
1031
1059
  let t = this.plugins[e.name];
1032
1060
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1033
1061
  };
1034
1062
  registerFeature = (e, t) => {
1035
- Ee(e, t, this.features);
1063
+ Te(e, t, this.features);
1036
1064
  };
1037
1065
  registerPredicate = (e, t) => {
1038
- Ce(e, t, this.predicates);
1066
+ Se(e, t, this.predicates);
1039
1067
  };
1040
1068
  registerField = (e) => {
1041
- Pe(e, this.fields);
1069
+ Me(e, this.fields);
1042
1070
  };
1043
1071
  registerAction = (e, t) => {
1044
- Re(e, t, this.actions);
1072
+ Ie(e, t, this.actions);
1045
1073
  };
1046
1074
  registerExperience = (e) => {
1047
- e.component && H(`experience:${e.id}`, e.component, this.components), fe(e, this.experiences);
1075
+ e.component && U(`experience:${e.id}`, e.component, this.components), de(e, this.experiences);
1048
1076
  };
1049
- getStateSnapshot = () => U(this);
1077
+ getStateSnapshot = () => W(this);
1050
1078
  launchExperienceById = async (e, t) => {
1051
1079
  this.experiences.launch({
1052
1080
  id: e,
@@ -1060,7 +1088,7 @@ var Q = class {
1060
1088
  for (let e of this.pluginStartHooks) await e();
1061
1089
  }
1062
1090
  async evaluateGate(e) {
1063
- return e === void 0 ? !0 : typeof e == "boolean" ? e : await r(this, e) === !0;
1091
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
1064
1092
  }
1065
1093
  setupPlugins() {
1066
1094
  this.options.plugins?.forEach((e) => {
@@ -1126,47 +1154,28 @@ var Q = class {
1126
1154
  getPluginConfig = (e) => this.plugins[e] ?? {};
1127
1155
  renderString = (e, t) => {
1128
1156
  let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldId] = t.value, e), {});
1129
- return Z(e, {
1157
+ return et(e, {
1130
1158
  ...t,
1131
1159
  responses: n
1132
1160
  });
1133
1161
  };
1134
1162
  };
1135
1163
  //#endregion
1136
- //#region src/utils/get-step-fields.ts
1137
- function $(e) {
1138
- return e.options?.some((e) => "condition" in e) ?? !1;
1139
- }
1140
- function nt(e) {
1141
- return e.some((e) => e.condition || $(e));
1142
- }
1143
- async function rt(e, t) {
1144
- return t.length === 0 || !nt(t) ? t : (await Promise.all(t.map(async (t) => {
1145
- if (!(!t.condition || await r(e, t.condition))) return null;
1146
- if (!t.options || !$(t)) return t;
1147
- let n = (await Promise.all(t.options.map(async (t) => t.condition ? await r(e, t.condition) ? t : null : t))).filter((e) => e !== null);
1148
- return n.length === t.options.length ? t : n.length === 0 ? null : {
1149
- ...t,
1150
- options: n
1151
- };
1152
- }))).filter((e) => e !== null);
1153
- }
1154
- //#endregion
1155
1164
  //#region src/entities/component/lazyComponent.ts
1156
- function it(e) {
1165
+ function tt(e) {
1157
1166
  return {
1158
1167
  $$type: "lazy-component",
1159
1168
  load: e
1160
1169
  };
1161
1170
  }
1162
- function at(e) {
1171
+ function nt(e) {
1163
1172
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1164
1173
  }
1165
1174
  //#endregion
1166
1175
  //#region src/exports.ts
1167
- var ot = (e) => {
1168
- let t = new Q(e);
1169
- return te(t), t;
1176
+ var rt = (e) => {
1177
+ let t = new $(e);
1178
+ return d(t), t;
1170
1179
  };
1171
1180
  //#endregion
1172
- export { Q as Picked, ot as createClient, b as createStorageKey, r as evaluateRuleLogic, Y as getPickedConfig, rt as getStepFields, at as isLazyLoader, s as isPickedRoot, it as lazyComponent, v as localStore, y as sessionStore, ae as subscribe, re as supportsCookies, h as supportsCryptoRandomUUID, _ as supportsDocument, ee as supportsHistory, d as supportsIntersectionObserver, g as supportsLocalStorage, ne as supportsLocation, f as supportsSessionStorage, m as supportsShadowRoot, ie as supportsWebComponents, p as supportsWindow };
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 };