@picked/client 0.0.1-dev.1778561735098 → 0.0.1-dev.1778730134956
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-Bzb9pR2r.js → api-B-CbCRqb.js} +1 -1
- package/dist/{api-XV6bcv_D.cjs → api-CPRRXVw6.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dom-observer/index.js +1 -0
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/workspaces.mdx +1 -1
- package/dist/dom-C3C6Fmwz.cjs +1 -0
- package/dist/dom-DGePXPpM.js +84 -0
- package/dist/esm/index.js +323 -303
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dom-observer/index.js +87 -0
- package/dist/esm/plugins/dynamic-experiences/index.js +109 -38
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +14 -53
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BOhvCj_F.js +430 -0
- package/dist/experience-instance-D8yKenBU.cjs +1 -0
- package/dist/types/entities/content/content.d.ts +37 -0
- package/dist/types/entities/content/content.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +22 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +12 -0
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +19 -28
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +1 -0
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +17 -2
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
- package/dist/types/picked.d.ts +57 -8
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dom-observer/index.d.ts +3 -0
- package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +18 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +63 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -16
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -27
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/experience-instance-B16NqD7y.cjs +0 -1
- package/dist/experience-instance-CZC0uPuv.js +0 -513
- /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
- /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
- /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
- /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -2,34 +2,15 @@ import { t as e } from "../object-DvUDOytC.js";
|
|
|
2
2
|
import { n as t, t as n } from "../rules-logic-D_CVBuv7.js";
|
|
3
3
|
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
|
-
import { a as g,
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import {
|
|
5
|
+
import { a as g, i as _, r as v, s as y, t as b } from "../dom-DGePXPpM.js";
|
|
6
|
+
import { i as x, n as S, r as C } from "../experience-instance-BOhvCj_F.js";
|
|
7
|
+
import { i as w, n as T, r as E, t as D } from "../storage-hOHCCXvP.js";
|
|
8
|
+
import { n as O, r as ee } from "../api-B-CbCRqb.js";
|
|
9
|
+
import { t as te } from "../id-n2yrHvNo.js";
|
|
9
10
|
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, sample as I } from "effector";
|
|
10
11
|
import { createFactory as L, invoke as R } from "@withease/factories";
|
|
11
12
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var z = M("experience")
|
|
13
|
-
function ie(e, t) {
|
|
14
|
-
let n = /* @__PURE__ */ new Map();
|
|
15
|
-
for (let r of e) if (r.placement === "replace") for (let e of r.elements) {
|
|
16
|
-
let i = _(e, t);
|
|
17
|
-
if (i) {
|
|
18
|
-
n.set(r.selector, i);
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
for (let [e, r] of n) `${e}${r}${t}`;
|
|
23
|
-
}
|
|
24
|
-
function ae(e, t, n) {
|
|
25
|
-
let r = new Set(t.filter((e) => e.elements.length > 0).map((e) => e.selector));
|
|
26
|
-
for (let t of e) {
|
|
27
|
-
if (t.placement !== "replace" || r.has(t.selector)) continue;
|
|
28
|
-
let e = C(t.selector);
|
|
29
|
-
!e || e === n || `${t.selector}${e}${n}`;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
var oe = L(({ client: e, experience: r }) => {
|
|
13
|
+
var z = M("experience"), ne = L(({ client: e, experience: r }) => {
|
|
33
14
|
let i = z.store(r), a = j(i, { merge(e, t) {
|
|
34
15
|
return {
|
|
35
16
|
...e,
|
|
@@ -41,7 +22,7 @@ var oe = L(({ client: e, experience: r }) => {
|
|
|
41
22
|
targetSelectors: e.targets,
|
|
42
23
|
initializeOpenLogic: e.initializeOpen
|
|
43
24
|
})), s = A(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = A(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
44
|
-
let r = e.nodes.filter(
|
|
25
|
+
let r = e.nodes.filter(x).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(C).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
45
26
|
return {
|
|
46
27
|
steps: r,
|
|
47
28
|
nodes: e.nodes,
|
|
@@ -51,10 +32,10 @@ var oe = L(({ client: e, experience: r }) => {
|
|
|
51
32
|
}), l = r.actions ?? [], u, d = k({
|
|
52
33
|
source: o,
|
|
53
34
|
effect: (t, n) => {
|
|
54
|
-
let i =
|
|
55
|
-
i.forEach(({ elements: e }) => e.forEach((e) =>
|
|
35
|
+
let i = _(t.targetSelectors, r.id);
|
|
36
|
+
i.forEach(({ elements: e }) => e.forEach((e) => y(e, r.id))), b(i, r.id, r.key).forEach((t) => {
|
|
56
37
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
57
|
-
})
|
|
38
|
+
});
|
|
58
39
|
}
|
|
59
40
|
}), f = k({
|
|
60
41
|
source: A({
|
|
@@ -65,10 +46,42 @@ var oe = L(({ client: e, experience: r }) => {
|
|
|
65
46
|
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
66
47
|
if (!i || !a) return !1;
|
|
67
48
|
let { decisionLogic: s, targetSelectors: c } = o;
|
|
68
|
-
return c.length === 0 ||
|
|
49
|
+
return c.length === 0 || _(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
69
50
|
}
|
|
70
|
-
})
|
|
71
|
-
|
|
51
|
+
}), p = N(async () => {
|
|
52
|
+
if (!e.contentLoader) return !0;
|
|
53
|
+
try {
|
|
54
|
+
await e.contentLoader({
|
|
55
|
+
id: r.id,
|
|
56
|
+
key: r.key
|
|
57
|
+
});
|
|
58
|
+
} catch {
|
|
59
|
+
`${r.id}`;
|
|
60
|
+
}
|
|
61
|
+
return !0;
|
|
62
|
+
}), m = P(), h = P(), g = z.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
63
|
+
return I({
|
|
64
|
+
clock: m,
|
|
65
|
+
target: f
|
|
66
|
+
}), I({
|
|
67
|
+
clock: f.doneData,
|
|
68
|
+
source: g,
|
|
69
|
+
filter: (e, t) => t,
|
|
70
|
+
fn: (e) => e,
|
|
71
|
+
target: d
|
|
72
|
+
}), I({
|
|
73
|
+
clock: f.doneData,
|
|
74
|
+
filter: Boolean,
|
|
75
|
+
target: p
|
|
76
|
+
}), I({
|
|
77
|
+
clock: h,
|
|
78
|
+
source: g,
|
|
79
|
+
fn: (e) => e,
|
|
80
|
+
target: d
|
|
81
|
+
}), I({
|
|
82
|
+
clock: h,
|
|
83
|
+
target: p
|
|
84
|
+
}), u = {
|
|
72
85
|
id: r.id,
|
|
73
86
|
key: r.key,
|
|
74
87
|
name: r.name,
|
|
@@ -78,20 +91,23 @@ var oe = L(({ client: e, experience: r }) => {
|
|
|
78
91
|
actions: l,
|
|
79
92
|
merge: a.merge,
|
|
80
93
|
initialiseFx: d,
|
|
81
|
-
shouldInitialiseFx: f
|
|
94
|
+
shouldInitialiseFx: f,
|
|
95
|
+
initialiseRequested: m,
|
|
96
|
+
initialiseDirectly: h,
|
|
97
|
+
prepareExperienceContentFx: p
|
|
82
98
|
}, u;
|
|
83
99
|
});
|
|
84
|
-
function
|
|
85
|
-
return R(
|
|
100
|
+
function re(e) {
|
|
101
|
+
return R(ne, e);
|
|
86
102
|
}
|
|
87
|
-
var
|
|
103
|
+
var ie = L(({ client: e }) => {
|
|
88
104
|
let t = z.store({}), n = j(t, { register(e, t) {
|
|
89
105
|
return {
|
|
90
106
|
...e,
|
|
91
107
|
[t.id]: t
|
|
92
108
|
};
|
|
93
109
|
} }), r = P(), i = N((t) => {
|
|
94
|
-
n.register(
|
|
110
|
+
n.register(re({
|
|
95
111
|
client: e,
|
|
96
112
|
experience: t
|
|
97
113
|
}));
|
|
@@ -125,18 +141,14 @@ var ce = L(({ client: e }) => {
|
|
|
125
141
|
}
|
|
126
142
|
let c = k({
|
|
127
143
|
source: t,
|
|
128
|
-
effect:
|
|
144
|
+
effect: (e, t) => {
|
|
129
145
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
130
146
|
if (!n) {
|
|
131
147
|
"key" in t ? `${t.key}` : `${t.id}`;
|
|
132
148
|
return;
|
|
133
149
|
}
|
|
134
150
|
let { options: r } = t;
|
|
135
|
-
|
|
136
|
-
await n.initialiseFx(r);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
await n.shouldInitialiseFx() && await n.initialiseFx(r);
|
|
151
|
+
r?.bypassCondition ? n.initialiseDirectly(r) : n.initialiseRequested(r);
|
|
140
152
|
}
|
|
141
153
|
});
|
|
142
154
|
return {
|
|
@@ -151,7 +163,7 @@ var ce = L(({ client: e }) => {
|
|
|
151
163
|
instances: e.experienceInstances.listStore
|
|
152
164
|
},
|
|
153
165
|
effect: async ({ experiences: e, instances: t }, n) => {
|
|
154
|
-
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) =>
|
|
166
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => e.experienceId === r?.id);
|
|
155
167
|
if (i.length > 0) {
|
|
156
168
|
for (let e of i) e.open();
|
|
157
169
|
return;
|
|
@@ -174,30 +186,26 @@ var ce = L(({ client: e }) => {
|
|
|
174
186
|
listStore: a,
|
|
175
187
|
initialiseExperiencesFx: k({
|
|
176
188
|
source: a,
|
|
177
|
-
effect:
|
|
178
|
-
for (let t of e)
|
|
179
|
-
await t.shouldInitialiseFx() && await t.initialiseFx(void 0);
|
|
180
|
-
} catch {
|
|
181
|
-
`${t.id}`;
|
|
182
|
-
}
|
|
189
|
+
effect: (e) => {
|
|
190
|
+
for (let t of e) t.initialiseRequested(void 0);
|
|
183
191
|
}
|
|
184
192
|
})
|
|
185
193
|
};
|
|
186
194
|
});
|
|
187
|
-
function
|
|
188
|
-
return R(
|
|
195
|
+
function ae(e) {
|
|
196
|
+
return R(ie, e);
|
|
189
197
|
}
|
|
190
|
-
var
|
|
198
|
+
var oe = async (e) => {
|
|
191
199
|
await e.experiences.initialiseExperiencesFx();
|
|
192
200
|
};
|
|
193
201
|
//#endregion
|
|
194
202
|
//#region src/entities/plugin/plugin.ts
|
|
195
|
-
function
|
|
203
|
+
function se(e) {
|
|
196
204
|
return N(async () => {
|
|
197
205
|
await e();
|
|
198
206
|
});
|
|
199
207
|
}
|
|
200
|
-
var
|
|
208
|
+
var ce = (e, t, n) => {
|
|
201
209
|
let r = t.name, i = t.setup(e);
|
|
202
210
|
if (i) {
|
|
203
211
|
let e = n[r] ?? {};
|
|
@@ -206,16 +214,16 @@ var fe = (e, t, n) => {
|
|
|
206
214
|
...i
|
|
207
215
|
});
|
|
208
216
|
}
|
|
209
|
-
},
|
|
217
|
+
}, le = M("component"), ue = L(({ client: e, component: t, name: n }) => ({
|
|
210
218
|
name: n,
|
|
211
219
|
component: t,
|
|
212
220
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
213
221
|
}));
|
|
214
|
-
function
|
|
215
|
-
return R(
|
|
222
|
+
function de(e) {
|
|
223
|
+
return R(ue, e);
|
|
216
224
|
}
|
|
217
|
-
var
|
|
218
|
-
let t =
|
|
225
|
+
var fe = L(({ client: e }) => {
|
|
226
|
+
let t = le.store({}), n = j(t, { register(e, t) {
|
|
219
227
|
return {
|
|
220
228
|
...e,
|
|
221
229
|
[t.name]: t
|
|
@@ -228,7 +236,7 @@ var ge = L(({ client: e }) => {
|
|
|
228
236
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
229
237
|
}).watch((e) => /* @__PURE__ */ r("warn", e)), I({
|
|
230
238
|
clock: i,
|
|
231
|
-
fn: ({ name: t, component: n }) =>
|
|
239
|
+
fn: ({ name: t, component: n }) => de({
|
|
232
240
|
client: e,
|
|
233
241
|
name: t,
|
|
234
242
|
component: n
|
|
@@ -245,16 +253,16 @@ var ge = L(({ client: e }) => {
|
|
|
245
253
|
listStore: a
|
|
246
254
|
};
|
|
247
255
|
});
|
|
248
|
-
function
|
|
249
|
-
return R(
|
|
256
|
+
function pe(e) {
|
|
257
|
+
return R(fe, e);
|
|
250
258
|
}
|
|
251
259
|
var B = (e, t, n) => {
|
|
252
260
|
n.register({
|
|
253
261
|
name: e,
|
|
254
262
|
component: t
|
|
255
263
|
});
|
|
256
|
-
},
|
|
257
|
-
let t =
|
|
264
|
+
}, me = M("framework"), he = L((e) => {
|
|
265
|
+
let t = me.store({}), n = j(t, { register(e, t) {
|
|
258
266
|
return {
|
|
259
267
|
...e,
|
|
260
268
|
[t.name]: t.framework
|
|
@@ -279,20 +287,20 @@ var B = (e, t, n) => {
|
|
|
279
287
|
listStore: a
|
|
280
288
|
};
|
|
281
289
|
});
|
|
282
|
-
function
|
|
283
|
-
return R(
|
|
290
|
+
function ge(e) {
|
|
291
|
+
return R(he, e);
|
|
284
292
|
}
|
|
285
|
-
var
|
|
293
|
+
var _e = (e, t) => {
|
|
286
294
|
t.register({
|
|
287
295
|
name: e.name,
|
|
288
296
|
framework: e
|
|
289
297
|
});
|
|
290
|
-
},
|
|
291
|
-
let t =
|
|
292
|
-
location: t ?
|
|
293
|
-
document: t ?
|
|
294
|
-
sessionStorage: t ?
|
|
295
|
-
localStorage: t ?
|
|
298
|
+
}, ve = L(({ client: e }) => {
|
|
299
|
+
let t = "window" in globalThis, n = {
|
|
300
|
+
location: t ? globalThis.location : void 0,
|
|
301
|
+
document: t ? globalThis.document : void 0,
|
|
302
|
+
sessionStorage: t ? globalThis.sessionStorage : void 0,
|
|
303
|
+
localStorage: t ? globalThis.localStorage : void 0
|
|
296
304
|
};
|
|
297
305
|
return A(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
298
306
|
client: e,
|
|
@@ -301,12 +309,12 @@ var xe = (e, t) => {
|
|
|
301
309
|
...n
|
|
302
310
|
}));
|
|
303
311
|
});
|
|
304
|
-
function
|
|
305
|
-
return R(
|
|
312
|
+
function ye(e) {
|
|
313
|
+
return R(ve, e);
|
|
306
314
|
}
|
|
307
315
|
//#endregion
|
|
308
316
|
//#region src/logic-engine.ts
|
|
309
|
-
function
|
|
317
|
+
function be(e) {
|
|
310
318
|
return typeof e == "number" && !isNaN(e);
|
|
311
319
|
}
|
|
312
320
|
function V(e) {
|
|
@@ -322,14 +330,14 @@ function W(e) {
|
|
|
322
330
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
323
331
|
}
|
|
324
332
|
function G(e) {
|
|
325
|
-
if (
|
|
333
|
+
if (be(e)) return e;
|
|
326
334
|
let t = parseFloat(`${e}`);
|
|
327
335
|
return isNaN(t) ? 0 : t;
|
|
328
336
|
}
|
|
329
337
|
function K(e) {
|
|
330
338
|
return `${e}`;
|
|
331
339
|
}
|
|
332
|
-
var
|
|
340
|
+
var xe = {
|
|
333
341
|
"==": (e, t) => e == t,
|
|
334
342
|
"===": (e, t) => e === t,
|
|
335
343
|
"!=": (e, t) => e != t,
|
|
@@ -427,7 +435,7 @@ async function q(e, t) {
|
|
|
427
435
|
if (U(e)) return q(await e, t);
|
|
428
436
|
if (H(e)) return Promise.all(e.map((e) => q(e, t)));
|
|
429
437
|
if (!W(e)) return e;
|
|
430
|
-
let n =
|
|
438
|
+
let n = Se(e), r = n ? e[n] ?? [] : [];
|
|
431
439
|
switch (H(r) || (r = [r]), n) {
|
|
432
440
|
case "if":
|
|
433
441
|
case "?:":
|
|
@@ -488,19 +496,19 @@ async function q(e, t) {
|
|
|
488
496
|
return W(e) ? await q(e, t) : r[1] ? await q(r[1], e) : e instanceof Error ? e.message : e;
|
|
489
497
|
}
|
|
490
498
|
}
|
|
491
|
-
let i = await Promise.all(r.map((e) => q(e, t))), a = n ?
|
|
499
|
+
let i = await Promise.all(r.map((e) => q(e, t))), a = n ? xe[n] : void 0;
|
|
492
500
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
493
501
|
return a.apply(t, i);
|
|
494
502
|
}
|
|
495
503
|
async function J(e) {
|
|
496
504
|
return U(e) ? J(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
497
505
|
}
|
|
498
|
-
function
|
|
506
|
+
function Se(e) {
|
|
499
507
|
return Object.keys(e)[0];
|
|
500
508
|
}
|
|
501
509
|
//#endregion
|
|
502
510
|
//#region src/lifecycle/rules-logic.ts
|
|
503
|
-
var
|
|
511
|
+
var Ce = L(({ client: e }) => k({
|
|
504
512
|
source: {
|
|
505
513
|
stateSnapshot: e.stateSnapshotStore,
|
|
506
514
|
predicates: e.predicates.listStore,
|
|
@@ -539,26 +547,26 @@ var De = L(({ client: e }) => k({
|
|
|
539
547
|
});
|
|
540
548
|
}
|
|
541
549
|
}));
|
|
542
|
-
function
|
|
543
|
-
return R(
|
|
550
|
+
function we(e) {
|
|
551
|
+
return R(Ce, e);
|
|
544
552
|
}
|
|
545
553
|
//#endregion
|
|
546
554
|
//#region src/ping.ts
|
|
547
|
-
var
|
|
555
|
+
var Te = 6e3, Ee = D("last_ping", "global"), De = async (e) => {
|
|
548
556
|
try {
|
|
549
|
-
let t = Date.now(), n =
|
|
550
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
557
|
+
let t = Date.now(), n = T.get(Ee), r = 0;
|
|
558
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Te) return !0;
|
|
551
559
|
let i = {
|
|
552
560
|
projectId: e.projectId,
|
|
553
561
|
path: window.location.pathname
|
|
554
562
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
555
563
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
556
|
-
let s = (await
|
|
564
|
+
let s = (await O(e.apiUrl, "ping", i, a)).ok;
|
|
557
565
|
return s && n.set(t), s;
|
|
558
566
|
} catch {
|
|
559
567
|
return !1;
|
|
560
568
|
}
|
|
561
|
-
}, Y = M("lifecycle"),
|
|
569
|
+
}, Y = M("lifecycle"), Oe = L(({ client: e }) => {
|
|
562
570
|
let t = Y.store(!1), r = F(void 0, {
|
|
563
571
|
skipVoid: !1,
|
|
564
572
|
domain: Y
|
|
@@ -574,69 +582,69 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
574
582
|
}), l = P(), u = P(), d = P(), p = P(), m = P(), h = P();
|
|
575
583
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
576
584
|
let g = N(() => {
|
|
577
|
-
|
|
585
|
+
De(e);
|
|
578
586
|
}), _ = N(async () => {
|
|
579
|
-
await
|
|
580
|
-
}),
|
|
581
|
-
await
|
|
582
|
-
}),
|
|
587
|
+
await v();
|
|
588
|
+
}), y = N(async () => {
|
|
589
|
+
await oe(e);
|
|
590
|
+
}), b = k({ effect: y }), x = k({
|
|
583
591
|
source: o,
|
|
584
592
|
effect: async (e) => {
|
|
585
593
|
for (let t of e) await t();
|
|
586
594
|
}
|
|
587
|
-
}),
|
|
595
|
+
}), S = k({
|
|
588
596
|
source: s,
|
|
589
597
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
590
|
-
}),
|
|
598
|
+
}), C = k({
|
|
591
599
|
source: c,
|
|
592
600
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
593
|
-
}),
|
|
601
|
+
}), w = I({
|
|
594
602
|
clock: l,
|
|
595
603
|
filter: () => f()
|
|
596
604
|
});
|
|
597
605
|
I({
|
|
598
|
-
clock:
|
|
606
|
+
clock: w,
|
|
599
607
|
fn: () => "starting",
|
|
600
608
|
target: a
|
|
601
609
|
}), I({
|
|
602
|
-
clock:
|
|
610
|
+
clock: w,
|
|
603
611
|
target: g
|
|
604
612
|
}), I({
|
|
605
|
-
clock:
|
|
606
|
-
target:
|
|
613
|
+
clock: w,
|
|
614
|
+
target: x
|
|
607
615
|
}), I({
|
|
608
|
-
clock:
|
|
616
|
+
clock: w,
|
|
609
617
|
target: _
|
|
610
618
|
}), I({
|
|
611
|
-
clock:
|
|
612
|
-
target:
|
|
619
|
+
clock: x.done,
|
|
620
|
+
target: S
|
|
613
621
|
}), I({
|
|
614
|
-
clock:
|
|
622
|
+
clock: S.doneData,
|
|
615
623
|
target: r
|
|
616
624
|
}), I({
|
|
617
|
-
clock:
|
|
625
|
+
clock: C.doneData,
|
|
618
626
|
target: i
|
|
619
627
|
}), I({
|
|
620
|
-
clock:
|
|
628
|
+
clock: S.doneData,
|
|
621
629
|
filter: (e) => e,
|
|
622
|
-
target:
|
|
630
|
+
target: C
|
|
623
631
|
}), I({
|
|
624
|
-
clock:
|
|
632
|
+
clock: C.doneData,
|
|
625
633
|
target: e.session.setIsUser
|
|
626
634
|
}), I({
|
|
627
|
-
clock:
|
|
635
|
+
clock: C.doneData,
|
|
628
636
|
fn: (e) => ({
|
|
629
637
|
type: "user_decide",
|
|
630
638
|
value: e
|
|
631
639
|
}),
|
|
632
640
|
target: e.eventBus
|
|
633
641
|
}), I({
|
|
634
|
-
clock:
|
|
642
|
+
clock: S.doneData,
|
|
635
643
|
filter: (e) => !e,
|
|
636
644
|
fn: () => void 0,
|
|
637
645
|
target: d
|
|
638
646
|
}), I({
|
|
639
|
-
clock:
|
|
647
|
+
clock: C.doneData,
|
|
640
648
|
fn: () => void 0,
|
|
641
649
|
target: d
|
|
642
650
|
}), I({
|
|
@@ -644,20 +652,20 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
644
652
|
fn: () => ({ type: "initialize" }),
|
|
645
653
|
target: e.eventBus
|
|
646
654
|
});
|
|
647
|
-
let
|
|
655
|
+
let T = F(!1).on(_.done, () => !0), E = F(!1).on(d, () => !0), D = F(!1).on(b.done, () => !0), O = A(r, i, (e, t) => e === !0 && t === !0);
|
|
648
656
|
return I({
|
|
649
657
|
clock: d,
|
|
650
|
-
source:
|
|
658
|
+
source: O,
|
|
651
659
|
filter: (e) => e,
|
|
652
660
|
fn: () => void 0,
|
|
653
|
-
target:
|
|
661
|
+
target: y
|
|
654
662
|
}), I({
|
|
655
|
-
clock: A(
|
|
663
|
+
clock: A(T, E, O, (e, t, n) => e && t && n),
|
|
656
664
|
filter: (e) => e,
|
|
657
665
|
fn: () => void 0,
|
|
658
|
-
target:
|
|
666
|
+
target: b
|
|
659
667
|
}), I({
|
|
660
|
-
clock: A(
|
|
668
|
+
clock: A(T, E, O, D, (e, t, n, r) => e && t && (!n || r)),
|
|
661
669
|
filter: (e) => e,
|
|
662
670
|
fn: () => void 0,
|
|
663
671
|
target: u
|
|
@@ -681,11 +689,11 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
681
689
|
target: e.eventBus
|
|
682
690
|
}), I({
|
|
683
691
|
clock: [
|
|
684
|
-
b.fail,
|
|
685
692
|
x.fail,
|
|
686
693
|
S.fail,
|
|
687
|
-
|
|
694
|
+
C.fail,
|
|
688
695
|
y.fail,
|
|
696
|
+
b.fail,
|
|
689
697
|
_.fail
|
|
690
698
|
],
|
|
691
699
|
fn: () => "failed",
|
|
@@ -701,13 +709,13 @@ var ke = 6e3, Ae = O("last_ping", "global"), je = async (e) => {
|
|
|
701
709
|
setCondition: h
|
|
702
710
|
};
|
|
703
711
|
});
|
|
704
|
-
function
|
|
705
|
-
return R(
|
|
712
|
+
function ke(e) {
|
|
713
|
+
return R(Oe, e);
|
|
706
714
|
}
|
|
707
715
|
//#endregion
|
|
708
716
|
//#region src/entities/predicate/predicate.ts
|
|
709
|
-
var
|
|
710
|
-
let t =
|
|
717
|
+
var Ae = M("predicate"), je = L(({ client: e }) => {
|
|
718
|
+
let t = Ae.store({}), n = j(t, { register(e, t) {
|
|
711
719
|
return {
|
|
712
720
|
...e,
|
|
713
721
|
[t.name]: {
|
|
@@ -765,16 +773,16 @@ var Pe = M("predicate"), Fe = L(({ client: e }) => {
|
|
|
765
773
|
getEvokablePredicate: s
|
|
766
774
|
};
|
|
767
775
|
});
|
|
768
|
-
function
|
|
769
|
-
return R(
|
|
776
|
+
function Me(e) {
|
|
777
|
+
return R(je, e);
|
|
770
778
|
}
|
|
771
|
-
var
|
|
779
|
+
var Ne = (e, t, n) => {
|
|
772
780
|
n.register({
|
|
773
781
|
name: e,
|
|
774
782
|
predicate: t
|
|
775
783
|
});
|
|
776
|
-
},
|
|
777
|
-
let t =
|
|
784
|
+
}, Pe = M("feature"), Fe = L(({ client: e }) => {
|
|
785
|
+
let t = Pe.store({}), n = Pe.store([]), i = j(t, { register(e, t) {
|
|
778
786
|
return {
|
|
779
787
|
...e,
|
|
780
788
|
[t.id]: t.feature
|
|
@@ -800,7 +808,7 @@ var Le = (e, t, n) => {
|
|
|
800
808
|
target: i.register
|
|
801
809
|
});
|
|
802
810
|
let o = N(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
803
|
-
let r =
|
|
811
|
+
let r = D(`feature:${e}:${t}`, "global"), i = (n === "session" ? E : T).get(r).boolean();
|
|
804
812
|
return i === null ? null : {
|
|
805
813
|
id: e,
|
|
806
814
|
key: t,
|
|
@@ -809,8 +817,8 @@ var Le = (e, t, n) => {
|
|
|
809
817
|
};
|
|
810
818
|
}), s = N((e) => {
|
|
811
819
|
if (!e) return null;
|
|
812
|
-
let t =
|
|
813
|
-
(e.storage === "session" ?
|
|
820
|
+
let t = D(`feature:${e.id}:${e.key}`, "global");
|
|
821
|
+
(e.storage === "session" ? E : T).set(t, e.bucket);
|
|
814
822
|
}), c = /* @__PURE__ */ new Map(), l = k({
|
|
815
823
|
source: {
|
|
816
824
|
allFeaturesStore: t,
|
|
@@ -935,107 +943,70 @@ var Le = (e, t, n) => {
|
|
|
935
943
|
getEvokableFeature: p
|
|
936
944
|
};
|
|
937
945
|
});
|
|
938
|
-
function
|
|
939
|
-
return R(
|
|
946
|
+
function Ie(e) {
|
|
947
|
+
return R(Fe, e);
|
|
940
948
|
}
|
|
941
|
-
var
|
|
949
|
+
var Le = (e, t, n) => {
|
|
942
950
|
n.register({
|
|
943
951
|
id: e,
|
|
944
952
|
feature: t
|
|
945
953
|
});
|
|
946
954
|
}, X = M("history");
|
|
947
|
-
function
|
|
955
|
+
function Re(e, t) {
|
|
948
956
|
return {
|
|
949
|
-
id:
|
|
950
|
-
node:
|
|
957
|
+
id: te(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
958
|
+
node: t,
|
|
951
959
|
at: Date.now(),
|
|
952
|
-
|
|
953
|
-
experienceId: t
|
|
960
|
+
experienceId: e
|
|
954
961
|
};
|
|
955
962
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
|
-
return r === -1 ? [...e, n] : [
|
|
972
|
-
...e.slice(0, r),
|
|
973
|
-
n,
|
|
974
|
-
...e.slice(r + 1)
|
|
975
|
-
];
|
|
976
|
-
}), e.on(r, (e, { instanceId: t }) => {
|
|
977
|
-
let n = 0, r = -1;
|
|
978
|
-
for (let i = e.length - 1; i >= 0; i--) {
|
|
979
|
-
let a = e[i];
|
|
980
|
-
if (!(a?.instanceId !== t || !y(a.node)) && (n += 1, n === 2)) {
|
|
981
|
-
r = i;
|
|
963
|
+
var ze = L(() => {
|
|
964
|
+
let e = X.store({ entries: [] }), t = X.event(), n = X.event(), r = X.event(), i = X.event(), a = X.event();
|
|
965
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, Re(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Re(t.experienceId, t.node)] })), e.on(i, (e, t) => t), e.on(a, (e, { experienceId: t }) => ({ entries: e.entries.filter((e) => e.experienceId !== t) }));
|
|
966
|
+
function o(e, t) {
|
|
967
|
+
let n = {
|
|
968
|
+
lastStepIndex: -1,
|
|
969
|
+
secondLastStepIndex: -1
|
|
970
|
+
};
|
|
971
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
972
|
+
let i = e[r], a = i?.node;
|
|
973
|
+
if (!(!a || !x(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
974
|
+
else {
|
|
975
|
+
n.secondLastStepIndex = r;
|
|
982
976
|
break;
|
|
983
977
|
}
|
|
984
978
|
}
|
|
985
|
-
return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
|
|
986
|
-
}), e.on(i, (e, { snapshots: t }) => {
|
|
987
|
-
let n = new Set(e.map((e) => e.experienceId)), r = [];
|
|
988
|
-
for (let e of Object.keys(t)) {
|
|
989
|
-
if (n.has(e)) continue;
|
|
990
|
-
let i = t[e];
|
|
991
|
-
i && r.push(...i);
|
|
992
|
-
}
|
|
993
|
-
return r.length === 0 ? e : [...e, ...r];
|
|
994
|
-
}), e.on(o, (e, t) => [...e, ...t]);
|
|
995
|
-
let s = e.map((e) => {
|
|
996
|
-
let t = /* @__PURE__ */ new Map();
|
|
997
|
-
for (let n of e) t.set(n.experienceId, n.instanceId);
|
|
998
|
-
let n = {};
|
|
999
|
-
for (let r of e) {
|
|
1000
|
-
if (t.get(r.experienceId) !== r.instanceId) continue;
|
|
1001
|
-
let e = n[r.experienceId] ?? [];
|
|
1002
|
-
e.push(r), n[r.experienceId] = e;
|
|
1003
|
-
}
|
|
1004
979
|
return n;
|
|
1005
|
-
}
|
|
1006
|
-
return
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
fn: (e, { instanceId: t, experienceId: n }) => Ue(e[n] ?? []).map((e) => ({
|
|
980
|
+
}
|
|
981
|
+
return e.on(r, (e, t) => {
|
|
982
|
+
let { secondLastStepIndex: n } = o(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
|
|
983
|
+
return {
|
|
1010
984
|
...e,
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
})),
|
|
1014
|
-
target: o
|
|
985
|
+
entries: r
|
|
986
|
+
};
|
|
1015
987
|
}), {
|
|
1016
988
|
push: t,
|
|
1017
989
|
replace: n,
|
|
1018
990
|
back: r,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
entriesStore: e
|
|
1022
|
-
snapshotStore: s
|
|
991
|
+
restore: i,
|
|
992
|
+
resetExperience: a,
|
|
993
|
+
entriesStore: e.map((e) => e.entries)
|
|
1023
994
|
};
|
|
1024
995
|
});
|
|
1025
|
-
function
|
|
1026
|
-
return R(
|
|
996
|
+
function Be() {
|
|
997
|
+
return R(ze);
|
|
1027
998
|
}
|
|
1028
999
|
//#endregion
|
|
1029
1000
|
//#region src/utils/events.ts
|
|
1030
|
-
var
|
|
1001
|
+
var Ve = 0, He = (e) => {
|
|
1031
1002
|
let t = F([]);
|
|
1032
1003
|
return t.on(e, (e, t) => [...e, {
|
|
1033
|
-
id:
|
|
1004
|
+
id: Ve++,
|
|
1034
1005
|
at: /* @__PURE__ */ new Date(),
|
|
1035
1006
|
payload: t
|
|
1036
1007
|
}]), t;
|
|
1037
|
-
},
|
|
1038
|
-
let e =
|
|
1008
|
+
}, Ue = M("field"), We = L(() => {
|
|
1009
|
+
let e = Ue.store({}), t = j(e, {
|
|
1039
1010
|
register(e, t) {
|
|
1040
1011
|
return {
|
|
1041
1012
|
...e,
|
|
@@ -1083,13 +1054,13 @@ var Ke = 0, qe = (e) => {
|
|
|
1083
1054
|
getByName: c
|
|
1084
1055
|
};
|
|
1085
1056
|
});
|
|
1086
|
-
function
|
|
1087
|
-
return R(
|
|
1057
|
+
function Ge() {
|
|
1058
|
+
return R(We);
|
|
1088
1059
|
}
|
|
1089
1060
|
//#endregion
|
|
1090
1061
|
//#region src/entities/step/step.ts
|
|
1091
|
-
var
|
|
1092
|
-
let e =
|
|
1062
|
+
var Ke = M("step"), qe = L(() => {
|
|
1063
|
+
let e = Ke.store({}), t = j(e, { register(e, t) {
|
|
1093
1064
|
return {
|
|
1094
1065
|
...e,
|
|
1095
1066
|
[t.step.id]: t.step
|
|
@@ -1113,16 +1084,45 @@ var Ze = M("step"), Qe = L(() => {
|
|
|
1113
1084
|
indexStore: e
|
|
1114
1085
|
};
|
|
1115
1086
|
});
|
|
1116
|
-
function
|
|
1117
|
-
return R(
|
|
1087
|
+
function Je() {
|
|
1088
|
+
return R(qe);
|
|
1118
1089
|
}
|
|
1119
|
-
function
|
|
1090
|
+
function Ye(e, t) {
|
|
1091
|
+
t.register(e);
|
|
1092
|
+
}
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region src/entities/content/content.ts
|
|
1095
|
+
var Xe = M("content"), Ze = L(() => {
|
|
1096
|
+
let e = Xe.store({}), t = j(e, { register(e, t) {
|
|
1097
|
+
return {
|
|
1098
|
+
...e,
|
|
1099
|
+
[t.content.id]: t.content
|
|
1100
|
+
};
|
|
1101
|
+
} });
|
|
1102
|
+
function n(e) {
|
|
1103
|
+
t.register({ content: e });
|
|
1104
|
+
}
|
|
1105
|
+
let r = e.map((e) => Object.values(e));
|
|
1106
|
+
function i(t) {
|
|
1107
|
+
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1108
|
+
}
|
|
1109
|
+
return {
|
|
1110
|
+
register: n,
|
|
1111
|
+
getById: i,
|
|
1112
|
+
listStore: r,
|
|
1113
|
+
indexStore: e
|
|
1114
|
+
};
|
|
1115
|
+
});
|
|
1116
|
+
function Qe() {
|
|
1117
|
+
return R(Ze);
|
|
1118
|
+
}
|
|
1119
|
+
function $e(e, t) {
|
|
1120
1120
|
t.register(e);
|
|
1121
1121
|
}
|
|
1122
1122
|
//#endregion
|
|
1123
1123
|
//#region src/entities/action/action.ts
|
|
1124
|
-
var
|
|
1125
|
-
let t =
|
|
1124
|
+
var et = M("action"), tt = L(({ client: e }) => {
|
|
1125
|
+
let t = et.store({}), n = j(t, { register(e, t) {
|
|
1126
1126
|
return {
|
|
1127
1127
|
...e,
|
|
1128
1128
|
[t.key]: {
|
|
@@ -1180,10 +1180,10 @@ var tt = M("action"), nt = L(({ client: e }) => {
|
|
|
1180
1180
|
getEvokableAction: s
|
|
1181
1181
|
};
|
|
1182
1182
|
});
|
|
1183
|
-
function
|
|
1184
|
-
return R(
|
|
1183
|
+
function nt(e) {
|
|
1184
|
+
return R(tt, e);
|
|
1185
1185
|
}
|
|
1186
|
-
var
|
|
1186
|
+
var rt = (e, t, n) => {
|
|
1187
1187
|
n.register({
|
|
1188
1188
|
key: e,
|
|
1189
1189
|
action: t
|
|
@@ -1202,35 +1202,35 @@ function Z(e, t, n, r) {
|
|
|
1202
1202
|
function Q(e) {
|
|
1203
1203
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1204
1204
|
}
|
|
1205
|
-
function
|
|
1205
|
+
function it(e) {
|
|
1206
1206
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1207
1207
|
}
|
|
1208
|
-
function
|
|
1208
|
+
function at(e) {
|
|
1209
1209
|
try {
|
|
1210
1210
|
return JSON.stringify(e), !0;
|
|
1211
1211
|
} catch {
|
|
1212
1212
|
return !1;
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
|
-
function
|
|
1215
|
+
function ot(e, t) {
|
|
1216
1216
|
return t.find((t) => t.key === e) ?? null;
|
|
1217
1217
|
}
|
|
1218
|
-
function
|
|
1218
|
+
function st(e, t) {
|
|
1219
1219
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1220
1220
|
}
|
|
1221
|
-
function
|
|
1221
|
+
function ct(e, t) {
|
|
1222
1222
|
if (e.type !== "object" || Q(t)) return null;
|
|
1223
1223
|
if (e.multiple) {
|
|
1224
1224
|
if (!Array.isArray(t)) return Z(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1225
1225
|
for (let n of t) {
|
|
1226
1226
|
if (typeof n != "object" || !n) return Z(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1227
|
-
if (!
|
|
1227
|
+
if (!at(n)) return Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1228
1228
|
}
|
|
1229
1229
|
return null;
|
|
1230
1230
|
}
|
|
1231
|
-
return Array.isArray(t) ? Z(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Z(e, t, "This field expects an object value", "Field expects an object value.") :
|
|
1231
|
+
return Array.isArray(t) ? Z(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Z(e, t, "This field expects an object value", "Field expects an object value.") : at(t) ? null : Z(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1232
1232
|
}
|
|
1233
|
-
function
|
|
1233
|
+
function lt(e, t) {
|
|
1234
1234
|
if (Q(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1235
1235
|
let n = Array.isArray(t) ? t : [t];
|
|
1236
1236
|
if (e.type === "object") {
|
|
@@ -1238,9 +1238,9 @@ function ut(e, t) {
|
|
|
1238
1238
|
return n.every((e) => r.has(JSON.stringify(e))) ? null : Z(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1239
1239
|
}
|
|
1240
1240
|
let r = e.options.map((e) => e.value);
|
|
1241
|
-
return n.every((e) => !
|
|
1241
|
+
return n.every((e) => !it(e) || e === null ? !1 : r.includes(e)) ? null : Z(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1242
1242
|
}
|
|
1243
|
-
async function
|
|
1243
|
+
async function ut(t, n, r, i) {
|
|
1244
1244
|
if (n.validation && !e(n.validation) && !Q(r)) {
|
|
1245
1245
|
let e = i ? {
|
|
1246
1246
|
$input: r,
|
|
@@ -1253,8 +1253,8 @@ async function dt(t, n, r, i) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
//#endregion
|
|
1255
1255
|
//#region src/entities/response/response.ts
|
|
1256
|
-
var
|
|
1257
|
-
let t =
|
|
1256
|
+
var dt = M("response"), ft = L(({ client: e }) => {
|
|
1257
|
+
let t = dt.store({}), r = P(), i = P(), a = j(t, {
|
|
1258
1258
|
register(e, t) {
|
|
1259
1259
|
return {
|
|
1260
1260
|
...e,
|
|
@@ -1293,7 +1293,7 @@ var ft = M("response"), pt = L(({ client: e }) => {
|
|
|
1293
1293
|
...t,
|
|
1294
1294
|
...n
|
|
1295
1295
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1296
|
-
let o =
|
|
1296
|
+
let o = ot(t, e);
|
|
1297
1297
|
if (!o) {
|
|
1298
1298
|
r.push({
|
|
1299
1299
|
fieldKey: t,
|
|
@@ -1303,17 +1303,17 @@ var ft = M("response"), pt = L(({ client: e }) => {
|
|
|
1303
1303
|
});
|
|
1304
1304
|
return;
|
|
1305
1305
|
}
|
|
1306
|
-
let c =
|
|
1306
|
+
let c = st(o, n), l = await ut(s, o, c, a);
|
|
1307
1307
|
if (l) {
|
|
1308
1308
|
r.push(l);
|
|
1309
1309
|
return;
|
|
1310
1310
|
}
|
|
1311
|
-
let u =
|
|
1311
|
+
let u = ct(o, c);
|
|
1312
1312
|
if (u) {
|
|
1313
1313
|
r.push(u);
|
|
1314
1314
|
return;
|
|
1315
1315
|
}
|
|
1316
|
-
let d =
|
|
1316
|
+
let d = lt(o, c);
|
|
1317
1317
|
if (d) {
|
|
1318
1318
|
r.push(d);
|
|
1319
1319
|
return;
|
|
@@ -1373,16 +1373,30 @@ var ft = M("response"), pt = L(({ client: e }) => {
|
|
|
1373
1373
|
function _(t) {
|
|
1374
1374
|
return m(e.fields.getByName(t));
|
|
1375
1375
|
}
|
|
1376
|
-
|
|
1376
|
+
I({
|
|
1377
1377
|
clock: r,
|
|
1378
1378
|
target: a.clearAll
|
|
1379
1379
|
}), I({
|
|
1380
1380
|
clock: i,
|
|
1381
1381
|
target: a.clear
|
|
1382
|
-
})
|
|
1382
|
+
});
|
|
1383
|
+
let v = k({
|
|
1384
|
+
source: e.experiences.listStore,
|
|
1385
|
+
effect: (e, t) => {
|
|
1386
|
+
let n = e.find((e) => e.id === t);
|
|
1387
|
+
if (!n) return;
|
|
1388
|
+
let { steps: r } = n.treeStore.getState(), a = r.flatMap((e) => e.fieldKeys);
|
|
1389
|
+
for (let e of a) i(e);
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
function y(e) {
|
|
1393
|
+
v(e);
|
|
1394
|
+
}
|
|
1395
|
+
return {
|
|
1383
1396
|
register: o,
|
|
1384
1397
|
clearAll: r,
|
|
1385
1398
|
clear: i,
|
|
1399
|
+
clearByExperience: y,
|
|
1386
1400
|
commit: d,
|
|
1387
1401
|
getResponsesToCommit: l,
|
|
1388
1402
|
listStore: p,
|
|
@@ -1392,13 +1406,13 @@ var ft = M("response"), pt = L(({ client: e }) => {
|
|
|
1392
1406
|
getByFieldName: _
|
|
1393
1407
|
};
|
|
1394
1408
|
});
|
|
1395
|
-
function
|
|
1396
|
-
return R(
|
|
1409
|
+
function pt(e) {
|
|
1410
|
+
return R(ft, e);
|
|
1397
1411
|
}
|
|
1398
1412
|
//#endregion
|
|
1399
1413
|
//#region src/entities/condition/condition.ts
|
|
1400
|
-
var
|
|
1401
|
-
let e =
|
|
1414
|
+
var mt = M("condition"), ht = L(() => {
|
|
1415
|
+
let e = mt.store({}), t = j(e, { register(e, t) {
|
|
1402
1416
|
return {
|
|
1403
1417
|
...e,
|
|
1404
1418
|
[t.condition.id]: t.condition
|
|
@@ -1422,12 +1436,12 @@ var ht = M("condition"), gt = L(() => {
|
|
|
1422
1436
|
indexStore: e
|
|
1423
1437
|
};
|
|
1424
1438
|
});
|
|
1425
|
-
function
|
|
1426
|
-
return R(
|
|
1439
|
+
function gt() {
|
|
1440
|
+
return R(ht);
|
|
1427
1441
|
}
|
|
1428
1442
|
//#endregion
|
|
1429
1443
|
//#region src/utils/api-url.ts
|
|
1430
|
-
function
|
|
1444
|
+
function _t() {
|
|
1431
1445
|
if (f()) {
|
|
1432
1446
|
let e = [
|
|
1433
1447
|
document.currentScript,
|
|
@@ -1442,7 +1456,7 @@ function vt() {
|
|
|
1442
1456
|
}
|
|
1443
1457
|
//#endregion
|
|
1444
1458
|
//#region src/utils/search-params.ts
|
|
1445
|
-
function
|
|
1459
|
+
function vt() {
|
|
1446
1460
|
if (!o()) return {};
|
|
1447
1461
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1448
1462
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1450,23 +1464,23 @@ function yt() {
|
|
|
1450
1464
|
let n = r.replace("picked-", "");
|
|
1451
1465
|
t[n] = e.getAll(r);
|
|
1452
1466
|
}
|
|
1453
|
-
let r =
|
|
1454
|
-
if (n.size > 0)
|
|
1467
|
+
let r = D("s");
|
|
1468
|
+
if (n.size > 0) E.set(r, t);
|
|
1455
1469
|
else {
|
|
1456
|
-
let e =
|
|
1470
|
+
let e = E.get(r);
|
|
1457
1471
|
if (e) return e.json() || {};
|
|
1458
1472
|
}
|
|
1459
1473
|
return t;
|
|
1460
1474
|
}
|
|
1461
1475
|
//#endregion
|
|
1462
1476
|
//#region src/entities/session/session.ts
|
|
1463
|
-
var
|
|
1464
|
-
function
|
|
1477
|
+
var yt = D("session", "global");
|
|
1478
|
+
function bt() {
|
|
1465
1479
|
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)}`;
|
|
1466
1480
|
}
|
|
1467
|
-
function
|
|
1481
|
+
function xt() {
|
|
1468
1482
|
if (!u()) return null;
|
|
1469
|
-
let e =
|
|
1483
|
+
let e = T.get(yt);
|
|
1470
1484
|
if (!e.isSet()) return null;
|
|
1471
1485
|
try {
|
|
1472
1486
|
return e.json();
|
|
@@ -1474,8 +1488,8 @@ function St() {
|
|
|
1474
1488
|
return null;
|
|
1475
1489
|
}
|
|
1476
1490
|
}
|
|
1477
|
-
var
|
|
1478
|
-
let e =
|
|
1491
|
+
var St = L(() => {
|
|
1492
|
+
let e = xt(), t = { id: e?.id ?? bt() };
|
|
1479
1493
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1480
1494
|
let n = F(t), r = j(n, {
|
|
1481
1495
|
setIsUser: (e, t) => ({
|
|
@@ -1504,7 +1518,7 @@ var Ct = L(() => {
|
|
|
1504
1518
|
source: n,
|
|
1505
1519
|
effect: (e) => {
|
|
1506
1520
|
if (u()) try {
|
|
1507
|
-
|
|
1521
|
+
T.get(yt).set(e);
|
|
1508
1522
|
} catch {}
|
|
1509
1523
|
}
|
|
1510
1524
|
})
|
|
@@ -1515,27 +1529,27 @@ var Ct = L(() => {
|
|
|
1515
1529
|
removeIdentifier: r.removeIdentifier
|
|
1516
1530
|
};
|
|
1517
1531
|
});
|
|
1518
|
-
function
|
|
1519
|
-
return R(
|
|
1532
|
+
function Ct() {
|
|
1533
|
+
return R(St, void 0);
|
|
1520
1534
|
}
|
|
1521
1535
|
//#endregion
|
|
1522
1536
|
//#region src/utils/picked-config.ts
|
|
1523
|
-
function
|
|
1537
|
+
function wt() {
|
|
1524
1538
|
if (o()) return globalThis.window.pickedConfig;
|
|
1525
1539
|
}
|
|
1526
|
-
function
|
|
1527
|
-
if (o()) return
|
|
1540
|
+
function Tt() {
|
|
1541
|
+
if (o()) return wt()?.projectId;
|
|
1528
1542
|
}
|
|
1529
|
-
function
|
|
1543
|
+
function Et() {
|
|
1530
1544
|
if (!f()) return;
|
|
1531
1545
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1532
1546
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1533
1547
|
}
|
|
1534
|
-
function
|
|
1548
|
+
function Dt(e) {
|
|
1535
1549
|
if (e.projectId) return e.projectId;
|
|
1536
|
-
let t =
|
|
1550
|
+
let t = Tt();
|
|
1537
1551
|
if (t) return t;
|
|
1538
|
-
let n =
|
|
1552
|
+
let n = Et();
|
|
1539
1553
|
if (n) return n;
|
|
1540
1554
|
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.");
|
|
1541
1555
|
}
|
|
@@ -1544,7 +1558,7 @@ function Ot(e) {
|
|
|
1544
1558
|
function $(e) {
|
|
1545
1559
|
return e == null || e === "" || Number.isNaN(e);
|
|
1546
1560
|
}
|
|
1547
|
-
var
|
|
1561
|
+
var Ot = {
|
|
1548
1562
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1549
1563
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1550
1564
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1565,24 +1579,24 @@ var kt = {
|
|
|
1565
1579
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1566
1580
|
}
|
|
1567
1581
|
};
|
|
1568
|
-
function
|
|
1582
|
+
function kt(e) {
|
|
1569
1583
|
return typeof e == "object" && !!e;
|
|
1570
1584
|
}
|
|
1571
|
-
function
|
|
1585
|
+
function At(e, t) {
|
|
1572
1586
|
let n = t;
|
|
1573
|
-
for (let t of e.split(".")) if (
|
|
1587
|
+
for (let t of e.split(".")) if (kt(n) && t in n) n = n[t];
|
|
1574
1588
|
else return;
|
|
1575
1589
|
return typeof n == "function" ? n() : n;
|
|
1576
1590
|
}
|
|
1577
|
-
function
|
|
1578
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1591
|
+
function jt(e, t) {
|
|
1592
|
+
let n = e.split("|").map((e) => e.trim()), r = At(n.shift() ?? "", t);
|
|
1579
1593
|
for (let e of n) {
|
|
1580
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1594
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Ot[i];
|
|
1581
1595
|
o && (r = o(r, a));
|
|
1582
1596
|
}
|
|
1583
1597
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1584
1598
|
}
|
|
1585
|
-
function
|
|
1599
|
+
function Mt(e, t) {
|
|
1586
1600
|
let n = "", r = 0;
|
|
1587
1601
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1588
1602
|
r += 2;
|
|
@@ -1594,15 +1608,17 @@ function Nt(e, t) {
|
|
|
1594
1608
|
}
|
|
1595
1609
|
i += e[r++];
|
|
1596
1610
|
}
|
|
1597
|
-
n +=
|
|
1611
|
+
n += jt(i.trim(), t);
|
|
1598
1612
|
} else n += e[r++];
|
|
1599
1613
|
return n;
|
|
1600
1614
|
}
|
|
1601
1615
|
//#endregion
|
|
1602
1616
|
//#region src/picked.ts
|
|
1603
|
-
var
|
|
1617
|
+
var Nt = class {
|
|
1604
1618
|
static logger = r;
|
|
1605
1619
|
options;
|
|
1620
|
+
dataSource = null;
|
|
1621
|
+
contentLoader;
|
|
1606
1622
|
plugins = {};
|
|
1607
1623
|
eventBus = P();
|
|
1608
1624
|
events;
|
|
@@ -1610,61 +1626,62 @@ var Pt = class {
|
|
|
1610
1626
|
apiUrl;
|
|
1611
1627
|
dashboardUrl;
|
|
1612
1628
|
documentationSiteUrl;
|
|
1613
|
-
session =
|
|
1614
|
-
searchParams =
|
|
1615
|
-
history =
|
|
1616
|
-
components =
|
|
1617
|
-
experienceInstances =
|
|
1618
|
-
experiences =
|
|
1619
|
-
frameworks =
|
|
1620
|
-
predicates =
|
|
1621
|
-
features =
|
|
1622
|
-
conditions =
|
|
1623
|
-
fields =
|
|
1624
|
-
responses =
|
|
1625
|
-
steps =
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
+
session = Ct();
|
|
1630
|
+
searchParams = vt();
|
|
1631
|
+
history = Be();
|
|
1632
|
+
components = pe({ client: this });
|
|
1633
|
+
experienceInstances = S({ client: this });
|
|
1634
|
+
experiences = ae({ client: this });
|
|
1635
|
+
frameworks = ge({ client: this });
|
|
1636
|
+
predicates = Me({ client: this });
|
|
1637
|
+
features = Ie({ client: this });
|
|
1638
|
+
conditions = gt();
|
|
1639
|
+
fields = Ge();
|
|
1640
|
+
responses = pt({ client: this });
|
|
1641
|
+
steps = Je();
|
|
1642
|
+
contents = Qe();
|
|
1643
|
+
actions = nt({ client: this });
|
|
1644
|
+
stateSnapshotStore = ye({ client: this });
|
|
1645
|
+
evaluateRuleLogicFx = we({ client: this });
|
|
1629
1646
|
start;
|
|
1630
1647
|
readyStore;
|
|
1631
1648
|
preconditionPassedStore;
|
|
1632
1649
|
conditionPassedStore;
|
|
1633
1650
|
lifecycleStageStore;
|
|
1634
|
-
lifecycle =
|
|
1651
|
+
lifecycle = ke({ client: this });
|
|
1635
1652
|
renderStringFx = k({
|
|
1636
1653
|
source: this.responses.listStore,
|
|
1637
1654
|
effect: (e, { template: t, context: n }) => {
|
|
1638
1655
|
let r = {};
|
|
1639
1656
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1640
|
-
return
|
|
1657
|
+
return Mt(t, {
|
|
1641
1658
|
...n,
|
|
1642
1659
|
responses: r
|
|
1643
1660
|
});
|
|
1644
1661
|
}
|
|
1645
1662
|
});
|
|
1646
1663
|
constructor(e) {
|
|
1647
|
-
this.events =
|
|
1664
|
+
this.events = He(this.eventBus), this.projectId = Dt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || _t(), 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({
|
|
1648
1665
|
type: "load",
|
|
1649
|
-
version:
|
|
1666
|
+
version: ee()
|
|
1650
1667
|
});
|
|
1651
1668
|
}
|
|
1652
1669
|
registerFramework = (e) => {
|
|
1653
|
-
|
|
1670
|
+
_e(e, this.frameworks);
|
|
1654
1671
|
};
|
|
1655
1672
|
registerComponent = (e, t) => {
|
|
1656
1673
|
B(e, t, this.components);
|
|
1657
1674
|
};
|
|
1658
1675
|
registerPlugin = (e) => {
|
|
1659
|
-
|
|
1676
|
+
ce(this, e, this.plugins);
|
|
1660
1677
|
let t = this.plugins[e.name];
|
|
1661
1678
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1662
1679
|
};
|
|
1663
1680
|
registerFeature = (e, t) => {
|
|
1664
|
-
|
|
1681
|
+
Le(e, t, this.features);
|
|
1665
1682
|
};
|
|
1666
1683
|
registerPredicate = (e, t) => {
|
|
1667
|
-
|
|
1684
|
+
Ne(e, t, this.predicates);
|
|
1668
1685
|
};
|
|
1669
1686
|
registerCondition = (e) => {
|
|
1670
1687
|
this.conditions.register(e);
|
|
@@ -1673,10 +1690,13 @@ var Pt = class {
|
|
|
1673
1690
|
this.fields.register(e);
|
|
1674
1691
|
};
|
|
1675
1692
|
registerStep = (e) => {
|
|
1676
|
-
|
|
1693
|
+
Ye(e, this.steps);
|
|
1694
|
+
};
|
|
1695
|
+
registerContent = (e) => {
|
|
1696
|
+
$e(e, this.contents);
|
|
1677
1697
|
};
|
|
1678
1698
|
registerAction = (e, t) => {
|
|
1679
|
-
|
|
1699
|
+
rt(e, t, this.actions);
|
|
1680
1700
|
};
|
|
1681
1701
|
registerExperience = (e) => {
|
|
1682
1702
|
e.component && B(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
@@ -1764,20 +1784,20 @@ var Pt = class {
|
|
|
1764
1784
|
};
|
|
1765
1785
|
//#endregion
|
|
1766
1786
|
//#region src/entities/component/lazyComponent.ts
|
|
1767
|
-
function
|
|
1787
|
+
function Pt(e) {
|
|
1768
1788
|
return {
|
|
1769
1789
|
$$type: "lazy-component",
|
|
1770
1790
|
load: e
|
|
1771
1791
|
};
|
|
1772
1792
|
}
|
|
1773
|
-
function
|
|
1793
|
+
function Ft(e) {
|
|
1774
1794
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1775
1795
|
}
|
|
1776
1796
|
//#endregion
|
|
1777
1797
|
//#region src/exports.ts
|
|
1778
|
-
var
|
|
1779
|
-
let t = new
|
|
1798
|
+
var It = (e) => {
|
|
1799
|
+
let t = new Nt(e);
|
|
1780
1800
|
return d(t), t;
|
|
1781
1801
|
};
|
|
1782
1802
|
//#endregion
|
|
1783
|
-
export {
|
|
1803
|
+
export { Nt as Picked, It as createClient, se as createPluginEffect, D as createStorageKey, n as evaluateRuleLogic, wt as getPickedConfig, Ft as isLazyLoader, g as isPickedRoot, Pt as lazyComponent, T as localStore, E as sessionStore, w 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 };
|