@picked/client 0.0.48-next.1 → 0.0.49-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/api-DlWmrA8P.js +32 -0
  2. package/dist/api-sPUT21Vf.cjs +1 -0
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/esm/index.js +422 -415
  7. package/dist/esm/plugins/create-experience/index.js +54 -60
  8. package/dist/esm/plugins/dynamic-experiences/index.js +63 -41
  9. package/dist/types/client.d.ts +13 -0
  10. package/dist/types/client.d.ts.map +1 -1
  11. package/dist/types/entities/experience/experience.d.ts +24 -9
  12. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  13. package/dist/types/picked.d.ts +4 -2
  14. package/dist/types/picked.d.ts.map +1 -1
  15. package/dist/types/plugins/create-experience/create-experience.d.ts +0 -3
  16. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  17. package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -0
  18. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  19. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +2 -2
  20. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  21. package/dist/types/plugins/dynamic-experiences/types.d.ts +4 -0
  22. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  23. package/dist/types/utils/api.d.ts +1 -1
  24. package/dist/types/utils/api.d.ts.map +1 -1
  25. package/dist/types/utils/client-headers.d.ts +2 -0
  26. package/dist/types/utils/client-headers.d.ts.map +1 -0
  27. package/package.json +2 -2
  28. package/dist/api-CbXfbi_s.js +0 -19
  29. package/dist/api-DzSCgBQ2.cjs +0 -1
package/dist/esm/index.js CHANGED
@@ -1,124 +1,124 @@
1
- import { createDomain as F, createApi as j, attach as U, createStore as T, createEffect as R, sample as k, combine as D, createEvent as V } from "effector";
1
+ import { createDomain as x, createApi as j, attach as U, createStore as T, createEffect as R, sample as k, combine as D, createEvent as V } from "effector";
2
2
  import { createFactory as b, invoke as I } from "@withease/factories";
