@picked/client 0.0.75-next.1 → 0.0.76-next.1
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/.tsbuildinfo +1 -1
- package/dist/{api-CUlZaK-b.cjs → api-BSaiU2_6.cjs} +1 -1
- package/dist/{api-ITpKqiED.js → api-Ck8lmzse.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/reference/sdk/features.md +7 -0
- package/dist/esm/index.js +226 -461
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/server/index.js +1 -1
- package/dist/{plugin-BNLWb4FA.js → plugin-lN21f9R_.js} +73 -52
- package/dist/plugin-lSsl6IEd.cjs +1 -0
- package/dist/{provider-DCjzwNWK.cjs → provider-DtspNGzA.cjs} +1 -1
- package/dist/{provider-Da1D5BIA.js → provider-So2by8pt.js} +1 -1
- package/dist/types/entities/feature/feature.d.ts +43 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/version-OPJEe34i.cjs +1 -0
- package/dist/version-u9kKN2Ti.js +256 -0
- package/package.json +2 -2
- package/dist/plugin-xFCAKJuO.cjs +0 -1
- package/dist/version-BsVuRkHH.js +0 -4
- package/dist/version-DYoxIopP.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -5,14 +5,14 @@ import { a as i, c as a, d as o, f as s, i as c, l, m as u, n as d, o as f, r as
|
|
|
5
5
|
import { a as _, i as v, r as ee, s as y, t as b } from "../dom-BqcToNL0.js";
|
|
6
6
|
import { l as x, n as S, r as C, u as w } from "../experience-instance-DGk11d8a.js";
|
|
7
7
|
import { i as T, n as E, r as D, t as O } from "../storage-1MW3-_As.js";
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { n as
|
|
11
|
-
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as
|
|
8
|
+
import { i as te, n as ne, r as re, t as ie } from "../version-u9kKN2Ti.js";
|
|
9
|
+
import { t as ae } from "../id-Bo4RBeOs.js";
|
|
10
|
+
import { n as oe, r as se, t as ce } from "../inert-script-report-B_bMPRzp.js";
|
|
11
|
+
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as le, sample as I } from "effector";
|
|
12
12
|
import { createFactory as L, invoke as R } from "@withease/factories";
|
|
13
|
-
import { sendPing as
|
|
13
|
+
import { sendPing as ue } from "@picked/delivery-api-client";
|
|
14
14
|
//#region src/entities/experience/experience.ts
|
|
15
|
-
var z = M("experience"),
|
|
15
|
+
var z = M("experience"), de = L(({ client: e, experience: r }) => {
|
|
16
16
|
let i = z.store(r), a = j(i, { merge(e, t) {
|
|
17
17
|
return {
|
|
18
18
|
...e,
|
|
@@ -99,17 +99,17 @@ var z = M("experience"), ce = L(({ client: e, experience: r }) => {
|
|
|
99
99
|
prepareExperienceContentFx: m
|
|
100
100
|
}, u;
|
|
101
101
|
});
|
|
102
|
-
function
|
|
103
|
-
return R(
|
|
102
|
+
function fe(e) {
|
|
103
|
+
return R(de, e);
|
|
104
104
|
}
|
|
105
|
-
var
|
|
105
|
+
var pe = L(({ client: e }) => {
|
|
106
106
|
let t = z.store({}), n = j(t, { register(e, t) {
|
|
107
107
|
return {
|
|
108
108
|
...e,
|
|
109
109
|
[t.id]: t
|
|
110
110
|
};
|
|
111
111
|
} }), r = P(), i = N((t) => {
|
|
112
|
-
n.register(
|
|
112
|
+
n.register(fe({
|
|
113
113
|
client: e,
|
|
114
114
|
experience: t
|
|
115
115
|
}));
|
|
@@ -195,20 +195,20 @@ var ue = L(({ client: e }) => {
|
|
|
195
195
|
})
|
|
196
196
|
};
|
|
197
197
|
});
|
|
198
|
-
function
|
|
199
|
-
return R(
|
|
198
|
+
function me(e) {
|
|
199
|
+
return R(pe, e);
|
|
200
200
|
}
|
|
201
|
-
var
|
|
201
|
+
var he = async (e) => {
|
|
202
202
|
await e.experiences.initialiseExperiencesFx();
|
|
203
203
|
};
|
|
204
204
|
//#endregion
|
|
205
205
|
//#region src/entities/plugin/plugin.ts
|
|
206
|
-
function
|
|
206
|
+
function ge(e) {
|
|
207
207
|
return N(async () => {
|
|
208
208
|
await e();
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
-
var
|
|
211
|
+
var _e = (e, t, n) => {
|
|
212
212
|
let r = t.name, i = t.setup(e);
|
|
213
213
|
if (i) {
|
|
214
214
|
let e = n[r] ?? {};
|
|
@@ -217,16 +217,16 @@ var me = (e, t, n) => {
|
|
|
217
217
|
...i
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
-
},
|
|
220
|
+
}, ve = M("component"), ye = L(({ client: e, component: t, name: n }) => ({
|
|
221
221
|
name: n,
|
|
222
222
|
component: t,
|
|
223
223
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
224
224
|
}));
|
|
225
|
-
function
|
|
226
|
-
return R(
|
|
225
|
+
function be(e) {
|
|
226
|
+
return R(ye, e);
|
|
227
227
|
}
|
|
228
|
-
var
|
|
229
|
-
let t =
|
|
228
|
+
var xe = L(({ client: e }) => {
|
|
229
|
+
let t = ve.store({}), n = j(t, { register(e, t) {
|
|
230
230
|
return {
|
|
231
231
|
...e,
|
|
232
232
|
[t.name]: t
|
|
@@ -239,7 +239,7 @@ var ve = L(({ client: e }) => {
|
|
|
239
239
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
240
240
|
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
241
241
|
clock: i,
|
|
242
|
-
fn: ({ name: t, component: n }) =>
|
|
242
|
+
fn: ({ name: t, component: n }) => be({
|
|
243
243
|
client: e,
|
|
244
244
|
name: t,
|
|
245
245
|
component: n
|
|
@@ -256,16 +256,16 @@ var ve = L(({ client: e }) => {
|
|
|
256
256
|
listStore: a
|
|
257
257
|
};
|
|
258
258
|
});
|
|
259
|
-
function
|
|
260
|
-
return R(
|
|
259
|
+
function Se(e) {
|
|
260
|
+
return R(xe, e);
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var Ce = (e, t, n) => {
|
|
263
263
|
n.register({
|
|
264
264
|
name: e,
|
|
265
265
|
component: t
|
|
266
266
|
});
|
|
267
|
-
},
|
|
268
|
-
let t =
|
|
267
|
+
}, we = M("framework"), Te = L((e) => {
|
|
268
|
+
let t = we.store({}), n = j(t, { register(e, t) {
|
|
269
269
|
return {
|
|
270
270
|
...e,
|
|
271
271
|
[t.name]: t.framework
|
|
@@ -290,15 +290,15 @@ var be = (e, t, n) => {
|
|
|
290
290
|
listStore: a
|
|
291
291
|
};
|
|
292
292
|
});
|
|
293
|
-
function
|
|
294
|
-
return R(
|
|
293
|
+
function Ee(e) {
|
|
294
|
+
return R(Te, e);
|
|
295
295
|
}
|
|
296
|
-
var
|
|
296
|
+
var De = (e, t) => {
|
|
297
297
|
t.register({
|
|
298
298
|
name: e.name,
|
|
299
299
|
framework: e
|
|
300
300
|
});
|
|
301
|
-
},
|
|
301
|
+
}, Oe = L(({ client: e }) => {
|
|
302
302
|
let t = "window" in globalThis, n = {
|
|
303
303
|
location: t ? globalThis.location : void 0,
|
|
304
304
|
document: t ? globalThis.document : void 0,
|
|
@@ -312,12 +312,12 @@ var we = (e, t) => {
|
|
|
312
312
|
...n
|
|
313
313
|
}));
|
|
314
314
|
});
|
|
315
|
-
function
|
|
316
|
-
return R(
|
|
315
|
+
function ke(e) {
|
|
316
|
+
return R(Oe, e);
|
|
317
317
|
}
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/logic-engine.ts
|
|
320
|
-
function
|
|
320
|
+
function Ae(e) {
|
|
321
321
|
return typeof e == "number" && !isNaN(e);
|
|
322
322
|
}
|
|
323
323
|
function B(e) {
|
|
@@ -326,21 +326,21 @@ function B(e) {
|
|
|
326
326
|
function V(e) {
|
|
327
327
|
return Array.isArray(e);
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function je(e) {
|
|
330
330
|
return e instanceof Promise;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Me(e) {
|
|
333
333
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
334
334
|
}
|
|
335
335
|
function H(e) {
|
|
336
|
-
if (
|
|
336
|
+
if (Ae(e)) return e;
|
|
337
337
|
let t = parseFloat(`${e}`);
|
|
338
338
|
return isNaN(t) ? 0 : t;
|
|
339
339
|
}
|
|
340
340
|
function U(e) {
|
|
341
341
|
return `${e}`;
|
|
342
342
|
}
|
|
343
|
-
var
|
|
343
|
+
var Ne = {
|
|
344
344
|
"==": (e, t) => e == t,
|
|
345
345
|
"===": (e, t) => e === t,
|
|
346
346
|
"!=": (e, t) => e != t,
|
|
@@ -435,10 +435,10 @@ var Ae = {
|
|
|
435
435
|
};
|
|
436
436
|
async function W(e, t) {
|
|
437
437
|
if (!e) return e;
|
|
438
|
-
if (
|
|
438
|
+
if (je(e)) return W(await e, t);
|
|
439
439
|
if (V(e)) return Promise.all(e.map((e) => W(e, t)));
|
|
440
|
-
if (!
|
|
441
|
-
let n =
|
|
440
|
+
if (!Me(e)) return e;
|
|
441
|
+
let n = Pe(e), r = n ? e[n] ?? [] : [];
|
|
442
442
|
switch (V(r) || (r = [r]), n) {
|
|
443
443
|
case "if":
|
|
444
444
|
case "?:":
|
|
@@ -496,32 +496,32 @@ async function W(e, t) {
|
|
|
496
496
|
case "catch": try {
|
|
497
497
|
return await W(r[0], t);
|
|
498
498
|
} catch (e) {
|
|
499
|
-
return
|
|
499
|
+
return Me(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
let i = await Promise.all(r.map((e) => W(e, t))), a = n ?
|
|
502
|
+
let i = await Promise.all(r.map((e) => W(e, t))), a = n ? Ne[n] : void 0;
|
|
503
503
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
504
504
|
return a.apply(t, i);
|
|
505
505
|
}
|
|
506
506
|
async function G(e) {
|
|
507
|
-
return
|
|
507
|
+
return je(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function Pe(e) {
|
|
510
510
|
return Object.keys(e)[0];
|
|
511
511
|
}
|
|
512
512
|
//#endregion
|
|
513
513
|
//#region src/lifecycle/rules-logic.ts
|
|
514
|
-
function
|
|
514
|
+
function Fe(e, t, n) {
|
|
515
515
|
return new Proxy(Object.create(null), { get(r, i) {
|
|
516
516
|
if (typeof i != "string") return;
|
|
517
517
|
let a = e.find((e) => e.key === i);
|
|
518
518
|
if (a !== void 0) return async () => !n.has(i) && await W(a.logic, {
|
|
519
519
|
...t,
|
|
520
|
-
conditions:
|
|
520
|
+
conditions: Fe(e, t, new Set(n).add(i))
|
|
521
521
|
}) === !0;
|
|
522
522
|
} });
|
|
523
523
|
}
|
|
524
|
-
var
|
|
524
|
+
var Ie = L(({ client: e }) => k({
|
|
525
525
|
source: {
|
|
526
526
|
stateSnapshot: e.stateSnapshotStore,
|
|
527
527
|
predicates: e.predicates.listStore,
|
|
@@ -560,22 +560,22 @@ var Ne = L(({ client: e }) => k({
|
|
|
560
560
|
};
|
|
561
561
|
return await W(o, {
|
|
562
562
|
...d,
|
|
563
|
-
conditions:
|
|
563
|
+
conditions: Fe(a, d, /* @__PURE__ */ new Set())
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
}));
|
|
567
|
-
function
|
|
568
|
-
return R(
|
|
567
|
+
function Le(e) {
|
|
568
|
+
return R(Ie, e);
|
|
569
569
|
}
|
|
570
570
|
//#endregion
|
|
571
571
|
//#region src/ping.ts
|
|
572
|
-
var
|
|
572
|
+
var Re = 6e3, ze = O("last_ping", "global"), Be = async (e) => {
|
|
573
573
|
try {
|
|
574
|
-
let t = Date.now(), n = E.get(
|
|
575
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
574
|
+
let t = Date.now(), n = E.get(ze), r = 0;
|
|
575
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Re) return !0;
|
|
576
576
|
let i = {}, a = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
577
577
|
a && (i["x-vercel-protection-bypass"] = a);
|
|
578
|
-
let o = await
|
|
578
|
+
let o = await ue(e.apiUrl, {
|
|
579
579
|
projectId: e.projectId,
|
|
580
580
|
path: window.location.pathname
|
|
581
581
|
}, { headers: i });
|
|
@@ -583,7 +583,7 @@ var Fe = 6e3, Ie = O("last_ping", "global"), Le = async (e) => {
|
|
|
583
583
|
} catch {
|
|
584
584
|
return !1;
|
|
585
585
|
}
|
|
586
|
-
}, K = M("lifecycle"),
|
|
586
|
+
}, K = M("lifecycle"), Ve = L(({ client: e }) => {
|
|
587
587
|
let t = K.store(!1), r = F(void 0, {
|
|
588
588
|
skipVoid: !1,
|
|
589
589
|
domain: K
|
|
@@ -599,11 +599,11 @@ var Fe = 6e3, Ie = O("last_ping", "global"), Le = async (e) => {
|
|
|
599
599
|
}), u = P(), d = P(), f = P(), p = P(), m = P(), h = P();
|
|
600
600
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), l.on(h, (e, t) => t), t.on(d, () => !0);
|
|
601
601
|
let g = N(() => {
|
|
602
|
-
|
|
602
|
+
Be(e);
|
|
603
603
|
}), _ = N(async () => {
|
|
604
604
|
await ee();
|
|
605
605
|
}), v = N(async () => {
|
|
606
|
-
await
|
|
606
|
+
await he(e);
|
|
607
607
|
}), y = k({ effect: v }), b = k({
|
|
608
608
|
source: o,
|
|
609
609
|
effect: async (e) => {
|
|
@@ -732,13 +732,13 @@ var Fe = 6e3, Ie = O("last_ping", "global"), Le = async (e) => {
|
|
|
732
732
|
setCondition: h
|
|
733
733
|
};
|
|
734
734
|
});
|
|
735
|
-
function
|
|
736
|
-
return R(
|
|
735
|
+
function He(e) {
|
|
736
|
+
return R(Ve, e);
|
|
737
737
|
}
|
|
738
738
|
//#endregion
|
|
739
739
|
//#region src/entities/predicate/predicate.ts
|
|
740
|
-
var
|
|
741
|
-
let t =
|
|
740
|
+
var Ue = M("predicate"), We = L(({ client: e }) => {
|
|
741
|
+
let t = Ue.store({}), n = j(t, { register(e, t) {
|
|
742
742
|
return {
|
|
743
743
|
...e,
|
|
744
744
|
[t.name]: {
|
|
@@ -796,261 +796,26 @@ var Be = M("predicate"), Ve = L(({ client: e }) => {
|
|
|
796
796
|
getEvokablePredicate: s
|
|
797
797
|
};
|
|
798
798
|
});
|
|
799
|
-
function
|
|
800
|
-
return R(
|
|
799
|
+
function Ge(e) {
|
|
800
|
+
return R(We, e);
|
|
801
801
|
}
|
|
802
|
-
var
|
|
802
|
+
var Ke = (e, t, n) => {
|
|
803
803
|
n.register({
|
|
804
804
|
name: e,
|
|
805
805
|
predicate: t
|
|
806
806
|
});
|
|
807
|
-
},
|
|
808
|
-
function
|
|
809
|
-
return e?.enabled === !1;
|
|
810
|
-
}
|
|
811
|
-
function Ge(e) {
|
|
812
|
-
return e === "true" || e !== "false" && e;
|
|
813
|
-
}
|
|
814
|
-
var Ke = L(({ client: e }) => {
|
|
815
|
-
let t = We.store({}), n = We.store([]), i = j(t, { register(e, t) {
|
|
816
|
-
return {
|
|
817
|
-
...e,
|
|
818
|
-
[t.id]: t.feature
|
|
819
|
-
};
|
|
820
|
-
} }), a = P();
|
|
821
|
-
I({
|
|
822
|
-
clock: a,
|
|
823
|
-
source: t,
|
|
824
|
-
filter: (e, { id: t }) => e[t] !== void 0,
|
|
825
|
-
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
826
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
827
|
-
clock: a,
|
|
828
|
-
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
829
|
-
id: e,
|
|
830
|
-
feature: {
|
|
831
|
-
id: e,
|
|
832
|
-
feature: {
|
|
833
|
-
...t,
|
|
834
|
-
id: e
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}),
|
|
838
|
-
target: i.register
|
|
839
|
-
});
|
|
840
|
-
let o = N(async ({ id: e, key: t, storage: n = "local", enabled: r }) => {
|
|
841
|
-
if (r === !1) return null;
|
|
842
|
-
let i = O(`feature:${e}:${t}`, "global"), a = (n === "session" ? D : E).get(i).text();
|
|
843
|
-
return a ? {
|
|
844
|
-
id: e,
|
|
845
|
-
key: t,
|
|
846
|
-
bucket: Ge(a),
|
|
847
|
-
storage: n
|
|
848
|
-
} : null;
|
|
849
|
-
}), s = N((e) => {
|
|
850
|
-
if (!e) return null;
|
|
851
|
-
let t = O(`feature:${e.id}:${e.key}`, "global");
|
|
852
|
-
(e.storage === "session" ? D : E).set(t, e.bucket);
|
|
853
|
-
}), c = /* @__PURE__ */ new Map(), l = k({
|
|
854
|
-
source: {
|
|
855
|
-
allFeaturesStore: t,
|
|
856
|
-
resolvedFeaturesStore: n
|
|
857
|
-
},
|
|
858
|
-
effect: async ({ allFeaturesStore: e, resolvedFeaturesStore: t }, { id: n, decide: r, key: i }) => {
|
|
859
|
-
let a = t.find((e) => e.id === n && e.key === i);
|
|
860
|
-
if (a) return a;
|
|
861
|
-
let o = e[n];
|
|
862
|
-
if (!o) throw Error(`Feature with id '${n}' not found`);
|
|
863
|
-
if (q(o.feature)) return {
|
|
864
|
-
id: o.id,
|
|
865
|
-
bucket: !1,
|
|
866
|
-
key: i,
|
|
867
|
-
storage: o.feature.storage
|
|
868
|
-
};
|
|
869
|
-
let s = c.get(`${n}:${i}`);
|
|
870
|
-
if (s !== void 0) {
|
|
871
|
-
let e = await s;
|
|
872
|
-
return {
|
|
873
|
-
id: o.id,
|
|
874
|
-
bucket: e,
|
|
875
|
-
key: i,
|
|
876
|
-
storage: o.feature.storage
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
let l = r();
|
|
880
|
-
c.set(`${n}:${i}`, l);
|
|
881
|
-
let u = await l;
|
|
882
|
-
return {
|
|
883
|
-
id: o.id,
|
|
884
|
-
bucket: u,
|
|
885
|
-
key: i,
|
|
886
|
-
storage: o.feature.storage
|
|
887
|
-
};
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
I({
|
|
891
|
-
clock: i.register,
|
|
892
|
-
fn: (e) => {
|
|
893
|
-
let { id: t, feature: n } = e;
|
|
894
|
-
return {
|
|
895
|
-
id: t,
|
|
896
|
-
key: n.feature.key,
|
|
897
|
-
storage: n.feature.storage,
|
|
898
|
-
enabled: n.feature.enabled
|
|
899
|
-
};
|
|
900
|
-
},
|
|
901
|
-
target: o
|
|
902
|
-
}), I({
|
|
903
|
-
source: t,
|
|
904
|
-
clock: l.doneData,
|
|
905
|
-
filter: (e, t) => !q(e[t.id]?.feature),
|
|
906
|
-
fn: (e, t) => {
|
|
907
|
-
let { id: n, bucket: r, storage: i } = t, a = e[n]?.feature.key;
|
|
908
|
-
return a ? {
|
|
909
|
-
key: a,
|
|
910
|
-
id: n,
|
|
911
|
-
bucket: r,
|
|
912
|
-
storage: i
|
|
913
|
-
} : null;
|
|
914
|
-
},
|
|
915
|
-
target: s
|
|
916
|
-
});
|
|
917
|
-
let u = A({
|
|
918
|
-
allFeaturesStore: t,
|
|
919
|
-
resolvedFeaturesStore: n
|
|
920
|
-
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
921
|
-
let n = t.find((t) => t.id === e.id && t.key === e.feature.key);
|
|
922
|
-
return n ? {
|
|
923
|
-
id: e.id,
|
|
924
|
-
name: e.feature.name,
|
|
925
|
-
key: e.feature.key,
|
|
926
|
-
enabled: e.feature.enabled,
|
|
927
|
-
weight: e.feature.weight,
|
|
928
|
-
getBucket: () => ({
|
|
929
|
-
id: e.id,
|
|
930
|
-
bucket: n.bucket
|
|
931
|
-
}),
|
|
932
|
-
isResolved: !0
|
|
933
|
-
} : {
|
|
934
|
-
id: e.id,
|
|
935
|
-
name: e.feature.name,
|
|
936
|
-
key: e.feature.key,
|
|
937
|
-
enabled: e.feature.enabled,
|
|
938
|
-
weight: e.feature.weight,
|
|
939
|
-
getBucket: async () => await l(e.feature),
|
|
940
|
-
isResolved: !1
|
|
941
|
-
};
|
|
942
|
-
}));
|
|
943
|
-
I({
|
|
944
|
-
clock: l.doneData,
|
|
945
|
-
source: {
|
|
946
|
-
resolvedFeatures: n,
|
|
947
|
-
allFeatures: t
|
|
948
|
-
},
|
|
949
|
-
filter: ({ resolvedFeatures: e, allFeatures: t }, { id: n, key: r }) => !q(t[n]?.feature) && !e.some((e) => e.id === n && e.key === r),
|
|
950
|
-
fn: (e, t) => t,
|
|
951
|
-
target: e.eventBus.prepend((e) => ({
|
|
952
|
-
type: "feature_decide",
|
|
953
|
-
feature: e
|
|
954
|
-
}))
|
|
955
|
-
}), I({
|
|
956
|
-
clock: [o.doneData, l.doneData],
|
|
957
|
-
source: {
|
|
958
|
-
resolvedFeatures: n,
|
|
959
|
-
allFeatures: t
|
|
960
|
-
},
|
|
961
|
-
fn: ({ resolvedFeatures: e, allFeatures: t }, n) => !n || q(t[n.id]?.feature) || e.some((e) => e.id === n.id && e.key === n.key) ? e : [...e, n],
|
|
962
|
-
target: n
|
|
963
|
-
});
|
|
964
|
-
function d(e) {
|
|
965
|
-
return u.map((t) => t.find((t) => t.id === e));
|
|
966
|
-
}
|
|
967
|
-
let f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
968
|
-
function h(e) {
|
|
969
|
-
let t = f.get(e);
|
|
970
|
-
if (t) return t;
|
|
971
|
-
let n = d(e);
|
|
972
|
-
return f.set(e, n), n;
|
|
973
|
-
}
|
|
974
|
-
function g(e) {
|
|
975
|
-
return t.map((t) => t[e], { skipVoid: !1 });
|
|
976
|
-
}
|
|
977
|
-
function _(e) {
|
|
978
|
-
let t = F(async () => void 0, { skipVoid: !1 }), n = h(e), r = k({
|
|
979
|
-
source: n,
|
|
980
|
-
effect: async (e) => {
|
|
981
|
-
if (e) return async () => (await e.getBucket()).bucket;
|
|
982
|
-
}
|
|
983
|
-
});
|
|
984
|
-
return I({
|
|
985
|
-
clock: n,
|
|
986
|
-
target: r
|
|
987
|
-
}), I({
|
|
988
|
-
clock: r.doneData,
|
|
989
|
-
filter: (e) => e !== void 0,
|
|
990
|
-
target: t
|
|
991
|
-
}), r(), t;
|
|
992
|
-
}
|
|
993
|
-
function v(e) {
|
|
994
|
-
let t = p.get(e);
|
|
995
|
-
if (t) return t;
|
|
996
|
-
let n = _(e);
|
|
997
|
-
return p.set(e, n), n;
|
|
998
|
-
}
|
|
999
|
-
function ee(e) {
|
|
1000
|
-
let t = v(e), n = F(void 0, { skipVoid: !1 }), r = k({
|
|
1001
|
-
source: t,
|
|
1002
|
-
mapParams: (e, t) => t,
|
|
1003
|
-
effect: N(async (e) => await e())
|
|
1004
|
-
});
|
|
1005
|
-
return I({
|
|
1006
|
-
clock: r.doneData,
|
|
1007
|
-
fn: (t) => {
|
|
1008
|
-
if (t !== void 0) return {
|
|
1009
|
-
id: e,
|
|
1010
|
-
bucket: t
|
|
1011
|
-
};
|
|
1012
|
-
},
|
|
1013
|
-
target: n
|
|
1014
|
-
}), I({
|
|
1015
|
-
clock: t,
|
|
1016
|
-
target: r
|
|
1017
|
-
}), r(), n;
|
|
1018
|
-
}
|
|
1019
|
-
function y(e) {
|
|
1020
|
-
let t = m.get(e);
|
|
1021
|
-
if (t) return t;
|
|
1022
|
-
let n = ee(e);
|
|
1023
|
-
return m.set(e, n), n;
|
|
1024
|
-
}
|
|
1025
|
-
return {
|
|
1026
|
-
register: a,
|
|
1027
|
-
getById: h,
|
|
1028
|
-
getByName: g,
|
|
1029
|
-
listStore: u,
|
|
1030
|
-
getEvokableFeature: v,
|
|
1031
|
-
getFeatureResult: y
|
|
1032
|
-
};
|
|
1033
|
-
});
|
|
1034
|
-
function qe(e) {
|
|
1035
|
-
return R(Ke, e);
|
|
1036
|
-
}
|
|
1037
|
-
var Je = (e, t, n) => {
|
|
1038
|
-
n.register({
|
|
1039
|
-
id: e,
|
|
1040
|
-
feature: t
|
|
1041
|
-
});
|
|
1042
|
-
}, J = M("history");
|
|
1043
|
-
function Ye(e, t) {
|
|
807
|
+
}, q = M("history");
|
|
808
|
+
function qe(e, t) {
|
|
1044
809
|
return {
|
|
1045
|
-
id:
|
|
810
|
+
id: ae(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
1046
811
|
node: t,
|
|
1047
812
|
at: Date.now(),
|
|
1048
813
|
experienceId: e
|
|
1049
814
|
};
|
|
1050
815
|
}
|
|
1051
|
-
var
|
|
1052
|
-
let e =
|
|
1053
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
816
|
+
var Je = L(() => {
|
|
817
|
+
let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
|
|
818
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, qe(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), qe(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
1054
819
|
function a(e, t) {
|
|
1055
820
|
let n = {
|
|
1056
821
|
lastStepIndex: -1,
|
|
@@ -1080,20 +845,20 @@ var Xe = L(() => {
|
|
|
1080
845
|
entriesStore: e.map((e) => e.entries)
|
|
1081
846
|
};
|
|
1082
847
|
});
|
|
1083
|
-
function
|
|
1084
|
-
return R(
|
|
848
|
+
function Ye() {
|
|
849
|
+
return R(Je);
|
|
1085
850
|
}
|
|
1086
851
|
//#endregion
|
|
1087
852
|
//#region src/utils/events.ts
|
|
1088
|
-
var
|
|
853
|
+
var Xe = 0, Ze = (e) => {
|
|
1089
854
|
let t = F([]);
|
|
1090
855
|
return t.on(e, (e, t) => [...e, {
|
|
1091
|
-
id:
|
|
856
|
+
id: Xe++,
|
|
1092
857
|
at: /* @__PURE__ */ new Date(),
|
|
1093
858
|
payload: t
|
|
1094
859
|
}]), t;
|
|
1095
|
-
},
|
|
1096
|
-
let e =
|
|
860
|
+
}, Qe = M("field"), $e = L(() => {
|
|
861
|
+
let e = Qe.store({}), t = j(e, {
|
|
1097
862
|
register(e, t) {
|
|
1098
863
|
return {
|
|
1099
864
|
...e,
|
|
@@ -1141,13 +906,13 @@ var Qe = 0, $e = (e) => {
|
|
|
1141
906
|
getByName: c
|
|
1142
907
|
};
|
|
1143
908
|
});
|
|
1144
|
-
function
|
|
1145
|
-
return R(
|
|
909
|
+
function et() {
|
|
910
|
+
return R($e);
|
|
1146
911
|
}
|
|
1147
912
|
//#endregion
|
|
1148
913
|
//#region src/entities/step/step.ts
|
|
1149
|
-
var
|
|
1150
|
-
let e =
|
|
914
|
+
var tt = M("step"), nt = L(() => {
|
|
915
|
+
let e = tt.store({}), t = j(e, { register(e, t) {
|
|
1151
916
|
return {
|
|
1152
917
|
...e,
|
|
1153
918
|
[t.step.id]: t.step
|
|
@@ -1171,16 +936,16 @@ var rt = M("step"), it = L(() => {
|
|
|
1171
936
|
indexStore: e
|
|
1172
937
|
};
|
|
1173
938
|
});
|
|
1174
|
-
function
|
|
1175
|
-
return R(
|
|
939
|
+
function rt() {
|
|
940
|
+
return R(nt);
|
|
1176
941
|
}
|
|
1177
|
-
function
|
|
942
|
+
function it(e, t) {
|
|
1178
943
|
t.register(e);
|
|
1179
944
|
}
|
|
1180
945
|
//#endregion
|
|
1181
946
|
//#region src/entities/content/content.ts
|
|
1182
|
-
var
|
|
1183
|
-
let e =
|
|
947
|
+
var at = M("content"), ot = L(() => {
|
|
948
|
+
let e = at.store({}), t = j(e, {
|
|
1184
949
|
register(e, t) {
|
|
1185
950
|
return {
|
|
1186
951
|
...e,
|
|
@@ -1221,16 +986,16 @@ var st = M("content"), ct = L(() => {
|
|
|
1221
986
|
indexStore: e
|
|
1222
987
|
};
|
|
1223
988
|
});
|
|
1224
|
-
function
|
|
1225
|
-
return R(
|
|
989
|
+
function st() {
|
|
990
|
+
return R(ot);
|
|
1226
991
|
}
|
|
1227
|
-
function
|
|
992
|
+
function ct(e, t) {
|
|
1228
993
|
t.register(e);
|
|
1229
994
|
}
|
|
1230
995
|
//#endregion
|
|
1231
996
|
//#region src/entities/action/action.ts
|
|
1232
|
-
var
|
|
1233
|
-
let t =
|
|
997
|
+
var lt = M("action"), ut = L(({ client: e }) => {
|
|
998
|
+
let t = lt.store({}), n = j(t, { register(e, t) {
|
|
1234
999
|
return {
|
|
1235
1000
|
...e,
|
|
1236
1001
|
[t.key]: {
|
|
@@ -1288,10 +1053,10 @@ var dt = M("action"), ft = L(({ client: e }) => {
|
|
|
1288
1053
|
getEvokableAction: s
|
|
1289
1054
|
};
|
|
1290
1055
|
});
|
|
1291
|
-
function
|
|
1292
|
-
return R(
|
|
1056
|
+
function dt(e) {
|
|
1057
|
+
return R(ut, e);
|
|
1293
1058
|
}
|
|
1294
|
-
var
|
|
1059
|
+
var ft = (e, t, n) => {
|
|
1295
1060
|
n.register({
|
|
1296
1061
|
key: e,
|
|
1297
1062
|
action: t
|
|
@@ -1299,7 +1064,7 @@ var mt = (e, t, n) => {
|
|
|
1299
1064
|
};
|
|
1300
1065
|
//#endregion
|
|
1301
1066
|
//#region src/entities/response/response-validation.ts
|
|
1302
|
-
function
|
|
1067
|
+
function J(e, t, n, r) {
|
|
1303
1068
|
return {
|
|
1304
1069
|
fieldKey: e.key,
|
|
1305
1070
|
userMessage: n,
|
|
@@ -1307,62 +1072,62 @@ function Y(e, t, n, r) {
|
|
|
1307
1072
|
value: t
|
|
1308
1073
|
};
|
|
1309
1074
|
}
|
|
1310
|
-
function
|
|
1075
|
+
function Y(e) {
|
|
1311
1076
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1312
1077
|
}
|
|
1313
|
-
function
|
|
1078
|
+
function pt(e) {
|
|
1314
1079
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1315
1080
|
}
|
|
1316
|
-
function
|
|
1081
|
+
function mt(e) {
|
|
1317
1082
|
try {
|
|
1318
1083
|
return JSON.stringify(e), !0;
|
|
1319
1084
|
} catch {
|
|
1320
1085
|
return !1;
|
|
1321
1086
|
}
|
|
1322
1087
|
}
|
|
1323
|
-
function
|
|
1088
|
+
function ht(e, t) {
|
|
1324
1089
|
return t.find((t) => t.key === e) ?? null;
|
|
1325
1090
|
}
|
|
1326
|
-
function
|
|
1091
|
+
function gt(e, t) {
|
|
1327
1092
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1328
1093
|
}
|
|
1329
|
-
function
|
|
1330
|
-
if (e.type !== "object" ||
|
|
1094
|
+
function _t(e, t) {
|
|
1095
|
+
if (e.type !== "object" || Y(t)) return null;
|
|
1331
1096
|
if (e.multiple) {
|
|
1332
|
-
if (!Array.isArray(t)) return
|
|
1097
|
+
if (!Array.isArray(t)) return J(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1333
1098
|
for (let n of t) {
|
|
1334
|
-
if (typeof n != "object" || !n) return
|
|
1335
|
-
if (!
|
|
1099
|
+
if (typeof n != "object" || !n) return J(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1100
|
+
if (!mt(n)) return J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1336
1101
|
}
|
|
1337
1102
|
return null;
|
|
1338
1103
|
}
|
|
1339
|
-
return Array.isArray(t) ?
|
|
1104
|
+
return Array.isArray(t) ? J(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? J(e, t, "This field expects an object value", "Field expects an object value.") : mt(t) ? null : J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1340
1105
|
}
|
|
1341
|
-
function
|
|
1342
|
-
if (
|
|
1106
|
+
function vt(e, t) {
|
|
1107
|
+
if (Y(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1343
1108
|
let n = Array.isArray(t) ? t : [t];
|
|
1344
1109
|
if (e.type === "object") {
|
|
1345
1110
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1346
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1111
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : J(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1347
1112
|
}
|
|
1348
1113
|
let r = e.options.map((e) => e.value);
|
|
1349
|
-
return n.every((e) => !
|
|
1114
|
+
return n.every((e) => !pt(e) || e === null ? !1 : r.includes(e)) ? null : J(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1350
1115
|
}
|
|
1351
|
-
async function
|
|
1352
|
-
if (n.validation && !e(n.validation) && !
|
|
1116
|
+
async function yt(t, n, r, i) {
|
|
1117
|
+
if (n.validation && !e(n.validation) && !Y(r)) {
|
|
1353
1118
|
let e = i ? {
|
|
1354
1119
|
$input: r,
|
|
1355
1120
|
responses: i
|
|
1356
1121
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1357
|
-
if (typeof a == "string") return
|
|
1358
|
-
if (a === !1) return
|
|
1122
|
+
if (typeof a == "string") return J(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1123
|
+
if (a === !1) return J(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1359
1124
|
}
|
|
1360
|
-
return n.required &&
|
|
1125
|
+
return n.required && Y(r) ? J(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? J(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1361
1126
|
}
|
|
1362
1127
|
//#endregion
|
|
1363
1128
|
//#region src/entities/response/response.ts
|
|
1364
|
-
var
|
|
1365
|
-
let t =
|
|
1129
|
+
var bt = M("response"), xt = L(({ client: e }) => {
|
|
1130
|
+
let t = bt.store({}), r = P(), i = P(), a = j(t, {
|
|
1366
1131
|
register(e, t) {
|
|
1367
1132
|
return {
|
|
1368
1133
|
...e,
|
|
@@ -1401,7 +1166,7 @@ var St = M("response"), Ct = L(({ client: e }) => {
|
|
|
1401
1166
|
...t,
|
|
1402
1167
|
...n
|
|
1403
1168
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1404
|
-
let o =
|
|
1169
|
+
let o = ht(t, e);
|
|
1405
1170
|
if (!o) {
|
|
1406
1171
|
r.push({
|
|
1407
1172
|
fieldKey: t,
|
|
@@ -1411,17 +1176,17 @@ var St = M("response"), Ct = L(({ client: e }) => {
|
|
|
1411
1176
|
});
|
|
1412
1177
|
return;
|
|
1413
1178
|
}
|
|
1414
|
-
let c =
|
|
1179
|
+
let c = gt(o, n), l = await yt(s, o, c, a);
|
|
1415
1180
|
if (l) {
|
|
1416
1181
|
r.push(l);
|
|
1417
1182
|
return;
|
|
1418
1183
|
}
|
|
1419
|
-
let u =
|
|
1184
|
+
let u = _t(o, c);
|
|
1420
1185
|
if (u) {
|
|
1421
1186
|
r.push(u);
|
|
1422
1187
|
return;
|
|
1423
1188
|
}
|
|
1424
|
-
let d =
|
|
1189
|
+
let d = vt(o, c);
|
|
1425
1190
|
if (d) {
|
|
1426
1191
|
r.push(d);
|
|
1427
1192
|
return;
|
|
@@ -1500,13 +1265,13 @@ var St = M("response"), Ct = L(({ client: e }) => {
|
|
|
1500
1265
|
getByFieldName: _
|
|
1501
1266
|
};
|
|
1502
1267
|
});
|
|
1503
|
-
function
|
|
1504
|
-
return R(
|
|
1268
|
+
function St(e) {
|
|
1269
|
+
return R(xt, e);
|
|
1505
1270
|
}
|
|
1506
1271
|
//#endregion
|
|
1507
1272
|
//#region src/entities/condition/condition.ts
|
|
1508
|
-
var
|
|
1509
|
-
let e =
|
|
1273
|
+
var Ct = M("condition"), wt = L(() => {
|
|
1274
|
+
let e = Ct.store({}), t = j(e, { register(e, t) {
|
|
1510
1275
|
return {
|
|
1511
1276
|
...e,
|
|
1512
1277
|
[t.condition.id]: t.condition
|
|
@@ -1530,12 +1295,12 @@ var Tt = M("condition"), Et = L(() => {
|
|
|
1530
1295
|
indexStore: e
|
|
1531
1296
|
};
|
|
1532
1297
|
});
|
|
1533
|
-
function
|
|
1534
|
-
return R(
|
|
1298
|
+
function Tt() {
|
|
1299
|
+
return R(wt);
|
|
1535
1300
|
}
|
|
1536
1301
|
//#endregion
|
|
1537
1302
|
//#region src/utils/api-url.ts
|
|
1538
|
-
function
|
|
1303
|
+
function Et() {
|
|
1539
1304
|
if (c()) {
|
|
1540
1305
|
let e = [
|
|
1541
1306
|
document.currentScript,
|
|
@@ -1550,7 +1315,7 @@ function Ot() {
|
|
|
1550
1315
|
}
|
|
1551
1316
|
//#endregion
|
|
1552
1317
|
//#region src/utils/search-params.ts
|
|
1553
|
-
function
|
|
1318
|
+
function Dt() {
|
|
1554
1319
|
if (!s()) return {};
|
|
1555
1320
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1556
1321
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1568,13 +1333,13 @@ function kt() {
|
|
|
1568
1333
|
}
|
|
1569
1334
|
//#endregion
|
|
1570
1335
|
//#region src/entities/session/session.ts
|
|
1571
|
-
var
|
|
1572
|
-
function
|
|
1336
|
+
var Ot = O("session", "global");
|
|
1337
|
+
function kt() {
|
|
1573
1338
|
return p() ? 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)}`;
|
|
1574
1339
|
}
|
|
1575
|
-
function
|
|
1340
|
+
function At() {
|
|
1576
1341
|
if (!m()) return null;
|
|
1577
|
-
let e = E.get(
|
|
1342
|
+
let e = E.get(Ot);
|
|
1578
1343
|
if (!e.isSet()) return null;
|
|
1579
1344
|
try {
|
|
1580
1345
|
return e.json();
|
|
@@ -1582,8 +1347,8 @@ function Mt() {
|
|
|
1582
1347
|
return null;
|
|
1583
1348
|
}
|
|
1584
1349
|
}
|
|
1585
|
-
var
|
|
1586
|
-
let e =
|
|
1350
|
+
var jt = L(() => {
|
|
1351
|
+
let e = At(), t = { id: e?.id ?? kt() };
|
|
1587
1352
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1588
1353
|
let n = F(t), r = j(n, {
|
|
1589
1354
|
setIsUser: (e, t) => ({
|
|
@@ -1609,7 +1374,7 @@ var Nt = L(() => {
|
|
|
1609
1374
|
source: n,
|
|
1610
1375
|
effect: (e) => {
|
|
1611
1376
|
if (m()) try {
|
|
1612
|
-
E.get(
|
|
1377
|
+
E.get(Ot).set(e);
|
|
1613
1378
|
} catch {}
|
|
1614
1379
|
}
|
|
1615
1380
|
});
|
|
@@ -1623,39 +1388,39 @@ var Nt = L(() => {
|
|
|
1623
1388
|
removeIdentifier: r.removeIdentifier
|
|
1624
1389
|
};
|
|
1625
1390
|
});
|
|
1626
|
-
function
|
|
1627
|
-
return R(
|
|
1391
|
+
function Mt() {
|
|
1392
|
+
return R(jt, void 0);
|
|
1628
1393
|
}
|
|
1629
1394
|
//#endregion
|
|
1630
1395
|
//#region src/utils/picked-config.ts
|
|
1631
|
-
function
|
|
1396
|
+
function Nt() {
|
|
1632
1397
|
if (s()) return globalThis.window.pickedConfig;
|
|
1633
1398
|
}
|
|
1634
|
-
function
|
|
1635
|
-
if (s()) return
|
|
1399
|
+
function Pt() {
|
|
1400
|
+
if (s()) return Nt()?.projectId;
|
|
1636
1401
|
}
|
|
1637
|
-
function
|
|
1402
|
+
function Ft() {
|
|
1638
1403
|
if (!c()) return;
|
|
1639
1404
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1640
1405
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1641
1406
|
}
|
|
1642
|
-
function
|
|
1407
|
+
function It(e) {
|
|
1643
1408
|
if (e.projectId) return e.projectId;
|
|
1644
|
-
let t =
|
|
1409
|
+
let t = Pt();
|
|
1645
1410
|
if (t) return t;
|
|
1646
|
-
let n =
|
|
1411
|
+
let n = Ft();
|
|
1647
1412
|
if (n) return n;
|
|
1648
1413
|
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.");
|
|
1649
1414
|
}
|
|
1650
1415
|
//#endregion
|
|
1651
1416
|
//#region src/utils/render-string.ts
|
|
1652
|
-
function
|
|
1417
|
+
function X(e) {
|
|
1653
1418
|
return e == null || e === "" || Number.isNaN(e);
|
|
1654
1419
|
}
|
|
1655
|
-
var
|
|
1656
|
-
default: (e, t) =>
|
|
1657
|
-
append: (e, t) => t && !
|
|
1658
|
-
prepend: (e, t) => t && !
|
|
1420
|
+
var Lt = {
|
|
1421
|
+
default: (e, t) => X(e) ? String(t ?? "") : String(e),
|
|
1422
|
+
append: (e, t) => t && !X(e) ? `${e} ${t}` : e,
|
|
1423
|
+
prepend: (e, t) => t && !X(e) ? `${t} ${e}` : e,
|
|
1659
1424
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1660
1425
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1661
1426
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1673,24 +1438,24 @@ var zt = {
|
|
|
1673
1438
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1674
1439
|
}
|
|
1675
1440
|
};
|
|
1676
|
-
function
|
|
1441
|
+
function Rt(e) {
|
|
1677
1442
|
return typeof e == "object" && !!e;
|
|
1678
1443
|
}
|
|
1679
|
-
function
|
|
1444
|
+
function zt(e, t) {
|
|
1680
1445
|
let n = t;
|
|
1681
|
-
for (let t of e.split(".")) if (
|
|
1446
|
+
for (let t of e.split(".")) if (Rt(n) && t in n) n = n[t];
|
|
1682
1447
|
else return;
|
|
1683
1448
|
return typeof n == "function" ? n() : n;
|
|
1684
1449
|
}
|
|
1685
|
-
function
|
|
1686
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1450
|
+
function Bt(e, t) {
|
|
1451
|
+
let n = e.split("|").map((e) => e.trim()), r = zt(n.shift() ?? "", t);
|
|
1687
1452
|
for (let e of n) {
|
|
1688
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1453
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Lt[i];
|
|
1689
1454
|
o && (r = o(r, a));
|
|
1690
1455
|
}
|
|
1691
|
-
return
|
|
1456
|
+
return X(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1692
1457
|
}
|
|
1693
|
-
function
|
|
1458
|
+
function Vt(e, t) {
|
|
1694
1459
|
let n = "", r = 0;
|
|
1695
1460
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1696
1461
|
r += 2;
|
|
@@ -1702,19 +1467,19 @@ function Ut(e, t) {
|
|
|
1702
1467
|
}
|
|
1703
1468
|
i += e[r++];
|
|
1704
1469
|
}
|
|
1705
|
-
n +=
|
|
1470
|
+
n += Bt(i.trim(), t);
|
|
1706
1471
|
} else n += e[r++];
|
|
1707
1472
|
return n;
|
|
1708
1473
|
}
|
|
1709
1474
|
//#endregion
|
|
1710
1475
|
//#region src/utils/preview-session.ts
|
|
1711
|
-
var
|
|
1712
|
-
function
|
|
1713
|
-
return !s() || !h() ? !1 : !!
|
|
1476
|
+
var Ht = "preview-token";
|
|
1477
|
+
function Ut() {
|
|
1478
|
+
return !s() || !h() ? !1 : !!Dt()[Ht]?.[0];
|
|
1714
1479
|
}
|
|
1715
1480
|
//#endregion
|
|
1716
1481
|
//#region src/picked.ts
|
|
1717
|
-
var
|
|
1482
|
+
var Wt = class {
|
|
1718
1483
|
static logger = r;
|
|
1719
1484
|
options;
|
|
1720
1485
|
dataSource = null;
|
|
@@ -1730,51 +1495,51 @@ var Kt = class {
|
|
|
1730
1495
|
apiUrl;
|
|
1731
1496
|
dashboardUrl;
|
|
1732
1497
|
documentationSiteUrl;
|
|
1733
|
-
session =
|
|
1734
|
-
searchParams =
|
|
1735
|
-
history =
|
|
1736
|
-
components =
|
|
1498
|
+
session = Mt();
|
|
1499
|
+
searchParams = Dt();
|
|
1500
|
+
history = Ye();
|
|
1501
|
+
components = Se({ client: this });
|
|
1737
1502
|
experienceInstances = S({ client: this });
|
|
1738
|
-
experiences =
|
|
1739
|
-
frameworks =
|
|
1740
|
-
predicates =
|
|
1741
|
-
features =
|
|
1742
|
-
conditions =
|
|
1743
|
-
fields =
|
|
1744
|
-
responses =
|
|
1745
|
-
steps =
|
|
1746
|
-
contents =
|
|
1747
|
-
actions =
|
|
1503
|
+
experiences = me({ client: this });
|
|
1504
|
+
frameworks = Ee({ client: this });
|
|
1505
|
+
predicates = Ge({ client: this });
|
|
1506
|
+
features = ne({ client: this });
|
|
1507
|
+
conditions = Tt();
|
|
1508
|
+
fields = et();
|
|
1509
|
+
responses = St({ client: this });
|
|
1510
|
+
steps = rt();
|
|
1511
|
+
contents = st();
|
|
1512
|
+
actions = dt({ client: this });
|
|
1748
1513
|
conditionResults = C();
|
|
1749
|
-
stateSnapshotStore =
|
|
1750
|
-
evaluateRuleLogicFx =
|
|
1514
|
+
stateSnapshotStore = ke({ client: this });
|
|
1515
|
+
evaluateRuleLogicFx = Le({ client: this });
|
|
1751
1516
|
start;
|
|
1752
1517
|
readyStore;
|
|
1753
1518
|
preconditionPassedStore;
|
|
1754
1519
|
conditionPassedStore;
|
|
1755
1520
|
lifecycleStageStore;
|
|
1756
|
-
lifecycle =
|
|
1521
|
+
lifecycle = He({ client: this });
|
|
1757
1522
|
renderStringFx = k({
|
|
1758
1523
|
source: this.responses.listStore,
|
|
1759
1524
|
effect: (e, { template: t, context: n }) => {
|
|
1760
1525
|
let r = {};
|
|
1761
1526
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1762
|
-
return
|
|
1527
|
+
return Vt(t, {
|
|
1763
1528
|
...n,
|
|
1764
1529
|
responses: r
|
|
1765
1530
|
});
|
|
1766
1531
|
}
|
|
1767
1532
|
});
|
|
1768
1533
|
constructor(e) {
|
|
1769
|
-
this.events =
|
|
1534
|
+
this.events = Ze(this.eventBus), this.projectId = It(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Et(), 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({
|
|
1770
1535
|
type: "load",
|
|
1771
|
-
version:
|
|
1536
|
+
version: ie()
|
|
1772
1537
|
}), this.maybeStartPreviewChannel();
|
|
1773
1538
|
}
|
|
1774
1539
|
dataProviderFor(e) {
|
|
1775
1540
|
let t = e ?? "", n = this.dataProviders.get(t);
|
|
1776
1541
|
if (n) return n;
|
|
1777
|
-
let r = import("../provider-
|
|
1542
|
+
let r = import("../provider-So2by8pt.js").then((t) => t.createPickedDataProvider({
|
|
1778
1543
|
apiUrl: this.apiUrl,
|
|
1779
1544
|
projectId: this.projectId,
|
|
1780
1545
|
...e !== void 0 && { previewToken: e }
|
|
@@ -1790,24 +1555,24 @@ var Kt = class {
|
|
|
1790
1555
|
return (await this.dataProviderFor(t?.previewToken)).getContent(e, t?.signal === void 0 ? void 0 : { signal: t.signal });
|
|
1791
1556
|
}
|
|
1792
1557
|
maybeStartPreviewChannel() {
|
|
1793
|
-
|
|
1558
|
+
Ut() && import("../preview-channel-CSr96XAo.js").then((e) => e.initPreviewChannel(this)).catch(() => void 0);
|
|
1794
1559
|
}
|
|
1795
1560
|
registerFramework = (e) => {
|
|
1796
|
-
|
|
1561
|
+
De(e, this.frameworks);
|
|
1797
1562
|
};
|
|
1798
1563
|
registerComponent = (e, t) => {
|
|
1799
|
-
|
|
1564
|
+
Ce(e, t, this.components);
|
|
1800
1565
|
};
|
|
1801
1566
|
registerPlugin = (e) => {
|
|
1802
|
-
|
|
1567
|
+
_e(this, e, this.plugins);
|
|
1803
1568
|
let t = this.plugins[e.name];
|
|
1804
1569
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1805
1570
|
};
|
|
1806
1571
|
registerFeature = (e, t) => {
|
|
1807
|
-
|
|
1572
|
+
te(e, t, this.features);
|
|
1808
1573
|
};
|
|
1809
1574
|
registerPredicate = (e, t) => {
|
|
1810
|
-
|
|
1575
|
+
Ke(e, t, this.predicates);
|
|
1811
1576
|
};
|
|
1812
1577
|
registerCondition = (e) => {
|
|
1813
1578
|
this.conditions.register(e);
|
|
@@ -1816,19 +1581,19 @@ var Kt = class {
|
|
|
1816
1581
|
this.fields.register(e);
|
|
1817
1582
|
};
|
|
1818
1583
|
registerStep = (e) => {
|
|
1819
|
-
|
|
1584
|
+
it(e, this.steps);
|
|
1820
1585
|
};
|
|
1821
1586
|
registerContent = (e) => {
|
|
1822
|
-
|
|
1587
|
+
ct(e, this.contents);
|
|
1823
1588
|
};
|
|
1824
1589
|
patchContent = (e, t) => {
|
|
1825
1590
|
this.contents.patch(e, t);
|
|
1826
1591
|
};
|
|
1827
1592
|
registerAction = (e, t) => {
|
|
1828
|
-
|
|
1593
|
+
ft(e, t, this.actions);
|
|
1829
1594
|
};
|
|
1830
1595
|
registerExperience = (e) => {
|
|
1831
|
-
e.component &&
|
|
1596
|
+
e.component && Ce(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1832
1597
|
};
|
|
1833
1598
|
launchExperienceById = async (e, t) => {
|
|
1834
1599
|
this.experiences.launch({
|
|
@@ -1871,12 +1636,12 @@ var Kt = class {
|
|
|
1871
1636
|
this.registerFeature(e, n);
|
|
1872
1637
|
}), this.searchParams.feature && this.searchParams.feature.forEach((e) => {
|
|
1873
1638
|
try {
|
|
1874
|
-
let
|
|
1875
|
-
if (!t
|
|
1876
|
-
let r =
|
|
1877
|
-
this.registerFeature(
|
|
1639
|
+
let t = re(e);
|
|
1640
|
+
if (!t) return;
|
|
1641
|
+
let { id: n, bucket: r } = t;
|
|
1642
|
+
this.registerFeature(n, {
|
|
1878
1643
|
key: `${r}`,
|
|
1879
|
-
name:
|
|
1644
|
+
name: n,
|
|
1880
1645
|
decide: () => r,
|
|
1881
1646
|
storage: "session"
|
|
1882
1647
|
});
|
|
@@ -1910,8 +1675,8 @@ var Kt = class {
|
|
|
1910
1675
|
});
|
|
1911
1676
|
}
|
|
1912
1677
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1913
|
-
},
|
|
1914
|
-
async function
|
|
1678
|
+
}, Gt = "application/picked-javascript", Kt = "application/picked-module", qt = "data-picked-hydrated";
|
|
1679
|
+
async function Jt(e) {
|
|
1915
1680
|
if (!("document" in globalThis)) return;
|
|
1916
1681
|
let t = "application/picked-module", n = "data-picked-hydrated";
|
|
1917
1682
|
function r(e) {
|
|
@@ -1940,42 +1705,42 @@ async function Xt(e) {
|
|
|
1940
1705
|
a && await a;
|
|
1941
1706
|
}
|
|
1942
1707
|
}
|
|
1943
|
-
function
|
|
1944
|
-
return `<script>(${
|
|
1708
|
+
function Yt() {
|
|
1709
|
+
return `<script>(${Jt.toString()})(document)<\/script>`;
|
|
1945
1710
|
}
|
|
1946
1711
|
//#endregion
|
|
1947
1712
|
//#region src/utils/html-asset-value.ts
|
|
1948
|
-
function
|
|
1713
|
+
function Xt(e) {
|
|
1949
1714
|
return typeof e == "object" && !!e && "id" in e && typeof e.id == "string" && "content" in e && (typeof e.content == "string" || e.content === null);
|
|
1950
1715
|
}
|
|
1951
1716
|
//#endregion
|
|
1952
1717
|
//#region src/entities/component/lazyComponent.ts
|
|
1953
|
-
function
|
|
1718
|
+
function Zt(e) {
|
|
1954
1719
|
return {
|
|
1955
1720
|
$$type: "lazy-component",
|
|
1956
1721
|
load: e
|
|
1957
1722
|
};
|
|
1958
1723
|
}
|
|
1959
|
-
function
|
|
1724
|
+
function Qt(e) {
|
|
1960
1725
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1961
1726
|
}
|
|
1962
1727
|
//#endregion
|
|
1963
1728
|
//#region src/entities/content/reference.ts
|
|
1964
|
-
function
|
|
1729
|
+
function Z(e) {
|
|
1965
1730
|
return typeof e == "object" && !!e && !Array.isArray(e) && "contentEntryId" in e && typeof e.contentEntryId == "string";
|
|
1966
1731
|
}
|
|
1967
|
-
function
|
|
1968
|
-
return
|
|
1732
|
+
function Q(e) {
|
|
1733
|
+
return Z(e) ? e.contentEntryId : null;
|
|
1969
1734
|
}
|
|
1970
|
-
function
|
|
1735
|
+
function $(e) {
|
|
1971
1736
|
let t = Array.isArray(e) ? e : [e], n = [];
|
|
1972
|
-
for (let e of t)
|
|
1737
|
+
for (let e of t) Z(e) && n.push(e.contentEntryId);
|
|
1973
1738
|
return n;
|
|
1974
1739
|
}
|
|
1975
|
-
function
|
|
1740
|
+
function $t(e, t) {
|
|
1976
1741
|
return t === null ? null : e[t] ?? null;
|
|
1977
1742
|
}
|
|
1978
|
-
function
|
|
1743
|
+
function en(e, t) {
|
|
1979
1744
|
let n = [];
|
|
1980
1745
|
for (let r of t) {
|
|
1981
1746
|
let t = e[r];
|
|
@@ -1983,29 +1748,29 @@ function rn(e, t) {
|
|
|
1983
1748
|
}
|
|
1984
1749
|
return n;
|
|
1985
1750
|
}
|
|
1986
|
-
function
|
|
1987
|
-
if (
|
|
1988
|
-
let n =
|
|
1989
|
-
return e.indexStore.map((e) =>
|
|
1751
|
+
function tn(e, t) {
|
|
1752
|
+
if (le.store(t)) return A(t, e.indexStore, (e, t) => $t(t, Q(e)));
|
|
1753
|
+
let n = Q(t);
|
|
1754
|
+
return e.indexStore.map((e) => $t(e, n), { skipVoid: !1 });
|
|
1990
1755
|
}
|
|
1991
|
-
function
|
|
1992
|
-
if (
|
|
1993
|
-
let n =
|
|
1994
|
-
return e.indexStore.map((e) =>
|
|
1756
|
+
function nn(e, t) {
|
|
1757
|
+
if (le.store(t)) return A(t, e.indexStore, (e, t) => en(t, $(e)));
|
|
1758
|
+
let n = $(t);
|
|
1759
|
+
return e.indexStore.map((e) => en(e, n), { skipVoid: !1 });
|
|
1995
1760
|
}
|
|
1996
1761
|
//#endregion
|
|
1997
1762
|
//#region src/exports.ts
|
|
1998
|
-
var
|
|
1999
|
-
let t = new
|
|
1763
|
+
var rn = (e) => {
|
|
1764
|
+
let t = new Wt(e);
|
|
2000
1765
|
return u(t), t;
|
|
2001
1766
|
};
|
|
2002
1767
|
//#endregion
|
|
2003
1768
|
//#region src/typed-content.ts
|
|
2004
|
-
function
|
|
1769
|
+
function an(e) {
|
|
2005
1770
|
return typeof e.data == "object";
|
|
2006
1771
|
}
|
|
2007
|
-
function
|
|
2008
|
-
return e.map((e) => !e || !
|
|
1772
|
+
function on(e) {
|
|
1773
|
+
return e.map((e) => !e || !an(e) ? null : e, { skipVoid: !1 });
|
|
2009
1774
|
}
|
|
2010
1775
|
//#endregion
|
|
2011
|
-
export {
|
|
1776
|
+
export { qt as PICKED_HYDRATED_ATTR, Kt as PICKED_MODULE_SCRIPT_TYPE, Gt as PICKED_SCRIPT_TYPE, Ht as PREVIEW_TOKEN_PARAM, Wt as Picked, Yt as buildRehydrateBootstrap, rn as createClient, ge as createPluginEffect, O as createStorageKey, tn as deriveReference, nn as deriveReferences, n as evaluateRuleLogic, Nt as getPickedConfig, Z as isContentReference, Xt as isHtmlAssetValue, h as isInsideIframe, Qt as isLazyLoader, _ as isPickedRoot, Ut as isPreviewSession, Zt as lazyComponent, E as localStore, ce as onInertScriptSubtrees, Q as readReferenceId, $ as readReferenceIds, Jt as rehydrateScripts, oe as reportInertScriptSubtrees, se as resetInertScriptReport, D as sessionStore, T as subscribe, d as supportsCookies, p as supportsCryptoRandomUUID, c as supportsDocument, i as supportsHistory, f as supportsIntersectionObserver, m as supportsLocalStorage, a as supportsLocation, l as supportsSessionStorage, g as supportsShadowRoot, o as supportsWebComponents, s as supportsWindow, on as toTypedContentStore };
|