@picked/client 0.0.48 → 0.0.49-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-CTXU-Aoh.js → api-DlWmrA8P.js} +1 -1
- package/dist/api-sPUT21Vf.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +338 -330
- package/dist/esm/plugins/create-experience/index.js +54 -60
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/types/client.d.ts +13 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +24 -9
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/picked.d.ts +4 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +0 -3
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/api-CbpxV_xX.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import { createFactory as b, invoke as I } from "@withease/factories";
|
|
|
3
3
|
import { g as W, t as te, c as re, i as se, e as P, a as ne, b as ie, d as oe } from "../experience-instance-fvSEb72i.js";
|
|
4
4
|
import { f as zt } from "../experience-instance-fvSEb72i.js";
|
|
5
5
|
import { l as w } from "../logger-C9a75KZn.js";
|
|
6
|
-
import { c as A, l as C, s as
|
|
7
|
-
import { a as
|
|
8
|
-
import { p as ae, g as ce } from "../api-
|
|
6
|
+
import { c as A, l as C, s as O } from "../storage-Co_LbKr_.js";
|
|
7
|
+
import { a as Ot } from "../storage-Co_LbKr_.js";
|
|
8
|
+
import { p as ae, g as ce } from "../api-DlWmrA8P.js";
|
|
9
9
|
import { g as ue } from "../id-BW-g3y32.js";
|
|
10
10
|
import { i as de } from "../object-JwZ58NOH.js";
|
|
11
11
|
import { s as L, a as _, b as le, c as pe, d as fe } from "../supports-8YT4QKI7.js";
|
|
@@ -13,33 +13,33 @@ import { e as Ut, f as Dt, g as Vt, h as Nt, i as Tt, j as Lt, k as _t } from ".
|
|
|
13
13
|
const Y = x("experience"), ge = b(
|
|
14
14
|
({ client: t, experience: e }) => {
|
|
15
15
|
const r = Y.store(e), s = j(r, {
|
|
16
|
-
merge(
|
|
16
|
+
merge(d, g) {
|
|
17
17
|
return {
|
|
18
|
-
...
|
|
18
|
+
...d,
|
|
19
19
|
...g.experience
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
23
|
-
name:
|
|
24
|
-
decisionLogic:
|
|
25
|
-
targetSelectors:
|
|
22
|
+
}), n = r.map((d) => ({
|
|
23
|
+
name: d.name,
|
|
24
|
+
decisionLogic: d.condition ?? d.decide,
|
|
25
|
+
targetSelectors: d.targets,
|
|
26
26
|
initializeOpenLogic: e.initializeOpen
|
|
27
|
-
})),
|
|
28
|
-
(
|
|
27
|
+
})), p = t.components.listStore.map(
|
|
28
|
+
(d) => (e.componentName ? d.find((g) => g.name === e.componentName) : void 0) || d.find((g) => g.name === `experience:${e.id}`) || d.find((g) => g.name === "experience"),
|
|
29
29
|
{ skipVoid: !1 }
|
|
30
|
-
), a = r.map((
|
|
31
|
-
steps:
|
|
32
|
-
nodes:
|
|
33
|
-
edges:
|
|
34
|
-
conditionals:
|
|
35
|
-
})),
|
|
30
|
+
), a = r.map((d) => ({
|
|
31
|
+
steps: d.steps,
|
|
32
|
+
nodes: d.nodes,
|
|
33
|
+
edges: d.edges,
|
|
34
|
+
conditionals: d.conditionals
|
|
35
|
+
})), i = r.map((d) => d.fields), c = e.actions ?? [];
|
|
36
36
|
return {
|
|
37
37
|
id: e.id,
|
|
38
|
-
configStore:
|
|
38
|
+
configStore: n,
|
|
39
39
|
treeStore: a,
|
|
40
|
-
fieldsStore:
|
|
41
|
-
componentStore:
|
|
42
|
-
actions:
|
|
40
|
+
fieldsStore: i,
|
|
41
|
+
componentStore: p,
|
|
42
|
+
actions: c,
|
|
43
43
|
merge: s.merge
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -49,64 +49,64 @@ function me(t) {
|
|
|
49
49
|
}
|
|
50
50
|
const he = b(({ client: t }) => {
|
|
51
51
|
const e = Y.store({}), r = j(e, {
|
|
52
|
-
register(
|
|
52
|
+
register(c, d) {
|
|
53
53
|
return {
|
|
54
|
-
...
|
|
55
|
-
[
|
|
54
|
+
...c,
|
|
55
|
+
[d.id]: d
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
function s(
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
59
|
+
function s(c) {
|
|
60
|
+
const d = e.getState()[c.id];
|
|
61
|
+
if (d) {
|
|
62
|
+
d.merge({ experience: c, strategy: "override" });
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
r.register(
|
|
65
|
+
const g = me({ client: t, experience: c });
|
|
66
|
+
r.register(g);
|
|
67
67
|
}
|
|
68
|
-
const
|
|
69
|
-
function
|
|
70
|
-
return e.map((
|
|
68
|
+
const n = e.map((c) => Object.values(c));
|
|
69
|
+
function p(c) {
|
|
70
|
+
return e.map((d) => d[c], { skipVoid: !1 });
|
|
71
71
|
}
|
|
72
|
-
const a =
|
|
72
|
+
const a = U({
|
|
73
73
|
source: e,
|
|
74
|
-
effect: async (
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
77
|
-
w("warn", `Experience with id '${
|
|
74
|
+
effect: async (c, { id: d, options: g }) => {
|
|
75
|
+
const S = c[d];
|
|
76
|
+
if (!S) {
|
|
77
|
+
w("warn", `Experience with id '${d}' not found.`);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
if (
|
|
81
|
-
N(t,
|
|
80
|
+
if (g?.bypassCondition) {
|
|
81
|
+
N(t, S, g);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
await Q(t,
|
|
84
|
+
await Q(t, S) && N(t, S, g);
|
|
85
85
|
}
|
|
86
|
-
}),
|
|
86
|
+
}), i = U({
|
|
87
87
|
source: t.experienceInstances.listStore,
|
|
88
|
-
effect: (
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
for (const
|
|
92
|
-
|
|
88
|
+
effect: (c, { id: d, options: g }) => {
|
|
89
|
+
const S = c.filter((m) => m.experienceId === d);
|
|
90
|
+
if (S.length > 0)
|
|
91
|
+
for (const m of S)
|
|
92
|
+
m.open();
|
|
93
93
|
else
|
|
94
|
-
|
|
94
|
+
a({ id: d, options: { ...g, initialiseOpen: !0 } });
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
return {
|
|
98
98
|
/** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
|
|
99
99
|
register: s,
|
|
100
100
|
/** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
|
|
101
|
-
get:
|
|
101
|
+
get: p,
|
|
102
102
|
/** @deprecated Use `experiences.get(id)` instead. */
|
|
103
|
-
getById:
|
|
103
|
+
getById: p,
|
|
104
104
|
/** Effector effect that launches an experience by ID, creating instances for each DOM target. */
|
|
105
|
-
launch:
|
|
105
|
+
launch: a,
|
|
106
106
|
/** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
|
|
107
|
-
open:
|
|
107
|
+
open: i,
|
|
108
108
|
/** Derived store containing all registered experiences as an array. */
|
|
109
|
-
listStore:
|
|
109
|
+
listStore: n
|
|
110
110
|
};
|
|
111
111
|
});
|
|
112
112
|
function ye(t) {
|
|
@@ -115,10 +115,10 @@ function ye(t) {
|
|
|
115
115
|
const Se = (t, e) => {
|
|
116
116
|
e.register(t);
|
|
117
117
|
}, N = (t, e, r) => {
|
|
118
|
-
const { targetSelectors: s } = e.configStore.getState(),
|
|
119
|
-
|
|
120
|
-
({ elements: a }) => a.forEach((
|
|
121
|
-
), re(
|
|
118
|
+
const { targetSelectors: s } = e.configStore.getState(), n = W(s, e.id);
|
|
119
|
+
n.forEach(
|
|
120
|
+
({ elements: a }) => a.forEach((i) => te(i, e.id))
|
|
121
|
+
), re(n, e.id).forEach((a) => {
|
|
122
122
|
r ? t.experienceInstances.spawn(e, a, r) : t.experienceInstances.spawn(e, a);
|
|
123
123
|
});
|
|
124
124
|
}, H = async (t) => {
|
|
@@ -128,15 +128,15 @@ const Se = (t, e) => {
|
|
|
128
128
|
})
|
|
129
129
|
);
|
|
130
130
|
}, Q = async (t, e) => {
|
|
131
|
-
if (!t.session?.isUser)
|
|
131
|
+
if (!t.preconditionPassed || !t.session?.isUser)
|
|
132
132
|
return !1;
|
|
133
133
|
const { decisionLogic: r, targetSelectors: s } = e.configStore.getState();
|
|
134
134
|
return W(s, e.id).length < 1 || s.length === 0 ? !1 : r === void 0 ? !0 : se(r) ? await P(t, r) === !0 : !0;
|
|
135
135
|
}, ve = (t, e, r) => {
|
|
136
|
-
const s = e.name,
|
|
137
|
-
if (
|
|
138
|
-
const
|
|
139
|
-
r[s] = Object.freeze({ ...
|
|
136
|
+
const s = e.name, n = e.setup(t);
|
|
137
|
+
if (n) {
|
|
138
|
+
const p = r[s] ?? {};
|
|
139
|
+
r[s] = Object.freeze({ ...p, ...n });
|
|
140
140
|
}
|
|
141
141
|
}, ke = x("component"), we = b(
|
|
142
142
|
({ client: t, component: e, name: r }) => {
|
|
@@ -153,29 +153,29 @@ function be(t) {
|
|
|
153
153
|
}
|
|
154
154
|
const Ie = b(({ client: t }) => {
|
|
155
155
|
const e = ke.store({}), r = j(e, {
|
|
156
|
-
register(a,
|
|
156
|
+
register(a, i) {
|
|
157
157
|
return {
|
|
158
158
|
...a,
|
|
159
|
-
[
|
|
159
|
+
[i.name]: i
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
|
-
function s(a,
|
|
163
|
+
function s(a, i) {
|
|
164
164
|
e.getState()[a] && w(
|
|
165
165
|
"warn",
|
|
166
166
|
`Component '${a}' already registered. Registering again will override the previous registration.`
|
|
167
167
|
);
|
|
168
|
-
const
|
|
169
|
-
r.register(
|
|
168
|
+
const d = be({ client: t, name: a, component: i });
|
|
169
|
+
r.register(d);
|
|
170
170
|
}
|
|
171
|
-
const
|
|
172
|
-
function
|
|
173
|
-
return e.map((
|
|
171
|
+
const n = e.map((a) => Object.values(a));
|
|
172
|
+
function p(a) {
|
|
173
|
+
return e.map((i) => i[a], { skipVoid: !1 });
|
|
174
174
|
}
|
|
175
175
|
return {
|
|
176
176
|
register: s,
|
|
177
|
-
getByName:
|
|
178
|
-
listStore:
|
|
177
|
+
getByName: p,
|
|
178
|
+
listStore: n
|
|
179
179
|
};
|
|
180
180
|
});
|
|
181
181
|
function Fe(t) {
|
|
@@ -185,27 +185,27 @@ const G = (t, e, r) => {
|
|
|
185
185
|
r.register(t, e);
|
|
186
186
|
}, xe = x("framework"), je = b(({ client: t }) => {
|
|
187
187
|
const e = xe.store({}), r = j(e, {
|
|
188
|
-
register(a,
|
|
188
|
+
register(a, i) {
|
|
189
189
|
return {
|
|
190
190
|
...a,
|
|
191
|
-
[
|
|
191
|
+
[i.name]: i.framework
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
function s(a,
|
|
195
|
+
function s(a, i) {
|
|
196
196
|
e.getState()[a] && w(
|
|
197
197
|
"warn",
|
|
198
198
|
`Framework '${a}' already registered. Registering again will override the previous registration.`
|
|
199
|
-
), r.register({ name: a, framework:
|
|
199
|
+
), r.register({ name: a, framework: i });
|
|
200
200
|
}
|
|
201
|
-
const
|
|
202
|
-
function
|
|
203
|
-
return e.map((
|
|
201
|
+
const n = e.map((a) => Object.values(a));
|
|
202
|
+
function p(a) {
|
|
203
|
+
return e.map((i) => i[a], { skipVoid: !1 });
|
|
204
204
|
}
|
|
205
205
|
return {
|
|
206
206
|
register: s,
|
|
207
|
-
getByName:
|
|
208
|
-
listStore:
|
|
207
|
+
getByName: p,
|
|
208
|
+
listStore: n
|
|
209
209
|
};
|
|
210
210
|
});
|
|
211
211
|
function Ee(t) {
|
|
@@ -219,13 +219,13 @@ const Pe = (t, e) => {
|
|
|
219
219
|
let s = 0;
|
|
220
220
|
if (r.isSet() && (s = r.json() ?? 0), s && e - s < Ae)
|
|
221
221
|
return !0;
|
|
222
|
-
const
|
|
222
|
+
const n = {
|
|
223
223
|
projectId: t.projectId,
|
|
224
224
|
path: window.location.pathname
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
return
|
|
225
|
+
}, p = {}, i = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
226
|
+
i && (p["x-vercel-protection-bypass"] = i);
|
|
227
|
+
const d = (await ae(t.apiUrl, "ping", n, p)).ok;
|
|
228
|
+
return d && r.set(e), d;
|
|
229
229
|
} catch (e) {
|
|
230
230
|
return w("error", e), !1;
|
|
231
231
|
}
|
|
@@ -244,32 +244,32 @@ function X(t) {
|
|
|
244
244
|
}
|
|
245
245
|
const Re = x("predicate"), ze = b(({ client: t }) => {
|
|
246
246
|
const e = Re.store({}), r = j(e, {
|
|
247
|
-
register(
|
|
247
|
+
register(i, c) {
|
|
248
248
|
return {
|
|
249
|
-
...
|
|
250
|
-
[
|
|
251
|
-
name:
|
|
252
|
-
predicate:
|
|
249
|
+
...i,
|
|
250
|
+
[c.name]: {
|
|
251
|
+
name: c.name,
|
|
252
|
+
predicate: c.predicate
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
|
-
function s(
|
|
258
|
-
e.getState()[
|
|
257
|
+
function s(i, c) {
|
|
258
|
+
e.getState()[i] && w(
|
|
259
259
|
"warn",
|
|
260
|
-
`Predicate '${
|
|
261
|
-
), r.register(Object.freeze({ name:
|
|
260
|
+
`Predicate '${i}' already registered. Registering again will override the previous registration.`
|
|
261
|
+
), r.register(Object.freeze({ name: i, predicate: c }));
|
|
262
262
|
}
|
|
263
|
-
const
|
|
264
|
-
function
|
|
265
|
-
return e.map((
|
|
263
|
+
const n = e.map((i) => Object.values(i));
|
|
264
|
+
function p(i) {
|
|
265
|
+
return e.map((c) => c[i]?.predicate, { skipVoid: !1 });
|
|
266
266
|
}
|
|
267
|
-
function a(
|
|
268
|
-
const
|
|
267
|
+
function a(i) {
|
|
268
|
+
const c = T(() => {
|
|
269
269
|
}, {
|
|
270
270
|
skipVoid: !1
|
|
271
|
-
}),
|
|
272
|
-
const g =
|
|
271
|
+
}), d = R(async () => {
|
|
272
|
+
const g = p(i).getState();
|
|
273
273
|
if (!g)
|
|
274
274
|
return;
|
|
275
275
|
const S = X(t);
|
|
@@ -277,71 +277,71 @@ const Re = x("predicate"), ze = b(({ client: t }) => {
|
|
|
277
277
|
});
|
|
278
278
|
return k({
|
|
279
279
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
280
|
-
target:
|
|
280
|
+
target: d
|
|
281
281
|
}), k({
|
|
282
|
-
clock:
|
|
282
|
+
clock: d.doneData,
|
|
283
283
|
filter: (g) => g !== void 0,
|
|
284
|
-
target:
|
|
285
|
-
}),
|
|
284
|
+
target: c
|
|
285
|
+
}), d(), c;
|
|
286
286
|
}
|
|
287
287
|
return {
|
|
288
288
|
register: s,
|
|
289
|
-
getByName:
|
|
290
|
-
listStore:
|
|
289
|
+
getByName: p,
|
|
290
|
+
listStore: n,
|
|
291
291
|
getEvokablePredicate: a
|
|
292
292
|
};
|
|
293
293
|
});
|
|
294
294
|
function Ce(t) {
|
|
295
295
|
return I(ze, t);
|
|
296
296
|
}
|
|
297
|
-
const
|
|
297
|
+
const Oe = (t, e, r) => {
|
|
298
298
|
r.register(t, e);
|
|
299
|
-
}, J = x("feature"),
|
|
299
|
+
}, J = x("feature"), Me = b(({ client: t }) => {
|
|
300
300
|
const e = J.store({}), r = J.store([]), s = j(e, {
|
|
301
|
-
register(o,
|
|
301
|
+
register(o, u) {
|
|
302
302
|
return {
|
|
303
303
|
...o,
|
|
304
|
-
[
|
|
304
|
+
[u.id]: u.feature
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
});
|
|
308
|
-
function
|
|
308
|
+
function n(o, u) {
|
|
309
309
|
e.getState()[o] && w(
|
|
310
310
|
"warn",
|
|
311
311
|
`Feature '${o}' already registered. Registering again will override the previous registration.`
|
|
312
312
|
);
|
|
313
|
-
const
|
|
313
|
+
const l = {
|
|
314
314
|
id: o,
|
|
315
315
|
feature: {
|
|
316
|
-
...
|
|
316
|
+
...u,
|
|
317
317
|
id: o
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
320
|
s.register(
|
|
321
321
|
Object.freeze({
|
|
322
322
|
id: o,
|
|
323
|
-
feature:
|
|
323
|
+
feature: l
|
|
324
324
|
})
|
|
325
325
|
);
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const p = R(
|
|
328
328
|
async ({
|
|
329
329
|
id: o,
|
|
330
|
-
key:
|
|
330
|
+
key: u,
|
|
331
331
|
storage: f = "local"
|
|
332
332
|
}) => {
|
|
333
|
-
const
|
|
334
|
-
return y === null ? null : { id: o, key:
|
|
333
|
+
const l = A(`feature:${o}:${u}`, "global"), y = (f === "session" ? O : C).get(l).boolean();
|
|
334
|
+
return y === null ? null : { id: o, key: u, bucket: y, storage: f };
|
|
335
335
|
}
|
|
336
336
|
), a = R((o) => {
|
|
337
337
|
if (!o)
|
|
338
338
|
return null;
|
|
339
|
-
const
|
|
340
|
-
(o.storage === "session" ?
|
|
341
|
-
}),
|
|
339
|
+
const u = A(`feature:${o.id}:${o.key}`, "global");
|
|
340
|
+
(o.storage === "session" ? O : C).set(u, o.bucket);
|
|
341
|
+
}), i = /* @__PURE__ */ new Map(), c = U({
|
|
342
342
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
343
|
-
effect: async ({ allFeaturesStore: o, resolvedFeaturesStore:
|
|
344
|
-
const y =
|
|
343
|
+
effect: async ({ allFeaturesStore: o, resolvedFeaturesStore: u }, { id: f, decide: l, key: h }) => {
|
|
344
|
+
const y = u.find(
|
|
345
345
|
(B) => B.id === f && B.key === h
|
|
346
346
|
);
|
|
347
347
|
if (y)
|
|
@@ -349,13 +349,13 @@ const Me = (t, e, r) => {
|
|
|
349
349
|
const F = o[f];
|
|
350
350
|
if (!F)
|
|
351
351
|
throw new Error(`Feature with id '${f}' not found`);
|
|
352
|
-
const $ =
|
|
352
|
+
const $ = i.get(`${f}:${h}`);
|
|
353
353
|
if ($ !== void 0) {
|
|
354
354
|
const B = await $;
|
|
355
355
|
return { id: F.id, bucket: B, key: h, storage: F.feature.storage };
|
|
356
356
|
}
|
|
357
|
-
const v =
|
|
358
|
-
|
|
357
|
+
const v = l();
|
|
358
|
+
i.set(`${f}:${h}`, v);
|
|
359
359
|
const ee = await v;
|
|
360
360
|
return { id: F.id, bucket: ee, key: h, storage: F.feature.storage };
|
|
361
361
|
}
|
|
@@ -363,97 +363,97 @@ const Me = (t, e, r) => {
|
|
|
363
363
|
k({
|
|
364
364
|
clock: s.register,
|
|
365
365
|
fn: (o) => {
|
|
366
|
-
const { id:
|
|
367
|
-
return { id:
|
|
366
|
+
const { id: u, feature: f } = o;
|
|
367
|
+
return { id: u, key: f.feature.key, storage: f.feature.storage };
|
|
368
368
|
},
|
|
369
|
-
target:
|
|
369
|
+
target: p
|
|
370
370
|
}), k({
|
|
371
371
|
source: e,
|
|
372
|
-
clock:
|
|
373
|
-
fn: (o,
|
|
374
|
-
const { id: f, bucket:
|
|
375
|
-
return y ? { key: y, id: f, bucket:
|
|
372
|
+
clock: c.doneData,
|
|
373
|
+
fn: (o, u) => {
|
|
374
|
+
const { id: f, bucket: l, storage: h } = u, y = o[f]?.feature.key;
|
|
375
|
+
return y ? { key: y, id: f, bucket: l, storage: h } : null;
|
|
376
376
|
},
|
|
377
377
|
target: a
|
|
378
378
|
});
|
|
379
|
-
const
|
|
379
|
+
const d = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
380
380
|
({
|
|
381
381
|
allFeaturesStore: o,
|
|
382
|
-
resolvedFeaturesStore:
|
|
382
|
+
resolvedFeaturesStore: u
|
|
383
383
|
}) => Object.values(o).map((f) => {
|
|
384
|
-
const
|
|
384
|
+
const l = u.find(
|
|
385
385
|
(h) => h.id === f.id && h.key === f.feature.key
|
|
386
386
|
);
|
|
387
|
-
return
|
|
387
|
+
return l ? {
|
|
388
388
|
id: f.id,
|
|
389
389
|
name: f.feature.name,
|
|
390
390
|
key: f.feature.key,
|
|
391
|
-
getBucket: () => ({ id: f.id, bucket:
|
|
391
|
+
getBucket: () => ({ id: f.id, bucket: l.bucket }),
|
|
392
392
|
isResolved: !0
|
|
393
393
|
} : {
|
|
394
394
|
id: f.id,
|
|
395
395
|
name: f.feature.name,
|
|
396
396
|
key: f.feature.key,
|
|
397
|
-
getBucket: async () => await
|
|
397
|
+
getBucket: async () => await c(f.feature),
|
|
398
398
|
isResolved: !1
|
|
399
399
|
};
|
|
400
400
|
})
|
|
401
401
|
);
|
|
402
402
|
k({
|
|
403
|
-
clock:
|
|
403
|
+
clock: c.doneData,
|
|
404
404
|
source: { resolvedFeatures: r },
|
|
405
|
-
filter: ({ resolvedFeatures: o }, { id:
|
|
406
|
-
(h) => h.id ===
|
|
405
|
+
filter: ({ resolvedFeatures: o }, { id: u, key: f }) => !o.some(
|
|
406
|
+
(h) => h.id === u && h.key === f
|
|
407
407
|
),
|
|
408
|
-
fn: (o,
|
|
408
|
+
fn: (o, u) => u,
|
|
409
409
|
target: t.eventBus.prepend((o) => ({
|
|
410
410
|
type: "feature_decide",
|
|
411
411
|
feature: o
|
|
412
412
|
}))
|
|
413
413
|
}), k({
|
|
414
|
-
clock: [
|
|
414
|
+
clock: [p.doneData, c.doneData],
|
|
415
415
|
source: r,
|
|
416
|
-
fn: (o,
|
|
417
|
-
(
|
|
418
|
-
) ? o : [...o,
|
|
416
|
+
fn: (o, u) => !u || o.some(
|
|
417
|
+
(l) => l.id === u.id && l.key === u.key
|
|
418
|
+
) ? o : [...o, u],
|
|
419
419
|
target: r
|
|
420
420
|
});
|
|
421
421
|
function g(o) {
|
|
422
|
-
return
|
|
422
|
+
return d.map((u) => u.find((f) => f.id === o));
|
|
423
423
|
}
|
|
424
424
|
function S(o) {
|
|
425
|
-
return e.map((
|
|
425
|
+
return e.map((u) => u[o], { skipVoid: !1 });
|
|
426
426
|
}
|
|
427
427
|
function m(o) {
|
|
428
|
-
const
|
|
428
|
+
const u = T(
|
|
429
429
|
async () => {
|
|
430
430
|
},
|
|
431
431
|
{ skipVoid: !1 }
|
|
432
432
|
), f = R(async () => {
|
|
433
|
-
const
|
|
434
|
-
if (
|
|
435
|
-
return async () => (await
|
|
433
|
+
const l = g(o).getState();
|
|
434
|
+
if (l)
|
|
435
|
+
return async () => (await l.getBucket()).bucket;
|
|
436
436
|
});
|
|
437
437
|
return k({
|
|
438
438
|
source: r,
|
|
439
|
-
filter: (
|
|
439
|
+
filter: (l) => l.some((h) => h.id === o),
|
|
440
440
|
target: f
|
|
441
441
|
}), k({
|
|
442
442
|
clock: f.doneData,
|
|
443
|
-
filter: (
|
|
444
|
-
target:
|
|
445
|
-
}), f(),
|
|
443
|
+
filter: (l) => l !== void 0,
|
|
444
|
+
target: u
|
|
445
|
+
}), f(), u;
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
448
|
-
register:
|
|
448
|
+
register: n,
|
|
449
449
|
getById: g,
|
|
450
450
|
getByName: S,
|
|
451
|
-
listStore:
|
|
451
|
+
listStore: d,
|
|
452
452
|
getEvokableFeature: m
|
|
453
453
|
};
|
|
454
454
|
});
|
|
455
455
|
function Ue(t) {
|
|
456
|
-
return I(
|
|
456
|
+
return I(Me, t);
|
|
457
457
|
}
|
|
458
458
|
const De = (t, e, r) => {
|
|
459
459
|
r.register(t, e);
|
|
@@ -468,40 +468,40 @@ function q(t, e) {
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
const Ve = b(() => {
|
|
471
|
-
const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(),
|
|
472
|
-
t.on(e, (a,
|
|
473
|
-
entries: [...a.entries, q(
|
|
474
|
-
})), t.on(r, (a,
|
|
471
|
+
const t = E.store({ entries: [] }), e = E.event(), r = E.event(), s = E.event(), n = E.event();
|
|
472
|
+
t.on(e, (a, i) => ({
|
|
473
|
+
entries: [...a.entries, q(i.experienceId, i.node)]
|
|
474
|
+
})), t.on(r, (a, i) => ({
|
|
475
475
|
entries: [
|
|
476
476
|
...a.entries.slice(0, -1),
|
|
477
|
-
q(
|
|
477
|
+
q(i.experienceId, i.node)
|
|
478
478
|
]
|
|
479
|
-
})), t.on(
|
|
480
|
-
function
|
|
481
|
-
const
|
|
482
|
-
for (let
|
|
483
|
-
const g = a[
|
|
484
|
-
if (!(!S || !ne(S)) && !(
|
|
485
|
-
if (
|
|
486
|
-
|
|
479
|
+
})), t.on(n, (a, i) => i);
|
|
480
|
+
function p(a, i) {
|
|
481
|
+
const c = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
482
|
+
for (let d = a.length - 1; d >= 0; d--) {
|
|
483
|
+
const g = a[d], S = g?.node;
|
|
484
|
+
if (!(!S || !ne(S)) && !(i && g?.experienceId !== i))
|
|
485
|
+
if (c.lastStepIndex === -1)
|
|
486
|
+
c.lastStepIndex = d;
|
|
487
487
|
else {
|
|
488
|
-
|
|
488
|
+
c.secondLastStepIndex = d;
|
|
489
489
|
break;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
return
|
|
492
|
+
return c;
|
|
493
493
|
}
|
|
494
|
-
return t.on(s, (a,
|
|
495
|
-
const { secondLastStepIndex:
|
|
494
|
+
return t.on(s, (a, i) => {
|
|
495
|
+
const { secondLastStepIndex: c } = p(a.entries, i.experienceId), d = c !== -1 ? a.entries.slice(0, c + 1) : a.entries;
|
|
496
496
|
return {
|
|
497
497
|
...a,
|
|
498
|
-
entries:
|
|
498
|
+
entries: d
|
|
499
499
|
};
|
|
500
500
|
}), {
|
|
501
501
|
push: e,
|
|
502
502
|
replace: r,
|
|
503
503
|
back: s,
|
|
504
|
-
restore:
|
|
504
|
+
restore: n,
|
|
505
505
|
entriesStore: t.map((a) => a.entries)
|
|
506
506
|
};
|
|
507
507
|
});
|
|
@@ -526,37 +526,37 @@ const Le = (t) => {
|
|
|
526
526
|
}), e;
|
|
527
527
|
}, _e = x("field"), He = b(() => {
|
|
528
528
|
const t = _e.store({}), e = j(t, {
|
|
529
|
-
register(
|
|
529
|
+
register(i, c) {
|
|
530
530
|
return {
|
|
531
|
-
...
|
|
532
|
-
[
|
|
531
|
+
...i,
|
|
532
|
+
[c.field.id]: c.field
|
|
533
533
|
};
|
|
534
534
|
}
|
|
535
535
|
});
|
|
536
|
-
function r(
|
|
537
|
-
e.register({ field:
|
|
536
|
+
function r(i) {
|
|
537
|
+
e.register({ field: i });
|
|
538
538
|
}
|
|
539
|
-
function s(
|
|
540
|
-
const
|
|
541
|
-
if (!
|
|
539
|
+
function s(i, c) {
|
|
540
|
+
const d = p(i).getState();
|
|
541
|
+
if (!d)
|
|
542
542
|
return;
|
|
543
|
-
const g = Object.assign({},
|
|
544
|
-
...
|
|
543
|
+
const g = Object.assign({}, d, {
|
|
544
|
+
...c
|
|
545
545
|
});
|
|
546
546
|
e.register({ field: { ...g } });
|
|
547
547
|
}
|
|
548
|
-
const
|
|
549
|
-
function
|
|
550
|
-
return t.map((
|
|
548
|
+
const n = t.map((i) => Object.values(i));
|
|
549
|
+
function p(i) {
|
|
550
|
+
return t.map((c) => c[i] || null);
|
|
551
551
|
}
|
|
552
|
-
function a(
|
|
553
|
-
return t.map((
|
|
552
|
+
function a(i) {
|
|
553
|
+
return t.map((c) => Object.values(c).find((d) => d.name === i) || null);
|
|
554
554
|
}
|
|
555
555
|
return {
|
|
556
556
|
register: r,
|
|
557
557
|
update: s,
|
|
558
|
-
getById:
|
|
559
|
-
listStore:
|
|
558
|
+
getById: p,
|
|
559
|
+
listStore: n,
|
|
560
560
|
getByName: a
|
|
561
561
|
};
|
|
562
562
|
});
|
|
@@ -567,37 +567,37 @@ const Je = (t, e) => {
|
|
|
567
567
|
e.register(t);
|
|
568
568
|
}, qe = x("action"), Ke = b(() => {
|
|
569
569
|
const t = qe.store({}), e = j(t, {
|
|
570
|
-
register(a,
|
|
570
|
+
register(a, i) {
|
|
571
571
|
return {
|
|
572
572
|
...a,
|
|
573
|
-
[
|
|
574
|
-
name:
|
|
575
|
-
action:
|
|
573
|
+
[i.name]: {
|
|
574
|
+
name: i.name,
|
|
575
|
+
action: i.action
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
578
|
}
|
|
579
579
|
});
|
|
580
|
-
function r(a,
|
|
581
|
-
e.register({ name: a, action:
|
|
580
|
+
function r(a, i) {
|
|
581
|
+
e.register({ name: a, action: i });
|
|
582
582
|
}
|
|
583
583
|
const s = t.map((a) => Object.values(a));
|
|
584
|
-
function
|
|
585
|
-
return t.map((
|
|
584
|
+
function n(a) {
|
|
585
|
+
return t.map((i) => i[a], { skipVoid: !1 });
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function p(a) {
|
|
588
588
|
return t.map(
|
|
589
|
-
(
|
|
590
|
-
const
|
|
591
|
-
return
|
|
589
|
+
(i) => {
|
|
590
|
+
const c = i[a];
|
|
591
|
+
return c ? c.action : void 0;
|
|
592
592
|
},
|
|
593
593
|
{ skipVoid: !1 }
|
|
594
594
|
);
|
|
595
595
|
}
|
|
596
596
|
return {
|
|
597
597
|
register: r,
|
|
598
|
-
getByName:
|
|
598
|
+
getByName: n,
|
|
599
599
|
listStore: s,
|
|
600
|
-
getEvokableAction:
|
|
600
|
+
getEvokableAction: p
|
|
601
601
|
};
|
|
602
602
|
});
|
|
603
603
|
function We() {
|
|
@@ -606,7 +606,7 @@ function We() {
|
|
|
606
606
|
const Ye = (t, e, r) => {
|
|
607
607
|
r.register(t, e);
|
|
608
608
|
};
|
|
609
|
-
function
|
|
609
|
+
function M(t) {
|
|
610
610
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
611
611
|
}
|
|
612
612
|
function Qe(t) {
|
|
@@ -620,7 +620,7 @@ function K(t) {
|
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
const Xe = x("response"), Ze = b(({ client: t }) => {
|
|
623
|
-
const e = Xe.store({}), r = V(), s = V(),
|
|
623
|
+
const e = Xe.store({}), r = V(), s = V(), n = j(e, {
|
|
624
624
|
register(m, o) {
|
|
625
625
|
return {
|
|
626
626
|
...m,
|
|
@@ -634,193 +634,193 @@ const Xe = x("response"), Ze = b(({ client: t }) => {
|
|
|
634
634
|
};
|
|
635
635
|
},
|
|
636
636
|
clear(m, o) {
|
|
637
|
-
const { [o]:
|
|
637
|
+
const { [o]: u, ...f } = m;
|
|
638
638
|
return f;
|
|
639
639
|
},
|
|
640
640
|
clearAll() {
|
|
641
641
|
return {};
|
|
642
642
|
}
|
|
643
643
|
});
|
|
644
|
-
function
|
|
644
|
+
function p(m, o) {
|
|
645
645
|
if (typeof m == "string") {
|
|
646
646
|
if (o === void 0)
|
|
647
647
|
throw new Error("Response is required when registering a single field");
|
|
648
|
-
|
|
648
|
+
n.register({ fieldId: m, response: o });
|
|
649
649
|
} else
|
|
650
|
-
|
|
650
|
+
n.registerBatch(m);
|
|
651
651
|
}
|
|
652
652
|
async function a(m) {
|
|
653
653
|
const o = [];
|
|
654
654
|
return await Promise.allSettled(
|
|
655
|
-
Object.entries(m).map(async ([
|
|
656
|
-
let
|
|
657
|
-
const h = t.fields.getById(
|
|
655
|
+
Object.entries(m).map(async ([u, f]) => {
|
|
656
|
+
let l = f;
|
|
657
|
+
const h = t.fields.getById(u).getState();
|
|
658
658
|
if (!h) {
|
|
659
659
|
o.push({
|
|
660
|
-
fieldId:
|
|
661
|
-
userMessage: `Field '${
|
|
662
|
-
systemMessage: `No field with ID '${
|
|
663
|
-
value:
|
|
660
|
+
fieldId: u,
|
|
661
|
+
userMessage: `Field '${u}' not found`,
|
|
662
|
+
systemMessage: `No field with ID '${u}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
663
|
+
value: l
|
|
664
664
|
});
|
|
665
665
|
return;
|
|
666
666
|
}
|
|
667
|
-
if (h.multiple && (typeof
|
|
667
|
+
if (h.multiple && (typeof l == "string" || typeof l == "number" || typeof l == "boolean") && (l = [l]), h.validation && !de(h.validation) && !M(l)) {
|
|
668
668
|
const y = await P(t, h.validation, {
|
|
669
|
-
$input:
|
|
669
|
+
$input: l
|
|
670
670
|
});
|
|
671
671
|
if (typeof y == "string") {
|
|
672
672
|
o.push({
|
|
673
|
-
fieldId:
|
|
673
|
+
fieldId: u,
|
|
674
674
|
userMessage: y,
|
|
675
675
|
systemMessage: `Field validation resulted in an error: ${y}.`,
|
|
676
|
-
value:
|
|
676
|
+
value: l
|
|
677
677
|
});
|
|
678
678
|
return;
|
|
679
679
|
}
|
|
680
680
|
if (y === !1) {
|
|
681
681
|
o.push({
|
|
682
|
-
fieldId:
|
|
682
|
+
fieldId: u,
|
|
683
683
|
userMessage: "This field is invalid",
|
|
684
684
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
685
|
-
value:
|
|
685
|
+
value: l
|
|
686
686
|
});
|
|
687
687
|
return;
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
|
-
if (h.required &&
|
|
690
|
+
if (h.required && M(l)) {
|
|
691
691
|
o.push({
|
|
692
|
-
fieldId:
|
|
692
|
+
fieldId: u,
|
|
693
693
|
userMessage: "This field is required",
|
|
694
694
|
systemMessage: "Field is required.",
|
|
695
|
-
value:
|
|
695
|
+
value: l
|
|
696
696
|
});
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
|
-
if (!h.multiple && Array.isArray(
|
|
699
|
+
if (!h.multiple && Array.isArray(l) && l.length > 1) {
|
|
700
700
|
o.push({
|
|
701
|
-
fieldId:
|
|
701
|
+
fieldId: u,
|
|
702
702
|
userMessage: "This field expects a single response",
|
|
703
703
|
systemMessage: "Field expects a single response.",
|
|
704
|
-
value:
|
|
704
|
+
value: l
|
|
705
705
|
});
|
|
706
706
|
return;
|
|
707
707
|
}
|
|
708
|
-
if (h.type === "object" && !
|
|
708
|
+
if (h.type === "object" && !M(l))
|
|
709
709
|
if (h.multiple) {
|
|
710
|
-
if (!Array.isArray(
|
|
710
|
+
if (!Array.isArray(l)) {
|
|
711
711
|
o.push({
|
|
712
|
-
fieldId:
|
|
712
|
+
fieldId: u,
|
|
713
713
|
userMessage: "This field expects multiple values",
|
|
714
714
|
systemMessage: "Field expects an array of objects.",
|
|
715
|
-
value:
|
|
715
|
+
value: l
|
|
716
716
|
});
|
|
717
717
|
return;
|
|
718
718
|
}
|
|
719
|
-
for (const y of
|
|
719
|
+
for (const y of l) {
|
|
720
720
|
if (typeof y != "object" || y === null) {
|
|
721
721
|
o.push({
|
|
722
|
-
fieldId:
|
|
722
|
+
fieldId: u,
|
|
723
723
|
userMessage: "This field expects object values",
|
|
724
724
|
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
725
|
-
value:
|
|
725
|
+
value: l
|
|
726
726
|
});
|
|
727
727
|
return;
|
|
728
728
|
}
|
|
729
729
|
if (!K(y)) {
|
|
730
730
|
o.push({
|
|
731
|
-
fieldId:
|
|
731
|
+
fieldId: u,
|
|
732
732
|
userMessage: "This field contains non-serializable data",
|
|
733
733
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
734
|
-
value:
|
|
734
|
+
value: l
|
|
735
735
|
});
|
|
736
736
|
return;
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
} else {
|
|
740
|
-
if (Array.isArray(
|
|
740
|
+
if (Array.isArray(l)) {
|
|
741
741
|
o.push({
|
|
742
|
-
fieldId:
|
|
742
|
+
fieldId: u,
|
|
743
743
|
userMessage: "This field expects a single value",
|
|
744
744
|
systemMessage: "Field expects a single object, not an array.",
|
|
745
|
-
value:
|
|
745
|
+
value: l
|
|
746
746
|
});
|
|
747
747
|
return;
|
|
748
748
|
}
|
|
749
|
-
if (typeof
|
|
749
|
+
if (typeof l != "object" || l === null) {
|
|
750
750
|
o.push({
|
|
751
|
-
fieldId:
|
|
751
|
+
fieldId: u,
|
|
752
752
|
userMessage: "This field expects an object value",
|
|
753
753
|
systemMessage: "Field expects an object value.",
|
|
754
|
-
value:
|
|
754
|
+
value: l
|
|
755
755
|
});
|
|
756
756
|
return;
|
|
757
757
|
}
|
|
758
|
-
if (!K(
|
|
758
|
+
if (!K(l)) {
|
|
759
759
|
o.push({
|
|
760
|
-
fieldId:
|
|
760
|
+
fieldId: u,
|
|
761
761
|
userMessage: "This field contains non-serializable data",
|
|
762
762
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
763
|
-
value:
|
|
763
|
+
value: l
|
|
764
764
|
});
|
|
765
765
|
return;
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
if (Array.isArray(h.options) && h.options.length > 0) {
|
|
769
|
-
const y = Array.isArray(
|
|
769
|
+
const y = Array.isArray(l) ? l : [l];
|
|
770
770
|
if (h.type === "object") {
|
|
771
771
|
const F = h.options.map((v) => JSON.stringify(v.value));
|
|
772
772
|
y.every((v) => F.includes(JSON.stringify(v))) || o.push({
|
|
773
|
-
fieldId:
|
|
773
|
+
fieldId: u,
|
|
774
774
|
userMessage: "This field expects a valid option",
|
|
775
775
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
776
|
-
value:
|
|
776
|
+
value: l
|
|
777
777
|
});
|
|
778
778
|
} else {
|
|
779
779
|
const F = h.options.map((v) => v.value);
|
|
780
780
|
y.every((v) => !Qe(v) || v === null ? !1 : F.includes(v)) || o.push({
|
|
781
|
-
fieldId:
|
|
781
|
+
fieldId: u,
|
|
782
782
|
userMessage: "This field expects a valid option",
|
|
783
783
|
systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
|
|
784
|
-
value:
|
|
784
|
+
value: l
|
|
785
785
|
});
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
788
|
})
|
|
789
789
|
), { responsesToCommit: m, validationErrors: o };
|
|
790
790
|
}
|
|
791
|
-
async function
|
|
792
|
-
const { responsesToCommit: o, validationErrors:
|
|
793
|
-
return
|
|
791
|
+
async function i(m) {
|
|
792
|
+
const { responsesToCommit: o, validationErrors: u } = await a(m);
|
|
793
|
+
return u.length ? { errors: u } : (n.registerBatch(o), { errors: [] });
|
|
794
794
|
}
|
|
795
|
-
const
|
|
796
|
-
fieldId:
|
|
797
|
-
value: m[
|
|
795
|
+
const c = e.map((m) => m), d = e.map((m) => Object.keys(m).map((u) => ({
|
|
796
|
+
fieldId: u,
|
|
797
|
+
value: m[u]
|
|
798
798
|
})));
|
|
799
799
|
function g(m) {
|
|
800
|
-
const o = t.fields.getById(m),
|
|
801
|
-
return D({ f: o, r:
|
|
800
|
+
const o = t.fields.getById(m), u = e.map((f) => f[m] || null);
|
|
801
|
+
return D({ f: o, r: u }, ({ f, r: l }) => l || (f?.defaultValue ? f.defaultValue : null));
|
|
802
802
|
}
|
|
803
803
|
function S(m) {
|
|
804
804
|
const o = t.fields.getByName(m);
|
|
805
|
-
return D({ f: o, s: e }, ({ f:
|
|
806
|
-
const
|
|
807
|
-
return
|
|
805
|
+
return D({ f: o, s: e }, ({ f: u, s: f }) => {
|
|
806
|
+
const l = u && f[u.id] || null;
|
|
807
|
+
return l || (u?.defaultValue ? u.defaultValue : null);
|
|
808
808
|
});
|
|
809
809
|
}
|
|
810
810
|
return k({
|
|
811
811
|
clock: r,
|
|
812
|
-
target:
|
|
812
|
+
target: n.clearAll
|
|
813
813
|
}), k({
|
|
814
814
|
clock: s,
|
|
815
|
-
target:
|
|
815
|
+
target: n.clear
|
|
816
816
|
}), {
|
|
817
|
-
register:
|
|
817
|
+
register: p,
|
|
818
818
|
clearAll: r,
|
|
819
819
|
clear: s,
|
|
820
|
-
commit:
|
|
820
|
+
commit: i,
|
|
821
821
|
getResponsesToCommit: a,
|
|
822
|
-
listStore:
|
|
823
|
-
getAllStore:
|
|
822
|
+
listStore: d,
|
|
823
|
+
getAllStore: c,
|
|
824
824
|
getByFieldId: g,
|
|
825
825
|
getByFieldName: S
|
|
826
826
|
};
|
|
@@ -847,19 +847,19 @@ function rt() {
|
|
|
847
847
|
if (!_())
|
|
848
848
|
return {};
|
|
849
849
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
850
|
-
for (const [
|
|
851
|
-
|
|
852
|
-
for (const
|
|
853
|
-
const
|
|
854
|
-
e[
|
|
850
|
+
for (const [n] of t.entries())
|
|
851
|
+
n.startsWith("picked-") && r.add(n);
|
|
852
|
+
for (const n of r) {
|
|
853
|
+
const p = n.replace("picked-", "");
|
|
854
|
+
e[p] = t.getAll(n);
|
|
855
855
|
}
|
|
856
856
|
const s = A("s");
|
|
857
857
|
if (r.size > 0)
|
|
858
|
-
|
|
858
|
+
O.set(s, e);
|
|
859
859
|
else {
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
return
|
|
860
|
+
const n = O.get(s);
|
|
861
|
+
if (n)
|
|
862
|
+
return n.json() || {};
|
|
863
863
|
}
|
|
864
864
|
return e;
|
|
865
865
|
}
|
|
@@ -873,23 +873,23 @@ const nt = A("session", "global"), it = () => {
|
|
|
873
873
|
const t = C.get(nt);
|
|
874
874
|
let e;
|
|
875
875
|
t.isSet() && (e = t.json());
|
|
876
|
-
const r = (
|
|
877
|
-
id:
|
|
878
|
-
isUser:
|
|
879
|
-
identifiers:
|
|
876
|
+
const r = (n) => t.set({
|
|
877
|
+
id: n.id,
|
|
878
|
+
isUser: n.isUser,
|
|
879
|
+
identifiers: n.identifiers
|
|
880
880
|
}), s = {
|
|
881
881
|
id: e?.id ?? st(),
|
|
882
882
|
isUser: e?.isUser ?? void 0,
|
|
883
883
|
identifiers: e?.identifiers ?? void 0,
|
|
884
|
-
setIsUser(
|
|
885
|
-
this.isUser =
|
|
884
|
+
setIsUser(n) {
|
|
885
|
+
this.isUser = n, r(this);
|
|
886
886
|
},
|
|
887
|
-
setIdentifier(
|
|
888
|
-
this.identifiers = { ...this.identifiers, [
|
|
887
|
+
setIdentifier(n, p) {
|
|
888
|
+
this.identifiers = { ...this.identifiers, [n]: p }, r(this);
|
|
889
889
|
},
|
|
890
|
-
removeIdentifier(
|
|
890
|
+
removeIdentifier(n) {
|
|
891
891
|
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
892
|
-
Object.entries(this.identifiers).filter(([
|
|
892
|
+
Object.entries(this.identifiers).filter(([p]) => p !== n)
|
|
893
893
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
894
894
|
}
|
|
895
895
|
};
|
|
@@ -922,9 +922,9 @@ function dt(t) {
|
|
|
922
922
|
const s = ct();
|
|
923
923
|
if (s)
|
|
924
924
|
return s;
|
|
925
|
-
const
|
|
926
|
-
if (
|
|
927
|
-
return
|
|
925
|
+
const n = ut();
|
|
926
|
+
if (n)
|
|
927
|
+
return n;
|
|
928
928
|
throw new Error(
|
|
929
929
|
`organizationId and projectId are required. You can provide them via one of:
|
|
930
930
|
(1) createClient({ organizationId, projectId }) options;
|
|
@@ -949,7 +949,7 @@ const lt = {
|
|
|
949
949
|
if (Array.isArray(t))
|
|
950
950
|
return e.format(t.map(String));
|
|
951
951
|
if (t instanceof Map) {
|
|
952
|
-
const r = Array.from(t.entries()).map(([s,
|
|
952
|
+
const r = Array.from(t.entries()).map(([s, n]) => `${s}: ${n}`);
|
|
953
953
|
return e.format(r);
|
|
954
954
|
}
|
|
955
955
|
return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
|
|
@@ -968,28 +968,28 @@ function ft(t, e) {
|
|
|
968
968
|
return typeof r == "function" ? r() : r;
|
|
969
969
|
}
|
|
970
970
|
function gt(t, e) {
|
|
971
|
-
const r = t.split("|").map((
|
|
972
|
-
let
|
|
973
|
-
for (const
|
|
974
|
-
const [a, ...
|
|
975
|
-
g && (
|
|
971
|
+
const r = t.split("|").map((p) => p.trim()), s = r.shift() ?? "";
|
|
972
|
+
let n = ft(s, e);
|
|
973
|
+
for (const p of r) {
|
|
974
|
+
const [a, ...i] = p.split(":"), c = a?.trim() ?? "", d = i.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), g = lt[c];
|
|
975
|
+
g && (n = g(n, d));
|
|
976
976
|
}
|
|
977
|
-
return z(
|
|
977
|
+
return z(n) ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
|
|
978
978
|
}
|
|
979
979
|
function mt(t, e) {
|
|
980
980
|
let r = "", s = 0;
|
|
981
981
|
for (; s < t.length; )
|
|
982
982
|
if (t[s] === "{" && t[s + 1] === "{") {
|
|
983
983
|
s += 2;
|
|
984
|
-
let
|
|
984
|
+
let n = "";
|
|
985
985
|
for (; s < t.length; ) {
|
|
986
986
|
if (t[s] === "}" && t[s + 1] === "}") {
|
|
987
987
|
s += 2;
|
|
988
988
|
break;
|
|
989
989
|
}
|
|
990
|
-
|
|
990
|
+
n += t[s++];
|
|
991
991
|
}
|
|
992
|
-
r += gt(
|
|
992
|
+
r += gt(n.trim(), e);
|
|
993
993
|
} else
|
|
994
994
|
r += t[s++];
|
|
995
995
|
return r;
|
|
@@ -1011,6 +1011,7 @@ class ht {
|
|
|
1011
1011
|
session;
|
|
1012
1012
|
precondition;
|
|
1013
1013
|
condition;
|
|
1014
|
+
preconditionPassed;
|
|
1014
1015
|
searchParams = rt();
|
|
1015
1016
|
history = Ne();
|
|
1016
1017
|
components = Fe({ client: this });
|
|
@@ -1025,7 +1026,7 @@ class ht {
|
|
|
1025
1026
|
constructor(e) {
|
|
1026
1027
|
w("info", "Picked client initializing."), this.events = Le(this.eventBus);
|
|
1027
1028
|
const { organizationId: r, projectId: s } = dt(e);
|
|
1028
|
-
this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
|
|
1029
|
+
this.organizationId = r, this.projectId = s, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = ot(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: ce() }), w("info", "Picked client initialized.");
|
|
1029
1030
|
}
|
|
1030
1031
|
start = () => {
|
|
1031
1032
|
Be(this), (async () => {
|
|
@@ -1033,16 +1034,17 @@ class ht {
|
|
|
1033
1034
|
return;
|
|
1034
1035
|
await this.runPluginStartHooks();
|
|
1035
1036
|
const r = await this.evaluateGate(this.precondition);
|
|
1037
|
+
this.preconditionPassed = r;
|
|
1036
1038
|
let s;
|
|
1037
1039
|
r && (s = await this.evaluateGate(this.condition));
|
|
1038
|
-
const
|
|
1040
|
+
const n = r && s === !0;
|
|
1039
1041
|
if (typeof s == "boolean" && this.session) {
|
|
1040
|
-
const
|
|
1041
|
-
this.session.setIsUser(
|
|
1042
|
+
const p = s;
|
|
1043
|
+
this.session.setIsUser(p), this.eventBus({ type: "user_decide", value: p });
|
|
1042
1044
|
}
|
|
1043
|
-
if (this.eventBus({ type: "initialize" }),
|
|
1044
|
-
const { id:
|
|
1045
|
-
this.eventBus({ type: "session", id:
|
|
1045
|
+
if (this.eventBus({ type: "initialize" }), n && H(this), await oe(), n && H(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1046
|
+
const { id: p, isUser: a, identifiers: i } = this.session;
|
|
1047
|
+
this.eventBus({ type: "session", id: p, isUser: a, identifiers: i });
|
|
1046
1048
|
}
|
|
1047
1049
|
})();
|
|
1048
1050
|
};
|
|
@@ -1061,7 +1063,7 @@ class ht {
|
|
|
1061
1063
|
De(e, r, this.features);
|
|
1062
1064
|
};
|
|
1063
1065
|
registerPredicate = (e, r) => {
|
|
1064
|
-
|
|
1066
|
+
Oe(e, r, this.predicates);
|
|
1065
1067
|
};
|
|
1066
1068
|
registerField = (e) => {
|
|
1067
1069
|
Je(e, this.fields);
|
|
@@ -1107,20 +1109,20 @@ class ht {
|
|
|
1107
1109
|
setupFeatures() {
|
|
1108
1110
|
const e = this.options.features;
|
|
1109
1111
|
e && (Object.entries(e).forEach(([r, s]) => {
|
|
1110
|
-
const
|
|
1111
|
-
this.registerFeature(r,
|
|
1112
|
+
const n = typeof s == "function" ? s() : s;
|
|
1113
|
+
this.registerFeature(r, n);
|
|
1112
1114
|
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
1113
1115
|
try {
|
|
1114
|
-
const [s,
|
|
1115
|
-
if (!s || !
|
|
1116
|
+
const [s, n] = r.split(":");
|
|
1117
|
+
if (!s || !n)
|
|
1116
1118
|
return;
|
|
1117
|
-
let
|
|
1118
|
-
|
|
1119
|
-
key: `${
|
|
1119
|
+
let p = n;
|
|
1120
|
+
p === "true" && (p = !0), p === "false" && (p = !1), this.registerFeature(s, {
|
|
1121
|
+
key: `${p}`,
|
|
1120
1122
|
// use the assigned bucket value as the key
|
|
1121
1123
|
name: s,
|
|
1122
1124
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
1123
|
-
decide: () =>
|
|
1125
|
+
decide: () => p,
|
|
1124
1126
|
storage: "session"
|
|
1125
1127
|
});
|
|
1126
1128
|
} catch {
|
|
@@ -1147,6 +1149,12 @@ class ht {
|
|
|
1147
1149
|
this.registerAction(r, s);
|
|
1148
1150
|
});
|
|
1149
1151
|
}
|
|
1152
|
+
setupComponents() {
|
|
1153
|
+
const e = this.options.components;
|
|
1154
|
+
e && Object.entries(e).forEach(([r, s]) => {
|
|
1155
|
+
this.registerComponent(r, s);
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1150
1158
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1151
1159
|
/**
|
|
1152
1160
|
* Interpolates a template string using values from the client's response store and/or a provided context.
|
|
@@ -1191,7 +1199,7 @@ class ht {
|
|
|
1191
1199
|
* // => "Fruits: apple, banana, and cherry"
|
|
1192
1200
|
*/
|
|
1193
1201
|
renderString = (e, r) => {
|
|
1194
|
-
const s = this.responses.listStore.getState().reduce((
|
|
1202
|
+
const s = this.responses.listStore.getState().reduce((n, p) => (n[p.fieldId] = p.value, n), {});
|
|
1195
1203
|
return mt(e, {
|
|
1196
1204
|
...r,
|
|
1197
1205
|
responses: s
|
|
@@ -1212,8 +1220,8 @@ async function Et(t, e) {
|
|
|
1212
1220
|
if (!s.options || !Z(s))
|
|
1213
1221
|
return s;
|
|
1214
1222
|
const a = (await Promise.all(
|
|
1215
|
-
s.options.map(async (
|
|
1216
|
-
)).filter((
|
|
1223
|
+
s.options.map(async (c) => c.condition ? await P(t, c.condition) ? c : null : c)
|
|
1224
|
+
)).filter((c) => c !== null);
|
|
1217
1225
|
return a.length === s.options.length ? s : a.length === 0 ? null : { ...s, options: a };
|
|
1218
1226
|
})
|
|
1219
1227
|
)).filter((s) => s !== null);
|
|
@@ -1242,8 +1250,8 @@ export {
|
|
|
1242
1250
|
zt as isPickedRoot,
|
|
1243
1251
|
Pt as lazyComponent,
|
|
1244
1252
|
C as localStore,
|
|
1245
|
-
|
|
1246
|
-
|
|
1253
|
+
O as sessionStore,
|
|
1254
|
+
Ot as subscribe,
|
|
1247
1255
|
Ut as supportsCookies,
|
|
1248
1256
|
pe as supportsCryptoRandomUUID,
|
|
1249
1257
|
L as supportsDocument,
|