@picked/client 0.0.1-dev.1765246229329 → 0.0.1-dev.1765328754832
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 +4 -1
- package/dist/esm/index.js +836 -161
- package/dist/esm/plugins/single-page-app/index.js +3 -3
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +7 -7
- package/dist/{experience-instance-Du9C8zgX.js → experience-instance-C4INDX6a.js} +7 -7
- package/dist/{supports-DBMT17KZ.js → supports-BjhuLJ8z.js} +10 -10
- package/dist/types/client.d.ts +6 -4
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +4 -5
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +12 -0
- package/dist/types/utils/picked-config.d.ts.map +1 -0
- package/dist/types/utils/user-session.d.ts +3 -0
- package/dist/types/utils/user-session.d.ts.map +1 -1
- package/package.json +1 -7
- package/dist/cjs/plugins/data-layer/index.js +0 -1
- package/dist/esm/plugins/data-layer/index.js +0 -146
- package/dist/types/plugins/data-layer/index.d.ts +0 -2
- package/dist/types/plugins/data-layer/index.d.ts.map +0 -1
- package/dist/types/plugins/data-layer/plugin.d.ts +0 -74
- package/dist/types/plugins/data-layer/plugin.d.ts.map +0 -1
- package/dist/user-session-CRVgPCug.cjs +0 -1
- package/dist/user-session-DejpEbvb.js +0 -650
package/dist/esm/index.js
CHANGED
|
@@ -1,146 +1,820 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { c as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
var Y = Object.defineProperty;
|
|
2
|
+
var J = (t, e, r) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var m = (t, e, r) => J(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { createDomain as b, createApi as F, createEffect as M, attach as Q, sample as x, combine as z, createEvent as C } from "effector";
|
|
5
|
+
import { createFactory as k, invoke as w } from "@withease/factories";
|
|
6
|
+
import { g as G, t as X, c as Z, i as ee, e as E, a as te, b as re, d as ne } from "../experience-instance-C4INDX6a.js";
|
|
7
|
+
import { f as It } from "../experience-instance-C4INDX6a.js";
|
|
8
|
+
import { l as S } from "../logger-C9a75KZn.js";
|
|
9
|
+
import { c as R, l as $, s as O } from "../storage-BLmAhfhl.js";
|
|
10
|
+
import { a as Ft } from "../storage-BLmAhfhl.js";
|
|
11
|
+
import { g as se } from "../id-BW-g3y32.js";
|
|
12
|
+
import { i as ie } from "../object-JwZ58NOH.js";
|
|
13
|
+
import { s as D, a as U, b as oe, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
|
|
14
|
+
import { h as Et, f as jt, j as Pt, e as Rt, g as Bt, i as At, k as $t } from "../supports-BjhuLJ8z.js";
|
|
15
|
+
const H = b("experience"), ue = k(
|
|
16
|
+
({ client: t, experience: e }) => {
|
|
17
|
+
const r = H.store(e), n = F(r, {
|
|
18
|
+
merge(d, h) {
|
|
19
|
+
return {
|
|
20
|
+
...d,
|
|
21
|
+
...h.experience
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}), i = r.map((d) => ({
|
|
25
|
+
name: d.name,
|
|
26
|
+
decisionLogic: d.condition ?? d.decide,
|
|
27
|
+
targetSelectors: d.targets,
|
|
28
|
+
initializeOpenLogic: e.initializeOpen
|
|
29
|
+
})), a = t.components.listStore.map(
|
|
30
|
+
(d) => d.find((h) => h.name === `experience:${e.id}`) || d.find((h) => h.name === "experience"),
|
|
31
|
+
{ skipVoid: !1 }
|
|
32
|
+
), s = r.map((d) => ({
|
|
33
|
+
steps: d.steps,
|
|
34
|
+
nodes: d.nodes,
|
|
35
|
+
edges: d.edges,
|
|
36
|
+
conditionals: d.conditionals
|
|
37
|
+
})), o = e.actions ?? [];
|
|
38
|
+
return {
|
|
39
|
+
id: e.id,
|
|
40
|
+
configStore: i,
|
|
41
|
+
treeStore: s,
|
|
42
|
+
componentStore: a,
|
|
43
|
+
actions: o,
|
|
44
|
+
merge: n.merge
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
function de(t) {
|
|
49
|
+
return w(ue, t);
|
|
50
|
+
}
|
|
51
|
+
const le = k(({ client: t }) => {
|
|
52
|
+
const e = H.store({}), r = F(e, {
|
|
53
|
+
register(s, o) {
|
|
54
|
+
return {
|
|
55
|
+
...s,
|
|
56
|
+
[o.id]: o
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
function n(s) {
|
|
61
|
+
const o = e.getState()[s.id];
|
|
62
|
+
if (o) {
|
|
63
|
+
o.merge({ experience: s, strategy: "override" });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const d = de({ client: t, experience: s });
|
|
67
|
+
r.register(d);
|
|
68
|
+
}
|
|
69
|
+
const i = e.map((s) => Object.values(s));
|
|
70
|
+
function a(s) {
|
|
71
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
register: n,
|
|
75
|
+
getById: a,
|
|
76
|
+
listStore: i
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
function pe(t) {
|
|
80
|
+
return w(le, t);
|
|
81
|
+
}
|
|
82
|
+
const ge = (t, e) => {
|
|
83
|
+
e.register(t);
|
|
84
|
+
}, q = (t, e) => {
|
|
85
|
+
const { targetSelectors: r } = e.configStore.getState(), n = G(r, e.id);
|
|
86
|
+
n.forEach(
|
|
87
|
+
({ elements: a }) => a.forEach((s) => X(s, e.id))
|
|
88
|
+
), Z(n, e.id).forEach((a) => {
|
|
89
|
+
t.experienceInstances.spawn(e, a);
|
|
90
|
+
});
|
|
91
|
+
}, T = async (t) => {
|
|
92
|
+
await Promise.all(
|
|
93
|
+
t.experiences.listStore.getState().map(async (e) => {
|
|
94
|
+
await fe(t, e) && q(t, e);
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
}, fe = async (t, e) => {
|
|
98
|
+
const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
|
|
99
|
+
return G(n, e.id).length < 1 || n.length === 0 ? !1 : r && ee(r) ? await E(t, r) === !0 : !0;
|
|
100
|
+
}, me = (t, e, r) => {
|
|
101
|
+
const n = e.name, i = e.setup(t);
|
|
102
|
+
if (i) {
|
|
103
|
+
const a = r[n] ?? {};
|
|
104
|
+
r[n] = Object.freeze({ ...a, ...i });
|
|
105
|
+
}
|
|
106
|
+
}, he = b("component"), ye = k(
|
|
107
|
+
({ client: t, component: e, name: r }) => {
|
|
108
|
+
const n = t.frameworks.getByName(e.frameworkName);
|
|
109
|
+
return {
|
|
110
|
+
name: r,
|
|
111
|
+
component: e,
|
|
112
|
+
frameworkStore: n
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
function ve(t) {
|
|
117
|
+
return w(ye, t);
|
|
118
|
+
}
|
|
119
|
+
const Se = k(({ client: t }) => {
|
|
120
|
+
const e = he.store({}), r = F(e, {
|
|
121
|
+
register(s, o) {
|
|
122
|
+
return {
|
|
123
|
+
...s,
|
|
124
|
+
[o.name]: o
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
function n(s, o) {
|
|
129
|
+
e.getState()[s] && S(
|
|
130
|
+
"warn",
|
|
131
|
+
`Component '${s}' already registered. Registering again will override the previous registration.`
|
|
132
|
+
);
|
|
133
|
+
const h = ve({ client: t, name: s, component: o });
|
|
134
|
+
r.register(h);
|
|
135
|
+
}
|
|
136
|
+
const i = e.map((s) => Object.values(s));
|
|
137
|
+
function a(s) {
|
|
138
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
register: n,
|
|
142
|
+
getByName: a,
|
|
143
|
+
listStore: i
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
function ke(t) {
|
|
147
|
+
return w(Se, t);
|
|
148
|
+
}
|
|
149
|
+
const V = (t, e, r) => {
|
|
150
|
+
r.register(t, e);
|
|
151
|
+
}, we = b("framework"), Ie = k(({ client: t }) => {
|
|
152
|
+
const e = we.store({}), r = F(e, {
|
|
153
|
+
register(s, o) {
|
|
154
|
+
return {
|
|
155
|
+
...s,
|
|
156
|
+
[o.name]: o.framework
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
function n(s, o) {
|
|
161
|
+
e.getState()[s] && S(
|
|
162
|
+
"warn",
|
|
163
|
+
`Framework '${s}' already registered. Registering again will override the previous registration.`
|
|
164
|
+
), r.register({ name: s, framework: o });
|
|
165
|
+
}
|
|
166
|
+
const i = e.map((s) => Object.values(s));
|
|
167
|
+
function a(s) {
|
|
168
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
register: n,
|
|
172
|
+
getByName: a,
|
|
173
|
+
listStore: i
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
function be(t) {
|
|
177
|
+
return w(Ie, t);
|
|
178
|
+
}
|
|
179
|
+
const Fe = (t, e) => {
|
|
180
|
+
e.register(t.name, t);
|
|
181
|
+
}, xe = 6e3, Ee = R("last_ping", "global"), je = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
|
|
182
|
+
try {
|
|
183
|
+
const e = Date.now(), r = $.get(Ee);
|
|
184
|
+
let n = 0;
|
|
185
|
+
if (r.isSet() && (n = r.json() ?? 0), n && e - n < xe)
|
|
186
|
+
return !0;
|
|
187
|
+
const i = je(t.apiUrl), a = {
|
|
188
|
+
projectId: t.projectId,
|
|
189
|
+
path: window.location.pathname
|
|
190
|
+
}, s = JSON.stringify(a), o = {
|
|
191
|
+
"Content-Type": "application/json"
|
|
192
|
+
}, d = document.getElementById("picked_script"), h = d == null ? void 0 : d.dataset.verceltoken;
|
|
193
|
+
h && (o["x-vercel-protection-bypass"] = h);
|
|
194
|
+
const l = (await fetch(i, {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: o,
|
|
197
|
+
body: s
|
|
198
|
+
})).ok;
|
|
199
|
+
return l && r.set(e), l;
|
|
200
|
+
} catch (e) {
|
|
201
|
+
return S("error", e), !1;
|
|
18
202
|
}
|
|
19
203
|
};
|
|
20
|
-
function
|
|
21
|
-
const e = typeof window < "u",
|
|
22
|
-
client:
|
|
23
|
-
responses:
|
|
24
|
-
fields:
|
|
204
|
+
function Re(t) {
|
|
205
|
+
const e = typeof window < "u", r = {
|
|
206
|
+
client: t,
|
|
207
|
+
responses: t.responses.listStore.getState(),
|
|
208
|
+
fields: t.fields.listStore.getState(),
|
|
25
209
|
location: e ? window.location : void 0,
|
|
26
210
|
document: e ? window.document : void 0,
|
|
27
211
|
sessionStorage: e ? window.sessionStorage : void 0,
|
|
28
212
|
localStorage: e ? window.localStorage : void 0
|
|
29
213
|
};
|
|
30
|
-
return Object.freeze(
|
|
214
|
+
return Object.freeze(r);
|
|
215
|
+
}
|
|
216
|
+
const Be = b("predicate"), Ae = k(({ client: t }) => {
|
|
217
|
+
const e = Be.store({}), r = F(e, {
|
|
218
|
+
register(s, o) {
|
|
219
|
+
return {
|
|
220
|
+
...s,
|
|
221
|
+
[o.name]: {
|
|
222
|
+
name: o.name,
|
|
223
|
+
predicate: o.predicate
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
function n(s, o) {
|
|
229
|
+
e.getState()[s] && S(
|
|
230
|
+
"warn",
|
|
231
|
+
`Predicate '${s}' already registered. Registering again will override the previous registration.`
|
|
232
|
+
), r.register(Object.freeze({ name: s, predicate: o }));
|
|
233
|
+
}
|
|
234
|
+
const i = e.map((s) => Object.values(s));
|
|
235
|
+
function a(s) {
|
|
236
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
register: n,
|
|
240
|
+
getByName: a,
|
|
241
|
+
listStore: i
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
function $e(t) {
|
|
245
|
+
return w(Ae, t);
|
|
246
|
+
}
|
|
247
|
+
const Oe = (t, e, r) => {
|
|
248
|
+
r.register(t, e);
|
|
249
|
+
}, N = b("feature"), ze = k(({ client: t }) => {
|
|
250
|
+
const e = N.store({}), r = N.store([]), n = F(e, {
|
|
251
|
+
register(l, u) {
|
|
252
|
+
return {
|
|
253
|
+
...l,
|
|
254
|
+
[u.id]: u.feature
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
function i(l, u) {
|
|
259
|
+
e.getState()[l] && S(
|
|
260
|
+
"warn",
|
|
261
|
+
`Feature '${l}' already registered. Registering again will override the previous registration.`
|
|
262
|
+
);
|
|
263
|
+
const p = {
|
|
264
|
+
id: l,
|
|
265
|
+
feature: {
|
|
266
|
+
...u,
|
|
267
|
+
id: l
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
n.register(
|
|
271
|
+
Object.freeze({
|
|
272
|
+
id: l,
|
|
273
|
+
feature: p
|
|
274
|
+
})
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
const a = M(
|
|
278
|
+
async ({
|
|
279
|
+
id: l,
|
|
280
|
+
key: u,
|
|
281
|
+
storage: c = "local"
|
|
282
|
+
}) => {
|
|
283
|
+
const p = R(`feature:${l}:${u}`, "global"), g = (c === "session" ? O : $).get(p).boolean();
|
|
284
|
+
return g === null ? null : { id: l, key: u, bucket: g, storage: c };
|
|
285
|
+
}
|
|
286
|
+
), s = M((l) => {
|
|
287
|
+
if (!l)
|
|
288
|
+
return null;
|
|
289
|
+
const u = R(`feature:${l.id}:${l.key}`, "global");
|
|
290
|
+
(l.storage === "session" ? O : $).set(u, l.bucket);
|
|
291
|
+
}), o = /* @__PURE__ */ new Map(), d = Q({
|
|
292
|
+
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
293
|
+
effect: async ({ allFeaturesStore: l, resolvedFeaturesStore: u }, { id: c, decide: p, key: f }) => {
|
|
294
|
+
const g = u.find(
|
|
295
|
+
(A) => A.id === c && A.key === f
|
|
296
|
+
);
|
|
297
|
+
if (g)
|
|
298
|
+
return g;
|
|
299
|
+
const y = l[c];
|
|
300
|
+
if (!y)
|
|
301
|
+
throw new Error(`Feature with id '${c}' not found`);
|
|
302
|
+
const I = o.get(`${c}:${f}`);
|
|
303
|
+
if (I !== void 0) {
|
|
304
|
+
const A = await I;
|
|
305
|
+
return { id: y.id, bucket: A, key: f, storage: y.feature.storage };
|
|
306
|
+
}
|
|
307
|
+
const B = p();
|
|
308
|
+
o.set(`${c}:${f}`, B);
|
|
309
|
+
const j = await B;
|
|
310
|
+
return { id: y.id, bucket: j, key: f, storage: y.feature.storage };
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
x({
|
|
314
|
+
clock: n.register,
|
|
315
|
+
fn: (l) => {
|
|
316
|
+
const { id: u, feature: c } = l;
|
|
317
|
+
return { id: u, key: c.feature.key, storage: c.feature.storage };
|
|
318
|
+
},
|
|
319
|
+
target: a
|
|
320
|
+
}), x({
|
|
321
|
+
source: e,
|
|
322
|
+
clock: d.doneData,
|
|
323
|
+
fn: (l, u) => {
|
|
324
|
+
var y;
|
|
325
|
+
const { id: c, bucket: p, storage: f } = u, g = (y = l[c]) == null ? void 0 : y.feature.key;
|
|
326
|
+
return g ? { key: g, id: c, bucket: p, storage: f } : null;
|
|
327
|
+
},
|
|
328
|
+
target: s
|
|
329
|
+
});
|
|
330
|
+
const h = z({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
331
|
+
({
|
|
332
|
+
allFeaturesStore: l,
|
|
333
|
+
resolvedFeaturesStore: u
|
|
334
|
+
}) => Object.values(l).map((c) => {
|
|
335
|
+
const p = u.find(
|
|
336
|
+
(f) => f.id === c.id && f.key === c.feature.key
|
|
337
|
+
);
|
|
338
|
+
return p ? {
|
|
339
|
+
id: c.id,
|
|
340
|
+
name: c.feature.name,
|
|
341
|
+
key: c.feature.key,
|
|
342
|
+
getBucket: () => ({ id: c.id, bucket: p.bucket }),
|
|
343
|
+
isResolved: !0
|
|
344
|
+
} : {
|
|
345
|
+
id: c.id,
|
|
346
|
+
name: c.feature.name,
|
|
347
|
+
key: c.feature.key,
|
|
348
|
+
getBucket: async () => await d(c.feature),
|
|
349
|
+
isResolved: !1
|
|
350
|
+
};
|
|
351
|
+
})
|
|
352
|
+
);
|
|
353
|
+
x({
|
|
354
|
+
clock: d.doneData,
|
|
355
|
+
source: { resolvedFeatures: r },
|
|
356
|
+
filter: ({ resolvedFeatures: l }, { id: u, key: c }) => !l.some(
|
|
357
|
+
(f) => f.id === u && f.key === c
|
|
358
|
+
),
|
|
359
|
+
fn: (l, u) => u,
|
|
360
|
+
target: t.eventBus.prepend((l) => ({
|
|
361
|
+
type: "feature_decide",
|
|
362
|
+
feature: l
|
|
363
|
+
}))
|
|
364
|
+
}), x({
|
|
365
|
+
clock: [a.doneData, d.doneData],
|
|
366
|
+
source: r,
|
|
367
|
+
fn: (l, u) => !u || l.some(
|
|
368
|
+
(p) => p.id === u.id && p.key === u.key
|
|
369
|
+
) ? l : [...l, u],
|
|
370
|
+
target: r
|
|
371
|
+
});
|
|
372
|
+
function v(l) {
|
|
373
|
+
return e.map((u) => u[l], { skipVoid: !1 });
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
register: i,
|
|
377
|
+
getByName: v,
|
|
378
|
+
listStore: h
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
function Ce(t) {
|
|
382
|
+
return w(ze, t);
|
|
31
383
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
384
|
+
const De = (t, e, r) => {
|
|
385
|
+
r.register(t, e);
|
|
386
|
+
}, P = b("history");
|
|
387
|
+
function _(t, e) {
|
|
388
|
+
return {
|
|
389
|
+
// eslint-disable-next-line sonarjs/pseudo-random
|
|
390
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
391
|
+
node: e,
|
|
392
|
+
at: Date.now(),
|
|
393
|
+
experienceId: t
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
const Ue = k(() => {
|
|
397
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), i = P.event();
|
|
398
|
+
t.on(e, (s, o) => ({
|
|
399
|
+
entries: [...s.entries, _(o.experienceId, o.node)]
|
|
400
|
+
})), t.on(r, (s, o) => ({
|
|
401
|
+
entries: [
|
|
402
|
+
...s.entries.slice(0, -1),
|
|
403
|
+
_(o.experienceId, o.node)
|
|
404
|
+
]
|
|
405
|
+
})), t.on(i, (s, o) => o);
|
|
406
|
+
function a(s, o) {
|
|
407
|
+
const d = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
408
|
+
for (let h = s.length - 1; h >= 0; h--) {
|
|
409
|
+
const v = s[h], l = v == null ? void 0 : v.node;
|
|
410
|
+
if (!(!l || !te(l)) && !(o && (v == null ? void 0 : v.experienceId) !== o))
|
|
411
|
+
if (d.lastStepIndex === -1)
|
|
412
|
+
d.lastStepIndex = h;
|
|
413
|
+
else {
|
|
414
|
+
d.secondLastStepIndex = h;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return d;
|
|
419
|
+
}
|
|
420
|
+
return t.on(n, (s, o) => {
|
|
421
|
+
const { secondLastStepIndex: d } = a(s.entries, o.experienceId), h = d !== -1 ? s.entries.slice(0, d + 1) : s.entries;
|
|
422
|
+
return {
|
|
423
|
+
...s,
|
|
424
|
+
entries: h
|
|
425
|
+
};
|
|
426
|
+
}), {
|
|
427
|
+
push: e,
|
|
428
|
+
replace: r,
|
|
429
|
+
back: n,
|
|
430
|
+
restore: i,
|
|
431
|
+
entriesStore: t.map((s) => s.entries)
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
function Me() {
|
|
435
|
+
return w(Ue);
|
|
436
|
+
}
|
|
437
|
+
const Te = () => C(), Ve = b("field"), Ne = k(() => {
|
|
438
|
+
const t = Ve.store({}), e = F(t, {
|
|
439
|
+
register(s, o) {
|
|
440
|
+
return {
|
|
441
|
+
...s,
|
|
442
|
+
[o.field.id]: o.field
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
function r(s) {
|
|
447
|
+
e.register({ field: s });
|
|
448
|
+
}
|
|
449
|
+
const n = t.map((s) => Object.values(s));
|
|
450
|
+
function i(s) {
|
|
451
|
+
return t.map((o) => o[s] || null);
|
|
452
|
+
}
|
|
453
|
+
function a(s) {
|
|
454
|
+
return t.map((o) => Object.values(o).find((d) => d.name === s) || null);
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
register: r,
|
|
458
|
+
getById: i,
|
|
459
|
+
listStore: n,
|
|
460
|
+
getByName: a
|
|
461
|
+
};
|
|
462
|
+
});
|
|
463
|
+
function _e() {
|
|
464
|
+
return w(Ne);
|
|
465
|
+
}
|
|
466
|
+
const Le = (t, e) => {
|
|
467
|
+
e.register(t);
|
|
468
|
+
}, Ge = b("action"), He = k(() => {
|
|
469
|
+
const t = Ge.store({}), e = F(t, {
|
|
470
|
+
register(a, s) {
|
|
471
|
+
return {
|
|
472
|
+
...a,
|
|
473
|
+
[s.name]: {
|
|
474
|
+
name: s.name,
|
|
475
|
+
action: s.action
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
function r(a, s) {
|
|
481
|
+
e.register({ name: a, action: s });
|
|
482
|
+
}
|
|
483
|
+
const n = t.map((a) => Object.values(a));
|
|
484
|
+
function i(a) {
|
|
485
|
+
return t.map((s) => s[a], { skipVoid: !1 });
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
register: r,
|
|
489
|
+
getByName: i,
|
|
490
|
+
listStore: n
|
|
491
|
+
};
|
|
492
|
+
});
|
|
493
|
+
function qe() {
|
|
494
|
+
return w(He);
|
|
495
|
+
}
|
|
496
|
+
const Ke = (t, e, r) => {
|
|
497
|
+
r.register(t, e);
|
|
498
|
+
};
|
|
499
|
+
function L(t) {
|
|
500
|
+
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
501
|
+
}
|
|
502
|
+
const We = b("response"), Ye = k(({ client: t }) => {
|
|
503
|
+
const e = We.store({}), r = C(), n = C(), i = F(e, {
|
|
504
|
+
register(u, c) {
|
|
505
|
+
return {
|
|
506
|
+
...u,
|
|
507
|
+
[c.fieldId]: c.response
|
|
508
|
+
};
|
|
509
|
+
},
|
|
510
|
+
registerBatch(u, c) {
|
|
511
|
+
return {
|
|
512
|
+
...u,
|
|
513
|
+
...c
|
|
514
|
+
};
|
|
515
|
+
},
|
|
516
|
+
clear(u, c) {
|
|
517
|
+
const { [c]: p, ...f } = u;
|
|
518
|
+
return f;
|
|
519
|
+
},
|
|
520
|
+
clearAll() {
|
|
521
|
+
return {};
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
function a(u, c) {
|
|
525
|
+
i.register({ fieldId: u, response: c });
|
|
526
|
+
}
|
|
527
|
+
async function s(u) {
|
|
528
|
+
const c = [];
|
|
529
|
+
return await Promise.allSettled(
|
|
530
|
+
Object.entries(u).map(async ([p, f]) => {
|
|
531
|
+
let g = f;
|
|
532
|
+
const y = t.fields.getById(p).getState();
|
|
533
|
+
if (!y) {
|
|
534
|
+
c.push({
|
|
535
|
+
fieldId: p,
|
|
536
|
+
userMessage: `Field '${p}' not found`,
|
|
537
|
+
systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
538
|
+
value: g
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
if (y.multiple && (typeof g == "string" || typeof g == "number" || typeof g == "boolean") && (g = [g]), y.validation && !ie(y.validation) && !L(g)) {
|
|
543
|
+
const I = await E(t, y.validation, {
|
|
544
|
+
$input: g
|
|
545
|
+
});
|
|
546
|
+
if (typeof I == "string") {
|
|
547
|
+
c.push({
|
|
548
|
+
fieldId: p,
|
|
549
|
+
userMessage: I,
|
|
550
|
+
systemMessage: `Field validation resulted in an error: ${I}.`,
|
|
551
|
+
value: g
|
|
552
|
+
});
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (I === !1) {
|
|
556
|
+
c.push({
|
|
557
|
+
fieldId: p,
|
|
558
|
+
userMessage: "This field is invalid",
|
|
559
|
+
systemMessage: "Field validation resulted in an unspecified error.",
|
|
560
|
+
value: g
|
|
561
|
+
});
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (y.required && L(g)) {
|
|
566
|
+
c.push({
|
|
567
|
+
fieldId: p,
|
|
568
|
+
userMessage: "This field is required",
|
|
569
|
+
systemMessage: "Field is required.",
|
|
570
|
+
value: g
|
|
571
|
+
});
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (!y.multiple && Array.isArray(g) && g.length > 1) {
|
|
575
|
+
c.push({
|
|
576
|
+
fieldId: p,
|
|
577
|
+
userMessage: "This field expects a single response",
|
|
578
|
+
systemMessage: "Field expects a single response.",
|
|
579
|
+
value: g
|
|
580
|
+
});
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (y.options) {
|
|
584
|
+
const I = y.options.map((j) => j.value), B = Array.isArray(g) ? g : [g];
|
|
585
|
+
Array.isArray(g) && (B.every((j) => I.includes(j)) || c.push({
|
|
586
|
+
fieldId: p,
|
|
587
|
+
userMessage: "This field expects a valid option",
|
|
588
|
+
systemMessage: `Field expects a valid option. Valid options are: ${I.join(", ")}`,
|
|
589
|
+
value: g
|
|
590
|
+
}));
|
|
591
|
+
}
|
|
592
|
+
})
|
|
593
|
+
), { responsesToCommit: u, validationErrors: c };
|
|
594
|
+
}
|
|
595
|
+
async function o(u) {
|
|
596
|
+
const { responsesToCommit: c, validationErrors: p } = await s(u);
|
|
597
|
+
return p.length ? { errors: p } : (i.registerBatch(c), { errors: [] });
|
|
598
|
+
}
|
|
599
|
+
const d = e.map((u) => u), h = e.map((u) => Object.keys(u).map((p) => ({
|
|
600
|
+
fieldId: p,
|
|
601
|
+
value: u[p]
|
|
602
|
+
})));
|
|
603
|
+
function v(u) {
|
|
604
|
+
const c = t.fields.getById(u), p = e.map((f) => f[u] || null);
|
|
605
|
+
return z({ f: c, r: p }, ({ f, r: g }) => g || (f != null && f.defaultValue ? f.defaultValue : null));
|
|
606
|
+
}
|
|
607
|
+
function l(u) {
|
|
608
|
+
const c = t.fields.getByName(u);
|
|
609
|
+
return z({ f: c, s: e }, ({ f: p, s: f }) => {
|
|
610
|
+
const g = p && f[p.id] || null;
|
|
611
|
+
return g || (p != null && p.defaultValue ? p.defaultValue : null);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
return x({
|
|
615
|
+
clock: r,
|
|
616
|
+
target: i.clearAll
|
|
617
|
+
}), x({
|
|
618
|
+
clock: n,
|
|
619
|
+
target: i.clear
|
|
620
|
+
}), {
|
|
621
|
+
register: a,
|
|
622
|
+
clearAll: r,
|
|
623
|
+
clear: n,
|
|
624
|
+
commit: o,
|
|
625
|
+
getResponsesToCommit: s,
|
|
626
|
+
listStore: h,
|
|
627
|
+
getAllStore: d,
|
|
628
|
+
getByFieldId: v,
|
|
629
|
+
getByFieldName: l
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
function Je(t) {
|
|
633
|
+
return w(Ye, t);
|
|
634
|
+
}
|
|
635
|
+
const Qe = () => "0.0.1-dev.1765328754832";
|
|
636
|
+
function Xe() {
|
|
637
|
+
if (D()) {
|
|
638
|
+
const t = [
|
|
36
639
|
document.currentScript,
|
|
37
640
|
document.getElementById("picked_script"),
|
|
38
641
|
document.getElementById("picked"),
|
|
39
642
|
document.getElementById("cvly"),
|
|
40
643
|
document.getElementById("cvly-x")
|
|
41
644
|
];
|
|
42
|
-
for (const e of
|
|
645
|
+
for (const e of t)
|
|
43
646
|
if (e != null && e.dataset.api)
|
|
44
647
|
return e.dataset.api;
|
|
45
648
|
}
|
|
46
649
|
return "https://api.picked.app";
|
|
47
650
|
}
|
|
48
|
-
function
|
|
49
|
-
if (!
|
|
651
|
+
function Ze() {
|
|
652
|
+
if (!U())
|
|
50
653
|
return {};
|
|
51
|
-
const
|
|
52
|
-
for (const [
|
|
53
|
-
|
|
54
|
-
for (const
|
|
55
|
-
const
|
|
56
|
-
e[
|
|
57
|
-
}
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
|
|
654
|
+
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
655
|
+
for (const [i] of t.entries())
|
|
656
|
+
i.startsWith("picked-") && r.add(i);
|
|
657
|
+
for (const i of r) {
|
|
658
|
+
const a = i.replace("picked-", "");
|
|
659
|
+
e[a] = t.getAll(i);
|
|
660
|
+
}
|
|
661
|
+
const n = R("s");
|
|
662
|
+
if (r.size > 0)
|
|
663
|
+
O.set(n, e);
|
|
61
664
|
else {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
665
|
+
const i = O.get(n);
|
|
666
|
+
if (i)
|
|
667
|
+
return i.json() || {};
|
|
65
668
|
}
|
|
66
669
|
return e;
|
|
67
670
|
}
|
|
68
|
-
|
|
671
|
+
function et() {
|
|
672
|
+
if (ae())
|
|
673
|
+
return crypto.randomUUID();
|
|
674
|
+
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);
|
|
675
|
+
return `${t}-${e}-${r}-${n}`;
|
|
676
|
+
}
|
|
677
|
+
const tt = R("session", "global"), rt = () => {
|
|
678
|
+
const t = $.get(tt);
|
|
679
|
+
let e;
|
|
680
|
+
t.isSet() && (e = t.json());
|
|
681
|
+
const r = (i) => t.set({
|
|
682
|
+
id: i.id,
|
|
683
|
+
isUser: i.isUser,
|
|
684
|
+
identifiers: i.identifiers
|
|
685
|
+
}), n = {
|
|
686
|
+
id: (e == null ? void 0 : e.id) ?? et(),
|
|
687
|
+
isUser: (e == null ? void 0 : e.isUser) ?? void 0,
|
|
688
|
+
identifiers: (e == null ? void 0 : e.identifiers) ?? void 0,
|
|
689
|
+
setIsUser(i) {
|
|
690
|
+
this.isUser = i, r(this);
|
|
691
|
+
},
|
|
692
|
+
setIdentifier(i, a) {
|
|
693
|
+
this.identifiers = { ...this.identifiers, [i]: a }, r(this);
|
|
694
|
+
},
|
|
695
|
+
removeIdentifier(i) {
|
|
696
|
+
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
697
|
+
Object.entries(this.identifiers).filter(([a]) => a !== i)
|
|
698
|
+
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
return r(n), n;
|
|
702
|
+
}, nt = () => oe() ? rt() : null;
|
|
703
|
+
function st() {
|
|
704
|
+
if (U())
|
|
705
|
+
return globalThis.window.pickedConfig;
|
|
706
|
+
}
|
|
707
|
+
function it() {
|
|
708
|
+
if (!U())
|
|
709
|
+
return;
|
|
710
|
+
const t = st(), e = t == null ? void 0 : t.organizationId, r = t == null ? void 0 : t.projectId;
|
|
711
|
+
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
712
|
+
}
|
|
713
|
+
function ot() {
|
|
714
|
+
if (!D())
|
|
715
|
+
return;
|
|
716
|
+
const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
|
|
717
|
+
document.getElementById("cvly");
|
|
718
|
+
if (!t)
|
|
719
|
+
return;
|
|
720
|
+
const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
|
|
721
|
+
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
722
|
+
}
|
|
723
|
+
function at(t) {
|
|
724
|
+
const { organizationId: e, projectId: r } = t;
|
|
725
|
+
if (e && r)
|
|
726
|
+
return { organizationId: e, projectId: r };
|
|
727
|
+
const n = it();
|
|
728
|
+
if (n)
|
|
729
|
+
return n;
|
|
730
|
+
const i = ot();
|
|
731
|
+
if (i)
|
|
732
|
+
return i;
|
|
733
|
+
throw new Error(
|
|
734
|
+
`organizationId and projectId are required. You can provide them via one of:
|
|
735
|
+
(1) createClient({ organizationId, projectId }) options;
|
|
736
|
+
(2) window.pickedConfig = { organizationId, projectId };
|
|
737
|
+
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
class K {
|
|
69
741
|
constructor(e) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
742
|
+
m(this, "options");
|
|
743
|
+
m(this, "isReady", !1);
|
|
744
|
+
m(this, "project");
|
|
745
|
+
m(this, "plugins", {});
|
|
746
|
+
m(this, "eventBus", Te());
|
|
747
|
+
m(this, "organizationId");
|
|
748
|
+
m(this, "projectId");
|
|
749
|
+
m(this, "apiUrl");
|
|
750
|
+
m(this, "session");
|
|
751
|
+
m(this, "precondition");
|
|
752
|
+
m(this, "condition");
|
|
753
|
+
m(this, "searchParams", Ze());
|
|
754
|
+
m(this, "history", Me());
|
|
755
|
+
m(this, "components", ke({ client: this }));
|
|
756
|
+
m(this, "experienceInstances", re({ client: this }));
|
|
757
|
+
m(this, "experiences", pe({ client: this }));
|
|
758
|
+
m(this, "frameworks", be({ client: this }));
|
|
759
|
+
m(this, "predicates", $e({ client: this }));
|
|
760
|
+
m(this, "features", Ce({ client: this }));
|
|
761
|
+
m(this, "responses", Je({ client: this }));
|
|
762
|
+
m(this, "fields", _e());
|
|
763
|
+
m(this, "actions", qe());
|
|
764
|
+
S("info", "Picked client initializing.");
|
|
765
|
+
const { organizationId: r, projectId: n } = at(e);
|
|
766
|
+
this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Xe(), this.session = nt(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: Qe() }), S("info", "Picked client initialized.");
|
|
93
767
|
}
|
|
94
768
|
start() {
|
|
95
|
-
|
|
96
|
-
if (!
|
|
769
|
+
Pe(this), (async () => {
|
|
770
|
+
if (!D())
|
|
97
771
|
return;
|
|
98
|
-
let
|
|
99
|
-
typeof this.precondition > "u" ?
|
|
100
|
-
let
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
if (typeof
|
|
104
|
-
const
|
|
105
|
-
this.session.setIsUser(
|
|
772
|
+
let r;
|
|
773
|
+
typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
|
|
774
|
+
let n;
|
|
775
|
+
r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await E(this, this.condition) === !0);
|
|
776
|
+
const i = r && n === !0;
|
|
777
|
+
if (typeof n == "boolean" && this.session) {
|
|
778
|
+
const a = n;
|
|
779
|
+
this.session.setIsUser(a), this.eventBus({ type: "user_decide", value: a });
|
|
106
780
|
}
|
|
107
|
-
this.eventBus({ type: "initialize" }), document.body &&
|
|
781
|
+
this.eventBus({ type: "initialize" }), document.body && i && T(this), await ne(), i && T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
108
782
|
})();
|
|
109
783
|
}
|
|
110
784
|
registerFramework(e) {
|
|
111
|
-
|
|
785
|
+
Fe(e, this.frameworks);
|
|
112
786
|
}
|
|
113
|
-
registerComponent(e,
|
|
114
|
-
|
|
787
|
+
registerComponent(e, r) {
|
|
788
|
+
V(e, r, this.components);
|
|
115
789
|
}
|
|
116
790
|
registerPlugin(e) {
|
|
117
|
-
|
|
791
|
+
me(this, e, this.plugins);
|
|
118
792
|
}
|
|
119
|
-
registerFeature(e,
|
|
120
|
-
|
|
793
|
+
registerFeature(e, r) {
|
|
794
|
+
De(e, r, this.features);
|
|
121
795
|
}
|
|
122
|
-
registerPredicate(e,
|
|
123
|
-
|
|
796
|
+
registerPredicate(e, r) {
|
|
797
|
+
Oe(e, r, this.predicates);
|
|
124
798
|
}
|
|
125
799
|
registerField(e) {
|
|
126
|
-
|
|
800
|
+
Le(e, this.fields);
|
|
127
801
|
}
|
|
128
|
-
registerAction(e,
|
|
129
|
-
|
|
802
|
+
registerAction(e, r) {
|
|
803
|
+
Ke(e, r, this.actions);
|
|
130
804
|
}
|
|
131
805
|
registerExperience(e) {
|
|
132
|
-
e.component &&
|
|
806
|
+
e.component && V(`experience:${e.id}`, e.component, this.components), ge(e, this.experiences);
|
|
133
807
|
}
|
|
134
808
|
getStateSnapshot() {
|
|
135
|
-
return
|
|
809
|
+
return Re(this);
|
|
136
810
|
}
|
|
137
811
|
async launchExperienceById(e) {
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
|
|
812
|
+
const r = this.experiences.getById(e).getState();
|
|
813
|
+
if (!r) {
|
|
814
|
+
S("warn", `Experience with id '${e}' not found.`);
|
|
141
815
|
return;
|
|
142
816
|
}
|
|
143
|
-
|
|
817
|
+
q(this, r);
|
|
144
818
|
}
|
|
145
819
|
// private async fetchProject() {
|
|
146
820
|
// if (this.project) {
|
|
@@ -153,38 +827,38 @@ class g {
|
|
|
153
827
|
// }
|
|
154
828
|
setupPlugins() {
|
|
155
829
|
var e;
|
|
156
|
-
(e = this.options.plugins) == null || e.forEach((
|
|
157
|
-
if (Array.isArray(
|
|
158
|
-
|
|
159
|
-
this.registerPlugin(
|
|
830
|
+
(e = this.options.plugins) == null || e.forEach((r) => {
|
|
831
|
+
if (Array.isArray(r)) {
|
|
832
|
+
r.forEach((i) => {
|
|
833
|
+
this.registerPlugin(i);
|
|
160
834
|
});
|
|
161
835
|
return;
|
|
162
836
|
}
|
|
163
|
-
const
|
|
164
|
-
if (Array.isArray(
|
|
165
|
-
|
|
837
|
+
const n = typeof r == "function" ? r() : r;
|
|
838
|
+
if (Array.isArray(n)) {
|
|
839
|
+
n.forEach((i) => this.registerPlugin(i));
|
|
166
840
|
return;
|
|
167
841
|
}
|
|
168
|
-
this.registerPlugin(
|
|
842
|
+
this.registerPlugin(n);
|
|
169
843
|
});
|
|
170
844
|
}
|
|
171
845
|
setupFeatures() {
|
|
172
846
|
const e = this.options.features;
|
|
173
|
-
e && (Object.entries(e).forEach(([
|
|
174
|
-
const
|
|
175
|
-
this.registerFeature(
|
|
176
|
-
}), this.searchParams.feature && this.searchParams.feature.forEach((
|
|
847
|
+
e && (Object.entries(e).forEach(([r, n]) => {
|
|
848
|
+
const i = typeof n == "function" ? n() : n;
|
|
849
|
+
this.registerFeature(r, i);
|
|
850
|
+
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
177
851
|
try {
|
|
178
|
-
const [
|
|
179
|
-
if (!
|
|
852
|
+
const [n, i] = r.split(":");
|
|
853
|
+
if (!n || !i)
|
|
180
854
|
return;
|
|
181
|
-
let
|
|
182
|
-
|
|
183
|
-
key: `${
|
|
855
|
+
let a = i;
|
|
856
|
+
a === "true" && (a = !0), a === "false" && (a = !1), this.registerFeature(n, {
|
|
857
|
+
key: `${a}`,
|
|
184
858
|
// use the assigned bucket value as the key
|
|
185
|
-
name:
|
|
859
|
+
name: n,
|
|
186
860
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
187
|
-
decide: () =>
|
|
861
|
+
decide: () => a,
|
|
188
862
|
storage: "session"
|
|
189
863
|
});
|
|
190
864
|
} catch {
|
|
@@ -193,73 +867,74 @@ class g {
|
|
|
193
867
|
}
|
|
194
868
|
setupPredicates() {
|
|
195
869
|
const e = this.options.predicates;
|
|
196
|
-
e && Object.entries(e).forEach(([
|
|
197
|
-
if (typeof
|
|
198
|
-
|
|
870
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
871
|
+
if (typeof n != "function") {
|
|
872
|
+
S("warn", `Predicate "${r}" is not a function.`);
|
|
199
873
|
return;
|
|
200
874
|
}
|
|
201
|
-
this.registerPredicate(
|
|
875
|
+
this.registerPredicate(r, n);
|
|
202
876
|
});
|
|
203
877
|
}
|
|
204
878
|
setupActions() {
|
|
205
879
|
const e = this.options.actions;
|
|
206
|
-
e && Object.entries(e).forEach(([
|
|
207
|
-
if (typeof
|
|
208
|
-
|
|
880
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
881
|
+
if (typeof n != "function") {
|
|
882
|
+
S("warn", `Action "${r}" is not a function.`);
|
|
209
883
|
return;
|
|
210
884
|
}
|
|
211
|
-
this.registerAction(
|
|
885
|
+
this.registerAction(r, n);
|
|
212
886
|
});
|
|
213
887
|
}
|
|
214
888
|
getPluginConfig(e) {
|
|
215
889
|
return this.plugins[e] ?? {};
|
|
216
890
|
}
|
|
217
891
|
}
|
|
218
|
-
|
|
219
|
-
function
|
|
892
|
+
m(K, "logger", S);
|
|
893
|
+
function W(t) {
|
|
220
894
|
var e;
|
|
221
|
-
return ((e =
|
|
895
|
+
return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
|
|
222
896
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
897
|
+
function ct(t) {
|
|
898
|
+
return t.some((e) => e.condition || W(e));
|
|
225
899
|
}
|
|
226
|
-
async function
|
|
227
|
-
return e.length === 0 || !
|
|
228
|
-
e.map(async (
|
|
229
|
-
if (!(
|
|
900
|
+
async function vt(t, e) {
|
|
901
|
+
return e.length === 0 || !ct(e) ? e : (await Promise.all(
|
|
902
|
+
e.map(async (n) => {
|
|
903
|
+
if (!(n.condition ? await E(t, n.condition) : !0))
|
|
230
904
|
return null;
|
|
231
|
-
if (!
|
|
232
|
-
return
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
)).filter((
|
|
236
|
-
return
|
|
905
|
+
if (!n.options || !W(n))
|
|
906
|
+
return n;
|
|
907
|
+
const s = (await Promise.all(
|
|
908
|
+
n.options.map(async (d) => d.condition ? await E(t, d.condition) ? d : null : d)
|
|
909
|
+
)).filter((d) => d !== null);
|
|
910
|
+
return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
|
|
237
911
|
})
|
|
238
|
-
)).filter((
|
|
912
|
+
)).filter((n) => n !== null);
|
|
239
913
|
}
|
|
240
|
-
const
|
|
241
|
-
const e = new
|
|
242
|
-
return
|
|
914
|
+
const St = (t) => {
|
|
915
|
+
const e = new K(t);
|
|
916
|
+
return ce(e), e;
|
|
243
917
|
};
|
|
244
918
|
export {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
919
|
+
K as Picked,
|
|
920
|
+
St as createClient,
|
|
921
|
+
R as createStorageKey,
|
|
922
|
+
E as evaluateRuleLogic,
|
|
923
|
+
st as getPickedConfig,
|
|
924
|
+
vt as getStepFields,
|
|
925
|
+
It as isPickedRoot,
|
|
926
|
+
$ as localStore,
|
|
927
|
+
O as sessionStore,
|
|
928
|
+
Ft as subscribe,
|
|
929
|
+
Et as supportsCookies,
|
|
930
|
+
ae as supportsCryptoRandomUUID,
|
|
931
|
+
D as supportsDocument,
|
|
932
|
+
jt as supportsHistory,
|
|
933
|
+
Pt as supportsIntersectionObserver,
|
|
934
|
+
oe as supportsLocalStorage,
|
|
935
|
+
Rt as supportsLocation,
|
|
936
|
+
Bt as supportsSessionStorage,
|
|
937
|
+
At as supportsShadowRoot,
|
|
938
|
+
$t as supportsWebComponents,
|
|
939
|
+
U as supportsWindow
|
|
265
940
|
};
|