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

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