@picked/client 0.0.45-next.1 → 0.0.45-next.3
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/server/index.js +1 -1
- package/dist/esm/index.js +343 -335
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-CU_pYPyd.js +820 -0
- package/dist/experience-instance-D_Mwuzb4.cjs +1 -0
- package/dist/types/entities/experience/experience.d.ts +2 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +4 -3
- package/dist/types/entities/experience-instance/experience-instance.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 +6 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-D0bQ9DzM.js +0 -815
- package/dist/experience-instance-D8RtqKEZ.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
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
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
|
|
4
|
-
import { f as Bt } from "../experience-instance-
|
|
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-CU_pYPyd.js";
|
|
4
|
+
import { f as Bt } from "../experience-instance-CU_pYPyd.js";
|
|
5
5
|
import { l as w } from "../logger-C9a75KZn.js";
|
|
6
|
-
import { c as A, l as
|
|
6
|
+
import { c as A, l as C, s as z } from "../storage-Co_LbKr_.js";
|
|
7
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
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
|
|
11
|
+
import { e as Ct, f as zt, g as Mt, h as Dt, i as Vt, j as Nt, k as Tt } from "../supports-8YT4QKI7.js";
|
|
12
12
|
const K = x("experience"), le = b(
|
|
13
13
|
({ client: t, experience: e }) => {
|
|
14
|
-
const r = K.store(e),
|
|
15
|
-
merge(
|
|
14
|
+
const r = K.store(e), n = j(r, {
|
|
15
|
+
merge(p, h) {
|
|
16
16
|
return {
|
|
17
|
-
...
|
|
17
|
+
...p,
|
|
18
18
|
...h.experience
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
}),
|
|
22
|
-
name:
|
|
23
|
-
decisionLogic:
|
|
24
|
-
targetSelectors:
|
|
21
|
+
}), o = r.map((p) => ({
|
|
22
|
+
name: p.name,
|
|
23
|
+
decisionLogic: p.condition ?? p.decide,
|
|
24
|
+
targetSelectors: p.targets,
|
|
25
25
|
initializeOpenLogic: e.initializeOpen
|
|
26
26
|
})), d = t.components.listStore.map(
|
|
27
|
-
(
|
|
27
|
+
(p) => p.find((h) => h.name === `experience:${e.id}`) || p.find((h) => h.name === "experience"),
|
|
28
28
|
{ skipVoid: !1 }
|
|
29
|
-
),
|
|
30
|
-
steps:
|
|
31
|
-
nodes:
|
|
32
|
-
edges:
|
|
33
|
-
conditionals:
|
|
34
|
-
})),
|
|
29
|
+
), i = r.map((p) => ({
|
|
30
|
+
steps: p.steps,
|
|
31
|
+
nodes: p.nodes,
|
|
32
|
+
edges: p.edges,
|
|
33
|
+
conditionals: p.conditionals
|
|
34
|
+
})), s = r.map((p) => p.fields), l = e.actions ?? [];
|
|
35
35
|
return {
|
|
36
36
|
id: e.id,
|
|
37
|
-
configStore:
|
|
38
|
-
treeStore:
|
|
39
|
-
fieldsStore:
|
|
37
|
+
configStore: o,
|
|
38
|
+
treeStore: i,
|
|
39
|
+
fieldsStore: s,
|
|
40
40
|
componentStore: d,
|
|
41
41
|
actions: l,
|
|
42
|
-
merge:
|
|
42
|
+
merge: n.merge
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
|
-
function
|
|
46
|
+
function pe(t) {
|
|
47
47
|
return I(le, t);
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const fe = b(({ client: t }) => {
|
|
50
50
|
const e = K.store({}), r = j(e, {
|
|
51
|
-
register(
|
|
51
|
+
register(i, s) {
|
|
52
52
|
return {
|
|
53
|
-
...
|
|
54
|
-
[
|
|
53
|
+
...i,
|
|
54
|
+
[s.id]: s
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
function
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
58
|
+
function n(i) {
|
|
59
|
+
const s = e.getState()[i.id];
|
|
60
|
+
if (s) {
|
|
61
|
+
s.merge({ experience: i, strategy: "override" });
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const l =
|
|
64
|
+
const l = pe({ client: t, experience: i });
|
|
65
65
|
r.register(l);
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
function d(
|
|
69
|
-
return e.map((
|
|
67
|
+
const o = e.map((i) => Object.values(i));
|
|
68
|
+
function d(i) {
|
|
69
|
+
return e.map((s) => s[i], { skipVoid: !1 });
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
register:
|
|
72
|
+
register: n,
|
|
73
73
|
getById: d,
|
|
74
|
-
listStore:
|
|
74
|
+
listStore: o
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
77
|
function ge(t) {
|
|
78
|
-
return I(
|
|
78
|
+
return I(fe, t);
|
|
79
79
|
}
|
|
80
80
|
const me = (t, e) => {
|
|
81
81
|
e.register(t);
|
|
82
|
-
}, W = (t, e) => {
|
|
83
|
-
const { targetSelectors:
|
|
84
|
-
|
|
85
|
-
({ elements:
|
|
86
|
-
), te(
|
|
87
|
-
t.experienceInstances.spawn(e,
|
|
82
|
+
}, W = (t, e, r) => {
|
|
83
|
+
const { targetSelectors: n } = e.configStore.getState(), o = q(n, e.id);
|
|
84
|
+
o.forEach(
|
|
85
|
+
({ elements: i }) => i.forEach((s) => ee(s, e.id))
|
|
86
|
+
), te(o, e.id).forEach((i) => {
|
|
87
|
+
r ? t.experienceInstances.spawn(e, i, r) : t.experienceInstances.spawn(e, i);
|
|
88
88
|
});
|
|
89
89
|
}, _ = async (t) => {
|
|
90
90
|
await Promise.all(
|
|
@@ -93,21 +93,21 @@ const me = (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
|
|
100
|
-
if (
|
|
101
|
-
const d = r[
|
|
102
|
-
r[
|
|
99
|
+
const n = e.name, o = e.setup(t);
|
|
100
|
+
if (o) {
|
|
101
|
+
const d = r[n] ?? {};
|
|
102
|
+
r[n] = Object.freeze({ ...d, ...o });
|
|
103
103
|
}
|
|
104
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
|
);
|
|
@@ -116,29 +116,29 @@ function ke(t) {
|
|
|
116
116
|
}
|
|
117
117
|
const we = b(({ client: t }) => {
|
|
118
118
|
const e = Se.store({}), r = j(e, {
|
|
119
|
-
register(
|
|
119
|
+
register(i, s) {
|
|
120
120
|
return {
|
|
121
|
-
...
|
|
122
|
-
[
|
|
121
|
+
...i,
|
|
122
|
+
[s.name]: s
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
function
|
|
127
|
-
e.getState()[
|
|
126
|
+
function n(i, s) {
|
|
127
|
+
e.getState()[i] && w(
|
|
128
128
|
"warn",
|
|
129
|
-
`Component '${
|
|
129
|
+
`Component '${i}' already registered. Registering again will override the previous registration.`
|
|
130
130
|
);
|
|
131
|
-
const
|
|
132
|
-
r.register(
|
|
131
|
+
const p = ke({ client: t, name: i, component: s });
|
|
132
|
+
r.register(p);
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function d(
|
|
136
|
-
return e.map((
|
|
134
|
+
const o = e.map((i) => Object.values(i));
|
|
135
|
+
function d(i) {
|
|
136
|
+
return e.map((s) => s[i], { skipVoid: !1 });
|
|
137
137
|
}
|
|
138
138
|
return {
|
|
139
|
-
register:
|
|
139
|
+
register: n,
|
|
140
140
|
getByName: d,
|
|
141
|
-
listStore:
|
|
141
|
+
listStore: o
|
|
142
142
|
};
|
|
143
143
|
});
|
|
144
144
|
function be(t) {
|
|
@@ -148,27 +148,27 @@ const L = (t, e, r) => {
|
|
|
148
148
|
r.register(t, e);
|
|
149
149
|
}, Ie = x("framework"), Fe = b(({ client: t }) => {
|
|
150
150
|
const e = Ie.store({}), r = j(e, {
|
|
151
|
-
register(
|
|
151
|
+
register(i, s) {
|
|
152
152
|
return {
|
|
153
|
-
...
|
|
154
|
-
[
|
|
153
|
+
...i,
|
|
154
|
+
[s.name]: s.framework
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
function
|
|
159
|
-
e.getState()[
|
|
158
|
+
function n(i, s) {
|
|
159
|
+
e.getState()[i] && w(
|
|
160
160
|
"warn",
|
|
161
|
-
`Framework '${
|
|
162
|
-
), r.register({ name:
|
|
161
|
+
`Framework '${i}' already registered. Registering again will override the previous registration.`
|
|
162
|
+
), r.register({ name: i, framework: s });
|
|
163
163
|
}
|
|
164
|
-
const
|
|
165
|
-
function d(
|
|
166
|
-
return e.map((
|
|
164
|
+
const o = e.map((i) => Object.values(i));
|
|
165
|
+
function d(i) {
|
|
166
|
+
return e.map((s) => s[i], { skipVoid: !1 });
|
|
167
167
|
}
|
|
168
168
|
return {
|
|
169
|
-
register:
|
|
169
|
+
register: n,
|
|
170
170
|
getByName: d,
|
|
171
|
-
listStore:
|
|
171
|
+
listStore: o
|
|
172
172
|
};
|
|
173
173
|
});
|
|
174
174
|
function xe(t) {
|
|
@@ -178,21 +178,21 @@ 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 = C.get(Pe);
|
|
182
|
+
let n = 0;
|
|
183
|
+
if (r.isSet() && (n = r.json() ?? 0), n && e - n < Ee)
|
|
184
184
|
return !0;
|
|
185
|
-
const
|
|
185
|
+
const o = Ae(t.apiUrl), d = {
|
|
186
186
|
projectId: t.projectId,
|
|
187
187
|
path: window.location.pathname
|
|
188
|
-
},
|
|
188
|
+
}, i = JSON.stringify(d), s = {
|
|
189
189
|
"Content-Type": "application/json"
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
const v = (await fetch(
|
|
190
|
+
}, p = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
191
|
+
p && (s["x-vercel-protection-bypass"] = p);
|
|
192
|
+
const v = (await fetch(o, {
|
|
193
193
|
method: "POST",
|
|
194
|
-
headers:
|
|
195
|
-
body:
|
|
194
|
+
headers: s,
|
|
195
|
+
body: i
|
|
196
196
|
})).ok;
|
|
197
197
|
return v && r.set(e), v;
|
|
198
198
|
} catch (e) {
|
|
@@ -213,9 +213,9 @@ function Y(t) {
|
|
|
213
213
|
}
|
|
214
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,22 +223,22 @@ const Re = x("predicate"), $e = b(({ 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
|
|
233
|
-
function d(
|
|
234
|
-
return e.map((l) => l[
|
|
232
|
+
const o = e.map((s) => Object.values(s));
|
|
233
|
+
function d(s) {
|
|
234
|
+
return e.map((l) => l[s]?.predicate, { skipVoid: !1 });
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function i(s) {
|
|
237
237
|
const l = N(() => {
|
|
238
238
|
}, {
|
|
239
239
|
skipVoid: !1
|
|
240
|
-
}),
|
|
241
|
-
const h = d(
|
|
240
|
+
}), p = $(async () => {
|
|
241
|
+
const h = d(s).getState();
|
|
242
242
|
if (!h)
|
|
243
243
|
return;
|
|
244
244
|
const v = Y(t);
|
|
@@ -246,27 +246,27 @@ const Re = x("predicate"), $e = b(({ client: t }) => {
|
|
|
246
246
|
});
|
|
247
247
|
return k({
|
|
248
248
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
249
|
-
target:
|
|
249
|
+
target: p
|
|
250
250
|
}), k({
|
|
251
|
-
clock:
|
|
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
|
-
listStore:
|
|
260
|
-
getEvokablePredicate:
|
|
259
|
+
listStore: o,
|
|
260
|
+
getEvokablePredicate: i
|
|
261
261
|
};
|
|
262
262
|
});
|
|
263
|
-
function
|
|
263
|
+
function Oe(t) {
|
|
264
264
|
return I($e, t);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
266
|
+
const Ce = (t, e, r) => {
|
|
267
267
|
r.register(t, e);
|
|
268
|
-
}, J = x("feature"),
|
|
269
|
-
const e = J.store({}), r = J.store([]),
|
|
268
|
+
}, J = x("feature"), ze = 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,
|
|
@@ -274,7 +274,7 @@ const ze = (t, e, r) => {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
|
-
function
|
|
277
|
+
function o(a, c) {
|
|
278
278
|
e.getState()[a] && w(
|
|
279
279
|
"warn",
|
|
280
280
|
`Feature '${a}' already registered. Registering again will override the previous registration.`
|
|
@@ -286,7 +286,7 @@ const ze = (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
|
|
@@ -297,73 +297,73 @@ const ze = (t, e, r) => {
|
|
|
297
297
|
async ({
|
|
298
298
|
id: a,
|
|
299
299
|
key: c,
|
|
300
|
-
storage:
|
|
300
|
+
storage: f = "local"
|
|
301
301
|
}) => {
|
|
302
|
-
const u = A(`feature:${a}:${c}`, "global"), y = (
|
|
303
|
-
return y === null ? null : { id: a, key: c, bucket: y, storage:
|
|
302
|
+
const u = A(`feature:${a}:${c}`, "global"), y = (f === "session" ? z : C).get(u).boolean();
|
|
303
|
+
return y === null ? null : { id: a, key: c, bucket: y, storage: f };
|
|
304
304
|
}
|
|
305
|
-
),
|
|
305
|
+
), i = $((a) => {
|
|
306
306
|
if (!a)
|
|
307
307
|
return null;
|
|
308
308
|
const c = A(`feature:${a.id}:${a.key}`, "global");
|
|
309
|
-
(a.storage === "session" ?
|
|
310
|
-
}),
|
|
309
|
+
(a.storage === "session" ? z : C).set(c, a.bucket);
|
|
310
|
+
}), s = /* @__PURE__ */ new Map(), l = Z({
|
|
311
311
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
312
|
-
effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: c }, { id:
|
|
312
|
+
effect: async ({ allFeaturesStore: a, resolvedFeaturesStore: c }, { id: f, decide: u, key: g }) => {
|
|
313
313
|
const y = c.find(
|
|
314
|
-
(R) => R.id ===
|
|
314
|
+
(R) => R.id === f && R.key === g
|
|
315
315
|
);
|
|
316
316
|
if (y)
|
|
317
317
|
return y;
|
|
318
|
-
const F = a[
|
|
318
|
+
const F = a[f];
|
|
319
319
|
if (!F)
|
|
320
|
-
throw new Error(`Feature with id '${
|
|
321
|
-
const B =
|
|
320
|
+
throw new Error(`Feature with id '${f}' not found`);
|
|
321
|
+
const B = s.get(`${f}:${g}`);
|
|
322
322
|
if (B !== void 0) {
|
|
323
323
|
const R = await B;
|
|
324
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
329
|
return { id: F.id, bucket: X, key: g, storage: F.feature.storage };
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
332
|
k({
|
|
333
|
-
clock:
|
|
333
|
+
clock: n.register,
|
|
334
334
|
fn: (a) => {
|
|
335
|
-
const { id: c, feature:
|
|
336
|
-
return { id: c, key:
|
|
335
|
+
const { id: c, feature: f } = a;
|
|
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) => {
|
|
343
|
-
const { id:
|
|
344
|
-
return y ? { key: y, id:
|
|
343
|
+
const { id: f, bucket: u, storage: g } = c, y = a[f]?.feature.key;
|
|
344
|
+
return y ? { key: y, id: f, bucket: u, storage: g } : null;
|
|
345
345
|
},
|
|
346
|
-
target:
|
|
346
|
+
target: i
|
|
347
347
|
});
|
|
348
|
-
const
|
|
348
|
+
const p = D({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
349
349
|
({
|
|
350
350
|
allFeaturesStore: a,
|
|
351
351
|
resolvedFeaturesStore: c
|
|
352
|
-
}) => Object.values(a).map((
|
|
352
|
+
}) => Object.values(a).map((f) => {
|
|
353
353
|
const u = c.find(
|
|
354
|
-
(g) => g.id ===
|
|
354
|
+
(g) => g.id === f.id && g.key === f.feature.key
|
|
355
355
|
);
|
|
356
356
|
return u ? {
|
|
357
|
-
id:
|
|
358
|
-
name:
|
|
359
|
-
key:
|
|
360
|
-
getBucket: () => ({ id:
|
|
357
|
+
id: f.id,
|
|
358
|
+
name: f.feature.name,
|
|
359
|
+
key: f.feature.key,
|
|
360
|
+
getBucket: () => ({ id: f.id, bucket: u.bucket }),
|
|
361
361
|
isResolved: !0
|
|
362
362
|
} : {
|
|
363
|
-
id:
|
|
364
|
-
name:
|
|
365
|
-
key:
|
|
366
|
-
getBucket: async () => await l(
|
|
363
|
+
id: f.id,
|
|
364
|
+
name: f.feature.name,
|
|
365
|
+
key: f.feature.key,
|
|
366
|
+
getBucket: async () => await l(f.feature),
|
|
367
367
|
isResolved: !1
|
|
368
368
|
};
|
|
369
369
|
})
|
|
@@ -371,8 +371,8 @@ const ze = (t, e, r) => {
|
|
|
371
371
|
k({
|
|
372
372
|
clock: l.doneData,
|
|
373
373
|
source: { resolvedFeatures: r },
|
|
374
|
-
filter: ({ resolvedFeatures: a }, { id: c, key:
|
|
375
|
-
(g) => g.id === c && g.key ===
|
|
374
|
+
filter: ({ resolvedFeatures: a }, { id: c, key: f }) => !a.some(
|
|
375
|
+
(g) => g.id === c && g.key === f
|
|
376
376
|
),
|
|
377
377
|
fn: (a, c) => c,
|
|
378
378
|
target: t.eventBus.prepend((a) => ({
|
|
@@ -388,7 +388,7 @@ const ze = (t, e, r) => {
|
|
|
388
388
|
target: r
|
|
389
389
|
});
|
|
390
390
|
function h(a) {
|
|
391
|
-
return
|
|
391
|
+
return p.map((c) => c.find((f) => f.id === a));
|
|
392
392
|
}
|
|
393
393
|
function v(a) {
|
|
394
394
|
return e.map((c) => c[a], { skipVoid: !1 });
|
|
@@ -398,7 +398,7 @@ const ze = (t, e, r) => {
|
|
|
398
398
|
async () => {
|
|
399
399
|
},
|
|
400
400
|
{ skipVoid: !1 }
|
|
401
|
-
),
|
|
401
|
+
), f = $(async () => {
|
|
402
402
|
const u = h(a).getState();
|
|
403
403
|
if (u)
|
|
404
404
|
return async () => (await u.getBucket()).bucket;
|
|
@@ -406,23 +406,23 @@ const ze = (t, e, r) => {
|
|
|
406
406
|
return k({
|
|
407
407
|
source: r,
|
|
408
408
|
filter: (u) => u.some((g) => g.id === a),
|
|
409
|
-
target:
|
|
409
|
+
target: f
|
|
410
410
|
}), k({
|
|
411
|
-
clock:
|
|
411
|
+
clock: f.doneData,
|
|
412
412
|
filter: (u) => u !== void 0,
|
|
413
413
|
target: c
|
|
414
|
-
}),
|
|
414
|
+
}), f(), c;
|
|
415
415
|
}
|
|
416
416
|
return {
|
|
417
|
-
register:
|
|
417
|
+
register: o,
|
|
418
418
|
getById: h,
|
|
419
419
|
getByName: v,
|
|
420
|
-
listStore:
|
|
420
|
+
listStore: p,
|
|
421
421
|
getEvokableFeature: m
|
|
422
422
|
};
|
|
423
423
|
});
|
|
424
424
|
function Me(t) {
|
|
425
|
-
return I(
|
|
425
|
+
return I(ze, t);
|
|
426
426
|
}
|
|
427
427
|
const De = (t, e, r) => {
|
|
428
428
|
r.register(t, e);
|
|
@@ -437,41 +437,41 @@ function H(t, e) {
|
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
439
|
const Ve = b(() => {
|
|
440
|
-
const t = P.store({ entries: [] }), e = P.event(), r = P.event(),
|
|
441
|
-
t.on(e, (
|
|
442
|
-
entries: [...
|
|
443
|
-
})), t.on(r, (
|
|
440
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), o = P.event();
|
|
441
|
+
t.on(e, (i, s) => ({
|
|
442
|
+
entries: [...i.entries, H(s.experienceId, s.node)]
|
|
443
|
+
})), t.on(r, (i, s) => ({
|
|
444
444
|
entries: [
|
|
445
|
-
...
|
|
446
|
-
H(
|
|
445
|
+
...i.entries.slice(0, -1),
|
|
446
|
+
H(s.experienceId, s.node)
|
|
447
447
|
]
|
|
448
|
-
})), t.on(
|
|
449
|
-
function d(
|
|
448
|
+
})), t.on(o, (i, s) => s);
|
|
449
|
+
function d(i, s) {
|
|
450
450
|
const l = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
451
|
-
for (let
|
|
452
|
-
const h =
|
|
453
|
-
if (!(!v || !
|
|
451
|
+
for (let p = i.length - 1; p >= 0; p--) {
|
|
452
|
+
const h = i[p], v = h?.node;
|
|
453
|
+
if (!(!v || !ne(v)) && !(s && h?.experienceId !== s))
|
|
454
454
|
if (l.lastStepIndex === -1)
|
|
455
|
-
l.lastStepIndex =
|
|
455
|
+
l.lastStepIndex = p;
|
|
456
456
|
else {
|
|
457
|
-
l.secondLastStepIndex =
|
|
457
|
+
l.secondLastStepIndex = p;
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
return l;
|
|
462
462
|
}
|
|
463
|
-
return t.on(
|
|
464
|
-
const { secondLastStepIndex: l } = d(
|
|
463
|
+
return t.on(n, (i, s) => {
|
|
464
|
+
const { secondLastStepIndex: l } = d(i.entries, s.experienceId), p = l !== -1 ? i.entries.slice(0, l + 1) : i.entries;
|
|
465
465
|
return {
|
|
466
|
-
...
|
|
467
|
-
entries:
|
|
466
|
+
...i,
|
|
467
|
+
entries: p
|
|
468
468
|
};
|
|
469
469
|
}), {
|
|
470
470
|
push: e,
|
|
471
471
|
replace: r,
|
|
472
|
-
back:
|
|
473
|
-
restore:
|
|
474
|
-
entriesStore: t.map((
|
|
472
|
+
back: n,
|
|
473
|
+
restore: o,
|
|
474
|
+
entriesStore: t.map((i) => i.entries)
|
|
475
475
|
};
|
|
476
476
|
});
|
|
477
477
|
function Ne() {
|
|
@@ -483,50 +483,50 @@ const Ue = (t) => {
|
|
|
483
483
|
return k({
|
|
484
484
|
clock: t,
|
|
485
485
|
source: e,
|
|
486
|
-
fn: (r,
|
|
486
|
+
fn: (r, n) => [
|
|
487
487
|
...r,
|
|
488
488
|
{
|
|
489
489
|
id: Te++,
|
|
490
490
|
at: /* @__PURE__ */ new Date(),
|
|
491
|
-
payload:
|
|
491
|
+
payload: n
|
|
492
492
|
}
|
|
493
493
|
],
|
|
494
494
|
target: e
|
|
495
495
|
}), e;
|
|
496
496
|
}, _e = x("field"), Le = b(() => {
|
|
497
497
|
const t = _e.store({}), e = j(t, {
|
|
498
|
-
register(
|
|
498
|
+
register(s, l) {
|
|
499
499
|
return {
|
|
500
|
-
...
|
|
500
|
+
...s,
|
|
501
501
|
[l.field.id]: l.field
|
|
502
502
|
};
|
|
503
503
|
}
|
|
504
504
|
});
|
|
505
|
-
function r(
|
|
506
|
-
e.register({ field:
|
|
505
|
+
function r(s) {
|
|
506
|
+
e.register({ field: s });
|
|
507
507
|
}
|
|
508
|
-
function s
|
|
509
|
-
const
|
|
510
|
-
if (!
|
|
508
|
+
function n(s, l) {
|
|
509
|
+
const p = d(s).getState();
|
|
510
|
+
if (!p)
|
|
511
511
|
return;
|
|
512
|
-
const h = Object.assign({},
|
|
512
|
+
const h = Object.assign({}, p, {
|
|
513
513
|
...l
|
|
514
514
|
});
|
|
515
515
|
e.register({ field: { ...h } });
|
|
516
516
|
}
|
|
517
|
-
const
|
|
518
|
-
function d(
|
|
519
|
-
return t.map((l) => l[
|
|
517
|
+
const o = t.map((s) => Object.values(s));
|
|
518
|
+
function d(s) {
|
|
519
|
+
return t.map((l) => l[s] || null);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
522
|
-
return t.map((l) => Object.values(l).find((
|
|
521
|
+
function i(s) {
|
|
522
|
+
return t.map((l) => Object.values(l).find((p) => p.name === s) || null);
|
|
523
523
|
}
|
|
524
524
|
return {
|
|
525
525
|
register: r,
|
|
526
|
-
update:
|
|
526
|
+
update: n,
|
|
527
527
|
getById: d,
|
|
528
|
-
listStore:
|
|
529
|
-
getByName:
|
|
528
|
+
listStore: o,
|
|
529
|
+
getByName: i
|
|
530
530
|
};
|
|
531
531
|
});
|
|
532
532
|
function Je() {
|
|
@@ -536,27 +536,27 @@ const He = (t, e) => {
|
|
|
536
536
|
e.register(t);
|
|
537
537
|
}, Ge = x("action"), qe = b(() => {
|
|
538
538
|
const t = Ge.store({}), e = j(t, {
|
|
539
|
-
register(
|
|
539
|
+
register(i, s) {
|
|
540
540
|
return {
|
|
541
|
-
...
|
|
542
|
-
[
|
|
543
|
-
name:
|
|
544
|
-
action:
|
|
541
|
+
...i,
|
|
542
|
+
[s.name]: {
|
|
543
|
+
name: s.name,
|
|
544
|
+
action: s.action
|
|
545
545
|
}
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
});
|
|
549
|
-
function r(
|
|
550
|
-
e.register({ name:
|
|
549
|
+
function r(i, s) {
|
|
550
|
+
e.register({ name: i, action: s });
|
|
551
551
|
}
|
|
552
|
-
const
|
|
553
|
-
function i
|
|
554
|
-
return t.map((
|
|
552
|
+
const n = t.map((i) => Object.values(i));
|
|
553
|
+
function o(i) {
|
|
554
|
+
return t.map((s) => s[i], { skipVoid: !1 });
|
|
555
555
|
}
|
|
556
|
-
function d(
|
|
556
|
+
function d(i) {
|
|
557
557
|
return t.map(
|
|
558
|
-
(
|
|
559
|
-
const l =
|
|
558
|
+
(s) => {
|
|
559
|
+
const l = s[i];
|
|
560
560
|
return l ? l.action : void 0;
|
|
561
561
|
},
|
|
562
562
|
{ skipVoid: !1 }
|
|
@@ -564,8 +564,8 @@ const He = (t, e) => {
|
|
|
564
564
|
}
|
|
565
565
|
return {
|
|
566
566
|
register: r,
|
|
567
|
-
getByName:
|
|
568
|
-
listStore:
|
|
567
|
+
getByName: o,
|
|
568
|
+
listStore: n,
|
|
569
569
|
getEvokableAction: d
|
|
570
570
|
};
|
|
571
571
|
});
|
|
@@ -589,7 +589,7 @@ function G(t) {
|
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
591
|
const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
592
|
-
const e = Qe.store({}), r = V(),
|
|
592
|
+
const e = Qe.store({}), r = V(), n = V(), o = j(e, {
|
|
593
593
|
register(m, a) {
|
|
594
594
|
return {
|
|
595
595
|
...m,
|
|
@@ -603,8 +603,8 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
|
603
603
|
};
|
|
604
604
|
},
|
|
605
605
|
clear(m, a) {
|
|
606
|
-
const { [a]: c, ...
|
|
607
|
-
return
|
|
606
|
+
const { [a]: c, ...f } = m;
|
|
607
|
+
return f;
|
|
608
608
|
},
|
|
609
609
|
clearAll() {
|
|
610
610
|
return {};
|
|
@@ -614,15 +614,15 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
|
614
614
|
if (typeof m == "string") {
|
|
615
615
|
if (a === void 0)
|
|
616
616
|
throw new Error("Response is required when registering a single field");
|
|
617
|
-
|
|
617
|
+
o.register({ fieldId: m, response: a });
|
|
618
618
|
} else
|
|
619
|
-
|
|
619
|
+
o.registerBatch(m);
|
|
620
620
|
}
|
|
621
|
-
async function
|
|
621
|
+
async function i(m) {
|
|
622
622
|
const a = [];
|
|
623
623
|
return await Promise.allSettled(
|
|
624
|
-
Object.entries(m).map(async ([c,
|
|
625
|
-
let u =
|
|
624
|
+
Object.entries(m).map(async ([c, f]) => {
|
|
625
|
+
let u = f;
|
|
626
626
|
const g = t.fields.getById(c).getState();
|
|
627
627
|
if (!g) {
|
|
628
628
|
a.push({
|
|
@@ -757,38 +757,38 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
|
757
757
|
})
|
|
758
758
|
), { responsesToCommit: m, validationErrors: a };
|
|
759
759
|
}
|
|
760
|
-
async function
|
|
761
|
-
const { responsesToCommit: a, validationErrors: c } = await
|
|
762
|
-
return c.length ? { errors: c } : (
|
|
760
|
+
async function s(m) {
|
|
761
|
+
const { responsesToCommit: a, validationErrors: c } = await i(m);
|
|
762
|
+
return c.length ? { errors: c } : (o.registerBatch(a), { errors: [] });
|
|
763
763
|
}
|
|
764
|
-
const l = e.map((m) => m),
|
|
764
|
+
const l = e.map((m) => m), p = e.map((m) => Object.keys(m).map((c) => ({
|
|
765
765
|
fieldId: c,
|
|
766
766
|
value: m[c]
|
|
767
767
|
})));
|
|
768
768
|
function h(m) {
|
|
769
|
-
const a = t.fields.getById(m), c = e.map((
|
|
770
|
-
return D({ f: a, r: c }, ({ f
|
|
769
|
+
const a = t.fields.getById(m), c = e.map((f) => f[m] || null);
|
|
770
|
+
return D({ f: a, r: c }, ({ f, r: u }) => u || (f?.defaultValue ? f.defaultValue : null));
|
|
771
771
|
}
|
|
772
772
|
function v(m) {
|
|
773
773
|
const a = t.fields.getByName(m);
|
|
774
|
-
return D({ f: a, s: e }, ({ f: c, s:
|
|
775
|
-
const u = c &&
|
|
774
|
+
return D({ f: a, s: e }, ({ f: c, s: f }) => {
|
|
775
|
+
const u = c && f[c.id] || null;
|
|
776
776
|
return u || (c?.defaultValue ? c.defaultValue : null);
|
|
777
777
|
});
|
|
778
778
|
}
|
|
779
779
|
return k({
|
|
780
780
|
clock: r,
|
|
781
|
-
target:
|
|
781
|
+
target: o.clearAll
|
|
782
782
|
}), k({
|
|
783
|
-
clock:
|
|
784
|
-
target:
|
|
783
|
+
clock: n,
|
|
784
|
+
target: o.clear
|
|
785
785
|
}), {
|
|
786
786
|
register: d,
|
|
787
787
|
clearAll: r,
|
|
788
|
-
clear:
|
|
789
|
-
commit:
|
|
790
|
-
getResponsesToCommit:
|
|
791
|
-
listStore:
|
|
788
|
+
clear: n,
|
|
789
|
+
commit: s,
|
|
790
|
+
getResponsesToCommit: i,
|
|
791
|
+
listStore: p,
|
|
792
792
|
getAllStore: l,
|
|
793
793
|
getByFieldId: h,
|
|
794
794
|
getByFieldName: v
|
|
@@ -797,7 +797,7 @@ const Qe = x("response"), Xe = b(({ client: t }) => {
|
|
|
797
797
|
function Ze(t) {
|
|
798
798
|
return I(Xe, t);
|
|
799
799
|
}
|
|
800
|
-
const et = () => "0.0.45-next.
|
|
800
|
+
const et = () => "0.0.45-next.3";
|
|
801
801
|
function tt() {
|
|
802
802
|
if (T()) {
|
|
803
803
|
const t = [
|
|
@@ -817,53 +817,53 @@ function rt() {
|
|
|
817
817
|
if (!U())
|
|
818
818
|
return {};
|
|
819
819
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
820
|
-
for (const [
|
|
821
|
-
|
|
822
|
-
for (const
|
|
823
|
-
const d =
|
|
824
|
-
e[d] = t.getAll(
|
|
820
|
+
for (const [o] of t.entries())
|
|
821
|
+
o.startsWith("picked-") && r.add(o);
|
|
822
|
+
for (const o of r) {
|
|
823
|
+
const d = o.replace("picked-", "");
|
|
824
|
+
e[d] = t.getAll(o);
|
|
825
825
|
}
|
|
826
|
-
const
|
|
826
|
+
const n = A("s");
|
|
827
827
|
if (r.size > 0)
|
|
828
|
-
|
|
828
|
+
z.set(n, e);
|
|
829
829
|
else {
|
|
830
|
-
const
|
|
831
|
-
if (
|
|
832
|
-
return
|
|
830
|
+
const o = z.get(n);
|
|
831
|
+
if (o)
|
|
832
|
+
return o.json() || {};
|
|
833
833
|
}
|
|
834
834
|
return e;
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function nt() {
|
|
837
837
|
if (ue())
|
|
838
838
|
return crypto.randomUUID();
|
|
839
|
-
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15),
|
|
840
|
-
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}`;
|
|
841
841
|
}
|
|
842
|
-
const
|
|
843
|
-
const t =
|
|
842
|
+
const st = A("session", "global"), it = () => {
|
|
843
|
+
const t = C.get(st);
|
|
844
844
|
let e;
|
|
845
845
|
t.isSet() && (e = t.json());
|
|
846
|
-
const r = (
|
|
847
|
-
id:
|
|
848
|
-
isUser:
|
|
849
|
-
identifiers:
|
|
850
|
-
}),
|
|
851
|
-
id: e?.id ??
|
|
846
|
+
const r = (o) => t.set({
|
|
847
|
+
id: o.id,
|
|
848
|
+
isUser: o.isUser,
|
|
849
|
+
identifiers: o.identifiers
|
|
850
|
+
}), n = {
|
|
851
|
+
id: e?.id ?? nt(),
|
|
852
852
|
isUser: e?.isUser ?? void 0,
|
|
853
853
|
identifiers: e?.identifiers ?? void 0,
|
|
854
|
-
setIsUser(
|
|
855
|
-
this.isUser =
|
|
854
|
+
setIsUser(o) {
|
|
855
|
+
this.isUser = o, r(this);
|
|
856
856
|
},
|
|
857
|
-
setIdentifier(
|
|
858
|
-
this.identifiers = { ...this.identifiers, [
|
|
857
|
+
setIdentifier(o, d) {
|
|
858
|
+
this.identifiers = { ...this.identifiers, [o]: d }, r(this);
|
|
859
859
|
},
|
|
860
|
-
removeIdentifier(
|
|
860
|
+
removeIdentifier(o) {
|
|
861
861
|
this.identifiers && (this.identifiers = Object.fromEntries(
|
|
862
|
-
Object.entries(this.identifiers).filter(([d]) => d !==
|
|
862
|
+
Object.entries(this.identifiers).filter(([d]) => d !== o)
|
|
863
863
|
), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, r(this));
|
|
864
864
|
}
|
|
865
865
|
};
|
|
866
|
-
return r(
|
|
866
|
+
return r(n), n;
|
|
867
867
|
}, ot = () => ce() ? it() : null;
|
|
868
868
|
function at() {
|
|
869
869
|
if (U())
|
|
@@ -889,12 +889,12 @@ function dt(t) {
|
|
|
889
889
|
const { organizationId: e, projectId: r } = t;
|
|
890
890
|
if (e && r)
|
|
891
891
|
return { organizationId: e, projectId: r };
|
|
892
|
-
const
|
|
893
|
-
if (
|
|
894
|
-
return
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
return
|
|
892
|
+
const n = ct();
|
|
893
|
+
if (n)
|
|
894
|
+
return n;
|
|
895
|
+
const o = ut();
|
|
896
|
+
if (o)
|
|
897
|
+
return o;
|
|
898
898
|
throw new Error(
|
|
899
899
|
`organizationId and projectId are required. You can provide them via one of:
|
|
900
900
|
(1) createClient({ organizationId, projectId }) options;
|
|
@@ -902,13 +902,13 @@ function dt(t) {
|
|
|
902
902
|
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
903
903
|
);
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function O(t) {
|
|
906
906
|
return t == null || t === "" || Number.isNaN(t);
|
|
907
907
|
}
|
|
908
908
|
const lt = {
|
|
909
|
-
default: (t, e) =>
|
|
910
|
-
append: (t, e) => e && !
|
|
911
|
-
prepend: (t, e) => e && !
|
|
909
|
+
default: (t, e) => O(t) ? String(e ?? "") : String(t),
|
|
910
|
+
append: (t, e) => e && !O(t) ? `${t} ${e}` : t,
|
|
911
|
+
prepend: (t, e) => e && !O(t) ? `${e} ${t}` : t,
|
|
912
912
|
upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
|
|
913
913
|
lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
|
|
914
914
|
capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
|
|
@@ -919,49 +919,49 @@ const lt = {
|
|
|
919
919
|
if (Array.isArray(t))
|
|
920
920
|
return e.format(t.map(String));
|
|
921
921
|
if (t instanceof Map) {
|
|
922
|
-
const r = Array.from(t.entries()).map(([
|
|
922
|
+
const r = Array.from(t.entries()).map(([n, o]) => `${n}: ${o}`);
|
|
923
923
|
return e.format(r);
|
|
924
924
|
}
|
|
925
925
|
return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
|
|
926
926
|
}
|
|
927
927
|
};
|
|
928
|
-
function
|
|
928
|
+
function pt(t) {
|
|
929
929
|
return typeof t == "object" && t !== null;
|
|
930
930
|
}
|
|
931
|
-
function
|
|
931
|
+
function ft(t, e) {
|
|
932
932
|
let r = e;
|
|
933
|
-
for (const
|
|
934
|
-
if (
|
|
935
|
-
r = r[
|
|
933
|
+
for (const n of t.split("."))
|
|
934
|
+
if (pt(r) && n in r)
|
|
935
|
+
r = r[n];
|
|
936
936
|
else
|
|
937
937
|
return;
|
|
938
938
|
return typeof r == "function" ? r() : r;
|
|
939
939
|
}
|
|
940
940
|
function gt(t, e) {
|
|
941
|
-
const r = t.split("|").map((d) => d.trim()),
|
|
942
|
-
let
|
|
941
|
+
const r = t.split("|").map((d) => d.trim()), n = r.shift() ?? "";
|
|
942
|
+
let o = ft(n, e);
|
|
943
943
|
for (const d of r) {
|
|
944
|
-
const [
|
|
945
|
-
h && (
|
|
944
|
+
const [i, ...s] = d.split(":"), l = i?.trim() ?? "", p = s.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), h = lt[l];
|
|
945
|
+
h && (o = h(o, p));
|
|
946
946
|
}
|
|
947
|
-
return
|
|
947
|
+
return O(o) ? "" : typeof o == "object" ? JSON.stringify(o) : String(o);
|
|
948
948
|
}
|
|
949
949
|
function mt(t, e) {
|
|
950
|
-
let r = "",
|
|
951
|
-
for (;
|
|
952
|
-
if (t[
|
|
953
|
-
|
|
954
|
-
let
|
|
955
|
-
for (;
|
|
956
|
-
if (t[
|
|
957
|
-
|
|
950
|
+
let r = "", n = 0;
|
|
951
|
+
for (; n < t.length; )
|
|
952
|
+
if (t[n] === "{" && t[n + 1] === "{") {
|
|
953
|
+
n += 2;
|
|
954
|
+
let o = "";
|
|
955
|
+
for (; n < t.length; ) {
|
|
956
|
+
if (t[n] === "}" && t[n + 1] === "}") {
|
|
957
|
+
n += 2;
|
|
958
958
|
break;
|
|
959
959
|
}
|
|
960
|
-
|
|
960
|
+
o += t[n++];
|
|
961
961
|
}
|
|
962
|
-
r += gt(
|
|
962
|
+
r += gt(o.trim(), e);
|
|
963
963
|
} else
|
|
964
|
-
r += t[
|
|
964
|
+
r += t[n++];
|
|
965
965
|
return r;
|
|
966
966
|
}
|
|
967
967
|
class ht {
|
|
@@ -981,18 +981,18 @@ class ht {
|
|
|
981
981
|
searchParams = rt();
|
|
982
982
|
history = Ne();
|
|
983
983
|
components = be({ client: this });
|
|
984
|
-
experienceInstances =
|
|
984
|
+
experienceInstances = se({ client: this });
|
|
985
985
|
experiences = ge({ client: this });
|
|
986
986
|
frameworks = xe({ client: this });
|
|
987
|
-
predicates =
|
|
987
|
+
predicates = Oe({ client: this });
|
|
988
988
|
features = Me({ client: this });
|
|
989
989
|
responses = Ze({ client: this });
|
|
990
990
|
fields = Je();
|
|
991
991
|
actions = Ke();
|
|
992
992
|
constructor(e) {
|
|
993
993
|
w("info", "Picked client initializing."), this.events = Ue(this.eventBus);
|
|
994
|
-
const { organizationId: r, projectId:
|
|
995
|
-
this.organizationId = r, this.projectId =
|
|
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.");
|
|
996
996
|
}
|
|
997
997
|
start = () => {
|
|
998
998
|
Be(this), (async () => {
|
|
@@ -1000,16 +1000,16 @@ class ht {
|
|
|
1000
1000
|
return;
|
|
1001
1001
|
let r;
|
|
1002
1002
|
typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await E(this, this.precondition) === !0;
|
|
1003
|
-
let
|
|
1004
|
-
r && (this.condition === void 0 ?
|
|
1005
|
-
const
|
|
1006
|
-
if (typeof
|
|
1007
|
-
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 o = r && n === !0;
|
|
1006
|
+
if (typeof n == "boolean" && this.session) {
|
|
1007
|
+
const d = n;
|
|
1008
1008
|
this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
|
|
1009
1009
|
}
|
|
1010
|
-
if (this.eventBus({ type: "initialize" }), document.body &&
|
|
1011
|
-
const { id: d, isUser:
|
|
1012
|
-
this.eventBus({ type: "session", id: d, isUser:
|
|
1010
|
+
if (this.eventBus({ type: "initialize" }), document.body && o && _(this), await ie(), o && _(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1011
|
+
const { id: d, isUser: i, identifiers: s } = this.session;
|
|
1012
|
+
this.eventBus({ type: "session", id: d, isUser: i, identifiers: s });
|
|
1013
1013
|
}
|
|
1014
1014
|
})();
|
|
1015
1015
|
};
|
|
@@ -1026,7 +1026,7 @@ class ht {
|
|
|
1026
1026
|
De(e, r, this.features);
|
|
1027
1027
|
};
|
|
1028
1028
|
registerPredicate = (e, r) => {
|
|
1029
|
-
|
|
1029
|
+
Ce(e, r, this.predicates);
|
|
1030
1030
|
};
|
|
1031
1031
|
registerField = (e) => {
|
|
1032
1032
|
He(e, this.fields);
|
|
@@ -1038,13 +1038,21 @@ class ht {
|
|
|
1038
1038
|
e.component && L(`experience:${e.id}`, e.component, this.components), me(e, this.experiences);
|
|
1039
1039
|
};
|
|
1040
1040
|
getStateSnapshot = () => Y(this);
|
|
1041
|
-
launchExperienceById = async (e) => {
|
|
1042
|
-
const
|
|
1043
|
-
if (!
|
|
1041
|
+
launchExperienceById = async (e, r) => {
|
|
1042
|
+
const n = this.experiences.getById(e).getState();
|
|
1043
|
+
if (!n) {
|
|
1044
1044
|
w("warn", `Experience with id '${e}' not found.`);
|
|
1045
1045
|
return;
|
|
1046
1046
|
}
|
|
1047
|
-
W(this, r);
|
|
1047
|
+
W(this, n, r);
|
|
1048
|
+
};
|
|
1049
|
+
openExperienceById = async (e) => {
|
|
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 });
|
|
1048
1056
|
};
|
|
1049
1057
|
// private async fetchProject() {
|
|
1050
1058
|
// if (this.project) {
|
|
@@ -1058,14 +1066,14 @@ class ht {
|
|
|
1058
1066
|
setupPlugins() {
|
|
1059
1067
|
this.options.plugins?.forEach((e) => {
|
|
1060
1068
|
if (Array.isArray(e)) {
|
|
1061
|
-
e.forEach((
|
|
1062
|
-
this.registerPlugin(
|
|
1069
|
+
e.forEach((n) => {
|
|
1070
|
+
this.registerPlugin(n);
|
|
1063
1071
|
});
|
|
1064
1072
|
return;
|
|
1065
1073
|
}
|
|
1066
1074
|
const r = typeof e == "function" ? e() : e;
|
|
1067
1075
|
if (Array.isArray(r)) {
|
|
1068
|
-
r.forEach((
|
|
1076
|
+
r.forEach((n) => this.registerPlugin(n));
|
|
1069
1077
|
return;
|
|
1070
1078
|
}
|
|
1071
1079
|
this.registerPlugin(r);
|
|
@@ -1073,19 +1081,19 @@ class ht {
|
|
|
1073
1081
|
}
|
|
1074
1082
|
setupFeatures() {
|
|
1075
1083
|
const e = this.options.features;
|
|
1076
|
-
e && (Object.entries(e).forEach(([r,
|
|
1077
|
-
const
|
|
1078
|
-
this.registerFeature(r,
|
|
1084
|
+
e && (Object.entries(e).forEach(([r, n]) => {
|
|
1085
|
+
const o = typeof n == "function" ? n() : n;
|
|
1086
|
+
this.registerFeature(r, o);
|
|
1079
1087
|
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
1080
1088
|
try {
|
|
1081
|
-
const [
|
|
1082
|
-
if (!
|
|
1089
|
+
const [n, o] = r.split(":");
|
|
1090
|
+
if (!n || !o)
|
|
1083
1091
|
return;
|
|
1084
|
-
let d =
|
|
1085
|
-
d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(
|
|
1092
|
+
let d = o;
|
|
1093
|
+
d === "true" && (d = !0), d === "false" && (d = !1), this.registerFeature(n, {
|
|
1086
1094
|
key: `${d}`,
|
|
1087
1095
|
// use the assigned bucket value as the key
|
|
1088
|
-
name:
|
|
1096
|
+
name: n,
|
|
1089
1097
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
1090
1098
|
decide: () => d,
|
|
1091
1099
|
storage: "session"
|
|
@@ -1096,22 +1104,22 @@ class ht {
|
|
|
1096
1104
|
}
|
|
1097
1105
|
setupPredicates() {
|
|
1098
1106
|
const e = this.options.predicates;
|
|
1099
|
-
e && Object.entries(e).forEach(([r,
|
|
1100
|
-
if (typeof
|
|
1107
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
1108
|
+
if (typeof n != "function") {
|
|
1101
1109
|
w("warn", `Predicate "${r}" is not a function.`);
|
|
1102
1110
|
return;
|
|
1103
1111
|
}
|
|
1104
|
-
this.registerPredicate(r,
|
|
1112
|
+
this.registerPredicate(r, n);
|
|
1105
1113
|
});
|
|
1106
1114
|
}
|
|
1107
1115
|
setupActions() {
|
|
1108
1116
|
const e = this.options.actions;
|
|
1109
|
-
e && Object.entries(e).forEach(([r,
|
|
1110
|
-
if (typeof
|
|
1117
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
1118
|
+
if (typeof n != "function") {
|
|
1111
1119
|
w("warn", `Action "${r}" is not a function.`);
|
|
1112
1120
|
return;
|
|
1113
1121
|
}
|
|
1114
|
-
this.registerAction(r,
|
|
1122
|
+
this.registerAction(r, n);
|
|
1115
1123
|
});
|
|
1116
1124
|
}
|
|
1117
1125
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
@@ -1158,10 +1166,10 @@ class ht {
|
|
|
1158
1166
|
* // => "Fruits: apple, banana, and cherry"
|
|
1159
1167
|
*/
|
|
1160
1168
|
renderString = (e, r) => {
|
|
1161
|
-
const
|
|
1169
|
+
const n = this.responses.listStore.getState().reduce((o, d) => (o[d.fieldId] = d.value, o), {});
|
|
1162
1170
|
return mt(e, {
|
|
1163
1171
|
...r,
|
|
1164
|
-
responses:
|
|
1172
|
+
responses: n
|
|
1165
1173
|
});
|
|
1166
1174
|
};
|
|
1167
1175
|
}
|
|
@@ -1173,17 +1181,17 @@ function yt(t) {
|
|
|
1173
1181
|
}
|
|
1174
1182
|
async function jt(t, e) {
|
|
1175
1183
|
return e.length === 0 || !yt(e) ? e : (await Promise.all(
|
|
1176
|
-
e.map(async (
|
|
1177
|
-
if (!(
|
|
1184
|
+
e.map(async (n) => {
|
|
1185
|
+
if (!(n.condition ? await E(t, n.condition) : !0))
|
|
1178
1186
|
return null;
|
|
1179
|
-
if (!
|
|
1180
|
-
return
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1187
|
+
if (!n.options || !Q(n))
|
|
1188
|
+
return n;
|
|
1189
|
+
const i = (await Promise.all(
|
|
1190
|
+
n.options.map(async (l) => l.condition ? await E(t, l.condition) ? l : null : l)
|
|
1183
1191
|
)).filter((l) => l !== null);
|
|
1184
|
-
return
|
|
1192
|
+
return i.length === n.options.length ? n : i.length === 0 ? null : { ...n, options: i };
|
|
1185
1193
|
})
|
|
1186
|
-
)).filter((
|
|
1194
|
+
)).filter((n) => n !== null);
|
|
1187
1195
|
}
|
|
1188
1196
|
const Et = (t) => {
|
|
1189
1197
|
const e = new ht(t);
|
|
@@ -1197,13 +1205,13 @@ export {
|
|
|
1197
1205
|
at as getPickedConfig,
|
|
1198
1206
|
jt as getStepFields,
|
|
1199
1207
|
Bt as isPickedRoot,
|
|
1200
|
-
|
|
1201
|
-
|
|
1208
|
+
C as localStore,
|
|
1209
|
+
z as sessionStore,
|
|
1202
1210
|
$t as subscribe,
|
|
1203
|
-
|
|
1211
|
+
Ct as supportsCookies,
|
|
1204
1212
|
ue as supportsCryptoRandomUUID,
|
|
1205
1213
|
T as supportsDocument,
|
|
1206
|
-
|
|
1214
|
+
zt as supportsHistory,
|
|
1207
1215
|
Mt as supportsIntersectionObserver,
|
|
1208
1216
|
ce as supportsLocalStorage,
|
|
1209
1217
|
Dt as supportsLocation,
|