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