@picked/client 0.0.1-dev.1777601813342 → 0.0.1-dev.1777611471601

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 (65) hide show
  1. package/dist/{api-BAOO2VZv.cjs → api-CP_eIRW2.cjs} +1 -1
  2. package/dist/{api-CiR56vZg.js → api-UYfzBUGT.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dom-observer/index.js +1 -0
  7. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  8. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  11. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  12. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  13. package/dist/cjs/plugins/web-components/index.js +1 -1
  14. package/dist/cjs/plugins/window-object/index.js +1 -1
  15. package/dist/cjs/server/index.js +1 -1
  16. package/dist/esm/form/index.js +1 -1
  17. package/dist/esm/index.js +178 -177
  18. package/dist/esm/plugins/create-experience/index.js +1 -1
  19. package/dist/esm/plugins/dom-observer/index.js +58 -0
  20. package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
  21. package/dist/esm/plugins/experience-browser-storage/index.js +3 -3
  22. package/dist/esm/plugins/history-browser-storage/index.js +2 -2
  23. package/dist/esm/plugins/responses-browser-storage/index.js +2 -2
  24. package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
  25. package/dist/esm/plugins/single-page-app/index.js +25 -93
  26. package/dist/esm/plugins/web-components/index.js +2 -2
  27. package/dist/esm/plugins/window-object/index.js +1 -1
  28. package/dist/esm/server/index.js +1 -1
  29. package/dist/{experience-DOWnsvA1.cjs → experience-BhteyYBl.cjs} +1 -1
  30. package/dist/{experience-CR19HpPg.js → experience-CoMdlvyn.js} +3 -3
  31. package/dist/{experience-instance-C2jZU8ho.cjs → experience-instance-CZDcicPj.cjs} +1 -1
  32. package/dist/{experience-instance-CGLdwg--.js → experience-instance-IkIw31Cg.js} +15 -28
  33. package/dist/{nodes-Bmzx3TP_.js → nodes-ChVU1VZO.js} +7 -7
  34. package/dist/{nodes-Dx9bxj35.cjs → nodes-DDDs-rC2.cjs} +1 -1
  35. package/dist/object-C82v79xc.js +25 -0
  36. package/dist/object-CUJOjanb.cjs +1 -0
  37. package/dist/rules-logic-BTIxfrJJ.js +240 -0
  38. package/dist/rules-logic-DNLOv90w.cjs +1 -0
  39. package/dist/{supports-DUJbucFW.js → supports-0XIfd4-R.js} +9 -18
  40. package/dist/supports-Dsjg-82e.cjs +1 -0
  41. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  42. package/dist/types/entities/framework/framework.d.ts +0 -12
  43. package/dist/types/entities/framework/framework.d.ts.map +1 -1
  44. package/dist/types/plugins/dom-observer/index.d.ts +3 -0
  45. package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
  46. package/dist/types/plugins/dom-observer/plugin.d.ts +37 -0
  47. package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
  48. package/dist/types/plugins/single-page-app/index.d.ts +1 -2
  49. package/dist/types/plugins/single-page-app/index.d.ts.map +1 -1
  50. package/dist/types/plugins/single-page-app/plugin.d.ts +9 -92
  51. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  52. package/dist/types/utils/global-obj.d.ts +0 -5
  53. package/dist/types/utils/global-obj.d.ts.map +1 -1
  54. package/dist/types/utils/supports.d.ts +0 -113
  55. package/dist/types/utils/supports.d.ts.map +1 -1
  56. package/package.json +11 -1
  57. package/dist/rules-logic-CvILqbhz.js +0 -266
  58. package/dist/rules-logic-DV5SUr5M.cjs +0 -1
  59. package/dist/supports-DFDQ6eJO.cjs +0 -1
  60. /package/dist/{id-n2yrHvNo.js → id-B-N2zNbS.js} +0 -0
  61. /package/dist/{id-Cg7fVl1O.cjs → id-Bbodazn8.cjs} +0 -0
  62. /package/dist/{logger-C44jSdYl.js → logger-6z_gb4rA.js} +0 -0
  63. /package/dist/{logger-CJUj90QX.cjs → logger-fbvQC40v.cjs} +0 -0
  64. /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
  65. /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,14 +1,15 @@
1
- import { r as e, t } from "../rules-logic-CvILqbhz.js";
2
- import { t as n } from "../logger-C44jSdYl.js";
3
- import { a as r, c as i, d as a, f as o, i as s, l as c, m as l, n as u, o as d, r as f, s as p, t as m, u as h } from "../supports-DUJbucFW.js";
4
- import { a as g, c as _, u as ee } from "../nodes-Bmzx3TP_.js";
5
- import { n as v, t as te } from "../experience-CR19HpPg.js";
6
- import { i as ne, n as y, r as b, t as x } from "../storage-6Xk0uAxB.js";
7
- import { n as S, r as C } from "../api-CiR56vZg.js";
8
- import { n as re } from "../experience-instance-CGLdwg--.js";
9
- import { t as ie } from "../id-n2yrHvNo.js";
10
- import { attach as w, combine as T, createApi as E, createDomain as D, createEffect as O, createEvent as k, createStore as A, sample as j } from "effector";
11
- import { createFactory as M, invoke as N } from "@withease/factories";
1
+ import { t as e } from "../rules-logic-BTIxfrJJ.js";
2
+ import { t } from "../object-C82v79xc.js";
3
+ import { t as n } from "../logger-6z_gb4rA.js";
4
+ import { a as r, c as i, d as a, i as o, l as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "../supports-0XIfd4-R.js";
5
+ import { a as h, c as g, u as _ } from "../nodes-ChVU1VZO.js";
6
+ import { n as v, t as ee } from "../experience-CoMdlvyn.js";
7
+ import { i as te, n as y, r as b, t as x } from "../storage-hOHCCXvP.js";
8
+ import { n as ne, r as re } from "../api-UYfzBUGT.js";
9
+ import { n as ie } from "../experience-instance-IkIw31Cg.js";
10
+ import { t as S } from "../id-B-N2zNbS.js";
11
+ import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
12
+ import { createFactory as j, invoke as M } from "@withease/factories";
12
13
  //#region src/entities/plugin/plugin.ts
13
14
  var ae = (e, t, n) => {
14
15
  let r = t.name, i = t.setup(e);
@@ -19,16 +20,16 @@ var ae = (e, t, n) => {
19
20
  ...i
20
21
  });
21
22
  }
22
- }, oe = D("component"), se = M(({ client: e, component: t, name: n }) => ({
23
+ }, oe = E("component"), se = j(({ client: e, component: t, name: n }) => ({
23
24
  name: n,
24
25
  component: t,
25
26
  frameworkStore: e.frameworks.getByName(t.frameworkName)
26
27
  }));
27
28
  function ce(e) {
28
- return N(se, e);
29
+ return M(se, e);
29
30
  }
30
- var le = M(({ client: e }) => {
31
- let t = oe.store({}), n = E(t, { register(e, t) {
31
+ var le = j(({ client: e }) => {
32
+ let t = oe.store({}), n = T(t, { register(e, t) {
32
33
  return {
33
34
  ...e,
34
35
  [t.name]: t
@@ -54,12 +55,12 @@ var le = M(({ client: e }) => {
54
55
  };
55
56
  });
56
57
  function ue(e) {
57
- return N(le, e);
58
+ return M(le, e);
58
59
  }
59
- var P = (e, t, n) => {
60
+ var N = (e, t, n) => {
60
61
  n.register(e, t);
61
- }, F = D("framework"), I = M(({ client: e }) => {
62
- let t = F.store({}), n = E(t, { register(e, t) {
62
+ }, P = E("framework"), F = j(({ client: e }) => {
63
+ let t = P.store({}), n = T(t, { register(e, t) {
63
64
  return {
64
65
  ...e,
65
66
  [t.name]: t.framework
@@ -81,21 +82,21 @@ var P = (e, t, n) => {
81
82
  listStore: i
82
83
  };
83
84
  });
84
- function L(e) {
85
- return N(I, e);
85
+ function I(e) {
86
+ return M(F, e);
86
87
  }
87
- var R = (e, t) => {
88
+ var L = (e, t) => {
88
89
  t.register(e.name, e);
89
- }, z = 6e3, B = x("last_ping", "global"), V = async (e) => {
90
+ }, R = 6e3, z = x("last_ping", "global"), B = async (e) => {
90
91
  try {
91
- let t = Date.now(), n = y.get(B), r = 0;
92
- if (n.isSet() && (r = n.json() ?? 0), r && t - r < z) return !0;
92
+ let t = Date.now(), n = y.get(z), r = 0;
93
+ if (n.isSet() && (r = n.json() ?? 0), r && t - r < R) return !0;
93
94
  let i = {
94
95
  projectId: e.projectId,
95
96
  path: window.location.pathname
96
97
  }, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
97
98
  o && (a["x-vercel-protection-bypass"] = o);
98
- let s = (await S(e.apiUrl, "ping", i, a)).ok;
99
+ let s = (await ne(e.apiUrl, "ping", i, a)).ok;
99
100
  return s && n.set(t), s;
100
101
  } catch {
101
102
  return !1;
@@ -103,7 +104,7 @@ var R = (e, t) => {
103
104
  };
104
105
  //#endregion
105
106
  //#region src/utils/state-snaphot.ts
106
- function H(e) {
107
+ function V(e) {
107
108
  let t = typeof window < "u", n = {
108
109
  client: e,
109
110
  responses: e.responses.listStore.getState(),
@@ -117,8 +118,8 @@ function H(e) {
117
118
  }
118
119
  //#endregion
119
120
  //#region src/entities/predicate/predicate.ts
120
- var U = D("predicate"), de = M(({ client: e }) => {
121
- let t = U.store({}), n = E(t, { register(e, t) {
121
+ var H = E("predicate"), U = j(({ client: e }) => {
122
+ let t = H.store({}), n = T(t, { register(e, t) {
122
123
  return {
123
124
  ...e,
124
125
  [t.name]: {
@@ -138,22 +139,22 @@ var U = D("predicate"), de = M(({ client: e }) => {
138
139
  return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
139
140
  }
140
141
  function o(t) {
141
- let n = A(() => void 0, { skipVoid: !1 }), r = O(async () => {
142
+ let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
142
143
  let n = a(t).getState();
143
144
  if (!n) return;
144
- let r = H(e);
145
+ let r = V(e);
145
146
  return (...e) => n({
146
147
  ...r,
147
148
  args: e
148
149
  });
149
150
  });
150
- return j({
151
+ return A({
151
152
  source: {
152
153
  responses: e.responses.listStore,
153
154
  fields: e.fields.listStore
154
155
  },
155
156
  target: r
156
- }), j({
157
+ }), A({
157
158
  clock: r.doneData,
158
159
  filter: (e) => e !== void 0,
159
160
  target: n
@@ -166,13 +167,13 @@ var U = D("predicate"), de = M(({ client: e }) => {
166
167
  getEvokablePredicate: o
167
168
  };
168
169
  });
169
- function fe(e) {
170
- return N(de, e);
170
+ function de(e) {
171
+ return M(U, e);
171
172
  }
172
- var pe = (e, t, n) => {
173
+ var fe = (e, t, n) => {
173
174
  n.register(e, t);
174
- }, W = D("feature"), me = M(({ client: e }) => {
175
- let t = W.store({}), n = W.store([]), r = E(t, { register(e, t) {
175
+ }, W = E("feature"), pe = j(({ client: e }) => {
176
+ let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
176
177
  return {
177
178
  ...e,
178
179
  [t.id]: t.feature
@@ -192,7 +193,7 @@ var pe = (e, t, n) => {
192
193
  feature: i
193
194
  }));
194
195
  }
195
- let a = O(async ({ id: e, key: t, storage: n = "local" }) => {
196
+ let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
196
197
  let r = x(`feature:${e}:${t}`, "global"), i = (n === "session" ? b : y).get(r).boolean();
197
198
  return i === null ? null : {
198
199
  id: e,
@@ -200,11 +201,11 @@ var pe = (e, t, n) => {
200
201
  bucket: i,
201
202
  storage: n
202
203
  };
203
- }), o = O((e) => {
204
+ }), o = D((e) => {
204
205
  if (!e) return null;
205
206
  let t = x(`feature:${e.id}:${e.key}`, "global");
206
207
  (e.storage === "session" ? b : y).set(t, e.bucket);
207
- }), s = /* @__PURE__ */ new Map(), c = w({
208
+ }), s = /* @__PURE__ */ new Map(), c = C({
208
209
  source: {
209
210
  allFeaturesStore: t,
210
211
  resolvedFeaturesStore: n
@@ -235,7 +236,7 @@ var pe = (e, t, n) => {
235
236
  };
236
237
  }
237
238
  });
238
- j({
239
+ A({
239
240
  clock: r.register,
240
241
  fn: (e) => {
241
242
  let { id: t, feature: n } = e;
@@ -246,7 +247,7 @@ var pe = (e, t, n) => {
246
247
  };
247
248
  },
248
249
  target: a
249
- }), j({
250
+ }), A({
250
251
  source: t,
251
252
  clock: c.doneData,
252
253
  fn: (e, t) => {
@@ -260,7 +261,7 @@ var pe = (e, t, n) => {
260
261
  },
261
262
  target: o
262
263
  });
263
- let l = T({
264
+ let l = w({
264
265
  allFeaturesStore: t,
265
266
  resolvedFeaturesStore: n
266
267
  }).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
@@ -282,7 +283,7 @@ var pe = (e, t, n) => {
282
283
  isResolved: !1
283
284
  };
284
285
  }));
285
- j({
286
+ A({
286
287
  clock: c.doneData,
287
288
  source: { resolvedFeatures: n },
288
289
  filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
@@ -291,7 +292,7 @@ var pe = (e, t, n) => {
291
292
  type: "feature_decide",
292
293
  feature: e
293
294
  }))
294
- }), j({
295
+ }), A({
295
296
  clock: [a.doneData, c.doneData],
296
297
  source: n,
297
298
  fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
@@ -304,15 +305,15 @@ var pe = (e, t, n) => {
304
305
  return t.map((t) => t[e], { skipVoid: !1 });
305
306
  }
306
307
  function f(e) {
307
- let t = A(async () => void 0, { skipVoid: !1 }), r = O(async () => {
308
+ let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
308
309
  let t = u(e).getState();
309
310
  if (t) return async () => (await t.getBucket()).bucket;
310
311
  });
311
- return j({
312
+ return A({
312
313
  source: n,
313
314
  filter: (t) => t.some((t) => t.id === e),
314
315
  target: r
315
- }), j({
316
+ }), A({
316
317
  clock: r.doneData,
317
318
  filter: (e) => e !== void 0,
318
319
  target: t
@@ -326,21 +327,21 @@ var pe = (e, t, n) => {
326
327
  getEvokableFeature: f
327
328
  };
328
329
  });
329
- function he(e) {
330
- return N(me, e);
330
+ function me(e) {
331
+ return M(pe, e);
331
332
  }
332
- var ge = (e, t, n) => {
333
+ var he = (e, t, n) => {
333
334
  n.register(e, t);
334
- }, G = D("history");
335
+ }, G = E("history");
335
336
  function K(e, t) {
336
337
  return {
337
- id: ie(`history-entry-${Date.now()}-${Math.random()}}`),
338
+ id: S(`history-entry-${Date.now()}-${Math.random()}}`),
338
339
  node: t,
339
340
  at: Date.now(),
340
341
  experienceId: e
341
342
  };
342
343
  }
343
- var _e = M(() => {
344
+ var ge = j(() => {
344
345
  let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
345
346
  e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
346
347
  function a(e, t) {
@@ -350,7 +351,7 @@ var _e = M(() => {
350
351
  };
351
352
  for (let r = e.length - 1; r >= 0; r--) {
352
353
  let i = e[r], a = i?.node;
353
- if (!(!a || !g(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
354
+ if (!(!a || !h(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
354
355
  else {
355
356
  n.secondLastStepIndex = r;
356
357
  break;
@@ -372,25 +373,25 @@ var _e = M(() => {
372
373
  entriesStore: e.map((e) => e.entries)
373
374
  };
374
375
  });
375
- function ve() {
376
- return N(_e);
376
+ function _e() {
377
+ return M(ge);
377
378
  }
378
379
  //#endregion
379
380
  //#region src/utils/events.ts
380
- var ye = 0, be = (e) => {
381
- let t = A([]);
382
- return j({
381
+ var ve = 0, ye = (e) => {
382
+ let t = k([]);
383
+ return A({
383
384
  clock: e,
384
385
  source: t,
385
386
  fn: (e, t) => [...e, {
386
- id: ye++,
387
+ id: ve++,
387
388
  at: /* @__PURE__ */ new Date(),
388
389
  payload: t
389
390
  }],
390
391
  target: t
391
392
  }), t;
392
- }, xe = D("field"), Se = M(() => {
393
- let e = xe.store({}), t = E(e, {
393
+ }, be = E("field"), xe = j(() => {
394
+ let e = be.store({}), t = T(e, {
394
395
  register(e, t) {
395
396
  return {
396
397
  ...e,
@@ -434,13 +435,13 @@ var ye = 0, be = (e) => {
434
435
  getByName: s
435
436
  };
436
437
  });
437
- function Ce() {
438
- return N(Se);
438
+ function Se() {
439
+ return M(xe);
439
440
  }
440
441
  //#endregion
441
442
  //#region src/entities/step/step.ts
442
- var we = D("step"), Te = M(() => {
443
- let e = we.store({}), t = E(e, { register(e, t) {
443
+ var Ce = E("step"), we = j(() => {
444
+ let e = Ce.store({}), t = T(e, { register(e, t) {
444
445
  return {
445
446
  ...e,
446
447
  [t.step.id]: t.step
@@ -464,16 +465,16 @@ var we = D("step"), Te = M(() => {
464
465
  indexStore: e
465
466
  };
466
467
  });
467
- function Ee() {
468
- return N(Te);
468
+ function Te() {
469
+ return M(we);
469
470
  }
470
- function De(e, t) {
471
+ function Ee(e, t) {
471
472
  t.register(e);
472
473
  }
473
474
  //#endregion
474
475
  //#region src/entities/action/action.ts
475
- var Oe = D("action"), ke = M(({ client: e }) => {
476
- let t = Oe.store({}), n = E(t, { register(e, t) {
476
+ var De = E("action"), Oe = j(({ client: e }) => {
477
+ let t = De.store({}), n = T(t, { register(e, t) {
477
478
  return {
478
479
  ...e,
479
480
  [t.key]: {
@@ -493,22 +494,22 @@ var Oe = D("action"), ke = M(({ client: e }) => {
493
494
  return t.map((t) => t[e]?.action, { skipVoid: !1 });
494
495
  }
495
496
  function o(t, n) {
496
- let r = A(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = O(async () => {
497
+ let r = k(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, o = D(async () => {
497
498
  let n = a(t).getState();
498
499
  if (!n) return;
499
- let r = H(e);
500
+ let r = V(e);
500
501
  return (...e) => n({
501
502
  ...r,
502
503
  args: e
503
504
  }, i);
504
505
  });
505
- return j({
506
+ return A({
506
507
  source: {
507
508
  responses: e.responses.listStore,
508
509
  fields: e.fields.listStore
509
510
  },
510
511
  target: o
511
- }), j({
512
+ }), A({
512
513
  clock: o.doneData,
513
514
  filter: (e) => e !== void 0,
514
515
  target: r
@@ -521,10 +522,10 @@ var Oe = D("action"), ke = M(({ client: e }) => {
521
522
  getEvokableAction: o
522
523
  };
523
524
  });
524
- function Ae(e) {
525
- return N(ke, e);
525
+ function ke(e) {
526
+ return M(Oe, e);
526
527
  }
527
- var je = (e, t, n) => {
528
+ var Ae = (e, t, n) => {
528
529
  n.register(e, t);
529
530
  };
530
531
  //#endregion
@@ -540,7 +541,7 @@ function q(e, t, n, r) {
540
541
  function J(e) {
541
542
  return e === null || e === "" || Array.isArray(e) && !e.length;
542
543
  }
543
- function Me(e) {
544
+ function je(e) {
544
545
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
545
546
  }
546
547
  function Y(e) {
@@ -550,13 +551,13 @@ function Y(e) {
550
551
  return !1;
551
552
  }
552
553
  }
553
- function Ne(e, t) {
554
+ function Me(e, t) {
554
555
  return t.find((t) => t.key === e) ?? null;
555
556
  }
556
- function Pe(e, t) {
557
+ function Ne(e, t) {
557
558
  return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
558
559
  }
559
- function Fe(e, t) {
560
+ function Pe(e, t) {
560
561
  if (e.type !== "object" || J(t)) return null;
561
562
  if (e.multiple) {
562
563
  if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
@@ -568,7 +569,7 @@ function Fe(e, t) {
568
569
  }
569
570
  return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
570
571
  }
571
- function Ie(e, t) {
572
+ function Fe(e, t) {
572
573
  if (J(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
573
574
  let n = Array.isArray(t) ? t : [t];
574
575
  if (e.type === "object") {
@@ -576,14 +577,14 @@ function Ie(e, t) {
576
577
  return n.every((e) => r.has(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
577
578
  }
578
579
  let r = e.options.map((e) => e.value);
579
- return n.every((e) => !Me(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
580
+ return n.every((e) => !je(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
580
581
  }
581
- async function Le(t, n, r, i) {
582
- if (n.validation && !e(n.validation) && !J(r)) {
583
- let e = i ? {
582
+ async function Ie(e, n, r, i) {
583
+ if (n.validation && !t(n.validation) && !J(r)) {
584
+ let t = i ? {
584
585
  $input: r,
585
586
  responses: i
586
- } : { $input: r }, a = await t(n.validation, e);
587
+ } : { $input: r }, a = await e(n.validation, t);
587
588
  if (typeof a == "string") return q(n, r, a, `Field validation resulted in an error: ${a}.`);
588
589
  if (a === !1) return q(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
589
590
  }
@@ -591,8 +592,8 @@ async function Le(t, n, r, i) {
591
592
  }
592
593
  //#endregion
593
594
  //#region src/entities/response/response.ts
594
- var Re = D("response"), ze = M(({ client: e }) => {
595
- let n = Re.store({}), r = k(), i = k(), a = E(n, {
595
+ var Le = E("response"), Re = j(({ client: t }) => {
596
+ let n = Le.store({}), r = O(), i = O(), a = T(n, {
596
597
  register(e, t) {
597
598
  return {
598
599
  ...e,
@@ -621,9 +622,9 @@ var Re = D("response"), ze = M(({ client: e }) => {
621
622
  });
622
623
  } else a.registerBatch(e);
623
624
  }
624
- let s = (n, r) => t(e, n, r), c = w({
625
+ let s = (n, r) => e(t, n, r), c = C({
625
626
  source: {
626
- allFields: e.fields.listStore,
627
+ allFields: t.fields.listStore,
627
628
  existingResponses: n
628
629
  },
629
630
  effect: async ({ allFields: e, existingResponses: t }, n) => {
@@ -631,7 +632,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
631
632
  ...t,
632
633
  ...n
633
634
  }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
634
- let o = Ne(t, e);
635
+ let o = Me(t, e);
635
636
  if (!o) {
636
637
  r.push({
637
638
  fieldKey: t,
@@ -641,17 +642,17 @@ var Re = D("response"), ze = M(({ client: e }) => {
641
642
  });
642
643
  return;
643
644
  }
644
- let c = Pe(o, n), l = await Le(s, o, c, a);
645
+ let c = Ne(o, n), l = await Ie(s, o, c, a);
645
646
  if (l) {
646
647
  r.push(l);
647
648
  return;
648
649
  }
649
- let u = Fe(o, c);
650
+ let u = Pe(o, c);
650
651
  if (u) {
651
652
  r.push(u);
652
653
  return;
653
654
  }
654
- let d = Ie(o, c);
655
+ let d = Fe(o, c);
655
656
  if (d) {
656
657
  r.push(d);
657
658
  return;
@@ -679,7 +680,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
679
680
  async function l(e) {
680
681
  return c(e);
681
682
  }
682
- let u = w({
683
+ let u = C({
683
684
  source: n,
684
685
  effect: async (e, t) => {
685
686
  let { responsesToCommit: n, validationErrors: r } = await c(t);
@@ -694,7 +695,7 @@ var Re = D("response"), ze = M(({ client: e }) => {
694
695
  value: t
695
696
  })));
696
697
  function m(e) {
697
- return T({
698
+ return w({
698
699
  f: e,
699
700
  s: n
700
701
  }, ({ f: e, s: t }) => {
@@ -702,19 +703,19 @@ var Re = D("response"), ze = M(({ client: e }) => {
702
703
  return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
703
704
  });
704
705
  }
705
- function h(t) {
706
- return m(e.fields.getById(t));
706
+ function h(e) {
707
+ return m(t.fields.getById(e));
707
708
  }
708
- function g(t) {
709
- return m(e.fields.getByKey(t));
709
+ function g(e) {
710
+ return m(t.fields.getByKey(e));
710
711
  }
711
- function _(t) {
712
- return m(e.fields.getByName(t));
712
+ function _(e) {
713
+ return m(t.fields.getByName(e));
713
714
  }
714
- return j({
715
+ return A({
715
716
  clock: r,
716
717
  target: a.clearAll
717
- }), j({
718
+ }), A({
718
719
  clock: i,
719
720
  target: a.clear
720
721
  }), {
@@ -730,13 +731,13 @@ var Re = D("response"), ze = M(({ client: e }) => {
730
731
  getByFieldName: _
731
732
  };
732
733
  });
733
- function Be(e) {
734
- return N(ze, e);
734
+ function ze(e) {
735
+ return M(Re, e);
735
736
  }
736
737
  //#endregion
737
738
  //#region src/entities/condition/condition.ts
738
- var Ve = D("condition"), He = M(() => {
739
- let e = Ve.store({}), t = E(e, { register(e, t) {
739
+ var Be = E("condition"), Ve = j(() => {
740
+ let e = Be.store({}), t = T(e, { register(e, t) {
740
741
  return {
741
742
  ...e,
742
743
  [t.condition.id]: t.condition
@@ -760,13 +761,13 @@ var Ve = D("condition"), He = M(() => {
760
761
  indexStore: e
761
762
  };
762
763
  });
763
- function Ue() {
764
- return N(He);
764
+ function He() {
765
+ return M(Ve);
765
766
  }
766
767
  //#endregion
767
768
  //#region src/utils/api-url.ts
768
- function We() {
769
- if (f()) {
769
+ function Ue() {
770
+ if (d()) {
770
771
  let e = [
771
772
  document.currentScript,
772
773
  document.getElementById("picked_script"),
@@ -780,8 +781,8 @@ function We() {
780
781
  }
781
782
  //#endregion
782
783
  //#region src/utils/search-params.ts
783
- function Ge() {
784
- if (!o()) return {};
784
+ function We() {
785
+ if (!a()) return {};
785
786
  let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
786
787
  for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
787
788
  for (let r of n) {
@@ -798,18 +799,18 @@ function Ge() {
798
799
  }
799
800
  //#endregion
800
801
  //#region src/utils/user-session.ts
801
- function Ke() {
802
- return u() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
802
+ function Ge() {
803
+ return c() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
803
804
  }
804
- var qe = x("session", "global"), Je = () => {
805
- let e = y.get(qe), t;
805
+ var Ke = x("session", "global"), qe = () => {
806
+ let e = y.get(Ke), t;
806
807
  e.isSet() && (t = e.json());
807
808
  let n = (t) => e.set({
808
809
  id: t.id,
809
810
  isUser: t.isUser,
810
811
  identifiers: t.identifiers
811
812
  }), r = {
812
- id: t?.id ?? Ke(),
813
+ id: t?.id ?? Ge(),
813
814
  isUser: t?.isUser ?? void 0,
814
815
  identifiers: t?.identifiers ?? void 0,
815
816
  setIsUser(e) {
@@ -826,22 +827,22 @@ var qe = x("session", "global"), Je = () => {
826
827
  }
827
828
  };
828
829
  return n(r), r;
829
- }, Ye = () => d() ? Je() : null;
830
+ }, Je = () => l() ? qe() : null;
830
831
  //#endregion
831
832
  //#region src/utils/picked-config.ts
832
833
  function X() {
833
- if (o()) return globalThis.window.pickedConfig;
834
+ if (a()) return globalThis.window.pickedConfig;
834
835
  }
835
- function Xe() {
836
- if (!o()) return;
836
+ function Ye() {
837
+ if (!a()) return;
837
838
  let e = X(), t = e?.organizationId, n = e?.projectId;
838
839
  return t && n ? {
839
840
  organizationId: t,
840
841
  projectId: n
841
842
  } : void 0;
842
843
  }
843
- function Z() {
844
- if (!f()) return;
844
+ function Xe() {
845
+ if (!d()) return;
845
846
  let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
846
847
  if (!e) return;
847
848
  let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
@@ -850,15 +851,15 @@ function Z() {
850
851
  projectId: n
851
852
  } : void 0;
852
853
  }
853
- function Ze(e) {
854
+ function Z(e) {
854
855
  let { organizationId: t, projectId: n } = e;
855
856
  if (t && n) return {
856
857
  organizationId: t,
857
858
  projectId: n
858
859
  };
859
- let r = Xe();
860
+ let r = Ye();
860
861
  if (r) return r;
861
- let i = Z();
862
+ let i = Xe();
862
863
  if (i) return i;
863
864
  throw Error("organizationId and projectId are required. You can provide them via one of:\n (1) createClient({ organizationId, projectId }) options;\n (2) window.pickedConfig = { organizationId, projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.");
864
865
  }
@@ -867,7 +868,7 @@ function Ze(e) {
867
868
  function Q(e) {
868
869
  return e == null || e === "" || Number.isNaN(e);
869
870
  }
870
- var Qe = {
871
+ var Ze = {
871
872
  default: (e, t) => Q(e) ? String(t ?? "") : String(e),
872
873
  append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
873
874
  prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
@@ -888,24 +889,24 @@ var Qe = {
888
889
  return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
889
890
  }
890
891
  };
891
- function $e(e) {
892
+ function Qe(e) {
892
893
  return typeof e == "object" && !!e;
893
894
  }
894
- function et(e, t) {
895
+ function $e(e, t) {
895
896
  let n = t;
896
- for (let t of e.split(".")) if ($e(n) && t in n) n = n[t];
897
+ for (let t of e.split(".")) if (Qe(n) && t in n) n = n[t];
897
898
  else return;
898
899
  return typeof n == "function" ? n() : n;
899
900
  }
900
- function tt(e, t) {
901
- let n = e.split("|").map((e) => e.trim()), r = et(n.shift() ?? "", t);
901
+ function et(e, t) {
902
+ let n = e.split("|").map((e) => e.trim()), r = $e(n.shift() ?? "", t);
902
903
  for (let e of n) {
903
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Qe[i];
904
+ let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ze[i];
904
905
  o && (r = o(r, a));
905
906
  }
906
907
  return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
907
908
  }
908
- function nt(e, t) {
909
+ function tt(e, t) {
909
910
  let n = "", r = 0;
910
911
  for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
911
912
  r += 2;
@@ -917,7 +918,7 @@ function nt(e, t) {
917
918
  }
918
919
  i += e[r++];
919
920
  }
920
- n += tt(i.trim(), t);
921
+ n += et(i.trim(), t);
921
922
  } else n += e[r++];
922
923
  return n;
923
924
  }
@@ -929,7 +930,7 @@ var $ = class {
929
930
  isReady = !1;
930
931
  plugins = {};
931
932
  pluginStartHooks = [];
932
- eventBus = k();
933
+ eventBus = O();
933
934
  events;
934
935
  organizationId;
935
936
  projectId;
@@ -940,30 +941,30 @@ var $ = class {
940
941
  precondition;
941
942
  condition;
942
943
  preconditionPassed;
943
- searchParams = Ge();
944
- history = ve();
944
+ searchParams = We();
945
+ history = _e();
945
946
  components = ue({ client: this });
946
- experienceInstances = re({ client: this });
947
- experiences = te({ client: this });
948
- frameworks = L({ client: this });
949
- predicates = fe({ client: this });
950
- features = he({ client: this });
951
- conditions = Ue();
952
- fields = Ce();
953
- responses = Be({ client: this });
954
- steps = Ee();
955
- actions = Ae({ client: this });
947
+ experienceInstances = ie({ client: this });
948
+ experiences = ee({ client: this });
949
+ frameworks = I({ client: this });
950
+ predicates = de({ client: this });
951
+ features = me({ client: this });
952
+ conditions = He();
953
+ fields = Se();
954
+ responses = ze({ client: this });
955
+ steps = Te();
956
+ actions = ke({ client: this });
956
957
  constructor(e) {
957
- this.events = be(this.eventBus);
958
- let { organizationId: t, projectId: n } = Ze(e);
959
- this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || We(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Ye(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
958
+ this.events = ye(this.eventBus);
959
+ let { organizationId: t, projectId: n } = Z(e);
960
+ this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = Je(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
960
961
  type: "load",
961
- version: C()
962
+ version: re()
962
963
  });
963
964
  }
964
965
  start = () => {
965
- V(this), (async () => {
966
- if (!f()) return;
966
+ B(this), (async () => {
967
+ if (!d()) return;
967
968
  await this.runPluginStartHooks();
968
969
  let e = await this.evaluateGate(this.precondition);
969
970
  this.preconditionPassed = e;
@@ -977,7 +978,7 @@ var $ = class {
977
978
  value: e
978
979
  });
979
980
  }
980
- if (this.eventBus({ type: "initialize" }), n && v(this), await _(), n && v(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
981
+ if (this.eventBus({ type: "initialize" }), n && v(this), await g(), n && v(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
981
982
  let { id: e, isUser: t, identifiers: n } = this.session;
982
983
  this.eventBus({
983
984
  type: "session",
@@ -989,10 +990,10 @@ var $ = class {
989
990
  })();
990
991
  };
991
992
  registerFramework = (e) => {
992
- R(e, this.frameworks);
993
+ L(e, this.frameworks);
993
994
  };
994
995
  registerComponent = (e, t) => {
995
- P(e, t, this.components);
996
+ N(e, t, this.components);
996
997
  };
997
998
  registerPlugin = (e) => {
998
999
  ae(this, e, this.plugins);
@@ -1000,10 +1001,10 @@ var $ = class {
1000
1001
  t?.onStart && this.pluginStartHooks.push(t.onStart);
1001
1002
  };
1002
1003
  registerFeature = (e, t) => {
1003
- ge(e, t, this.features);
1004
+ he(e, t, this.features);
1004
1005
  };
1005
1006
  registerPredicate = (e, t) => {
1006
- pe(e, t, this.predicates);
1007
+ fe(e, t, this.predicates);
1007
1008
  };
1008
1009
  registerCondition = (e) => {
1009
1010
  this.conditions.register(e);
@@ -1012,15 +1013,15 @@ var $ = class {
1012
1013
  this.fields.register(e);
1013
1014
  };
1014
1015
  registerStep = (e) => {
1015
- De(e, this.steps);
1016
+ Ee(e, this.steps);
1016
1017
  };
1017
1018
  registerAction = (e, t) => {
1018
- je(e, t, this.actions);
1019
+ Ae(e, t, this.actions);
1019
1020
  };
1020
1021
  registerExperience = (e) => {
1021
- e.component && P(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1022
+ e.component && N(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1022
1023
  };
1023
- getStateSnapshot = () => H(this);
1024
+ getStateSnapshot = () => V(this);
1024
1025
  launchExperienceById = async (e, t) => {
1025
1026
  this.experiences.launch({
1026
1027
  id: e,
@@ -1042,8 +1043,8 @@ var $ = class {
1042
1043
  async runPluginStartHooks() {
1043
1044
  for (let e of this.pluginStartHooks) await e();
1044
1045
  }
1045
- async evaluateGate(e) {
1046
- return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
1046
+ async evaluateGate(t) {
1047
+ return t === void 0 ? !0 : typeof t == "boolean" ? t : await e(this, t) === !0;
1047
1048
  }
1048
1049
  setupPlugins() {
1049
1050
  this.options.plugins?.forEach((e) => {
@@ -1109,7 +1110,7 @@ var $ = class {
1109
1110
  getPluginConfig = (e) => this.plugins[e] ?? {};
1110
1111
  renderString = (e, t) => {
1111
1112
  let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
1112
- return nt(e, {
1113
+ return tt(e, {
1113
1114
  ...t,
1114
1115
  responses: n
1115
1116
  });
@@ -1117,20 +1118,20 @@ var $ = class {
1117
1118
  };
1118
1119
  //#endregion
1119
1120
  //#region src/entities/component/lazyComponent.ts
1120
- function rt(e) {
1121
+ function nt(e) {
1121
1122
  return {
1122
1123
  $$type: "lazy-component",
1123
1124
  load: e
1124
1125
  };
1125
1126
  }
1126
- function it(e) {
1127
+ function rt(e) {
1127
1128
  return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1128
1129
  }
1129
1130
  //#endregion
1130
1131
  //#region src/exports.ts
1131
- var at = (e) => {
1132
+ var it = (e) => {
1132
1133
  let t = new $(e);
1133
- return l(t), t;
1134
+ return u(t), t;
1134
1135
  };
1135
1136
  //#endregion
1136
- export { $ as Picked, at as createClient, x as createStorageKey, t as evaluateRuleLogic, X as getPickedConfig, it as isLazyLoader, ee as isPickedRoot, rt as lazyComponent, y as localStore, b as sessionStore, ne as subscribe, m as supportsCookies, u as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, r as supportsIntersectionObserver, d as supportsLocalStorage, p as supportsLocation, i as supportsNavigation, c as supportsSessionStorage, h as supportsShadowRoot, a as supportsWebComponents, o as supportsWindow };
1137
+ export { $ as Picked, it as createClient, x as createStorageKey, e as evaluateRuleLogic, X as getPickedConfig, rt as isLazyLoader, _ as isPickedRoot, nt as lazyComponent, y as localStore, b as sessionStore, te as subscribe, p as supportsCookies, c as supportsCryptoRandomUUID, d as supportsDocument, o as supportsHistory, r as supportsIntersectionObserver, l as supportsLocalStorage, f as supportsLocation, i as supportsSessionStorage, s as supportsShadowRoot, m as supportsWebComponents, a as supportsWindow };