@picked/client 0.0.62-next.12 → 0.0.62-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-BTbEUnGh.js → api-DnsQgAfY.js} +1 -1
- package/dist/api-Dy5cTzV6.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- 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/image-optimisation-service.md +6 -6
- package/dist/docs/sdk/content-security-policy.md +7 -8
- package/dist/docs/sdk/fields.md +2 -2
- package/dist/docs/workspaces.mdx +1 -1
- package/dist/esm/index.js +277 -342
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +38 -109
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BrLWgVAN.js +501 -0
- package/dist/experience-instance-Ct3ogC7n.cjs +1 -0
- package/dist/types/entities/experience/experience.d.ts +2 -22
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +2 -17
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
- package/dist/types/picked.d.ts +0 -39
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -2
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +1 -18
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +1 -63
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/package.json +1 -11
- package/dist/api-DDd_Zf11.cjs +0 -1
- package/dist/cjs/plugins/dom-observer/index.js +0 -1
- package/dist/dom-C3C6Fmwz.cjs +0 -1
- package/dist/dom-DGePXPpM.js +0 -84
- package/dist/esm/plugins/dom-observer/index.js +0 -87
- package/dist/experience-instance-DImym3m_.js +0 -419
- package/dist/experience-instance-DygAdzbn.cjs +0 -1
- package/dist/types/entities/content/content.d.ts +0 -37
- package/dist/types/entities/content/content.d.ts.map +0 -1
- package/dist/types/plugins/dom-observer/index.d.ts +0 -3
- package/dist/types/plugins/dom-observer/index.d.ts.map +0 -1
- package/dist/types/plugins/dom-observer/plugin.d.ts +0 -50
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +0 -1
- /package/dist/{id-Cg7fVl1O.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-n2yrHvNo.js → id-CRqy981z.js} +0 -0
- /package/dist/{storage-hOHCCXvP.js → storage-6Xk0uAxB.js} +0 -0
- /package/dist/{storage-BXSlLTRa.cjs → storage-B6lQtc4-.cjs} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -2,16 +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 {
|
|
8
|
-
import {
|
|
9
|
-
import { t as ne } from "../id-n2yrHvNo.js";
|
|
5
|
+
import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
|
|
6
|
+
import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as D, r as te } from "../api-DnsQgAfY.js";
|
|
8
|
+
import { t as ne } from "../id-CRqy981z.js";
|
|
10
9
|
import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
|
|
11
10
|
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
12
11
|
//#region src/entities/experience/experience.ts
|
|
13
|
-
var
|
|
14
|
-
let i =
|
|
12
|
+
var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
13
|
+
let i = re.store(r), a = A(i, { merge(e, t) {
|
|
15
14
|
return {
|
|
16
15
|
...e,
|
|
17
16
|
...t.experience
|
|
@@ -22,7 +21,7 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
22
21
|
targetSelectors: e.targets,
|
|
23
22
|
initializeOpenLogic: e.initializeOpen
|
|
24
23
|
})), s = k(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 = k(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
25
|
-
let r = e.nodes.filter(
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(x).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
26
25
|
return {
|
|
27
26
|
steps: r,
|
|
28
27
|
nodes: e.nodes,
|
|
@@ -32,8 +31,8 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
32
31
|
}), l = r.actions ?? [], u, d = O({
|
|
33
32
|
source: o,
|
|
34
33
|
effect: (t, n) => {
|
|
35
|
-
let i =
|
|
36
|
-
i.forEach(({ elements: e }) => e.forEach((e) =>
|
|
34
|
+
let i = S(t.targetSelectors, r.id);
|
|
35
|
+
i.forEach(({ elements: e }) => e.forEach((e) => y(e, r.id))), g(i, r.id, r.key).forEach((t) => {
|
|
37
36
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
38
37
|
});
|
|
39
38
|
}
|
|
@@ -46,42 +45,10 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
46
45
|
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
47
46
|
if (!i || !a) return !1;
|
|
48
47
|
let { decisionLogic: s, targetSelectors: c } = o;
|
|
49
|
-
return c.length === 0 ||
|
|
48
|
+
return c.length === 0 || S(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
50
49
|
}
|
|
51
|
-
})
|
|
52
|
-
|
|
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 = N(), h = N(), g = R.createStore(void 0, { skipVoid: !1 }).on(m, (e, t) => t).on(h, (e, t) => t);
|
|
63
|
-
return F({
|
|
64
|
-
clock: m,
|
|
65
|
-
target: f
|
|
66
|
-
}), F({
|
|
67
|
-
clock: f.doneData,
|
|
68
|
-
source: g,
|
|
69
|
-
filter: (e, t) => t,
|
|
70
|
-
fn: (e) => e,
|
|
71
|
-
target: d
|
|
72
|
-
}), F({
|
|
73
|
-
clock: f.doneData,
|
|
74
|
-
filter: Boolean,
|
|
75
|
-
target: p
|
|
76
|
-
}), F({
|
|
77
|
-
clock: h,
|
|
78
|
-
source: g,
|
|
79
|
-
fn: (e) => e,
|
|
80
|
-
target: d
|
|
81
|
-
}), F({
|
|
82
|
-
clock: h,
|
|
83
|
-
target: p
|
|
84
|
-
}), u = {
|
|
50
|
+
});
|
|
51
|
+
return u = {
|
|
85
52
|
id: r.id,
|
|
86
53
|
key: r.key,
|
|
87
54
|
name: r.name,
|
|
@@ -91,23 +58,20 @@ var R = j("experience"), re = I(({ client: e, experience: r }) => {
|
|
|
91
58
|
actions: l,
|
|
92
59
|
merge: a.merge,
|
|
93
60
|
initialiseFx: d,
|
|
94
|
-
shouldInitialiseFx: f
|
|
95
|
-
initialiseRequested: m,
|
|
96
|
-
initialiseDirectly: h,
|
|
97
|
-
prepareExperienceContentFx: p
|
|
61
|
+
shouldInitialiseFx: f
|
|
98
62
|
}, u;
|
|
99
63
|
});
|
|
100
|
-
function
|
|
101
|
-
return L(
|
|
64
|
+
function ae(e) {
|
|
65
|
+
return L(ie, e);
|
|
102
66
|
}
|
|
103
|
-
var
|
|
104
|
-
let t =
|
|
67
|
+
var oe = I(({ client: e }) => {
|
|
68
|
+
let t = re.store({}), n = A(t, { register(e, t) {
|
|
105
69
|
return {
|
|
106
70
|
...e,
|
|
107
71
|
[t.id]: t
|
|
108
72
|
};
|
|
109
73
|
} }), r = N(), i = M((t) => {
|
|
110
|
-
n.register(
|
|
74
|
+
n.register(ae({
|
|
111
75
|
client: e,
|
|
112
76
|
experience: t
|
|
113
77
|
}));
|
|
@@ -141,14 +105,18 @@ var ae = I(({ client: e }) => {
|
|
|
141
105
|
}
|
|
142
106
|
let c = O({
|
|
143
107
|
source: t,
|
|
144
|
-
effect: (e, t) => {
|
|
108
|
+
effect: async (e, t) => {
|
|
145
109
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
146
110
|
if (!n) {
|
|
147
111
|
"key" in t ? `${t.key}` : `${t.id}`;
|
|
148
112
|
return;
|
|
149
113
|
}
|
|
150
114
|
let { options: r } = t;
|
|
151
|
-
r?.bypassCondition
|
|
115
|
+
if (r?.bypassCondition) {
|
|
116
|
+
await n.initialiseFx(r);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
await n.shouldInitialiseFx() && await n.initialiseFx(r);
|
|
152
120
|
}
|
|
153
121
|
});
|
|
154
122
|
return {
|
|
@@ -163,7 +131,7 @@ var ae = I(({ client: e }) => {
|
|
|
163
131
|
instances: e.experienceInstances.listStore
|
|
164
132
|
},
|
|
165
133
|
effect: async ({ experiences: e, instances: t }, n) => {
|
|
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
|
|
134
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
|
|
167
135
|
if (i.length > 0) {
|
|
168
136
|
for (let e of i) e.open();
|
|
169
137
|
return;
|
|
@@ -186,26 +154,28 @@ var ae = I(({ client: e }) => {
|
|
|
186
154
|
listStore: a,
|
|
187
155
|
initialiseExperiencesFx: O({
|
|
188
156
|
source: a,
|
|
189
|
-
effect: (e) => {
|
|
190
|
-
|
|
157
|
+
effect: async (e) => {
|
|
158
|
+
await Promise.all(e.map(async (e) => {
|
|
159
|
+
await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
|
|
160
|
+
}));
|
|
191
161
|
}
|
|
192
162
|
})
|
|
193
163
|
};
|
|
194
164
|
});
|
|
195
|
-
function
|
|
196
|
-
return L(
|
|
165
|
+
function se(e) {
|
|
166
|
+
return L(oe, e);
|
|
197
167
|
}
|
|
198
|
-
var
|
|
168
|
+
var ce = async (e) => {
|
|
199
169
|
await e.experiences.initialiseExperiencesFx();
|
|
200
170
|
};
|
|
201
171
|
//#endregion
|
|
202
172
|
//#region src/entities/plugin/plugin.ts
|
|
203
|
-
function
|
|
173
|
+
function le(e) {
|
|
204
174
|
return M(async () => {
|
|
205
175
|
await e();
|
|
206
176
|
});
|
|
207
177
|
}
|
|
208
|
-
var
|
|
178
|
+
var ue = (e, t, n) => {
|
|
209
179
|
let r = t.name, i = t.setup(e);
|
|
210
180
|
if (i) {
|
|
211
181
|
let e = n[r] ?? {};
|
|
@@ -214,16 +184,16 @@ var le = (e, t, n) => {
|
|
|
214
184
|
...i
|
|
215
185
|
});
|
|
216
186
|
}
|
|
217
|
-
},
|
|
187
|
+
}, de = j("component"), fe = I(({ client: e, component: t, name: n }) => ({
|
|
218
188
|
name: n,
|
|
219
189
|
component: t,
|
|
220
190
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
221
191
|
}));
|
|
222
|
-
function
|
|
223
|
-
return L(
|
|
192
|
+
function pe(e) {
|
|
193
|
+
return L(fe, e);
|
|
224
194
|
}
|
|
225
|
-
var
|
|
226
|
-
let t =
|
|
195
|
+
var me = I(({ client: e }) => {
|
|
196
|
+
let t = de.store({}), n = A(t, { register(e, t) {
|
|
227
197
|
return {
|
|
228
198
|
...e,
|
|
229
199
|
[t.name]: t
|
|
@@ -236,7 +206,7 @@ var pe = I(({ client: e }) => {
|
|
|
236
206
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
237
207
|
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
238
208
|
clock: i,
|
|
239
|
-
fn: ({ name: t, component: n }) =>
|
|
209
|
+
fn: ({ name: t, component: n }) => pe({
|
|
240
210
|
client: e,
|
|
241
211
|
name: t,
|
|
242
212
|
component: n
|
|
@@ -253,16 +223,16 @@ var pe = I(({ client: e }) => {
|
|
|
253
223
|
listStore: a
|
|
254
224
|
};
|
|
255
225
|
});
|
|
256
|
-
function
|
|
257
|
-
return L(
|
|
226
|
+
function he(e) {
|
|
227
|
+
return L(me, e);
|
|
258
228
|
}
|
|
259
|
-
var
|
|
229
|
+
var ge = (e, t, n) => {
|
|
260
230
|
n.register({
|
|
261
231
|
name: e,
|
|
262
232
|
component: t
|
|
263
233
|
});
|
|
264
|
-
},
|
|
265
|
-
let t =
|
|
234
|
+
}, _e = j("framework"), ve = I((e) => {
|
|
235
|
+
let t = _e.store({}), n = A(t, { register(e, t) {
|
|
266
236
|
return {
|
|
267
237
|
...e,
|
|
268
238
|
[t.name]: t.framework
|
|
@@ -287,20 +257,20 @@ var z = (e, t, n) => {
|
|
|
287
257
|
listStore: a
|
|
288
258
|
};
|
|
289
259
|
});
|
|
290
|
-
function
|
|
291
|
-
return L(
|
|
260
|
+
function ye(e) {
|
|
261
|
+
return L(ve, e);
|
|
292
262
|
}
|
|
293
|
-
var
|
|
263
|
+
var be = (e, t) => {
|
|
294
264
|
t.register({
|
|
295
265
|
name: e.name,
|
|
296
266
|
framework: e
|
|
297
267
|
});
|
|
298
|
-
},
|
|
299
|
-
let t =
|
|
300
|
-
location: t ?
|
|
301
|
-
document: t ?
|
|
302
|
-
sessionStorage: t ?
|
|
303
|
-
localStorage: t ?
|
|
268
|
+
}, xe = I(({ client: e }) => {
|
|
269
|
+
let t = typeof window < "u", n = {
|
|
270
|
+
location: t ? window.location : void 0,
|
|
271
|
+
document: t ? window.document : void 0,
|
|
272
|
+
sessionStorage: t ? window.sessionStorage : void 0,
|
|
273
|
+
localStorage: t ? window.localStorage : void 0
|
|
304
274
|
};
|
|
305
275
|
return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
306
276
|
client: e,
|
|
@@ -309,84 +279,84 @@ var ve = (e, t) => {
|
|
|
309
279
|
...n
|
|
310
280
|
}));
|
|
311
281
|
});
|
|
312
|
-
function
|
|
313
|
-
return L(
|
|
282
|
+
function Se(e) {
|
|
283
|
+
return L(xe, e);
|
|
314
284
|
}
|
|
315
285
|
//#endregion
|
|
316
286
|
//#region src/logic-engine.ts
|
|
317
|
-
function
|
|
287
|
+
function Ce(e) {
|
|
318
288
|
return typeof e == "number" && !isNaN(e);
|
|
319
289
|
}
|
|
320
|
-
function
|
|
290
|
+
function R(e) {
|
|
321
291
|
return typeof e == "string";
|
|
322
292
|
}
|
|
323
|
-
function
|
|
293
|
+
function z(e) {
|
|
324
294
|
return Array.isArray(e);
|
|
325
295
|
}
|
|
326
|
-
function
|
|
296
|
+
function B(e) {
|
|
327
297
|
return e instanceof Promise;
|
|
328
298
|
}
|
|
329
|
-
function
|
|
299
|
+
function V(e) {
|
|
330
300
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
331
301
|
}
|
|
332
|
-
function
|
|
333
|
-
if (
|
|
302
|
+
function H(e) {
|
|
303
|
+
if (Ce(e)) return e;
|
|
334
304
|
let t = parseFloat(`${e}`);
|
|
335
305
|
return isNaN(t) ? 0 : t;
|
|
336
306
|
}
|
|
337
|
-
function
|
|
307
|
+
function U(e) {
|
|
338
308
|
return `${e}`;
|
|
339
309
|
}
|
|
340
|
-
var
|
|
310
|
+
var we = {
|
|
341
311
|
"==": (e, t) => e == t,
|
|
342
312
|
"===": (e, t) => e === t,
|
|
343
313
|
"!=": (e, t) => e != t,
|
|
344
314
|
"!==": (e, t) => e !== t,
|
|
345
|
-
">": (e, t) =>
|
|
346
|
-
">=": (e, t) =>
|
|
315
|
+
">": (e, t) => H(e) > H(t),
|
|
316
|
+
">=": (e, t) => H(e) >= H(t),
|
|
347
317
|
"<": (e, t, n) => {
|
|
348
|
-
let r =
|
|
318
|
+
let r = H(e), i = H(t);
|
|
349
319
|
if (n === void 0) return r < i;
|
|
350
|
-
let a =
|
|
320
|
+
let a = H(n);
|
|
351
321
|
return r < i && i < a;
|
|
352
322
|
},
|
|
353
323
|
"<=": (e, t, n) => {
|
|
354
|
-
let r =
|
|
324
|
+
let r = H(e), i = H(t);
|
|
355
325
|
if (n === void 0) return r <= i;
|
|
356
|
-
let a =
|
|
326
|
+
let a = H(n);
|
|
357
327
|
return r <= i && i <= a;
|
|
358
328
|
},
|
|
359
|
-
"!!": async (e) => await
|
|
360
|
-
"!": async (e) => !await
|
|
361
|
-
"%": (e, t) =>
|
|
329
|
+
"!!": async (e) => await G(e),
|
|
330
|
+
"!": async (e) => !await G(e),
|
|
331
|
+
"%": (e, t) => H(e) % H(t),
|
|
362
332
|
log: (e) => (console.log(e), e),
|
|
363
|
-
in: (e, t) => t ?
|
|
364
|
-
cat: (...e) => e.map(
|
|
333
|
+
in: (e, t) => t ? R(t) ? t.indexOf(U(e)) !== -1 : z(t) ? t.includes(e) : !1 : !1,
|
|
334
|
+
cat: (...e) => e.map(U).join(""),
|
|
365
335
|
substr: (e, t, n) => {
|
|
366
|
-
let r =
|
|
336
|
+
let r = U(e), i = H(t);
|
|
367
337
|
if (n === void 0) return r.substr(i);
|
|
368
|
-
let a =
|
|
338
|
+
let a = H(n);
|
|
369
339
|
if (a < 0) {
|
|
370
340
|
let e = r.substr(i);
|
|
371
341
|
return e.substr(0, e.length + a);
|
|
372
342
|
}
|
|
373
343
|
return r.substr(i, a);
|
|
374
344
|
},
|
|
375
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
376
|
-
"*": (...e) => e.reduce((e, t) =>
|
|
345
|
+
"+": (...e) => e.reduce((e, t) => H(e) + H(t), 0),
|
|
346
|
+
"*": (...e) => e.reduce((e, t) => H(e) * H(t), 1),
|
|
377
347
|
"-": (e, t) => {
|
|
378
|
-
let n =
|
|
379
|
-
return t === void 0 ? -n : n -
|
|
348
|
+
let n = H(e);
|
|
349
|
+
return t === void 0 ? -n : n - H(t);
|
|
380
350
|
},
|
|
381
|
-
"/": (e, t) =>
|
|
382
|
-
min: (...e) => Math.min(...e.map(
|
|
383
|
-
max: (...e) => Math.max(...e.map(
|
|
384
|
-
merge: (...e) => e.reduce((e, t) =>
|
|
351
|
+
"/": (e, t) => H(e) / H(t),
|
|
352
|
+
min: (...e) => Math.min(...e.map(H)),
|
|
353
|
+
max: (...e) => Math.max(...e.map(H)),
|
|
354
|
+
merge: (...e) => e.reduce((e, t) => z(t) ? e.concat(t) : e.concat([t]), []),
|
|
385
355
|
var(e, t) {
|
|
386
356
|
let n = arguments.length > 1 ? t : null;
|
|
387
357
|
if (e === "" || e === "." || e == null) return this;
|
|
388
358
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
389
|
-
let r =
|
|
359
|
+
let r = U(e);
|
|
390
360
|
if (r === "" || r === ".") return this;
|
|
391
361
|
let i = r.split("."), a = this;
|
|
392
362
|
for (let e of i) {
|
|
@@ -399,116 +369,116 @@ var Se = {
|
|
|
399
369
|
return a === void 0 ? n : a;
|
|
400
370
|
},
|
|
401
371
|
async missing(...e) {
|
|
402
|
-
let t =
|
|
372
|
+
let t = z(e[0]) ? e[0] : e, n = [];
|
|
403
373
|
for (let e of t) {
|
|
404
|
-
let t = await
|
|
374
|
+
let t = await W({ var: e }, this);
|
|
405
375
|
(t === null || t === "") && n.push(`${e}`);
|
|
406
376
|
}
|
|
407
377
|
return n;
|
|
408
378
|
},
|
|
409
379
|
async missing_some(e, t) {
|
|
410
|
-
let n = await
|
|
411
|
-
if (!
|
|
412
|
-
let r = n.filter(
|
|
413
|
-
return t.filter(
|
|
380
|
+
let n = await W({ missing: t }, this);
|
|
381
|
+
if (!z(n) || !z(t)) return [];
|
|
382
|
+
let r = n.filter(R);
|
|
383
|
+
return t.filter(R).length - r.length >= H(e) ? [] : r;
|
|
414
384
|
},
|
|
415
385
|
invoke(...e) {
|
|
416
386
|
let [t, ...n] = e;
|
|
417
387
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
418
388
|
},
|
|
419
|
-
startsWith: (e, t) =>
|
|
420
|
-
endsWith: (e, t) =>
|
|
389
|
+
startsWith: (e, t) => R(e) && R(t) && e.startsWith(t),
|
|
390
|
+
endsWith: (e, t) => R(e) && R(t) && e.endsWith(t),
|
|
421
391
|
regexp_matches(e, t) {
|
|
422
392
|
let n = e, r = "";
|
|
423
|
-
if (
|
|
393
|
+
if (z(e)) {
|
|
424
394
|
let [t, i] = e;
|
|
425
395
|
n = t, r = i;
|
|
426
396
|
}
|
|
427
|
-
return !
|
|
397
|
+
return !R(n) || !R(r) ? !1 : new RegExp(n, r).test(U(t));
|
|
428
398
|
},
|
|
429
399
|
throw(e) {
|
|
430
|
-
throw Error(
|
|
400
|
+
throw Error(U(e));
|
|
431
401
|
}
|
|
432
402
|
};
|
|
433
|
-
async function
|
|
403
|
+
async function W(e, t) {
|
|
434
404
|
if (!e) return e;
|
|
435
|
-
if (
|
|
436
|
-
if (
|
|
437
|
-
if (!
|
|
438
|
-
let n =
|
|
439
|
-
switch (
|
|
405
|
+
if (B(e)) return W(await e, t);
|
|
406
|
+
if (z(e)) return Promise.all(e.map((e) => W(e, t)));
|
|
407
|
+
if (!V(e)) return e;
|
|
408
|
+
let n = Te(e), r = n ? e[n] ?? [] : [];
|
|
409
|
+
switch (z(r) || (r = [r]), n) {
|
|
440
410
|
case "if":
|
|
441
411
|
case "?:":
|
|
442
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
443
|
-
return r.length % 2 == 1 ?
|
|
412
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await G(await W(r[e], t))) return W(r[e + 1], t);
|
|
413
|
+
return r.length % 2 == 1 ? W(r[r.length - 1], t) : null;
|
|
444
414
|
case "and": {
|
|
445
415
|
let e = null;
|
|
446
|
-
for (let n of r) if (e = await
|
|
416
|
+
for (let n of r) if (e = await W(n, t), !await G(e)) return e;
|
|
447
417
|
return e;
|
|
448
418
|
}
|
|
449
419
|
case "or": {
|
|
450
420
|
let e = null;
|
|
451
|
-
for (let n of r) if (e = await
|
|
421
|
+
for (let n of r) if (e = await W(n, t), await G(e)) return e;
|
|
452
422
|
return e;
|
|
453
423
|
}
|
|
454
424
|
case "map": {
|
|
455
|
-
let e = await
|
|
456
|
-
return
|
|
425
|
+
let e = await W(r[0], t);
|
|
426
|
+
return z(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
|
|
457
427
|
}
|
|
458
428
|
case "filter": {
|
|
459
|
-
let e = await
|
|
460
|
-
return
|
|
429
|
+
let e = await W(r[0], t);
|
|
430
|
+
return z(e) ? (await Promise.all(e.map(async (e) => ({
|
|
461
431
|
item: e,
|
|
462
|
-
shouldInclude: await
|
|
432
|
+
shouldInclude: await G(await W(r[1], e))
|
|
463
433
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
464
434
|
}
|
|
465
435
|
case "reduce": {
|
|
466
|
-
let e = await
|
|
467
|
-
if (!
|
|
468
|
-
let n = r[1], i = r.length > 2 ? await
|
|
469
|
-
for (let t of e) i = await
|
|
436
|
+
let e = await W(r[0], t);
|
|
437
|
+
if (!z(e)) return r.length > 2 ? await W(r[2], t) : null;
|
|
438
|
+
let n = r[1], i = r.length > 2 ? await W(r[2], t) : null;
|
|
439
|
+
for (let t of e) i = await W(n, {
|
|
470
440
|
current: t,
|
|
471
441
|
accumulator: i
|
|
472
442
|
});
|
|
473
443
|
return i;
|
|
474
444
|
}
|
|
475
445
|
case "all": {
|
|
476
|
-
let e = await
|
|
477
|
-
if (!
|
|
478
|
-
for (let t of e) if (!await
|
|
446
|
+
let e = await W(r[0], t);
|
|
447
|
+
if (!z(e) || e.length === 0) return !1;
|
|
448
|
+
for (let t of e) if (!await G(await W(r[1], t))) return !1;
|
|
479
449
|
return !0;
|
|
480
450
|
}
|
|
481
451
|
case "some": {
|
|
482
|
-
let e = await
|
|
483
|
-
if (!
|
|
484
|
-
for (let t of e) if (await
|
|
452
|
+
let e = await W(r[0], t);
|
|
453
|
+
if (!z(e)) return !1;
|
|
454
|
+
for (let t of e) if (await G(await W(r[1], t))) return !0;
|
|
485
455
|
return !1;
|
|
486
456
|
}
|
|
487
457
|
case "none": {
|
|
488
|
-
let e = await
|
|
489
|
-
if (!
|
|
490
|
-
for (let t of e) if (await
|
|
458
|
+
let e = await W(r[0], t);
|
|
459
|
+
if (!z(e)) return !0;
|
|
460
|
+
for (let t of e) if (await G(await W(r[1], t))) return !1;
|
|
491
461
|
return !0;
|
|
492
462
|
}
|
|
493
463
|
case "catch": try {
|
|
494
|
-
return await
|
|
464
|
+
return await W(r[0], t);
|
|
495
465
|
} catch (e) {
|
|
496
|
-
return
|
|
466
|
+
return V(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
497
467
|
}
|
|
498
468
|
}
|
|
499
|
-
let i = await Promise.all(r.map((e) =>
|
|
469
|
+
let i = await Promise.all(r.map((e) => W(e, t))), a = n ? we[n] : void 0;
|
|
500
470
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
501
471
|
return a.apply(t, i);
|
|
502
472
|
}
|
|
503
|
-
async function
|
|
504
|
-
return
|
|
473
|
+
async function G(e) {
|
|
474
|
+
return B(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
505
475
|
}
|
|
506
|
-
function
|
|
476
|
+
function Te(e) {
|
|
507
477
|
return Object.keys(e)[0];
|
|
508
478
|
}
|
|
509
479
|
//#endregion
|
|
510
480
|
//#region src/lifecycle/rules-logic.ts
|
|
511
|
-
var
|
|
481
|
+
var Ee = I(({ client: e }) => O({
|
|
512
482
|
source: {
|
|
513
483
|
stateSnapshot: e.stateSnapshotStore,
|
|
514
484
|
predicates: e.predicates.listStore,
|
|
@@ -527,7 +497,7 @@ var we = I(({ client: e }) => O({
|
|
|
527
497
|
let { bucket: e } = await t.getBucket();
|
|
528
498
|
return e;
|
|
529
499
|
}, e), {});
|
|
530
|
-
return await
|
|
500
|
+
return await W(a, {
|
|
531
501
|
responses: i,
|
|
532
502
|
location: typeof e.location == "object" ? {
|
|
533
503
|
hash: e.location.hash,
|
|
@@ -547,15 +517,15 @@ var we = I(({ client: e }) => O({
|
|
|
547
517
|
});
|
|
548
518
|
}
|
|
549
519
|
}));
|
|
550
|
-
function
|
|
551
|
-
return L(
|
|
520
|
+
function De(e) {
|
|
521
|
+
return L(Ee, e);
|
|
552
522
|
}
|
|
553
523
|
//#endregion
|
|
554
524
|
//#region src/ping.ts
|
|
555
|
-
var
|
|
525
|
+
var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
556
526
|
try {
|
|
557
|
-
let t = Date.now(), n = w.get(
|
|
558
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
527
|
+
let t = Date.now(), n = w.get(ke), r = 0;
|
|
528
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Oe) return !0;
|
|
559
529
|
let i = {
|
|
560
530
|
projectId: e.projectId,
|
|
561
531
|
path: window.location.pathname
|
|
@@ -566,27 +536,27 @@ var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
|
566
536
|
} catch {
|
|
567
537
|
return !1;
|
|
568
538
|
}
|
|
569
|
-
},
|
|
570
|
-
let t =
|
|
539
|
+
}, K = j("lifecycle"), je = I(({ client: e }) => {
|
|
540
|
+
let t = K.store(!1), r = P(void 0, {
|
|
571
541
|
skipVoid: !1,
|
|
572
|
-
domain:
|
|
542
|
+
domain: K
|
|
573
543
|
}), i = P(void 0, {
|
|
574
544
|
skipVoid: !1,
|
|
575
|
-
domain:
|
|
576
|
-
}), a =
|
|
545
|
+
domain: K
|
|
546
|
+
}), a = K.store("idle"), o = K.store([]), s = P(void 0, {
|
|
577
547
|
skipVoid: !1,
|
|
578
|
-
domain:
|
|
548
|
+
domain: K
|
|
579
549
|
}), c = P(void 0, {
|
|
580
550
|
skipVoid: !1,
|
|
581
|
-
domain:
|
|
551
|
+
domain: K
|
|
582
552
|
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
583
553
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
584
554
|
let g = M(() => {
|
|
585
|
-
|
|
555
|
+
Ae(e);
|
|
586
556
|
}), _ = M(async () => {
|
|
587
557
|
await ee();
|
|
588
558
|
}), v = M(async () => {
|
|
589
|
-
await
|
|
559
|
+
await ce(e);
|
|
590
560
|
}), y = O({ effect: v }), b = O({
|
|
591
561
|
source: o,
|
|
592
562
|
effect: async (e) => {
|
|
@@ -709,13 +679,13 @@ var Ee = 6e3, De = E("last_ping", "global"), Oe = async (e) => {
|
|
|
709
679
|
setCondition: h
|
|
710
680
|
};
|
|
711
681
|
});
|
|
712
|
-
function
|
|
713
|
-
return L(
|
|
682
|
+
function Me(e) {
|
|
683
|
+
return L(je, e);
|
|
714
684
|
}
|
|
715
685
|
//#endregion
|
|
716
686
|
//#region src/entities/predicate/predicate.ts
|
|
717
|
-
var
|
|
718
|
-
let t =
|
|
687
|
+
var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
688
|
+
let t = Ne.store({}), n = A(t, { register(e, t) {
|
|
719
689
|
return {
|
|
720
690
|
...e,
|
|
721
691
|
[t.name]: {
|
|
@@ -773,16 +743,16 @@ var je = j("predicate"), Me = I(({ client: e }) => {
|
|
|
773
743
|
getEvokablePredicate: s
|
|
774
744
|
};
|
|
775
745
|
});
|
|
776
|
-
function
|
|
777
|
-
return L(
|
|
746
|
+
function Fe(e) {
|
|
747
|
+
return L(Pe, e);
|
|
778
748
|
}
|
|
779
|
-
var
|
|
749
|
+
var Ie = (e, t, n) => {
|
|
780
750
|
n.register({
|
|
781
751
|
name: e,
|
|
782
752
|
predicate: t
|
|
783
753
|
});
|
|
784
|
-
},
|
|
785
|
-
let t =
|
|
754
|
+
}, Le = j("feature"), Re = I(({ client: e }) => {
|
|
755
|
+
let t = Le.store({}), n = Le.store([]), i = A(t, { register(e, t) {
|
|
786
756
|
return {
|
|
787
757
|
...e,
|
|
788
758
|
[t.id]: t.feature
|
|
@@ -943,16 +913,16 @@ var Pe = (e, t, n) => {
|
|
|
943
913
|
getEvokableFeature: p
|
|
944
914
|
};
|
|
945
915
|
});
|
|
946
|
-
function
|
|
947
|
-
return L(
|
|
916
|
+
function ze(e) {
|
|
917
|
+
return L(Re, e);
|
|
948
918
|
}
|
|
949
|
-
var
|
|
919
|
+
var Be = (e, t, n) => {
|
|
950
920
|
n.register({
|
|
951
921
|
id: e,
|
|
952
922
|
feature: t
|
|
953
923
|
});
|
|
954
|
-
},
|
|
955
|
-
function
|
|
924
|
+
}, q = j("history");
|
|
925
|
+
function J(e, t) {
|
|
956
926
|
return {
|
|
957
927
|
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
958
928
|
node: t,
|
|
@@ -960,9 +930,9 @@ function Re(e, t) {
|
|
|
960
930
|
experienceId: e
|
|
961
931
|
};
|
|
962
932
|
}
|
|
963
|
-
var
|
|
964
|
-
let e =
|
|
965
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
933
|
+
var Ve = I(() => {
|
|
934
|
+
let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
|
|
935
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, J(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), J(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
966
936
|
function a(e, t) {
|
|
967
937
|
let n = {
|
|
968
938
|
lastStepIndex: -1,
|
|
@@ -970,7 +940,7 @@ var ze = I(() => {
|
|
|
970
940
|
};
|
|
971
941
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
972
942
|
let i = e[r], a = i?.node;
|
|
973
|
-
if (!(!a || !
|
|
943
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
974
944
|
else {
|
|
975
945
|
n.secondLastStepIndex = r;
|
|
976
946
|
break;
|
|
@@ -992,20 +962,20 @@ var ze = I(() => {
|
|
|
992
962
|
entriesStore: e.map((e) => e.entries)
|
|
993
963
|
};
|
|
994
964
|
});
|
|
995
|
-
function
|
|
996
|
-
return L(
|
|
965
|
+
function He() {
|
|
966
|
+
return L(Ve);
|
|
997
967
|
}
|
|
998
968
|
//#endregion
|
|
999
969
|
//#region src/utils/events.ts
|
|
1000
|
-
var
|
|
970
|
+
var Ue = 0, We = (e) => {
|
|
1001
971
|
let t = P([]);
|
|
1002
972
|
return t.on(e, (e, t) => [...e, {
|
|
1003
|
-
id:
|
|
973
|
+
id: Ue++,
|
|
1004
974
|
at: /* @__PURE__ */ new Date(),
|
|
1005
975
|
payload: t
|
|
1006
976
|
}]), t;
|
|
1007
|
-
},
|
|
1008
|
-
let e =
|
|
977
|
+
}, Ge = j("field"), Ke = I(() => {
|
|
978
|
+
let e = Ge.store({}), t = A(e, {
|
|
1009
979
|
register(e, t) {
|
|
1010
980
|
return {
|
|
1011
981
|
...e,
|
|
@@ -1053,13 +1023,13 @@ var Ve = 0, He = (e) => {
|
|
|
1053
1023
|
getByName: c
|
|
1054
1024
|
};
|
|
1055
1025
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return L(
|
|
1026
|
+
function qe() {
|
|
1027
|
+
return L(Ke);
|
|
1058
1028
|
}
|
|
1059
1029
|
//#endregion
|
|
1060
1030
|
//#region src/entities/step/step.ts
|
|
1061
|
-
var
|
|
1062
|
-
let e =
|
|
1031
|
+
var Je = j("step"), Ye = I(() => {
|
|
1032
|
+
let e = Je.store({}), t = A(e, { register(e, t) {
|
|
1063
1033
|
return {
|
|
1064
1034
|
...e,
|
|
1065
1035
|
[t.step.id]: t.step
|
|
@@ -1083,45 +1053,16 @@ var Ke = j("step"), qe = I(() => {
|
|
|
1083
1053
|
indexStore: e
|
|
1084
1054
|
};
|
|
1085
1055
|
});
|
|
1086
|
-
function
|
|
1087
|
-
return L(
|
|
1056
|
+
function Xe() {
|
|
1057
|
+
return L(Ye);
|
|
1088
1058
|
}
|
|
1089
|
-
function
|
|
1090
|
-
t.register(e);
|
|
1091
|
-
}
|
|
1092
|
-
//#endregion
|
|
1093
|
-
//#region src/entities/content/content.ts
|
|
1094
|
-
var Xe = j("content"), Ze = I(() => {
|
|
1095
|
-
let e = Xe.store({}), t = A(e, { register(e, t) {
|
|
1096
|
-
return {
|
|
1097
|
-
...e,
|
|
1098
|
-
[t.content.id]: t.content
|
|
1099
|
-
};
|
|
1100
|
-
} });
|
|
1101
|
-
function n(e) {
|
|
1102
|
-
t.register({ content: e });
|
|
1103
|
-
}
|
|
1104
|
-
let r = e.map((e) => Object.values(e));
|
|
1105
|
-
function i(t) {
|
|
1106
|
-
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
1107
|
-
}
|
|
1108
|
-
return {
|
|
1109
|
-
register: n,
|
|
1110
|
-
getById: i,
|
|
1111
|
-
listStore: r,
|
|
1112
|
-
indexStore: e
|
|
1113
|
-
};
|
|
1114
|
-
});
|
|
1115
|
-
function Qe() {
|
|
1116
|
-
return L(Ze);
|
|
1117
|
-
}
|
|
1118
|
-
function $e(e, t) {
|
|
1059
|
+
function Ze(e, t) {
|
|
1119
1060
|
t.register(e);
|
|
1120
1061
|
}
|
|
1121
1062
|
//#endregion
|
|
1122
1063
|
//#region src/entities/action/action.ts
|
|
1123
|
-
var
|
|
1124
|
-
let t =
|
|
1064
|
+
var Qe = j("action"), $e = I(({ client: e }) => {
|
|
1065
|
+
let t = Qe.store({}), n = A(t, { register(e, t) {
|
|
1125
1066
|
return {
|
|
1126
1067
|
...e,
|
|
1127
1068
|
[t.key]: {
|
|
@@ -1179,10 +1120,10 @@ var et = j("action"), tt = I(({ client: e }) => {
|
|
|
1179
1120
|
getEvokableAction: s
|
|
1180
1121
|
};
|
|
1181
1122
|
});
|
|
1182
|
-
function
|
|
1183
|
-
return L(
|
|
1123
|
+
function et(e) {
|
|
1124
|
+
return L($e, e);
|
|
1184
1125
|
}
|
|
1185
|
-
var
|
|
1126
|
+
var tt = (e, t, n) => {
|
|
1186
1127
|
n.register({
|
|
1187
1128
|
key: e,
|
|
1188
1129
|
action: t
|
|
@@ -1190,7 +1131,7 @@ var rt = (e, t, n) => {
|
|
|
1190
1131
|
};
|
|
1191
1132
|
//#endregion
|
|
1192
1133
|
//#region src/entities/response/response-validation.ts
|
|
1193
|
-
function
|
|
1134
|
+
function Y(e, t, n, r) {
|
|
1194
1135
|
return {
|
|
1195
1136
|
fieldKey: e.key,
|
|
1196
1137
|
userMessage: n,
|
|
@@ -1198,62 +1139,62 @@ function Z(e, t, n, r) {
|
|
|
1198
1139
|
value: t
|
|
1199
1140
|
};
|
|
1200
1141
|
}
|
|
1201
|
-
function
|
|
1142
|
+
function X(e) {
|
|
1202
1143
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1203
1144
|
}
|
|
1204
|
-
function
|
|
1145
|
+
function nt(e) {
|
|
1205
1146
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1206
1147
|
}
|
|
1207
|
-
function
|
|
1148
|
+
function Z(e) {
|
|
1208
1149
|
try {
|
|
1209
1150
|
return JSON.stringify(e), !0;
|
|
1210
1151
|
} catch {
|
|
1211
1152
|
return !1;
|
|
1212
1153
|
}
|
|
1213
1154
|
}
|
|
1214
|
-
function
|
|
1155
|
+
function rt(e, t) {
|
|
1215
1156
|
return t.find((t) => t.key === e) ?? null;
|
|
1216
1157
|
}
|
|
1217
|
-
function
|
|
1158
|
+
function it(e, t) {
|
|
1218
1159
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1219
1160
|
}
|
|
1220
|
-
function
|
|
1221
|
-
if (e.type !== "object" ||
|
|
1161
|
+
function at(e, t) {
|
|
1162
|
+
if (e.type !== "object" || X(t)) return null;
|
|
1222
1163
|
if (e.multiple) {
|
|
1223
|
-
if (!Array.isArray(t)) return
|
|
1164
|
+
if (!Array.isArray(t)) return Y(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1224
1165
|
for (let n of t) {
|
|
1225
|
-
if (typeof n != "object" || !n) return
|
|
1226
|
-
if (!
|
|
1166
|
+
if (typeof n != "object" || !n) return Y(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1167
|
+
if (!Z(n)) return Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1227
1168
|
}
|
|
1228
1169
|
return null;
|
|
1229
1170
|
}
|
|
1230
|
-
return Array.isArray(t) ?
|
|
1171
|
+
return Array.isArray(t) ? Y(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Y(e, t, "This field expects an object value", "Field expects an object value.") : Z(t) ? null : Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1231
1172
|
}
|
|
1232
|
-
function
|
|
1233
|
-
if (
|
|
1173
|
+
function ot(e, t) {
|
|
1174
|
+
if (X(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1234
1175
|
let n = Array.isArray(t) ? t : [t];
|
|
1235
1176
|
if (e.type === "object") {
|
|
1236
1177
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1237
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1178
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : Y(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1238
1179
|
}
|
|
1239
1180
|
let r = e.options.map((e) => e.value);
|
|
1240
|
-
return n.every((e) => !
|
|
1181
|
+
return n.every((e) => !nt(e) || e === null ? !1 : r.includes(e)) ? null : Y(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1241
1182
|
}
|
|
1242
|
-
async function
|
|
1243
|
-
if (n.validation && !e(n.validation) && !
|
|
1183
|
+
async function st(t, n, r, i) {
|
|
1184
|
+
if (n.validation && !e(n.validation) && !X(r)) {
|
|
1244
1185
|
let e = i ? {
|
|
1245
1186
|
$input: r,
|
|
1246
1187
|
responses: i
|
|
1247
1188
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1248
|
-
if (typeof a == "string") return
|
|
1249
|
-
if (a === !1) return
|
|
1189
|
+
if (typeof a == "string") return Y(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1190
|
+
if (a === !1) return Y(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
1250
1191
|
}
|
|
1251
|
-
return n.required &&
|
|
1192
|
+
return n.required && X(r) ? Y(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Y(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
1252
1193
|
}
|
|
1253
1194
|
//#endregion
|
|
1254
1195
|
//#region src/entities/response/response.ts
|
|
1255
|
-
var
|
|
1256
|
-
let t =
|
|
1196
|
+
var ct = j("response"), lt = I(({ client: e }) => {
|
|
1197
|
+
let t = ct.store({}), r = N(), i = N(), a = A(t, {
|
|
1257
1198
|
register(e, t) {
|
|
1258
1199
|
return {
|
|
1259
1200
|
...e,
|
|
@@ -1292,7 +1233,7 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1292
1233
|
...t,
|
|
1293
1234
|
...n
|
|
1294
1235
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1295
|
-
let o =
|
|
1236
|
+
let o = rt(t, e);
|
|
1296
1237
|
if (!o) {
|
|
1297
1238
|
r.push({
|
|
1298
1239
|
fieldKey: t,
|
|
@@ -1302,17 +1243,17 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1302
1243
|
});
|
|
1303
1244
|
return;
|
|
1304
1245
|
}
|
|
1305
|
-
let c =
|
|
1246
|
+
let c = it(o, n), l = await st(s, o, c, a);
|
|
1306
1247
|
if (l) {
|
|
1307
1248
|
r.push(l);
|
|
1308
1249
|
return;
|
|
1309
1250
|
}
|
|
1310
|
-
let u =
|
|
1251
|
+
let u = at(o, c);
|
|
1311
1252
|
if (u) {
|
|
1312
1253
|
r.push(u);
|
|
1313
1254
|
return;
|
|
1314
1255
|
}
|
|
1315
|
-
let d =
|
|
1256
|
+
let d = ot(o, c);
|
|
1316
1257
|
if (d) {
|
|
1317
1258
|
r.push(d);
|
|
1318
1259
|
return;
|
|
@@ -1391,13 +1332,13 @@ var dt = j("response"), ft = I(({ client: e }) => {
|
|
|
1391
1332
|
getByFieldName: _
|
|
1392
1333
|
};
|
|
1393
1334
|
});
|
|
1394
|
-
function
|
|
1395
|
-
return L(
|
|
1335
|
+
function ut(e) {
|
|
1336
|
+
return L(lt, e);
|
|
1396
1337
|
}
|
|
1397
1338
|
//#endregion
|
|
1398
1339
|
//#region src/entities/condition/condition.ts
|
|
1399
|
-
var
|
|
1400
|
-
let e =
|
|
1340
|
+
var dt = j("condition"), ft = I(() => {
|
|
1341
|
+
let e = dt.store({}), t = A(e, { register(e, t) {
|
|
1401
1342
|
return {
|
|
1402
1343
|
...e,
|
|
1403
1344
|
[t.condition.id]: t.condition
|
|
@@ -1421,12 +1362,12 @@ var mt = j("condition"), ht = I(() => {
|
|
|
1421
1362
|
indexStore: e
|
|
1422
1363
|
};
|
|
1423
1364
|
});
|
|
1424
|
-
function
|
|
1425
|
-
return L(
|
|
1365
|
+
function pt() {
|
|
1366
|
+
return L(ft);
|
|
1426
1367
|
}
|
|
1427
1368
|
//#endregion
|
|
1428
1369
|
//#region src/utils/api-url.ts
|
|
1429
|
-
function
|
|
1370
|
+
function mt() {
|
|
1430
1371
|
if (f()) {
|
|
1431
1372
|
let e = [
|
|
1432
1373
|
document.currentScript,
|
|
@@ -1441,7 +1382,7 @@ function _t() {
|
|
|
1441
1382
|
}
|
|
1442
1383
|
//#endregion
|
|
1443
1384
|
//#region src/utils/search-params.ts
|
|
1444
|
-
function
|
|
1385
|
+
function ht() {
|
|
1445
1386
|
if (!o()) return {};
|
|
1446
1387
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1447
1388
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1459,13 +1400,13 @@ function vt() {
|
|
|
1459
1400
|
}
|
|
1460
1401
|
//#endregion
|
|
1461
1402
|
//#region src/entities/session/session.ts
|
|
1462
|
-
var
|
|
1463
|
-
function
|
|
1403
|
+
var Q = E("session", "global");
|
|
1404
|
+
function gt() {
|
|
1464
1405
|
return l() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1465
1406
|
}
|
|
1466
|
-
function
|
|
1407
|
+
function _t() {
|
|
1467
1408
|
if (!u()) return null;
|
|
1468
|
-
let e = w.get(
|
|
1409
|
+
let e = w.get(Q);
|
|
1469
1410
|
if (!e.isSet()) return null;
|
|
1470
1411
|
try {
|
|
1471
1412
|
return e.json();
|
|
@@ -1473,8 +1414,8 @@ function xt() {
|
|
|
1473
1414
|
return null;
|
|
1474
1415
|
}
|
|
1475
1416
|
}
|
|
1476
|
-
var
|
|
1477
|
-
let e =
|
|
1417
|
+
var vt = I(() => {
|
|
1418
|
+
let e = _t(), t = { id: e?.id ?? gt() };
|
|
1478
1419
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1479
1420
|
let n = P(t), r = A(n, {
|
|
1480
1421
|
setIsUser: (e, t) => ({
|
|
@@ -1503,7 +1444,7 @@ var St = I(() => {
|
|
|
1503
1444
|
source: n,
|
|
1504
1445
|
effect: (e) => {
|
|
1505
1446
|
if (u()) try {
|
|
1506
|
-
w.get(
|
|
1447
|
+
w.get(Q).set(e);
|
|
1507
1448
|
} catch {}
|
|
1508
1449
|
}
|
|
1509
1450
|
})
|
|
@@ -1514,27 +1455,27 @@ var St = I(() => {
|
|
|
1514
1455
|
removeIdentifier: r.removeIdentifier
|
|
1515
1456
|
};
|
|
1516
1457
|
});
|
|
1517
|
-
function
|
|
1518
|
-
return L(
|
|
1458
|
+
function yt() {
|
|
1459
|
+
return L(vt, void 0);
|
|
1519
1460
|
}
|
|
1520
1461
|
//#endregion
|
|
1521
1462
|
//#region src/utils/picked-config.ts
|
|
1522
|
-
function
|
|
1463
|
+
function bt() {
|
|
1523
1464
|
if (o()) return globalThis.window.pickedConfig;
|
|
1524
1465
|
}
|
|
1525
|
-
function
|
|
1526
|
-
if (o()) return
|
|
1466
|
+
function xt() {
|
|
1467
|
+
if (o()) return bt()?.projectId;
|
|
1527
1468
|
}
|
|
1528
|
-
function
|
|
1469
|
+
function St() {
|
|
1529
1470
|
if (!f()) return;
|
|
1530
1471
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1531
1472
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1532
1473
|
}
|
|
1533
|
-
function
|
|
1474
|
+
function Ct(e) {
|
|
1534
1475
|
if (e.projectId) return e.projectId;
|
|
1535
|
-
let t =
|
|
1476
|
+
let t = xt();
|
|
1536
1477
|
if (t) return t;
|
|
1537
|
-
let n =
|
|
1478
|
+
let n = St();
|
|
1538
1479
|
if (n) return n;
|
|
1539
1480
|
throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
|
|
1540
1481
|
}
|
|
@@ -1543,7 +1484,7 @@ function Dt(e) {
|
|
|
1543
1484
|
function $(e) {
|
|
1544
1485
|
return e == null || e === "" || Number.isNaN(e);
|
|
1545
1486
|
}
|
|
1546
|
-
var
|
|
1487
|
+
var wt = {
|
|
1547
1488
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1548
1489
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1549
1490
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1564,24 +1505,24 @@ var Ot = {
|
|
|
1564
1505
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1565
1506
|
}
|
|
1566
1507
|
};
|
|
1567
|
-
function
|
|
1508
|
+
function Tt(e) {
|
|
1568
1509
|
return typeof e == "object" && !!e;
|
|
1569
1510
|
}
|
|
1570
|
-
function
|
|
1511
|
+
function Et(e, t) {
|
|
1571
1512
|
let n = t;
|
|
1572
|
-
for (let t of e.split(".")) if (
|
|
1513
|
+
for (let t of e.split(".")) if (Tt(n) && t in n) n = n[t];
|
|
1573
1514
|
else return;
|
|
1574
1515
|
return typeof n == "function" ? n() : n;
|
|
1575
1516
|
}
|
|
1576
|
-
function
|
|
1577
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1517
|
+
function Dt(e, t) {
|
|
1518
|
+
let n = e.split("|").map((e) => e.trim()), r = Et(n.shift() ?? "", t);
|
|
1578
1519
|
for (let e of n) {
|
|
1579
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1520
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = wt[i];
|
|
1580
1521
|
o && (r = o(r, a));
|
|
1581
1522
|
}
|
|
1582
1523
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1583
1524
|
}
|
|
1584
|
-
function
|
|
1525
|
+
function Ot(e, t) {
|
|
1585
1526
|
let n = "", r = 0;
|
|
1586
1527
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1587
1528
|
r += 2;
|
|
@@ -1593,17 +1534,15 @@ function Mt(e, t) {
|
|
|
1593
1534
|
}
|
|
1594
1535
|
i += e[r++];
|
|
1595
1536
|
}
|
|
1596
|
-
n +=
|
|
1537
|
+
n += Dt(i.trim(), t);
|
|
1597
1538
|
} else n += e[r++];
|
|
1598
1539
|
return n;
|
|
1599
1540
|
}
|
|
1600
1541
|
//#endregion
|
|
1601
1542
|
//#region src/picked.ts
|
|
1602
|
-
var
|
|
1543
|
+
var kt = class {
|
|
1603
1544
|
static logger = r;
|
|
1604
1545
|
options;
|
|
1605
|
-
dataSource = null;
|
|
1606
|
-
contentLoader;
|
|
1607
1546
|
plugins = {};
|
|
1608
1547
|
eventBus = N();
|
|
1609
1548
|
events;
|
|
@@ -1611,62 +1550,61 @@ var Nt = class {
|
|
|
1611
1550
|
apiUrl;
|
|
1612
1551
|
dashboardUrl;
|
|
1613
1552
|
documentationSiteUrl;
|
|
1614
|
-
session =
|
|
1615
|
-
searchParams =
|
|
1616
|
-
history =
|
|
1617
|
-
components =
|
|
1618
|
-
experienceInstances =
|
|
1619
|
-
experiences =
|
|
1620
|
-
frameworks =
|
|
1621
|
-
predicates =
|
|
1622
|
-
features =
|
|
1623
|
-
conditions =
|
|
1624
|
-
fields =
|
|
1625
|
-
responses =
|
|
1626
|
-
steps =
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
evaluateRuleLogicFx = Te({ client: this });
|
|
1553
|
+
session = yt();
|
|
1554
|
+
searchParams = ht();
|
|
1555
|
+
history = He();
|
|
1556
|
+
components = he({ client: this });
|
|
1557
|
+
experienceInstances = b({ client: this });
|
|
1558
|
+
experiences = se({ client: this });
|
|
1559
|
+
frameworks = ye({ client: this });
|
|
1560
|
+
predicates = Fe({ client: this });
|
|
1561
|
+
features = ze({ client: this });
|
|
1562
|
+
conditions = pt();
|
|
1563
|
+
fields = qe();
|
|
1564
|
+
responses = ut({ client: this });
|
|
1565
|
+
steps = Xe();
|
|
1566
|
+
actions = et({ client: this });
|
|
1567
|
+
stateSnapshotStore = Se({ client: this });
|
|
1568
|
+
evaluateRuleLogicFx = De({ client: this });
|
|
1631
1569
|
start;
|
|
1632
1570
|
readyStore;
|
|
1633
1571
|
preconditionPassedStore;
|
|
1634
1572
|
conditionPassedStore;
|
|
1635
1573
|
lifecycleStageStore;
|
|
1636
|
-
lifecycle =
|
|
1574
|
+
lifecycle = Me({ client: this });
|
|
1637
1575
|
renderStringFx = O({
|
|
1638
1576
|
source: this.responses.listStore,
|
|
1639
1577
|
effect: (e, { template: t, context: n }) => {
|
|
1640
1578
|
let r = {};
|
|
1641
1579
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1642
|
-
return
|
|
1580
|
+
return Ot(t, {
|
|
1643
1581
|
...n,
|
|
1644
1582
|
responses: r
|
|
1645
1583
|
});
|
|
1646
1584
|
}
|
|
1647
1585
|
});
|
|
1648
1586
|
constructor(e) {
|
|
1649
|
-
this.events =
|
|
1587
|
+
this.events = We(this.eventBus), this.projectId = Ct(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
|
|
1650
1588
|
type: "load",
|
|
1651
1589
|
version: te()
|
|
1652
1590
|
});
|
|
1653
1591
|
}
|
|
1654
1592
|
registerFramework = (e) => {
|
|
1655
|
-
|
|
1593
|
+
be(e, this.frameworks);
|
|
1656
1594
|
};
|
|
1657
1595
|
registerComponent = (e, t) => {
|
|
1658
|
-
|
|
1596
|
+
ge(e, t, this.components);
|
|
1659
1597
|
};
|
|
1660
1598
|
registerPlugin = (e) => {
|
|
1661
|
-
|
|
1599
|
+
ue(this, e, this.plugins);
|
|
1662
1600
|
let t = this.plugins[e.name];
|
|
1663
1601
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1664
1602
|
};
|
|
1665
1603
|
registerFeature = (e, t) => {
|
|
1666
|
-
|
|
1604
|
+
Be(e, t, this.features);
|
|
1667
1605
|
};
|
|
1668
1606
|
registerPredicate = (e, t) => {
|
|
1669
|
-
|
|
1607
|
+
Ie(e, t, this.predicates);
|
|
1670
1608
|
};
|
|
1671
1609
|
registerCondition = (e) => {
|
|
1672
1610
|
this.conditions.register(e);
|
|
@@ -1675,16 +1613,13 @@ var Nt = class {
|
|
|
1675
1613
|
this.fields.register(e);
|
|
1676
1614
|
};
|
|
1677
1615
|
registerStep = (e) => {
|
|
1678
|
-
|
|
1679
|
-
};
|
|
1680
|
-
registerContent = (e) => {
|
|
1681
|
-
$e(e, this.contents);
|
|
1616
|
+
Ze(e, this.steps);
|
|
1682
1617
|
};
|
|
1683
1618
|
registerAction = (e, t) => {
|
|
1684
|
-
|
|
1619
|
+
tt(e, t, this.actions);
|
|
1685
1620
|
};
|
|
1686
1621
|
registerExperience = (e) => {
|
|
1687
|
-
e.component &&
|
|
1622
|
+
e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1688
1623
|
};
|
|
1689
1624
|
launchExperienceById = async (e, t) => {
|
|
1690
1625
|
this.experiences.launch({
|
|
@@ -1769,20 +1704,20 @@ var Nt = class {
|
|
|
1769
1704
|
};
|
|
1770
1705
|
//#endregion
|
|
1771
1706
|
//#region src/entities/component/lazyComponent.ts
|
|
1772
|
-
function
|
|
1707
|
+
function At(e) {
|
|
1773
1708
|
return {
|
|
1774
1709
|
$$type: "lazy-component",
|
|
1775
1710
|
load: e
|
|
1776
1711
|
};
|
|
1777
1712
|
}
|
|
1778
|
-
function
|
|
1713
|
+
function jt(e) {
|
|
1779
1714
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1780
1715
|
}
|
|
1781
1716
|
//#endregion
|
|
1782
1717
|
//#region src/exports.ts
|
|
1783
|
-
var
|
|
1784
|
-
let t = new
|
|
1718
|
+
var Mt = (e) => {
|
|
1719
|
+
let t = new kt(e);
|
|
1785
1720
|
return d(t), t;
|
|
1786
1721
|
};
|
|
1787
1722
|
//#endregion
|
|
1788
|
-
export {
|
|
1723
|
+
export { kt as Picked, Mt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, bt as getPickedConfig, jt as isLazyLoader, _ as isPickedRoot, At as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
|