@picked/client 0.0.1-dev.1765906219520 → 0.0.1-dev.1765907257168

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,204 +1,204 @@
1
- var X = Object.defineProperty;
2
- var Y = (t, e, r) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var h = (t, e, r) => Y(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { createDomain as b, createApi as F, createEffect as V, attach as J, sample as x, combine as O, createEvent as z } from "effector";
5
- import { createFactory as w, invoke as I } from "@withease/factories";
6
- import { g as G, t as Q, c as Z, i as ee, e as j, a as te, b as re, d as ne } from "../experience-instance-C4INDX6a.js";
7
- import { f as Ft } from "../experience-instance-C4INDX6a.js";
8
- import { l as k } from "../logger-C9a75KZn.js";
9
- import { c as A, l as C, s as $ } from "../storage-BLmAhfhl.js";
10
- import { a as xt } from "../storage-BLmAhfhl.js";
1
+ var Y = Object.defineProperty;
2
+ var J = (t, e, r) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var m = (t, e, r) => J(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { createDomain as b, createApi as F, createEffect as M, attach as Q, sample as x, combine as z, createEvent as C } from "effector";
5
+ import { createFactory as k, invoke as w } from "@withease/factories";
6
+ import { g as G, t as X, c as Z, i as ee, e as E, a as te, b as re, d as ne } from "../experience-instance-C4INDX6a.js";
7
+ import { f as It } from "../experience-instance-C4INDX6a.js";
8
+ import { l as S } from "../logger-C9a75KZn.js";
9
+ import { c as R, l as $, s as O } from "../storage-BLmAhfhl.js";
10
+ import { a as Ft } from "../storage-BLmAhfhl.js";
11
11
  import { g as se } from "../id-BW-g3y32.js";
12
12
  import { i as ie } from "../object-JwZ58NOH.js";
13
13
  import { s as D, a as U, b as oe, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
14
- import { h as Pt, f as Rt, j as At, e as Bt, g as Ct, i as $t, k as Ot } from "../supports-BjhuLJ8z.js";
15
- const H = b("experience"), ue = w(
14
+ import { h as Et, f as jt, j as Pt, e as Rt, g as Bt, i as At, k as $t } from "../supports-BjhuLJ8z.js";
15
+ const H = b("experience"), ue = k(
16
16
  ({ client: t, experience: e }) => {
17
- const r = H.store(e), i = F(r, {
18
- merge(l, g) {
17
+ const r = H.store(e), n = F(r, {
18
+ merge(d, h) {
19
19
  return {
20
- ...l,
21
- ...g.experience
20
+ ...d,
21
+ ...h.experience
22
22
  };
23
23
  }
24
- }), s = r.map((l) => ({
25
- name: l.name,
26
- decisionLogic: l.condition ?? l.decide,
27
- targetSelectors: l.targets,
24
+ }), i = r.map((d) => ({
25
+ name: d.name,
26
+ decisionLogic: d.condition ?? d.decide,
27
+ targetSelectors: d.targets,
28
28
  initializeOpenLogic: e.initializeOpen
29
29
  })), a = t.components.listStore.map(
30
- (l) => l.find((g) => g.name === `experience:${e.id}`) || l.find((g) => g.name === "experience"),
30
+ (d) => d.find((h) => h.name === `experience:${e.id}`) || d.find((h) => h.name === "experience"),
31
31
  { skipVoid: !1 }
32
- ), n = r.map((l) => ({
33
- steps: l.steps,
34
- nodes: l.nodes,
35
- edges: l.edges,
36
- conditionals: l.conditionals
32
+ ), s = r.map((d) => ({
33
+ steps: d.steps,
34
+ nodes: d.nodes,
35
+ edges: d.edges,
36
+ conditionals: d.conditionals
37
37
  })), o = e.actions ?? [];
38
38
  return {
39
39
  id: e.id,
40
- configStore: s,
41
- treeStore: n,
40
+ configStore: i,
41
+ treeStore: s,
42
42
  componentStore: a,
43
43
  actions: o,
44
- merge: i.merge
44
+ merge: n.merge
45
45
  };
46
46
  }
47
47
  );
48
48
  function de(t) {
49
- return I(ue, t);
49
+ return w(ue, t);
50
50
  }
51
- const le = w(({ client: t }) => {
51
+ const le = k(({ client: t }) => {
52
52
  const e = H.store({}), r = F(e, {
53
- register(n, o) {
53
+ register(s, o) {
54
54
  return {
55
- ...n,
55
+ ...s,
56
56
  [o.id]: o
57
57
  };
58
58
  }
59
59
  });
60
- function i(n) {
61
- const o = e.getState()[n.id];
60
+ function n(s) {
61
+ const o = e.getState()[s.id];
62
62
  if (o) {
63
- o.merge({ experience: n, strategy: "override" });
63
+ o.merge({ experience: s, strategy: "override" });
64
64
  return;
65
65
  }
66
- const l = de({ client: t, experience: n });
67
- r.register(l);
66
+ const d = de({ client: t, experience: s });
67
+ r.register(d);
68
68
  }
69
- const s = e.map((n) => Object.values(n));
70
- function a(n) {
71
- return e.map((o) => o[n], { skipVoid: !1 });
69
+ const i = e.map((s) => Object.values(s));
70
+ function a(s) {
71
+ return e.map((o) => o[s], { skipVoid: !1 });
72
72
  }
73
73
  return {
74
- register: i,
74
+ register: n,
75
75
  getById: a,
76
- listStore: s
76
+ listStore: i
77
77
  };
78
78
  });
79
79
  function pe(t) {
80
- return I(le, t);
80
+ return w(le, t);
81
81
  }
82
- const fe = (t, e) => {
82
+ const ge = (t, e) => {
83
83
  e.register(t);
84
84
  }, q = (t, e) => {
85
- const { targetSelectors: r } = e.configStore.getState(), i = G(r, e.id);
86
- i.forEach(
87
- ({ elements: a }) => a.forEach((n) => Q(n, e.id))
88
- ), Z(i, e.id).forEach((a) => {
85
+ const { targetSelectors: r } = e.configStore.getState(), n = G(r, e.id);
86
+ n.forEach(
87
+ ({ elements: a }) => a.forEach((s) => X(s, e.id))
88
+ ), Z(n, e.id).forEach((a) => {
89
89
  t.experienceInstances.spawn(e, a);
90
90
  });
91
- }, M = async (t) => {
91
+ }, T = async (t) => {
92
92
  await Promise.all(
93
93
  t.experiences.listStore.getState().map(async (e) => {
94
- await ge(t, e) && q(t, e);
94
+ await fe(t, e) && q(t, e);
95
95
  })
96
96
  );
97
- }, ge = async (t, e) => {
98
- const { decisionLogic: r, targetSelectors: i } = e.configStore.getState();
99
- return G(i, e.id).length < 1 || i.length === 0 ? !1 : r && ee(r) ? await j(t, r) === !0 : !0;
97
+ }, fe = async (t, e) => {
98
+ const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
99
+ return G(n, e.id).length < 1 || n.length === 0 ? !1 : r && ee(r) ? await E(t, r) === !0 : !0;
100
100
  }, me = (t, e, r) => {
101
- const i = e.name, s = e.setup(t);
102
- if (s) {
103
- const a = r[i] ?? {};
104
- r[i] = Object.freeze({ ...a, ...s });
101
+ const n = e.name, i = e.setup(t);
102
+ if (i) {
103
+ const a = r[n] ?? {};
104
+ r[n] = Object.freeze({ ...a, ...i });
105
105
  }
106
- }, he = b("component"), ye = w(
106
+ }, he = b("component"), ye = k(
107
107
  ({ client: t, component: e, name: r }) => {
108
- const i = t.frameworks.getByName(e.frameworkName);
108
+ const n = t.frameworks.getByName(e.frameworkName);
109
109
  return {
110
110
  name: r,
111
111
  component: e,
112
- frameworkStore: i
112
+ frameworkStore: n
113
113
  };
114
114
  }
115
115
  );
116
116
  function ve(t) {
117
- return I(ye, t);
117
+ return w(ye, t);
118
118
  }
119
- const Se = w(({ client: t }) => {
119
+ const Se = k(({ client: t }) => {
120
120
  const e = he.store({}), r = F(e, {
121
- register(n, o) {
121
+ register(s, o) {
122
122
  return {
123
- ...n,
123
+ ...s,
124
124
  [o.name]: o
125
125
  };
126
126
  }
127
127
  });
128
- function i(n, o) {
129
- e.getState()[n] && k(
128
+ function n(s, o) {
129
+ e.getState()[s] && S(
130
130
  "warn",
131
- `Component '${n}' already registered. Registering again will override the previous registration.`
131
+ `Component '${s}' already registered. Registering again will override the previous registration.`
132
132
  );
133
- const g = ve({ client: t, name: n, component: o });
134
- r.register(g);
133
+ const h = ve({ client: t, name: s, component: o });
134
+ r.register(h);
135
135
  }
136
- const s = e.map((n) => Object.values(n));
137
- function a(n) {
138
- return e.map((o) => o[n], { skipVoid: !1 });
136
+ const i = e.map((s) => Object.values(s));
137
+ function a(s) {
138
+ return e.map((o) => o[s], { skipVoid: !1 });
139
139
  }
140
140
  return {
141
- register: i,
141
+ register: n,
142
142
  getByName: a,
143
- listStore: s
143
+ listStore: i
144
144
  };
145
145
  });
146
146
  function ke(t) {
147
- return I(Se, t);
147
+ return w(Se, t);
148
148
  }
149
- const T = (t, e, r) => {
149
+ const V = (t, e, r) => {
150
150
  r.register(t, e);
151
- }, we = b("framework"), Ie = w(({ client: t }) => {
151
+ }, we = b("framework"), Ie = k(({ client: t }) => {
152
152
  const e = we.store({}), r = F(e, {
153
- register(n, o) {
153
+ register(s, o) {
154
154
  return {
155
- ...n,
155
+ ...s,
156
156
  [o.name]: o.framework
157
157
  };
158
158
  }
159
159
  });
160
- function i(n, o) {
161
- e.getState()[n] && k(
160
+ function n(s, o) {
161
+ e.getState()[s] && S(
162
162
  "warn",
163
- `Framework '${n}' already registered. Registering again will override the previous registration.`
164
- ), r.register({ name: n, framework: o });
163
+ `Framework '${s}' already registered. Registering again will override the previous registration.`
164
+ ), r.register({ name: s, framework: o });
165
165
  }
166
- const s = e.map((n) => Object.values(n));
167
- function a(n) {
168
- return e.map((o) => o[n], { skipVoid: !1 });
166
+ const i = e.map((s) => Object.values(s));
167
+ function a(s) {
168
+ return e.map((o) => o[s], { skipVoid: !1 });
169
169
  }
170
170
  return {
171
- register: i,
171
+ register: n,
172
172
  getByName: a,
173
- listStore: s
173
+ listStore: i
174
174
  };
175
175
  });
176
176
  function be(t) {
177
- return I(Ie, t);
177
+ return w(Ie, t);
178
178
  }
179
179
  const Fe = (t, e) => {
180
180
  e.register(t.name, t);
181
- }, Ee = 6e3, xe = A("last_ping", "global"), je = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
181
+ }, xe = 6e3, Ee = R("last_ping", "global"), je = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
182
182
  try {
183
- const e = Date.now(), r = C.get(xe);
184
- let i = 0;
185
- if (r.isSet() && (i = r.json() ?? 0), i && e - i < Ee)
183
+ const e = Date.now(), r = $.get(Ee);
184
+ let n = 0;
185
+ if (r.isSet() && (n = r.json() ?? 0), n && e - n < xe)
186
186
  return !0;
187
- const s = je(t.apiUrl), a = {
187
+ const i = je(t.apiUrl), a = {
188
188
  projectId: t.projectId,
189
189
  path: window.location.pathname
190
- }, n = JSON.stringify(a), o = {
190
+ }, s = JSON.stringify(a), o = {
191
191
  "Content-Type": "application/json"
192
- }, l = document.getElementById("picked_script"), g = l == null ? void 0 : l.dataset.verceltoken;
193
- g && (o["x-vercel-protection-bypass"] = g);
194
- const c = (await fetch(s, {
192
+ }, d = document.getElementById("picked_script"), h = d == null ? void 0 : d.dataset.verceltoken;
193
+ h && (o["x-vercel-protection-bypass"] = h);
194
+ const l = (await fetch(i, {
195
195
  method: "POST",
196
196
  headers: o,
197
- body: n
197
+ body: s
198
198
  })).ok;
199
- return c && r.set(e), c;
199
+ return l && r.set(e), l;
200
200
  } catch (e) {
201
- return k("error", e), !1;
201
+ return S("error", e), !1;
202
202
  }
203
203
  };
204
204
  function Re(t) {
@@ -213,11 +213,11 @@ function Re(t) {
213
213
  };
214
214
  return Object.freeze(r);
215
215
  }
216
- const Ae = b("predicate"), Be = w(({ client: t }) => {
217
- const e = Ae.store({}), r = F(e, {
218
- register(n, o) {
216
+ const Be = b("predicate"), Ae = k(({ client: t }) => {
217
+ const e = Be.store({}), r = F(e, {
218
+ register(s, o) {
219
219
  return {
220
- ...n,
220
+ ...s,
221
221
  [o.name]: {
222
222
  name: o.name,
223
223
  predicate: o.predicate
@@ -225,166 +225,166 @@ const Ae = b("predicate"), Be = w(({ client: t }) => {
225
225
  };
226
226
  }
227
227
  });
228
- function i(n, o) {
229
- e.getState()[n] && k(
228
+ function n(s, o) {
229
+ e.getState()[s] && S(
230
230
  "warn",
231
- `Predicate '${n}' already registered. Registering again will override the previous registration.`
232
- ), r.register(Object.freeze({ name: n, predicate: o }));
231
+ `Predicate '${s}' already registered. Registering again will override the previous registration.`
232
+ ), r.register(Object.freeze({ name: s, predicate: o }));
233
233
  }
234
- const s = e.map((n) => Object.values(n));
235
- function a(n) {
236
- return e.map((o) => o[n], { skipVoid: !1 });
234
+ const i = e.map((s) => Object.values(s));
235
+ function a(s) {
236
+ return e.map((o) => o[s], { skipVoid: !1 });
237
237
  }
238
238
  return {
239
- register: i,
239
+ register: n,
240
240
  getByName: a,
241
- listStore: s
241
+ listStore: i
242
242
  };
243
243
  });
244
- function Ce(t) {
245
- return I(Be, t);
244
+ function $e(t) {
245
+ return w(Ae, t);
246
246
  }
247
- const $e = (t, e, r) => {
247
+ const Oe = (t, e, r) => {
248
248
  r.register(t, e);
249
- }, _ = b("feature"), Oe = w(({ client: t }) => {
250
- const e = _.store({}), r = _.store([]), i = F(e, {
251
- register(c, d) {
249
+ }, N = b("feature"), ze = k(({ client: t }) => {
250
+ const e = N.store({}), r = N.store([]), n = F(e, {
251
+ register(l, u) {
252
252
  return {
253
- ...c,
254
- [d.id]: d.feature
253
+ ...l,
254
+ [u.id]: u.feature
255
255
  };
256
256
  }
257
257
  });
258
- function s(c, d) {
259
- e.getState()[c] && k(
258
+ function i(l, u) {
259
+ e.getState()[l] && S(
260
260
  "warn",
261
- `Feature '${c}' already registered. Registering again will override the previous registration.`
261
+ `Feature '${l}' already registered. Registering again will override the previous registration.`
262
262
  );
263
263
  const p = {
264
- id: c,
264
+ id: l,
265
265
  feature: {
266
- ...d,
267
- id: c
266
+ ...u,
267
+ id: l
268
268
  }
269
269
  };
270
- i.register(
270
+ n.register(
271
271
  Object.freeze({
272
- id: c,
272
+ id: l,
273
273
  feature: p
274
274
  })
275
275
  );
276
276
  }
277
- const a = V(
277
+ const a = M(
278
278
  async ({
279
- id: c,
280
- key: d,
281
- storage: u = "local"
279
+ id: l,
280
+ key: u,
281
+ storage: c = "local"
282
282
  }) => {
283
- const p = A(`feature:${c}:${d}`, "global"), f = (u === "session" ? $ : C).get(p).boolean();
284
- return f === null ? null : { id: c, key: d, bucket: f, storage: u };
283
+ const p = R(`feature:${l}:${u}`, "global"), g = (c === "session" ? O : $).get(p).boolean();
284
+ return g === null ? null : { id: l, key: u, bucket: g, storage: c };
285
285
  }
286
- ), n = V((c) => {
287
- if (!c)
286
+ ), s = M((l) => {
287
+ if (!l)
288
288
  return null;
289
- const d = A(`feature:${c.id}:${c.key}`, "global");
290
- (c.storage === "session" ? $ : C).set(d, c.bucket);
291
- }), o = /* @__PURE__ */ new Map(), l = J({
289
+ const u = R(`feature:${l.id}:${l.key}`, "global");
290
+ (l.storage === "session" ? O : $).set(u, l.bucket);
291
+ }), o = /* @__PURE__ */ new Map(), d = Q({
292
292
  source: { allFeaturesStore: e, resolvedFeaturesStore: r },
293
- effect: async ({ allFeaturesStore: c, resolvedFeaturesStore: d }, { id: u, decide: p, key: m }) => {
294
- const f = d.find(
295
- (B) => B.id === u && B.key === m
293
+ effect: async ({ allFeaturesStore: l, resolvedFeaturesStore: u }, { id: c, decide: p, key: f }) => {
294
+ const g = u.find(
295
+ (A) => A.id === c && A.key === f
296
296
  );
297
- if (f)
298
- return f;
299
- const y = c[u];
297
+ if (g)
298
+ return g;
299
+ const y = l[c];
300
300
  if (!y)
301
- throw new Error(`Feature with id '${u}' not found`);
302
- const S = o.get(`${u}:${m}`);
303
- if (S !== void 0) {
304
- const B = await S;
305
- return { id: y.id, bucket: B, key: m, storage: y.feature.storage };
301
+ throw new Error(`Feature with id '${c}' not found`);
302
+ const I = o.get(`${c}:${f}`);
303
+ if (I !== void 0) {
304
+ const A = await I;
305
+ return { id: y.id, bucket: A, key: f, storage: y.feature.storage };
306
306
  }
307
- const E = p();
308
- o.set(`${u}:${m}`, E);
309
- const P = await E;
310
- return { id: y.id, bucket: P, key: m, storage: y.feature.storage };
307
+ const B = p();
308
+ o.set(`${c}:${f}`, B);
309
+ const j = await B;
310
+ return { id: y.id, bucket: j, key: f, storage: y.feature.storage };
311
311
  }
312
312
  });
313
313
  x({
314
- clock: i.register,
315
- fn: (c) => {
316
- const { id: d, feature: u } = c;
317
- return { id: d, key: u.feature.key, storage: u.feature.storage };
314
+ clock: n.register,
315
+ fn: (l) => {
316
+ const { id: u, feature: c } = l;
317
+ return { id: u, key: c.feature.key, storage: c.feature.storage };
318
318
  },
319
319
  target: a
320
320
  }), x({
321
321
  source: e,
322
- clock: l.doneData,
323
- fn: (c, d) => {
322
+ clock: d.doneData,
323
+ fn: (l, u) => {
324
324
  var y;
325
- const { id: u, bucket: p, storage: m } = d, f = (y = c[u]) == null ? void 0 : y.feature.key;
326
- return f ? { key: f, id: u, bucket: p, storage: m } : null;
325
+ const { id: c, bucket: p, storage: f } = u, g = (y = l[c]) == null ? void 0 : y.feature.key;
326
+ return g ? { key: g, id: c, bucket: p, storage: f } : null;
327
327
  },
328
- target: n
328
+ target: s
329
329
  });
330
- const g = O({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
330
+ const h = z({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
331
331
  ({
332
- allFeaturesStore: c,
333
- resolvedFeaturesStore: d
334
- }) => Object.values(c).map((u) => {
335
- const p = d.find(
336
- (m) => m.id === u.id && m.key === u.feature.key
332
+ allFeaturesStore: l,
333
+ resolvedFeaturesStore: u
334
+ }) => Object.values(l).map((c) => {
335
+ const p = u.find(
336
+ (f) => f.id === c.id && f.key === c.feature.key
337
337
  );
338
338
  return p ? {
339
- id: u.id,
340
- name: u.feature.name,
341
- key: u.feature.key,
342
- getBucket: () => ({ id: u.id, bucket: p.bucket }),
339
+ id: c.id,
340
+ name: c.feature.name,
341
+ key: c.feature.key,
342
+ getBucket: () => ({ id: c.id, bucket: p.bucket }),
343
343
  isResolved: !0
344
344
  } : {
345
- id: u.id,
346
- name: u.feature.name,
347
- key: u.feature.key,
348
- getBucket: async () => await l(u.feature),
345
+ id: c.id,
346
+ name: c.feature.name,
347
+ key: c.feature.key,
348
+ getBucket: async () => await d(c.feature),
349
349
  isResolved: !1
350
350
  };
351
351
  })
352
352
  );
353
353
  x({
354
- clock: l.doneData,
354
+ clock: d.doneData,
355
355
  source: { resolvedFeatures: r },
356
- filter: ({ resolvedFeatures: c }, { id: d, key: u }) => !c.some(
357
- (m) => m.id === d && m.key === u
356
+ filter: ({ resolvedFeatures: l }, { id: u, key: c }) => !l.some(
357
+ (f) => f.id === u && f.key === c
358
358
  ),
359
- fn: (c, d) => d,
360
- target: t.eventBus.prepend((c) => ({
359
+ fn: (l, u) => u,
360
+ target: t.eventBus.prepend((l) => ({
361
361
  type: "feature_decide",
362
- feature: c
362
+ feature: l
363
363
  }))
364
364
  }), x({
365
- clock: [a.doneData, l.doneData],
365
+ clock: [a.doneData, d.doneData],
366
366
  source: r,
367
- fn: (c, d) => !d || c.some(
368
- (p) => p.id === d.id && p.key === d.key
369
- ) ? c : [...c, d],
367
+ fn: (l, u) => !u || l.some(
368
+ (p) => p.id === u.id && p.key === u.key
369
+ ) ? l : [...l, u],
370
370
  target: r
371
371
  });
372
- function v(c) {
373
- return e.map((d) => d[c], { skipVoid: !1 });
372
+ function v(l) {
373
+ return e.map((u) => u[l], { skipVoid: !1 });
374
374
  }
375
375
  return {
376
- register: s,
376
+ register: i,
377
377
  getByName: v,
378
- listStore: g
378
+ listStore: h
379
379
  };
380
380
  });
381
- function ze(t) {
382
- return I(Oe, t);
381
+ function Ce(t) {
382
+ return w(ze, t);
383
383
  }
384
384
  const De = (t, e, r) => {
385
385
  r.register(t, e);
386
- }, R = b("history");
387
- function L(t, e) {
386
+ }, P = b("history");
387
+ function _(t, e) {
388
388
  return {
389
389
  // eslint-disable-next-line sonarjs/pseudo-random
390
390
  id: se(`history-entry-${Date.now()}-${Math.random()}}`),
@@ -393,247 +393,247 @@ function L(t, e) {
393
393
  experienceId: t
394
394
  };
395
395
  }
396
- const Ue = w(() => {
397
- const t = R.store({ entries: [] }), e = R.event(), r = R.event(), i = R.event(), s = R.event();
398
- t.on(e, (n, o) => ({
399
- entries: [...n.entries, L(o.experienceId, o.node)]
400
- })), t.on(r, (n, o) => ({
396
+ const Ue = k(() => {
397
+ const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), i = P.event();
398
+ t.on(e, (s, o) => ({
399
+ entries: [...s.entries, _(o.experienceId, o.node)]
400
+ })), t.on(r, (s, o) => ({
401
401
  entries: [
402
- ...n.entries.slice(0, -1),
403
- L(o.experienceId, o.node)
402
+ ...s.entries.slice(0, -1),
403
+ _(o.experienceId, o.node)
404
404
  ]
405
- })), t.on(s, (n, o) => o);
406
- function a(n, o) {
407
- const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
408
- for (let g = n.length - 1; g >= 0; g--) {
409
- const v = n[g], c = v == null ? void 0 : v.node;
410
- if (!(!c || !te(c)) && !(o && (v == null ? void 0 : v.experienceId) !== o))
411
- if (l.lastStepIndex === -1)
412
- l.lastStepIndex = g;
405
+ })), t.on(i, (s, o) => o);
406
+ function a(s, o) {
407
+ const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
408
+ for (let h = s.length - 1; h >= 0; h--) {
409
+ const v = s[h], l = v == null ? void 0 : v.node;
410
+ if (!(!l || !te(l)) && !(o && (v == null ? void 0 : v.experienceId) !== o))
411
+ if (d.lastStepIndex === -1)
412
+ d.lastStepIndex = h;
413
413
  else {
414
- l.secondLastStepIndex = g;
414
+ d.secondLastStepIndex = h;
415
415
  break;
416
416
  }
417
417
  }
418
- return l;
418
+ return d;
419
419
  }
420
- return t.on(i, (n, o) => {
421
- const { secondLastStepIndex: l } = a(n.entries, o.experienceId), g = l !== -1 ? n.entries.slice(0, l + 1) : n.entries;
420
+ return t.on(n, (s, o) => {
421
+ const { secondLastStepIndex: d } = a(s.entries, o.experienceId), h = d !== -1 ? s.entries.slice(0, d + 1) : s.entries;
422
422
  return {
423
- ...n,
424
- entries: g
423
+ ...s,
424
+ entries: h
425
425
  };
426
426
  }), {
427
427
  push: e,
428
428
  replace: r,
429
- back: i,
430
- restore: s,
431
- entriesStore: t.map((n) => n.entries)
429
+ back: n,
430
+ restore: i,
431
+ entriesStore: t.map((s) => s.entries)
432
432
  };
433
433
  });
434
- function Ve() {
435
- return I(Ue);
434
+ function Me() {
435
+ return w(Ue);
436
436
  }
437
- const Me = () => z(), Te = b("field"), _e = w(() => {
438
- const t = Te.store({}), e = F(t, {
439
- register(n, o) {
437
+ const Te = () => C(), Ve = b("field"), Ne = k(() => {
438
+ const t = Ve.store({}), e = F(t, {
439
+ register(s, o) {
440
440
  return {
441
- ...n,
441
+ ...s,
442
442
  [o.field.id]: o.field
443
443
  };
444
444
  }
445
445
  });
446
- function r(n) {
447
- e.register({ field: n });
446
+ function r(s) {
447
+ e.register({ field: s });
448
448
  }
449
- const i = t.map((n) => Object.values(n));
450
- function s(n) {
451
- return t.map((o) => o[n] || null);
449
+ const n = t.map((s) => Object.values(s));
450
+ function i(s) {
451
+ return t.map((o) => o[s] || null);
452
452
  }
453
- function a(n) {
454
- return t.map((o) => Object.values(o).find((l) => l.name === n) || null);
453
+ function a(s) {
454
+ return t.map((o) => Object.values(o).find((d) => d.name === s) || null);
455
455
  }
456
456
  return {
457
457
  register: r,
458
- getById: s,
459
- listStore: i,
458
+ getById: i,
459
+ listStore: n,
460
460
  getByName: a
461
461
  };
462
462
  });
463
- function Le() {
464
- return I(_e);
463
+ function _e() {
464
+ return w(Ne);
465
465
  }
466
- const Ne = (t, e) => {
466
+ const Le = (t, e) => {
467
467
  e.register(t);
468
- }, Ge = b("action"), He = w(() => {
468
+ }, Ge = b("action"), He = k(() => {
469
469
  const t = Ge.store({}), e = F(t, {
470
- register(a, n) {
470
+ register(a, s) {
471
471
  return {
472
472
  ...a,
473
- [n.name]: {
474
- name: n.name,
475
- action: n.action
473
+ [s.name]: {
474
+ name: s.name,
475
+ action: s.action
476
476
  }
477
477
  };
478
478
  }
479
479
  });
480
- function r(a, n) {
481
- e.register({ name: a, action: n });
480
+ function r(a, s) {
481
+ e.register({ name: a, action: s });
482
482
  }
483
- const i = t.map((a) => Object.values(a));
484
- function s(a) {
485
- return t.map((n) => n[a], { skipVoid: !1 });
483
+ const n = t.map((a) => Object.values(a));
484
+ function i(a) {
485
+ return t.map((s) => s[a], { skipVoid: !1 });
486
486
  }
487
487
  return {
488
488
  register: r,
489
- getByName: s,
490
- listStore: i
489
+ getByName: i,
490
+ listStore: n
491
491
  };
492
492
  });
493
493
  function qe() {
494
- return I(He);
494
+ return w(He);
495
495
  }
496
496
  const Ke = (t, e, r) => {
497
497
  r.register(t, e);
498
498
  };
499
- function N(t) {
499
+ function L(t) {
500
500
  return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
501
501
  }
502
- const We = b("response"), Xe = w(({ client: t }) => {
503
- const e = We.store({}), r = z(), i = z(), s = F(e, {
504
- register(d, u) {
502
+ const We = b("response"), Ye = k(({ client: t }) => {
503
+ const e = We.store({}), r = C(), n = C(), i = F(e, {
504
+ register(u, c) {
505
505
  return {
506
- ...d,
507
- [u.fieldId]: u.response
506
+ ...u,
507
+ [c.fieldId]: c.response
508
508
  };
509
509
  },
510
- registerBatch(d, u) {
510
+ registerBatch(u, c) {
511
511
  return {
512
- ...d,
513
- ...u
512
+ ...u,
513
+ ...c
514
514
  };
515
515
  },
516
- clear(d, u) {
517
- const { [u]: p, ...m } = d;
518
- return m;
516
+ clear(u, c) {
517
+ const { [c]: p, ...f } = u;
518
+ return f;
519
519
  },
520
520
  clearAll() {
521
521
  return {};
522
522
  }
523
523
  });
524
- function a(d, u) {
525
- s.register({ fieldId: d, response: u });
524
+ function a(u, c) {
525
+ i.register({ fieldId: u, response: c });
526
526
  }
527
- async function n(d) {
528
- const u = [];
527
+ async function s(u) {
528
+ const c = [];
529
529
  return await Promise.allSettled(
530
- Object.entries(d).map(async ([p, m]) => {
531
- let f = m;
530
+ Object.entries(u).map(async ([p, f]) => {
531
+ let g = f;
532
532
  const y = t.fields.getById(p).getState();
533
533
  if (!y) {
534
- u.push({
534
+ c.push({
535
535
  fieldId: p,
536
536
  userMessage: `Field '${p}' not found`,
537
537
  systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
538
- value: f
538
+ value: g
539
539
  });
540
540
  return;
541
541
  }
542
- if (y.multiple && (typeof f == "string" || typeof f == "number" || typeof f == "boolean") && (f = [f]), y.validation && !ie(y.validation) && !N(f)) {
543
- const S = await j(t, y.validation, {
544
- $input: f
542
+ if (y.multiple && (typeof g == "string" || typeof g == "number" || typeof g == "boolean") && (g = [g]), y.validation && !ie(y.validation) && !L(g)) {
543
+ const I = await E(t, y.validation, {
544
+ $input: g
545
545
  });
546
- if (typeof S == "string") {
547
- u.push({
546
+ if (typeof I == "string") {
547
+ c.push({
548
548
  fieldId: p,
549
- userMessage: S,
550
- systemMessage: `Field validation resulted in an error: ${S}.`,
551
- value: f
549
+ userMessage: I,
550
+ systemMessage: `Field validation resulted in an error: ${I}.`,
551
+ value: g
552
552
  });
553
553
  return;
554
554
  }
555
- if (S === !1) {
556
- u.push({
555
+ if (I === !1) {
556
+ c.push({
557
557
  fieldId: p,
558
558
  userMessage: "This field is invalid",
559
559
  systemMessage: "Field validation resulted in an unspecified error.",
560
- value: f
560
+ value: g
561
561
  });
562
562
  return;
563
563
  }
564
564
  }
565
- if (y.required && N(f)) {
566
- u.push({
565
+ if (y.required && L(g)) {
566
+ c.push({
567
567
  fieldId: p,
568
568
  userMessage: "This field is required",
569
569
  systemMessage: "Field is required.",
570
- value: f
570
+ value: g
571
571
  });
572
572
  return;
573
573
  }
574
- if (!y.multiple && Array.isArray(f) && f.length > 1) {
575
- u.push({
574
+ if (!y.multiple && Array.isArray(g) && g.length > 1) {
575
+ c.push({
576
576
  fieldId: p,
577
577
  userMessage: "This field expects a single response",
578
578
  systemMessage: "Field expects a single response.",
579
- value: f
579
+ value: g
580
580
  });
581
581
  return;
582
582
  }
583
583
  if (y.options) {
584
- const S = y.options.map((P) => P.value), E = Array.isArray(f) ? f : [f];
585
- Array.isArray(f) && (E.every((P) => S.includes(P)) || u.push({
584
+ const I = y.options.map((j) => j.value), B = Array.isArray(g) ? g : [g];
585
+ Array.isArray(g) && (B.every((j) => I.includes(j)) || c.push({
586
586
  fieldId: p,
587
587
  userMessage: "This field expects a valid option",
588
- systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
589
- value: f
588
+ systemMessage: `Field expects a valid option. Valid options are: ${I.join(", ")}`,
589
+ value: g
590
590
  }));
591
591
  }
592
592
  })
593
- ), { responsesToCommit: d, validationErrors: u };
593
+ ), { responsesToCommit: u, validationErrors: c };
594
594
  }
595
- async function o(d) {
596
- const { responsesToCommit: u, validationErrors: p } = await n(d);
597
- return p.length ? { errors: p } : (s.registerBatch(u), { errors: [] });
595
+ async function o(u) {
596
+ const { responsesToCommit: c, validationErrors: p } = await s(u);
597
+ return p.length ? { errors: p } : (i.registerBatch(c), { errors: [] });
598
598
  }
599
- const l = e.map((d) => d), g = e.map((d) => Object.keys(d).map((p) => ({
599
+ const d = e.map((u) => u), h = e.map((u) => Object.keys(u).map((p) => ({
600
600
  fieldId: p,
601
- value: d[p]
601
+ value: u[p]
602
602
  })));
603
- function v(d) {
604
- const u = t.fields.getById(d), p = e.map((m) => m[d] || null);
605
- return O({ f: u, r: p }, ({ f: m, r: f }) => f || (m != null && m.defaultValue ? m.defaultValue : null));
606
- }
607
- function c(d) {
608
- const u = t.fields.getByName(d);
609
- return O({ f: u, s: e }, ({ f: p, s: m }) => {
610
- const f = p && m[p.id] || null;
611
- return f || (p != null && p.defaultValue ? p.defaultValue : null);
603
+ function v(u) {
604
+ const c = t.fields.getById(u), p = e.map((f) => f[u] || null);
605
+ return z({ f: c, r: p }, ({ f, r: g }) => g || (f != null && f.defaultValue ? f.defaultValue : null));
606
+ }
607
+ function l(u) {
608
+ const c = t.fields.getByName(u);
609
+ return z({ f: c, s: e }, ({ f: p, s: f }) => {
610
+ const g = p && f[p.id] || null;
611
+ return g || (p != null && p.defaultValue ? p.defaultValue : null);
612
612
  });
613
613
  }
614
614
  return x({
615
615
  clock: r,
616
- target: s.clearAll
616
+ target: i.clearAll
617
617
  }), x({
618
- clock: i,
619
- target: s.clear
618
+ clock: n,
619
+ target: i.clear
620
620
  }), {
621
621
  register: a,
622
622
  clearAll: r,
623
- clear: i,
623
+ clear: n,
624
624
  commit: o,
625
- getResponsesToCommit: n,
626
- listStore: g,
627
- getAllStore: l,
625
+ getResponsesToCommit: s,
626
+ listStore: h,
627
+ getAllStore: d,
628
628
  getByFieldId: v,
629
- getByFieldName: c
629
+ getByFieldName: l
630
630
  };
631
631
  });
632
- function Ye(t) {
633
- return I(Xe, t);
632
+ function Je(t) {
633
+ return w(Ye, t);
634
634
  }
635
- const Je = () => "0.0.1-dev.1765906219520";
636
- function Qe() {
635
+ const Qe = () => "0.0.1-dev.1765907257168";
636
+ function Xe() {
637
637
  if (D()) {
638
638
  const t = [
639
639
  document.currentScript,
@@ -652,53 +652,53 @@ function Ze() {
652
652
  if (!U())
653
653
  return {};
654
654
  const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
655
- for (const [s] of t.entries())
656
- s.startsWith("picked-") && r.add(s);
657
- for (const s of r) {
658
- const a = s.replace("picked-", "");
659
- e[a] = t.getAll(s);
655
+ for (const [i] of t.entries())
656
+ i.startsWith("picked-") && r.add(i);
657
+ for (const i of r) {
658
+ const a = i.replace("picked-", "");
659
+ e[a] = t.getAll(i);
660
660
  }
661
- const i = A("s");
661
+ const n = R("s");
662
662
  if (r.size > 0)
663
- $.set(i, e);
663
+ O.set(n, e);
664
664
  else {
665
- const s = $.get(i);
666
- if (s)
667
- return s.json() || {};
665
+ const i = O.get(n);
666
+ if (i)
667
+ return i.json() || {};
668
668
  }
669
669
  return e;
670
670
  }
671
671
  function et() {
672
672
  if (ae())
673
673
  return crypto.randomUUID();
674
- const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), i = Math.random().toString(36).substring(2, 15);
675
- return `${t}-${e}-${r}-${i}`;
674
+ 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);
675
+ return `${t}-${e}-${r}-${n}`;
676
676
  }
677
- const tt = A("session", "global"), rt = () => {
678
- const t = C.get(tt);
677
+ const tt = R("session", "global"), rt = () => {
678
+ const t = $.get(tt);
679
679
  let e;
680
680
  t.isSet() && (e = t.json());
681
- const r = (s) => t.set({
682
- id: s.id,
683
- isUser: s.isUser,
684
- identifiers: s.identifiers
685
- }), i = {
681
+ const r = (i) => t.set({
682
+ id: i.id,
683
+ isUser: i.isUser,
684
+ identifiers: i.identifiers
685
+ }), n = {
686
686
  id: (e == null ? void 0 : e.id) ?? et(),
687
687
  isUser: (e == null ? void 0 : e.isUser) ?? void 0,
688
688
  identifiers: (e == null ? void 0 : e.identifiers) ?? void 0,
689
- setIsUser(s) {
690
- this.isUser = s, r(this);
689
+ setIsUser(i) {
690
+ this.isUser = i, r(this);
691
691
  },
692
- setIdentifier(s, a) {
693
- this.identifiers = { ...this.identifiers, [s]: a }, r(this);
692
+ setIdentifier(i, a) {
693
+ this.identifiers = { ...this.identifiers, [i]: a }, r(this);
694
694
  },
695
- removeIdentifier(s) {
695
+ removeIdentifier(i) {
696
696
  this.identifiers && (this.identifiers = Object.fromEntries(
697
- Object.entries(this.identifiers).filter(([a]) => a !== s)
697
+ Object.entries(this.identifiers).filter(([a]) => a !== i)
698
698
  ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
699
699
  }
700
700
  };
701
- return r(i), i;
701
+ return r(n), n;
702
702
  }, nt = () => oe() ? rt() : null;
703
703
  function st() {
704
704
  if (U())
@@ -724,12 +724,12 @@ function at(t) {
724
724
  const { organizationId: e, projectId: r } = t;
725
725
  if (e && r)
726
726
  return { organizationId: e, projectId: r };
727
- const i = it();
727
+ const n = it();
728
+ if (n)
729
+ return n;
730
+ const i = ot();
728
731
  if (i)
729
732
  return i;
730
- const s = ot();
731
- if (s)
732
- return s;
733
733
  throw new Error(
734
734
  `organizationId and projectId are required. You can provide them via one of:
735
735
  (1) createClient({ organizationId, projectId }) options;
@@ -739,53 +739,53 @@ function at(t) {
739
739
  }
740
740
  class K {
741
741
  constructor(e) {
742
- h(this, "options");
743
- h(this, "isReady", !1);
744
- h(this, "project");
745
- h(this, "plugins", {});
746
- h(this, "eventBus", Me());
747
- h(this, "organizationId");
748
- h(this, "projectId");
749
- h(this, "apiUrl");
750
- h(this, "session");
751
- h(this, "precondition");
752
- h(this, "condition");
753
- h(this, "searchParams", Ze());
754
- h(this, "history", Ve());
755
- h(this, "components", ke({ client: this }));
756
- h(this, "experienceInstances", re({ client: this }));
757
- h(this, "experiences", pe({ client: this }));
758
- h(this, "frameworks", be({ client: this }));
759
- h(this, "predicates", Ce({ client: this }));
760
- h(this, "features", ze({ client: this }));
761
- h(this, "responses", Ye({ client: this }));
762
- h(this, "fields", Le());
763
- h(this, "actions", qe());
764
- k("info", "Picked client initializing.");
765
- const { organizationId: r, projectId: i } = at(e);
766
- this.organizationId = r, this.projectId = i, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Qe(), this.session = nt(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Je() }), k("info", "Picked client initialized.");
742
+ m(this, "options");
743
+ m(this, "isReady", !1);
744
+ m(this, "project");
745
+ m(this, "plugins", {});
746
+ m(this, "eventBus", Te());
747
+ m(this, "organizationId");
748
+ m(this, "projectId");
749
+ m(this, "apiUrl");
750
+ m(this, "session");
751
+ m(this, "precondition");
752
+ m(this, "condition");
753
+ m(this, "searchParams", Ze());
754
+ m(this, "history", Me());
755
+ m(this, "components", ke({ client: this }));
756
+ m(this, "experienceInstances", re({ client: this }));
757
+ m(this, "experiences", pe({ client: this }));
758
+ m(this, "frameworks", be({ client: this }));
759
+ m(this, "predicates", $e({ client: this }));
760
+ m(this, "features", Ce({ client: this }));
761
+ m(this, "responses", Je({ client: this }));
762
+ m(this, "fields", _e());
763
+ m(this, "actions", qe());
764
+ S("info", "Picked client initializing.");
765
+ const { organizationId: r, projectId: n } = at(e);
766
+ this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Xe(), this.session = nt(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Qe() }), S("info", "Picked client initialized.");
767
767
  }
768
768
  start() {
769
769
  Pe(this), (async () => {
770
770
  if (!D())
771
771
  return;
772
772
  let r;
773
- typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await j(this, this.precondition) === !0;
774
- let i;
775
- r && (this.condition === void 0 ? i = !0 : typeof this.condition == "boolean" ? i = this.condition : i = await j(this, this.condition) === !0);
776
- const s = r && i === !0;
777
- if (typeof i == "boolean" && this.session) {
778
- const a = i;
773
+ typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
774
+ let n;
775
+ r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await E(this, this.condition) === !0);
776
+ const i = r && n === !0;
777
+ if (typeof n == "boolean" && this.session) {
778
+ const a = n;
779
779
  this.session.setIsUser(a), this.eventBus({ type: "user_decide", value: a });
780
780
  }
781
- this.eventBus({ type: "initialize" }), document.body && s && M(this), await ne(), s && M(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
781
+ this.eventBus({ type: "initialize" }), document.body && i && T(this), await ne(), i && T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
782
782
  })();
783
783
  }
784
784
  registerFramework(e) {
785
785
  Fe(e, this.frameworks);
786
786
  }
787
787
  registerComponent(e, r) {
788
- T(e, r, this.components);
788
+ V(e, r, this.components);
789
789
  }
790
790
  registerPlugin(e) {
791
791
  me(this, e, this.plugins);
@@ -794,16 +794,16 @@ class K {
794
794
  De(e, r, this.features);
795
795
  }
796
796
  registerPredicate(e, r) {
797
- $e(e, r, this.predicates);
797
+ Oe(e, r, this.predicates);
798
798
  }
799
799
  registerField(e) {
800
- Ne(e, this.fields);
800
+ Le(e, this.fields);
801
801
  }
802
802
  registerAction(e, r) {
803
803
  Ke(e, r, this.actions);
804
804
  }
805
805
  registerExperience(e) {
806
- e.component && T(`experience:${e.id}`, e.component, this.components), fe(e, this.experiences);
806
+ e.component && V(`experience:${e.id}`, e.component, this.components), ge(e, this.experiences);
807
807
  }
808
808
  getStateSnapshot() {
809
809
  return Re(this);
@@ -811,7 +811,7 @@ class K {
811
811
  async launchExperienceById(e) {
812
812
  const r = this.experiences.getById(e).getState();
813
813
  if (!r) {
814
- k("warn", `Experience with id '${e}' not found.`);
814
+ S("warn", `Experience with id '${e}' not found.`);
815
815
  return;
816
816
  }
817
817
  q(this, r);
@@ -829,34 +829,34 @@ class K {
829
829
  var e;
830
830
  (e = this.options.plugins) == null || e.forEach((r) => {
831
831
  if (Array.isArray(r)) {
832
- r.forEach((s) => {
833
- this.registerPlugin(s);
832
+ r.forEach((i) => {
833
+ this.registerPlugin(i);
834
834
  });
835
835
  return;
836
836
  }
837
- const i = typeof r == "function" ? r() : r;
838
- if (Array.isArray(i)) {
839
- i.forEach((s) => this.registerPlugin(s));
837
+ const n = typeof r == "function" ? r() : r;
838
+ if (Array.isArray(n)) {
839
+ n.forEach((i) => this.registerPlugin(i));
840
840
  return;
841
841
  }
842
- this.registerPlugin(i);
842
+ this.registerPlugin(n);
843
843
  });
844
844
  }
845
845
  setupFeatures() {
846
846
  const e = this.options.features;
847
- e && (Object.entries(e).forEach(([r, i]) => {
848
- const s = typeof i == "function" ? i() : i;
849
- this.registerFeature(r, s);
847
+ e && (Object.entries(e).forEach(([r, n]) => {
848
+ const i = typeof n == "function" ? n() : n;
849
+ this.registerFeature(r, i);
850
850
  }), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
851
851
  try {
852
- const [i, s] = r.split(":");
853
- if (!i || !s)
852
+ const [n, i] = r.split(":");
853
+ if (!n || !i)
854
854
  return;
855
- let a = s;
856
- a === "true" && (a = !0), a === "false" && (a = !1), this.registerFeature(i, {
855
+ let a = i;
856
+ a === "true" && (a = !0), a === "false" && (a = !1), this.registerFeature(n, {
857
857
  key: `${a}`,
858
858
  // use the assigned bucket value as the key
859
- name: i,
859
+ name: n,
860
860
  // eslint-disable-next-line sonarjs/function-return-type
861
861
  decide: () => a,
862
862
  storage: "session"
@@ -867,131 +867,74 @@ class K {
867
867
  }
868
868
  setupPredicates() {
869
869
  const e = this.options.predicates;
870
- e && Object.entries(e).forEach(([r, i]) => {
871
- if (typeof i != "function") {
872
- k("warn", `Predicate "${r}" is not a function.`);
870
+ e && Object.entries(e).forEach(([r, n]) => {
871
+ if (typeof n != "function") {
872
+ S("warn", `Predicate "${r}" is not a function.`);
873
873
  return;
874
874
  }
875
- this.registerPredicate(r, i);
875
+ this.registerPredicate(r, n);
876
876
  });
877
877
  }
878
878
  setupActions() {
879
879
  const e = this.options.actions;
880
- e && Object.entries(e).forEach(([r, i]) => {
881
- if (typeof i != "function") {
882
- k("warn", `Action "${r}" is not a function.`);
880
+ e && Object.entries(e).forEach(([r, n]) => {
881
+ if (typeof n != "function") {
882
+ S("warn", `Action "${r}" is not a function.`);
883
883
  return;
884
884
  }
885
- this.registerAction(r, i);
885
+ this.registerAction(r, n);
886
886
  });
887
887
  }
888
888
  getPluginConfig(e) {
889
889
  return this.plugins[e] ?? {};
890
890
  }
891
891
  }
892
- h(K, "logger", k);
893
- function ct(t, e) {
894
- const r = (
895
- // eslint-disable-next-line sonarjs/slow-regex
896
- /\{\{\s*(?<key>[^|}]+?)\s*(?<params>(?:\|\|\s*(?:default|case):\s*.*?)*?)\s*\}\}/g
897
- ), i = /default:\s*(?<default>[^|]*)/, s = /case:\s*(?<case>[^|]*)/;
898
- return t.replaceAll(
899
- r,
900
- (a, n, o) => {
901
- var d, u, p, m;
902
- const l = n == null ? void 0 : n.trim(), g = (u = (d = o == null ? void 0 : o.match(i)) == null ? void 0 : d[1]) == null ? void 0 : u.trim();
903
- if (!l)
904
- return g ?? "";
905
- let c = e[l] ?? g ?? a;
906
- if (typeof c == "string" && c !== a) {
907
- const f = (m = (p = o == null ? void 0 : o.match(s)) == null ? void 0 : p[1]) == null ? void 0 : m.trim(), y = f == null ? void 0 : f.toLowerCase();
908
- if (!y)
909
- return c;
910
- switch (y) {
911
- case "upper":
912
- c = c.toUpperCase();
913
- break;
914
- case "lower":
915
- c = c.toLowerCase();
916
- break;
917
- case "title":
918
- c = c.replaceAll(
919
- /\w\S*/g,
920
- (S) => {
921
- var E;
922
- return S.length > 0 ? ((E = S[0]) == null ? void 0 : E.toUpperCase()) + S.slice(1).toLowerCase() : S;
923
- }
924
- );
925
- break;
926
- }
927
- }
928
- return String(c);
929
- }
930
- );
931
- }
892
+ m(K, "logger", S);
932
893
  function W(t) {
933
894
  var e;
934
895
  return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
935
896
  }
936
- function ut(t) {
897
+ function ct(t) {
937
898
  return t.some((e) => e.condition || W(e));
938
899
  }
939
- function dt(t, e) {
940
- const { responses: r, fields: i } = t;
941
- return e.map((s) => {
942
- let a = s.label;
943
- return a = ct(
944
- a,
945
- r.listStore.getState().reduce((n, o) => {
946
- var g, v;
947
- const l = i.getById(o.fieldId).getState();
948
- return o.value !== void 0 && (typeof o.value == "string" || typeof o.value == "number") && (n[o.fieldId] = ((v = (g = l == null ? void 0 : l.options) == null ? void 0 : g.find((c) => c.value === o.value)) == null ? void 0 : v.label) ?? o.value), n;
949
- }, {})
950
- ), {
951
- ...s,
952
- label: a
953
- };
954
- });
955
- }
956
- async function kt(t, e) {
957
- const r = dt(t, e);
958
- return r.length === 0 || !ut(r) ? r : (await Promise.all(
959
- r.map(async (s) => {
960
- if (!(s.condition ? await j(t, s.condition) : !0))
900
+ async function vt(t, e) {
901
+ return e.length === 0 || !ct(e) ? e : (await Promise.all(
902
+ e.map(async (n) => {
903
+ if (!(n.condition ? await E(t, n.condition) : !0))
961
904
  return null;
962
- if (!s.options || !W(s))
963
- return s;
964
- const o = (await Promise.all(
965
- s.options.map(async (g) => g.condition ? await j(t, g.condition) ? g : null : g)
966
- )).filter((g) => g !== null);
967
- return o.length === s.options.length ? s : o.length === 0 ? null : { ...s, options: o };
905
+ if (!n.options || !W(n))
906
+ return n;
907
+ const s = (await Promise.all(
908
+ n.options.map(async (d) => d.condition ? await E(t, d.condition) ? d : null : d)
909
+ )).filter((d) => d !== null);
910
+ return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
968
911
  })
969
- )).filter((s) => s !== null);
912
+ )).filter((n) => n !== null);
970
913
  }
971
- const wt = (t) => {
914
+ const St = (t) => {
972
915
  const e = new K(t);
973
916
  return ce(e), e;
974
917
  };
975
918
  export {
976
919
  K as Picked,
977
- wt as createClient,
978
- A as createStorageKey,
979
- j as evaluateRuleLogic,
920
+ St as createClient,
921
+ R as createStorageKey,
922
+ E as evaluateRuleLogic,
980
923
  st as getPickedConfig,
981
- kt as getStepFields,
982
- Ft as isPickedRoot,
983
- C as localStore,
984
- $ as sessionStore,
985
- xt as subscribe,
986
- Pt as supportsCookies,
924
+ vt as getStepFields,
925
+ It as isPickedRoot,
926
+ $ as localStore,
927
+ O as sessionStore,
928
+ Ft as subscribe,
929
+ Et as supportsCookies,
987
930
  ae as supportsCryptoRandomUUID,
988
931
  D as supportsDocument,
989
- Rt as supportsHistory,
990
- At as supportsIntersectionObserver,
932
+ jt as supportsHistory,
933
+ Pt as supportsIntersectionObserver,
991
934
  oe as supportsLocalStorage,
992
- Bt as supportsLocation,
993
- Ct as supportsSessionStorage,
994
- $t as supportsShadowRoot,
995
- Ot as supportsWebComponents,
935
+ Rt as supportsLocation,
936
+ Bt as supportsSessionStorage,
937
+ At as supportsShadowRoot,
938
+ $t as supportsWebComponents,
996
939
  U as supportsWindow
997
940
  };