@picked/client 0.0.1-dev.1772168509010 → 0.0.1-dev.1772412203098

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 (75) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/cjs/plugins/create-experience/index.js +1 -1
  3. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  4. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  5. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  6. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  7. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  8. package/dist/cjs/server/index.js +1 -1
  9. package/dist/esm/index.js +691 -593
  10. package/dist/esm/plugins/create-experience/index.js +210 -236
  11. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  12. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  13. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  14. package/dist/esm/plugins/responses-indexeddb/index.js +51 -46
  15. package/dist/esm/plugins/single-page-app/index.js +24 -24
  16. package/dist/esm/server/index.js +1 -1
  17. package/dist/experience-instance-BX0aqKsC.cjs +1 -0
  18. package/dist/{experience-instance-fvSEb72i.js → experience-instance-DTyL1fNb.js} +205 -199
  19. package/dist/{object-JwZ58NOH.js → object-CJssU1Pm.js} +1 -1
  20. package/dist/object-mwaxtjLG.cjs +1 -0
  21. package/dist/storage-58NoTSsc.cjs +1 -0
  22. package/dist/{storage-Co_LbKr_.js → storage-B2d81EOI.js} +35 -30
  23. package/dist/types/entities/action/action.d.ts +5 -2
  24. package/dist/types/entities/action/action.d.ts.map +1 -1
  25. package/dist/types/entities/experience/experience.d.ts +5 -4
  26. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  27. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  28. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  29. package/dist/types/entities/field/field.d.ts +51 -14
  30. package/dist/types/entities/field/field.d.ts.map +1 -1
  31. package/dist/types/entities/history/history.d.ts.map +1 -1
  32. package/dist/types/entities/project/project.d.ts.map +1 -1
  33. package/dist/types/entities/response/response.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/logic-engine.d.ts +2 -8
  37. package/dist/types/logic-engine.d.ts.map +1 -1
  38. package/dist/types/picked.d.ts +16 -7
  39. package/dist/types/picked.d.ts.map +1 -1
  40. package/dist/types/plugins/create-experience/create-experience.d.ts +26 -21
  41. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  42. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
  43. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  44. package/dist/types/plugins/history-browser-storage/plugin.d.ts +2 -1
  45. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  46. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
  47. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  48. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  49. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  50. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  51. package/dist/types/utils/dom.d.ts +0 -3
  52. package/dist/types/utils/dom.d.ts.map +1 -1
  53. package/dist/types/utils/events.d.ts +1 -1
  54. package/dist/types/utils/events.d.ts.map +1 -1
  55. package/dist/types/utils/get-step-fields.d.ts +2 -1
  56. package/dist/types/utils/get-step-fields.d.ts.map +1 -1
  57. package/dist/types/utils/global-obj.d.ts +0 -1
  58. package/dist/types/utils/global-obj.d.ts.map +1 -1
  59. package/dist/types/utils/indexed-db.d.ts +2 -1
  60. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  61. package/dist/types/utils/logger.d.ts.map +1 -1
  62. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  63. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  64. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  65. package/dist/types/utils/object.d.ts +0 -8
  66. package/dist/types/utils/object.d.ts.map +1 -1
  67. package/dist/types/utils/picked-config.d.ts +1 -1
  68. package/dist/types/utils/picked-config.d.ts.map +1 -1
  69. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  70. package/dist/types/utils/search-params.d.ts.map +1 -1
  71. package/dist/types/utils/storage.d.ts.map +1 -1
  72. package/package.json +14 -2
  73. package/dist/experience-instance-BsXG5XJ4.cjs +0 -1
  74. package/dist/object-BbFTsGh3.cjs +0 -1
  75. package/dist/storage-Be5xWNPC.cjs +0 -1
