@picked/client 0.0.12-next.4 → 0.0.12-next.6

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,45 +1,45 @@
1
1
  var W = Object.defineProperty;
2
2
  var Y = (t, e, r) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var m = (t, e, r) => Y(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { createDomain as I, createApi as x, createEffect as M, attach as J, sample as F, combine as C, createEvent as D } from "effector";
4
+ import { createDomain as I, createApi as x, createEffect as M, attach as J, sample as F, combine as O, createEvent as C } from "effector";
5
5
  import { createFactory as w, invoke as k } from "@withease/factories";
6
- import { g as _, t as Q, c as X, e as R, i as Z, a as ee, b as te, d as re } from "../experience-instance-BBz99AXU.js";
7
- import { f as St } from "../experience-instance-BBz99AXU.js";
6
+ import { g as U, t as Q, c as X, i as Z, e as B, a as ee, b as te, d as re } from "../experience-instance-Bs9t-zff.js";
7
+ import { f as St } from "../experience-instance-Bs9t-zff.js";
8
8
  import { l as v } from "../logger-C9a75KZn.js";
9
- import { c as A, s as $, l as O } from "../storage-Cb_71y48.js";
9
+ import { c as R, s as $, l as D } from "../storage-Cb_71y48.js";
10
10
  import { a as wt } from "../storage-Cb_71y48.js";
11
11
  import { g as se } from "../id-BW-g3y32.js";
12
12
  import { i as ne } from "../object-JwZ58NOH.js";
13
- import { s as z, a as oe, b as ie, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
13
+ import { s as _, a as oe, b as ie, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
14
14
  import { h as bt, f as It, j as xt, e as Ft, g as Et, i as Pt, k as Rt } from "../supports-BjhuLJ8z.js";
15
15
  const H = I("experience"), ue = w(
16
16
  ({ client: t, experience: e }) => {
17
17
  const r = H.store(e), n = x(r, {
18
- merge(u, h) {
18
+ merge(l, h) {
19
19
  return {
20
- ...u,
20
+ ...l,
21
21
  ...h.experience
22
22
  };
23
23
  }
24
- }), a = r.map((u) => ({
25
- type: u.type,
26
- name: u.name,
27
- decisionLogic: u.decide,
28
- targetSelectors: u.targets
29
- })), l = t.components.listStore.map(
30
- (u) => u.find((h) => h.name === `experience:${e.id}`) || u.find((h) => h.name === "experience"),
24
+ }), c = r.map((l) => ({
25
+ name: l.name,
26
+ decisionLogic: l.decide,
27
+ targetSelectors: l.targets,
28
+ initializeOpenLogic: e.initializeOpen
29
+ })), u = t.components.listStore.map(
30
+ (l) => l.find((h) => h.name === `experience:${e.id}`) || l.find((h) => h.name === "experience"),
31
31
  { skipVoid: !1 }
32
- ), s = r.map((u) => ({
33
- steps: u.steps,
34
- nodes: u.nodes,
35
- edges: u.edges,
36
- conditionals: u.conditionals
32
+ ), s = r.map((l) => ({
33
+ steps: l.steps,
34
+ nodes: l.nodes,
35
+ edges: l.edges,
36
+ conditionals: l.conditionals
37
37
  })), o = e.actions ?? [];
38
38
  return {
39
39
  id: e.id,
40
- configStore: a,
40
+ configStore: c,
41
41
  treeStore: s,
42
- componentStore: l,
42
+ componentStore: u,
43
43
  actions: o,
44
44
  merge: n.merge
45
45
  };
@@ -63,17 +63,17 @@ const de = w(({ client: t }) => {
63
63
  o.merge({ experience: s, strategy: "override" });
64
64
  return;
65
65
  }
66
- const u = le({ client: t, experience: s });
67
- r.register(u);
66
+ const l = le({ client: t, experience: s });
67
+ r.register(l);
68
68
  }
69
- const a = e.map((s) => Object.values(s));
70
- function l(s) {
69
+ const c = e.map((s) => Object.values(s));
70
+ function u(s) {
71
71
  return e.map((o) => o[s], { skipVoid: !1 });
72
72
  }
73
73
  return {
74
74
  register: n,
75
- getById: l,
76
- listStore: a
75
+ getById: u,
76
+ listStore: c
77
77
  };
78
78
  });
79
79
  function pe(t) {
@@ -82,11 +82,11 @@ function pe(t) {
82
82
  const ge = (t, e) => {
83
83
  e.register(t);
84
84
  }, K = (t, e) => {
85
- const { targetSelectors: r } = e.configStore.getState(), n = _(r, e.id);
85
+ const { targetSelectors: r } = e.configStore.getState(), n = U(r, e.id);
86
86
  n.forEach(
87
- ({ elements: l }) => l.forEach((s) => Q(s, e.id))
88
- ), X(n, e.id).forEach((l) => {
89
- t.experienceInstances.spawn(e, l);
87
+ ({ elements: u }) => u.forEach((s) => Q(s, e.id))
88
+ ), X(n, e.id).forEach((u) => {
89
+ t.experienceInstances.spawn(e, u);
90
90
  });
91
91
  }, T = async (t) => {
92
92
  await Promise.all(
@@ -95,13 +95,13 @@ const ge = (t, e) => {
95
95
  })
96
96
  );
97
97
  }, fe = async (t, e) => {
98
- const { type: r, decisionLogic: n, targetSelectors: a } = e.configStore.getState();
99
- return _(a, e.id).length < 1 ? !1 : r === "funnel" ? n ? await R(t, n) === !0 : !1 : a.length === 0 ? !1 : Z(n) ? await R(t, n) === !0 : !0;
98
+ const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
99
+ return U(n, e.id).length < 1 || n.length === 0 ? !1 : r && Z(r) ? await B(t, r) === !0 : !0;
100
100
  }, me = (t, e, r) => {
101
- const n = e.name, a = e.setup(t);
102
- if (a) {
103
- const l = r[n] ?? {};
104
- r[n] = Object.freeze({ ...l, ...a });
101
+ const n = e.name, c = e.setup(t);
102
+ if (c) {
103
+ const u = r[n] ?? {};
104
+ r[n] = Object.freeze({ ...u, ...c });
105
105
  }
106
106
  }, he = I("component"), ye = w(
107
107
  ({ client: t, component: e, name: r }) => {
@@ -133,14 +133,14 @@ const ve = w(({ client: t }) => {
133
133
  const h = Se({ client: t, name: s, component: o });
134
134
  r.register(h);
135
135
  }
136
- const a = e.map((s) => Object.values(s));
137
- function l(s) {
136
+ const c = e.map((s) => Object.values(s));
137
+ function u(s) {
138
138
  return e.map((o) => o[s], { skipVoid: !1 });
139
139
  }
140
140
  return {
141
141
  register: n,
142
- getByName: l,
143
- listStore: a
142
+ getByName: u,
143
+ listStore: c
144
144
  };
145
145
  });
146
146
  function we(t) {
@@ -163,14 +163,14 @@ const V = (t, e, r) => {
163
163
  `Framework '${s}' already registered. Registering again will override the previous registration.`
164
164
  ), r.register({ name: s, framework: o });
165
165
  }
166
- const a = e.map((s) => Object.values(s));
167
- function l(s) {
166
+ const c = e.map((s) => Object.values(s));
167
+ function u(s) {
168
168
  return e.map((o) => o[s], { skipVoid: !1 });
169
169
  }
170
170
  return {
171
171
  register: n,
172
- getByName: l,
173
- listStore: a
172
+ getByName: u,
173
+ listStore: c
174
174
  };
175
175
  });
176
176
  function Ie(t) {
@@ -178,22 +178,22 @@ function Ie(t) {
178
178
  }
179
179
  const xe = (t, e) => {
180
180
  e.register(t.name, t);
181
- }, Fe = 6e3, N = A("last_ping", "global"), Ee = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
181
+ }, Fe = 6e3, N = R("last_ping", "global"), Ee = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
182
182
  try {
183
183
  const e = Date.now(), r = localStorage.getItem(N);
184
184
  if (r && e - parseInt(r) < Fe)
185
185
  return !0;
186
- const n = Ee(t.apiUrl), a = {
186
+ const n = Ee(t.apiUrl), c = {
187
187
  projectId: t.projectId,
188
188
  path: window.location.pathname
189
- }, l = JSON.stringify(a), s = {
189
+ }, u = JSON.stringify(c), s = {
190
190
  "Content-Type": "application/json"
191
- }, o = document.getElementById("picked_script"), u = o == null ? void 0 : o.dataset.verceltoken;
192
- u && (s["x-vercel-protection-bypass"] = u);
191
+ }, o = document.getElementById("picked_script"), l = o == null ? void 0 : o.dataset.verceltoken;
192
+ l && (s["x-vercel-protection-bypass"] = l);
193
193
  const S = (await fetch(n, {
194
194
  method: "POST",
195
195
  headers: s,
196
- body: l
196
+ body: u
197
197
  })).ok;
198
198
  return S && localStorage.setItem(N, e.toString()), S;
199
199
  } catch (e) {
@@ -230,14 +230,14 @@ const Ae = I("predicate"), Be = w(({ client: t }) => {
230
230
  `Predicate '${s}' already registered. Registering again will override the previous registration.`
231
231
  ), r.register(Object.freeze({ name: s, predicate: o }));
232
232
  }
233
- const a = e.map((s) => Object.values(s));
234
- function l(s) {
233
+ const c = e.map((s) => Object.values(s));
234
+ function u(s) {
235
235
  return e.map((o) => o[s], { skipVoid: !1 });
236
236
  }
237
237
  return {
238
238
  register: n,
239
- getByName: l,
240
- listStore: a
239
+ getByName: u,
240
+ listStore: c
241
241
  };
242
242
  });
243
243
  function $e(t) {
@@ -245,16 +245,16 @@ function $e(t) {
245
245
  }
246
246
  const je = (t, e, r) => {
247
247
  r.register(t, e);
248
- }, L = I("feature"), Ce = w(({ client: t }) => {
249
- const e = L.store({}), r = L.store([]), n = x(e, {
250
- register(d, c) {
248
+ }, z = I("feature"), Oe = w(({ client: t }) => {
249
+ const e = z.store({}), r = z.store([]), n = x(e, {
250
+ register(d, a) {
251
251
  return {
252
252
  ...d,
253
- [c.id]: c.feature
253
+ [a.id]: a.feature
254
254
  };
255
255
  }
256
256
  });
257
- function a(d, c) {
257
+ function c(d, a) {
258
258
  e.getState()[d] && v(
259
259
  "warn",
260
260
  `Feature '${d}' already registered. Registering again will override the previous registration.`
@@ -262,7 +262,7 @@ const je = (t, e, r) => {
262
262
  const g = {
263
263
  id: d,
264
264
  feature: {
265
- ...c,
265
+ ...a,
266
266
  id: d
267
267
  }
268
268
  };
@@ -273,24 +273,24 @@ const je = (t, e, r) => {
273
273
  })
274
274
  );
275
275
  }
276
- const l = M(
276
+ const u = M(
277
277
  async ({
278
278
  id: d,
279
- key: c,
279
+ key: a,
280
280
  storage: i = "local"
281
281
  }) => {
282
- const g = A(`feature:${d}:${c}`, "global"), p = (i === "session" ? $ : O).get(g).boolean();
283
- return p ? { id: d, key: c, bucket: p } : null;
282
+ const g = R(`feature:${d}:${a}`, "global"), p = (i === "session" ? $ : D).get(g).boolean();
283
+ return p ? { id: d, key: a, bucket: p } : null;
284
284
  }
285
285
  ), s = M((d) => {
286
286
  if (!d)
287
287
  return null;
288
- const c = A(`feature:${d.id}:${d.key}`, "global");
289
- (d.storage === "session" ? $ : O).set(c, d.bucket);
290
- }), o = /* @__PURE__ */ new Map(), u = J({
288
+ const a = R(`feature:${d.id}:${d.key}`, "global");
289
+ (d.storage === "session" ? $ : D).set(a, d.bucket);
290
+ }), o = /* @__PURE__ */ new Map(), l = J({
291
291
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
292
- effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: c }, { id: i, decide: g, key: f }) => {
293
- const p = c.find((j) => j.id === i);
292
+ effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: a }, { id: i, decide: g, key: f }) => {
293
+ const p = a.find((j) => j.id === i);
294
294
  if (p)
295
295
  return p;
296
296
  const y = d[i];
@@ -301,35 +301,35 @@ const je = (t, e, r) => {
301
301
  const j = await b;
302
302
  return { id: y.id, bucket: j, key: f, storage: y.feature.storage };
303
303
  }
304
- const B = g();
305
- o.set(`${i}:${f}`, B);
306
- const E = await B;
304
+ const A = g();
305
+ o.set(`${i}:${f}`, A);
306
+ const E = await A;
307
307
  return { id: y.id, bucket: E, key: f, storage: y.feature.storage };
308
308
  }
309
309
  });
310
310
  F({
311
311
  clock: n.register,
312
312
  fn: (d) => {
313
- const { id: c, feature: i } = d;
314
- return { id: c, key: i.feature.key, storage: i.feature.storage };
313
+ const { id: a, feature: i } = d;
314
+ return { id: a, key: i.feature.key, storage: i.feature.storage };
315
315
  },
316
- target: l
316
+ target: u
317
317
  }), F({
318
318
  source: e,
319
- clock: u.doneData,
320
- fn: (d, c) => {
319
+ clock: l.doneData,
320
+ fn: (d, a) => {
321
321
  var y;
322
- const { id: i, bucket: g, storage: f } = c, p = (y = d[i]) == null ? void 0 : y.feature.key;
322
+ const { id: i, bucket: g, storage: f } = a, p = (y = d[i]) == null ? void 0 : y.feature.key;
323
323
  return p ? { key: p, id: i, bucket: g, storage: f } : null;
324
324
  },
325
325
  target: s
326
326
  });
327
- const h = C({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
327
+ const h = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
328
328
  ({
329
329
  allFeaturesStore: d,
330
- resolvedFeaturesStore: c
330
+ resolvedFeaturesStore: a
331
331
  }) => Object.values(d).map((i) => {
332
- const g = c.find((f) => f.id === i.id);
332
+ const g = a.find((f) => f.id === i.id);
333
333
  return g ? {
334
334
  id: i.id,
335
335
  name: i.feature.name,
@@ -340,42 +340,42 @@ const je = (t, e, r) => {
340
340
  id: i.id,
341
341
  name: i.feature.name,
342
342
  key: i.feature.key,
343
- getBucket: async () => await u(i.feature),
343
+ getBucket: async () => await l(i.feature),
344
344
  isResolved: !1
345
345
  };
346
346
  })
347
347
  );
348
348
  F({
349
- clock: u.doneData,
349
+ clock: l.doneData,
350
350
  source: { resolvedFeatures: r },
351
- filter: ({ resolvedFeatures: d }, { id: c }) => !d.some((i) => i.id === c),
352
- fn: (d, c) => c,
351
+ filter: ({ resolvedFeatures: d }, { id: a }) => !d.some((i) => i.id === a),
352
+ fn: (d, a) => a,
353
353
  target: t.eventBus.prepend((d) => ({
354
354
  type: "feature_decide",
355
355
  feature: d
356
356
  }))
357
357
  }), F({
358
- clock: [l.doneData, u.doneData],
358
+ clock: [u.doneData, l.doneData],
359
359
  source: r,
360
- fn: (d, c) => !c || d.some((i) => i.id === c.id) ? d : [...d, c],
360
+ fn: (d, a) => !a || d.some((i) => i.id === a.id) ? d : [...d, a],
361
361
  target: r
362
362
  });
363
363
  function S(d) {
364
- return e.map((c) => c[d], { skipVoid: !1 });
364
+ return e.map((a) => a[d], { skipVoid: !1 });
365
365
  }
366
366
  return {
367
- register: a,
367
+ register: c,
368
368
  getByName: S,
369
369
  listStore: h
370
370
  };
371
371
  });
372
- function De(t) {
373
- return k(Ce, t);
372
+ function Ce(t) {
373
+ return k(Oe, t);
374
374
  }
375
- const Oe = (t, e, r) => {
375
+ const De = (t, e, r) => {
376
376
  r.register(t, e);
377
377
  }, P = I("history");
378
- function U(t, e) {
378
+ function L(t, e) {
379
379
  return {
380
380
  // eslint-disable-next-line sonarjs/pseudo-random
381
381
  id: se(`history-entry-${Date.now()}-${Math.random()}}`),
@@ -385,31 +385,31 @@ function U(t, e) {
385
385
  };
386
386
  }
387
387
  const Me = w(() => {
388
- const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), a = P.event();
388
+ const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), c = P.event();
389
389
  t.on(e, (s, o) => ({
390
- entries: [...s.entries, U(o.experienceId, o.node)]
390
+ entries: [...s.entries, L(o.experienceId, o.node)]
391
391
  })), t.on(r, (s, o) => ({
392
392
  entries: [
393
393
  ...s.entries.slice(0, -1),
394
- U(o.experienceId, o.node)
394
+ L(o.experienceId, o.node)
395
395
  ]
396
- })), t.on(a, (s, o) => o);
397
- function l(s, o) {
398
- const u = { lastStepIndex: -1, secondLastStepIndex: -1 };
396
+ })), t.on(c, (s, o) => o);
397
+ function u(s, o) {
398
+ const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
399
399
  for (let h = s.length - 1; h >= 0; h--) {
400
400
  const S = s[h], d = S == null ? void 0 : S.node;
401
401
  if (!(!d || !ee(d)) && !(o && (S == null ? void 0 : S.experienceId) !== o))
402
- if (u.lastStepIndex === -1)
403
- u.lastStepIndex = h;
402
+ if (l.lastStepIndex === -1)
403
+ l.lastStepIndex = h;
404
404
  else {
405
- u.secondLastStepIndex = h;
405
+ l.secondLastStepIndex = h;
406
406
  break;
407
407
  }
408
408
  }
409
- return u;
409
+ return l;
410
410
  }
411
411
  return t.on(n, (s, o) => {
412
- const { secondLastStepIndex: u } = l(s.entries, o.experienceId), h = u !== -1 ? s.entries.slice(0, u + 1) : s.entries;
412
+ const { secondLastStepIndex: l } = u(s.entries, o.experienceId), h = l !== -1 ? s.entries.slice(0, l + 1) : s.entries;
413
413
  return {
414
414
  ...s,
415
415
  entries: h
@@ -418,14 +418,14 @@ const Me = w(() => {
418
418
  push: e,
419
419
  replace: r,
420
420
  back: n,
421
- restore: a,
421
+ restore: c,
422
422
  entriesStore: t.map((s) => s.entries)
423
423
  };
424
424
  });
425
425
  function Te() {
426
426
  return k(Me);
427
427
  }
428
- const Ve = () => D(), Ne = I("field"), Le = w(() => {
428
+ const Ve = () => C(), Ne = I("field"), ze = w(() => {
429
429
  const t = Ne.store({}), e = x(t, {
430
430
  register(s, o) {
431
431
  return {
@@ -438,29 +438,29 @@ const Ve = () => D(), Ne = I("field"), Le = w(() => {
438
438
  e.register({ field: s });
439
439
  }
440
440
  const n = t.map((s) => Object.values(s));
441
- function a(s) {
441
+ function c(s) {
442
442
  return t.map((o) => o[s] || null);
443
443
  }
444
- function l(s) {
445
- return t.map((o) => Object.values(o).find((u) => u.name === s) || null);
444
+ function u(s) {
445
+ return t.map((o) => Object.values(o).find((l) => l.name === s) || null);
446
446
  }
447
447
  return {
448
448
  register: r,
449
- getById: a,
449
+ getById: c,
450
450
  listStore: n,
451
- getByName: l
451
+ getByName: u
452
452
  };
453
453
  });
454
- function Ue() {
455
- return k(Le);
454
+ function Le() {
455
+ return k(ze);
456
456
  }
457
- const _e = (t, e) => {
457
+ const Ue = (t, e) => {
458
458
  e.register(t);
459
- }, ze = I("action"), He = w(() => {
460
- const t = ze.store({}), e = x(t, {
461
- register(l, s) {
459
+ }, _e = I("action"), He = w(() => {
460
+ const t = _e.store({}), e = x(t, {
461
+ register(u, s) {
462
462
  return {
463
- ...l,
463
+ ...u,
464
464
  [s.name]: {
465
465
  name: s.name,
466
466
  action: s.action
@@ -468,16 +468,16 @@ const _e = (t, e) => {
468
468
  };
469
469
  }
470
470
  });
471
- function r(l, s) {
472
- e.register({ name: l, action: s });
471
+ function r(u, s) {
472
+ e.register({ name: u, action: s });
473
473
  }
474
- const n = t.map((l) => Object.values(l));
475
- function a(l) {
476
- return t.map((s) => s[l], { skipVoid: !1 });
474
+ const n = t.map((u) => Object.values(u));
475
+ function c(u) {
476
+ return t.map((s) => s[u], { skipVoid: !1 });
477
477
  }
478
478
  return {
479
479
  register: r,
480
- getByName: a,
480
+ getByName: c,
481
481
  listStore: n
482
482
  };
483
483
  });
@@ -487,34 +487,34 @@ function Ke() {
487
487
  const qe = (t, e, r) => {
488
488
  r.register(t, e);
489
489
  }, Ge = I("response"), We = w(({ client: t }) => {
490
- const e = Ge.store({}), r = D(), n = D(), a = x(e, {
491
- register(c, i) {
490
+ const e = Ge.store({}), r = C(), n = C(), c = x(e, {
491
+ register(a, i) {
492
492
  return {
493
- ...c,
493
+ ...a,
494
494
  [i.fieldId]: i.response
495
495
  };
496
496
  },
497
- registerBatch(c, i) {
497
+ registerBatch(a, i) {
498
498
  return {
499
- ...c,
499
+ ...a,
500
500
  ...i
501
501
  };
502
502
  },
503
- clear(c, i) {
504
- const { [i]: g, ...f } = c;
503
+ clear(a, i) {
504
+ const { [i]: g, ...f } = a;
505
505
  return f;
506
506
  },
507
507
  clearAll() {
508
508
  return {};
509
509
  }
510
510
  });
511
- function l(c, i) {
512
- a.register({ fieldId: c, response: i });
511
+ function u(a, i) {
512
+ c.register({ fieldId: a, response: i });
513
513
  }
514
- async function s(c) {
514
+ async function s(a) {
515
515
  const i = [];
516
516
  return await Promise.allSettled(
517
- Object.entries(c).map(async ([g, f]) => {
517
+ Object.entries(a).map(async ([g, f]) => {
518
518
  let p = f;
519
519
  const y = t.fields.getById(g).getState();
520
520
  if (!y) {
@@ -527,7 +527,7 @@ const qe = (t, e, r) => {
527
527
  return;
528
528
  }
529
529
  if (y.multiple && (typeof p == "string" || typeof p == "number" || typeof p == "boolean") && (p = [p]), y.validation && !ne(y.validation)) {
530
- const b = await R(t, y.validation, {
530
+ const b = await B(t, y.validation, {
531
531
  $input: p
532
532
  });
533
533
  if (typeof b == "string") {
@@ -568,8 +568,8 @@ const qe = (t, e, r) => {
568
568
  return;
569
569
  }
570
570
  if (y.options) {
571
- const b = y.options.map((E) => E.value), B = Array.isArray(p) ? p : [p];
572
- Array.isArray(p) && (B.every((E) => b.includes(E)) || i.push({
571
+ const b = y.options.map((E) => E.value), A = Array.isArray(p) ? p : [p];
572
+ Array.isArray(p) && (A.every((E) => b.includes(E)) || i.push({
573
573
  fieldId: g,
574
574
  userMessage: "This field expects a valid option",
575
575
  systemMessage: `Field expects a valid option. Valid options are: ${b.join(", ")}`,
@@ -577,41 +577,41 @@ const qe = (t, e, r) => {
577
577
  }));
578
578
  }
579
579
  })
580
- ), { responsesToCommit: c, validationErrors: i };
580
+ ), { responsesToCommit: a, validationErrors: i };
581
581
  }
582
- async function o(c) {
583
- const { responsesToCommit: i, validationErrors: g } = await s(c);
584
- return g.length ? { errors: g } : (a.registerBatch(i), { errors: [] });
582
+ async function o(a) {
583
+ const { responsesToCommit: i, validationErrors: g } = await s(a);
584
+ return g.length ? { errors: g } : (c.registerBatch(i), { errors: [] });
585
585
  }
586
- const u = e.map((c) => c), h = e.map((c) => Object.keys(c).map((g) => ({
586
+ const l = e.map((a) => a), h = e.map((a) => Object.keys(a).map((g) => ({
587
587
  fieldId: g,
588
- value: c[g]
588
+ value: a[g]
589
589
  })));
590
- function S(c) {
591
- const i = t.fields.getById(c), g = e.map((f) => f[c] || null);
592
- return C({ f: i, r: g }, ({ f, r: p }) => p || (f != null && f.defaultValue ? f.defaultValue : null));
590
+ function S(a) {
591
+ const i = t.fields.getById(a), g = e.map((f) => f[a] || null);
592
+ return O({ f: i, r: g }, ({ f, r: p }) => p || (f != null && f.defaultValue ? f.defaultValue : null));
593
593
  }
594
- function d(c) {
595
- const i = t.fields.getByName(c);
596
- return C({ f: i, s: e }, ({ f: g, s: f }) => {
594
+ function d(a) {
595
+ const i = t.fields.getByName(a);
596
+ return O({ f: i, s: e }, ({ f: g, s: f }) => {
597
597
  const p = g && f[g.id] || null;
598
598
  return p || (g != null && g.defaultValue ? g.defaultValue : null);
599
599
  });
600
600
  }
601
601
  return F({
602
602
  clock: r,
603
- target: a.clearAll
603
+ target: c.clearAll
604
604
  }), F({
605
605
  clock: n,
606
- target: a.clear
606
+ target: c.clear
607
607
  }), {
608
- register: l,
608
+ register: u,
609
609
  clearAll: r,
610
610
  clear: n,
611
611
  commit: o,
612
612
  getResponsesToCommit: s,
613
613
  listStore: h,
614
- getAllStore: u,
614
+ getAllStore: l,
615
615
  getByFieldId: S,
616
616
  getByFieldName: d
617
617
  };
@@ -619,9 +619,9 @@ const qe = (t, e, r) => {
619
619
  function Ye(t) {
620
620
  return k(We, t);
621
621
  }
622
- const Je = () => "0.0.12-next.4";
622
+ const Je = () => "0.0.12-next.6";
623
623
  function Qe() {
624
- if (z()) {
624
+ if (_()) {
625
625
  const t = [
626
626
  document.currentScript,
627
627
  document.getElementById("picked_script"),
@@ -639,19 +639,19 @@ function Xe() {
639
639
  if (!oe())
640
640
  return {};
641
641
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
642
- for (const [a] of t.entries())
643
- a.startsWith("picked-") && r.add(a);
644
- for (const a of r) {
645
- const l = a.replace("picked-", "");
646
- e[l] = t.getAll(a);
642
+ for (const [c] of t.entries())
643
+ c.startsWith("picked-") && r.add(c);
644
+ for (const c of r) {
645
+ const u = c.replace("picked-", "");
646
+ e[u] = t.getAll(c);
647
647
  }
648
- const n = A("s");
648
+ const n = R("s");
649
649
  if (r.size > 0)
650
650
  $.set(n, e);
651
651
  else {
652
- const a = $.get(n);
653
- if (a)
654
- return a.json() || {};
652
+ const c = $.get(n);
653
+ if (c)
654
+ return c.json() || {};
655
655
  }
656
656
  return e;
657
657
  }
@@ -663,9 +663,9 @@ function Ze() {
663
663
  }
664
664
  const et = () => ({
665
665
  id: Ze()
666
- }), tt = A("session", "global"), rt = () => {
666
+ }), tt = R("session", "global"), rt = () => {
667
667
  if (!ie()) return null;
668
- const t = O.get(tt);
668
+ const t = D.get(tt);
669
669
  let e = t.isSet() ? t.json() : null;
670
670
  return e || (e = et(), t.set(e)), e;
671
671
  }, st = () => rt();
@@ -687,15 +687,15 @@ class q {
687
687
  m(this, "experiences", pe({ client: this }));
688
688
  m(this, "frameworks", Ie({ client: this }));
689
689
  m(this, "predicates", $e({ client: this }));
690
- m(this, "features", De({ client: this }));
690
+ m(this, "features", Ce({ client: this }));
691
691
  m(this, "responses", Ye({ client: this }));
692
- m(this, "fields", Ue());
692
+ m(this, "fields", Le());
693
693
  m(this, "actions", Ke());
694
694
  v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Qe(), this.session = st(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.eventBus({ type: "initialized", version: Je() }), v("info", "Picked client initialized.");
695
695
  }
696
696
  start() {
697
697
  Pe(this), (async () => {
698
- z() && (document.body && T(this), await re(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
698
+ _() && (document.body && T(this), await re(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
699
699
  })();
700
700
  }
701
701
  registerFramework(e) {
@@ -708,13 +708,13 @@ class q {
708
708
  me(this, e, this.plugins);
709
709
  }
710
710
  registerFeature(e, r) {
711
- Oe(e, r, this.features);
711
+ De(e, r, this.features);
712
712
  }
713
713
  registerPredicate(e, r) {
714
714
  je(e, r, this.predicates);
715
715
  }
716
716
  registerField(e) {
717
- _e(e, this.fields);
717
+ Ue(e, this.fields);
718
718
  }
719
719
  registerAction(e, r) {
720
720
  qe(e, r, this.actions);
@@ -746,14 +746,14 @@ class q {
746
746
  var e;
747
747
  (e = this.options.plugins) == null || e.forEach((r) => {
748
748
  if (Array.isArray(r)) {
749
- r.forEach((a) => {
750
- this.registerPlugin(a);
749
+ r.forEach((c) => {
750
+ this.registerPlugin(c);
751
751
  });
752
752
  return;
753
753
  }
754
754
  const n = typeof r == "function" ? r() : r;
755
755
  if (Array.isArray(n)) {
756
- n.forEach((a) => this.registerPlugin(a));
756
+ n.forEach((c) => this.registerPlugin(c));
757
757
  return;
758
758
  }
759
759
  this.registerPlugin(n);
@@ -762,20 +762,20 @@ class q {
762
762
  setupFeatures() {
763
763
  const e = this.options.features;
764
764
  e && (Object.entries(e).forEach(([r, n]) => {
765
- const a = typeof n == "function" ? n() : n;
766
- this.registerFeature(r, a);
765
+ const c = typeof n == "function" ? n() : n;
766
+ this.registerFeature(r, c);
767
767
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
768
768
  try {
769
- const [n, a] = r.split(":");
770
- if (!n || !a)
769
+ const [n, c] = r.split(":");
770
+ if (!n || !c)
771
771
  return;
772
- let l = a;
773
- l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(n, {
774
- key: `${l}`,
772
+ let u = c;
773
+ u === "true" && (u = !0), u === "false" && (u = !1), this.registerFeature(n, {
774
+ key: `${u}`,
775
775
  // use the assigned bucket value as the key
776
776
  name: n,
777
777
  // eslint-disable-next-line sonarjs/function-return-type
778
- decide: () => l,
778
+ decide: () => u,
779
779
  storage: "session"
780
780
  });
781
781
  } catch {
@@ -817,13 +817,13 @@ function nt(t) {
817
817
  async function ft(t, e) {
818
818
  return e.length === 0 || !nt(e) ? e : (await Promise.all(
819
819
  e.map(async (n) => {
820
- if (!(n.condition ? await R(t, n.condition) : !0))
820
+ if (!(n.condition ? await B(t, n.condition) : !0))
821
821
  return null;
822
822
  if (!n.options || !G(n))
823
823
  return n;
824
824
  const s = (await Promise.all(
825
- n.options.map(async (u) => u.condition ? await R(t, u.condition) ? u : null : u)
826
- )).filter((u) => u !== null);
825
+ n.options.map(async (l) => l.condition ? await B(t, l.condition) ? l : null : l)
826
+ )).filter((l) => l !== null);
827
827
  return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
828
828
  })
829
829
  )).filter((n) => n !== null);
@@ -835,16 +835,16 @@ const mt = (t) => {
835
835
  export {
836
836
  q as Picked,
837
837
  mt as createClient,
838
- A as createStorageKey,
839
- R as evaluateRuleLogic,
838
+ R as createStorageKey,
839
+ B as evaluateRuleLogic,
840
840
  ft as getStepFields,
841
841
  St as isPickedRoot,
842
- O as localStore,
842
+ D as localStore,
843
843
  $ as sessionStore,
844
844
  wt as subscribe,
845
845
  bt as supportsCookies,
846
846
  ae as supportsCryptoRandomUUID,
847
- z as supportsDocument,
847
+ _ as supportsDocument,
848
848
  It as supportsHistory,
849
849
  xt as supportsIntersectionObserver,
850
850
  ie as supportsLocalStorage,