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

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 (88) hide show
  1. package/dist/{api-CLwLE-DW.js → api-B3x8PEp4.js} +1 -1
  2. package/dist/{api-Cn-rv5A5.cjs → api-Z3Hn2Kw-.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 +723 -662
  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/exports.d.ts +0 -1
  40. package/dist/types/exports.d.ts.map +1 -1
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/logic-engine.d.ts +2 -8
  44. package/dist/types/logic-engine.d.ts.map +1 -1
  45. package/dist/types/picked.d.ts +18 -14
  46. package/dist/types/picked.d.ts.map +1 -1
  47. package/dist/types/plugins/create-experience/create-experience.d.ts +26 -36
  48. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  49. package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -3
  50. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  51. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
  52. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  53. package/dist/types/plugins/history-browser-storage/plugin.d.ts +2 -1
  54. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  55. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
  56. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  57. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  58. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  59. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  60. package/dist/types/utils/dom.d.ts +0 -3
  61. package/dist/types/utils/dom.d.ts.map +1 -1
  62. package/dist/types/utils/events.d.ts +1 -1
  63. package/dist/types/utils/events.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 +10 -14
  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/get-step-fields.d.ts +0 -4
  86. package/dist/types/utils/get-step-fields.d.ts.map +0 -1
  87. package/dist/types/utils/to-kebab-case.d.ts +0 -9
  88. package/dist/types/utils/to-kebab-case.d.ts.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,236 +1,236 @@
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 R, sample as w, combine as E, createEvent as P } from "effector";
2
+ import { createFactory as I, invoke as x } from "@withease/factories";
3
+ import { g as Q, t as re, c as se, i as ne, e as D, a as ie, b as oe, d as ae } from "../experience-instance-DTyL1fNb.js";
4
+ import { f as zt } from "../experience-instance-DTyL1fNb.js";
5
+ import { l as b } from "../logger-C9a75KZn.js";
6
+ import { c as $, l as M, s as O } from "../storage-B2d81EOI.js";
7
+ import { a as Ct } from "../storage-B2d81EOI.js";
8
+ import { p as ce, g as ue } from "../api-B3x8PEp4.js";
9
+ import { g as de } from "../id-BW-g3y32.js";
10
+ import { i as le } 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 Ot, f as Dt, g as Ut, h as Vt, i as Nt, j as Tt, k as Lt } from "../supports-8YT4QKI7.js";
13
+ const X = F("experience"), me = 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), n = 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
+ }), a = 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,
43
- merge: s.merge
38
+ configStore: a,
39
+ treeStore: p,
40
+ fieldsStore: u,
41
+ componentStore: l,
42
+ actions: f,
43
+ merge: n.merge
44
44
  };
45
45
  }
46
46
  );