package/dist/esm/index.js CHANGED
@@ -1,144 +1,145 @@
1
- import { createDomain as x, createApi as j, attach as U, createStore as T, createEffect as R, sample as k, combine as D, createEvent as V } from "effector";
2
- import { createFactory as b, invoke as I } from "@withease/factories";
3
- import { g as W, t as te, c as re, i as se, e as P, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
4
- import { f as zt } from "../experience-instance-fvSEb72i.js";
5
- import { l as w } from "../logger-C9a75KZn.js";
6
- import { c as A, l as C, s as M } from "../storage-Co_LbKr_.js";
7
- import { a as Mt } from "../storage-Co_LbKr_.js";
8
- import { p as ae } from "../api-CbXfbi_s.js";
9
- import { g as ce } from "../id-BW-g3y32.js";
10
- import { i as ue } from "../object-JwZ58NOH.js";
11
- import { s as L, a as _, b as de, c as le, d as pe } from "../supports-8YT4QKI7.js";
12
- import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from "../supports-8YT4QKI7.js";
13
- const Y = x("experience"), fe = b(
1
+ import { createDomain as F, createApi as j, attach as T, createStore as _, createEffect as C, sample as w, combine as A, createEvent as $ } from "effector";
2
+ import { createFactory as I, invoke as x } from "@withease/factories";
3
+ import { g as Q, t as ne, c as se, i as ie, e as E, a as oe, b as ae, d as ce } from "../experience-instance-DTyL1fNb.js";
4
+ import { f as Mt } from "../experience-instance-DTyL1fNb.js";
5
+ import { l as b } from "../logger-C9a75KZn.js";
6
+ import { c as R, l as O, s as D } from "../storage-B2d81EOI.js";
7
+ import { a as Dt } from "../storage-B2d81EOI.js";
8
+ import { p as ue } from "../api-CbXfbi_s.js";
9
+ import { g as le } from "../id-BW-g3y32.js";
10
+ import { i as de } from "../object-CJssU1Pm.js";
11
+ import { s as H, a as G, b as pe, c as fe, d as ge } from "../supports-8YT4QKI7.js";
12
+ import { e as Vt, f as Nt, g as Tt, h as Lt, i as _t, j as Ht, k as Gt } from "../supports-8YT4QKI7.js";
13
+ const X = F("experience"), me = I(
14
14
  ({ client: t, experience: e }) => {
15
- const r = Y.store(e), s = j(r, {
16
- merge(u, g) {
15
+ const r = X.store(e), s = j(r, {
16
+ merge(l, m) {
17
17
  return {
18
- ...u,
19
- ...g.experience
18
+ ...l,
19
+ ...m.experience
20
20
  };
21
21
  }
22
- }), i = r.map((u) => ({
23
- name: u.name,
24
- decisionLogic: u.condition ?? u.decide,
25
- targetSelectors: u.targets,
22
+ }), i = r.map((l) => ({
23
+ name: l.name,
24
+ // eslint-disable-next-line sonarjs/deprecation -- backwards compatibility: `decide` is deprecated but still supported
25
+ decisionLogic: l.condition ?? l.decide,
26
+ targetSelectors: l.targets,
26
27
  initializeOpenLogic: e.initializeOpen
27
- })), l = t.components.listStore.map(
28
- (u) => u.find((g) => g.name === `experience:${e.id}`) || u.find((g) => g.name === "experience"),
28
+ })), d = t.components.listStore.map(
29
+ (l) => l.find((m) => m.name === `experience:${e.id}`) || l.find((m) => m.name === "experience"),
29
30
  { skipVoid: !1 }
30
- ), a = r.map((u) => ({
31
- steps: u.steps,
32
- nodes: u.nodes,
33
- edges: u.edges,
34
- conditionals: u.conditionals
35
- })), n = r.map((u) => u.fields), p = e.actions ?? [];
31
+ ), p = r.map((l) => ({
32
+ steps: l.steps,
33
+ nodes: l.nodes,
34
+ edges: l.edges,
35
+ conditionals: l.conditionals
36
+ })), u = r.map((l) => l.fields), g = e.actions ?? [];
36
37
  return {
37
38
  id: e.id,
38
39
  configStore: i,
39
- treeStore: a,
40
- fieldsStore: n,
41
- componentStore: l,
42
- actions: p,
40
+ treeStore: p,
41
+ fieldsStore: u,
42
+ componentStore: d,
43
+ actions: g,
43
44
  merge: s.merge
44
45
  };
45
46
  }
46
47
  );
47
- function ge(t) {
48
- return I(fe, t);
48
+ function ye(t) {
49
+ return x(me, t);
49
50
  }
50
- const me = b(({ client: t }) => {
51
- const e = Y.store({}), r = j(e, {
52
- register(u, g) {
51
+ const he = I(({ client: t }) => {
52
+ const e = X.store({}), r = j(e, {
53
+ register(l, m) {
53
54
  return {
54
- ...u,
55
- [g.id]: g
55
+ ...l,
56
+ [m.id]: m
56
57
  };
57
58
  }
58
59
  });
59
- function s(u) {
60
- const g = e.getState()[u.id];
61
- if (g) {
62
- g.merge({ experience: u, strategy: "override" });
60
+ function s(l) {
61
+ const m = e.getState()[l.id];
62
+ if (m) {
63
+ m.merge({ experience: l, strategy: "override" });
63
64
  return;
64
65
  }
65
- const S = ge({ client: t, experience: u });
66
- r.register(S);
66
+ const h = ye({ client: t, experience: l });
67
+ r.register(h);
67
68
  }
68
- const i = e.map((u) => Object.values(u));
69
- function l(u) {
70
- return e.map((g) => g[u], { skipVoid: !1 });
69
+ const i = e.map((l) => Object.values(l));
70
+ function d(l) {
71
+ return e.map((m) => m[l], { skipVoid: !1 });
71
72
  }
72
- const a = l, n = U({
73
+ const p = d, u = T({
73
74
  source: e,
74
- effect: async (u, { id: g, options: S }) => {
75
- const m = u[g];
76
- if (!m) {
77
- w("warn", `Experience with id '${g}' not found.`);
75
+ effect: async (l, { id: m, options: h }) => {
76
+ const y = l[m];
77
+ if (!y) {
78
+ b("warn", `Experience with id '${m}' not found.`);
78
79
  return;
79
80
  }
80
- if (S?.bypassCondition) {
81
- N(t, m, S);
81
+ if (h?.bypassCondition) {
82
+ L(t, y, h);
82
83
  return;
83
84
  }
84
- await Q(t, m) && N(t, m, S);
85
+ await Z(t, y) && L(t, y, h);
85
86
  }
86
- }), p = U({
87
+ }), g = T({
87
88
  source: t.experienceInstances.listStore,
88
- effect: (u, { id: g, options: S }) => {
89
- const m = u.filter((o) => o.experienceId === g);
90
- if (m.length > 0)
91
- for (const o of m)
92
- o.open();
89
+ effect: (l, { id: m, options: h }) => {
90
+ const y = l.filter((c) => c.experienceId === m);
91
+ if (y.length > 0)
92
+ for (const c of y)
93
+ c.open();
93
94
  else
94
- n({ id: g, options: { ...S, initialiseOpen: !0 } });
95
+ u({ id: m, options: { ...h, initialiseOpen: !0 } });
95
96
  }
96
97
  });
97
98
  return {
98
99
  /** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
99
100
  register: s,
100
101
  /** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
101
- get: l,
102
+ get: d,
102
103
  /** @deprecated Use `experiences.get(id)` instead. */
103
- getById: a,
104
+ getById: p,
104
105
  /** Effector effect that launches an experience by ID, creating instances for each DOM target. */
105
- launch: n,
106
+ launch: u,
106
107
  /** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
107
- open: p,
108
+ open: g,
108
109
  /** Derived store containing all registered experiences as an array. */
109
110
  listStore: i
110
111
  };
111
112
  });
112
- function he(t) {
113
- return I(me, t);
113
+ function ve(t) {
114
+ return x(he, t);
114
115
  }
115
- const ye = (t, e) => {
116
+ const Se = (t, e) => {
116
117
  e.register(t);
117
- }, N = (t, e, r) => {
118
- const { targetSelectors: s } = e.configStore.getState(), i = W(s, e.id);
118
+ }, L = (t, e, r) => {
119
+ const { targetSelectors: s } = e.configStore.getState(), i = Q(s, e.id);
119
120
  i.forEach(
120
- ({ elements: a }) => a.forEach((n) => te(n, e.id))
121
- ), re(i, e.id).forEach((a) => {
122
- r ? t.experienceInstances.spawn(e, a, r) : t.experienceInstances.spawn(e, a);
121
+ ({ elements: p }) => p.forEach((u) => ne(u, e.id))
122
+ ), se(i, e.id).forEach((p) => {
123
+ r ? t.experienceInstances.spawn(e, p, r) : t.experienceInstances.spawn(e, p);
123
124
  });
124
- }, H = async (t) => {
125
+ }, J = async (t) => {
125
126
  await Promise.all(
126
127
  t.experiences.listStore.getState().map(async (e) => {
127
- await Q(t, e) && N(t, e);
128
+ await Z(t, e) && L(t, e);
128
129
  })
129
130
  );
130
- }, Q = async (t, e) => {
131
+ }, Z = async (t, e) => {
131
132
  if (!t.session?.isUser)
132
133
  return !1;
133
134
  const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
134
- return W(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : se(r) ? await P(t, r) === !0 : !0;
135
- }, Se = (t, e, r) => {
135
+ return Q(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : ie(r) ? await E(t, r) === !0 : !0;
136
+ }, ke = (t, e, r) => {
136
137
  const s = e.name, i = e.setup(t);
137
138
  if (i) {
138
- const l = r[s] ?? {};
139
- r[s] = Object.freeze({ ...l, ...i });
139
+ const d = r[s] ?? {};
140
+ r[s] = Object.freeze({ ...d, ...i });
140
141
  }
141
- }, ve = x("component"), ke = b(
142
+ }, we = F("component"), be = I(
142
143
  ({ client: t, component: e, name: r }) => {
143
144
  const s = t.frameworks.getByName(e.frameworkName);
144
145
  return {
@@ -148,89 +149,89 @@ const ye = (t, e) => {
148
149
  };
149
150
  }
150
151
  );
151
- function we(t) {
152
- return I(ke, t);
152
+ function Ie(t) {
153
+ return x(be, t);
153
154
  }
154
- const be = b(({ client: t }) => {
155
- const e = ve.store({}), r = j(e, {
156
- register(a, n) {
155
+ const xe = I(({ client: t }) => {
156
+ const e = we.store({}), r = j(e, {
157
+ register(p, u) {
157
158
  return {
158
- ...a,
159
- [n.name]: n
159
+ ...p,
160
+ [u.name]: u
160
161
  };
161
162
  }
162
163
  });
163
- function s(a, n) {
164
- e.getState()[a] && w(
164
+ function s(p, u) {
165
+ e.getState()[p] && b(
165
166
  "warn",
166
- `Component '${a}' already registered. Registering again will override the previous registration.`
167
+ `Component '${p}' already registered. Registering again will override the previous registration.`
167
168
  );
168
- const u = we({ client: t, name: a, component: n });
169
- r.register(u);
169
+ const l = Ie({ client: t, name: p, component: u });
170
+ r.register(l);
170
171
  }
171
- const i = e.map((a) => Object.values(a));
172
- function l(a) {
173
- return e.map((n) => n[a], { skipVoid: !1 });
172
+ const i = e.map((p) => Object.values(p));
173
+ function d(p) {
174
+ return e.map((u) => u[p], { skipVoid: !1 });
174
175
  }
175
176
  return {
176
177
  register: s,
177
- getByName: l,
178
+ getByName: d,
178
179
  listStore: i
179
180
  };
180
181
  });
181
- function Ie(t) {
182
- return I(be, t);
182
+ function Fe(t) {
183
+ return x(xe, t);
183
184
  }
184
- const G = (t, e, r) => {
185
+ const q = (t, e, r) => {
185
186
  r.register(t, e);
186
- }, Fe = x("framework"), xe = b(({ client: t }) => {
187
- const e = Fe.store({}), r = j(e, {
188
- register(a, n) {
187
+ }, je = F("framework"), Ae = I(({ client: t }) => {
188
+ const e = je.store({}), r = j(e, {
189
+ register(p, u) {
189
190
  return {
190
- ...a,
191
- [n.name]: n.framework
191
+ ...p,
192
+ [u.name]: u.framework
192
193
  };
193
194
  }
194
195
  });
195
- function s(a, n) {
196
- e.getState()[a] && w(
196
+ function s(p, u) {
197
+ e.getState()[p] && b(
197
198
  "warn",
198
- `Framework '${a}' already registered. Registering again will override the previous registration.`
199
- ), r.register({ name: a, framework: n });
199
+ `Framework '${p}' already registered. Registering again will override the previous registration.`
200
+ ), r.register({ name: p, framework: u });
200
201
  }
201
- const i = e.map((a) => Object.values(a));
202
- function l(a) {
203
- return e.map((n) => n[a], { skipVoid: !1 });
202
+ const i = e.map((p) => Object.values(p));
203
+ function d(p) {
204
+ return e.map((u) => u[p], { skipVoid: !1 });
204
205
  }
205
206
  return {
206
207
  register: s,
207
- getByName: l,
208
+ getByName: d,
208
209
  listStore: i
209
210
  };
210
211
  });
211
- function je(t) {
212
- return I(xe, t);
212
+ function Ee(t) {
213
+ return x(Ae, t);
213
214
  }
214
- const Ee = (t, e) => {
215
+ const Pe = (t, e) => {
215
216
  e.register(t.name, t);
216
- }, Pe = 6e3, Ae = A("last_ping", "global"), $e = async (t) => {
217
+ }, $e = 6e3, Re = R("last_ping", "global"), Be = async (t) => {
217
218
  try {
218
- const e = Date.now(), r = C.get(Ae);
219
+ const e = Date.now(), r = O.get(Re);
219
220
  let s = 0;
220
- if (r.isSet() && (s = r.json() ?? 0), s && e - s < Pe)
221
+ if (r.isSet() && (s = r.json() ?? 0), s && e - s < $e)
221
222
  return !0;
222
223
  const i = {
223
224
  projectId: t.projectId,
224
225
  path: window.location.pathname
225
- }, l = {}, n = document.getElementById("picked_script")?.dataset.verceltoken;
226
- n && (l["x-vercel-protection-bypass"] = n);
227
- const u = (await ae(t.apiUrl, "ping", i, l)).ok;
228
- return u && r.set(e), u;
226
+ }, d = {}, u = document.getElementById("picked_script")?.dataset.verceltoken;
227
+ u && (d["x-vercel-protection-bypass"] = u);
228
+ const l = (await ue(t.apiUrl, "ping", i, d)).ok;
229
+ return l && r.set(e), l;
229
230
  } catch (e) {
230
- return w("error", e), !1;
231
+ return b("error", e), !1;
231
232
  }
232
233
  };
233
- function X(t) {
234
+ function ee(t) {
234
235
  const e = typeof window < "u", r = {
235
236
  client: t,
236
237
  responses: t.responses.listStore.getState(),
@@ -242,595 +243,692 @@ function X(t) {
242
243
  };
243
244
  return Object.freeze(r);
244
245
  }
245
- const Be = x("predicate"), Re = b(({ client: t }) => {
246
- const e = Be.store({}), r = j(e, {
247
- register(n, p) {
246
+ const ze = F("predicate"), Ce = I(({ client: t }) => {
247
+ const e = ze.store({}), r = j(e, {
248
+ register(u, g) {
248
249
  return {
249
- ...n,
250
- [p.name]: {
251
- name: p.name,
252
- predicate: p.predicate
250
+ ...u,
251
+ [g.name]: {
252
+ name: g.name,
253
+ predicate: g.predicate
253
254
  }
254
255
  };
255
256
  }
256
257
  });
257
- function s(n, p) {
258
- e.getState()[n] && w(
258
+ function s(u, g) {
259
+ e.getState()[u] && b(
259
260
  "warn",
260
- `Predicate '${n}' already registered. Registering again will override the previous registration.`
261
- ), r.register(Object.freeze({ name: n, predicate: p }));
261
+ `Predicate '${u}' already registered. Registering again will override the previous registration.`
262
+ ), r.register(Object.freeze({ name: u, predicate: g }));
262
263
  }
263
- const i = e.map((n) => Object.values(n));
264
- function l(n) {
265
- return e.map((p) => p[n]?.predicate, { skipVoid: !1 });
264
+ const i = e.map((u) => Object.values(u));
265
+ function d(u) {
266
+ return e.map((g) => g[u]?.predicate, { skipVoid: !1 });
266
267
  }
267
- function a(n) {
268
- const p = T(() => {
268
+ function p(u) {
269
+ const g = _(() => {
269
270
  }, {
270
271
  skipVoid: !1
271
- }), u = R(async () => {
272
- const g = l(n).getState();
273
- if (!g)
272
+ }), l = C(async () => {
273
+ const m = d(u).getState();
274
+ if (!m)
274
275
  return;
275
- const S = X(t);
276
- return (...m) => g({ ...S, args: m });
276
+ const h = ee(t);
277
+ return (...y) => m({ ...h, args: y });
277
278
  });
278
- return k({
279
+ return w({
279
280
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
280
- target: u
281
- }), k({
282
- clock: u.doneData,
283
- filter: (g) => g !== void 0,
284
- target: p
285
- }), u(), p;
281
+ target: l
282
+ }), w({
283
+ clock: l.doneData,
284
+ filter: (m) => m !== void 0,
285
+ target: g
286
+ }), l(), g;
286
287
  }
287
288
  return {
288
289
  register: s,
289
- getByName: l,
290
+ getByName: d,
290
291
  listStore: i,
291
- getEvokablePredicate: a
292
+ getEvokablePredicate: p
292
293
  };
293
294
  });
294
- function ze(t) {
295
- return I(Re, t);
295
+ function Me(t) {
296
+ return x(Ce, t);
296
297
  }
297
- const Ce = (t, e, r) => {
298
+ const Oe = (t, e, r) => {
298
299
  r.register(t, e);
299
- }, J = x("feature"), Me = b(({ client: t }) => {
300
- const e = J.store({}), r = J.store([]), s = j(e, {
301
- register(o, c) {
300
+ }, K = F("feature"), De = I(({ client: t }) => {
301
+ const e = K.store({}), r = K.store([]), s = j(e, {
302
+ register(c, n) {
302
303
  return {
303
- ...o,
304
- [c.id]: c.feature
304
+ ...c,
305
+ [n.id]: n.feature
305
306
  };
306
307
  }
307
308
  });
308
- function i(o, c) {
309
- e.getState()[o] && w(
309
+ function i(c, n) {
310
+ e.getState()[c] && b(
310
311
  "warn",
311
- `Feature '${o}' already registered. Registering again will override the previous registration.`
312
+ `Feature '${c}' already registered. Registering again will override the previous registration.`
312
313
  );
313
- const d = {
314
- id: o,
314
+ const a = {
315
+ id: c,
315
316
  feature: {
316
- ...c,
317
- id: o
317
+ ...n,
318
+ id: c
318
319
  }
319
320
  };
320
321
  s.register(
321
322
  Object.freeze({
322
- id: o,
323
- feature: d
323
+ id: c,
324
+ feature: a
324
325
  })
325
326
  );
326
327
  }
327
- const l = R(
328
+ const d = C(
328
329
  async ({
329
- id: o,
330
- key: c,
331
- storage: f = "local"
330
+ id: c,
331
+ key: n,
332
+ storage: o = "local"
332
333
  }) => {
333
- const d = A(`feature:${o}:${c}`, "global"), y = (f === "session" ? M : C).get(d).boolean();
334
- return y === null ? null : { id: o, key: c, bucket: y, storage: f };
334
+ const a = R(`feature:${c}:${n}`, "global"), v = (o === "session" ? D : O).get(a).boolean();
335
+ return v === null ? null : { id: c, key: n, bucket: v, storage: o };
335
336
  }
336
- ), a = R((o) => {
337
- if (!o)
337
+ ), p = C((c) => {
338
+ if (!c)
338
339
  return null;
339
- const c = A(`feature:${o.id}:${o.key}`, "global");
340
- (o.storage === "session" ? M : C).set(c, o.bucket);
341
- }), n = /* @__PURE__ */ new Map(), p = U({
340
+ const n = R(`feature:${c.id}:${c.key}`, "global");
341
+ (c.storage === "session" ? D : O).set(n, c.bucket);
342
+ }), u = /* @__PURE__ */ new Map(), g = T({
342
343
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
343
- effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: c }, { id: f, decide: d, key: h }) => {
344
- const y = c.find(
345
- (B) => B.id === f && B.key === h
344
+ effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: n }, { id: o, decide: a, key: f }) => {
345
+ const v = n.find(
346
+ (z) => z.id === o && z.key === f
346
347
  );
347
- if (y)
348
- return y;
349
- const F = o[f];
350
- if (!F)
351
- throw new Error(`Feature with id '${f}' not found`);
352
- const $ = n.get(`${f}:${h}`);
353
- if ($ !== void 0) {
354
- const B = await $;
355
- return { id: F.id, bucket: B, key: h, storage: F.feature.storage };
348
+ if (v)
349
+ return v;
350
+ const S = c[o];
351
+ if (!S)
352
+ throw new Error(`Feature with id '${o}' not found`);
353
+ const B = u.get(`${o}:${f}`);
354
+ if (B !== void 0) {
355
+ const z = await B;
356
+ return { id: S.id, bucket: z, key: f, storage: S.feature.storage };
356
357
  }
357
- const v = d();
358
- n.set(`${f}:${h}`, v);
359
- const ee = await v;
360
- return { id: F.id, bucket: ee, key: h, storage: F.feature.storage };
358
+ const k = a();
359
+ u.set(`${o}:${f}`, k);
360
+ const re = await k;
361
+ return { id: S.id, bucket: re, key: f, storage: S.feature.storage };
361
362
  }
362
363
  });
363
- k({
364
+ w({
364
365
  clock: s.register,
365
- fn: (o) => {
366
- const { id: c, feature: f } = o;
367
- return { id: c, key: f.feature.key, storage: f.feature.storage };
366
+ fn: (c) => {
367
+ const { id: n, feature: o } = c;
368
+ return { id: n, key: o.feature.key, storage: o.feature.storage };
368
369
  },
369
- target: l
370
- }), k({
370
+ target: d
371
+ }), w({
371
372
  source: e,
372
- clock: p.doneData,
373
- fn: (o, c) => {
374
- const { id: f, bucket: d, storage: h } = c, y = o[f]?.feature.key;
375
- return y ? { key: y, id: f, bucket: d, storage: h } : null;
373
+ clock: g.doneData,
374
+ fn: (c, n) => {
375
+ const { id: o, bucket: a, storage: f } = n, v = c[o]?.feature.key;
376
+ return v ? { key: v, id: o, bucket: a, storage: f } : null;
376
377
  },
377
- target: a
378
+ target: p
378
379
  });
379
- const u = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
380
+ const l = A({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
380
381
  ({
381
- allFeaturesStore: o,
382
- resolvedFeaturesStore: c
383
- }) => Object.values(o).map((f) => {
384
- const d = c.find(
385
- (h) => h.id === f.id && h.key === f.feature.key
382
+ allFeaturesStore: c,
383
+ resolvedFeaturesStore: n
384
+ }) => Object.values(c).map((o) => {
385
+ const a = n.find(
386
+ (f) => f.id === o.id && f.key === o.feature.key
386
387
  );
387
- return d ? {
388
- id: f.id,
389
- name: f.feature.name,
390
- key: f.feature.key,
391
- getBucket: () => ({ id: f.id, bucket: d.bucket }),
388
+ return a ? {
389
+ id: o.id,
390
+ name: o.feature.name,
391
+ key: o.feature.key,
392
+ getBucket: () => ({ id: o.id, bucket: a.bucket }),
392
393
  isResolved: !0
393
394
  } : {
394
- id: f.id,
395
- name: f.feature.name,
396
- key: f.feature.key,
397
- getBucket: async () => await p(f.feature),
395
+ id: o.id,
396
+ name: o.feature.name,
397
+ key: o.feature.key,
398
+ getBucket: async () => await g(o.feature),
398
399
  isResolved: !1
399
400
  };
400
401
  })
401
402
  );
402
- k({
403
- clock: p.doneData,
403
+ w({
404
+ clock: g.doneData,
404
405
  source: { resolvedFeatures: r },
405
- filter: ({ resolvedFeatures: o }, { id: c, key: f }) => !o.some(
406
- (h) => h.id === c && h.key === f
406
+ filter: ({ resolvedFeatures: c }, { id: n, key: o }) => !c.some(
407
+ (f) => f.id === n && f.key === o
407
408
  ),
408
- fn: (o, c) => c,
409
- target: t.eventBus.prepend((o) => ({
409
+ fn: (c, n) => n,
410
+ target: t.eventBus.prepend((c) => ({
410
411
  type: "feature_decide",
411
- feature: o
412
+ feature: c
412
413
  }))
413
- }), k({
414
- clock: [l.doneData, p.doneData],
414
+ }), w({
415
+ clock: [d.doneData, g.doneData],
415
416
  source: r,
416
- fn: (o, c) => !c || o.some(
417
- (d) => d.id === c.id && d.key === c.key
418
- ) ? o : [...o, c],
417
+ fn: (c, n) => !n || c.some(
418
+ (a) => a.id === n.id && a.key === n.key
419
+ ) ? c : [...c, n],
419
420
  target: r
420
421
  });
421
- function g(o) {
422
- return u.map((c) => c.find((f) => f.id === o));
422
+ function m(c) {
423
+ return l.map((n) => n.find((o) => o.id === c));
423
424
  }
424
- function S(o) {
425
- return e.map((c) => c[o], { skipVoid: !1 });
425
+ function h(c) {
426
+ return e.map((n) => n[c], { skipVoid: !1 });
426
427
  }
427
- function m(o) {
428
- const c = T(
428
+ function y(c) {
429
+ const n = _(
429
430
  async () => {
430
431
  },
431
432
  { skipVoid: !1 }
432
- ), f = R(async () => {
433
- const d = g(o).getState();
434
- if (d)
435
- return async () => (await d.getBucket()).bucket;
433
+ ), o = C(async () => {
434
+ const a = m(c).getState();
435
+ if (a)
436
+ return async () => (await a.getBucket()).bucket;
436
437
  });
437
- return k({
438
+ return w({
438
439
  source: r,
439
- filter: (d) => d.some((h) => h.id === o),
440
- target: f
441
- }), k({
442
- clock: f.doneData,
443
- filter: (d) => d !== void 0,
444
- target: c
445
- }), f(), c;
440
+ filter: (a) => a.some((f) => f.id === c),
441
+ target: o
442
+ }), w({
443
+ clock: o.doneData,
444
+ filter: (a) => a !== void 0,
445
+ target: n
446
+ }), o(), n;
446
447
  }
447
448
  return {
448
449
  register: i,
449
- getById: g,
450
- getByName: S,
451
- listStore: u,
452
- getEvokableFeature: m
450
+ getById: m,
451
+ // eslint-disable-next-line sonarjs/deprecation -- kept for backwards compatibility; use getById instead
452
+ getByName: h,
453
+ listStore: l,
454
+ getEvokableFeature: y
453
455
  };
454
456
  });
455
- function Oe(t) {
456
- return I(Me, t);
457
+ function Ue(t) {
458
+ return x(De, t);
457
459
  }
458
- const Ue = (t, e, r) => {
460
+ const Ve = (t, e, r) => {
459
461
  r.register(t, e);
460
- }, E = x("history");
461
- function q(t, e) {
462
+ }, P = F("history");
463
+ function W(t, e) {
462
464
  return {
463
465
  // eslint-disable-next-line sonarjs/pseudo-random
464
- id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
466
+ id: le(`history-entry-${Date.now()}-${Math.random()}}`),
465
467
  node: e,
466
468
  at: Date.now(),
467
469
  experienceId: t
468
470
  };
469
471
  }
470
- const De = b(() => {
471
- const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), i = E.event();
472
- t.on(e, (a, n) => ({
473
- entries: [...a.entries, q(n.experienceId, n.node)]
474
- })), t.on(r, (a, n) => ({
472
+ const Ne = I(() => {
473
+ const t = P.store({ entries: [] }), e = P.event(), r = P.event(), s = P.event(), i = P.event();
474
+ t.on(e, (p, u) => ({
475
+ entries: [...p.entries, W(u.experienceId, u.node)]
476
+ })), t.on(r, (p, u) => ({
475
477
  entries: [
476
- ...a.entries.slice(0, -1),
477
- q(n.experienceId, n.node)
478
+ ...p.entries.slice(0, -1),
479
+ W(u.experienceId, u.node)
478
480
  ]
479
- })), t.on(i, (a, n) => n);
480
- function l(a, n) {
481
- const p = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
- for (let u = a.length - 1; u >= 0; u--) {
483
- const g = a[u], S = g?.node;
484
- if (!(!S || !ne(S)) && !(n && g?.experienceId !== n))
485
- if (p.lastStepIndex === -1)
486
- p.lastStepIndex = u;
481
+ })), t.on(i, (p, u) => u);
482
+ function d(p, u) {
483
+ const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
484
+ for (let l = p.length - 1; l >= 0; l--) {
485
+ const m = p[l], h = m?.node;
486
+ if (!(!h || !oe(h)) && !(u && m.experienceId !== u))
487
+ if (g.lastStepIndex === -1)
488
+ g.lastStepIndex = l;
487
489
  else {
488
- p.secondLastStepIndex = u;
490
+ g.secondLastStepIndex = l;
489
491
  break;
490
492
  }
491
493
  }
492
- return p;
494
+ return g;
493
495
  }
494
- return t.on(s, (a, n) => {
495
- const { secondLastStepIndex: p } = l(a.entries, n.experienceId), u = p !== -1 ? a.entries.slice(0, p + 1) : a.entries;
496
+ return t.on(s, (p, u) => {
497
+ const { secondLastStepIndex: g } = d(p.entries, u.experienceId), l = g !== -1 ? p.entries.slice(0, g + 1) : p.entries;
496
498
  return {
497
- ...a,
498
- entries: u
499
+ ...p,
500
+ entries: l
499
501
  };
500
502
  }), {
501
503
  push: e,
502
504
  replace: r,
503
505
  back: s,
504
506
  restore: i,
505
- entriesStore: t.map((a) => a.entries)
507
+ entriesStore: t.map((p) => p.entries)
506
508
  };
507
509
  });
508
- function Ve() {
509
- return I(De);
510
+ function Te() {
511
+ return x(Ne);
510
512
  }
511
- let Ne = 0;
512
- const Te = (t) => {
513
- const e = T([]);
514
- return k({
513
+ let Le = 0;
514
+ const _e = (t) => {
515
+ const e = _([]);
516
+ return w({
515
517
  clock: t,
516
518
  source: e,
517
519
  fn: (r, s) => [
518
520
  ...r,
519
521
  {
520
- id: Ne++,
522
+ id: Le++,
521
523
  at: /* @__PURE__ */ new Date(),
522
524
  payload: s
523
525
  }
524
526
  ],
525
527
  target: e
526
528
  }), e;
527
- }, Le = x("field"), _e = b(() => {
528
- const t = Le.store({}), e = j(t, {
529
- register(n, p) {
529
+ }, U = F("field");
530
+ function He(t) {
531
+ return Array.isArray(t) && t.every(
532
+ (e) => typeof e == "object" && e !== null && "id" in e && "label" in e && "value" in e
533
+ );
534
+ }
535
+ function V(t, e) {
536
+ const r = e ?? {
537
+ status: "idle",
538
+ options: Array.isArray(t.options) ? t.options : null
539
+ };
540
+ return {
541
+ ...t,
542
+ ...r,
543
+ options: r.options ?? (Array.isArray(t.options) ? t.options : null)
544
+ };
545
+ }
546
+ const Ge = I(({ client: t }) => {
547
+ const e = U.store({}), r = j(e, {
548
+ register(n, o) {
530
549
  return {
531
550
  ...n,
532
- [p.field.id]: p.field
551
+ [o.field.id]: o.field
533
552
  };
534
553
  }
535
554
  });
536
- function r(n) {
537
- e.register({ field: n });
555
+ function s(n) {
556
+ r.register({ field: n });
538
557
  }
539
- function s(n, p) {
540
- const u = l(n).getState();
541
- if (!u)
558
+ function i(n, o) {
559
+ const a = e.getState()[n];
560
+ if (!a)
542
561
  return;
543
- const g = Object.assign({}, u, {
544
- ...p
562
+ const f = Object.assign({}, a, {
563
+ ...o
564
+ });
565
+ r.register({ field: { ...f } });
566
+ }
567
+ const d = U.store({}), p = A(
568
+ e,
569
+ d,
570
+ (n, o) => Object.values(n).map((a) => V(a, o[a.id]))
571
+ );
572
+ function u(n) {
573
+ return A(e, d, (o, a) => {
574
+ const f = o[n];
575
+ return f ? V(f, a[n]) : null;
576
+ });
577
+ }
578
+ function g(n) {
579
+ return A(e, d, (o, a) => {
580
+ const f = Object.values(o).find((v) => v.name === n);
581
+ return f ? V(f, a[f.id]) : null;
545
582
  });
546
- e.register({ field: { ...g } });
547
583
  }
548
- const i = t.map((n) => Object.values(n));
549
- function l(n) {
550
- return t.map((p) => p[n] || null);
584
+ const l = U.effect(
585
+ async ({
586
+ fieldId: n,
587
+ fieldOptions: o,
588
+ context: a
589
+ }) => {
590
+ if (t && !Array.isArray(o) && o !== null) {
591
+ const f = await E(t, o, a);
592
+ return He(f) ? { fieldId: n, options: f } : { fieldId: n, options: null };
593
+ }
594
+ return { fieldId: n, options: Array.isArray(o) ? o : null };
595
+ }
596
+ );
597
+ d.on(l, (n, { fieldId: o }) => {
598
+ const a = n[o];
599
+ return {
600
+ ...n,
601
+ [o]: {
602
+ status: "loading",
603
+ // Preserve stale options during re-fetch so the UI doesn't flash blank
604
+ options: a?.status === "resolved" ? a.options : null
605
+ }
606
+ };
607
+ }), d.on(l.doneData, (n, { fieldId: o, options: a }) => ({
608
+ ...n,
609
+ [o]: { status: "resolved", options: a }
610
+ })), d.on(l.fail, (n, { params: { fieldId: o } }) => ({
611
+ ...n,
612
+ [o]: { status: "error", options: null, error: "Failed to resolve field options" }
613
+ }));
614
+ const m = $();
615
+ d.on(m, (n, o) => ({
616
+ ...n,
617
+ [o]: { status: "waiting", options: null }
618
+ }));
619
+ const h = $();
620
+ t && w({
621
+ clock: h,
622
+ source: {
623
+ states: d,
624
+ fields: e
625
+ },
626
+ filter: ({ states: n }, { fieldId: o, force: a }) => {
627
+ if (a) return !0;
628
+ const f = n[o];
629
+ return !f || f.status === "idle";
630
+ },
631
+ fn: ({ fields: n }, { fieldId: o, context: a }) => {
632
+ const f = n[o] ?? null;
633
+ return {
634
+ fieldId: o,
635
+ fieldOptions: f?.options ?? null,
636
+ context: a
637
+ };
638
+ },
639
+ target: l
640
+ });
641
+ function y(n, o) {
642
+ h({ fieldId: n, force: o?.force, context: o?.context });
551
643
  }
552
- function a(n) {
553
- return t.map((p) => Object.values(p).find((u) => u.name === n) || null);
644
+ function c(n, o) {
645
+ for (const a of n)
646
+ h({ fieldId: a, force: o?.force, context: o?.context });
554
647
  }
555
648
  return {
556
- register: r,
557
- update: s,
558
- getById: l,
559
- listStore: i,
560
- getByName: a
649
+ register: s,
650
+ update: i,
651
+ getById: u,
652
+ listStore: p,
653
+ getByName: g,
654
+ resolve: y,
655
+ resolveAll: c,
656
+ setWaiting: m
561
657
  };
562
658
  });
563
- function He() {
564
- return I(_e);
659
+ function Je(t) {
660
+ return x(Ge, t ?? {});
565
661
  }
566
- const Ge = (t, e) => {
662
+ const qe = (t, e) => {
567
663
  e.register(t);
568
- }, Je = x("action"), qe = b(() => {
569
- const t = Je.store({}), e = j(t, {
570
- register(a, n) {
664
+ }, Ke = F("action"), We = I(({ client: t }) => {
665
+ const e = Ke.store({}), r = j(e, {
666
+ register(u, g) {
571
667
  return {
572
- ...a,
573
- [n.name]: {
574
- name: n.name,
575
- action: n.action
668
+ ...u,
669
+ [g.name]: {
670
+ name: g.name,
671
+ action: g.action
576
672
  }
577
673
  };
578
674
  }
579
675
  });
580
- function r(a, n) {
581
- e.register({ name: a, action: n });
676
+ function s(u, g) {
677
+ r.register({ name: u, action: g });
582
678
  }
583
- const s = t.map((a) => Object.values(a));
584
- function i(a) {
585
- return t.map((n) => n[a], { skipVoid: !1 });
679
+ const i = e.map((u) => Object.values(u));
680
+ function d(u) {
681
+ return e.map((g) => g[u], { skipVoid: !1 });
586
682
  }
587
- function l(a) {
588
- return t.map(
589
- (n) => {
590
- const p = n[a];
591
- return p ? p.action : void 0;
683
+ function p(u) {
684
+ return e.map(
685
+ (g) => {
686
+ const l = g[u];
687
+ return l ? l.action : void 0;
592
688
  },
593
689
  { skipVoid: !1 }
594
690
  );
595
691
  }
596
692
  return {
597
- register: r,
598
- getByName: i,
599
- listStore: s,
600
- getEvokableAction: l
693
+ register: s,
694
+ getByName: d,
695
+ listStore: i,
696
+ getEvokableAction: p
601
697
  };
602
698
  });
603
- function Ke() {
604
- return I(qe);
699
+ function Ye(t) {
700
+ return x(We, t);
605
701
  }
606
- const We = (t, e, r) => {
702
+ const Qe = (t, e, r) => {
607
703
  r.register(t, e);
608
704
  };
609
- function O(t) {
705
+ function N(t) {
610
706
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
611
707
  }
612
- function Ye(t) {
708
+ function Xe(t) {
613
709
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
614
710
  }
615
- function K(t) {
711
+ function Y(t) {
616
712
  try {
617
713
  return JSON.stringify(t), !0;
618
714
  } catch {
619
715
  return !1;
620
716
  }
621
717
  }
622
- const Qe = x("response"), Xe = b(({ client: t }) => {
623
- const e = Qe.store({}), r = V(), s = V(), i = j(e, {
624
- register(m, o) {
718
+ const Ze = F("response"), et = I(({ client: t }) => {
719
+ const e = Ze.store({}), r = $(), s = $(), i = j(e, {
720
+ register(y, c) {
625
721
  return {
626
- ...m,
627
- [o.fieldId]: o.response
722
+ ...y,
723
+ [c.fieldId]: c.response
628
724
  };
629
725
  },
630
- registerBatch(m, o) {
726
+ registerBatch(y, c) {
631
727
  return {
632
- ...m,
633
- ...o
728
+ ...y,
729
+ ...c
634
730
  };
635
731
  },
636
- clear(m, o) {
637
- const { [o]: c, ...f } = m;
638
- return f;
732
+ clear(y, c) {
733
+ const { [c]: n, ...o } = y;
734
+ return o;
639
735
  },
640
736
  clearAll() {
641
737
  return {};
642
738
  }
643
739
  });
644
- function l(m, o) {
645
- if (typeof m == "string") {
646
- if (o === void 0)
740
+ function d(y, c) {
741
+ if (typeof y == "string") {
742
+ if (c === void 0)
647
743
  throw new Error("Response is required when registering a single field");
648
- i.register({ fieldId: m, response: o });
744
+ i.register({ fieldId: y, response: c });
649
745
  } else
650
- i.registerBatch(m);
746
+ i.registerBatch(y);
651
747
  }
652
- async function a(m) {
653
- const o = [];
748
+ async function p(y) {
749
+ const c = [];
654
750
  return await Promise.allSettled(
655
- Object.entries(m).map(async ([c, f]) => {
656
- let d = f;
657
- const h = t.fields.getById(c).getState();
658
- if (!h) {
659
- o.push({
660
- fieldId: c,
661
- userMessage: `Field '${c}' not found`,
662
- systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
- value: d
751
+ // eslint-disable-next-line sonarjs/cognitive-complexity -- comprehensive validation logic; refactoring would harm readability
752
+ Object.entries(y).map(async ([n, o]) => {
753
+ let a = o;
754
+ const f = t.fields.getById(n).getState();
755
+ if (!f) {
756
+ c.push({
757
+ fieldId: n,
758
+ userMessage: `Field '${n}' not found`,
759
+ systemMessage: `No field with ID '${n}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
760
+ value: a
664
761
  });
665
762
  return;
666
763
  }
667
- if (h.multiple && (typeof d == "string" || typeof d == "number" || typeof d == "boolean") && (d = [d]), h.validation && !ue(h.validation) && !O(d)) {
668
- const y = await P(t, h.validation, {
669
- $input: d
764
+ if (f.multiple && (typeof a == "string" || typeof a == "number" || typeof a == "boolean") && (a = [a]), f.validation && !de(f.validation) && !N(a)) {
765
+ const v = { ...e.getState(), ...y }, S = await E(t, f.validation, {
766
+ $input: a,
767
+ responses: v
670
768
  });
671
- if (typeof y == "string") {
672
- o.push({
673
- fieldId: c,
674
- userMessage: y,
675
- systemMessage: `Field validation resulted in an error: ${y}.`,
676
- value: d
769
+ if (typeof S == "string") {
770
+ c.push({
771
+ fieldId: n,
772
+ userMessage: S,
773
+ systemMessage: `Field validation resulted in an error: ${S}.`,
774
+ value: a
677
775
  });
678
776
  return;
679
777
  }
680
- if (y === !1) {
681
- o.push({
682
- fieldId: c,
778
+ if (S === !1) {
779
+ c.push({
780
+ fieldId: n,
683
781
  userMessage: "This field is invalid",
684
782
  systemMessage: "Field validation resulted in an unspecified error.",
685
- value: d
783
+ value: a
686
784
  });
687
785
  return;
688
786
  }
689
787
  }
690
- if (h.required && O(d)) {
691
- o.push({
692
- fieldId: c,
788
+ if (f.required && N(a)) {
789
+ c.push({
790
+ fieldId: n,
693
791
  userMessage: "This field is required",
694
792
  systemMessage: "Field is required.",
695
- value: d
793
+ value: a
696
794
  });
697
795
  return;
698
796
  }
699
- if (!h.multiple && Array.isArray(d) && d.length > 1) {
700
- o.push({
701
- fieldId: c,
797
+ if (!f.multiple && Array.isArray(a) && a.length > 1) {
798
+ c.push({
799
+ fieldId: n,
702
800
  userMessage: "This field expects a single response",
703
801
  systemMessage: "Field expects a single response.",
704
- value: d
802
+ value: a
705
803
  });
706
804
  return;
707
805
  }
708
- if (h.type === "object" && !O(d))
709
- if (h.multiple) {
710
- if (!Array.isArray(d)) {
711
- o.push({
712
- fieldId: c,
806
+ if (f.type === "object" && !N(a))
807
+ if (f.multiple) {
808
+ if (!Array.isArray(a)) {
809
+ c.push({
810
+ fieldId: n,
713
811
  userMessage: "This field expects multiple values",
714
812
  systemMessage: "Field expects an array of objects.",
715
- value: d
813
+ value: a
716
814
  });
717
815
  return;
718
816
  }
719
- for (const y of d) {
720
- if (typeof y != "object" || y === null) {
721
- o.push({
722
- fieldId: c,
817
+ for (const v of a) {
818
+ if (typeof v != "object" || v === null) {
819
+ c.push({
820
+ fieldId: n,
723
821
  userMessage: "This field expects object values",
724
822
  systemMessage: "Field expects an array of objects, but received non-object value.",
725
- value: d
823
+ value: a
726
824
  });
727
825
  return;
728
826
  }
729
- if (!K(y)) {
730
- o.push({
731
- fieldId: c,
827
+ if (!Y(v)) {
828
+ c.push({
829
+ fieldId: n,
732
830
  userMessage: "This field contains non-serializable data",
733
831
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
734
- value: d
832
+ value: a
735
833
  });
736
834
  return;
737
835
  }
738
836
  }
739
837
  } else {
740
- if (Array.isArray(d)) {
741
- o.push({
742
- fieldId: c,
838
+ if (Array.isArray(a)) {
839
+ c.push({
840
+ fieldId: n,
743
841
  userMessage: "This field expects a single value",
744
842
  systemMessage: "Field expects a single object, not an array.",
745
- value: d
843
+ value: a
746
844
  });
747
845
  return;
748
846
  }
749
- if (typeof d != "object" || d === null) {
750
- o.push({
751
- fieldId: c,
847
+ if (typeof a != "object" || a === null) {
848
+ c.push({
849
+ fieldId: n,
752
850
  userMessage: "This field expects an object value",
753
851
  systemMessage: "Field expects an object value.",
754
- value: d
852
+ value: a
755
853
  });
756
854
  return;
757
855
  }
758
- if (!K(d)) {
759
- o.push({
760
- fieldId: c,
856
+ if (!Y(a)) {
857
+ c.push({
858
+ fieldId: n,
761
859
  userMessage: "This field contains non-serializable data",
762
860
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
763
- value: d
861
+ value: a
764
862
  });
765
863
  return;
766
864
  }
767
865
  }
768
- if (Array.isArray(h.options) && h.options.length > 0) {
769
- const y = Array.isArray(d) ? d : [d];
770
- if (h.type === "object") {
771
- const F = h.options.map((v) => JSON.stringify(v.value));
772
- y.every((v) => F.includes(JSON.stringify(v))) || o.push({
773
- fieldId: c,
866
+ if (Array.isArray(f.options) && f.options.length > 0) {
867
+ const v = Array.isArray(a) ? a : [a];
868
+ if (f.type === "object") {
869
+ const S = f.options.map((k) => JSON.stringify(k.value));
870
+ v.every((k) => S.includes(JSON.stringify(k))) || c.push({
871
+ fieldId: n,
774
872
  userMessage: "This field expects a valid option",
775
873
  systemMessage: "Field expects a valid option from the defined choices.",
776
- value: d
874
+ value: a
777
875
  });
778
876
  } else {
779
- const F = h.options.map((v) => v.value);
780
- y.every((v) => !Ye(v) || v === null ? !1 : F.includes(v)) || o.push({
781
- fieldId: c,
877
+ const S = f.options.map((k) => k.value);
878
+ v.every((k) => !Xe(k) || k === null ? !1 : S.includes(k)) || c.push({
879
+ fieldId: n,
782
880
  userMessage: "This field expects a valid option",
783
- systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
784
- value: d
881
+ systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
882
+ value: a
785
883
  });
786
884
  }
787
885
  }
788
886
  })
789
- ), { responsesToCommit: m, validationErrors: o };
887
+ ), { responsesToCommit: y, validationErrors: c };
790
888
  }
791
- async function n(m) {
792
- const { responsesToCommit: o, validationErrors: c } = await a(m);
793
- return c.length ? { errors: c } : (i.registerBatch(o), { errors: [] });
889
+ async function u(y) {
890
+ const { responsesToCommit: c, validationErrors: n } = await p(y);
891
+ return n.length ? { errors: n } : (i.registerBatch(c), { errors: [] });
794
892
  }
795
- const p = e.map((m) => m), u = e.map((m) => Object.keys(m).map((c) => ({
796
- fieldId: c,
797
- value: m[c]
893
+ const g = e.map((y) => y), l = e.map((y) => Object.keys(y).map((n) => ({
894
+ fieldId: n,
895
+ value: y[n]
798
896
  })));
799
- function g(m) {
800
- const o = t.fields.getById(m), c = e.map((f) => f[m] || null);
801
- return D({ f: o, r: c }, ({ f, r: d }) => d || (f?.defaultValue ? f.defaultValue : null));
897
+ function m(y) {
898
+ const c = t.fields.getById(y), n = e.map((o) => o[y] || null);
899
+ return A({ f: c, r: n }, ({ f: o, r: a }) => a || (o?.defaultValue ? o.defaultValue : null));
802
900
  }
803
- function S(m) {
804
- const o = t.fields.getByName(m);
805
- return D({ f: o, s: e }, ({ f: c, s: f }) => {
806
- const d = c && f[c.id] || null;
807
- return d || (c?.defaultValue ? c.defaultValue : null);
901
+ function h(y) {
902
+ const c = t.fields.getByName(y);
903
+ return A({ f: c, s: e }, ({ f: n, s: o }) => {
904
+ const a = n && o[n.id] || null;
905
+ return a || (n?.defaultValue ? n.defaultValue : null);
808
906
  });
809
907
  }
810
- return k({
908
+ return w({
811
909
  clock: r,
812
910
  target: i.clearAll
813
- }), k({
911
+ }), w({
814
912
  clock: s,
815
913
  target: i.clear
816
914
  }), {
817
- register: l,
915
+ register: d,
818
916
  clearAll: r,
819
917
  clear: s,
820
- commit: n,
821
- getResponsesToCommit: a,
822
- listStore: u,
823
- getAllStore: p,
824
- getByFieldId: g,
825
- getByFieldName: S
918
+ commit: u,
919
+ getResponsesToCommit: p,
920
+ listStore: l,
921
+ getAllStore: g,
922
+ getByFieldId: m,
923
+ getByFieldName: h
826
924
  };
827
925
  });
828
- function Ze(t) {
829
- return I(Xe, t);
926
+ function tt(t) {
927
+ return x(et, t);
830
928
  }
831
- const et = () => "0.0.1-dev.1772168509010";
832
- function tt() {
833
- if (L()) {
929
+ const rt = () => "0.0.1-dev.1772412203098";
930
+ function nt() {
931
+ if (H()) {
834
932
  const t = [
835
933
  document.currentScript,
836
934
  document.getElementById("picked_script"),
@@ -844,34 +942,34 @@ function tt() {
844
942
  }
845
943
  return "https://api.picked.app";
846
944
  }
847
- function rt() {
848
- if (!_())
945
+ function st() {
946
+ if (!G())
849
947
  return {};
850
948
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
851
949
  for (const [i] of t.entries())
852
950
  i.startsWith("picked-") && r.add(i);
853
951
  for (const i of r) {
854
- const l = i.replace("picked-", "");
855
- e[l] = t.getAll(i);
952
+ const d = i.replace("picked-", "");
953
+ e[d] = t.getAll(i);
856
954
  }
857
- const s = A("s");
955
+ const s = R("s");
858
956
  if (r.size > 0)
859
- M.set(s, e);
957
+ D.set(s, e);
860
958
  else {
861
- const i = M.get(s);
959
+ const i = D.get(s);
862
960
  if (i)
863
961
  return i.json() || {};
864
962
  }
865
963
  return e;
866
964
  }
867
- function st() {
868
- if (le())
965
+ function it() {
966
+ if (fe())
869
967
  return crypto.randomUUID();
870
968
  const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
871
969
  return `${t}-${e}-${r}-${s}`;
872
970
  }
873
- const nt = A("session", "global"), it = () => {
874
- const t = C.get(nt);
971
+ const ot = R("session", "global"), at = () => {
972
+ const t = O.get(ot);
875
973
  let e;
876
974
  t.isSet() && (e = t.json());
877
975
  const r = (i) => t.set({
@@ -879,35 +977,35 @@ const nt = A("session", "global"), it = () => {
879
977
  isUser: i.isUser,
880
978
  identifiers: i.identifiers
881
979
  }), s = {
882
- id: e?.id ?? st(),
980
+ id: e?.id ?? it(),
883
981
  isUser: e?.isUser ?? void 0,
884
982
  identifiers: e?.identifiers ?? void 0,
885
983
  setIsUser(i) {
886
984
  this.isUser = i, r(this);
887
985
  },
888
- setIdentifier(i, l) {
889
- this.identifiers = { ...this.identifiers, [i]: l }, r(this);
986
+ setIdentifier(i, d) {
987
+ this.identifiers = { ...this.identifiers, [i]: d }, r(this);
890
988
  },
891
989
  removeIdentifier(i) {
892
990
  this.identifiers && (this.identifiers = Object.fromEntries(
893
- Object.entries(this.identifiers).filter(([l]) => l !== i)
991
+ Object.entries(this.identifiers).filter(([d]) => d !== i)
894
992
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
895
993
  }
896
994
  };
897
995
  return r(s), s;
898
- }, ot = () => de() ? it() : null;
899
- function at() {
900
- if (_())
996
+ }, ct = () => pe() ? at() : null;
997
+ function ut() {
998
+ if (G())
901
999
  return globalThis.window.pickedConfig;
902
1000
  }
903
- function ct() {
904
- if (!_())
1001
+ function lt() {
1002
+ if (!G())
905
1003
  return;
906
- const t = at(), e = t?.organizationId, r = t?.projectId;
1004
+ const t = ut(), e = t?.organizationId, r = t?.projectId;
907
1005
  return e && r ? { organizationId: e, projectId: r } : void 0;
908
1006
  }
909
- function ut() {
910
- if (!L())
1007
+ function dt() {
1008
+ if (!H())
911
1009
  return;
912
1010
  const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
913
1011
  document.getElementById("cvly");
@@ -916,14 +1014,14 @@ function ut() {
916
1014
  const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
917
1015
  return e && r ? { organizationId: e, projectId: r } : void 0;
918
1016
  }
919
- function dt(t) {
1017
+ function pt(t) {
920
1018
  const { organizationId: e, projectId: r } = t;
921
1019
  if (e && r)
922
1020
  return { organizationId: e, projectId: r };
923
- const s = ct();
1021
+ const s = lt();
924
1022
  if (s)
925
1023
  return s;
926
- const i = ut();
1024
+ const i = dt();
927
1025
  if (i)
928
1026
  return i;
929
1027
  throw new Error(
@@ -933,13 +1031,13 @@ function dt(t) {
933
1031
  (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
934
1032
  );
935
1033
  }
936
- function z(t) {
1034
+ function M(t) {
937
1035
  return t == null || t === "" || Number.isNaN(t);
938
1036
  }
939
- const lt = {
940
- default: (t, e) => z(t) ? String(e ?? "") : String(t),
941
- append: (t, e) => e && !z(t) ? `${t} ${e}` : t,
942
- prepend: (t, e) => e && !z(t) ? `${e} ${t}` : t,
1037
+ const ft = {
1038
+ default: (t, e) => M(t) ? String(e ?? "") : String(t),
1039
+ append: (t, e) => e && !M(t) ? `${t} ${e}` : t,
1040
+ prepend: (t, e) => e && !M(t) ? `${e} ${t}` : t,
943
1041
  upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
944
1042
  lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
945
1043
  capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
@@ -956,28 +1054,28 @@ const lt = {
956
1054
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
957
1055
  }
958
1056
  };
959
- function pt(t) {
1057
+ function gt(t) {
960
1058
  return typeof t == "object" && t !== null;
961
1059
  }
962
- function ft(t, e) {
1060
+ function mt(t, e) {
963
1061
  let r = e;
964
1062
  for (const s of t.split("."))
965
- if (pt(r) && s in r)
1063
+ if (gt(r) && s in r)
966
1064
  r = r[s];
967
1065
  else
968
1066
  return;
969
1067
  return typeof r == "function" ? r() : r;
970
1068
  }
971
- function gt(t, e) {
972
- const r = t.split("|").map((l) => l.trim()), s = r.shift() ?? "";
973
- let i = ft(s, e);
974
- for (const l of r) {
975
- const [a, ...n] = l.split(":"), p = a?.trim() ?? "", u = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[p];
976
- g && (i = g(i, u));
1069
+ function yt(t, e) {
1070
+ const r = t.split("|").map((d) => d.trim()), s = r.shift() ?? "";
1071
+ let i = mt(s, e);
1072
+ for (const d of r) {
1073
+ const [p, ...u] = d.split(":"), g = p?.trim() ?? "", l = u.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), m = ft[g];
1074
+ m && (i = m(i, l));
977
1075
  }
978
- return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
1076
+ return M(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
979
1077
  }
980
- function mt(t, e) {
1078
+ function ht(t, e) {
981
1079
  let r = "", s = 0;
982
1080
  for (; s < t.length; )
983
1081
  if (t[s] === "{" && t[s + 1] === "{") {
@@ -990,19 +1088,19 @@ function mt(t, e) {
990
1088
  }
991
1089
  i += t[s++];
992
1090
  }
993
- r += gt(i.trim(), e);
1091
+ r += yt(i.trim(), e);
994
1092
  } else
995
1093
  r += t[s++];
996
1094
  return r;
997
1095
  }
998
- class ht {
999
- static logger = w;
1096
+ class vt {
1097
+ static logger = b;
1000
1098
  options;
1001
1099
  isReady = !1;
1002
1100
  project;
1003
1101
  plugins = {};
1004
1102
  pluginStartHooks = [];
1005
- eventBus = V();
1103
+ eventBus = $();
1006
1104
  events;
1007
1105
  organizationId;
1008
1106
  projectId;
@@ -1012,25 +1110,25 @@ class ht {
1012
1110
  session;
1013
1111
  precondition;
1014
1112
  condition;
1015
- searchParams = rt();
1016
- history = Ve();
1017
- components = Ie({ client: this });
1018
- experienceInstances = ie({ client: this });
1019
- experiences = he({ client: this });
1020
- frameworks = je({ client: this });
1021
- predicates = ze({ client: this });
1022
- features = Oe({ client: this });
1023
- responses = Ze({ client: this });
1024
- fields = He();
1025
- actions = Ke();
1113
+ searchParams = st();
1114
+ history = Te();
1115
+ components = Fe({ client: this });
1116
+ experienceInstances = ae({ client: this });
1117
+ experiences = ve({ client: this });
1118
+ frameworks = Ee({ client: this });
1119
+ predicates = Me({ client: this });
1120
+ features = Ue({ client: this });
1121
+ responses = tt({ client: this });
1122
+ fields = Je({ client: this });
1123
+ actions = Ye({ client: this });
1026
1124
  constructor(e) {
1027
- w("info", "Picked client initializing."), this.events = Te(this.eventBus);
1028
- const { organizationId: r, projectId: s } = dt(e);
1029
- this.organizationId = r, this.projectId = s, 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 = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: et() }), w("info", "Picked client initialized.");
1125
+ b("info", "Picked client initializing."), this.events = _e(this.eventBus);
1126
+ const { organizationId: r, projectId: s } = pt(e);
1127
+ this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || nt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ct(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: rt() }), b("info", "Picked client initialized.");
1030
1128
  }
1031
1129
  start = () => {
1032
- $e(this), (async () => {
1033
- if (!L())
1130
+ Be(this), (async () => {
1131
+ if (!H())
1034
1132
  return;
1035
1133
  await this.runPluginStartHooks();
1036
1134
  const r = await this.evaluateGate(this.precondition);
@@ -1038,42 +1136,42 @@ class ht {
1038
1136
  r && (s = await this.evaluateGate(this.condition));
1039
1137
  const i = r && s === !0;
1040
1138
  if (typeof s == "boolean" && this.session) {
1041
- const l = s;
1042
- this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
1139
+ const d = s;
1140
+ this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
1043
1141
  }
1044
- if (this.eventBus({ type: "initialize" }), i && H(this), await oe(), i && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1045
- const { id: l, isUser: a, identifiers: n } = this.session;
1046
- this.eventBus({ type: "session", id: l, isUser: a, identifiers: n });
1142
+ if (this.eventBus({ type: "initialize" }), i && J(this), await ce(), i && J(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1143
+ const { id: d, isUser: p, identifiers: u } = this.session;
1144
+ this.eventBus({ type: "session", id: d, isUser: p, identifiers: u });
1047
1145
  }
1048
1146
  })();
1049
1147
  };
1050
1148
  registerFramework = (e) => {
1051
- Ee(e, this.frameworks);
1149
+ Pe(e, this.frameworks);
1052
1150
  };
1053
1151
  registerComponent = (e, r) => {
1054
- G(e, r, this.components);
1152
+ q(e, r, this.components);
1055
1153
  };
1056
1154
  registerPlugin = (e) => {
1057
- Se(this, e, this.plugins);
1155
+ ke(this, e, this.plugins);
1058
1156
  const r = this.plugins[e.name];
1059
1157
  r?.onStart && this.pluginStartHooks.push(r.onStart);
1060
1158
  };
1061
1159
  registerFeature = (e, r) => {
1062
- Ue(e, r, this.features);
1160
+ Ve(e, r, this.features);
1063
1161
  };
1064
1162
  registerPredicate = (e, r) => {
1065
- Ce(e, r, this.predicates);
1163
+ Oe(e, r, this.predicates);
1066
1164
  };
1067
1165
  registerField = (e) => {
1068
- Ge(e, this.fields);
1166
+ qe(e, this.fields);
1069
1167
  };
1070
1168
  registerAction = (e, r) => {
1071
- We(e, r, this.actions);
1169
+ Qe(e, r, this.actions);
1072
1170
  };
1073
1171
  registerExperience = (e) => {
1074
- e.component && G(`experience:${e.id}`, e.component, this.components), ye(e, this.experiences);
1172
+ e.component && q(`experience:${e.id}`, e.component, this.components), Se(e, this.experiences);
1075
1173
  };
1076
- getStateSnapshot = () => X(this);
1174
+ getStateSnapshot = () => ee(this);
1077
1175
  /** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
1078
1176
  launchExperienceById = async (e, r) => {
1079
1177
  this.experiences.launch({ id: e, options: r });
@@ -1087,7 +1185,7 @@ class ht {
1087
1185
  await e();
1088
1186
  }
1089
1187
  async evaluateGate(e) {
1090
- return e === void 0 ? !0 : typeof e == "boolean" ? e : await P(this, e) === !0;
1188
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await E(this, e) === !0;
1091
1189
  }
1092
1190
  setupPlugins() {
1093
1191
  this.options.plugins?.forEach((e) => {
@@ -1115,13 +1213,13 @@ class ht {
1115
1213
  const [s, i] = r.split(":");
1116
1214
  if (!s || !i)
1117
1215
  return;
1118
- let l = i;
1119
- l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(s, {
1120
- key: `${l}`,
1216
+ let d = i;
1217
+ d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(s, {
1218
+ key: `${d}`,
1121
1219
  // use the assigned bucket value as the key
1122
1220
  name: s,
1123
1221
  // eslint-disable-next-line sonarjs/function-return-type
1124
- decide: () => l,
1222
+ decide: () => d,
1125
1223
  storage: "session"
1126
1224
  });
1127
1225
  } catch {
@@ -1132,7 +1230,7 @@ class ht {
1132
1230
  const e = this.options.predicates;
1133
1231
  e && Object.entries(e).forEach(([r, s]) => {
1134
1232
  if (typeof s != "function") {
1135
- w("warn", `Predicate "${r}" is not a function.`);
1233
+ b("warn", `Predicate "${r}" is not a function.`);
1136
1234
  return;
1137
1235
  }
1138
1236
  this.registerPredicate(r, s);
@@ -1142,7 +1240,7 @@ class ht {
1142
1240
  const e = this.options.actions;
1143
1241
  e && Object.entries(e).forEach(([r, s]) => {
1144
1242
  if (typeof s != "function") {
1145
- w("warn", `Action "${r}" is not a function.`);
1243
+ b("warn", `Action "${r}" is not a function.`);
1146
1244
  return;
1147
1245
  }
1148
1246
  this.registerAction(r, s);
@@ -1192,68 +1290,68 @@ class ht {
1192
1290
  * // => "Fruits: apple, banana, and cherry"
1193
1291
  */
1194
1292
  renderString = (e, r) => {
1195
- const s = this.responses.listStore.getState().reduce((i, l) => (i[l.fieldId] = l.value, i), {});
1196
- return mt(e, {
1293
+ const s = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
1294
+ return ht(e, {
1197
1295
  ...r,
1198
1296
  responses: s
1199
1297
  });
1200
1298
  };
1201
1299
  }
1202
- function Z(t) {
1203
- return t.options?.some((e) => "condition" in e) ?? !1;
1300
+ function te(t) {
1301
+ return Array.isArray(t.options) && t.options.some((e) => "condition" in e);
1204
1302
  }
1205
- function yt(t) {
1206
- return t.some((e) => e.condition || Z(e));
1303
+ function St(t) {
1304
+ return t.some((e) => e.condition || te(e));
1207
1305
  }
1208
- async function Et(t, e) {
1209
- return e.length === 0 || !yt(e) ? e : (await Promise.all(
1210
- e.map(async (s) => {
1211
- if (!(s.condition ? await P(t, s.condition) : !0))
1306
+ async function Pt(t, e, r) {
1307
+ return e.length === 0 || !St(e) ? e : (await Promise.all(
1308
+ e.map(async (i) => {
1309
+ if (!(i.condition ? await E(t, i.condition, r) : !0))
1212
1310
  return null;
1213
- if (!s.options || !Z(s))
1214
- return s;
1215
- const a = (await Promise.all(
1216
- s.options.map(async (p) => p.condition ? await P(t, p.condition) ? p : null : p)
1217
- )).filter((p) => p !== null);
1218
- return a.length === s.options.length ? s : a.length === 0 ? null : { ...s, options: a };
1311
+ if (!Array.isArray(i.options) || !te(i))
1312
+ return i;
1313
+ const u = (await Promise.all(
1314
+ i.options.map(async (l) => l.condition ? await E(t, l.condition, r) ? l : null : l)
1315
+ )).filter((l) => l !== null);
1316
+ return u.length === i.options.length ? i : u.length === 0 ? null : { ...i, options: u };
1219
1317
  })
1220
- )).filter((s) => s !== null);
1318
+ )).filter((i) => i !== null);
1221
1319
  }
1222
- function Pt(t) {
1320
+ function $t(t) {
1223
1321
  return {
1224
1322
  $$type: "lazy-component",
1225
1323
  load: t
1226
1324
  };
1227
1325
  }
1228
- function At(t) {
1326
+ function Rt(t) {
1229
1327
  return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
1230
1328
  }
1231
- const $t = (t) => {
1232
- const e = new ht(t);
1233
- return pe(e), e;
1329
+ const Bt = (t) => {
1330
+ const e = new vt(t);
1331
+ return ge(e), e;
1234
1332
  };
1235
1333
  export {
1236
- ht as Picked,
1237
- $t as createClient,
1238
- A as createStorageKey,
1239
- P as evaluateRuleLogic,
1240
- at as getPickedConfig,
1241
- Et as getStepFields,
1242
- At as isLazyLoader,
1243
- zt as isPickedRoot,
1244
- Pt as lazyComponent,
1245
- C as localStore,
1246
- M as sessionStore,
1247
- Mt as subscribe,
1248
- Ut as supportsCookies,
1249
- le as supportsCryptoRandomUUID,
1250
- L as supportsDocument,
1251
- Dt as supportsHistory,
1252
- Vt as supportsIntersectionObserver,
1253
- de as supportsLocalStorage,
1254
- Nt as supportsLocation,
1255
- Tt as supportsSessionStorage,
1256
- Lt as supportsShadowRoot,
1257
- _t as supportsWebComponents,
1258
- _ as supportsWindow
1334
+ vt as Picked,
1335
+ Bt as createClient,
1336
+ R as createStorageKey,
1337
+ E as evaluateRuleLogic,
1338
+ ut as getPickedConfig,
1339
+ Pt as getStepFields,
1340
+ Rt as isLazyLoader,
1341
+ Mt as isPickedRoot,
1342
+ $t as lazyComponent,
1343
+ O as localStore,
1344
+ D as sessionStore,
1345
+ Dt as subscribe,
1346
+ Vt as supportsCookies,
1347
+ fe as supportsCryptoRandomUUID,
1348
+ H as supportsDocument,
1349
+ Nt as supportsHistory,
1350
+ Tt as supportsIntersectionObserver,
1351
+ pe as supportsLocalStorage,
1352
+ Lt as supportsLocation,
1353
+ _t as supportsSessionStorage,
1354
+ Ht as supportsShadowRoot,
1355
+ Gt as supportsWebComponents,
1356
+ G as supportsWindow
1259
1357
  };