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

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