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