@picked/client 0.0.1-dev.1773807602703 → 0.0.1-dev.1773878362211

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