@picked/client 0.0.1-dev.1767922288295 → 0.0.1-dev.1767932013788

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