@picked/client 0.0.1-dev.1764710808992 → 0.0.1-dev.1764728988965

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