3
3
  import { g as W, t as te, c as re, i as se, e as P, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
4
4
  import { f as zt } from "../experience-instance-fvSEb72i.js";
5
5
  import { l as w } from "../logger-C9a75KZn.js";
6
- import { c as A, l as C, s as M } from "../storage-Co_LbKr_.js";
7
- import { a as Mt } from "../storage-Co_LbKr_.js";
8
- import { p as ae } from "../api-CbXfbi_s.js";
9
- import { g as ce } from "../id-BW-g3y32.js";
10
- import { i as ue } from "../object-JwZ58NOH.js";
11
- import { s as L, a as _, b as de, c as le, d as pe } from "../supports-8YT4QKI7.js";
6
+ import { c as A, l as C, s as O } 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-DlWmrA8P.js";
9
+ import { g as ue } from "../id-BW-g3y32.js";
10
+ import { i as de } from "../object-JwZ58NOH.js";
11
+ import { s as L, a as _, b as le, c as pe, d as fe } from "../supports-8YT4QKI7.js";
12
12
  import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from "../supports-8YT4QKI7.js";
13
- const Y = F("experience"), fe = b(
13
+ const Y = x("experience"), ge = b(
14
14
  ({ client: t, experience: e }) => {
15
15
  const r = Y.store(e), s = j(r, {
16
- merge(u, g) {
16
+ merge(d, g) {
17
17
  return {
18
- ...u,
18
+ ...d,
19
19
  ...g.experience
20
20
  };
21
21
  }
22
- }), i = r.map((u) => ({
23
- name: u.name,
24
- decisionLogic: u.condition ?? u.decide,
25
- targetSelectors: u.targets,
22
+ }), n = r.map((d) => ({
23
+ name: d.name,
24
+ decisionLogic: d.condition ?? d.decide,
25
+ targetSelectors: d.targets,
26
26
  initializeOpenLogic: e.initializeOpen
27
- })), l = t.components.listStore.map(
28
- (u) => u.find((g) => g.name === `experience:${e.id}`) || u.find((g) => g.name === "experience"),
27
+ })), p = t.components.listStore.map(
28
+ (d) => (e.componentName ? d.find((g) => g.name === e.componentName) : void 0) || d.find((g) => g.name === `experience:${e.id}`) || d.find((g) => g.name === "experience"),
29
29
  { skipVoid: !1 }
30
- ), a = r.map((u) => ({
31
- steps: u.steps,
32
- nodes: u.nodes,
33
- edges: u.edges,
34
- conditionals: u.conditionals
35
- })), n = r.map((u) => u.fields), p = e.actions ?? [];
30
+ ), a = r.map((d) => ({
31
+ steps: d.steps,
32
+ nodes: d.nodes,
33
+ edges: d.edges,
34
+ conditionals: d.conditionals
35
+ })), i = r.map((d) => d.fields), c = e.actions ?? [];
36
36
  return {
37
37
  id: e.id,
38
- configStore: i,
38
+ configStore: n,
39
39
  treeStore: a,
40
- fieldsStore: n,
41
- componentStore: l,
42
- actions: p,
40
+ fieldsStore: i,
41
+ componentStore: p,
42
+ actions: c,
43
43
  merge: s.merge
44
44
  };
45
45
  }
46
46
  );
47
- function ge(t) {
48
- return I(fe, t);
47
+ function me(t) {
48
+ return I(ge, t);
49
49
  }
50
- const me = b(({ client: t }) => {
50
+ const he = b(({ client: t }) => {
51
51
  const e = Y.store({}), r = j(e, {
52
- register(u, g) {
52
+ register(c, d) {
53
53
  return {
54
- ...u,
55
- [g.id]: g
54
+ ...c,
55
+ [d.id]: d
56
56
  };
57
57
  }
58
58
  });
59
- function s(u) {
60
- const g = e.getState()[u.id];
61
- if (g) {
62
- g.merge({ experience: u, strategy: "override" });
59
+ function s(c) {
60
+ const d = e.getState()[c.id];
61
+ if (d) {
62
+ d.merge({ experience: c, strategy: "override" });
63
63
  return;
64
64
  }
65
- const S = ge({ client: t, experience: u });
66
- r.register(S);
65
+ const g = me({ client: t, experience: c });
66
+ r.register(g);
67
67
  }
68
- const i = e.map((u) => Object.values(u));
69
- function l(u) {
70
- return e.map((g) => g[u], { skipVoid: !1 });
68
+ const n = e.map((c) => Object.values(c));
69
+ function p(c) {
70
+ return e.map((d) => d[c], { skipVoid: !1 });
71
71
  }
72
- const a = l, n = U({
72
+ const a = U({
73
73
  source: e,
74
- effect: async (u, { id: g, options: S }) => {
75
- const m = u[g];
76
- if (!m) {
77
- w("warn", `Experience with id '${g}' not found.`);
74
+ effect: async (c, { id: d, options: g }) => {
75
+ const S = c[d];
76
+ if (!S) {
77
+ w("warn", `Experience with id '${d}' not found.`);
78
78
  return;
79
79
  }
80
- if (S?.bypassCondition) {
81
- N(t, m, S);
80
+ if (g?.bypassCondition) {
81
+ N(t, S, g);
82
82
  return;
83
83
  }
84
- await Q(t, m) && N(t, m, S);
84
+ await Q(t, S) && N(t, S, g);
85
85
  }
86
- }), p = U({
86
+ }), i = U({
87
87
  source: t.experienceInstances.listStore,
88
- effect: (u, { id: g, options: S }) => {
89
- const m = u.filter((o) => o.experienceId === g);
90
- if (m.length > 0)
91
- for (const o of m)
92
- o.open();
88
+ effect: (c, { id: d, options: g }) => {
89
+ const S = c.filter((m) => m.experienceId === d);
90
+ if (S.length > 0)
91
+ for (const m of S)
92
+ m.open();
93
93
  else
94
- n({ id: g, options: { ...S, initialiseOpen: !0 } });
94
+ a({ id: d, options: { ...g, 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: l,
101
+ get: p,
102
102
  /** @deprecated Use `experiences.get(id)` instead. */
103
- getById: a,
103
+ getById: p,
104
104
  /** Effector effect that launches an experience by ID, creating instances for each DOM target. */
105
- launch: n,
105
+ launch: a,
106
106
  /** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
107
- open: p,
107
+ open: i,
108
108
  /** Derived store containing all registered experiences as an array. */
109
- listStore: i
109
+ listStore: n
110
110
  };
111
111
  });
112
- function he(t) {
113
- return I(me, t);
112
+ function ye(t) {
113
+ return I(he, t);
114
114
  }
115
- const ye = (t, e) => {
115
+ const Se = (t, e) => {
116
116
  e.register(t);
117
117
  }, N = (t, e, r) => {
118
- const { targetSelectors: s } = e.configStore.getState(), i = W(s, e.id);
119
- i.forEach(
120
- ({ elements: a }) => a.forEach((n) => te(n, e.id))
121
- ), re(i, e.id).forEach((a) => {
118
+ const { targetSelectors: s } = e.configStore.getState(), n = W(s, e.id);
119
+ n.forEach(
120
+ ({ elements: a }) => a.forEach((i) => te(i, e.id))
121
+ ), re(n, e.id).forEach((a) => {
122
122
  r ? t.experienceInstances.spawn(e, a, r) : t.experienceInstances.spawn(e, a);
123
123
  });
124
124
  }, H = async (t) => {
@@ -128,17 +128,17 @@ const ye = (t, e) => {
128
128
  })
129
129
  );
130
130
  }, Q = async (t, e) => {
131
- if (!t.session?.isUser)
131
+ if (!t.preconditionPassed || !t.session?.isUser)
132
132
  return !1;
133
133
  const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
134
134
  return W(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : se(r) ? await P(t, r) === !0 : !0;
135
- }, Se = (t, e, r) => {
136
- const s = e.name, i = e.setup(t);
137
- if (i) {
138
- const l = r[s] ?? {};
139
- r[s] = Object.freeze({ ...l, ...i });
135
+ }, ve = (t, e, r) => {
136
+ const s = e.name, n = e.setup(t);
137
+ if (n) {
138
+ const p = r[s] ?? {};
139
+ r[s] = Object.freeze({ ...p, ...n });
140
140
  }
141
- }, ve = F("component"), ke = b(
141
+ }, ke = x("component"), we = b(
142
142
  ({ client: t, component: e, name: r }) => {
143
143
  const s = t.frameworks.getByName(e.frameworkName);
144
144
  return {
@@ -148,84 +148,84 @@ const ye = (t, e) => {
148
148
  };
149
149
  }
150
150
  );
151
- function we(t) {
152
- return I(ke, t);
151
+ function be(t) {
152
+ return I(we, t);
153
153
  }
154
- const be = b(({ client: t }) => {
155
- const e = ve.store({}), r = j(e, {
156
- register(a, n) {
154
+ const Ie = b(({ client: t }) => {
155
+ const e = ke.store({}), r = j(e, {
156
+ register(a, i) {
157
157
  return {
158
158
  ...a,
159
- [n.name]: n
159
+ [i.name]: i
160
160
  };
161
161
  }
162
162
  });
163
- function s(a, n) {
163
+ function s(a, i) {
164
164
  e.getState()[a] && w(
165
165
  "warn",
166
166
  `Component '${a}' already registered. Registering again will override the previous registration.`
167
167
  );
168
- const u = we({ client: t, name: a, component: n });
169
- r.register(u);
168
+ const d = be({ client: t, name: a, component: i });
169
+ r.register(d);
170
170
  }
171
- const i = e.map((a) => Object.values(a));
172
- function l(a) {
173
- return e.map((n) => n[a], { skipVoid: !1 });
171
+ const n = e.map((a) => Object.values(a));
172
+ function p(a) {
173
+ return e.map((i) => i[a], { skipVoid: !1 });
174
174
  }
175
175
  return {
176
176
  register: s,
177
- getByName: l,
178
- listStore: i
177
+ getByName: p,
178
+ listStore: n
179
179
  };
180
180
  });
181
- function Ie(t) {
182
- return I(be, t);
181
+ function Fe(t) {
182
+ return I(Ie, t);
183
183
  }
184
184
  const G = (t, e, r) => {
185
185
  r.register(t, e);
186
- }, xe = F("framework"), Fe = b(({ client: t }) => {
186
+ }, xe = x("framework"), je = b(({ client: t }) => {
187
187
  const e = xe.store({}), r = j(e, {
188
- register(a, n) {
188
+ register(a, i) {
189
189
  return {
190
190
  ...a,
191
- [n.name]: n.framework
191
+ [i.name]: i.framework
192
192
  };
193
193
  }
194
194
  });
195
- function s(a, n) {
195
+ function s(a, i) {
196
196
  e.getState()[a] && w(
197
197
  "warn",
198
198
  `Framework '${a}' already registered. Registering again will override the previous registration.`
199
- ), r.register({ name: a, framework: n });
199
+ ), r.register({ name: a, framework: i });
200
200
  }
201
- const i = e.map((a) => Object.values(a));
202
- function l(a) {
203
- return e.map((n) => n[a], { skipVoid: !1 });
201
+ const n = e.map((a) => Object.values(a));
202
+ function p(a) {
203
+ return e.map((i) => i[a], { skipVoid: !1 });
204
204
  }
205
205
  return {
206
206
  register: s,
207
- getByName: l,
208
- listStore: i
207
+ getByName: p,
208
+ listStore: n
209
209
  };
210
210
  });
211
- function je(t) {
212
- return I(Fe, t);
211
+ function Ee(t) {
212
+ return I(je, t);
213
213
  }
214
- const Ee = (t, e) => {
214
+ const Pe = (t, e) => {
215
215
  e.register(t.name, t);
216
- }, Pe = 6e3, Ae = A("last_ping", "global"), $e = async (t) => {
216
+ }, Ae = 6e3, $e = A("last_ping", "global"), Be = async (t) => {
217
217
  try {
218
- const e = Date.now(), r = C.get(Ae);
218
+ const e = Date.now(), r = C.get($e);
219
219
  let s = 0;
220
- if (r.isSet() && (s = r.json() ?? 0), s && e - s < Pe)
220
+ if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ae)
221
221
  return !0;
222
- const i = {
222
+ const n = {
223
223
  projectId: t.projectId,
224
224
  path: window.location.pathname
225
- }, l = {}, n = document.getElementById("picked_script")?.dataset.verceltoken;
226
- n && (l["x-vercel-protection-bypass"] = n);
227
- const u = (await ae(t.apiUrl, "ping", i, l)).ok;
228
- return u && r.set(e), u;
225
+ }, p = {}, i = document.getElementById("picked_script")?.dataset.verceltoken;
226
+ i && (p["x-vercel-protection-bypass"] = i);
227
+ const d = (await ae(t.apiUrl, "ping", n, p)).ok;
228
+ return d && r.set(e), d;
229
229
  } catch (e) {
230
230
  return w("error", e), !1;
231
231
  }
@@ -242,34 +242,34 @@ function X(t) {
242
242
  };
243
243
  return Object.freeze(r);
244
244
  }
245
- const Be = F("predicate"), Re = b(({ client: t }) => {
246
- const e = Be.store({}), r = j(e, {
247
- register(n, p) {
245
+ const Re = x("predicate"), ze = b(({ client: t }) => {
246
+ const e = Re.store({}), r = j(e, {
247
+ register(i, c) {
248
248
  return {
249
- ...n,
250
- [p.name]: {
251
- name: p.name,
252
- predicate: p.predicate
249
+ ...i,
250
+ [c.name]: {
251
+ name: c.name,
252
+ predicate: c.predicate
253
253
  }
254
254
  };
255
255
  }
256
256
  });
257
- function s(n, p) {
258
- e.getState()[n] && w(
257
+ function s(i, c) {
258
+ e.getState()[i] && w(
259
259
  "warn",
260
- `Predicate '${n}' already registered. Registering again will override the previous registration.`
261
- ), r.register(Object.freeze({ name: n, predicate: p }));
260
+ `Predicate '${i}' already registered. Registering again will override the previous registration.`
261
+ ), r.register(Object.freeze({ name: i, predicate: c }));
262
262
  }
263
- const i = e.map((n) => Object.values(n));
264
- function l(n) {
265
- return e.map((p) => p[n]?.predicate, { skipVoid: !1 });
263
+ const n = e.map((i) => Object.values(i));
264
+ function p(i) {
265
+ return e.map((c) => c[i]?.predicate, { skipVoid: !1 });
266
266
  }
267
- function a(n) {
268
- const p = T(() => {
267
+ function a(i) {
268
+ const c = T(() => {
269
269
  }, {
270
270
  skipVoid: !1
271
- }), u = R(async () => {
272
- const g = l(n).getState();
271
+ }), d = R(async () => {
272
+ const g = p(i).getState();
273
273
  if (!g)
274
274
  return;
275
275
  const S = X(t);
@@ -277,239 +277,239 @@ const Be = F("predicate"), Re = b(({ client: t }) => {
277
277
  });
278
278
  return k({
279
279
  source: { responses: t.responses.listStore, fields: t.fields.listStore },
280
- target: u
280
+ target: d
281
281
  }), k({
282
- clock: u.doneData,
282
+ clock: d.doneData,
283
283
  filter: (g) => g !== void 0,
284
- target: p
285
- }), u(), p;
284
+ target: c
285
+ }), d(), c;
286
286
  }
287
287
  return {
288
288
  register: s,
289
- getByName: l,
290
- listStore: i,
289
+ getByName: p,
290
+ listStore: n,
291
291
  getEvokablePredicate: a
292
292
  };
293
293
  });
294
- function ze(t) {
295
- return I(Re, t);
294
+ function Ce(t) {
295
+ return I(ze, t);
296
296
  }
297
- const Ce = (t, e, r) => {
297
+ const Oe = (t, e, r) => {
298
298
  r.register(t, e);
299
- }, J = F("feature"), Me = b(({ client: t }) => {
299
+ }, J = x("feature"), Me = b(({ client: t }) => {
300
300
  const e = J.store({}), r = J.store([]), s = j(e, {
301
- register(o, c) {
301
+ register(o, u) {
302
302
  return {
303
303
  ...o,
304
- [c.id]: c.feature
304
+ [u.id]: u.feature
305
305
  };
306
306
  }
307
307
  });
308
- function i(o, c) {
308
+ function n(o, u) {
309
309
  e.getState()[o] && w(
310
310
  "warn",
311
311
  `Feature '${o}' already registered. Registering again will override the previous registration.`
312
312
  );
313
- const d = {
313
+ const l = {
314
314
  id: o,
315
315
  feature: {
316
- ...c,
316
+ ...u,
317
317
  id: o
318
318
  }
319
319
  };
320
320
  s.register(
321
321
  Object.freeze({
322
322
  id: o,
323
- feature: d
323
+ feature: l
324
324
  })
325
325
  );
326
326
  }
327
- const l = R(
327
+ const p = R(
328
328
  async ({
329
329
  id: o,
330
- key: c,
330
+ key: u,
331
331
  storage: f = "local"
332
332
  }) => {
333
- const d = A(`feature:${o}:${c}`, "global"), y = (f === "session" ? M : C).get(d).boolean();
334
- return y === null ? null : { id: o, key: c, bucket: y, storage: f };
333
+ const l = A(`feature:${o}:${u}`, "global"), y = (f === "session" ? O : C).get(l).boolean();
334
+ return y === null ? null : { id: o, key: u, bucket: y, storage: f };
335
335
  }
336
336
  ), a = R((o) => {
337
337
  if (!o)
338
338
  return null;
339
- const c = A(`feature:${o.id}:${o.key}`, "global");
340
- (o.storage === "session" ? M : C).set(c, o.bucket);
341
- }), n = /* @__PURE__ */ new Map(), p = U({
339
+ const u = A(`feature:${o.id}:${o.key}`, "global");
340
+ (o.storage === "session" ? O : C).set(u, o.bucket);
341
+ }), i = /* @__PURE__ */ new Map(), c = U({
342
342
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
343
- effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: c }, { id: f, decide: d, key: h }) => {
344
- const y = c.find(
343
+ effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: u }, { id: f, decide: l, key: h }) => {
344
+ const y = u.find(
345
345
  (B) => B.id === f && B.key === h
346
346
  );
347
347
  if (y)
348
348
  return y;
349
- const x = o[f];
350
- if (!x)
349
+ const F = o[f];
350
+ if (!F)
351
351
  throw new Error(`Feature with id '${f}' not found`);
352
- const $ = n.get(`${f}:${h}`);
352
+ const $ = i.get(`${f}:${h}`);
353
353
  if ($ !== void 0) {
354
354
  const B = await $;
355
- return { id: x.id, bucket: B, key: h, storage: x.feature.storage };
355
+ return { id: F.id, bucket: B, key: h, storage: F.feature.storage };
356
356
  }
357
- const v = d();
358
- n.set(`${f}:${h}`, v);
357
+ const v = l();
358
+ i.set(`${f}:${h}`, v);
359
359
  const ee = await v;
360
- return { id: x.id, bucket: ee, key: h, storage: x.feature.storage };
360
+ return { id: F.id, bucket: ee, key: h, storage: F.feature.storage };
361
361
  }
362
362
  });
363
363
  k({
364
364
  clock: s.register,
365
365
  fn: (o) => {
366
- const { id: c, feature: f } = o;
367
- return { id: c, key: f.feature.key, storage: f.feature.storage };
366
+ const { id: u, feature: f } = o;
367
+ return { id: u, key: f.feature.key, storage: f.feature.storage };
368
368
  },
369
- target: l
369
+ target: p
370
370
  }), k({
371
371
  source: e,
372
- clock: p.doneData,
373
- fn: (o, c) => {
374
- const { id: f, bucket: d, storage: h } = c, y = o[f]?.feature.key;
375
- return y ? { key: y, id: f, bucket: d, storage: h } : null;
372
+ clock: c.doneData,
373
+ fn: (o, u) => {
374
+ const { id: f, bucket: l, storage: h } = u, y = o[f]?.feature.key;
375
+ return y ? { key: y, id: f, bucket: l, storage: h } : null;
376
376
  },
377
377
  target: a
378
378
  });
379
- const u = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
379
+ const d = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
380
380
  ({
381
381
  allFeaturesStore: o,
382
- resolvedFeaturesStore: c
382
+ resolvedFeaturesStore: u
383
383
  }) => Object.values(o).map((f) => {
384
- const d = c.find(
384
+ const l = u.find(
385
385
  (h) => h.id === f.id && h.key === f.feature.key
386
386
  );
387
- return d ? {
387
+ return l ? {
388
388
  id: f.id,
389
389
  name: f.feature.name,
390
390
  key: f.feature.key,
391
- getBucket: () => ({ id: f.id, bucket: d.bucket }),
391
+ getBucket: () => ({ id: f.id, bucket: l.bucket }),
392
392
  isResolved: !0
393
393
  } : {
394
394
  id: f.id,
395
395
  name: f.feature.name,
396
396
  key: f.feature.key,
397
- getBucket: async () => await p(f.feature),
397
+ getBucket: async () => await c(f.feature),
398
398
  isResolved: !1
399
399
  };
400
400
  })
401
401
  );
402
402
  k({
403
- clock: p.doneData,
403
+ clock: c.doneData,
404
404
  source: { resolvedFeatures: r },
405
- filter: ({ resolvedFeatures: o }, { id: c, key: f }) => !o.some(
406
- (h) => h.id === c && h.key === f
405
+ filter: ({ resolvedFeatures: o }, { id: u, key: f }) => !o.some(
406
+ (h) => h.id === u && h.key === f
407
407
  ),
408
- fn: (o, c) => c,
408
+ fn: (o, u) => u,
409
409
  target: t.eventBus.prepend((o) => ({
410
410
  type: "feature_decide",
411
411
  feature: o
412
412
  }))
413
413
  }), k({
414
- clock: [l.doneData, p.doneData],
414
+ clock: [p.doneData, c.doneData],
415
415
  source: r,
416
- fn: (o, c) => !c || o.some(
417
- (d) => d.id === c.id && d.key === c.key
418
- ) ? o : [...o, c],
416
+ fn: (o, u) => !u || o.some(
417
+ (l) => l.id === u.id && l.key === u.key
418
+ ) ? o : [...o, u],
419
419
  target: r
420
420
  });
421
421
  function g(o) {
422
- return u.map((c) => c.find((f) => f.id === o));
422
+ return d.map((u) => u.find((f) => f.id === o));
423
423
  }
424
424
  function S(o) {
425
- return e.map((c) => c[o], { skipVoid: !1 });
425
+ return e.map((u) => u[o], { skipVoid: !1 });
426
426
  }
427
427
  function m(o) {
428
- const c = T(
428
+ const u = T(
429
429
  async () => {
430
430
  },
431
431
  { skipVoid: !1 }
432
432
  ), f = R(async () => {
433
- const d = g(o).getState();
434
- if (d)
435
- return async () => (await d.getBucket()).bucket;
433
+ const l = g(o).getState();
434
+ if (l)
435
+ return async () => (await l.getBucket()).bucket;
436
436
  });
437
437
  return k({
438
438
  source: r,
439
- filter: (d) => d.some((h) => h.id === o),
439
+ filter: (l) => l.some((h) => h.id === o),
440
440
  target: f
441
441
  }), k({
442
442
  clock: f.doneData,
443
- filter: (d) => d !== void 0,
444
- target: c
445
- }), f(), c;
443
+ filter: (l) => l !== void 0,
444
+ target: u
445
+ }), f(), u;
446
446
  }
447
447
  return {
448
- register: i,
448
+ register: n,
449
449
  getById: g,
450
450
  getByName: S,
451
- listStore: u,
451
+ listStore: d,
452
452
  getEvokableFeature: m
453
453
  };
454
454
  });
455
- function Oe(t) {
455
+ function Ue(t) {
456
456
  return I(Me, t);
457
457
  }
458
- const Ue = (t, e, r) => {
458
+ const De = (t, e, r) => {
459
459
  r.register(t, e);
460
- }, E = F("history");
460
+ }, E = x("history");
461
461
  function q(t, e) {
462
462
  return {
463
463
  // eslint-disable-next-line sonarjs/pseudo-random
464
- id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
464
+ id: ue(`history-entry-${Date.now()}-${Math.random()}}`),
465
465
  node: e,
466
466
  at: Date.now(),
467
467
  experienceId: t
468
468
  };
469
469
  }
470
- const De = b(() => {
471
- const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), i = E.event();
472
- t.on(e, (a, n) => ({
473
- entries: [...a.entries, q(n.experienceId, n.node)]
474
- })), t.on(r, (a, n) => ({
470
+ const Ve = b(() => {
471
+ const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), n = E.event();
472
+ t.on(e, (a, i) => ({
473
+ entries: [...a.entries, q(i.experienceId, i.node)]
474
+ })), t.on(r, (a, i) => ({
475
475
  entries: [
476
476
  ...a.entries.slice(0, -1),
477
- q(n.experienceId, n.node)
477
+ q(i.experienceId, i.node)
478
478
  ]
479
- })), t.on(i, (a, n) => n);
480
- function l(a, n) {
481
- const p = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
- for (let u = a.length - 1; u >= 0; u--) {
483
- const g = a[u], S = g?.node;
484
- if (!(!S || !ne(S)) && !(n && g?.experienceId !== n))
485
- if (p.lastStepIndex === -1)
486
- p.lastStepIndex = u;
479
+ })), t.on(n, (a, i) => i);
480
+ function p(a, i) {
481
+ const c = { lastStepIndex: -1, secondLastStepIndex: -1 };
482
+ for (let d = a.length - 1; d >= 0; d--) {
483
+ const g = a[d], S = g?.node;
484
+ if (!(!S || !ne(S)) && !(i && g?.experienceId !== i))
485
+ if (c.lastStepIndex === -1)
486
+ c.lastStepIndex = d;
487
487
  else {
488
- p.secondLastStepIndex = u;
488
+ c.secondLastStepIndex = d;
489
489
  break;
490
490
  }
491
491
  }
492
- return p;
492
+ return c;
493
493
  }
494
- return t.on(s, (a, n) => {
495
- const { secondLastStepIndex: p } = l(a.entries, n.experienceId), u = p !== -1 ? a.entries.slice(0, p + 1) : a.entries;
494
+ return t.on(s, (a, i) => {
495
+ const { secondLastStepIndex: c } = p(a.entries, i.experienceId), d = c !== -1 ? a.entries.slice(0, c + 1) : a.entries;
496
496
  return {
497
497
  ...a,
498
- entries: u
498
+ entries: d
499
499
  };
500
500
  }), {
501
501
  push: e,
502
502
  replace: r,
503
503
  back: s,
504
- restore: i,
504
+ restore: n,
505
505
  entriesStore: t.map((a) => a.entries)
506
506
  };
507
507
  });
508
- function Ve() {
509
- return I(De);
508
+ function Ne() {
509
+ return I(Ve);
510
510
  }
511
- let Ne = 0;
512
- const Te = (t) => {
511
+ let Te = 0;
512
+ const Le = (t) => {
513
513
  const e = T([]);
514
514
  return k({
515
515
  clock: t,
@@ -517,99 +517,99 @@ const Te = (t) => {
517
517
  fn: (r, s) => [
518
518
  ...r,
519
519
  {
520
- id: Ne++,
520
+ id: Te++,
521
521
  at: /* @__PURE__ */ new Date(),
522
522
  payload: s
523
523
  }
524
524
  ],
525
525
  target: e
526
526
  }), e;
527
- }, Le = F("field"), _e = b(() => {
528
- const t = Le.store({}), e = j(t, {
529
- register(n, p) {
527
+ }, _e = x("field"), He = b(() => {
528
+ const t = _e.store({}), e = j(t, {
529
+ register(i, c) {
530
530
  return {
531
- ...n,
532
- [p.field.id]: p.field
531
+ ...i,
532
+ [c.field.id]: c.field
533
533
  };
534
534
  }
535
535
  });
536
- function r(n) {
537
- e.register({ field: n });
536
+ function r(i) {
537
+ e.register({ field: i });
538
538
  }
539
- function s(n, p) {
540
- const u = l(n).getState();
541
- if (!u)
539
+ function s(i, c) {
540
+ const d = p(i).getState();
541
+ if (!d)
542
542
  return;
543
- const g = Object.assign({}, u, {
544
- ...p
543
+ const g = Object.assign({}, d, {
544
+ ...c
545
545
  });
546
546
  e.register({ field: { ...g } });
547
547
  }
548
- const i = t.map((n) => Object.values(n));
549
- function l(n) {
550
- return t.map((p) => p[n] || null);
548
+ const n = t.map((i) => Object.values(i));
549
+ function p(i) {
550
+ return t.map((c) => c[i] || null);
551
551
  }
552
- function a(n) {
553
- return t.map((p) => Object.values(p).find((u) => u.name === n) || null);
552
+ function a(i) {
553
+ return t.map((c) => Object.values(c).find((d) => d.name === i) || null);
554
554
  }
555
555
  return {
556
556
  register: r,
557
557
  update: s,
558
- getById: l,
559
- listStore: i,
558
+ getById: p,
559
+ listStore: n,
560
560
  getByName: a
561
561
  };
562
562
  });
563
- function He() {
564
- return I(_e);
563
+ function Ge() {
564
+ return I(He);
565
565
  }
566
- const Ge = (t, e) => {
566
+ const Je = (t, e) => {
567
567
  e.register(t);
568
- }, Je = F("action"), qe = b(() => {
569
- const t = Je.store({}), e = j(t, {
570
- register(a, n) {
568
+ }, qe = x("action"), Ke = b(() => {
569
+ const t = qe.store({}), e = j(t, {
570
+ register(a, i) {
571
571
  return {
572
572
  ...a,
573
- [n.name]: {
574
- name: n.name,
575
- action: n.action
573
+ [i.name]: {
574
+ name: i.name,
575
+ action: i.action
576
576
  }
577
577
  };
578
578
  }
579
579
  });
580
- function r(a, n) {
581
- e.register({ name: a, action: n });
580
+ function r(a, i) {
581
+ e.register({ name: a, action: i });
582
582
  }
583
583
  const s = t.map((a) => Object.values(a));
584
- function i(a) {
585
- return t.map((n) => n[a], { skipVoid: !1 });
584
+ function n(a) {
585
+ return t.map((i) => i[a], { skipVoid: !1 });
586
586
  }
587
- function l(a) {
587
+ function p(a) {
588
588
  return t.map(
589
- (n) => {
590
- const p = n[a];
591
- return p ? p.action : void 0;
589
+ (i) => {
590
+ const c = i[a];
591
+ return c ? c.action : void 0;
592
592
  },
593
593
  { skipVoid: !1 }
594
594
  );
595
595
  }
596
596
  return {
597
597
  register: r,
598
- getByName: i,
598
+ getByName: n,
599
599
  listStore: s,
600
- getEvokableAction: l
600
+ getEvokableAction: p
601
601
  };
602
602
  });
603
- function Ke() {
604
- return I(qe);
603
+ function We() {
604
+ return I(Ke);
605
605
  }
606
- const We = (t, e, r) => {
606
+ const Ye = (t, e, r) => {
607
607
  r.register(t, e);
608
608
  };
609
- function O(t) {
609
+ function M(t) {
610
610
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
611
611
  }
612
- function Ye(t) {
612
+ function Qe(t) {
613
613
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
614
614
  }
615
615
  function K(t) {
@@ -619,8 +619,8 @@ function K(t) {
619
619
  return !1;
620
620
  }
621
621
  }
622
- const Qe = F("response"), Xe = b(({ client: t }) => {
623
- const e = Qe.store({}), r = V(), s = V(), i = j(e, {
622
+ const Xe = x("response"), Ze = b(({ client: t }) => {
623
+ const e = Xe.store({}), r = V(), s = V(), n = j(e, {
624
624
  register(m, o) {
625
625
  return {
626
626
  ...m,
@@ -634,201 +634,200 @@ const Qe = F("response"), Xe = b(({ client: t }) => {
634
634
  };
635
635
  },
636
636
  clear(m, o) {
637
- const { [o]: c, ...f } = m;
637
+ const { [o]: u, ...f } = m;
638
638
  return f;
639
639
  },
640
640
  clearAll() {
641
641
  return {};
642
642
  }
643
643
  });
644
- function l(m, o) {
644
+ function p(m, o) {
645
645
  if (typeof m == "string") {
646
646
  if (o === void 0)
647
647
  throw new Error("Response is required when registering a single field");
648
- i.register({ fieldId: m, response: o });
648
+ n.register({ fieldId: m, response: o });
649
649
  } else
650
- i.registerBatch(m);
650
+ n.registerBatch(m);
651
651
  }
652
652
  async function a(m) {
653
653
  const o = [];
654
654
  return await Promise.allSettled(
655
- Object.entries(m).map(async ([c, f]) => {
656
- let d = f;
657
- const h = t.fields.getById(c).getState();
655
+ Object.entries(m).map(async ([u, f]) => {
656
+ let l = f;
657
+ const h = t.fields.getById(u).getState();
658
658
  if (!h) {
659
659
  o.push({
660
- fieldId: c,
661
- userMessage: `Field '${c}' not found`,
662
- systemMessage: `No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
- value: d
660
+ fieldId: u,
661
+ userMessage: `Field '${u}' not found`,
662
+ systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
663
+ value: l
664
664
  });
665
665
  return;
666
666
  }
667
- if (h.multiple && (typeof d == "string" || typeof d == "number" || typeof d == "boolean") && (d = [d]), h.validation && !ue(h.validation) && !O(d)) {
667
+ if (h.multiple && (typeof l == "string" || typeof l == "number" || typeof l == "boolean") && (l = [l]), h.validation && !de(h.validation) && !M(l)) {
668
668
  const y = await P(t, h.validation, {
669
- $input: d
669
+ $input: l
670
670
  });
671
671
  if (typeof y == "string") {
672
672
  o.push({
673
- fieldId: c,
673
+ fieldId: u,
674
674
  userMessage: y,
675
675
  systemMessage: `Field validation resulted in an error: ${y}.`,
676
- value: d
676
+ value: l
677
677
  });
678
678
  return;
679
679
  }
680
680
  if (y === !1) {
681
681
  o.push({
682
- fieldId: c,
682
+ fieldId: u,
683
683
  userMessage: "This field is invalid",
684
684
  systemMessage: "Field validation resulted in an unspecified error.",
685
- value: d
685
+ value: l
686
686
  });
687
687
  return;
688
688
  }
689
689
  }
690
- if (h.required && O(d)) {
690
+ if (h.required && M(l)) {
691
691
  o.push({
692
- fieldId: c,
692
+ fieldId: u,
693
693
  userMessage: "This field is required",
694
694
  systemMessage: "Field is required.",
695
- value: d
695
+ value: l
696
696
  });
697
697
  return;
698
698
  }
699
- if (!h.multiple && Array.isArray(d) && d.length > 1) {
699
+ if (!h.multiple && Array.isArray(l) && l.length > 1) {
700
700
  o.push({
701
- fieldId: c,
701
+ fieldId: u,
702
702
  userMessage: "This field expects a single response",
703
703
  systemMessage: "Field expects a single response.",
704
- value: d
704
+ value: l
705
705
  });
706
706
  return;
707
707
  }
708
- if (h.type === "object" && !O(d))
708
+ if (h.type === "object" && !M(l))
709
709
  if (h.multiple) {
710
- if (!Array.isArray(d)) {
710
+ if (!Array.isArray(l)) {
711
711
  o.push({
712
- fieldId: c,
712
+ fieldId: u,
713
713
  userMessage: "This field expects multiple values",
714
714
  systemMessage: "Field expects an array of objects.",
715
- value: d
715
+ value: l
716
716
  });
717
717
  return;
718
718
  }
719
- for (const y of d) {
719
+ for (const y of l) {
720
720
  if (typeof y != "object" || y === null) {
721
721
  o.push({
722
- fieldId: c,
722
+ fieldId: u,
723
723
  userMessage: "This field expects object values",
724
724
  systemMessage: "Field expects an array of objects, but received non-object value.",
725
- value: d
725
+ value: l
726
726
  });
727
727
  return;
728
728
  }
729
729
  if (!K(y)) {
730
730
  o.push({
731
- fieldId: c,
731
+ fieldId: u,
732
732
  userMessage: "This field contains non-serializable data",
733
733
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
734
- value: d
734
+ value: l
735
735
  });
736
736
  return;
737
737
  }
738
738
  }
739
739
  } else {
740
- if (Array.isArray(d)) {
740
+ if (Array.isArray(l)) {
741
741
  o.push({
742
- fieldId: c,
742
+ fieldId: u,
743
743
  userMessage: "This field expects a single value",
744
744
  systemMessage: "Field expects a single object, not an array.",
745
- value: d
745
+ value: l
746
746
  });
747
747
  return;
748
748
  }
749
- if (typeof d != "object" || d === null) {
749
+ if (typeof l != "object" || l === null) {
750
750
  o.push({
751
- fieldId: c,
751
+ fieldId: u,
752
752
  userMessage: "This field expects an object value",
753
753
  systemMessage: "Field expects an object value.",
754
- value: d
754
+ value: l
755
755
  });
756
756
  return;
757
757
  }
758
- if (!K(d)) {
758
+ if (!K(l)) {
759
759
  o.push({
760
- fieldId: c,
760
+ fieldId: u,
761
761
  userMessage: "This field contains non-serializable data",
762
762
  systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
763
- value: d
763
+ value: l
764
764
  });
765
765
  return;
766
766
  }
767
767
  }
768
768
  if (Array.isArray(h.options) && h.options.length > 0) {
769
- const y = Array.isArray(d) ? d : [d];
769
+ const y = Array.isArray(l) ? l : [l];
770
770
  if (h.type === "object") {
771
- const x = h.options.map((v) => JSON.stringify(v.value));
772
- y.every((v) => x.includes(JSON.stringify(v))) || o.push({
773
- fieldId: c,
771
+ const F = h.options.map((v) => JSON.stringify(v.value));
772
+ y.every((v) => F.includes(JSON.stringify(v))) || o.push({
773
+ fieldId: u,
774
774
  userMessage: "This field expects a valid option",
775
775
  systemMessage: "Field expects a valid option from the defined choices.",
776
- value: d
776
+ value: l
777
777
  });
778
778
  } else {
779
- const x = h.options.map((v) => v.value);
780
- y.every((v) => !Ye(v) || v === null ? !1 : x.includes(v)) || o.push({
781
- fieldId: c,
779
+ const F = h.options.map((v) => v.value);
780
+ y.every((v) => !Qe(v) || v === null ? !1 : F.includes(v)) || o.push({
781
+ fieldId: u,
782
782
  userMessage: "This field expects a valid option",
783
- systemMessage: `Field expects a valid option. Valid options are: ${x.join(", ")}`,
784
- value: d
783
+ systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
784
+ value: l
785
785
  });
786
786
  }
787
787
  }
788
788
  })
789
789
  ), { responsesToCommit: m, validationErrors: o };
790
790
  }
791
- async function n(m) {
792
- const { responsesToCommit: o, validationErrors: c } = await a(m);
793
- return c.length ? { errors: c } : (i.registerBatch(o), { errors: [] });
791
+ async function i(m) {
792
+ const { responsesToCommit: o, validationErrors: u } = await a(m);
793
+ return u.length ? { errors: u } : (n.registerBatch(o), { errors: [] });
794
794
  }
795
- const p = e.map((m) => m), u = e.map((m) => Object.keys(m).map((c) => ({
796
- fieldId: c,
797
- value: m[c]
795
+ const c = e.map((m) => m), d = e.map((m) => Object.keys(m).map((u) => ({
796
+ fieldId: u,
797
+ value: m[u]
798
798
  })));
799
799
  function g(m) {
800
- const o = t.fields.getById(m), c = e.map((f) => f[m] || null);
801
- return D({ f: o, r: c }, ({ f, r: d }) => d || (f?.defaultValue ? f.defaultValue : null));
800
+ const o = t.fields.getById(m), u = e.map((f) => f[m] || null);
801
+ return D({ f: o, r: u }, ({ f, r: l }) => l || (f?.defaultValue ? f.defaultValue : null));
802
802
  }
803
803
  function S(m) {
804
804
  const o = t.fields.getByName(m);
805
- return D({ f: o, s: e }, ({ f: c, s: f }) => {
806
- const d = c && f[c.id] || null;
807
- return d || (c?.defaultValue ? c.defaultValue : null);
805
+ return D({ f: o, s: e }, ({ f: u, s: f }) => {
806
+ const l = u && f[u.id] || null;
807
+ return l || (u?.defaultValue ? u.defaultValue : null);
808
808
  });
809
809
  }
810
810
  return k({
811
811
  clock: r,
812
- target: i.clearAll
812
+ target: n.clearAll
813
813
  }), k({
814
814
  clock: s,
815
- target: i.clear
815
+ target: n.clear
816
816
  }), {
817
- register: l,
817
+ register: p,
818
818
  clearAll: r,
819
819
  clear: s,
820
- commit: n,
820
+ commit: i,
821
821
  getResponsesToCommit: a,
822
- listStore: u,
823
- getAllStore: p,
822
+ listStore: d,
823
+ getAllStore: c,
824
824
  getByFieldId: g,
825
825
  getByFieldName: S
826
826
  };
827
827
  });
828
- function Ze(t) {
829
- return I(Xe, t);
828
+ function et(t) {
829
+ return I(Ze, t);
830
830
  }
831
- const et = () => "0.0.48-next.1";
832
831
  function tt() {
833
832
  if (L()) {
834
833
  const t = [
@@ -848,24 +847,24 @@ function rt() {
848
847
  if (!_())
849
848
  return {};
850
849
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
851
- for (const [i] of t.entries())
852
- i.startsWith("picked-") && r.add(i);
853
- for (const i of r) {
854
- const l = i.replace("picked-", "");
855
- e[l] = t.getAll(i);
850
+ for (const [n] of t.entries())
851
+ n.startsWith("picked-") && r.add(n);
852
+ for (const n of r) {
853
+ const p = n.replace("picked-", "");
854
+ e[p] = t.getAll(n);
856
855
  }
857
856
  const s = A("s");
858
857
  if (r.size > 0)
859
- M.set(s, e);
858
+ O.set(s, e);
860
859
  else {
861
- const i = M.get(s);
862
- if (i)
863
- return i.json() || {};
860
+ const n = O.get(s);
861
+ if (n)
862
+ return n.json() || {};
864
863
  }
865
864
  return e;
866
865
  }
867
866
  function st() {
868
- if (le())
867
+ if (pe())
869
868
  return crypto.randomUUID();
870
869
  const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
871
870
  return `${t}-${e}-${r}-${s}`;
@@ -874,28 +873,28 @@ const nt = A("session", "global"), it = () => {
874
873
  const t = C.get(nt);
875
874
  let e;
876
875
  t.isSet() && (e = t.json());
877
- const r = (i) => t.set({
878
- id: i.id,
879
- isUser: i.isUser,
880
- identifiers: i.identifiers
876
+ const r = (n) => t.set({
877
+ id: n.id,
878
+ isUser: n.isUser,
879
+ identifiers: n.identifiers
881
880
  }), s = {
882
881
  id: e?.id ?? st(),
883
882
  isUser: e?.isUser ?? void 0,
884
883
  identifiers: e?.identifiers ?? void 0,
885
- setIsUser(i) {
886
- this.isUser = i, r(this);
884
+ setIsUser(n) {
885
+ this.isUser = n, r(this);
887
886
  },
888
- setIdentifier(i, l) {
889
- this.identifiers = { ...this.identifiers, [i]: l }, r(this);
887
+ setIdentifier(n, p) {
888
+ this.identifiers = { ...this.identifiers, [n]: p }, r(this);
890
889
  },
891
- removeIdentifier(i) {
890
+ removeIdentifier(n) {
892
891
  this.identifiers && (this.identifiers = Object.fromEntries(
893
- Object.entries(this.identifiers).filter(([l]) => l !== i)
892
+ Object.entries(this.identifiers).filter(([p]) => p !== n)
894
893
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
895
894
  }
896
895
  };
897
896
  return r(s), s;
898
- }, ot = () => de() ? it() : null;
897
+ }, ot = () => le() ? it() : null;
899
898
  function at() {
900
899
  if (_())
901
900
  return globalThis.window.pickedConfig;
@@ -923,9 +922,9 @@ function dt(t) {
923
922
  const s = ct();
924
923
  if (s)
925
924
  return s;
926
- const i = ut();
927
- if (i)
928
- return i;
925
+ const n = ut();
926
+ if (n)
927
+ return n;
929
928
  throw new Error(
930
929
  `organizationId and projectId are required. You can provide them via one of:
931
930
  (1) createClient({ organizationId, projectId }) options;
@@ -950,7 +949,7 @@ const lt = {
950
949
  if (Array.isArray(t))
951
950
  return e.format(t.map(String));
952
951
  if (t instanceof Map) {
953
- const r = Array.from(t.entries()).map(([s, i]) => `${s}: ${i}`);
952
+ const r = Array.from(t.entries()).map(([s, n]) => `${s}: ${n}`);
954
953
  return e.format(r);
955
954
  }
956
955
  return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
@@ -969,28 +968,28 @@ function ft(t, e) {
969
968
  return typeof r == "function" ? r() : r;
970
969
  }
971
970
  function gt(t, e) {
972
- const r = t.split("|").map((l) => l.trim()), s = r.shift() ?? "";
973
- let i = ft(s, e);
974
- for (const l of r) {
975
- const [a, ...n] = l.split(":"), p = a?.trim() ?? "", u = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[p];
976
- g && (i = g(i, u));
971
+ const r = t.split("|").map((p) => p.trim()), s = r.shift() ?? "";
972
+ let n = ft(s, e);
973
+ for (const p of r) {
974
+ const [a, ...i] = p.split(":"), c = a?.trim() ?? "", d = i.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[c];
975
+ g && (n = g(n, d));
977
976
  }
978
- return z(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
977
+ return z(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
979
978
  }
980
979
  function mt(t, e) {
981
980
  let r = "", s = 0;
982
981
  for (; s < t.length; )
983
982
  if (t[s] === "{" && t[s + 1] === "{") {
984
983
  s += 2;
985
- let i = "";
984
+ let n = "";
986
985
  for (; s < t.length; ) {
987
986
  if (t[s] === "}" && t[s + 1] === "}") {
988
987
  s += 2;
989
988
  break;
990
989
  }
991
- i += t[s++];
990
+ n += t[s++];
992
991
  }
993
- r += gt(i.trim(), e);
992
+ r += gt(n.trim(), e);
994
993
  } else
995
994
  r += t[s++];
996
995
  return r;
@@ -1012,66 +1011,68 @@ class ht {
1012
1011
  session;
1013
1012
  precondition;
1014
1013
  condition;
1014
+ preconditionPassed;
1015
1015
  searchParams = rt();
1016
- history = Ve();
1017
- components = Ie({ client: this });
1016
+ history = Ne();
1017
+ components = Fe({ client: this });
1018
1018
  experienceInstances = ie({ client: this });
1019
- experiences = he({ client: this });
1020
- frameworks = je({ client: this });
1021
- predicates = ze({ client: this });
1022
- features = Oe({ client: this });
1023
- responses = Ze({ client: this });
1024
- fields = He();
1025
- actions = Ke();
1019
+ experiences = ye({ client: this });
1020
+ frameworks = Ee({ client: this });
1021
+ predicates = Ce({ client: this });
1022
+ features = Ue({ client: this });
1023
+ responses = et({ client: this });
1024
+ fields = Ge();
1025
+ actions = We();
1026
1026
  constructor(e) {
1027
- w("info", "Picked client initializing."), this.events = Te(this.eventBus);
1027
+ w("info", "Picked client initializing."), this.events = Le(this.eventBus);
1028
1028
  const { organizationId: r, projectId: s } = dt(e);
1029
- this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: et() }), w("info", "Picked client initialized.");
1029
+ this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
1030
1030
  }
1031
1031
  start = () => {
1032
- $e(this), (async () => {
1032
+ Be(this), (async () => {
1033
1033
  if (!L())
1034
1034
  return;
1035
1035
  await this.runPluginStartHooks();
1036
1036
  const r = await this.evaluateGate(this.precondition);
1037
+ this.preconditionPassed = r;
1037
1038
  let s;
1038
1039
  r && (s = await this.evaluateGate(this.condition));
1039
- const i = r && s === !0;
1040
+ const n = r && s === !0;
1040
1041
  if (typeof s == "boolean" && this.session) {
1041
- const l = s;
1042
- this.session.setIsUser(l), this.eventBus({ type: "user_decide", value: l });
1042
+ const p = s;
1043
+ this.session.setIsUser(p), this.eventBus({ type: "user_decide", value: p });
1043
1044
  }
1044
- if (this.eventBus({ type: "initialize" }), i && H(this), await oe(), i && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1045
- const { id: l, isUser: a, identifiers: n } = this.session;
1046
- this.eventBus({ type: "session", id: l, isUser: a, identifiers: n });
1045
+ if (this.eventBus({ type: "initialize" }), n && H(this), await oe(), n && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
1046
+ const { id: p, isUser: a, identifiers: i } = this.session;
1047
+ this.eventBus({ type: "session", id: p, isUser: a, identifiers: i });
1047
1048
  }
1048
1049
  })();
1049
1050
  };
1050
1051
  registerFramework = (e) => {
1051
- Ee(e, this.frameworks);
1052
+ Pe(e, this.frameworks);
1052
1053
  };
1053
1054
  registerComponent = (e, r) => {
1054
1055
  G(e, r, this.components);
1055
1056
  };
1056
1057
  registerPlugin = (e) => {
1057
- Se(this, e, this.plugins);
1058
+ ve(this, e, this.plugins);
1058
1059
  const r = this.plugins[e.name];
1059
1060
  r?.onStart && this.pluginStartHooks.push(r.onStart);
1060
1061
  };
1061
1062
  registerFeature = (e, r) => {
1062
- Ue(e, r, this.features);
1063
+ De(e, r, this.features);
1063
1064
  };
1064
1065
  registerPredicate = (e, r) => {
1065
- Ce(e, r, this.predicates);
1066
+ Oe(e, r, this.predicates);
1066
1067
  };
1067
1068
  registerField = (e) => {
1068
- Ge(e, this.fields);
1069
+ Je(e, this.fields);
1069
1070
  };
1070
1071
  registerAction = (e, r) => {
1071
- We(e, r, this.actions);
1072
+ Ye(e, r, this.actions);
1072
1073
  };
1073
1074
  registerExperience = (e) => {
1074
- e.component && G(`experience:${e.id}`, e.component, this.components), ye(e, this.experiences);
1075
+ e.component && G(`experience:${e.id}`, e.component, this.components), Se(e, this.experiences);
1075
1076
  };
1076
1077
  getStateSnapshot = () => X(this);
1077
1078
  /** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
@@ -1108,20 +1109,20 @@ class ht {
1108
1109
  setupFeatures() {
1109
1110
  const e = this.options.features;
1110
1111
  e && (Object.entries(e).forEach(([r, s]) => {
1111
- const i = typeof s == "function" ? s() : s;
1112
- this.registerFeature(r, i);
1112
+ const n = typeof s == "function" ? s() : s;
1113
+ this.registerFeature(r, n);
1113
1114
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
1114
1115
  try {
1115
- const [s, i] = r.split(":");
1116
- if (!s || !i)
1116
+ const [s, n] = r.split(":");
1117
+ if (!s || !n)
1117
1118
  return;
1118
- let l = i;
1119
- l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(s, {
1120
- key: `${l}`,
1119
+ let p = n;
1120
+ p === "true" && (p = !0), p === "false" && (p = !1), this.registerFeature(s, {
1121
+ key: `${p}`,
1121
1122
  // use the assigned bucket value as the key
1122
1123
  name: s,
1123
1124
  // eslint-disable-next-line sonarjs/function-return-type
1124
- decide: () => l,
1125
+ decide: () => p,
1125
1126
  storage: "session"
1126
1127
  });
1127
1128
  } catch {
@@ -1148,6 +1149,12 @@ class ht {
1148
1149
  this.registerAction(r, s);
1149
1150
  });
1150
1151
  }
1152
+ setupComponents() {
1153
+ const e = this.options.components;
1154
+ e && Object.entries(e).forEach(([r, s]) => {
1155
+ this.registerComponent(r, s);
1156
+ });
1157
+ }
1151
1158
  getPluginConfig = (e) => this.plugins[e] ?? {};
1152
1159
  /**
1153
1160
  * Interpolates a template string using values from the client's response store and/or a provided context.
@@ -1192,7 +1199,7 @@ class ht {
1192
1199
  * // => "Fruits: apple, banana, and cherry"
1193
1200
  */
1194
1201
  renderString = (e, r) => {
1195
- const s = this.responses.listStore.getState().reduce((i, l) => (i[l.fieldId] = l.value, i), {});
1202
+ const s = this.responses.listStore.getState().reduce((n, p) => (n[p.fieldId] = p.value, n), {});
1196
1203
  return mt(e, {
1197
1204
  ...r,
1198
1205
  responses: s
@@ -1213,8 +1220,8 @@ async function Et(t, e) {
1213
1220
  if (!s.options || !Z(s))
1214
1221
  return s;
1215
1222
  const a = (await Promise.all(
1216
- s.options.map(async (p) => p.condition ? await P(t, p.condition) ? p : null : p)
1217
- )).filter((p) => p !== null);
1223
+ s.options.map(async (c) => c.condition ? await P(t, c.condition) ? c : null : c)
1224
+ )).filter((c) => c !== null);
1218
1225
  return a.length === s.options.length ? s : a.length === 0 ? null : { ...s, options: a };
1219
1226
  })
1220
1227
  )).filter((s) => s !== null);
@@ -1230,7 +1237,7 @@ function At(t) {
1230
1237
  }
1231
1238
  const $t = (t) => {
1232
1239
  const e = new ht(t);
1233
- return pe(e), e;
1240
+ return fe(e), e;
1234
1241
  };
1235
1242
  export {
1236
1243
  ht as Picked,
@@ -1243,14 +1250,14 @@ export {
1243
1250
  zt as isPickedRoot,
1244
1251
  Pt as lazyComponent,
1245
1252
  C as localStore,
1246
- M as sessionStore,
1247
- Mt as subscribe,
1253
+ O as sessionStore,
1254
+ Ot as subscribe,
1248
1255
  Ut as supportsCookies,
1249
- le as supportsCryptoRandomUUID,
1256
+ pe as supportsCryptoRandomUUID,
1250
1257
  L as supportsDocument,
1251
1258
  Dt as supportsHistory,
1252
1259
  Vt as supportsIntersectionObserver,
1253
- de as supportsLocalStorage,
1260
+ le as supportsLocalStorage,
1254
1261
  Nt as supportsLocation,
1255
1262
  Tt as supportsSessionStorage,
1256
1263
  Lt as supportsShadowRoot,