@picked/client 0.0.41 → 0.0.42-next.2
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/esm/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createDomain as x, createApi as j, createStore as
|
|
2
|
-
import { createFactory as
|
|
3
|
-
import { g as q, t as ee, c as te, i as re, e as E, a as
|
|
4
|
-
import { f as
|
|
5
|
-
import { l as
|
|
6
|
-
import { c as A, l as
|
|
7
|
-
import { a as
|
|
1
|
+
import { createDomain as x, createApi as j, createStore as N, createEffect as $, sample as k, attach as Z, combine as D, createEvent as V } from "effector";
|
|
2
|
+
import { createFactory as b, invoke as I } from "@withease/factories";
|
|
3
|
+
import { g as q, t as ee, c as te, i as re, e as E, a as ne, b as se, d as ie } from "../experience-instance-D0bQ9DzM.js";
|
|
4
|
+
import { f as Bt } from "../experience-instance-D0bQ9DzM.js";
|
|
5
|
+
import { l as w } from "../logger-C9a75KZn.js";
|
|
6
|
+
import { c as A, l as z, s as O } from "../storage-Co_LbKr_.js";
|
|
7
|
+
import { a as $t } from "../storage-Co_LbKr_.js";
|
|
8
8
|
import { g as oe } from "../id-BW-g3y32.js";
|
|
9
9
|
import { i as ae } from "../object-JwZ58NOH.js";
|
|
10
|
-
import { s as
|
|
11
|
-
import { e as zt, f as
|
|
12
|
-
const K = x("experience"), le =
|
|
10
|
+
import { s as T, a as U, b as ce, c as ue, d as de } from "../supports-8YT4QKI7.js";
|
|
11
|
+
import { e as zt, f as Ot, g as Mt, h as Dt, i as Vt, j as Nt, k as Tt } from "../supports-8YT4QKI7.js";
|
|
12
|
+
const K = x("experience"), le = b(
|
|
13
13
|
({ client: t, experience: e }) => {
|
|
14
|
-
const r = K.store(e),
|
|
14
|
+
const r = K.store(e), n = j(r, {
|
|
15
15
|
merge(p, h) {
|
|
16
16
|
return {
|
|
17
17
|
...p,
|
|
@@ -31,34 +31,34 @@ const K = x("experience"), le = w(
|
|
|
31
31
|
nodes: p.nodes,
|
|
32
32
|
edges: p.edges,
|
|
33
33
|
conditionals: p.conditionals
|
|
34
|
-
})),
|
|
34
|
+
})), s = r.map((p) => p.fields), l = e.actions ?? [];
|
|
35
35
|
return {
|
|
36
36
|
id: e.id,
|
|
37
37
|
configStore: i,
|
|
38
38
|
treeStore: o,
|
|
39
|
-
fieldsStore:
|
|
39
|
+
fieldsStore: s,
|
|
40
40
|
componentStore: d,
|
|
41
41
|
actions: l,
|
|
42
|
-
merge:
|
|
42
|
+
merge: n.merge
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
function pe(t) {
|
|
47
|
-
return
|
|
47
|
+
return I(le, t);
|
|
48
48
|
}
|
|
49
|
-
const fe =
|
|
49
|
+
const fe = b(({ client: t }) => {
|
|
50
50
|
const e = K.store({}), r = j(e, {
|
|
51
|
-
register(o,
|
|
51
|
+
register(o, s) {
|
|
52
52
|
return {
|
|
53
53
|
...o,
|
|
54
|
-
[
|
|
54
|
+
[s.id]: s
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
function
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
58
|
+
function n(o) {
|
|
59
|
+
const s = e.getState()[o.id];
|
|
60
|
+
if (s) {
|
|
61
|
+
s.merge({ experience: o, strategy: "override" });
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const l = pe({ client: t, experience: o });
|
|
@@ -66,137 +66,137 @@ const fe = w(({ client: t }) => {
|
|
|
66
66
|
}
|
|
67
67
|
const i = e.map((o) => Object.values(o));
|
|
68
68
|
function d(o) {
|
|
69
|
-
return e.map((
|
|
69
|
+
return e.map((s) => s[o], { skipVoid: !1 });
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
register:
|
|
72
|
+
register: n,
|
|
73
73
|
getById: d,
|
|
74
74
|
listStore: i
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
77
|
function ge(t) {
|
|
78
|
-
return
|
|
78
|
+
return I(fe, t);
|
|
79
79
|
}
|
|
80
80
|
const me = (t, e) => {
|
|
81
81
|
e.register(t);
|
|
82
82
|
}, W = (t, e) => {
|
|
83
|
-
const { targetSelectors: r } = e.configStore.getState(),
|
|
84
|
-
|
|
83
|
+
const { targetSelectors: r } = e.configStore.getState(), n = q(r, e.id);
|
|
84
|
+
n.forEach(
|
|
85
85
|
({ elements: d }) => d.forEach((o) => ee(o, e.id))
|
|
86
|
-
), te(
|
|
86
|
+
), te(n, e.id).forEach((d) => {
|
|
87
87
|
t.experienceInstances.spawn(e, d);
|
|
88
88
|
});
|
|
89
|
-
},
|
|
89
|
+
}, _ = async (t) => {
|
|
90
90
|
await Promise.all(
|
|
91
91
|
t.experiences.listStore.getState().map(async (e) => {
|
|
92
92
|
await he(t, e) && W(t, e);
|
|
93
93
|
})
|
|
94
94
|
);
|
|
95
95
|
}, he = async (t, e) => {
|
|
96
|
-
const { decisionLogic: r, targetSelectors:
|
|
97
|
-
return q(
|
|
96
|
+
const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
|
|
97
|
+
return q(n, e.id).length < 1 || n.length === 0 ? !1 : r && re(r) ? await E(t, r) === !0 : !0;
|
|
98
98
|
}, ye = (t, e, r) => {
|
|
99
|
-
const
|
|
99
|
+
const n = e.name, i = e.setup(t);
|
|
100
100
|
if (i) {
|
|
101
|
-
const d = r[
|
|
102
|
-
r[
|
|
101
|
+
const d = r[n] ?? {};
|
|
102
|
+
r[n] = Object.freeze({ ...d, ...i });
|
|
103
103
|
}
|
|
104
|
-
}, Se = x("component"), ve =
|
|
104
|
+
}, Se = x("component"), ve = b(
|
|
105
105
|
({ client: t, component: e, name: r }) => {
|
|
106
|
-
const
|
|
106
|
+
const n = t.frameworks.getByName(e.frameworkName);
|
|
107
107
|
return {
|
|
108
108
|
name: r,
|
|
109
109
|
component: e,
|
|
110
|
-
frameworkStore:
|
|
110
|
+
frameworkStore: n
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
114
|
function ke(t) {
|
|
115
|
-
return
|
|
115
|
+
return I(ve, t);
|
|
116
116
|
}
|
|
117
|
-
const we =
|
|
117
|
+
const we = b(({ client: t }) => {
|
|
118
118
|
const e = Se.store({}), r = j(e, {
|
|
119
|
-
register(o,
|
|
119
|
+
register(o, s) {
|
|
120
120
|
return {
|
|
121
121
|
...o,
|
|
122
|
-
[
|
|
122
|
+
[s.name]: s
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
function
|
|
127
|
-
e.getState()[o] &&
|
|
126
|
+
function n(o, s) {
|
|
127
|
+
e.getState()[o] && w(
|
|
128
128
|
"warn",
|
|
129
129
|
`Component '${o}' already registered. Registering again will override the previous registration.`
|
|
130
130
|
);
|
|
131
|
-
const p = ke({ client: t, name: o, component:
|
|
131
|
+
const p = ke({ client: t, name: o, component: s });
|
|
132
132
|
r.register(p);
|
|
133
133
|
}
|
|
134
134
|
const i = e.map((o) => Object.values(o));
|
|
135
135
|
function d(o) {
|
|
136
|
-
return e.map((
|
|
136
|
+
return e.map((s) => s[o], { skipVoid: !1 });
|
|
137
137
|
}
|
|
138
138
|
return {
|
|
139
|
-
register:
|
|
139
|
+
register: n,
|
|
140
140
|
getByName: d,
|
|
141
141
|
listStore: i
|
|
142
142
|
};
|
|
143
143
|
});
|
|
144
144
|
function be(t) {
|
|
145
|
-
return
|
|
145
|
+
return I(we, t);
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const L = (t, e, r) => {
|
|
148
148
|
r.register(t, e);
|
|
149
|
-
}, Ie = x("framework"), Fe =
|
|
149
|
+
}, Ie = x("framework"), Fe = b(({ client: t }) => {
|
|
150
150
|
const e = Ie.store({}), r = j(e, {
|
|
151
|
-
register(o,
|
|
151
|
+
register(o, s) {
|
|
152
152
|
return {
|
|
153
153
|
...o,
|
|
154
|
-
[
|
|
154
|
+
[s.name]: s.framework
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
function
|
|
159
|
-
e.getState()[o] &&
|
|
158
|
+
function n(o, s) {
|
|
159
|
+
e.getState()[o] && w(
|
|
160
160
|
"warn",
|
|
161
161
|
`Framework '${o}' already registered. Registering again will override the previous registration.`
|
|
162
|
-
), r.register({ name: o, framework:
|
|
162
|
+
), r.register({ name: o, framework: s });
|
|
163
163
|
}
|
|
164
164
|
const i = e.map((o) => Object.values(o));
|
|
165
165
|
function d(o) {
|
|
166
|
-
return e.map((
|
|
166
|
+
return e.map((s) => s[o], { skipVoid: !1 });
|
|
167
167
|
}
|
|
168
168
|
return {
|
|
169
|
-
register:
|
|
169
|
+
register: n,
|
|
170
170
|
getByName: d,
|
|
171
171
|
listStore: i
|
|
172
172
|
};
|
|
173
173
|
});
|
|
174
174
|
function xe(t) {
|
|
175
|
-
return
|
|
175
|
+
return I(Fe, t);
|
|
176
176
|
}
|
|
177
177
|
const je = (t, e) => {
|
|
178
178
|
e.register(t.name, t);
|
|
179
179
|
}, Ee = 6e3, Pe = A("last_ping", "global"), Ae = (t) => `${t}/api/v1/ping`, Be = async (t) => {
|
|
180
180
|
try {
|
|
181
|
-
const e = Date.now(), r =
|
|
182
|
-
let
|
|
183
|
-
if (r.isSet() && (
|
|
181
|
+
const e = Date.now(), r = z.get(Pe);
|
|
182
|
+
let n = 0;
|
|
183
|
+
if (r.isSet() && (n = r.json() ?? 0), n && e - n < Ee)
|
|
184
184
|
return !0;
|
|
185
185
|
const i = Ae(t.apiUrl), d = {
|
|
186
186
|
projectId: t.projectId,
|
|
187
187
|
path: window.location.pathname
|
|
188
|
-
}, o = JSON.stringify(d),
|
|
188
|
+
}, o = JSON.stringify(d), s = {
|
|
189
189
|
"Content-Type": "application/json"
|
|
190
190
|
}, p = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
191
|
-
p && (
|
|
191
|
+
p && (s["x-vercel-protection-bypass"] = p);
|
|
192
192
|
const v = (await fetch(i, {
|
|
193
193
|
method: "POST",
|
|
194
|
-
headers:
|
|
194
|
+
headers: s,
|
|
195
195
|
body: o
|
|
196
196
|
})).ok;
|
|
197
197
|
return v && r.set(e), v;
|
|
198
198
|
} catch (e) {
|
|
199
|
-
return
|
|
199
|
+
return w("error", e), !1;
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
function Y(t) {
|
|
@@ -211,11 +211,11 @@ function Y(t) {
|
|
|
211
211
|
};
|
|
212
212
|
return Object.freeze(r);
|
|
213
213
|
}
|
|
214
|
-
const Re = x("predicate"), $e =
|
|
214
|
+
const Re = x("predicate"), $e = b(({ client: t }) => {
|
|
215
215
|
const e = Re.store({}), r = j(e, {
|
|
216
|
-
register(
|
|
216
|
+
register(s, l) {
|
|
217
217
|
return {
|
|
218
|
-
...
|
|
218
|
+
...s,
|
|
219
219
|
[l.name]: {
|
|
220
220
|
name: l.name,
|
|
221
221
|
predicate: l.predicate
|
|
@@ -223,50 +223,50 @@ const Re = x("predicate"), $e = w(({ client: t }) => {
|
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
|
-
function s
|
|
227
|
-
e.getState()[
|
|
226
|
+
function n(s, l) {
|
|
227
|
+
e.getState()[s] && w(
|
|
228
228
|
"warn",
|
|
229
|
-
`Predicate '${
|
|
230
|
-
), r.register(Object.freeze({ name:
|
|
229
|
+
`Predicate '${s}' already registered. Registering again will override the previous registration.`
|
|
230
|
+
), r.register(Object.freeze({ name: s, predicate: l }));
|
|
231
231
|
}
|
|
232
|
-
const i = e.map((
|
|
233
|
-
function d(
|
|
234
|
-
return e.map((l) => l[
|
|
232
|
+
const i = e.map((s) => Object.values(s));
|
|
233
|
+
function d(s) {
|
|
234
|
+
return e.map((l) => l[s]?.predicate, { skipVoid: !1 });
|
|
235
235
|
}
|
|
236
|
-
function o(
|
|
237
|
-
const l =
|
|
236
|
+
function o(s) {
|
|
237
|
+
const l = N(() => {
|
|
238
238
|
}, {
|
|
239
239
|
skipVoid: !1
|
|
240
240
|
}), p = $(async () => {
|
|
241
|
-
const h = d(
|
|
241
|
+
const h = d(s).getState();
|
|
242
242
|
if (!h)
|
|
243
243
|
return;
|
|
244
244
|
const v = Y(t);
|
|
245
245
|
return (...m) => h({ ...v, args: m });
|
|
246
246
|
});
|
|
247
|
-
return
|
|
247
|
+
return k({
|
|
248
248
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
249
249
|
target: p
|
|
250
|
-
}),
|
|
250
|
+
}), k({
|
|
251
251
|
clock: p.doneData,
|
|
252
252
|
filter: (h) => h !== void 0,
|
|
253
253
|
target: l
|
|
254
254
|
}), p(), l;
|
|
255
255
|
}
|
|
256
256
|
return {
|
|
257
|
-
register:
|
|
257
|
+
register: n,
|
|
258
258
|
getByName: d,
|
|
259
259
|
listStore: i,
|
|
260
260
|
getEvokablePredicate: o
|
|
261
261
|
};
|
|
262
262
|
});
|
|
263
|
-
function
|
|
264
|
-
return
|
|
263
|
+
function Ce(t) {
|
|
264
|
+
return I($e, t);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
266
|
+
const ze = (t, e, r) => {
|
|
267
267
|
r.register(t, e);
|
|
268
|
-
},
|
|
269
|
-
const e =
|
|
268
|
+
}, J = x("feature"), Oe = b(({ client: t }) => {
|
|
269
|
+
const e = J.store({}), r = J.store([]), n = j(e, {
|
|
270
270
|
register(a, c) {
|
|
271
271
|
return {
|
|
272
272
|
...a,
|
|
@@ -275,7 +275,7 @@ const Ce = (t, e, r) => {
|
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
function i(a, c) {
|
|
278
|
-
e.getState()[a] &&
|
|
278
|
+
e.getState()[a] && w(
|
|
279
279
|
"warn",
|
|
280
280
|
`Feature '${a}' already registered. Registering again will override the previous registration.`
|
|
281
281
|
);
|
|
@@ -286,7 +286,7 @@ const Ce = (t, e, r) => {
|
|
|
286
286
|
id: a
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
|
|
289
|
+
n.register(
|
|
290
290
|
Object.freeze({
|
|
291
291
|
id: a,
|
|
292
292
|
feature: u
|
|
@@ -299,15 +299,15 @@ const Ce = (t, e, r) => {
|
|
|
299
299
|
key: c,
|
|
300
300
|
storage: f = "local"
|
|
301
301
|
}) => {
|
|
302
|
-
const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? O :
|
|
302
|
+
const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? O : z).get(u).boolean();
|
|
303
303
|
return y === null ? null : { id: a, key: c, bucket: y, storage: f };
|
|
304
304
|
}
|
|
305
305
|
), o = $((a) => {
|
|
306
306
|
if (!a)
|
|
307
307
|
return null;
|
|
308
308
|
const c = A(`feature:${a.id}:${a.key}`, "global");
|
|
309
|
-
(a.storage === "session" ? O :
|
|
310
|
-
}),
|
|
309
|
+
(a.storage === "session" ? O : z).set(c, a.bucket);
|
|
310
|
+
}), s = /* @__PURE__ */ new Map(), l = Z({
|
|
311
311
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
312
312
|
effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: c }, { id: f, decide: u, key: g }) => {
|
|
313
313
|
const y = c.find(
|
|
@@ -315,28 +315,28 @@ const Ce = (t, e, r) => {
|
|
|
315
315
|
);
|
|
316
316
|
if (y)
|
|
317
317
|
return y;
|
|
318
|
-
const
|
|
319
|
-
if (!
|
|
318
|
+
const F = a[f];
|
|
319
|
+
if (!F)
|
|
320
320
|
throw new Error(`Feature with id '${f}' not found`);
|
|
321
|
-
const B =
|
|
321
|
+
const B = s.get(`${f}:${g}`);
|
|
322
322
|
if (B !== void 0) {
|
|
323
323
|
const R = await B;
|
|
324
|
-
return { id:
|
|
324
|
+
return { id: F.id, bucket: R, key: g, storage: F.feature.storage };
|
|
325
325
|
}
|
|
326
326
|
const S = u();
|
|
327
|
-
|
|
327
|
+
s.set(`${f}:${g}`, S);
|
|
328
328
|
const X = await S;
|
|
329
|
-
return { id:
|
|
329
|
+
return { id: F.id, bucket: X, key: g, storage: F.feature.storage };
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
|
-
|
|
333
|
-
clock:
|
|
332
|
+
k({
|
|
333
|
+
clock: n.register,
|
|
334
334
|
fn: (a) => {
|
|
335
335
|
const { id: c, feature: f } = a;
|
|
336
336
|
return { id: c, key: f.feature.key, storage: f.feature.storage };
|
|
337
337
|
},
|
|
338
338
|
target: d
|
|
339
|
-
}),
|
|
339
|
+
}), k({
|
|
340
340
|
source: e,
|
|
341
341
|
clock: l.doneData,
|
|
342
342
|
fn: (a, c) => {
|
|
@@ -345,7 +345,7 @@ const Ce = (t, e, r) => {
|
|
|
345
345
|
},
|
|
346
346
|
target: o
|
|
347
347
|
});
|
|
348
|
-
const p =
|
|
348
|
+
const p = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
349
349
|
({
|
|
350
350
|
allFeaturesStore: a,
|
|
351
351
|
resolvedFeaturesStore: c
|
|
@@ -368,7 +368,7 @@ const Ce = (t, e, r) => {
|
|
|
368
368
|
};
|
|
369
369
|
})
|
|
370
370
|
);
|
|
371
|
-
|
|
371
|
+
k({
|
|
372
372
|
clock: l.doneData,
|
|
373
373
|
source: { resolvedFeatures: r },
|
|
374
374
|
filter: ({ resolvedFeatures: a }, { id: c, key: f }) => !a.some(
|
|
@@ -379,7 +379,7 @@ const Ce = (t, e, r) => {
|
|
|
379
379
|
type: "feature_decide",
|
|
380
380
|
feature: a
|
|
381
381
|
}))
|
|
382
|
-
}),
|
|
382
|
+
}), k({
|
|
383
383
|
clock: [d.doneData, l.doneData],
|
|
384
384
|
source: r,
|
|
385
385
|
fn: (a, c) => !c || a.some(
|
|
@@ -394,7 +394,7 @@ const Ce = (t, e, r) => {
|
|
|
394
394
|
return e.map((c) => c[a], { skipVoid: !1 });
|
|
395
395
|
}
|
|
396
396
|
function m(a) {
|
|
397
|
-
const c =
|
|
397
|
+
const c = N(
|
|
398
398
|
async () => {
|
|
399
399
|
},
|
|
400
400
|
{ skipVoid: !1 }
|
|
@@ -403,11 +403,11 @@ const Ce = (t, e, r) => {
|
|
|
403
403
|
if (u)
|
|
404
404
|
return async () => (await u.getBucket()).bucket;
|
|
405
405
|
});
|
|
406
|
-
return
|
|
406
|
+
return k({
|
|
407
407
|
source: r,
|
|
408
408
|
filter: (u) => u.some((g) => g.id === a),
|
|
409
409
|
target: f
|
|
410
|
-
}),
|
|
410
|
+
}), k({
|
|
411
411
|
clock: f.doneData,
|
|
412
412
|
filter: (u) => u !== void 0,
|
|
413
413
|
target: c
|
|
@@ -422,12 +422,12 @@ const Ce = (t, e, r) => {
|
|
|
422
422
|
};
|
|
423
423
|
});
|
|
424
424
|
function Me(t) {
|
|
425
|
-
return
|
|
425
|
+
return I(Oe, t);
|
|
426
426
|
}
|
|
427
|
-
const
|
|
427
|
+
const De = (t, e, r) => {
|
|
428
428
|
r.register(t, e);
|
|
429
429
|
}, P = x("history");
|
|
430
|
-
function
|
|
430
|
+
function H(t, e) {
|
|
431
431
|
return {
|
|
432
432
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
433
433
|
id: oe(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
@@ -436,21 +436,21 @@ function J(t, e) {
|
|
|
436
436
|
experienceId: t
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
const
|
|
440
|
-
const t = P.store({ entries: [] }), e = P.event(), r = P.event(),
|
|
441
|
-
t.on(e, (o,
|
|
442
|
-
entries: [...o.entries,
|
|
443
|
-
})), t.on(r, (o,
|
|
439
|
+
const Ve = b(() => {
|
|
440
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), i = P.event();
|
|
441
|
+
t.on(e, (o, s) => ({
|
|
442
|
+
entries: [...o.entries, H(s.experienceId, s.node)]
|
|
443
|
+
})), t.on(r, (o, s) => ({
|
|
444
444
|
entries: [
|
|
445
445
|
...o.entries.slice(0, -1),
|
|
446
|
-
|
|
446
|
+
H(s.experienceId, s.node)
|
|
447
447
|
]
|
|
448
|
-
})), t.on(i, (o,
|
|
449
|
-
function d(o,
|
|
448
|
+
})), t.on(i, (o, s) => s);
|
|
449
|
+
function d(o, s) {
|
|
450
450
|
const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
451
451
|
for (let p = o.length - 1; p >= 0; p--) {
|
|
452
452
|
const h = o[p], v = h?.node;
|
|
453
|
-
if (!(!v || !
|
|
453
|
+
if (!(!v || !ne(v)) && !(s && h?.experienceId !== s))
|
|
454
454
|
if (l.lastStepIndex === -1)
|
|
455
455
|
l.lastStepIndex = p;
|
|
456
456
|
else {
|
|
@@ -460,8 +460,8 @@ const De = w(() => {
|
|
|
460
460
|
}
|
|
461
461
|
return l;
|
|
462
462
|
}
|
|
463
|
-
return t.on(
|
|
464
|
-
const { secondLastStepIndex: l } = d(o.entries,
|
|
463
|
+
return t.on(n, (o, s) => {
|
|
464
|
+
const { secondLastStepIndex: l } = d(o.entries, s.experienceId), p = l !== -1 ? o.entries.slice(0, l + 1) : o.entries;
|
|
465
465
|
return {
|
|
466
466
|
...o,
|
|
467
467
|
entries: p
|
|
@@ -469,28 +469,44 @@ const De = w(() => {
|
|
|
469
469
|
}), {
|
|
470
470
|
push: e,
|
|
471
471
|
replace: r,
|
|
472
|
-
back:
|
|
472
|
+
back: n,
|
|
473
473
|
restore: i,
|
|
474
474
|
entriesStore: t.map((o) => o.entries)
|
|
475
475
|
};
|
|
476
476
|
});
|
|
477
477
|
function Ne() {
|
|
478
|
-
return
|
|
478
|
+
return I(Ve);
|
|
479
479
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
480
|
+
let Te = 0;
|
|
481
|
+
const Ue = (t) => {
|
|
482
|
+
const e = N([]);
|
|
483
|
+
return k({
|
|
484
|
+
clock: t,
|
|
485
|
+
source: e,
|
|
486
|
+
fn: (r, n) => [
|
|
487
|
+
...r,
|
|
488
|
+
{
|
|
489
|
+
id: Te++,
|
|
490
|
+
at: /* @__PURE__ */ new Date(),
|
|
491
|
+
payload: n
|
|
492
|
+
}
|
|
493
|
+
],
|
|
494
|
+
target: e
|
|
495
|
+
}), e;
|
|
496
|
+
}, _e = x("field"), Le = b(() => {
|
|
497
|
+
const t = _e.store({}), e = j(t, {
|
|
498
|
+
register(s, l) {
|
|
483
499
|
return {
|
|
484
|
-
...
|
|
500
|
+
...s,
|
|
485
501
|
[l.field.id]: l.field
|
|
486
502
|
};
|
|
487
503
|
}
|
|
488
504
|
});
|
|
489
|
-
function r(
|
|
490
|
-
e.register({ field:
|
|
505
|
+
function r(s) {
|
|
506
|
+
e.register({ field: s });
|
|
491
507
|
}
|
|
492
|
-
function s
|
|
493
|
-
const p = d(
|
|
508
|
+
function n(s, l) {
|
|
509
|
+
const p = d(s).getState();
|
|
494
510
|
if (!p)
|
|
495
511
|
return;
|
|
496
512
|
const h = Object.assign({}, p, {
|
|
@@ -498,49 +514,49 @@ const Te = () => D(), Ue = x("field"), _e = w(() => {
|
|
|
498
514
|
});
|
|
499
515
|
e.register({ field: { ...h } });
|
|
500
516
|
}
|
|
501
|
-
const i = t.map((
|
|
502
|
-
function d(
|
|
503
|
-
return t.map((l) => l[
|
|
517
|
+
const i = t.map((s) => Object.values(s));
|
|
518
|
+
function d(s) {
|
|
519
|
+
return t.map((l) => l[s] || null);
|
|
504
520
|
}
|
|
505
|
-
function o(
|
|
506
|
-
return t.map((l) => Object.values(l).find((p) => p.name ===
|
|
521
|
+
function o(s) {
|
|
522
|
+
return t.map((l) => Object.values(l).find((p) => p.name === s) || null);
|
|
507
523
|
}
|
|
508
524
|
return {
|
|
509
525
|
register: r,
|
|
510
|
-
update:
|
|
526
|
+
update: n,
|
|
511
527
|
getById: d,
|
|
512
528
|
listStore: i,
|
|
513
529
|
getByName: o
|
|
514
530
|
};
|
|
515
531
|
});
|
|
516
|
-
function
|
|
517
|
-
return
|
|
532
|
+
function Je() {
|
|
533
|
+
return I(Le);
|
|
518
534
|
}
|
|
519
|
-
const
|
|
535
|
+
const He = (t, e) => {
|
|
520
536
|
e.register(t);
|
|
521
|
-
}, Ge = x("action"),
|
|
537
|
+
}, Ge = x("action"), qe = b(() => {
|
|
522
538
|
const t = Ge.store({}), e = j(t, {
|
|
523
|
-
register(o,
|
|
539
|
+
register(o, s) {
|
|
524
540
|
return {
|
|
525
541
|
...o,
|
|
526
|
-
[
|
|
527
|
-
name:
|
|
528
|
-
action:
|
|
542
|
+
[s.name]: {
|
|
543
|
+
name: s.name,
|
|
544
|
+
action: s.action
|
|
529
545
|
}
|
|
530
546
|
};
|
|
531
547
|
}
|
|
532
548
|
});
|
|
533
|
-
function r(o,
|
|
534
|
-
e.register({ name: o, action:
|
|
549
|
+
function r(o, s) {
|
|
550
|
+
e.register({ name: o, action: s });
|
|
535
551
|
}
|
|
536
|
-
const
|
|
552
|
+
const n = t.map((o) => Object.values(o));
|
|
537
553
|
function i(o) {
|
|
538
|
-
return t.map((
|
|
554
|
+
return t.map((s) => s[o], { skipVoid: !1 });
|
|
539
555
|
}
|
|
540
556
|
function d(o) {
|
|
541
557
|
return t.map(
|
|
542
|
-
(
|
|
543
|
-
const l =
|
|
558
|
+
(s) => {
|
|
559
|
+
const l = s[o];
|
|
544
560
|
return l ? l.action : void 0;
|
|
545
561
|
},
|
|
546
562
|
{ skipVoid: !1 }
|
|
@@ -549,20 +565,20 @@ const Je = (t, e) => {
|
|
|
549
565
|
return {
|
|
550
566
|
register: r,
|
|
551
567
|
getByName: i,
|
|
552
|
-
listStore:
|
|
568
|
+
listStore: n,
|
|
553
569
|
getEvokableAction: d
|
|
554
570
|
};
|
|
555
571
|
});
|
|
556
|
-
function
|
|
557
|
-
return
|
|
572
|
+
function Ke() {
|
|
573
|
+
return I(qe);
|
|
558
574
|
}
|
|
559
|
-
const
|
|
575
|
+
const We = (t, e, r) => {
|
|
560
576
|
r.register(t, e);
|
|
561
577
|
};
|
|
562
578
|
function M(t) {
|
|
563
579
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
564
580
|
}
|
|
565
|
-
function
|
|
581
|
+
function Ye(t) {
|
|
566
582
|
return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
|
|
567
583
|
}
|
|
568
584
|
function G(t) {
|
|
@@ -572,8 +588,8 @@ function G(t) {
|
|
|
572
588
|
return !1;
|
|
573
589
|
}
|
|
574
590
|
}
|
|
575
|
-
const
|
|
576
|
-
const e =
|
|
591
|
+
const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
592
|
+
const e = Qe.store({}), r = V(), n = V(), i = j(e, {
|
|
577
593
|
register(m, a) {
|
|
578
594
|
return {
|
|
579
595
|
...m,
|
|
@@ -721,19 +737,19 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
721
737
|
if (g.options) {
|
|
722
738
|
const y = Array.isArray(u) ? u : [u];
|
|
723
739
|
if (g.type === "object") {
|
|
724
|
-
const
|
|
725
|
-
y.every((S) =>
|
|
740
|
+
const F = g.options.map((S) => JSON.stringify(S.value));
|
|
741
|
+
y.every((S) => F.includes(JSON.stringify(S))) || a.push({
|
|
726
742
|
fieldId: c,
|
|
727
743
|
userMessage: "This field expects a valid option",
|
|
728
744
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
729
745
|
value: u
|
|
730
746
|
});
|
|
731
747
|
} else {
|
|
732
|
-
const
|
|
733
|
-
y.every((S) => !
|
|
748
|
+
const F = g.options.map((S) => S.value);
|
|
749
|
+
y.every((S) => !Ye(S) || S === null ? !1 : F.includes(S)) || a.push({
|
|
734
750
|
fieldId: c,
|
|
735
751
|
userMessage: "This field expects a valid option",
|
|
736
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
752
|
+
systemMessage: `Field expects a valid option. Valid options are: ${F.join(", ")}`,
|
|
737
753
|
value: u
|
|
738
754
|
});
|
|
739
755
|
}
|
|
@@ -741,7 +757,7 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
741
757
|
})
|
|
742
758
|
), { responsesToCommit: m, validationErrors: a };
|
|
743
759
|
}
|
|
744
|
-
async function
|
|
760
|
+
async function s(m) {
|
|
745
761
|
const { responsesToCommit: a, validationErrors: c } = await o(m);
|
|
746
762
|
return c.length ? { errors: c } : (i.registerBatch(a), { errors: [] });
|
|
747
763
|
}
|
|
@@ -751,26 +767,26 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
751
767
|
})));
|
|
752
768
|
function h(m) {
|
|
753
769
|
const a = t.fields.getById(m), c = e.map((f) => f[m] || null);
|
|
754
|
-
return
|
|
770
|
+
return D({ f: a, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
|
|
755
771
|
}
|
|
756
772
|
function v(m) {
|
|
757
773
|
const a = t.fields.getByName(m);
|
|
758
|
-
return
|
|
774
|
+
return D({ f: a, s: e }, ({ f: c, s: f }) => {
|
|
759
775
|
const u = c && f[c.id] || null;
|
|
760
776
|
return u || (c?.defaultValue ? c.defaultValue : null);
|
|
761
777
|
});
|
|
762
778
|
}
|
|
763
|
-
return
|
|
779
|
+
return k({
|
|
764
780
|
clock: r,
|
|
765
781
|
target: i.clearAll
|
|
766
|
-
}),
|
|
767
|
-
clock:
|
|
782
|
+
}), k({
|
|
783
|
+
clock: n,
|
|
768
784
|
target: i.clear
|
|
769
785
|
}), {
|
|
770
786
|
register: d,
|
|
771
787
|
clearAll: r,
|
|
772
|
-
clear:
|
|
773
|
-
commit:
|
|
788
|
+
clear: n,
|
|
789
|
+
commit: s,
|
|
774
790
|
getResponsesToCommit: o,
|
|
775
791
|
listStore: p,
|
|
776
792
|
getAllStore: l,
|
|
@@ -778,12 +794,12 @@ const Ye = x("response"), Qe = w(({ client: t }) => {
|
|
|
778
794
|
getByFieldName: v
|
|
779
795
|
};
|
|
780
796
|
});
|
|
781
|
-
function
|
|
782
|
-
return
|
|
797
|
+
function Ze(t) {
|
|
798
|
+
return I(Xe, t);
|
|
783
799
|
}
|
|
784
|
-
const
|
|
785
|
-
function
|
|
786
|
-
if (
|
|
800
|
+
const et = () => "0.0.42-next.2";
|
|
801
|
+
function tt() {
|
|
802
|
+
if (T()) {
|
|
787
803
|
const t = [
|
|
788
804
|
document.currentScript,
|
|
789
805
|
document.getElementById("picked_script"),
|
|
@@ -797,8 +813,8 @@ function et() {
|
|
|
797
813
|
}
|
|
798
814
|
return "https://api.picked.app";
|
|
799
815
|
}
|
|
800
|
-
function
|
|
801
|
-
if (!
|
|
816
|
+
function rt() {
|
|
817
|
+
if (!U())
|
|
802
818
|
return {};
|
|
803
819
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
804
820
|
for (const [i] of t.entries())
|
|
@@ -807,32 +823,32 @@ function tt() {
|
|
|
807
823
|
const d = i.replace("picked-", "");
|
|
808
824
|
e[d] = t.getAll(i);
|
|
809
825
|
}
|
|
810
|
-
const
|
|
826
|
+
const n = A("s");
|
|
811
827
|
if (r.size > 0)
|
|
812
|
-
O.set(
|
|
828
|
+
O.set(n, e);
|
|
813
829
|
else {
|
|
814
|
-
const i = O.get(
|
|
830
|
+
const i = O.get(n);
|
|
815
831
|
if (i)
|
|
816
832
|
return i.json() || {};
|
|
817
833
|
}
|
|
818
834
|
return e;
|
|
819
835
|
}
|
|
820
|
-
function
|
|
836
|
+
function nt() {
|
|
821
837
|
if (ue())
|
|
822
838
|
return crypto.randomUUID();
|
|
823
|
-
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15),
|
|
824
|
-
return `${t}-${e}-${r}-${
|
|
839
|
+
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);
|
|
840
|
+
return `${t}-${e}-${r}-${n}`;
|
|
825
841
|
}
|
|
826
|
-
const st = A("session", "global"),
|
|
827
|
-
const t =
|
|
842
|
+
const st = A("session", "global"), it = () => {
|
|
843
|
+
const t = z.get(st);
|
|
828
844
|
let e;
|
|
829
845
|
t.isSet() && (e = t.json());
|
|
830
846
|
const r = (i) => t.set({
|
|
831
847
|
id: i.id,
|
|
832
848
|
isUser: i.isUser,
|
|
833
849
|
identifiers: i.identifiers
|
|
834
|
-
}),
|
|
835
|
-
id: e?.id ??
|
|
850
|
+
}), n = {
|
|
851
|
+
id: e?.id ?? nt(),
|
|
836
852
|
isUser: e?.isUser ?? void 0,
|
|
837
853
|
identifiers: e?.identifiers ?? void 0,
|
|
838
854
|
setIsUser(i) {
|
|
@@ -847,20 +863,20 @@ const st = A("session", "global"), nt = () => {
|
|
|
847
863
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
848
864
|
}
|
|
849
865
|
};
|
|
850
|
-
return r(
|
|
851
|
-
},
|
|
852
|
-
function
|
|
853
|
-
if (
|
|
866
|
+
return r(n), n;
|
|
867
|
+
}, ot = () => ce() ? it() : null;
|
|
868
|
+
function at() {
|
|
869
|
+
if (U())
|
|
854
870
|
return globalThis.window.pickedConfig;
|
|
855
871
|
}
|
|
856
|
-
function
|
|
857
|
-
if (!
|
|
872
|
+
function ct() {
|
|
873
|
+
if (!U())
|
|
858
874
|
return;
|
|
859
|
-
const t =
|
|
875
|
+
const t = at(), e = t?.organizationId, r = t?.projectId;
|
|
860
876
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
861
877
|
}
|
|
862
|
-
function
|
|
863
|
-
if (!
|
|
878
|
+
function ut() {
|
|
879
|
+
if (!T())
|
|
864
880
|
return;
|
|
865
881
|
const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
|
|
866
882
|
document.getElementById("cvly");
|
|
@@ -869,14 +885,14 @@ function ct() {
|
|
|
869
885
|
const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
|
|
870
886
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
871
887
|
}
|
|
872
|
-
function
|
|
888
|
+
function dt(t) {
|
|
873
889
|
const { organizationId: e, projectId: r } = t;
|
|
874
890
|
if (e && r)
|
|
875
891
|
return { organizationId: e, projectId: r };
|
|
876
|
-
const
|
|
877
|
-
if (
|
|
878
|
-
return
|
|
879
|
-
const i =
|
|
892
|
+
const n = ct();
|
|
893
|
+
if (n)
|
|
894
|
+
return n;
|
|
895
|
+
const i = ut();
|
|
880
896
|
if (i)
|
|
881
897
|
return i;
|
|
882
898
|
throw new Error(
|
|
@@ -886,13 +902,13 @@ function ut(t) {
|
|
|
886
902
|
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
887
903
|
);
|
|
888
904
|
}
|
|
889
|
-
function
|
|
905
|
+
function C(t) {
|
|
890
906
|
return t == null || t === "" || Number.isNaN(t);
|
|
891
907
|
}
|
|
892
|
-
const
|
|
893
|
-
default: (t, e) =>
|
|
894
|
-
append: (t, e) => e && !
|
|
895
|
-
prepend: (t, e) => e && !
|
|
908
|
+
const lt = {
|
|
909
|
+
default: (t, e) => C(t) ? String(e ?? "") : String(t),
|
|
910
|
+
append: (t, e) => e && !C(t) ? `${t} ${e}` : t,
|
|
911
|
+
prepend: (t, e) => e && !C(t) ? `${e} ${t}` : t,
|
|
896
912
|
upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
|
|
897
913
|
lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
|
|
898
914
|
capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
|
|
@@ -903,125 +919,126 @@ const dt = {
|
|
|
903
919
|
if (Array.isArray(t))
|
|
904
920
|
return e.format(t.map(String));
|
|
905
921
|
if (t instanceof Map) {
|
|
906
|
-
const r = Array.from(t.entries()).map(([
|
|
922
|
+
const r = Array.from(t.entries()).map(([n, i]) => `${n}: ${i}`);
|
|
907
923
|
return e.format(r);
|
|
908
924
|
}
|
|
909
925
|
return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
|
|
910
926
|
}
|
|
911
927
|
};
|
|
912
|
-
function
|
|
928
|
+
function pt(t) {
|
|
913
929
|
return typeof t == "object" && t !== null;
|
|
914
930
|
}
|
|
915
|
-
function
|
|
931
|
+
function ft(t, e) {
|
|
916
932
|
let r = e;
|
|
917
|
-
for (const
|
|
918
|
-
if (
|
|
919
|
-
r = r[
|
|
933
|
+
for (const n of t.split("."))
|
|
934
|
+
if (pt(r) && n in r)
|
|
935
|
+
r = r[n];
|
|
920
936
|
else
|
|
921
937
|
return;
|
|
922
938
|
return typeof r == "function" ? r() : r;
|
|
923
939
|
}
|
|
924
|
-
function
|
|
925
|
-
const r = t.split("|").map((d) => d.trim()),
|
|
926
|
-
let i =
|
|
940
|
+
function gt(t, e) {
|
|
941
|
+
const r = t.split("|").map((d) => d.trim()), n = r.shift() ?? "";
|
|
942
|
+
let i = ft(n, e);
|
|
927
943
|
for (const d of r) {
|
|
928
|
-
const [o, ...
|
|
944
|
+
const [o, ...s] = d.split(":"), l = o?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = lt[l];
|
|
929
945
|
h && (i = h(i, p));
|
|
930
946
|
}
|
|
931
|
-
return
|
|
947
|
+
return C(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
|
|
932
948
|
}
|
|
933
|
-
function
|
|
934
|
-
let r = "",
|
|
935
|
-
for (;
|
|
936
|
-
if (t[
|
|
937
|
-
|
|
949
|
+
function mt(t, e) {
|
|
950
|
+
let r = "", n = 0;
|
|
951
|
+
for (; n < t.length; )
|
|
952
|
+
if (t[n] === "{" && t[n + 1] === "{") {
|
|
953
|
+
n += 2;
|
|
938
954
|
let i = "";
|
|
939
|
-
for (;
|
|
940
|
-
if (t[
|
|
941
|
-
|
|
955
|
+
for (; n < t.length; ) {
|
|
956
|
+
if (t[n] === "}" && t[n + 1] === "}") {
|
|
957
|
+
n += 2;
|
|
942
958
|
break;
|
|
943
959
|
}
|
|
944
|
-
i += t[
|
|
960
|
+
i += t[n++];
|
|
945
961
|
}
|
|
946
|
-
r +=
|
|
962
|
+
r += gt(i.trim(), e);
|
|
947
963
|
} else
|
|
948
|
-
r += t[
|
|
964
|
+
r += t[n++];
|
|
949
965
|
return r;
|
|
950
966
|
}
|
|
951
|
-
class
|
|
952
|
-
static logger =
|
|
967
|
+
class ht {
|
|
968
|
+
static logger = w;
|
|
953
969
|
options;
|
|
954
970
|
isReady = !1;
|
|
955
971
|
project;
|
|
956
972
|
plugins = {};
|
|
957
|
-
eventBus =
|
|
973
|
+
eventBus = V();
|
|
974
|
+
events;
|
|
958
975
|
organizationId;
|
|
959
976
|
projectId;
|
|
960
977
|
apiUrl;
|
|
961
978
|
session;
|
|
962
979
|
precondition;
|
|
963
980
|
condition;
|
|
964
|
-
searchParams =
|
|
981
|
+
searchParams = rt();
|
|
965
982
|
history = Ne();
|
|
966
983
|
components = be({ client: this });
|
|
967
|
-
experienceInstances =
|
|
984
|
+
experienceInstances = se({ client: this });
|
|
968
985
|
experiences = ge({ client: this });
|
|
969
986
|
frameworks = xe({ client: this });
|
|
970
|
-
predicates =
|
|
987
|
+
predicates = Ce({ client: this });
|
|
971
988
|
features = Me({ client: this });
|
|
972
|
-
responses =
|
|
973
|
-
fields =
|
|
974
|
-
actions =
|
|
989
|
+
responses = Ze({ client: this });
|
|
990
|
+
fields = Je();
|
|
991
|
+
actions = Ke();
|
|
975
992
|
constructor(e) {
|
|
976
|
-
|
|
977
|
-
const { organizationId: r, projectId:
|
|
978
|
-
this.organizationId = r, this.projectId =
|
|
993
|
+
w("info", "Picked client initializing."), this.events = Ue(this.eventBus);
|
|
994
|
+
const { organizationId: r, projectId: n } = dt(e);
|
|
995
|
+
this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), 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() }), w("info", "Picked client initialized.");
|
|
979
996
|
}
|
|
980
997
|
start = () => {
|
|
981
998
|
Be(this), (async () => {
|
|
982
|
-
if (!
|
|
999
|
+
if (!T())
|
|
983
1000
|
return;
|
|
984
1001
|
let r;
|
|
985
1002
|
typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
|
|
986
|
-
let
|
|
987
|
-
r && (this.condition === void 0 ?
|
|
988
|
-
const i = r &&
|
|
989
|
-
if (typeof
|
|
990
|
-
const d =
|
|
1003
|
+
let n;
|
|
1004
|
+
r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await E(this, this.condition) === !0);
|
|
1005
|
+
const i = r && n === !0;
|
|
1006
|
+
if (typeof n == "boolean" && this.session) {
|
|
1007
|
+
const d = n;
|
|
991
1008
|
this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
|
|
992
1009
|
}
|
|
993
|
-
this.eventBus({ type: "initialize" }), document.body && i &&
|
|
1010
|
+
this.eventBus({ type: "initialize" }), document.body && i && _(this), await ie(), i && _(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session });
|
|
994
1011
|
})();
|
|
995
1012
|
};
|
|
996
1013
|
registerFramework = (e) => {
|
|
997
1014
|
je(e, this.frameworks);
|
|
998
1015
|
};
|
|
999
1016
|
registerComponent = (e, r) => {
|
|
1000
|
-
|
|
1017
|
+
L(e, r, this.components);
|
|
1001
1018
|
};
|
|
1002
1019
|
registerPlugin = (e) => {
|
|
1003
1020
|
ye(this, e, this.plugins);
|
|
1004
1021
|
};
|
|
1005
1022
|
registerFeature = (e, r) => {
|
|
1006
|
-
|
|
1023
|
+
De(e, r, this.features);
|
|
1007
1024
|
};
|
|
1008
1025
|
registerPredicate = (e, r) => {
|
|
1009
|
-
|
|
1026
|
+
ze(e, r, this.predicates);
|
|
1010
1027
|
};
|
|
1011
1028
|
registerField = (e) => {
|
|
1012
|
-
|
|
1029
|
+
He(e, this.fields);
|
|
1013
1030
|
};
|
|
1014
1031
|
registerAction = (e, r) => {
|
|
1015
|
-
|
|
1032
|
+
We(e, r, this.actions);
|
|
1016
1033
|
};
|
|
1017
1034
|
registerExperience = (e) => {
|
|
1018
|
-
e.component &&
|
|
1035
|
+
e.component && L(`experience:${e.id}`, e.component, this.components), me(e, this.experiences);
|
|
1019
1036
|
};
|
|
1020
1037
|
getStateSnapshot = () => Y(this);
|
|
1021
1038
|
launchExperienceById = async (e) => {
|
|
1022
1039
|
const r = this.experiences.getById(e).getState();
|
|
1023
1040
|
if (!r) {
|
|
1024
|
-
|
|
1041
|
+
w("warn", `Experience with id '${e}' not found.`);
|
|
1025
1042
|
return;
|
|
1026
1043
|
}
|
|
1027
1044
|
W(this, r);
|
|
@@ -1038,14 +1055,14 @@ class mt {
|
|
|
1038
1055
|
setupPlugins() {
|
|
1039
1056
|
this.options.plugins?.forEach((e) => {
|
|
1040
1057
|
if (Array.isArray(e)) {
|
|
1041
|
-
e.forEach((
|
|
1042
|
-
this.registerPlugin(
|
|
1058
|
+
e.forEach((n) => {
|
|
1059
|
+
this.registerPlugin(n);
|
|
1043
1060
|
});
|
|
1044
1061
|
return;
|
|
1045
1062
|
}
|
|
1046
1063
|
const r = typeof e == "function" ? e() : e;
|
|
1047
1064
|
if (Array.isArray(r)) {
|
|
1048
|
-
r.forEach((
|
|
1065
|
+
r.forEach((n) => this.registerPlugin(n));
|
|
1049
1066
|
return;
|
|
1050
1067
|
}
|
|
1051
1068
|
this.registerPlugin(r);
|
|
@@ -1053,19 +1070,19 @@ class mt {
|
|
|
1053
1070
|
}
|
|
1054
1071
|
setupFeatures() {
|
|
1055
1072
|
const e = this.options.features;
|
|
1056
|
-
e && (Object.entries(e).forEach(([r,
|
|
1057
|
-
const i = typeof
|
|
1073
|
+
e && (Object.entries(e).forEach(([r, n]) => {
|
|
1074
|
+
const i = typeof n == "function" ? n() : n;
|
|
1058
1075
|
this.registerFeature(r, i);
|
|
1059
1076
|
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
1060
1077
|
try {
|
|
1061
|
-
const [
|
|
1062
|
-
if (!
|
|
1078
|
+
const [n, i] = r.split(":");
|
|
1079
|
+
if (!n || !i)
|
|
1063
1080
|
return;
|
|
1064
1081
|
let d = i;
|
|
1065
|
-
d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(
|
|
1082
|
+
d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(n, {
|
|
1066
1083
|
key: `${d}`,
|
|
1067
1084
|
// use the assigned bucket value as the key
|
|
1068
|
-
name:
|
|
1085
|
+
name: n,
|
|
1069
1086
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
1070
1087
|
decide: () => d,
|
|
1071
1088
|
storage: "session"
|
|
@@ -1076,22 +1093,22 @@ class mt {
|
|
|
1076
1093
|
}
|
|
1077
1094
|
setupPredicates() {
|
|
1078
1095
|
const e = this.options.predicates;
|
|
1079
|
-
e && Object.entries(e).forEach(([r,
|
|
1080
|
-
if (typeof
|
|
1081
|
-
|
|
1096
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
1097
|
+
if (typeof n != "function") {
|
|
1098
|
+
w("warn", `Predicate "${r}" is not a function.`);
|
|
1082
1099
|
return;
|
|
1083
1100
|
}
|
|
1084
|
-
this.registerPredicate(r,
|
|
1101
|
+
this.registerPredicate(r, n);
|
|
1085
1102
|
});
|
|
1086
1103
|
}
|
|
1087
1104
|
setupActions() {
|
|
1088
1105
|
const e = this.options.actions;
|
|
1089
|
-
e && Object.entries(e).forEach(([r,
|
|
1090
|
-
if (typeof
|
|
1091
|
-
|
|
1106
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
1107
|
+
if (typeof n != "function") {
|
|
1108
|
+
w("warn", `Action "${r}" is not a function.`);
|
|
1092
1109
|
return;
|
|
1093
1110
|
}
|
|
1094
|
-
this.registerAction(r,
|
|
1111
|
+
this.registerAction(r, n);
|
|
1095
1112
|
});
|
|
1096
1113
|
}
|
|
1097
1114
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
@@ -1138,57 +1155,57 @@ class mt {
|
|
|
1138
1155
|
* // => "Fruits: apple, banana, and cherry"
|
|
1139
1156
|
*/
|
|
1140
1157
|
renderString = (e, r) => {
|
|
1141
|
-
const
|
|
1142
|
-
return
|
|
1158
|
+
const n = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
|
|
1159
|
+
return mt(e, {
|
|
1143
1160
|
...r,
|
|
1144
|
-
responses:
|
|
1161
|
+
responses: n
|
|
1145
1162
|
});
|
|
1146
1163
|
};
|
|
1147
1164
|
}
|
|
1148
1165
|
function Q(t) {
|
|
1149
1166
|
return t.options?.some((e) => "condition" in e) ?? !1;
|
|
1150
1167
|
}
|
|
1151
|
-
function
|
|
1168
|
+
function yt(t) {
|
|
1152
1169
|
return t.some((e) => e.condition || Q(e));
|
|
1153
1170
|
}
|
|
1154
|
-
async function
|
|
1155
|
-
return e.length === 0 || !
|
|
1156
|
-
e.map(async (
|
|
1157
|
-
if (!(
|
|
1171
|
+
async function jt(t, e) {
|
|
1172
|
+
return e.length === 0 || !yt(e) ? e : (await Promise.all(
|
|
1173
|
+
e.map(async (n) => {
|
|
1174
|
+
if (!(n.condition ? await E(t, n.condition) : !0))
|
|
1158
1175
|
return null;
|
|
1159
|
-
if (!
|
|
1160
|
-
return
|
|
1176
|
+
if (!n.options || !Q(n))
|
|
1177
|
+
return n;
|
|
1161
1178
|
const o = (await Promise.all(
|
|
1162
|
-
|
|
1179
|
+
n.options.map(async (l) => l.condition ? await E(t, l.condition) ? l : null : l)
|
|
1163
1180
|
)).filter((l) => l !== null);
|
|
1164
|
-
return o.length ===
|
|
1181
|
+
return o.length === n.options.length ? n : o.length === 0 ? null : { ...n, options: o };
|
|
1165
1182
|
})
|
|
1166
|
-
)).filter((
|
|
1183
|
+
)).filter((n) => n !== null);
|
|
1167
1184
|
}
|
|
1168
|
-
const
|
|
1169
|
-
const e = new
|
|
1185
|
+
const Et = (t) => {
|
|
1186
|
+
const e = new ht(t);
|
|
1170
1187
|
return de(e), e;
|
|
1171
1188
|
};
|
|
1172
1189
|
export {
|
|
1173
|
-
|
|
1174
|
-
|
|
1190
|
+
ht as Picked,
|
|
1191
|
+
Et as createClient,
|
|
1175
1192
|
A as createStorageKey,
|
|
1176
1193
|
E as evaluateRuleLogic,
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1194
|
+
at as getPickedConfig,
|
|
1195
|
+
jt as getStepFields,
|
|
1196
|
+
Bt as isPickedRoot,
|
|
1197
|
+
z as localStore,
|
|
1181
1198
|
O as sessionStore,
|
|
1182
|
-
|
|
1199
|
+
$t as subscribe,
|
|
1183
1200
|
zt as supportsCookies,
|
|
1184
1201
|
ue as supportsCryptoRandomUUID,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1202
|
+
T as supportsDocument,
|
|
1203
|
+
Ot as supportsHistory,
|
|
1204
|
+
Mt as supportsIntersectionObserver,
|
|
1188
1205
|
ce as supportsLocalStorage,
|
|
1189
|
-
|
|
1206
|
+
Dt as supportsLocation,
|
|
1190
1207
|
Vt as supportsSessionStorage,
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1208
|
+
Nt as supportsShadowRoot,
|
|
1209
|
+
Tt as supportsWebComponents,
|
|
1210
|
+
U as supportsWindow
|
|
1194
1211
|
};
|