@picked/client 0.0.1-dev.1773371977114 → 0.0.1-dev.1773719715758

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