47
- function me(t) {
48
- return I(ge, t);
47
+ function he(t) {
48
+ return x(me, t);
49
49
  }
50
- const he = b(({ client: t }) => {
51
- const e = Q.store({}), r = j(e, {
52
- register(o, c) {
50
+ const ye = 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 n(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 = he({ 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 a = 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
- register: s,
99
+ register: n,
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: a
110
110
  };
111
111
  });
112
- function ye(t) {
113
- return I(he, t);
112
+ function ve(t) {
113
+ return x(ye, t);
114
114
  }
115
115
  const Se = (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: n } = e.configStore.getState(), a = Q(n, e.id);
119
+ a.forEach(
120
+ ({ elements: p }) => p.forEach((u) => re(u, e.id))
121
+ ), se(a, 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
- 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 });
133
+ const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
134
+ return Q(n, e.id).length < 1 || n.length === 0 ? !1 : r === void 0 ? !0 : ne(r) ? await D(t, r) === !0 : !0;
135
+ }, ke = (t, e, r) => {
136
+ const n = e.name, a = e.setup(t);
137
+ if (a) {
138
+ const l = r[n] ?? {};
139
+ r[n] = Object.freeze({ ...l, ...a });
140
140
  }
141
- }, ke = x("component"), we = b(
141
+ }, we = F("component"), be = I(
142
142
  ({ client: t, component: e, name: r }) => {
143
- const s = t.frameworks.getByName(e.frameworkName);
143
+ const n = t.frameworks.getByName(e.frameworkName);
144
144
  return {
145
145
  name: r,
146
146
  component: e,
147
- frameworkStore: s
147
+ frameworkStore: n
148
148
  };
149
149
  }
150
150
  );
151
- function be(t) {
152
- return I(we, t);
151
+ function Ie(t) {
152
+ return x(be, t);
153
153
  }
154
- const Ie = b(({ client: t }) => {
155
- const e = ke.store({}), r = j(e, {
156
- register(i, a) {
154
+ const xe = I(({ client: t }) => {
155
+ const e = we.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 n(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 = Ie({ 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 a = 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
- register: s,
177
- getByName: f,
178
- listStore: n
176
+ register: n,
177
+ getByName: l,
178
+ listStore: a
179
179
  };
180
180
  });
181
181
  function Fe(t) {
182
- return I(Ie, t);
182
+ return x(xe, 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
+ }, je = F("framework"), Ee = I(({ client: t }) => {
187
+ const e = je.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 n(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 a = 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
- register: s,
207
- getByName: f,
208
- listStore: n
206
+ register: n,
207
+ getByName: l,
208
+ listStore: a
209
209
  };
210
210
  });
211
- function Ee(t) {
212
- return I(je, t);
211
+ function Ae(t) {
212
+ return x(Ee, t);
213
213
  }
214
214
  const Pe = (t, e) => {
215
215
  e.register(t.name, t);
216
- }, Ae = 6e3, $e = $("last_ping", "global"), Be = async (t) => {
216
+ }, $e = 6e3, Be = $("last_ping", "global"), ze = async (t) => {
217
217
  try {
218
- const e = Date.now(), r = O.get($e);
219
- let s = 0;
220
- if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ae)
218
+ const e = Date.now(), r = M.get(Be);
219
+ let n = 0;
220
+ if (r.isSet() && (n = r.json() ?? 0), n && e - n < $e)
221
221
  return !0;
222
- const n = {
222
+ const a = {
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 ce(t.apiUrl, "ping", a, 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,686 @@ function Z(t) {
242
242
  };
243
243
  return Object.freeze(r);
244
244
  }
245
- const Re = x("predicate"), ze = b(({ client: t }) => {
245
+ const Re = F("predicate"), Ce = I(({ client: t }) => {
246
246
  const e = Re.store({}), r = j(e, {
247
- register(a, o) {
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 n(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 a = 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 = R(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
- register: s,
289
- getByName: f,
290
- listStore: n,
291
- getEvokablePredicate: i
288
+ register: n,
289
+ getByName: l,
290
+ listStore: a,
291
+ getEvokablePredicate: p
292
292
  };
293
293
  });
294
- function Ce(t) {
295
- return I(ze, t);
294
+ function Me(t) {
295
+ return x(Ce, t);
296
296
  }
297
297
  const Oe = (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"), De = I(({ client: t }) => {
300
+ const e = K.store({}), r = K.store([]), n = j(e, {
301
+ register(c, s) {
302
302
  return {
303
- ...d,
304
- [l.id]: l.feature
303
+ ...c,
304
+ [s.id]: s.feature
305
305
  };
306
306
  }
307
307
  });
308
- function n(d, l) {
309
- e.getState()[d] && w(
308
+ function a(c, s) {
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 o = {
314
+ id: c,
315
315
  feature: {
316
- ...l,
317
- id: d
316
+ ...s,
317
+ id: c
318
318
  }
319
319
  };
320
- s.register(
320
+ n.register(
321
321
  Object.freeze({
322
- id: d,
323
- feature: m
322
+ id: c,
323
+ feature: o
324
324
  })
325
325
  );
326
326
  }
327
- const f = z(
327
+ const l = R(
328
328
  async ({
329
- id: d,
330
- key: l,
331
- storage: u = "local"
329
+ id: c,
330
+ key: s,
331
+ storage: i = "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 o = $(`feature:${c}:${s}`, "global"), v = (i === "session" ? O : M).get(o).boolean();
334
+ return v === null ? null : { id: c, key: s, bucket: v, storage: i };
335
335
  }
336
- ), i = z((d) => {
337
- if (!d)
336
+ ), p = R((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 s = $(`feature:${c.id}:${c.key}`, "global");
340
+ (c.storage === "session" ? O : M).set(s, 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: s }, { id: i, decide: o, key: g }) => {
344
+ const v = s.find(
345
+ (z) => z.id === i && 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[i];
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 '${i}' not found`);
352
+ const B = u.get(`${i}:${g}`);
353
+ if (B !== void 0) {
354
+ const z = await B;
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 = o();
358
+ u.set(`${i}:${g}`, k);
359
+ const te = await k;
360
+ return { id: S.id, bucket: te, key: g, storage: S.feature.storage };
361
361
  }
362
362
  });
363
- k({
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 };
363
+ w({
364
+ clock: n.register,
365
+ fn: (c) => {
366
+ const { id: s, feature: i } = c;
367
+ return { id: s, key: i.feature.key, storage: i.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, s) => {
374
+ const { id: i, bucket: o, storage: g } = s, v = c[i]?.feature.key;
375
+ return v ? { key: v, id: i, bucket: o, 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: s
383
+ }) => Object.values(c).map((i) => {
384
+ const o = s.find(
385
+ (g) => g.id === i.id && g.key === i.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 o ? {
388
+ id: i.id,
389
+ name: i.feature.name,
390
+ key: i.feature.key,
391
+ getBucket: () => ({ id: i.id, bucket: o.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: i.id,
395
+ name: i.feature.name,
396
+ key: i.feature.key,
397
+ getBucket: async () => await f(i.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: s, key: i }) => !c.some(
406
+ (g) => g.id === s && g.key === i
407
407
  ),
408
- fn: (d, l) => l,
409
- target: t.eventBus.prepend((d) => ({
408
+ fn: (c, s) => s,
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, s) => !s || c.some(
417
+ (o) => o.id === s.id && o.key === s.key
418
+ ) ? c : [...c, s],
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((s) => s.find((i) => i.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((s) => s[c], { skipVoid: !1 });
426
426
  }
427
- function F(d) {
428
- const l = L(
427
+ function m(c) {
428
+ const s = _(
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
+ ), i = R(async () => {
433
+ const o = h(c).getState();
434
+ if (o)
435
+ return async () => (await o.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: (o) => o.some((g) => g.id === c),
440
+ target: i
441
+ }), w({
442
+ clock: i.doneData,
443
+ filter: (o) => o !== void 0,
444
+ target: s
445
+ }), i(), s;
446
446
  }
447
447
  return {
448
- register: n,
449
- getById: g,
448
+ register: a,
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
456
  function Ue(t) {
456
- return I(Me, t);
457
+ return x(De, t);
457
458
  }
458
- const De = (t, e, r) => {
459
+ const Ve = (t, e, r) => {
459
460
  r.register(t, e);
460
- }, P = x("history");
461
- function q(t, e) {
461
+ }, A = 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: de(`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 Ne = I(() => {
472
+ const t = A.store({ entries: [] }), e = A.event(), r = A.event(), n = A.event(), a = A.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(a, (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 || !ie(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(n, (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
- back: s,
504
- restore: n,
505
- entriesStore: t.map((i) => i.entries)
504
+ back: n,
505
+ restore: a,
506
+ entriesStore: t.map((p) => p.entries)
506
507
  };
507
508
  });
508
- function Ne() {
509
- return I(Ve);
509
+ function Te() {
510
+ return x(Ne);
510
511
  }
511
- let Te = 0;
512
- const Le = (t) => {
513
- const e = L([]);
514
- return k({
512
+ let Le = 0;
513
+ const _e = (t) => {
514
+ const e = _([]);
515
+ return w({
515
516
  clock: t,
516
517
  source: e,
517
- fn: (r, s) => [
518
+ fn: (r, n) => [
518
519
  ...r,
519
520
  {
520
- id: Te++,
521
+ id: Le++,
521
522
  at: /* @__PURE__ */ new Date(),
522
- payload: s
523
+ payload: n
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 He(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 = Array.isArray(t.options) ? t.options : null, n = e ?? { status: "idle", options: r };
536
+ return {
537
+ ...t,
538
+ ...n,
539
+ options: n.options ?? r
540
+ };
541
+ }
542
+ const Ge = I(({ client: t }) => {
543
+ const e = U.store({}), r = j(e, {
544
+ register(s, i) {
530
545
  return {
531
- ...o,
532
- [c.resolvedKey]: { ...c.field, key: c.resolvedKey }
546
+ ...s,
547
+ [i.field.id]: i.field
533
548
  };
549
+ },
550
+ updateById(s, i) {
551
+ const o = s[i.fieldId];
552
+ return o ? { ...s, [i.fieldId]: Object.assign({}, o, i.updates) } : s;
534
553
  }
535
554
  });
536
- function r(o) {
537
- e.register({ field: o, resolvedKey: o.key });
555
+ function n(s) {
556
+ r.register({ field: s });
538
557
  }
539
- function s(o, c) {
540
- const g = f(o).getState();
541
- if (!g)
542
- return;
543
- const y = Object.assign({}, g, {
544
- ...c
558
+ function a(s, i) {
559
+ r.updateById({ fieldId: s, updates: i });
560
+ }
561
+ const l = U.store({}), p = E(
562
+ e,
563
+ l,
564
+ (s, i) => Object.values(s).map((o) => V(o, i[o.id]))
565
+ );
566
+ function u(s) {
567
+ return E(e, l, (i, o) => {
568
+ const g = i[s];
569
+ return g ? V(g, o[s]) : null;
545
570
  });
546
- e.register({ field: { ...y }, resolvedKey: o });
547
571
  }
548
- const n = t.map((o) => Object.values(o));
549
- function f(o) {
550
- return t.map((c) => c[o] || null);
572
+ function f(s) {
573
+ return E(e, l, (i, o) => {
574
+ const g = Object.values(i).find((v) => v.name === s);
575
+ return g ? V(g, o[g.id]) : null;
576
+ });
551
577
  }
552
- function i(o) {
553
- return t.map((c) => Object.values(c).find((g) => g.id === o) || null);
578
+ const d = U.effect(
579
+ async ({
580
+ fieldId: s,
581
+ fieldOptions: i,
582
+ context: o
583
+ }) => {
584
+ if (t && !Array.isArray(i) && i !== null) {
585
+ const g = await D(t, i, o);
586
+ return He(g) ? { fieldId: s, options: g } : { fieldId: s, options: null };
587
+ }
588
+ return { fieldId: s, options: Array.isArray(i) ? i : null };
589
+ }
590
+ );
591
+ l.on(d, (s, { fieldId: i }) => {
592
+ const o = s[i];
593
+ return {
594
+ ...s,
595
+ [i]: {
596
+ status: "loading",
597
+ // Preserve stale options during re-fetch so the UI doesn't flash blank
598
+ options: o?.status === "resolved" ? o.options : null
599
+ }
600
+ };
601
+ }), l.on(d.doneData, (s, { fieldId: i, options: o }) => ({
602
+ ...s,
603
+ [i]: { status: "resolved", options: o }
604
+ })), l.on(d.fail, (s, { params: { fieldId: i } }) => ({
605
+ ...s,
606
+ [i]: { status: "error", options: null, error: "Failed to resolve field options" }
607
+ }));
608
+ const h = P();
609
+ l.on(h, (s, i) => ({
610
+ ...s,
611
+ [i]: { status: "waiting", options: null }
612
+ }));
613
+ const y = P();
614
+ t && w({
615
+ clock: y,
616
+ source: {
617
+ states: l,
618
+ fields: e
619
+ },
620
+ filter: ({ states: s }, { fieldId: i, force: o }) => {
621
+ if (o) return !0;
622
+ const g = s[i];
623
+ return !g || g.status === "idle";
624
+ },
625
+ fn: ({ fields: s }, { fieldId: i, context: o }) => {
626
+ const g = s[i] ?? null;
627
+ return {
628
+ fieldId: i,
629
+ fieldOptions: g?.options ?? null,
630
+ context: o
631
+ };
632
+ },
633
+ target: d
634
+ });
635
+ function m(s, i) {
636
+ y({ fieldId: s, force: i?.force, context: i?.context });
554
637
  }
555
- function a(o) {
556
- return t.map((c) => Object.values(c).find((g) => g.name === o) || null);
638
+ function c(s, i) {
639
+ for (const o of s)
640
+ y({ fieldId: o, force: i?.force, context: i?.context });
557
641
  }
558
642
  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
643
+ register: n,
644
+ update: a,
645
+ getById: u,
646
+ listStore: p,
647
+ getByName: f,
648
+ resolve: m,
649
+ resolveAll: c,
650
+ setWaiting: h
567
651
  };
568
652
  });
569
- function Ke() {
570
- return I(He);
653
+ function Je(t) {
654
+ return x(Ge, t ?? {});
571
655
  }
572
- const Ge = (t, e) => {
656
+ const qe = (t, e) => {
573
657
  e.register(t);
574
- }, Je = x("action"), qe = b(() => {
575
- const t = Je.store({}), e = j(t, {
576
- register(i, a) {
658
+ }, Ke = F("action"), We = I(({ client: t }) => {
659
+ const e = Ke.store({}), r = j(e, {
660
+ register(u, f) {
577
661
  return {
578
- ...i,
579
- [a.name]: {
580
- name: a.name,
581
- action: a.action
662
+ ...u,
663
+ [f.name]: {
664
+ name: f.name,
665
+ action: f.action
582
666
  }
583
667
  };
584
668
  }
585
669
  });
586
- function r(i, a) {
587
- e.register({ name: i, action: a });
670
+ function n(u, f) {
671
+ r.register({ name: u, action: f });
588
672
  }
589
- const s = t.map((i) => Object.values(i));
590
- function n(i) {
591
- return t.map((a) => a[i], { skipVoid: !1 });
673
+ const a = e.map((u) => Object.values(u));
674
+ function l(u) {
675
+ return e.map((f) => f[u], { skipVoid: !1 });
592
676
  }
593
- function f(i) {
594
- return t.map(
595
- (a) => {
596
- const o = a[i];
597
- return o ? o.action : void 0;
677
+ function p(u) {
678
+ return e.map(
679
+ (f) => {
680
+ const d = f[u];
681
+ return d ? d.action : void 0;
598
682
  },
599
683
  { skipVoid: !1 }
600
684
  );
601
685
  }
602
686
  return {
603
- register: r,
604
- getByName: n,
605
- listStore: s,
606
- getEvokableAction: f
687
+ register: n,
688
+ getByName: l,
689
+ listStore: a,
690
+ getEvokableAction: p
607
691
  };
608
692
  });
609
- function We() {
610
- return I(qe);
693
+ function Ye(t) {
694
+ return x(We, t);
611
695
  }
612
- const Ye = (t, e, r) => {
696
+ const Qe = (t, e, r) => {
613
697
  r.register(t, e);
614
698
  };
615
- function U(t) {
699
+ function N(t) {
616
700
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
617
701
  }
618
- function Qe(t) {
702
+ function Xe(t) {
619
703
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
620
704
  }
621
- function W(t) {
705
+ function Y(t) {
622
706
  try {
623
707
  return JSON.stringify(t), !0;
624
708
  } catch {
625
709
  return !1;
626
710
  }
627
711
  }
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) {
712
+ const Ze = F("response"), et = I(({ client: t }) => {
713
+ const e = Ze.store({}), r = P(), n = P(), a = j(e, {
714
+ register(m, c) {
631
715
  return {
632
- ...d,
633
- [l.fieldKey]: l.response
716
+ ...m,
717
+ [c.fieldId]: c.response
634
718
  };
635
719
  },
636
- registerBatch(d, l) {
720
+ registerBatch(m, c) {
637
721
  return {
638
- ...d,
639
- ...l
722
+ ...m,
723
+ ...c
640
724
  };
641
725
  },
642
- clear(d, l) {
643
- const { [l]: u, ...m } = d;
644
- return m;
726
+ clear(m, c) {
727
+ const { [c]: s, ...i } = m;
728
+ return i;
645
729
  },
646
730
  clearAll() {
647
731
  return {};
648
732
  }
649
733
  });
650
- function f(d, l) {
651
- if (typeof d == "string") {
652
- if (l === void 0)
734
+ function l(m, c) {
735
+ if (typeof m == "string") {
736
+ if (c === void 0)
653
737
  throw new Error("Response is required when registering a single field");
654
- n.register({ fieldKey: d, response: l });
738
+ a.register({ fieldId: m, response: c });
655
739
  } else
656
- n.registerBatch(d);
740
+ a.registerBatch(m);
657
741
  }
658
- async function i(d) {
659
- const l = [];
742
+ async function p(m) {
743
+ const c = [];
660
744
  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
745
+ // eslint-disable-next-line sonarjs/cognitive-complexity -- comprehensive validation logic; refactoring would harm readability
746
+ Object.entries(m).map(async ([s, i]) => {
747
+ let o = i;
748
+ const g = t.fields.getById(s).getState();
749
+ if (!g) {
750
+ c.push({
751
+ fieldId: s,
752
+ userMessage: `Field '${s}' not found`,
753
+ systemMessage: `No field with ID '${s}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
754
+ value: o
671
755
  });
672
756
  return;
673
757
  }
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
758
+ if (g.multiple && (typeof o == "string" || typeof o == "number" || typeof o == "boolean") && (o = [o]), g.validation && !le(g.validation) && !N(o)) {
759
+ const v = { ...e.getState(), ...m }, S = await D(t, g.validation, {
760
+ $input: o,
761
+ responses: v
677
762
  });
678
763
  if (typeof S == "string") {
679
- l.push({
680
- fieldId: u,
764
+ c.push({
765
+ fieldId: s,
681
766
  userMessage: S,
682
767
  systemMessage: `Field validation resulted in an error: ${S}.`,
683
- value: p
768
+ value: o
684
769
  });
685
770
  return;
686
771
  }
687
772
  if (S === !1) {
688
- l.push({
689
- fieldId: u,
773
+ c.push({
774
+ fieldId: s,
690
775
  userMessage: "This field is invalid",
691
776
  systemMessage: "Field validation resulted in an unspecified error.",
692
- value: p
777
+ value: o
693
778
  });
694
779
  return;
695
780
  }
696
781
  }
697
- if (h.required && U(p)) {
698
- l.push({
699
- fieldId: u,
782
+ if (g.required && N(o)) {
783
+ c.push({
784
+ fieldId: s,
700
785
  userMessage: "This field is required",
701
786
  systemMessage: "Field is required.",
702
- value: p
787
+ value: o
703
788
  });
704
789
  return;
705
790
  }
706
- if (!h.multiple && Array.isArray(p) && p.length > 1) {
707
- l.push({
708
- fieldId: u,
791
+ if (!g.multiple && Array.isArray(o) && o.length > 1) {
792
+ c.push({
793
+ fieldId: s,
709
794
  userMessage: "This field expects a single response",
710
795
  systemMessage: "Field expects a single response.",
711
- value: p
796
+ value: o
712
797
  });
713
798
  return;
714
799
  }
715
- if (h.type === "object" && !U(p))
716
- if (h.multiple) {
717
- if (!Array.isArray(p)) {
718
- l.push({
719
- fieldId: u,
800
+ if (g.type === "object" && !N(o))
801
+ if (g.multiple) {
802
+ if (!Array.isArray(o)) {
803
+ c.push({
804
+ fieldId: s,
720
805
  userMessage: "This field expects multiple values",
721
806
  systemMessage: "Field expects an array of objects.",
722
- value: p
807
+ value: o
723
808
  });
724
809
  return;
725
810
  }
726
- for (const S of p) {
727
- if (typeof S != "object" || S === null) {
728
- l.push({
729
- fieldId: u,
811
+ for (const v of o) {
812
+ if (typeof v != "object" || v === null) {
813
+ c.push({
814
+ fieldId: s,
730
815
  userMessage: "This field expects object values",
731
816
  systemMessage: "Field expects an array of objects, but received non-object value.",
732
- value: p
817
+ value: o
733
818
  });
734
819
  return;
735
820
  }
736
- if (!W(S)) {
737
- l.push({
738
- fieldId: u,
821
+ if (!Y(v)) {
822
+ c.push({
823
+ fieldId: s,
739
824
  userMessage: "This field contains non-serializable data",
740
825
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
741
- value: p
826
+ value: o
742
827
  });
743
828
  return;
744
829
  }
745
830
  }
746
831
  } else {
747
- if (Array.isArray(p)) {
748
- l.push({
749
- fieldId: u,
832
+ if (Array.isArray(o)) {
833
+ c.push({
834
+ fieldId: s,
750
835
  userMessage: "This field expects a single value",
751
836
  systemMessage: "Field expects a single object, not an array.",
752
- value: p
837
+ value: o
753
838
  });
754
839
  return;
755
840
  }
756
- if (typeof p != "object" || p === null) {
757
- l.push({
758
- fieldId: u,
841
+ if (typeof o != "object" || o === null) {
842
+ c.push({
843
+ fieldId: s,
759
844
  userMessage: "This field expects an object value",
760
845
  systemMessage: "Field expects an object value.",
761
- value: p
846
+ value: o
762
847
  });
763
848
  return;
764
849
  }
765
- if (!W(p)) {
766
- l.push({
767
- fieldId: u,
850
+ if (!Y(o)) {
851
+ c.push({
852
+ fieldId: s,
768
853
  userMessage: "This field contains non-serializable data",
769
854
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
770
- value: p
855
+ value: o
771
856
  });
772
857
  return;
773
858
  }
774
859
  }
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,
860
+ if (Array.isArray(g.options) && g.options.length > 0) {
861
+ const v = Array.isArray(o) ? o : [o];
862
+ if (g.type === "object") {
863
+ const S = g.options.map((k) => JSON.stringify(k.value));
864
+ v.every((k) => S.includes(JSON.stringify(k))) || c.push({
865
+ fieldId: s,
781
866
  userMessage: "This field expects a valid option",
782
867
  systemMessage: "Field expects a valid option from the defined choices.",
783
- value: p
868
+ value: o
784
869
  });
785
870
  } 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,
871
+ const S = g.options.map((k) => k.value);
872
+ v.every((k) => !Xe(k) || k === null ? !1 : S.includes(k)) || c.push({
873
+ fieldId: s,
789
874
  userMessage: "This field expects a valid option",
790
- systemMessage: `Field expects a valid option. Valid options are: ${E.join(", ")}`,
791
- value: p
875
+ systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
876
+ value: o
792
877
  });
793
878
  }
794
879
  }
795
880
  })
796
- ), { responsesToCommit: d, validationErrors: l };
881
+ ), { responsesToCommit: m, validationErrors: c };
797
882
  }
798
- async function a(d) {
799
- const { responsesToCommit: l, validationErrors: u } = await i(d);
800
- return u.length ? { errors: u } : (n.registerBatch(l), { errors: [] });
883
+ async function u(m) {
884
+ const { responsesToCommit: c, validationErrors: s } = await p(m);
885
+ return s.length ? { errors: s } : (a.registerBatch(c), { errors: [] });
801
886
  }
802
- const o = e.map((d) => d), c = e.map((d) => Object.keys(d).map((u) => ({
803
- fieldId: u,
804
- value: d[u]
887
+ const f = e.map((m) => m), d = e.map((m) => Object.keys(m).map((s) => ({
888
+ fieldId: s,
889
+ value: m[s]
805
890
  })));
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));
891
+ function h(m) {
892
+ const c = t.fields.getById(m), s = e.map((i) => i[m] || null);
893
+ return E({ f: c, r: s }, ({ f: i, r: o }) => o || (i?.defaultValue ? i.defaultValue : null));
809
894
  }
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);
895
+ function y(m) {
896
+ const c = t.fields.getByName(m);
897
+ return E({ f: c, s: e }, ({ f: s, s: i }) => {
898
+ const o = s && i[s.id] || null;
899
+ return o || (s?.defaultValue ? s.defaultValue : null);
816
900
  });
817
901
  }
818
- return k({
902
+ return w({
819
903
  clock: r,
820
- target: n.clearAll
821
- }), k({
822
- clock: s,
823
- target: n.clear
904
+ target: a.clearAll
905
+ }), w({
906
+ clock: n,
907
+ target: a.clear
824
908
  }), {
825
- register: f,
909
+ register: l,
826
910
  clearAll: r,
827
- 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
911
+ clear: n,
912
+ commit: u,
913
+ getResponsesToCommit: p,
914
+ listStore: d,
915
+ getAllStore: f,
916
+ getByFieldId: h,
917
+ getByFieldName: y
836
918
  };
837
919
  });
838
- function et(t) {
839
- return I(Ze, t);
920
+ function tt(t) {
921
+ return x(et, t);
840
922
  }
841
- function tt() {
842
- if (_()) {
923
+ function rt() {
924
+ if (H()) {
843
925
  const t = [
844
926
  document.currentScript,
845
927
  document.getElementById("picked_script"),
@@ -853,70 +935,70 @@ function tt() {
853
935
  }
854
936
  return "https://api.picked.app";
855
937
  }
856
- function rt() {
857
- if (!H())
938
+ function st() {
939
+ if (!G())
858
940
  return {};
859
941
  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);
942
+ for (const [a] of t.entries())
943
+ a.startsWith("picked-") && r.add(a);
944
+ for (const a of r) {
945
+ const l = a.replace("picked-", "");
946
+ e[l] = t.getAll(a);
865
947
  }
866
- const s = $("s");
948
+ const n = $("s");
867
949
  if (r.size > 0)
868
- M.set(s, e);
950
+ O.set(n, e);
869
951
  else {
870
- const n = M.get(s);
871
- if (n)
872
- return n.json() || {};
952
+ const a = O.get(n);
953
+ if (a)
954
+ return a.json() || {};
873
955
  }
874
956
  return e;
875
957
  }
876
- function st() {
877
- if (pe())
958
+ function nt() {
959
+ if (fe())
878
960
  return crypto.randomUUID();
879
- 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
- return `${t}-${e}-${r}-${s}`;
961
+ const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), n = Math.random().toString(36).substring(2, 15);
962
+ return `${t}-${e}-${r}-${n}`;
881
963
  }
882
- const nt = $("session", "global"), it = () => {
883
- const t = O.get(nt);
964
+ const it = $("session", "global"), ot = () => {
965
+ const t = M.get(it);
884
966
  let e;
885
967
  t.isSet() && (e = t.json());
886
- const r = (n) => t.set({
887
- id: n.id,
888
- isUser: n.isUser,
889
- identifiers: n.identifiers
890
- }), s = {
891
- id: e?.id ?? st(),
968
+ const r = (a) => t.set({
969
+ id: a.id,
970
+ isUser: a.isUser,
971
+ identifiers: a.identifiers
972
+ }), n = {
973
+ id: e?.id ?? nt(),
892
974
  isUser: e?.isUser ?? void 0,
893
975
  identifiers: e?.identifiers ?? void 0,
894
- setIsUser(n) {
895
- this.isUser = n, r(this);
976
+ setIsUser(a) {
977
+ this.isUser = a, r(this);
896
978
  },
897
- setIdentifier(n, f) {
898
- this.identifiers = { ...this.identifiers, [n]: f }, r(this);
979
+ setIdentifier(a, l) {
980
+ this.identifiers = { ...this.identifiers, [a]: l }, r(this);
899
981
  },
900
- removeIdentifier(n) {
982
+ removeIdentifier(a) {
901
983
  this.identifiers && (this.identifiers = Object.fromEntries(
902
- Object.entries(this.identifiers).filter(([f]) => f !== n)
984
+ Object.entries(this.identifiers).filter(([l]) => l !== a)
903
985
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
904
986
  }
905
987
  };
906
- return r(s), s;
907
- }, ot = () => le() ? it() : null;
908
- function at() {
909
- if (H())
988
+ return r(n), n;
989
+ }, at = () => pe() ? ot() : null;
990
+ function ct() {
991
+ if (G())
910
992
  return globalThis.window.pickedConfig;
911
993
  }
912
- function ct() {
913
- if (!H())
994
+ function ut() {
995
+ if (!G())
914
996
  return;
915
- const t = at(), e = t?.organizationId, r = t?.projectId;
997
+ const t = ct(), e = t?.organizationId, r = t?.projectId;
916
998
  return e && r ? { organizationId: e, projectId: r } : void 0;
917
999
  }
918
- function ut() {
919
- if (!_())
1000
+ function dt() {
1001
+ if (!H())
920
1002
  return;
921
1003
  const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
922
1004
  document.getElementById("cvly");
@@ -925,16 +1007,16 @@ function ut() {
925
1007
  const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
926
1008
  return e && r ? { organizationId: e, projectId: r } : void 0;
927
1009
  }
928
- function dt(t) {
1010
+ function lt(t) {
929
1011
  const { organizationId: e, projectId: r } = t;
930
1012
  if (e && r)
931
1013
  return { organizationId: e, projectId: r };
932
- const s = ct();
933
- if (s)
934
- return s;
935
1014
  const n = ut();
936
1015
  if (n)
937
1016
  return n;
1017
+ const a = dt();
1018
+ if (a)
1019
+ return a;
938
1020
  throw new Error(
939
1021
  `organizationId and projectId are required. You can provide them via one of:
940
1022
  (1) createClient({ organizationId, projectId }) options;
@@ -945,7 +1027,7 @@ function dt(t) {
945
1027
  function C(t) {
946
1028
  return t == null || t === "" || Number.isNaN(t);
947
1029
  }
948
- const lt = {
1030
+ const pt = {
949
1031
  default: (t, e) => C(t) ? String(e ?? "") : String(t),
950
1032
  append: (t, e) => e && !C(t) ? `${t} ${e}` : t,
951
1033
  prepend: (t, e) => e && !C(t) ? `${e} ${t}` : t,
@@ -959,59 +1041,59 @@ const lt = {
959
1041
  if (Array.isArray(t))
960
1042
  return e.format(t.map(String));
961
1043
  if (t instanceof Map) {
962
- const r = Array.from(t.entries()).map(([s, n]) => `${s}: ${n}`);
1044
+ const r = Array.from(t.entries()).map(([n, a]) => `${n}: ${a}`);
963
1045
  return e.format(r);
964
1046
  }
965
1047
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
966
1048
  }
967
1049
  };
968
- function pt(t) {
1050
+ function ft(t) {
969
1051
  return typeof t == "object" && t !== null;
970
1052
  }
971
- function ft(t, e) {
1053
+ function gt(t, e) {
972
1054
  let r = e;
973
- for (const s of t.split("."))
974
- if (pt(r) && s in r)
975
- r = r[s];
1055
+ for (const n of t.split("."))
1056
+ if (ft(r) && n in r)
1057
+ r = r[n];
976
1058
  else
977
1059
  return;
978
1060
  return typeof r == "function" ? r() : r;
979
1061
  }
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));
1062
+ function mt(t, e) {
1063
+ const r = t.split("|").map((l) => l.trim()), n = r.shift() ?? "";
1064
+ let a = gt(n, e);
1065
+ for (const l of r) {
1066
+ const [p, ...u] = l.split(":"), f = p?.trim() ?? "", d = u.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = pt[f];
1067
+ h && (a = h(a, d));
986
1068
  }
987
- return C(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
1069
+ return C(a) ? "" : typeof a == "object" ? JSON.stringify(a) : String(a);
988
1070
  }
989
- function mt(t, e) {
990
- let r = "", s = 0;
991
- for (; s < t.length; )
992
- if (t[s] === "{" && t[s + 1] === "{") {
993
- s += 2;
994
- let n = "";
995
- for (; s < t.length; ) {
996
- if (t[s] === "}" && t[s + 1] === "}") {
997
- s += 2;
1071
+ function ht(t, e) {
1072
+ let r = "", n = 0;
1073
+ for (; n < t.length; )
1074
+ if (t[n] === "{" && t[n + 1] === "{") {
1075
+ n += 2;
1076
+ let a = "";
1077
+ for (; n < t.length; ) {
1078
+ if (t[n] === "}" && t[n + 1] === "}") {
1079
+ n += 2;
998
1080
  break;
999
1081
  }
1000
- n += t[s++];
1082
+ a += t[n++];
1001
1083
  }
1002
- r += gt(n.trim(), e);
1084
+ r += mt(a.trim(), e);
1003
1085
  } else
1004
- r += t[s++];
1086
+ r += t[n++];
1005
1087
  return r;
1006
1088
  }
1007
- class ht {
1008
- static logger = w;
1089
+ class yt {
1090
+ static logger = b;
1009
1091
  options;
1010
1092
  isReady = !1;
1011
1093
  project;
1012
1094
  plugins = {};
1013
1095
  pluginStartHooks = [];
1014
- eventBus = N();
1096
+ eventBus = P();
1015
1097
  events;
1016
1098
  organizationId;
1017
1099
  projectId;
@@ -1022,39 +1104,39 @@ class ht {
1022
1104
  precondition;
1023
1105
  condition;
1024
1106
  preconditionPassed;
1025
- searchParams = rt();
1026
- history = Ne();
1107
+ searchParams = st();
1108
+ history = Te();
1027
1109
  components = Fe({ client: this });
1028
- experienceInstances = ie({ client: this });
1029
- experiences = ye({ client: this });
1030
- frameworks = Ee({ client: this });
1031
- predicates = Ce({ client: this });
1110
+ experienceInstances = oe({ client: this });
1111
+ experiences = ve({ client: this });
1112
+ frameworks = Ae({ client: this });
1113
+ predicates = Me({ client: this });
1032
1114
  features = Ue({ client: this });
1033
- responses = et({ client: this });
1034
- fields = Ke();
1035
- actions = We();
1115
+ responses = tt({ client: this });
1116
+ fields = Je({ client: this });
1117
+ actions = Ye({ client: this });
1036
1118
  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.");
1119
+ b("info", "Picked client initializing."), this.events = _e(this.eventBus);
1120
+ const { organizationId: r, projectId: n } = lt(e);
1121
+ this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || rt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ue() }), b("info", "Picked client initialized.");
1040
1122
  }
1041
1123
  start = () => {
1042
- Be(this), (async () => {
1043
- if (!_())
1124
+ ze(this), (async () => {
1125
+ if (!H())
1044
1126
  return;
1045
1127
  await this.runPluginStartHooks();
1046
1128
  const r = await this.evaluateGate(this.precondition);
1047
1129
  this.preconditionPassed = r;
1048
- let s;
1049
- r && (s = await this.evaluateGate(this.condition));
1050
- const n = r && s === !0;
1051
- if (typeof s == "boolean" && this.session) {
1052
- const f = s;
1053
- this.session.setIsUser(f), this.eventBus({ type: "user_decide", value: f });
1130
+ let n;
1131
+ r && (n = await this.evaluateGate(this.condition));
1132
+ const a = r && n === !0;
1133
+ if (typeof n == "boolean" && this.session) {
1134
+ const l = n;
1135
+ this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
1054
1136
  }
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 });
1137
+ if (this.eventBus({ type: "initialize" }), a && J(this), await ae(), a && J(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1138
+ const { id: l, isUser: p, identifiers: u } = this.session;
1139
+ this.eventBus({ type: "session", id: l, isUser: p, identifiers: u });
1058
1140
  }
1059
1141
  })();
1060
1142
  };
@@ -1062,29 +1144,29 @@ class ht {
1062
1144
  Pe(e, this.frameworks);
1063
1145
  };
1064
1146
  registerComponent = (e, r) => {
1065
- G(e, r, this.components);
1147
+ q(e, r, this.components);
1066
1148
  };
1067
1149
  registerPlugin = (e) => {
1068
- ve(this, e, this.plugins);
1150
+ ke(this, e, this.plugins);
1069
1151
  const r = this.plugins[e.name];
1070
1152
  r?.onStart && this.pluginStartHooks.push(r.onStart);
1071
1153
  };
1072
1154
  registerFeature = (e, r) => {
1073
- De(e, r, this.features);
1155
+ Ve(e, r, this.features);
1074
1156
  };
1075
1157
  registerPredicate = (e, r) => {
1076
1158
  Oe(e, r, this.predicates);
1077
1159
  };
1078
1160
  registerField = (e) => {
1079
- Ge(e, this.fields);
1161
+ qe(e, this.fields);
1080
1162
  };
1081
1163
  registerAction = (e, r) => {
1082
- Ye(e, r, this.actions);
1164
+ Qe(e, r, this.actions);
1083
1165
  };
1084
1166
  registerExperience = (e) => {
1085
- e.component && G(`experience:${e.id}`, e.component, this.components), Se(e, this.experiences);
1167
+ e.component && q(`experience:${e.id}`, e.component, this.components), Se(e, this.experiences);
1086
1168
  };
1087
- getStateSnapshot = () => Z(this);
1169
+ getStateSnapshot = () => ee(this);
1088
1170
  /** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
1089
1171
  launchExperienceById = async (e, r) => {
1090
1172
  this.experiences.launch({ id: e, options: r });
@@ -1098,19 +1180,19 @@ class ht {
1098
1180
  await e();
1099
1181
  }
1100
1182
  async evaluateGate(e) {
1101
- return e === void 0 ? !0 : typeof e == "boolean" ? e : await A(this, e) === !0;
1183
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : await D(this, e) === !0;
1102
1184
  }
1103
1185
  setupPlugins() {
1104
1186
  this.options.plugins?.forEach((e) => {
1105
1187
  if (Array.isArray(e)) {
1106
- e.forEach((s) => {
1107
- this.registerPlugin(s);
1188
+ e.forEach((n) => {
1189
+ this.registerPlugin(n);
1108
1190
  });
1109
1191
  return;
1110
1192
  }
1111
1193
  const r = typeof e == "function" ? e() : e;
1112
1194
  if (Array.isArray(r)) {
1113
- r.forEach((s) => this.registerPlugin(s));
1195
+ r.forEach((n) => this.registerPlugin(n));
1114
1196
  return;
1115
1197
  }
1116
1198
  this.registerPlugin(r);
@@ -1118,21 +1200,21 @@ class ht {
1118
1200
  }
1119
1201
  setupFeatures() {
1120
1202
  const e = this.options.features;
1121
- e && (Object.entries(e).forEach(([r, s]) => {
1122
- const n = typeof s == "function" ? s() : s;
1123
- this.registerFeature(r, n);
1203
+ e && (Object.entries(e).forEach(([r, n]) => {
1204
+ const a = typeof n == "function" ? n() : n;
1205
+ this.registerFeature(r, a);
1124
1206
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1125
1207
  try {
1126
- const [s, n] = r.split(":");
1127
- if (!s || !n)
1208
+ const [n, a] = r.split(":");
1209
+ if (!n || !a)
1128
1210
  return;
1129
- let f = n;
1130
- f === "true" && (f = !0), f === "false" && (f = !1), this.registerFeature(s, {
1131
- key: `${f}`,
1211
+ let l = a;
1212
+ l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(n, {
1213
+ key: `${l}`,
1132
1214
  // use the assigned bucket value as the key
1133
- name: s,
1215
+ name: n,
1134
1216
  // eslint-disable-next-line sonarjs/function-return-type
1135
- decide: () => f,
1217
+ decide: () => l,
1136
1218
  storage: "session"
1137
1219
  });
1138
1220
  } catch {
@@ -1141,28 +1223,28 @@ class ht {
1141
1223
  }
1142
1224
  setupPredicates() {
1143
1225
  const e = this.options.predicates;
1144
- e && Object.entries(e).forEach(([r, s]) => {
1145
- if (typeof s != "function") {
1146
- w("warn", `Predicate "${r}" is not a function.`);
1226
+ e && Object.entries(e).forEach(([r, n]) => {
1227
+ if (typeof n != "function") {
1228
+ b("warn", `Predicate "${r}" is not a function.`);
1147
1229
  return;
1148
1230
  }
1149
- this.registerPredicate(r, s);
1231
+ this.registerPredicate(r, n);
1150
1232
  });
1151
1233
  }
1152
1234
  setupActions() {
1153
1235
  const e = this.options.actions;
1154
- e && Object.entries(e).forEach(([r, s]) => {
1155
- if (typeof s != "function") {
1156
- w("warn", `Action "${r}" is not a function.`);
1236
+ e && Object.entries(e).forEach(([r, n]) => {
1237
+ if (typeof n != "function") {
1238
+ b("warn", `Action "${r}" is not a function.`);
1157
1239
  return;
1158
1240
  }
1159
- this.registerAction(r, s);
1241
+ this.registerAction(r, n);
1160
1242
  });
1161
1243
  }
1162
1244
  setupComponents() {
1163
1245
  const e = this.options.components;
1164
- e && Object.entries(e).forEach(([r, s]) => {
1165
- this.registerComponent(r, s);
1246
+ e && Object.entries(e).forEach(([r, n]) => {
1247
+ this.registerComponent(r, n);
1166
1248
  });
1167
1249
  }
1168
1250
  getPluginConfig = (e) => this.plugins[e] ?? {};
@@ -1209,34 +1291,14 @@ class ht {
1209
1291
  * // => "Fruits: apple, banana, and cherry"
1210
1292
  */
1211
1293
  renderString = (e, r) => {
1212
- const s = this.responses.listStore.getState().reduce((n, f) => (n[f.fieldId] = f.value, n), {});
1213
- return mt(e, {
1294
+ const n = this.responses.listStore.getState().reduce((a, l) => (a[l.fieldId] = l.value, a), {});
1295
+ return ht(e, {
1214
1296
  ...r,
1215
- responses: s
1297
+ responses: n
1216
1298
  });
1217
1299
  };
1218
1300
  }
1219
- function ee(t) {
1220
- return t.options?.some((e) => "condition" in e) ?? !1;
1221
- }
1222
- function yt(t) {
1223
- return t.some((e) => e.condition || ee(e));
1224
- }
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))
1229
- 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 };
1236
- })
1237
- )).filter((s) => s !== null);
1238
- }
1239
- function Pt(t) {
1301
+ function Et(t) {
1240
1302
  return {
1241
1303
  $$type: "lazy-component",
1242
1304
  load: t
@@ -1245,32 +1307,31 @@ function Pt(t) {
1245
1307
  function At(t) {
1246
1308
  return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
1247
1309
  }
1248
- const $t = (t) => {
1249
- const e = new ht(t);
1250
- return fe(e), e;
1310
+ const Pt = (t) => {
1311
+ const e = new yt(t);
1312
+ return ge(e), e;
1251
1313
  };
1252
1314
  export {
1253
- ht as Picked,
1254
- $t as createClient,
1315
+ yt as Picked,
1316
+ Pt as createClient,
1255
1317
  $ as createStorageKey,
1256
- A as evaluateRuleLogic,
1257
- at as getPickedConfig,
1258
- Et as getStepFields,
1318
+ D as evaluateRuleLogic,
1319
+ ct as getPickedConfig,
1259
1320
  At as isLazyLoader,
1260
1321
  zt as isPickedRoot,
1261
- Pt as lazyComponent,
1262
- O as localStore,
1263
- M as sessionStore,
1264
- Ot as subscribe,
1265
- Ut as supportsCookies,
1266
- pe as supportsCryptoRandomUUID,
1267
- _ as supportsDocument,
1322
+ Et as lazyComponent,
1323
+ M as localStore,
1324
+ O as sessionStore,
1325
+ Ct as subscribe,
1326
+ Ot as supportsCookies,
1327
+ fe as supportsCryptoRandomUUID,
1328
+ H as supportsDocument,
1268
1329
  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
1330
+ Ut as supportsIntersectionObserver,
1331
+ pe as supportsLocalStorage,
1332
+ Vt as supportsLocation,
1333
+ Nt as supportsSessionStorage,
1334
+ Tt as supportsShadowRoot,
1335
+ Lt as supportsWebComponents,
1336
+ G as supportsWindow
1276
1337
  };