@picked/client 0.0.1-dev.1778136207545 → 0.0.1-dev.1778458140037
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/{api-NcKXNrkY.cjs → api-DeZvPxwp.cjs} +1 -1
- package/dist/{api-Crj5wFbR.js → api-_Nom0-oJ.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/index.js +174 -220
- package/dist/esm/plugins/dynamic-experiences/index.js +38 -103
- package/dist/types/entities/experience/experience.d.ts +2 -23
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +0 -14
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +0 -38
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -2
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -18
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -62
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/entities/content/content.d.ts +0 -37
- package/dist/types/entities/content/content.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { t as r } from "../logger-6z_gb4rA.js";
|
|
|
4
4
|
import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
|
|
5
5
|
import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
|
|
6
6
|
import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
|
|
7
|
-
import { n as D, r as te } from "../api-
|
|
7
|
+
import { n as D, r as te } from "../api-_Nom0-oJ.js";
|
|
8
8
|
import { t as ne } from "../id-CRqy981z.js";
|
|
9
9
|
import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
|
|
10
10
|
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
@@ -105,18 +105,18 @@ var oe = I(({ client: e }) => {
|
|
|
105
105
|
}
|
|
106
106
|
let c = O({
|
|
107
107
|
source: t,
|
|
108
|
-
effect: async (
|
|
109
|
-
let
|
|
110
|
-
if (!
|
|
111
|
-
"key" in
|
|
108
|
+
effect: async (e, t) => {
|
|
109
|
+
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
110
|
+
if (!n) {
|
|
111
|
+
"key" in t ? `${t.key}` : `${t.id}`;
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
-
let { options:
|
|
115
|
-
if (
|
|
116
|
-
await
|
|
114
|
+
let { options: r } = t;
|
|
115
|
+
if (r?.bypassCondition) {
|
|
116
|
+
await n.initialiseFx(r);
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
await
|
|
119
|
+
await n.shouldInitialiseFx() && await n.initialiseFx(r);
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
return {
|
|
@@ -154,9 +154,9 @@ var oe = I(({ client: e }) => {
|
|
|
154
154
|
listStore: a,
|
|
155
155
|
initialiseExperiencesFx: O({
|
|
156
156
|
source: a,
|
|
157
|
-
effect: async (
|
|
158
|
-
await Promise.all(
|
|
159
|
-
await
|
|
157
|
+
effect: async (e) => {
|
|
158
|
+
await Promise.all(e.map(async (e) => {
|
|
159
|
+
await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
|
|
160
160
|
}));
|
|
161
161
|
}
|
|
162
162
|
})
|
|
@@ -167,17 +167,6 @@ function se(e) {
|
|
|
167
167
|
}
|
|
168
168
|
var ce = async (e) => {
|
|
169
169
|
await e.experiences.initialiseExperiencesFx();
|
|
170
|
-
}, R = async (e, t) => {
|
|
171
|
-
if (!e.contentLoader) return !0;
|
|
172
|
-
try {
|
|
173
|
-
await e.contentLoader({
|
|
174
|
-
id: t.id,
|
|
175
|
-
key: t.key
|
|
176
|
-
});
|
|
177
|
-
} catch {
|
|
178
|
-
`${t.id}`;
|
|
179
|
-
}
|
|
180
|
-
return !0;
|
|
181
170
|
};
|
|
182
171
|
//#endregion
|
|
183
172
|
//#region src/entities/plugin/plugin.ts
|
|
@@ -298,24 +287,24 @@ function Se(e) {
|
|
|
298
287
|
function Ce(e) {
|
|
299
288
|
return typeof e == "number" && !isNaN(e);
|
|
300
289
|
}
|
|
301
|
-
function
|
|
290
|
+
function R(e) {
|
|
302
291
|
return typeof e == "string";
|
|
303
292
|
}
|
|
304
|
-
function
|
|
293
|
+
function z(e) {
|
|
305
294
|
return Array.isArray(e);
|
|
306
295
|
}
|
|
307
|
-
function
|
|
296
|
+
function B(e) {
|
|
308
297
|
return e instanceof Promise;
|
|
309
298
|
}
|
|
310
|
-
function
|
|
299
|
+
function V(e) {
|
|
311
300
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
312
301
|
}
|
|
313
|
-
function
|
|
302
|
+
function H(e) {
|
|
314
303
|
if (Ce(e)) return e;
|
|
315
304
|
let t = parseFloat(`${e}`);
|
|
316
305
|
return isNaN(t) ? 0 : t;
|
|
317
306
|
}
|
|
318
|
-
function
|
|
307
|
+
function U(e) {
|
|
319
308
|
return `${e}`;
|
|
320
309
|
}
|
|
321
310
|
var we = {
|
|
@@ -323,51 +312,51 @@ var we = {
|
|
|
323
312
|
"===": (e, t) => e === t,
|
|
324
313
|
"!=": (e, t) => e != t,
|
|
325
314
|
"!==": (e, t) => e !== t,
|
|
326
|
-
">": (e, t) =>
|
|
327
|
-
">=": (e, t) =>
|
|
315
|
+
">": (e, t) => H(e) > H(t),
|
|
316
|
+
">=": (e, t) => H(e) >= H(t),
|
|
328
317
|
"<": (e, t, n) => {
|
|
329
|
-
let r =
|
|
318
|
+
let r = H(e), i = H(t);
|
|
330
319
|
if (n === void 0) return r < i;
|
|
331
|
-
let a =
|
|
320
|
+
let a = H(n);
|
|
332
321
|
return r < i && i < a;
|
|
333
322
|
},
|
|
334
323
|
"<=": (e, t, n) => {
|
|
335
|
-
let r =
|
|
324
|
+
let r = H(e), i = H(t);
|
|
336
325
|
if (n === void 0) return r <= i;
|
|
337
|
-
let a =
|
|
326
|
+
let a = H(n);
|
|
338
327
|
return r <= i && i <= a;
|
|
339
328
|
},
|
|
340
|
-
"!!": async (e) => await
|
|
341
|
-
"!": async (e) => !await
|
|
342
|
-
"%": (e, t) =>
|
|
329
|
+
"!!": async (e) => await G(e),
|
|
330
|
+
"!": async (e) => !await G(e),
|
|
331
|
+
"%": (e, t) => H(e) % H(t),
|
|
343
332
|
log: (e) => (console.log(e), e),
|
|
344
|
-
in: (e, t) => t ?
|
|
345
|
-
cat: (...e) => e.map(
|
|
333
|
+
in: (e, t) => t ? R(t) ? t.indexOf(U(e)) !== -1 : z(t) ? t.includes(e) : !1 : !1,
|
|
334
|
+
cat: (...e) => e.map(U).join(""),
|
|
346
335
|
substr: (e, t, n) => {
|
|
347
|
-
let r =
|
|
336
|
+
let r = U(e), i = H(t);
|
|
348
337
|
if (n === void 0) return r.substr(i);
|
|
349
|
-
let a =
|
|
338
|
+
let a = H(n);
|
|
350
339
|
if (a < 0) {
|
|
351
340
|
let e = r.substr(i);
|
|
352
341
|
return e.substr(0, e.length + a);
|
|
353
342
|
}
|
|
354
343
|
return r.substr(i, a);
|
|
355
344
|
},
|
|
356
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
357
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
345
|
+
"+": (...e) => e.reduce((e, t) => H(e) + H(t), 0),
|
|
346
|
+
"*": (...e) => e.reduce((e, t) => H(e) * H(t), 1),
|
|
358
347
|
"-": (e, t) => {
|
|
359
|
-
let n =
|
|
360
|
-
return t === void 0 ? -n : n -
|
|
348
|
+
let n = H(e);
|
|
349
|
+
return t === void 0 ? -n : n - H(t);
|
|
361
350
|
},
|
|
362
|
-
"/": (e, t) =>
|
|
363
|
-
min: (...e) => Math.min(...e.map(
|
|
364
|
-
max: (...e) => Math.max(...e.map(
|
|
365
|
-
merge: (...e) => e.reduce((e, t) =>
|
|
351
|
+
"/": (e, t) => H(e) / H(t),
|
|
352
|
+
min: (...e) => Math.min(...e.map(H)),
|
|
353
|
+
max: (...e) => Math.max(...e.map(H)),
|
|
354
|
+
merge: (...e) => e.reduce((e, t) => z(t) ? e.concat(t) : e.concat([t]), []),
|
|
366
355
|
var(e, t) {
|
|
367
356
|
let n = arguments.length > 1 ? t : null;
|
|
368
357
|
if (e === "" || e === "." || e == null) return this;
|
|
369
358
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
370
|
-
let r =
|
|
359
|
+
let r = U(e);
|
|
371
360
|
if (r === "" || r === ".") return this;
|
|
372
361
|
let i = r.split("."), a = this;
|
|
373
362
|
for (let e of i) {
|
|
@@ -380,109 +369,109 @@ var we = {
|
|
|
380
369
|
return a === void 0 ? n : a;
|
|
381
370
|
},
|
|
382
371
|
async missing(...e) {
|
|
383
|
-
let t =
|
|
372
|
+
let t = z(e[0]) ? e[0] : e, n = [];
|
|
384
373
|
for (let e of t) {
|
|
385
|
-
let t = await
|
|
374
|
+
let t = await W({ var: e }, this);
|
|
386
375
|
(t === null || t === "") && n.push(`${e}`);
|
|
387
376
|
}
|
|
388
377
|
return n;
|
|
389
378
|
},
|
|
390
379
|
async missing_some(e, t) {
|
|
391
|
-
let n = await
|
|
392
|
-
if (!
|
|
393
|
-
let r = n.filter(
|
|
394
|
-
return t.filter(
|
|
380
|
+
let n = await W({ missing: t }, this);
|
|
381
|
+
if (!z(n) || !z(t)) return [];
|
|
382
|
+
let r = n.filter(R);
|
|
383
|
+
return t.filter(R).length - r.length >= H(e) ? [] : r;
|
|
395
384
|
},
|
|
396
385
|
invoke(...e) {
|
|
397
386
|
let [t, ...n] = e;
|
|
398
387
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
399
388
|
},
|
|
400
|
-
startsWith: (e, t) =>
|
|
401
|
-
endsWith: (e, t) =>
|
|
389
|
+
startsWith: (e, t) => R(e) && R(t) && e.startsWith(t),
|
|
390
|
+
endsWith: (e, t) => R(e) && R(t) && e.endsWith(t),
|
|
402
391
|
regexp_matches(e, t) {
|
|
403
392
|
let n = e, r = "";
|
|
404
|
-
if (
|
|
393
|
+
if (z(e)) {
|
|
405
394
|
let [t, i] = e;
|
|
406
395
|
n = t, r = i;
|
|
407
396
|
}
|
|
408
|
-
return !
|
|
397
|
+
return !R(n) || !R(r) ? !1 : new RegExp(n, r).test(U(t));
|
|
409
398
|
},
|
|
410
399
|
throw(e) {
|
|
411
|
-
throw Error(
|
|
400
|
+
throw Error(U(e));
|
|
412
401
|
}
|
|
413
402
|
};
|
|
414
|
-
async function
|
|
403
|
+
async function W(e, t) {
|
|
415
404
|
if (!e) return e;
|
|
416
|
-
if (
|
|
417
|
-
if (
|
|
418
|
-
if (!
|
|
405
|
+
if (B(e)) return W(await e, t);
|
|
406
|
+
if (z(e)) return Promise.all(e.map((e) => W(e, t)));
|
|
407
|
+
if (!V(e)) return e;
|
|
419
408
|
let n = Te(e), r = n ? e[n] ?? [] : [];
|
|
420
|
-
switch (
|
|
409
|
+
switch (z(r) || (r = [r]), n) {
|
|
421
410
|
case "if":
|
|
422
411
|
case "?:":
|
|
423
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
424
|
-
return r.length % 2 == 1 ?
|
|
412
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await G(await W(r[e], t))) return W(r[e + 1], t);
|
|
413
|
+
return r.length % 2 == 1 ? W(r[r.length - 1], t) : null;
|
|
425
414
|
case "and": {
|
|
426
415
|
let e = null;
|
|
427
|
-
for (let n of r) if (e = await
|
|
416
|
+
for (let n of r) if (e = await W(n, t), !await G(e)) return e;
|
|
428
417
|
return e;
|
|
429
418
|
}
|
|
430
419
|
case "or": {
|
|
431
420
|
let e = null;
|
|
432
|
-
for (let n of r) if (e = await
|
|
421
|
+
for (let n of r) if (e = await W(n, t), await G(e)) return e;
|
|
433
422
|
return e;
|
|
434
423
|
}
|
|
435
424
|
case "map": {
|
|
436
|
-
let e = await
|
|
437
|
-
return
|
|
425
|
+
let e = await W(r[0], t);
|
|
426
|
+
return z(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
|
|
438
427
|
}
|
|
439
428
|
case "filter": {
|
|
440
|
-
let e = await
|
|
441
|
-
return
|
|
429
|
+
let e = await W(r[0], t);
|
|
430
|
+
return z(e) ? (await Promise.all(e.map(async (e) => ({
|
|
442
431
|
item: e,
|
|
443
|
-
shouldInclude: await
|
|
432
|
+
shouldInclude: await G(await W(r[1], e))
|
|
444
433
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
445
434
|
}
|
|
446
435
|
case "reduce": {
|
|
447
|
-
let e = await
|
|
448
|
-
if (!
|
|
449
|
-
let n = r[1], i = r.length > 2 ? await
|
|
450
|
-
for (let t of e) i = await
|
|
436
|
+
let e = await W(r[0], t);
|
|
437
|
+
if (!z(e)) return r.length > 2 ? await W(r[2], t) : null;
|
|
438
|
+
let n = r[1], i = r.length > 2 ? await W(r[2], t) : null;
|
|
439
|
+
for (let t of e) i = await W(n, {
|
|
451
440
|
current: t,
|
|
452
441
|
accumulator: i
|
|
453
442
|
});
|
|
454
443
|
return i;
|
|
455
444
|
}
|
|
456
445
|
case "all": {
|
|
457
|
-
let e = await
|
|
458
|
-
if (!
|
|
459
|
-
for (let t of e) if (!await
|
|
446
|
+
let e = await W(r[0], t);
|
|
447
|
+
if (!z(e) || e.length === 0) return !1;
|
|
448
|
+
for (let t of e) if (!await G(await W(r[1], t))) return !1;
|
|
460
449
|
return !0;
|
|
461
450
|
}
|
|
462
451
|
case "some": {
|
|
463
|
-
let e = await
|
|
464
|
-
if (!
|
|
465
|
-
for (let t of e) if (await
|
|
452
|
+
let e = await W(r[0], t);
|
|
453
|
+
if (!z(e)) return !1;
|
|
454
|
+
for (let t of e) if (await G(await W(r[1], t))) return !0;
|
|
466
455
|
return !1;
|
|
467
456
|
}
|
|
468
457
|
case "none": {
|
|
469
|
-
let e = await
|
|
470
|
-
if (!
|
|
471
|
-
for (let t of e) if (await
|
|
458
|
+
let e = await W(r[0], t);
|
|
459
|
+
if (!z(e)) return !0;
|
|
460
|
+
for (let t of e) if (await G(await W(r[1], t))) return !1;
|
|
472
461
|
return !0;
|
|
473
462
|
}
|
|
474
463
|
case "catch": try {
|
|
475
|
-
return await
|
|
464
|
+
return await W(r[0], t);
|
|
476
465
|
} catch (e) {
|
|
477
|
-
return
|
|
466
|
+
return V(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
478
467
|
}
|
|
479
468
|
}
|
|
480
|
-
let i = await Promise.all(r.map((e) =>
|
|
469
|
+
let i = await Promise.all(r.map((e) => W(e, t))), a = n ? we[n] : void 0;
|
|
481
470
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
482
471
|
return a.apply(t, i);
|
|
483
472
|
}
|
|
484
|
-
async function
|
|
485
|
-
return
|
|
473
|
+
async function G(e) {
|
|
474
|
+
return B(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
486
475
|
}
|
|
487
476
|
function Te(e) {
|
|
488
477
|
return Object.keys(e)[0];
|
|
@@ -508,7 +497,7 @@ var Ee = I(({ client: e }) => O({
|
|
|
508
497
|
let { bucket: e } = await t.getBucket();
|
|
509
498
|
return e;
|
|
510
499
|
}, e), {});
|
|
511
|
-
return await
|
|
500
|
+
return await W(a, {
|
|
512
501
|
responses: i,
|
|
513
502
|
location: typeof e.location == "object" ? {
|
|
514
503
|
hash: e.location.hash,
|
|
@@ -547,19 +536,19 @@ var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
|
547
536
|
} catch {
|
|
548
537
|
return !1;
|
|
549
538
|
}
|
|
550
|
-
},
|
|
551
|
-
let t =
|
|
539
|
+
}, K = j("lifecycle"), je = I(({ client: e }) => {
|
|
540
|
+
let t = K.store(!1), r = P(void 0, {
|
|
552
541
|
skipVoid: !1,
|
|
553
|
-
domain:
|
|
542
|
+
domain: K
|
|
554
543
|
}), i = P(void 0, {
|
|
555
544
|
skipVoid: !1,
|
|
556
|
-
domain:
|
|
557
|
-
}), a =
|
|
545
|
+
domain: K
|
|
546
|
+
}), a = K.store("idle"), o = K.store([]), s = P(void 0, {
|
|
558
547
|
skipVoid: !1,
|
|
559
|
-
domain:
|
|
548
|
+
domain: K
|
|
560
549
|
}), c = P(void 0, {
|
|
561
550
|
skipVoid: !1,
|
|
562
|
-
domain:
|
|
551
|
+
domain: K
|
|
563
552
|
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
564
553
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
565
554
|
let g = M(() => {
|
|
@@ -932,8 +921,8 @@ var Be = (e, t, n) => {
|
|
|
932
921
|
id: e,
|
|
933
922
|
feature: t
|
|
934
923
|
});
|
|
935
|
-
},
|
|
936
|
-
function
|
|
924
|
+
}, q = j("history");
|
|
925
|
+
function J(e, t) {
|
|
937
926
|
return {
|
|
938
927
|
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
939
928
|
node: t,
|
|
@@ -942,8 +931,8 @@ function Y(e, t) {
|
|
|
942
931
|
};
|
|
943
932
|
}
|
|
944
933
|
var Ve = I(() => {
|
|
945
|
-
let e =
|
|
946
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
934
|
+
let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
|
|
935
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, J(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), J(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
947
936
|
function a(e, t) {
|
|
948
937
|
let n = {
|
|
949
938
|
lastStepIndex: -1,
|
|
@@ -1071,38 +1060,9 @@ function Ze(e, t) {
|
|
|
1071
1060
|
t.register(e);
|
|
1072
1061
|
}
|
|
1073
1062
|
//#endregion
|
|
1074
|
-
//#region src/entities/content/content.ts
|
|
1075
|
-
var Qe = j("content"), $e = I(() => {
|
|
1076
|
-
let e = Qe.store({}), t = A(e, { register(e, t) {
|
|
1077
|
-
return {
|
|
1078
|
-
...e,
|
|
1079
|
-
[t.content.id]: t.content
|
|
1080
|
-
};
|
|
1081
|
-
} });
|
|
1082
|
-
function n(e) {
|
|
1083
|
-
t.register({ content: e });
|
|
1084
|
-
}
|
|
1085
|
-
let r = e.map((e) => Object.values(e));
|
|
1086
|
-
function i(t) {
|
|
1087
|
-
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1088
|
-
}
|
|
1089
|
-
return {
|
|
1090
|
-
register: n,
|
|
1091
|
-
getById: i,
|
|
1092
|
-
listStore: r,
|
|
1093
|
-
indexStore: e
|
|
1094
|
-
};
|
|
1095
|
-
});
|
|
1096
|
-
function et() {
|
|
1097
|
-
return L($e);
|
|
1098
|
-
}
|
|
1099
|
-
function tt(e, t) {
|
|
1100
|
-
t.register(e);
|
|
1101
|
-
}
|
|
1102
|
-
//#endregion
|
|
1103
1063
|
//#region src/entities/action/action.ts
|
|
1104
|
-
var
|
|
1105
|
-
let t =
|
|
1064
|
+
var Qe = j("action"), $e = I(({ client: e }) => {
|
|
1065
|
+
let t = Qe.store({}), n = A(t, { register(e, t) {
|
|
1106
1066
|
return {
|
|
1107
1067
|
...e,
|
|
1108
1068
|
[t.key]: {
|
|
@@ -1160,10 +1120,10 @@ var nt = j("action"), rt = I(({ client: e }) => {
|
|
|
1160
1120
|
getEvokableAction: s
|
|
1161
1121
|
};
|
|
1162
1122
|
});
|
|
1163
|
-
function
|
|
1164
|
-
return L(
|
|
1123
|
+
function et(e) {
|
|
1124
|
+
return L($e, e);
|
|
1165
1125
|
}
|
|
1166
|
-
var
|
|
1126
|
+
var tt = (e, t, n) => {
|
|
1167
1127
|
n.register({
|
|
1168
1128
|
key: e,
|
|
1169
1129
|
action: t
|
|
@@ -1171,7 +1131,7 @@ var at = (e, t, n) => {
|
|
|
1171
1131
|
};
|
|
1172
1132
|
//#endregion
|
|
1173
1133
|
//#region src/entities/response/response-validation.ts
|
|
1174
|
-
function
|
|
1134
|
+
function Y(e, t, n, r) {
|
|
1175
1135
|
return {
|
|
1176
1136
|
fieldKey: e.key,
|
|
1177
1137
|
userMessage: n,
|
|
@@ -1179,62 +1139,62 @@ function X(e, t, n, r) {
|
|
|
1179
1139
|
value: t
|
|
1180
1140
|
};
|
|
1181
1141
|
}
|
|
1182
|
-
function
|
|
1142
|
+
function X(e) {
|
|
1183
1143
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1184
1144
|
}
|
|
1185
|
-
function
|
|
1145
|
+
function nt(e) {
|
|
1186
1146
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1187
1147
|
}
|
|
1188
|
-
function
|
|
1148
|
+
function Z(e) {
|
|
1189
1149
|
try {
|
|
1190
1150
|
return JSON.stringify(e), !0;
|
|
1191
1151
|
} catch {
|
|
1192
1152
|
return !1;
|
|
1193
1153
|
}
|
|
1194
1154
|
}
|
|
1195
|
-
function
|
|
1155
|
+
function rt(e, t) {
|
|
1196
1156
|
return t.find((t) => t.key === e) ?? null;
|
|
1197
1157
|
}
|
|
1198
|
-
function
|
|
1158
|
+
function it(e, t) {
|
|
1199
1159
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1200
1160
|
}
|
|
1201
|
-
function
|
|
1202
|
-
if (e.type !== "object" ||
|
|
1161
|
+
function at(e, t) {
|
|
1162
|
+
if (e.type !== "object" || X(t)) return null;
|
|
1203
1163
|
if (e.multiple) {
|
|
1204
|
-
if (!Array.isArray(t)) return
|
|
1164
|
+
if (!Array.isArray(t)) return Y(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1205
1165
|
for (let n of t) {
|
|
1206
|
-
if (typeof n != "object" || !n) return
|
|
1207
|
-
if (!
|
|
1166
|
+
if (typeof n != "object" || !n) return Y(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1167
|
+
if (!Z(n)) return Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1208
1168
|
}
|
|
1209
1169
|
return null;
|
|
1210
1170
|
}
|
|
1211
|
-
return Array.isArray(t) ?
|
|
1171
|
+
return Array.isArray(t) ? Y(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Y(e, t, "This field expects an object value", "Field expects an object value.") : Z(t) ? null : Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1212
1172
|
}
|
|
1213
|
-
function
|
|
1214
|
-
if (
|
|
1173
|
+
function ot(e, t) {
|
|
1174
|
+
if (X(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1215
1175
|
let n = Array.isArray(t) ? t : [t];
|
|
1216
1176
|
if (e.type === "object") {
|
|
1217
1177
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1218
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1178
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : Y(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1219
1179
|
}
|
|
1220
1180
|
let r = e.options.map((e) => e.value);
|
|
1221
|
-
return n.every((e) => !
|
|
1181
|
+
return n.every((e) => !nt(e) || e === null ? !1 : r.includes(e)) ? null : Y(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1222
1182
|
}
|
|
1223
|
-
async function
|
|
1224
|
-
if (n.validation && !e(n.validation) && !
|
|
1183
|
+
async function st(t, n, r, i) {
|
|
1184
|
+
if (n.validation && !e(n.validation) && !X(r)) {
|
|
1225
1185
|
let e = i ? {
|
|
1226
1186
|
$input: r,
|
|
1227
1187
|
responses: i
|
|
1228
1188
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1229
|
-
if (typeof a == "string") return
|
|
1230
|
-
if (a === !1) return
|
|
1189
|
+
if (typeof a == "string") return Y(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1190
|
+
if (a === !1) return Y(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1231
1191
|
}
|
|
1232
|
-
return n.required &&
|
|
1192
|
+
return n.required && X(r) ? Y(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Y(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1233
1193
|
}
|
|
1234
1194
|
//#endregion
|
|
1235
1195
|
//#region src/entities/response/response.ts
|
|
1236
|
-
var
|
|
1237
|
-
let t =
|
|
1196
|
+
var ct = j("response"), lt = I(({ client: e }) => {
|
|
1197
|
+
let t = ct.store({}), r = N(), i = N(), a = A(t, {
|
|
1238
1198
|
register(e, t) {
|
|
1239
1199
|
return {
|
|
1240
1200
|
...e,
|
|
@@ -1273,7 +1233,7 @@ var ft = j("response"), pt = I(({ client: e }) => {
|
|
|
1273
1233
|
...t,
|
|
1274
1234
|
...n
|
|
1275
1235
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1276
|
-
let o =
|
|
1236
|
+
let o = rt(t, e);
|
|
1277
1237
|
if (!o) {
|
|
1278
1238
|
r.push({
|
|
1279
1239
|
fieldKey: t,
|
|
@@ -1283,17 +1243,17 @@ var ft = j("response"), pt = I(({ client: e }) => {
|
|
|
1283
1243
|
});
|
|
1284
1244
|
return;
|
|
1285
1245
|
}
|
|
1286
|
-
let c =
|
|
1246
|
+
let c = it(o, n), l = await st(s, o, c, a);
|
|
1287
1247
|
if (l) {
|
|
1288
1248
|
r.push(l);
|
|
1289
1249
|
return;
|
|
1290
1250
|
}
|
|
1291
|
-
let u =
|
|
1251
|
+
let u = at(o, c);
|
|
1292
1252
|
if (u) {
|
|
1293
1253
|
r.push(u);
|
|
1294
1254
|
return;
|
|
1295
1255
|
}
|
|
1296
|
-
let d =
|
|
1256
|
+
let d = ot(o, c);
|
|
1297
1257
|
if (d) {
|
|
1298
1258
|
r.push(d);
|
|
1299
1259
|
return;
|
|
@@ -1372,13 +1332,13 @@ var ft = j("response"), pt = I(({ client: e }) => {
|
|
|
1372
1332
|
getByFieldName: _
|
|
1373
1333
|
};
|
|
1374
1334
|
});
|
|
1375
|
-
function
|
|
1376
|
-
return L(
|
|
1335
|
+
function ut(e) {
|
|
1336
|
+
return L(lt, e);
|
|
1377
1337
|
}
|
|
1378
1338
|
//#endregion
|
|
1379
1339
|
//#region src/entities/condition/condition.ts
|
|
1380
|
-
var
|
|
1381
|
-
let e =
|
|
1340
|
+
var dt = j("condition"), ft = I(() => {
|
|
1341
|
+
let e = dt.store({}), t = A(e, { register(e, t) {
|
|
1382
1342
|
return {
|
|
1383
1343
|
...e,
|
|
1384
1344
|
[t.condition.id]: t.condition
|
|
@@ -1402,12 +1362,12 @@ var ht = j("condition"), gt = I(() => {
|
|
|
1402
1362
|
indexStore: e
|
|
1403
1363
|
};
|
|
1404
1364
|
});
|
|
1405
|
-
function
|
|
1406
|
-
return L(
|
|
1365
|
+
function pt() {
|
|
1366
|
+
return L(ft);
|
|
1407
1367
|
}
|
|
1408
1368
|
//#endregion
|
|
1409
1369
|
//#region src/utils/api-url.ts
|
|
1410
|
-
function
|
|
1370
|
+
function mt() {
|
|
1411
1371
|
if (f()) {
|
|
1412
1372
|
let e = [
|
|
1413
1373
|
document.currentScript,
|
|
@@ -1422,7 +1382,7 @@ function vt() {
|
|
|
1422
1382
|
}
|
|
1423
1383
|
//#endregion
|
|
1424
1384
|
//#region src/utils/search-params.ts
|
|
1425
|
-
function
|
|
1385
|
+
function ht() {
|
|
1426
1386
|
if (!o()) return {};
|
|
1427
1387
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1428
1388
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1440,13 +1400,13 @@ function yt() {
|
|
|
1440
1400
|
}
|
|
1441
1401
|
//#endregion
|
|
1442
1402
|
//#region src/entities/session/session.ts
|
|
1443
|
-
var
|
|
1444
|
-
function
|
|
1403
|
+
var Q = E("session", "global");
|
|
1404
|
+
function gt() {
|
|
1445
1405
|
return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1446
1406
|
}
|
|
1447
|
-
function
|
|
1407
|
+
function _t() {
|
|
1448
1408
|
if (!u()) return null;
|
|
1449
|
-
let e = w.get(
|
|
1409
|
+
let e = w.get(Q);
|
|
1450
1410
|
if (!e.isSet()) return null;
|
|
1451
1411
|
try {
|
|
1452
1412
|
return e.json();
|
|
@@ -1454,8 +1414,8 @@ function St() {
|
|
|
1454
1414
|
return null;
|
|
1455
1415
|
}
|
|
1456
1416
|
}
|
|
1457
|
-
var
|
|
1458
|
-
let e =
|
|
1417
|
+
var vt = I(() => {
|
|
1418
|
+
let e = _t(), t = { id: e?.id ?? gt() };
|
|
1459
1419
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1460
1420
|
let n = P(t), r = A(n, {
|
|
1461
1421
|
setIsUser: (e, t) => ({
|
|
@@ -1484,7 +1444,7 @@ var Ct = I(() => {
|
|
|
1484
1444
|
source: n,
|
|
1485
1445
|
effect: (e) => {
|
|
1486
1446
|
if (u()) try {
|
|
1487
|
-
w.get(
|
|
1447
|
+
w.get(Q).set(e);
|
|
1488
1448
|
} catch {}
|
|
1489
1449
|
}
|
|
1490
1450
|
})
|
|
@@ -1495,27 +1455,27 @@ var Ct = I(() => {
|
|
|
1495
1455
|
removeIdentifier: r.removeIdentifier
|
|
1496
1456
|
};
|
|
1497
1457
|
});
|
|
1498
|
-
function
|
|
1499
|
-
return L(
|
|
1458
|
+
function yt() {
|
|
1459
|
+
return L(vt, void 0);
|
|
1500
1460
|
}
|
|
1501
1461
|
//#endregion
|
|
1502
1462
|
//#region src/utils/picked-config.ts
|
|
1503
|
-
function
|
|
1463
|
+
function bt() {
|
|
1504
1464
|
if (o()) return globalThis.window.pickedConfig;
|
|
1505
1465
|
}
|
|
1506
|
-
function
|
|
1507
|
-
if (o()) return
|
|
1466
|
+
function xt() {
|
|
1467
|
+
if (o()) return bt()?.projectId;
|
|
1508
1468
|
}
|
|
1509
|
-
function
|
|
1469
|
+
function St() {
|
|
1510
1470
|
if (!f()) return;
|
|
1511
1471
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1512
1472
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1513
1473
|
}
|
|
1514
|
-
function
|
|
1474
|
+
function Ct(e) {
|
|
1515
1475
|
if (e.projectId) return e.projectId;
|
|
1516
|
-
let t =
|
|
1476
|
+
let t = xt();
|
|
1517
1477
|
if (t) return t;
|
|
1518
|
-
let n =
|
|
1478
|
+
let n = St();
|
|
1519
1479
|
if (n) return n;
|
|
1520
1480
|
throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
|
|
1521
1481
|
}
|
|
@@ -1524,7 +1484,7 @@ function Ot(e) {
|
|
|
1524
1484
|
function $(e) {
|
|
1525
1485
|
return e == null || e === "" || Number.isNaN(e);
|
|
1526
1486
|
}
|
|
1527
|
-
var
|
|
1487
|
+
var wt = {
|
|
1528
1488
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1529
1489
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1530
1490
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1545,24 +1505,24 @@ var kt = {
|
|
|
1545
1505
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1546
1506
|
}
|
|
1547
1507
|
};
|
|
1548
|
-
function
|
|
1508
|
+
function Tt(e) {
|
|
1549
1509
|
return typeof e == "object" && !!e;
|
|
1550
1510
|
}
|
|
1551
|
-
function
|
|
1511
|
+
function Et(e, t) {
|
|
1552
1512
|
let n = t;
|
|
1553
|
-
for (let t of e.split(".")) if (
|
|
1513
|
+
for (let t of e.split(".")) if (Tt(n) && t in n) n = n[t];
|
|
1554
1514
|
else return;
|
|
1555
1515
|
return typeof n == "function" ? n() : n;
|
|
1556
1516
|
}
|
|
1557
|
-
function
|
|
1558
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1517
|
+
function Dt(e, t) {
|
|
1518
|
+
let n = e.split("|").map((e) => e.trim()), r = Et(n.shift() ?? "", t);
|
|
1559
1519
|
for (let e of n) {
|
|
1560
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1520
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = wt[i];
|
|
1561
1521
|
o && (r = o(r, a));
|
|
1562
1522
|
}
|
|
1563
1523
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1564
1524
|
}
|
|
1565
|
-
function
|
|
1525
|
+
function Ot(e, t) {
|
|
1566
1526
|
let n = "", r = 0;
|
|
1567
1527
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1568
1528
|
r += 2;
|
|
@@ -1574,17 +1534,15 @@ function Nt(e, t) {
|
|
|
1574
1534
|
}
|
|
1575
1535
|
i += e[r++];
|
|
1576
1536
|
}
|
|
1577
|
-
n +=
|
|
1537
|
+
n += Dt(i.trim(), t);
|
|
1578
1538
|
} else n += e[r++];
|
|
1579
1539
|
return n;
|
|
1580
1540
|
}
|
|
1581
1541
|
//#endregion
|
|
1582
1542
|
//#region src/picked.ts
|
|
1583
|
-
var
|
|
1543
|
+
var kt = class {
|
|
1584
1544
|
static logger = r;
|
|
1585
1545
|
options;
|
|
1586
|
-
dataSource = null;
|
|
1587
|
-
contentLoader;
|
|
1588
1546
|
plugins = {};
|
|
1589
1547
|
eventBus = N();
|
|
1590
1548
|
events;
|
|
@@ -1592,8 +1550,8 @@ var Pt = class {
|
|
|
1592
1550
|
apiUrl;
|
|
1593
1551
|
dashboardUrl;
|
|
1594
1552
|
documentationSiteUrl;
|
|
1595
|
-
session =
|
|
1596
|
-
searchParams =
|
|
1553
|
+
session = yt();
|
|
1554
|
+
searchParams = ht();
|
|
1597
1555
|
history = He();
|
|
1598
1556
|
components = he({ client: this });
|
|
1599
1557
|
experienceInstances = b({ client: this });
|
|
@@ -1601,12 +1559,11 @@ var Pt = class {
|
|
|
1601
1559
|
frameworks = ye({ client: this });
|
|
1602
1560
|
predicates = Fe({ client: this });
|
|
1603
1561
|
features = ze({ client: this });
|
|
1604
|
-
conditions =
|
|
1562
|
+
conditions = pt();
|
|
1605
1563
|
fields = qe();
|
|
1606
|
-
responses =
|
|
1564
|
+
responses = ut({ client: this });
|
|
1607
1565
|
steps = Xe();
|
|
1608
|
-
|
|
1609
|
-
actions = it({ client: this });
|
|
1566
|
+
actions = et({ client: this });
|
|
1610
1567
|
stateSnapshotStore = Se({ client: this });
|
|
1611
1568
|
evaluateRuleLogicFx = De({ client: this });
|
|
1612
1569
|
start;
|
|
@@ -1620,14 +1577,14 @@ var Pt = class {
|
|
|
1620
1577
|
effect: (e, { template: t, context: n }) => {
|
|
1621
1578
|
let r = {};
|
|
1622
1579
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1623
|
-
return
|
|
1580
|
+
return Ot(t, {
|
|
1624
1581
|
...n,
|
|
1625
1582
|
responses: r
|
|
1626
1583
|
});
|
|
1627
1584
|
}
|
|
1628
1585
|
});
|
|
1629
1586
|
constructor(e) {
|
|
1630
|
-
this.events = We(this.eventBus), this.projectId =
|
|
1587
|
+
this.events = We(this.eventBus), this.projectId = Ct(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
|
|
1631
1588
|
type: "load",
|
|
1632
1589
|
version: te()
|
|
1633
1590
|
});
|
|
@@ -1658,11 +1615,8 @@ var Pt = class {
|
|
|
1658
1615
|
registerStep = (e) => {
|
|
1659
1616
|
Ze(e, this.steps);
|
|
1660
1617
|
};
|
|
1661
|
-
registerContent = (e) => {
|
|
1662
|
-
tt(e, this.contents);
|
|
1663
|
-
};
|
|
1664
1618
|
registerAction = (e, t) => {
|
|
1665
|
-
|
|
1619
|
+
tt(e, t, this.actions);
|
|
1666
1620
|
};
|
|
1667
1621
|
registerExperience = (e) => {
|
|
1668
1622
|
e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
@@ -1750,20 +1704,20 @@ var Pt = class {
|
|
|
1750
1704
|
};
|
|
1751
1705
|
//#endregion
|
|
1752
1706
|
//#region src/entities/component/lazyComponent.ts
|
|
1753
|
-
function
|
|
1707
|
+
function At(e) {
|
|
1754
1708
|
return {
|
|
1755
1709
|
$$type: "lazy-component",
|
|
1756
1710
|
load: e
|
|
1757
1711
|
};
|
|
1758
1712
|
}
|
|
1759
|
-
function
|
|
1713
|
+
function jt(e) {
|
|
1760
1714
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1761
1715
|
}
|
|
1762
1716
|
//#endregion
|
|
1763
1717
|
//#region src/exports.ts
|
|
1764
|
-
var
|
|
1765
|
-
let t = new
|
|
1718
|
+
var Mt = (e) => {
|
|
1719
|
+
let t = new kt(e);
|
|
1766
1720
|
return d(t), t;
|
|
1767
1721
|
};
|
|
1768
1722
|
//#endregion
|
|
1769
|
-
export {
|
|
1723
|
+
export { kt as Picked, Mt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, bt as getPickedConfig, jt as isLazyLoader, _ as isPickedRoot, At as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
|