@picked/client 0.0.12-next.13 → 0.0.12-next.2

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