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