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