@picked/client 0.0.1-dev.1778212587319 → 0.0.1-dev.1778467244607
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-Cz_3UuGL.cjs → api-CF5VqlzY.cjs} +1 -1
- package/dist/{api-Cwiixs03.js → api-DWGhvwuG.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +346 -366
- package/dist/esm/plugins/dynamic-experiences/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +10 -26
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-dwfbKgOd.js → experience-instance-BrLWgVAN.js} +179 -178
- package/dist/experience-instance-Ct3ogC7n.cjs +1 -0
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +16 -28
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/picked.d.ts +14 -8
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -19
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-DDZR8zjM.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,15 +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, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-
|
|
5
|
+
import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
|
|
6
6
|
import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
|
|
7
|
-
import { n as D, r as te } from "../api-
|
|
8
|
-
import { t as
|
|
9
|
-
import { attach as
|
|
10
|
-
import { createFactory as
|
|
7
|
+
import { n as D, r as te } from "../api-DWGhvwuG.js";
|
|
8
|
+
import { t as ne } from "../id-CRqy981z.js";
|
|
9
|
+
import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
|
|
10
|
+
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var
|
|
13
|
-
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) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
16
16
|
...t.experience
|
|
@@ -20,7 +20,7 @@ var ne = M("experience"), re = L(({ client: e, experience: r }) => {
|
|
|
20
20
|
decisionLogic: e.condition,
|
|
21
21
|
targetSelectors: e.targets,
|
|
22
22
|
initializeOpenLogic: e.initializeOpen
|
|
23
|
-
})), s =
|
|
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) => {
|
|
24
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);
|
|
25
25
|
return {
|
|
26
26
|
steps: r,
|
|
@@ -28,7 +28,7 @@ var ne = M("experience"), re = L(({ client: e, experience: r }) => {
|
|
|
28
28
|
edges: e.edges,
|
|
29
29
|
conditions: i
|
|
30
30
|
};
|
|
31
|
-
}), l = r.actions ?? [], u, d =
|
|
31
|
+
}), l = r.actions ?? [], u, d = O({
|
|
32
32
|
source: o,
|
|
33
33
|
effect: (t, n) => {
|
|
34
34
|
let i = S(t.targetSelectors, r.id);
|
|
@@ -36,8 +36,8 @@ var ne = M("experience"), re = L(({ client: e, experience: r }) => {
|
|
|
36
36
|
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
}), f =
|
|
40
|
-
source:
|
|
39
|
+
}), f = O({
|
|
40
|
+
source: k({
|
|
41
41
|
preconditionPassed: e.preconditionPassedStore,
|
|
42
42
|
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
43
43
|
config: o
|
|
@@ -61,22 +61,22 @@ var ne = M("experience"), re = L(({ client: e, experience: r }) => {
|
|
|
61
61
|
shouldInitialiseFx: f
|
|
62
62
|
}, u;
|
|
63
63
|
});
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function ae(e) {
|
|
65
|
+
return L(ie, e);
|
|
66
66
|
}
|
|
67
|
-
var
|
|
68
|
-
let t =
|
|
67
|
+
var oe = I(({ client: e }) => {
|
|
68
|
+
let t = re.store({}), n = A(t, { register(e, t) {
|
|
69
69
|
return {
|
|
70
70
|
...e,
|
|
71
71
|
[t.id]: t
|
|
72
72
|
};
|
|
73
|
-
} }), r =
|
|
74
|
-
n.register(
|
|
73
|
+
} }), r = N(), i = M((t) => {
|
|
74
|
+
n.register(ae({
|
|
75
75
|
client: e,
|
|
76
76
|
experience: t
|
|
77
77
|
}));
|
|
78
78
|
});
|
|
79
|
-
|
|
79
|
+
F({
|
|
80
80
|
clock: r,
|
|
81
81
|
source: t,
|
|
82
82
|
filter: (e, t) => e[t.id] !== void 0,
|
|
@@ -89,7 +89,7 @@ var ae = L(({ client: e }) => {
|
|
|
89
89
|
experience: t,
|
|
90
90
|
strategy: "override"
|
|
91
91
|
});
|
|
92
|
-
}),
|
|
92
|
+
}), F({
|
|
93
93
|
clock: r,
|
|
94
94
|
source: t,
|
|
95
95
|
filter: (e, t) => e[t.id] === void 0,
|
|
@@ -103,7 +103,7 @@ var ae = L(({ client: e }) => {
|
|
|
103
103
|
function s(e) {
|
|
104
104
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
105
105
|
}
|
|
106
|
-
let c =
|
|
106
|
+
let c = O({
|
|
107
107
|
source: t,
|
|
108
108
|
effect: async (e, t) => {
|
|
109
109
|
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
@@ -125,7 +125,7 @@ var ae = L(({ client: e }) => {
|
|
|
125
125
|
getById: o,
|
|
126
126
|
getByKey: s,
|
|
127
127
|
launch: c,
|
|
128
|
-
open:
|
|
128
|
+
open: O({
|
|
129
129
|
source: {
|
|
130
130
|
experiences: t,
|
|
131
131
|
instances: e.experienceInstances.listStore
|
|
@@ -152,7 +152,7 @@ var ae = L(({ client: e }) => {
|
|
|
152
152
|
}
|
|
153
153
|
}),
|
|
154
154
|
listStore: a,
|
|
155
|
-
initialiseExperiencesFx:
|
|
155
|
+
initialiseExperiencesFx: O({
|
|
156
156
|
source: a,
|
|
157
157
|
effect: async (e) => {
|
|
158
158
|
await Promise.all(e.map(async (e) => {
|
|
@@ -162,20 +162,20 @@ var ae = L(({ client: e }) => {
|
|
|
162
162
|
})
|
|
163
163
|
};
|
|
164
164
|
});
|
|
165
|
-
function
|
|
166
|
-
return
|
|
165
|
+
function se(e) {
|
|
166
|
+
return L(oe, e);
|
|
167
167
|
}
|
|
168
|
-
var
|
|
168
|
+
var ce = async (e) => {
|
|
169
169
|
await e.experiences.initialiseExperiencesFx();
|
|
170
170
|
};
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/entities/plugin/plugin.ts
|
|
173
|
-
function
|
|
174
|
-
return
|
|
173
|
+
function le(e) {
|
|
174
|
+
return M(async () => {
|
|
175
175
|
await e();
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
var
|
|
178
|
+
var ue = (e, t, n) => {
|
|
179
179
|
let r = t.name, i = t.setup(e);
|
|
180
180
|
if (i) {
|
|
181
181
|
let e = n[r] ?? {};
|
|
@@ -184,29 +184,29 @@ var le = (e, t, n) => {
|
|
|
184
184
|
...i
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
},
|
|
187
|
+
}, de = j("component"), fe = I(({ client: e, component: t, name: n }) => ({
|
|
188
188
|
name: n,
|
|
189
189
|
component: t,
|
|
190
190
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
191
191
|
}));
|
|
192
|
-
function
|
|
193
|
-
return
|
|
192
|
+
function pe(e) {
|
|
193
|
+
return L(fe, e);
|
|
194
194
|
}
|
|
195
|
-
var
|
|
196
|
-
let t =
|
|
195
|
+
var me = I(({ client: e }) => {
|
|
196
|
+
let t = de.store({}), n = A(t, { register(e, t) {
|
|
197
197
|
return {
|
|
198
198
|
...e,
|
|
199
199
|
[t.name]: t
|
|
200
200
|
};
|
|
201
|
-
} }), i =
|
|
202
|
-
|
|
201
|
+
} }), i = N();
|
|
202
|
+
F({
|
|
203
203
|
clock: i,
|
|
204
204
|
source: t,
|
|
205
205
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
206
206
|
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
207
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
207
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
208
208
|
clock: i,
|
|
209
|
-
fn: ({ name: t, component: n }) =>
|
|
209
|
+
fn: ({ name: t, component: n }) => pe({
|
|
210
210
|
client: e,
|
|
211
211
|
name: t,
|
|
212
212
|
component: n
|
|
@@ -223,27 +223,27 @@ var pe = L(({ client: e }) => {
|
|
|
223
223
|
listStore: a
|
|
224
224
|
};
|
|
225
225
|
});
|
|
226
|
-
function
|
|
227
|
-
return
|
|
226
|
+
function he(e) {
|
|
227
|
+
return L(me, e);
|
|
228
228
|
}
|
|
229
|
-
var
|
|
229
|
+
var ge = (e, t, n) => {
|
|
230
230
|
n.register({
|
|
231
231
|
name: e,
|
|
232
232
|
component: t
|
|
233
233
|
});
|
|
234
|
-
},
|
|
235
|
-
let t =
|
|
234
|
+
}, _e = j("framework"), ve = I((e) => {
|
|
235
|
+
let t = _e.store({}), n = A(t, { register(e, t) {
|
|
236
236
|
return {
|
|
237
237
|
...e,
|
|
238
238
|
[t.name]: t.framework
|
|
239
239
|
};
|
|
240
|
-
} }), i =
|
|
241
|
-
|
|
240
|
+
} }), i = N();
|
|
241
|
+
F({
|
|
242
242
|
clock: i,
|
|
243
243
|
source: t,
|
|
244
244
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
245
245
|
fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
|
|
246
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
246
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
247
247
|
clock: i,
|
|
248
248
|
target: n.register
|
|
249
249
|
});
|
|
@@ -257,106 +257,106 @@ var he = (e, t, n) => {
|
|
|
257
257
|
listStore: a
|
|
258
258
|
};
|
|
259
259
|
});
|
|
260
|
-
function
|
|
261
|
-
return
|
|
260
|
+
function ye(e) {
|
|
261
|
+
return L(ve, e);
|
|
262
262
|
}
|
|
263
|
-
var
|
|
263
|
+
var be = (e, t) => {
|
|
264
264
|
t.register({
|
|
265
265
|
name: e.name,
|
|
266
266
|
framework: e
|
|
267
267
|
});
|
|
268
|
-
},
|
|
268
|
+
}, xe = I(({ client: e }) => {
|
|
269
269
|
let t = typeof window < "u", n = {
|
|
270
270
|
location: t ? window.location : void 0,
|
|
271
271
|
document: t ? window.document : void 0,
|
|
272
272
|
sessionStorage: t ? window.sessionStorage : void 0,
|
|
273
273
|
localStorage: t ? window.localStorage : void 0
|
|
274
274
|
};
|
|
275
|
-
return
|
|
275
|
+
return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
276
276
|
client: e,
|
|
277
277
|
responses: t,
|
|
278
278
|
fields: r,
|
|
279
279
|
...n
|
|
280
280
|
}));
|
|
281
281
|
});
|
|
282
|
-
function
|
|
283
|
-
return
|
|
282
|
+
function Se(e) {
|
|
283
|
+
return L(xe, e);
|
|
284
284
|
}
|
|
285
285
|
//#endregion
|
|
286
286
|
//#region src/logic-engine.ts
|
|
287
|
-
function
|
|
287
|
+
function Ce(e) {
|
|
288
288
|
return typeof e == "number" && !isNaN(e);
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function R(e) {
|
|
291
291
|
return typeof e == "string";
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function z(e) {
|
|
294
294
|
return Array.isArray(e);
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function B(e) {
|
|
297
297
|
return e instanceof Promise;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function V(e) {
|
|
300
300
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
301
301
|
}
|
|
302
|
-
function
|
|
303
|
-
if (
|
|
302
|
+
function H(e) {
|
|
303
|
+
if (Ce(e)) return e;
|
|
304
304
|
let t = parseFloat(`${e}`);
|
|
305
305
|
return isNaN(t) ? 0 : t;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function U(e) {
|
|
308
308
|
return `${e}`;
|
|
309
309
|
}
|
|
310
|
-
var
|
|
310
|
+
var we = {
|
|
311
311
|
"==": (e, t) => e == t,
|
|
312
312
|
"===": (e, t) => e === t,
|
|
313
313
|
"!=": (e, t) => e != t,
|
|
314
314
|
"!==": (e, t) => e !== t,
|
|
315
|
-
">": (e, t) =>
|
|
316
|
-
">=": (e, t) =>
|
|
315
|
+
">": (e, t) => H(e) > H(t),
|
|
316
|
+
">=": (e, t) => H(e) >= H(t),
|
|
317
317
|
"<": (e, t, n) => {
|
|
318
|
-
let r =
|
|
318
|
+
let r = H(e), i = H(t);
|
|
319
319
|
if (n === void 0) return r < i;
|
|
320
|
-
let a =
|
|
320
|
+
let a = H(n);
|
|
321
321
|
return r < i && i < a;
|
|
322
322
|
},
|
|
323
323
|
"<=": (e, t, n) => {
|
|
324
|
-
let r =
|
|
324
|
+
let r = H(e), i = H(t);
|
|
325
325
|
if (n === void 0) return r <= i;
|
|
326
|
-
let a =
|
|
326
|
+
let a = H(n);
|
|
327
327
|
return r <= i && i <= a;
|
|
328
328
|
},
|
|
329
|
-
"!!": async (e) => await
|
|
330
|
-
"!": async (e) => !await
|
|
331
|
-
"%": (e, t) =>
|
|
329
|
+
"!!": async (e) => await G(e),
|
|
330
|
+
"!": async (e) => !await G(e),
|
|
331
|
+
"%": (e, t) => H(e) % H(t),
|
|
332
332
|
log: (e) => (console.log(e), e),
|
|
333
|
-
in: (e, t) => t ?
|
|
334
|
-
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(""),
|
|
335
335
|
substr: (e, t, n) => {
|
|
336
|
-
let r =
|
|
336
|
+
let r = U(e), i = H(t);
|
|
337
337
|
if (n === void 0) return r.substr(i);
|
|
338
|
-
let a =
|
|
338
|
+
let a = H(n);
|
|
339
339
|
if (a < 0) {
|
|
340
340
|
let e = r.substr(i);
|
|
341
341
|
return e.substr(0, e.length + a);
|
|
342
342
|
}
|
|
343
343
|
return r.substr(i, a);
|
|
344
344
|
},
|
|
345
|
-
"+": (...e) => e.reduce((e, t) =>
|
|
346
|
-
"*": (...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),
|
|
347
347
|
"-": (e, t) => {
|
|
348
|
-
let n =
|
|
349
|
-
return t === void 0 ? -n : n -
|
|
348
|
+
let n = H(e);
|
|
349
|
+
return t === void 0 ? -n : n - H(t);
|
|
350
350
|
},
|
|
351
|
-
"/": (e, t) =>
|
|
352
|
-
min: (...e) => Math.min(...e.map(
|
|
353
|
-
max: (...e) => Math.max(...e.map(
|
|
354
|
-
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]), []),
|
|
355
355
|
var(e, t) {
|
|
356
356
|
let n = arguments.length > 1 ? t : null;
|
|
357
357
|
if (e === "" || e === "." || e == null) return this;
|
|
358
358
|
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
359
|
-
let r =
|
|
359
|
+
let r = U(e);
|
|
360
360
|
if (r === "" || r === ".") return this;
|
|
361
361
|
let i = r.split("."), a = this;
|
|
362
362
|
for (let e of i) {
|
|
@@ -369,116 +369,116 @@ var Ce = {
|
|
|
369
369
|
return a === void 0 ? n : a;
|
|
370
370
|
},
|
|
371
371
|
async missing(...e) {
|
|
372
|
-
let t =
|
|
372
|
+
let t = z(e[0]) ? e[0] : e, n = [];
|
|
373
373
|
for (let e of t) {
|
|
374
|
-
let t = await
|
|
374
|
+
let t = await W({ var: e }, this);
|
|
375
375
|
(t === null || t === "") && n.push(`${e}`);
|
|
376
376
|
}
|
|
377
377
|
return n;
|
|
378
378
|
},
|
|
379
379
|
async missing_some(e, t) {
|
|
380
|
-
let n = await
|
|
381
|
-
if (!
|
|
382
|
-
let r = n.filter(
|
|
383
|
-
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;
|
|
384
384
|
},
|
|
385
385
|
invoke(...e) {
|
|
386
386
|
let [t, ...n] = e;
|
|
387
387
|
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
388
388
|
},
|
|
389
|
-
startsWith: (e, t) =>
|
|
390
|
-
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),
|
|
391
391
|
regexp_matches(e, t) {
|
|
392
392
|
let n = e, r = "";
|
|
393
|
-
if (
|
|
393
|
+
if (z(e)) {
|
|
394
394
|
let [t, i] = e;
|
|
395
395
|
n = t, r = i;
|
|
396
396
|
}
|
|
397
|
-
return !
|
|
397
|
+
return !R(n) || !R(r) ? !1 : new RegExp(n, r).test(U(t));
|
|
398
398
|
},
|
|
399
399
|
throw(e) {
|
|
400
|
-
throw Error(
|
|
400
|
+
throw Error(U(e));
|
|
401
401
|
}
|
|
402
402
|
};
|
|
403
|
-
async function
|
|
403
|
+
async function W(e, t) {
|
|
404
404
|
if (!e) return e;
|
|
405
|
-
if (
|
|
406
|
-
if (
|
|
407
|
-
if (!
|
|
408
|
-
let n =
|
|
409
|
-
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) {
|
|
410
410
|
case "if":
|
|
411
411
|
case "?:":
|
|
412
|
-
for (let e = 0; e < r.length - 1; e += 2) if (await
|
|
413
|
-
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;
|
|
414
414
|
case "and": {
|
|
415
415
|
let e = null;
|
|
416
|
-
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;
|
|
417
417
|
return e;
|
|
418
418
|
}
|
|
419
419
|
case "or": {
|
|
420
420
|
let e = null;
|
|
421
|
-
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;
|
|
422
422
|
return e;
|
|
423
423
|
}
|
|
424
424
|
case "map": {
|
|
425
|
-
let e = await
|
|
426
|
-
return
|
|
425
|
+
let e = await W(r[0], t);
|
|
426
|
+
return z(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
|
|
427
427
|
}
|
|
428
428
|
case "filter": {
|
|
429
|
-
let e = await
|
|
430
|
-
return
|
|
429
|
+
let e = await W(r[0], t);
|
|
430
|
+
return z(e) ? (await Promise.all(e.map(async (e) => ({
|
|
431
431
|
item: e,
|
|
432
|
-
shouldInclude: await
|
|
432
|
+
shouldInclude: await G(await W(r[1], e))
|
|
433
433
|
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
434
434
|
}
|
|
435
435
|
case "reduce": {
|
|
436
|
-
let e = await
|
|
437
|
-
if (!
|
|
438
|
-
let n = r[1], i = r.length > 2 ? await
|
|
439
|
-
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, {
|
|
440
440
|
current: t,
|
|
441
441
|
accumulator: i
|
|
442
442
|
});
|
|
443
443
|
return i;
|
|
444
444
|
}
|
|
445
445
|
case "all": {
|
|
446
|
-
let e = await
|
|
447
|
-
if (!
|
|
448
|
-
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;
|
|
449
449
|
return !0;
|
|
450
450
|
}
|
|
451
451
|
case "some": {
|
|
452
|
-
let e = await
|
|
453
|
-
if (!
|
|
454
|
-
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;
|
|
455
455
|
return !1;
|
|
456
456
|
}
|
|
457
457
|
case "none": {
|
|
458
|
-
let e = await
|
|
459
|
-
if (!
|
|
460
|
-
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;
|
|
461
461
|
return !0;
|
|
462
462
|
}
|
|
463
463
|
case "catch": try {
|
|
464
|
-
return await
|
|
464
|
+
return await W(r[0], t);
|
|
465
465
|
} catch (e) {
|
|
466
|
-
return
|
|
466
|
+
return V(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
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;
|
|
470
470
|
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
471
471
|
return a.apply(t, i);
|
|
472
472
|
}
|
|
473
|
-
async function
|
|
474
|
-
return
|
|
473
|
+
async function G(e) {
|
|
474
|
+
return B(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Te(e) {
|
|
477
477
|
return Object.keys(e)[0];
|
|
478
478
|
}
|
|
479
479
|
//#endregion
|
|
480
480
|
//#region src/lifecycle/rules-logic.ts
|
|
481
|
-
var
|
|
481
|
+
var Ee = I(({ client: e }) => O({
|
|
482
482
|
source: {
|
|
483
483
|
stateSnapshot: e.stateSnapshotStore,
|
|
484
484
|
predicates: e.predicates.listStore,
|
|
@@ -497,7 +497,7 @@ var Te = L(({ client: e }) => k({
|
|
|
497
497
|
let { bucket: e } = await t.getBucket();
|
|
498
498
|
return e;
|
|
499
499
|
}, e), {});
|
|
500
|
-
return await
|
|
500
|
+
return await W(a, {
|
|
501
501
|
responses: i,
|
|
502
502
|
location: typeof e.location == "object" ? {
|
|
503
503
|
hash: e.location.hash,
|
|
@@ -517,15 +517,15 @@ var Te = L(({ client: e }) => k({
|
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
}));
|
|
520
|
-
function
|
|
521
|
-
return
|
|
520
|
+
function De(e) {
|
|
521
|
+
return L(Ee, e);
|
|
522
522
|
}
|
|
523
523
|
//#endregion
|
|
524
524
|
//#region src/ping.ts
|
|
525
|
-
var
|
|
525
|
+
var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
526
526
|
try {
|
|
527
|
-
let t = Date.now(), n = w.get(
|
|
528
|
-
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;
|
|
529
529
|
let i = {
|
|
530
530
|
projectId: e.projectId,
|
|
531
531
|
path: window.location.pathname
|
|
@@ -536,118 +536,118 @@ var De = 6e3, Oe = E("last_ping", "global"), ke = async (e) => {
|
|
|
536
536
|
} catch {
|
|
537
537
|
return !1;
|
|
538
538
|
}
|
|
539
|
-
},
|
|
540
|
-
let t =
|
|
539
|
+
}, K = j("lifecycle"), je = I(({ client: e }) => {
|
|
540
|
+
let t = K.store(!1), r = P(void 0, {
|
|
541
541
|
skipVoid: !1,
|
|
542
|
-
domain:
|
|
543
|
-
}), i =
|
|
542
|
+
domain: K
|
|
543
|
+
}), i = P(void 0, {
|
|
544
544
|
skipVoid: !1,
|
|
545
|
-
domain:
|
|
546
|
-
}), a =
|
|
545
|
+
domain: K
|
|
546
|
+
}), a = K.store("idle"), o = K.store([]), s = P(void 0, {
|
|
547
547
|
skipVoid: !1,
|
|
548
|
-
domain:
|
|
549
|
-
}), c =
|
|
548
|
+
domain: K
|
|
549
|
+
}), c = P(void 0, {
|
|
550
550
|
skipVoid: !1,
|
|
551
|
-
domain:
|
|
552
|
-
}), l =
|
|
551
|
+
domain: K
|
|
552
|
+
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
553
553
|
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
554
|
-
let g =
|
|
555
|
-
|
|
556
|
-
}), _ =
|
|
554
|
+
let g = M(() => {
|
|
555
|
+
Ae(e);
|
|
556
|
+
}), _ = M(async () => {
|
|
557
557
|
await ee();
|
|
558
|
-
}), v =
|
|
559
|
-
await
|
|
560
|
-
}), y =
|
|
558
|
+
}), v = M(async () => {
|
|
559
|
+
await ce(e);
|
|
560
|
+
}), y = O({ effect: v }), b = O({
|
|
561
561
|
source: o,
|
|
562
562
|
effect: async (e) => {
|
|
563
563
|
for (let t of e) await t();
|
|
564
564
|
}
|
|
565
|
-
}), x =
|
|
565
|
+
}), x = O({
|
|
566
566
|
source: s,
|
|
567
567
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
568
|
-
}), S =
|
|
568
|
+
}), S = O({
|
|
569
569
|
source: c,
|
|
570
570
|
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
571
|
-
}), C =
|
|
571
|
+
}), C = F({
|
|
572
572
|
clock: l,
|
|
573
573
|
filter: () => f()
|
|
574
574
|
});
|
|
575
|
-
|
|
575
|
+
F({
|
|
576
576
|
clock: C,
|
|
577
577
|
fn: () => "starting",
|
|
578
578
|
target: a
|
|
579
|
-
}),
|
|
579
|
+
}), F({
|
|
580
580
|
clock: C,
|
|
581
581
|
target: g
|
|
582
|
-
}),
|
|
582
|
+
}), F({
|
|
583
583
|
clock: C,
|
|
584
584
|
target: b
|
|
585
|
-
}),
|
|
585
|
+
}), F({
|
|
586
586
|
clock: C,
|
|
587
587
|
target: _
|
|
588
|
-
}),
|
|
588
|
+
}), F({
|
|
589
589
|
clock: b.done,
|
|
590
590
|
target: x
|
|
591
|
-
}),
|
|
591
|
+
}), F({
|
|
592
592
|
clock: x.doneData,
|
|
593
593
|
target: r
|
|
594
|
-
}),
|
|
594
|
+
}), F({
|
|
595
595
|
clock: S.doneData,
|
|
596
596
|
target: i
|
|
597
|
-
}),
|
|
597
|
+
}), F({
|
|
598
598
|
clock: x.doneData,
|
|
599
599
|
filter: (e) => e,
|
|
600
600
|
target: S
|
|
601
|
-
}),
|
|
601
|
+
}), F({
|
|
602
602
|
clock: S.doneData,
|
|
603
603
|
target: e.session.setIsUser
|
|
604
|
-
}),
|
|
604
|
+
}), F({
|
|
605
605
|
clock: S.doneData,
|
|
606
606
|
fn: (e) => ({
|
|
607
607
|
type: "user_decide",
|
|
608
608
|
value: e
|
|
609
609
|
}),
|
|
610
610
|
target: e.eventBus
|
|
611
|
-
}),
|
|
611
|
+
}), F({
|
|
612
612
|
clock: x.doneData,
|
|
613
613
|
filter: (e) => !e,
|
|
614
614
|
fn: () => void 0,
|
|
615
615
|
target: d
|
|
616
|
-
}),
|
|
616
|
+
}), F({
|
|
617
617
|
clock: S.doneData,
|
|
618
618
|
fn: () => void 0,
|
|
619
619
|
target: d
|
|
620
|
-
}),
|
|
620
|
+
}), F({
|
|
621
621
|
clock: d,
|
|
622
622
|
fn: () => ({ type: "initialize" }),
|
|
623
623
|
target: e.eventBus
|
|
624
624
|
});
|
|
625
|
-
let w =
|
|
626
|
-
return
|
|
625
|
+
let w = P(!1).on(_.done, () => !0), T = P(!1).on(d, () => !0), E = P(!1).on(y.done, () => !0), D = k(r, i, (e, t) => e === !0 && t === !0);
|
|
626
|
+
return F({
|
|
627
627
|
clock: d,
|
|
628
628
|
source: D,
|
|
629
629
|
filter: (e) => e,
|
|
630
630
|
fn: () => void 0,
|
|
631
631
|
target: v
|
|
632
|
-
}),
|
|
633
|
-
clock:
|
|
632
|
+
}), F({
|
|
633
|
+
clock: k(w, T, D, (e, t, n) => e && t && n),
|
|
634
634
|
filter: (e) => e,
|
|
635
635
|
fn: () => void 0,
|
|
636
636
|
target: y
|
|
637
|
-
}),
|
|
638
|
-
clock:
|
|
637
|
+
}), F({
|
|
638
|
+
clock: k(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
639
639
|
filter: (e) => e,
|
|
640
640
|
fn: () => void 0,
|
|
641
641
|
target: u
|
|
642
|
-
}),
|
|
642
|
+
}), F({
|
|
643
643
|
clock: u,
|
|
644
644
|
fn: () => "ready",
|
|
645
645
|
target: a
|
|
646
|
-
}),
|
|
646
|
+
}), F({
|
|
647
647
|
clock: u,
|
|
648
648
|
fn: () => ({ type: "ready" }),
|
|
649
649
|
target: e.eventBus
|
|
650
|
-
}),
|
|
650
|
+
}), F({
|
|
651
651
|
clock: u,
|
|
652
652
|
source: e.session.store,
|
|
653
653
|
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
@@ -657,7 +657,7 @@ var De = 6e3, Oe = E("last_ping", "global"), ke = async (e) => {
|
|
|
657
657
|
identifiers: n
|
|
658
658
|
}),
|
|
659
659
|
target: e.eventBus
|
|
660
|
-
}),
|
|
660
|
+
}), F({
|
|
661
661
|
clock: [
|
|
662
662
|
b.fail,
|
|
663
663
|
x.fail,
|
|
@@ -679,13 +679,13 @@ var De = 6e3, Oe = E("last_ping", "global"), ke = async (e) => {
|
|
|
679
679
|
setCondition: h
|
|
680
680
|
};
|
|
681
681
|
});
|
|
682
|
-
function
|
|
683
|
-
return
|
|
682
|
+
function Me(e) {
|
|
683
|
+
return L(je, e);
|
|
684
684
|
}
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region src/entities/predicate/predicate.ts
|
|
687
|
-
var
|
|
688
|
-
let t =
|
|
687
|
+
var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
688
|
+
let t = Ne.store({}), n = A(t, { register(e, t) {
|
|
689
689
|
return {
|
|
690
690
|
...e,
|
|
691
691
|
[t.name]: {
|
|
@@ -693,13 +693,13 @@ var Me = M("predicate"), Ne = L(({ client: e }) => {
|
|
|
693
693
|
predicate: t.predicate
|
|
694
694
|
}
|
|
695
695
|
};
|
|
696
|
-
} }), i =
|
|
697
|
-
|
|
696
|
+
} }), i = N();
|
|
697
|
+
F({
|
|
698
698
|
clock: i,
|
|
699
699
|
source: t,
|
|
700
700
|
filter: (e, { name: t }) => e[t] !== void 0,
|
|
701
701
|
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
702
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
702
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
703
703
|
clock: i,
|
|
704
704
|
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
705
705
|
name: e,
|
|
@@ -712,7 +712,7 @@ var Me = M("predicate"), Ne = L(({ client: e }) => {
|
|
|
712
712
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
713
713
|
}
|
|
714
714
|
function s(t) {
|
|
715
|
-
let n =
|
|
715
|
+
let n = P(() => void 0, { skipVoid: !1 }), r = O({
|
|
716
716
|
source: {
|
|
717
717
|
predicate: o(t),
|
|
718
718
|
snapshot: e.stateSnapshotStore
|
|
@@ -724,13 +724,13 @@ var Me = M("predicate"), Ne = L(({ client: e }) => {
|
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
});
|
|
727
|
-
return
|
|
727
|
+
return F({
|
|
728
728
|
source: {
|
|
729
729
|
responses: e.responses.listStore,
|
|
730
730
|
fields: e.fields.listStore
|
|
731
731
|
},
|
|
732
732
|
target: r
|
|
733
|
-
}),
|
|
733
|
+
}), F({
|
|
734
734
|
clock: r.doneData,
|
|
735
735
|
filter: (e) => e !== void 0,
|
|
736
736
|
target: n
|
|
@@ -743,27 +743,27 @@ var Me = M("predicate"), Ne = L(({ client: e }) => {
|
|
|
743
743
|
getEvokablePredicate: s
|
|
744
744
|
};
|
|
745
745
|
});
|
|
746
|
-
function
|
|
747
|
-
return
|
|
746
|
+
function Fe(e) {
|
|
747
|
+
return L(Pe, e);
|
|
748
748
|
}
|
|
749
|
-
var
|
|
749
|
+
var Ie = (e, t, n) => {
|
|
750
750
|
n.register({
|
|
751
751
|
name: e,
|
|
752
752
|
predicate: t
|
|
753
753
|
});
|
|
754
|
-
},
|
|
755
|
-
let t =
|
|
754
|
+
}, Le = j("feature"), Re = I(({ client: e }) => {
|
|
755
|
+
let t = Le.store({}), n = Le.store([]), i = A(t, { register(e, t) {
|
|
756
756
|
return {
|
|
757
757
|
...e,
|
|
758
758
|
[t.id]: t.feature
|
|
759
759
|
};
|
|
760
|
-
} }), a =
|
|
761
|
-
|
|
760
|
+
} }), a = N();
|
|
761
|
+
F({
|
|
762
762
|
clock: a,
|
|
763
763
|
source: t,
|
|
764
764
|
filter: (e, { id: t }) => e[t] !== void 0,
|
|
765
765
|
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
766
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
766
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
767
767
|
clock: a,
|
|
768
768
|
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
769
769
|
id: e,
|
|
@@ -777,7 +777,7 @@ var Fe = (e, t, n) => {
|
|
|
777
777
|
}),
|
|
778
778
|
target: i.register
|
|
779
779
|
});
|
|
780
|
-
let o =
|
|
780
|
+
let o = M(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
781
781
|
let r = E(`feature:${e}:${t}`, "global"), i = (n === "session" ? T : w).get(r).boolean();
|
|
782
782
|
return i === null ? null : {
|
|
783
783
|
id: e,
|
|
@@ -785,11 +785,11 @@ var Fe = (e, t, n) => {
|
|
|
785
785
|
bucket: i,
|
|
786
786
|
storage: n
|
|
787
787
|
};
|
|
788
|
-
}), s =
|
|
788
|
+
}), s = M((e) => {
|
|
789
789
|
if (!e) return null;
|
|
790
790
|
let t = E(`feature:${e.id}:${e.key}`, "global");
|
|
791
791
|
(e.storage === "session" ? T : w).set(t, e.bucket);
|
|
792
|
-
}), c = /* @__PURE__ */ new Map(), l =
|
|
792
|
+
}), c = /* @__PURE__ */ new Map(), l = O({
|
|
793
793
|
source: {
|
|
794
794
|
allFeaturesStore: t,
|
|
795
795
|
resolvedFeaturesStore: n
|
|
@@ -820,7 +820,7 @@ var Fe = (e, t, n) => {
|
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
822
|
});
|
|
823
|
-
|
|
823
|
+
F({
|
|
824
824
|
clock: i.register,
|
|
825
825
|
fn: (e) => {
|
|
826
826
|
let { id: t, feature: n } = e;
|
|
@@ -831,7 +831,7 @@ var Fe = (e, t, n) => {
|
|
|
831
831
|
};
|
|
832
832
|
},
|
|
833
833
|
target: o
|
|
834
|
-
}),
|
|
834
|
+
}), F({
|
|
835
835
|
source: t,
|
|
836
836
|
clock: l.doneData,
|
|
837
837
|
fn: (e, t) => {
|
|
@@ -845,7 +845,7 @@ var Fe = (e, t, n) => {
|
|
|
845
845
|
},
|
|
846
846
|
target: s
|
|
847
847
|
});
|
|
848
|
-
let u =
|
|
848
|
+
let u = k({
|
|
849
849
|
allFeaturesStore: t,
|
|
850
850
|
resolvedFeaturesStore: n
|
|
851
851
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -867,7 +867,7 @@ var Fe = (e, t, n) => {
|
|
|
867
867
|
isResolved: !1
|
|
868
868
|
};
|
|
869
869
|
}));
|
|
870
|
-
|
|
870
|
+
F({
|
|
871
871
|
clock: l.doneData,
|
|
872
872
|
source: { resolvedFeatures: n },
|
|
873
873
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -876,7 +876,7 @@ var Fe = (e, t, n) => {
|
|
|
876
876
|
type: "feature_decide",
|
|
877
877
|
feature: e
|
|
878
878
|
}))
|
|
879
|
-
}),
|
|
879
|
+
}), F({
|
|
880
880
|
clock: [o.doneData, l.doneData],
|
|
881
881
|
source: n,
|
|
882
882
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -889,17 +889,17 @@ var Fe = (e, t, n) => {
|
|
|
889
889
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
890
890
|
}
|
|
891
891
|
function p(e) {
|
|
892
|
-
let t =
|
|
892
|
+
let t = P(async () => void 0, { skipVoid: !1 }), r = O({
|
|
893
893
|
source: d(e),
|
|
894
894
|
effect: async (e) => {
|
|
895
895
|
if (e) return async () => (await e.getBucket()).bucket;
|
|
896
896
|
}
|
|
897
897
|
});
|
|
898
|
-
return
|
|
898
|
+
return F({
|
|
899
899
|
source: n,
|
|
900
900
|
filter: (t) => t.some((t) => t.id === e),
|
|
901
901
|
target: r
|
|
902
|
-
}),
|
|
902
|
+
}), F({
|
|
903
903
|
clock: r.doneData,
|
|
904
904
|
filter: (e) => e !== void 0,
|
|
905
905
|
target: t
|
|
@@ -913,89 +913,69 @@ var Fe = (e, t, n) => {
|
|
|
913
913
|
getEvokableFeature: p
|
|
914
914
|
};
|
|
915
915
|
});
|
|
916
|
-
function
|
|
917
|
-
return
|
|
916
|
+
function ze(e) {
|
|
917
|
+
return L(Re, e);
|
|
918
918
|
}
|
|
919
|
-
var
|
|
919
|
+
var Be = (e, t, n) => {
|
|
920
920
|
n.register({
|
|
921
921
|
id: e,
|
|
922
922
|
feature: t
|
|
923
923
|
});
|
|
924
|
-
},
|
|
925
|
-
function
|
|
924
|
+
}, q = j("history");
|
|
925
|
+
function J(e, t) {
|
|
926
926
|
return {
|
|
927
|
-
id:
|
|
928
|
-
node:
|
|
927
|
+
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
928
|
+
node: t,
|
|
929
929
|
at: Date.now(),
|
|
930
|
-
|
|
931
|
-
experienceId: t
|
|
930
|
+
experienceId: e
|
|
932
931
|
};
|
|
933
932
|
}
|
|
934
|
-
|
|
935
|
-
let t =
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
if (!(a?.instanceId !== t || !v(a.node)) && (n += 1, n === 2)) {
|
|
948
|
-
r = i;
|
|
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);
|
|
936
|
+
function a(e, t) {
|
|
937
|
+
let n = {
|
|
938
|
+
lastStepIndex: -1,
|
|
939
|
+
secondLastStepIndex: -1
|
|
940
|
+
};
|
|
941
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
942
|
+
let i = e[r], a = i?.node;
|
|
943
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
944
|
+
else {
|
|
945
|
+
n.secondLastStepIndex = r;
|
|
949
946
|
break;
|
|
950
947
|
}
|
|
951
948
|
}
|
|
952
|
-
return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
|
|
953
|
-
}), e.on(i, (e, { snapshots: t }) => Object.values(t).flat()), e.on(o, (e, t) => [...e, ...t]);
|
|
954
|
-
let s = e.map((e) => {
|
|
955
|
-
let t = /* @__PURE__ */ new Map();
|
|
956
|
-
for (let n of e) t.set(n.experienceId, n.instanceId);
|
|
957
|
-
let n = {};
|
|
958
|
-
for (let r of e) {
|
|
959
|
-
if (t.get(r.experienceId) !== r.instanceId) continue;
|
|
960
|
-
let e = n[r.experienceId] ?? [];
|
|
961
|
-
e.push(r), n[r.experienceId] = e;
|
|
962
|
-
}
|
|
963
949
|
return n;
|
|
964
|
-
}
|
|
965
|
-
return
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
fn: (e, { instanceId: t, experienceId: n }) => ze(e[n] ?? []).map((e) => ({
|
|
950
|
+
}
|
|
951
|
+
return e.on(r, (e, t) => {
|
|
952
|
+
let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
|
|
953
|
+
return {
|
|
969
954
|
...e,
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
at: Date.now()
|
|
973
|
-
})),
|
|
974
|
-
target: o
|
|
955
|
+
entries: r
|
|
956
|
+
};
|
|
975
957
|
}), {
|
|
976
958
|
push: t,
|
|
977
959
|
replace: n,
|
|
978
960
|
back: r,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
entriesStore: e,
|
|
982
|
-
snapshotStore: s
|
|
961
|
+
restore: i,
|
|
962
|
+
entriesStore: e.map((e) => e.entries)
|
|
983
963
|
};
|
|
984
964
|
});
|
|
985
|
-
function
|
|
986
|
-
return
|
|
965
|
+
function He() {
|
|
966
|
+
return L(Ve);
|
|
987
967
|
}
|
|
988
968
|
//#endregion
|
|
989
969
|
//#region src/utils/events.ts
|
|
990
|
-
var
|
|
991
|
-
let t =
|
|
970
|
+
var Ue = 0, We = (e) => {
|
|
971
|
+
let t = P([]);
|
|
992
972
|
return t.on(e, (e, t) => [...e, {
|
|
993
|
-
id:
|
|
973
|
+
id: Ue++,
|
|
994
974
|
at: /* @__PURE__ */ new Date(),
|
|
995
975
|
payload: t
|
|
996
976
|
}]), t;
|
|
997
|
-
},
|
|
998
|
-
let e =
|
|
977
|
+
}, Ge = j("field"), Ke = I(() => {
|
|
978
|
+
let e = Ge.store({}), t = A(e, {
|
|
999
979
|
register(e, t) {
|
|
1000
980
|
return {
|
|
1001
981
|
...e,
|
|
@@ -1043,13 +1023,13 @@ var He = 0, Ue = (e) => {
|
|
|
1043
1023
|
getByName: c
|
|
1044
1024
|
};
|
|
1045
1025
|
});
|
|
1046
|
-
function
|
|
1047
|
-
return
|
|
1026
|
+
function qe() {
|
|
1027
|
+
return L(Ke);
|
|
1048
1028
|
}
|
|
1049
1029
|
//#endregion
|
|
1050
1030
|
//#region src/entities/step/step.ts
|
|
1051
|
-
var
|
|
1052
|
-
let e =
|
|
1031
|
+
var Je = j("step"), Ye = I(() => {
|
|
1032
|
+
let e = Je.store({}), t = A(e, { register(e, t) {
|
|
1053
1033
|
return {
|
|
1054
1034
|
...e,
|
|
1055
1035
|
[t.step.id]: t.step
|
|
@@ -1073,16 +1053,16 @@ var qe = M("step"), Je = L(() => {
|
|
|
1073
1053
|
indexStore: e
|
|
1074
1054
|
};
|
|
1075
1055
|
});
|
|
1076
|
-
function
|
|
1077
|
-
return
|
|
1056
|
+
function Xe() {
|
|
1057
|
+
return L(Ye);
|
|
1078
1058
|
}
|
|
1079
|
-
function
|
|
1059
|
+
function Ze(e, t) {
|
|
1080
1060
|
t.register(e);
|
|
1081
1061
|
}
|
|
1082
1062
|
//#endregion
|
|
1083
1063
|
//#region src/entities/action/action.ts
|
|
1084
|
-
var
|
|
1085
|
-
let t =
|
|
1064
|
+
var Qe = j("action"), $e = I(({ client: e }) => {
|
|
1065
|
+
let t = Qe.store({}), n = A(t, { register(e, t) {
|
|
1086
1066
|
return {
|
|
1087
1067
|
...e,
|
|
1088
1068
|
[t.key]: {
|
|
@@ -1090,13 +1070,13 @@ var Ze = M("action"), Qe = L(({ client: e }) => {
|
|
|
1090
1070
|
action: t.action
|
|
1091
1071
|
}
|
|
1092
1072
|
};
|
|
1093
|
-
} }), i =
|
|
1094
|
-
|
|
1073
|
+
} }), i = N();
|
|
1074
|
+
F({
|
|
1095
1075
|
clock: i,
|
|
1096
1076
|
source: t,
|
|
1097
1077
|
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1098
1078
|
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1099
|
-
}).watch((e) => /* @__PURE__ */ r("warn", e)),
|
|
1079
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
1100
1080
|
clock: i,
|
|
1101
1081
|
fn: ({ key: e, action: t }) => Object.freeze({
|
|
1102
1082
|
key: e,
|
|
@@ -1109,7 +1089,7 @@ var Ze = M("action"), Qe = L(({ client: e }) => {
|
|
|
1109
1089
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
1110
1090
|
}
|
|
1111
1091
|
function s(t, n) {
|
|
1112
|
-
let r =
|
|
1092
|
+
let r = P(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = O({
|
|
1113
1093
|
source: {
|
|
1114
1094
|
action: o(t),
|
|
1115
1095
|
snapshot: e.stateSnapshotStore
|
|
@@ -1121,13 +1101,13 @@ var Ze = M("action"), Qe = L(({ client: e }) => {
|
|
|
1121
1101
|
}, i);
|
|
1122
1102
|
}
|
|
1123
1103
|
});
|
|
1124
|
-
return
|
|
1104
|
+
return F({
|
|
1125
1105
|
source: {
|
|
1126
1106
|
responses: e.responses.listStore,
|
|
1127
1107
|
fields: e.fields.listStore
|
|
1128
1108
|
},
|
|
1129
1109
|
target: a
|
|
1130
|
-
}),
|
|
1110
|
+
}), F({
|
|
1131
1111
|
clock: a.doneData,
|
|
1132
1112
|
filter: (e) => e !== void 0,
|
|
1133
1113
|
target: r
|
|
@@ -1140,10 +1120,10 @@ var Ze = M("action"), Qe = L(({ client: e }) => {
|
|
|
1140
1120
|
getEvokableAction: s
|
|
1141
1121
|
};
|
|
1142
1122
|
});
|
|
1143
|
-
function
|
|
1144
|
-
return
|
|
1123
|
+
function et(e) {
|
|
1124
|
+
return L($e, e);
|
|
1145
1125
|
}
|
|
1146
|
-
var
|
|
1126
|
+
var tt = (e, t, n) => {
|
|
1147
1127
|
n.register({
|
|
1148
1128
|
key: e,
|
|
1149
1129
|
action: t
|
|
@@ -1151,7 +1131,7 @@ var et = (e, t, n) => {
|
|
|
1151
1131
|
};
|
|
1152
1132
|
//#endregion
|
|
1153
1133
|
//#region src/entities/response/response-validation.ts
|
|
1154
|
-
function
|
|
1134
|
+
function Y(e, t, n, r) {
|
|
1155
1135
|
return {
|
|
1156
1136
|
fieldKey: e.key,
|
|
1157
1137
|
userMessage: n,
|
|
@@ -1159,13 +1139,13 @@ function Z(e, t, n, r) {
|
|
|
1159
1139
|
value: t
|
|
1160
1140
|
};
|
|
1161
1141
|
}
|
|
1162
|
-
function
|
|
1142
|
+
function X(e) {
|
|
1163
1143
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1164
1144
|
}
|
|
1165
|
-
function
|
|
1145
|
+
function nt(e) {
|
|
1166
1146
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1167
1147
|
}
|
|
1168
|
-
function
|
|
1148
|
+
function Z(e) {
|
|
1169
1149
|
try {
|
|
1170
1150
|
return JSON.stringify(e), !0;
|
|
1171
1151
|
} catch {
|
|
@@ -1179,42 +1159,42 @@ function it(e, t) {
|
|
|
1179
1159
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1180
1160
|
}
|
|
1181
1161
|
function at(e, t) {
|
|
1182
|
-
if (e.type !== "object" ||
|
|
1162
|
+
if (e.type !== "object" || X(t)) return null;
|
|
1183
1163
|
if (e.multiple) {
|
|
1184
|
-
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.");
|
|
1185
1165
|
for (let n of t) {
|
|
1186
|
-
if (typeof n != "object" || !n) return
|
|
1187
|
-
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.).");
|
|
1188
1168
|
}
|
|
1189
1169
|
return null;
|
|
1190
1170
|
}
|
|
1191
|
-
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.).");
|
|
1192
1172
|
}
|
|
1193
1173
|
function ot(e, t) {
|
|
1194
|
-
if (
|
|
1174
|
+
if (X(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1195
1175
|
let n = Array.isArray(t) ? t : [t];
|
|
1196
1176
|
if (e.type === "object") {
|
|
1197
1177
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
1198
|
-
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.");
|
|
1199
1179
|
}
|
|
1200
1180
|
let r = e.options.map((e) => e.value);
|
|
1201
|
-
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(", ")}`);
|
|
1202
1182
|
}
|
|
1203
1183
|
async function st(t, n, r, i) {
|
|
1204
|
-
if (n.validation && !e(n.validation) && !
|
|
1184
|
+
if (n.validation && !e(n.validation) && !X(r)) {
|
|
1205
1185
|
let e = i ? {
|
|
1206
1186
|
$input: r,
|
|
1207
1187
|
responses: i
|
|
1208
1188
|
} : { $input: r }, a = await t(n.validation, e);
|
|
1209
|
-
if (typeof a == "string") return
|
|
1210
|
-
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.");
|
|
1211
1191
|
}
|
|
1212
|
-
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;
|
|
1213
1193
|
}
|
|
1214
1194
|
//#endregion
|
|
1215
1195
|
//#region src/entities/response/response.ts
|
|
1216
|
-
var ct =
|
|
1217
|
-
let t = ct.store({}), r =
|
|
1196
|
+
var ct = j("response"), lt = I(({ client: e }) => {
|
|
1197
|
+
let t = ct.store({}), r = N(), i = N(), a = A(t, {
|
|
1218
1198
|
register(e, t) {
|
|
1219
1199
|
return {
|
|
1220
1200
|
...e,
|
|
@@ -1243,7 +1223,7 @@ var ct = M("response"), lt = L(({ client: e }) => {
|
|
|
1243
1223
|
});
|
|
1244
1224
|
} else a.registerBatch(e);
|
|
1245
1225
|
}
|
|
1246
|
-
let s = (t, r) => n(e, t, r), c =
|
|
1226
|
+
let s = (t, r) => n(e, t, r), c = O({
|
|
1247
1227
|
source: {
|
|
1248
1228
|
allFields: e.fields.listStore,
|
|
1249
1229
|
existingResponses: t
|
|
@@ -1301,7 +1281,7 @@ var ct = M("response"), lt = L(({ client: e }) => {
|
|
|
1301
1281
|
async function l(e) {
|
|
1302
1282
|
return c(e);
|
|
1303
1283
|
}
|
|
1304
|
-
let u =
|
|
1284
|
+
let u = O({
|
|
1305
1285
|
source: t,
|
|
1306
1286
|
effect: async (e, t) => {
|
|
1307
1287
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
@@ -1316,7 +1296,7 @@ var ct = M("response"), lt = L(({ client: e }) => {
|
|
|
1316
1296
|
value: t
|
|
1317
1297
|
})));
|
|
1318
1298
|
function m(e) {
|
|
1319
|
-
return
|
|
1299
|
+
return k({
|
|
1320
1300
|
f: e,
|
|
1321
1301
|
s: t
|
|
1322
1302
|
}, ({ f: e, s: t }) => {
|
|
@@ -1333,10 +1313,10 @@ var ct = M("response"), lt = L(({ client: e }) => {
|
|
|
1333
1313
|
function _(t) {
|
|
1334
1314
|
return m(e.fields.getByName(t));
|
|
1335
1315
|
}
|
|
1336
|
-
return
|
|
1316
|
+
return F({
|
|
1337
1317
|
clock: r,
|
|
1338
1318
|
target: a.clearAll
|
|
1339
|
-
}),
|
|
1319
|
+
}), F({
|
|
1340
1320
|
clock: i,
|
|
1341
1321
|
target: a.clear
|
|
1342
1322
|
}), {
|
|
@@ -1353,12 +1333,12 @@ var ct = M("response"), lt = L(({ client: e }) => {
|
|
|
1353
1333
|
};
|
|
1354
1334
|
});
|
|
1355
1335
|
function ut(e) {
|
|
1356
|
-
return
|
|
1336
|
+
return L(lt, e);
|
|
1357
1337
|
}
|
|
1358
1338
|
//#endregion
|
|
1359
1339
|
//#region src/entities/condition/condition.ts
|
|
1360
|
-
var dt =
|
|
1361
|
-
let e = dt.store({}), t =
|
|
1340
|
+
var dt = j("condition"), ft = I(() => {
|
|
1341
|
+
let e = dt.store({}), t = A(e, { register(e, t) {
|
|
1362
1342
|
return {
|
|
1363
1343
|
...e,
|
|
1364
1344
|
[t.condition.id]: t.condition
|
|
@@ -1383,7 +1363,7 @@ var dt = M("condition"), ft = L(() => {
|
|
|
1383
1363
|
};
|
|
1384
1364
|
});
|
|
1385
1365
|
function pt() {
|
|
1386
|
-
return
|
|
1366
|
+
return L(ft);
|
|
1387
1367
|
}
|
|
1388
1368
|
//#endregion
|
|
1389
1369
|
//#region src/utils/api-url.ts
|
|
@@ -1420,13 +1400,13 @@ function ht() {
|
|
|
1420
1400
|
}
|
|
1421
1401
|
//#endregion
|
|
1422
1402
|
//#region src/entities/session/session.ts
|
|
1423
|
-
var
|
|
1424
|
-
function
|
|
1403
|
+
var Q = E("session", "global");
|
|
1404
|
+
function gt() {
|
|
1425
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)}`;
|
|
1426
1406
|
}
|
|
1427
|
-
function
|
|
1407
|
+
function _t() {
|
|
1428
1408
|
if (!u()) return null;
|
|
1429
|
-
let e = w.get(
|
|
1409
|
+
let e = w.get(Q);
|
|
1430
1410
|
if (!e.isSet()) return null;
|
|
1431
1411
|
try {
|
|
1432
1412
|
return e.json();
|
|
@@ -1434,10 +1414,10 @@ function vt() {
|
|
|
1434
1414
|
return null;
|
|
1435
1415
|
}
|
|
1436
1416
|
}
|
|
1437
|
-
var
|
|
1438
|
-
let e =
|
|
1417
|
+
var vt = I(() => {
|
|
1418
|
+
let e = _t(), t = { id: e?.id ?? gt() };
|
|
1439
1419
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1440
|
-
let n =
|
|
1420
|
+
let n = P(t), r = A(n, {
|
|
1441
1421
|
setIsUser: (e, t) => ({
|
|
1442
1422
|
...e,
|
|
1443
1423
|
isUser: t
|
|
@@ -1458,13 +1438,13 @@ var yt = L(() => {
|
|
|
1458
1438
|
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
1459
1439
|
}
|
|
1460
1440
|
});
|
|
1461
|
-
return
|
|
1441
|
+
return F({
|
|
1462
1442
|
source: n,
|
|
1463
|
-
target:
|
|
1443
|
+
target: O({
|
|
1464
1444
|
source: n,
|
|
1465
1445
|
effect: (e) => {
|
|
1466
1446
|
if (u()) try {
|
|
1467
|
-
w.get(
|
|
1447
|
+
w.get(Q).set(e);
|
|
1468
1448
|
} catch {}
|
|
1469
1449
|
}
|
|
1470
1450
|
})
|
|
@@ -1475,27 +1455,27 @@ var yt = L(() => {
|
|
|
1475
1455
|
removeIdentifier: r.removeIdentifier
|
|
1476
1456
|
};
|
|
1477
1457
|
});
|
|
1478
|
-
function
|
|
1479
|
-
return
|
|
1458
|
+
function yt() {
|
|
1459
|
+
return L(vt, void 0);
|
|
1480
1460
|
}
|
|
1481
1461
|
//#endregion
|
|
1482
1462
|
//#region src/utils/picked-config.ts
|
|
1483
|
-
function
|
|
1463
|
+
function bt() {
|
|
1484
1464
|
if (o()) return globalThis.window.pickedConfig;
|
|
1485
1465
|
}
|
|
1486
|
-
function
|
|
1487
|
-
if (o()) return
|
|
1466
|
+
function xt() {
|
|
1467
|
+
if (o()) return bt()?.projectId;
|
|
1488
1468
|
}
|
|
1489
|
-
function
|
|
1469
|
+
function St() {
|
|
1490
1470
|
if (!f()) return;
|
|
1491
1471
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1492
1472
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1493
1473
|
}
|
|
1494
|
-
function
|
|
1474
|
+
function Ct(e) {
|
|
1495
1475
|
if (e.projectId) return e.projectId;
|
|
1496
|
-
let t =
|
|
1476
|
+
let t = xt();
|
|
1497
1477
|
if (t) return t;
|
|
1498
|
-
let n =
|
|
1478
|
+
let n = St();
|
|
1499
1479
|
if (n) return n;
|
|
1500
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.");
|
|
1501
1481
|
}
|
|
@@ -1504,7 +1484,7 @@ function wt(e) {
|
|
|
1504
1484
|
function $(e) {
|
|
1505
1485
|
return e == null || e === "" || Number.isNaN(e);
|
|
1506
1486
|
}
|
|
1507
|
-
var
|
|
1487
|
+
var wt = {
|
|
1508
1488
|
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1509
1489
|
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1510
1490
|
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
@@ -1525,24 +1505,24 @@ var Tt = {
|
|
|
1525
1505
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1526
1506
|
}
|
|
1527
1507
|
};
|
|
1528
|
-
function
|
|
1508
|
+
function Tt(e) {
|
|
1529
1509
|
return typeof e == "object" && !!e;
|
|
1530
1510
|
}
|
|
1531
|
-
function
|
|
1511
|
+
function Et(e, t) {
|
|
1532
1512
|
let n = t;
|
|
1533
|
-
for (let t of e.split(".")) if (
|
|
1513
|
+
for (let t of e.split(".")) if (Tt(n) && t in n) n = n[t];
|
|
1534
1514
|
else return;
|
|
1535
1515
|
return typeof n == "function" ? n() : n;
|
|
1536
1516
|
}
|
|
1537
|
-
function
|
|
1538
|
-
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);
|
|
1539
1519
|
for (let e of n) {
|
|
1540
|
-
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];
|
|
1541
1521
|
o && (r = o(r, a));
|
|
1542
1522
|
}
|
|
1543
1523
|
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1544
1524
|
}
|
|
1545
|
-
function
|
|
1525
|
+
function Ot(e, t) {
|
|
1546
1526
|
let n = "", r = 0;
|
|
1547
1527
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1548
1528
|
r += 2;
|
|
@@ -1554,77 +1534,77 @@ function kt(e, t) {
|
|
|
1554
1534
|
}
|
|
1555
1535
|
i += e[r++];
|
|
1556
1536
|
}
|
|
1557
|
-
n +=
|
|
1537
|
+
n += Dt(i.trim(), t);
|
|
1558
1538
|
} else n += e[r++];
|
|
1559
1539
|
return n;
|
|
1560
1540
|
}
|
|
1561
1541
|
//#endregion
|
|
1562
1542
|
//#region src/picked.ts
|
|
1563
|
-
var
|
|
1543
|
+
var kt = class {
|
|
1564
1544
|
static logger = r;
|
|
1565
1545
|
options;
|
|
1566
1546
|
plugins = {};
|
|
1567
|
-
eventBus =
|
|
1547
|
+
eventBus = N();
|
|
1568
1548
|
events;
|
|
1569
1549
|
projectId;
|
|
1570
1550
|
apiUrl;
|
|
1571
1551
|
dashboardUrl;
|
|
1572
1552
|
documentationSiteUrl;
|
|
1573
|
-
session =
|
|
1553
|
+
session = yt();
|
|
1574
1554
|
searchParams = ht();
|
|
1575
|
-
history =
|
|
1576
|
-
components =
|
|
1555
|
+
history = He();
|
|
1556
|
+
components = he({ client: this });
|
|
1577
1557
|
experienceInstances = b({ client: this });
|
|
1578
|
-
experiences =
|
|
1579
|
-
frameworks =
|
|
1580
|
-
predicates =
|
|
1581
|
-
features =
|
|
1558
|
+
experiences = se({ client: this });
|
|
1559
|
+
frameworks = ye({ client: this });
|
|
1560
|
+
predicates = Fe({ client: this });
|
|
1561
|
+
features = ze({ client: this });
|
|
1582
1562
|
conditions = pt();
|
|
1583
|
-
fields =
|
|
1563
|
+
fields = qe();
|
|
1584
1564
|
responses = ut({ client: this });
|
|
1585
|
-
steps =
|
|
1586
|
-
actions =
|
|
1587
|
-
stateSnapshotStore =
|
|
1588
|
-
evaluateRuleLogicFx =
|
|
1565
|
+
steps = Xe();
|
|
1566
|
+
actions = et({ client: this });
|
|
1567
|
+
stateSnapshotStore = Se({ client: this });
|
|
1568
|
+
evaluateRuleLogicFx = De({ client: this });
|
|
1589
1569
|
start;
|
|
1590
1570
|
readyStore;
|
|
1591
1571
|
preconditionPassedStore;
|
|
1592
1572
|
conditionPassedStore;
|
|
1593
1573
|
lifecycleStageStore;
|
|
1594
|
-
lifecycle =
|
|
1595
|
-
renderStringFx =
|
|
1574
|
+
lifecycle = Me({ client: this });
|
|
1575
|
+
renderStringFx = O({
|
|
1596
1576
|
source: this.responses.listStore,
|
|
1597
1577
|
effect: (e, { template: t, context: n }) => {
|
|
1598
1578
|
let r = {};
|
|
1599
1579
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1600
|
-
return
|
|
1580
|
+
return Ot(t, {
|
|
1601
1581
|
...n,
|
|
1602
1582
|
responses: r
|
|
1603
1583
|
});
|
|
1604
1584
|
}
|
|
1605
1585
|
});
|
|
1606
1586
|
constructor(e) {
|
|
1607
|
-
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({
|
|
1608
1588
|
type: "load",
|
|
1609
1589
|
version: te()
|
|
1610
1590
|
});
|
|
1611
1591
|
}
|
|
1612
1592
|
registerFramework = (e) => {
|
|
1613
|
-
|
|
1593
|
+
be(e, this.frameworks);
|
|
1614
1594
|
};
|
|
1615
1595
|
registerComponent = (e, t) => {
|
|
1616
|
-
|
|
1596
|
+
ge(e, t, this.components);
|
|
1617
1597
|
};
|
|
1618
1598
|
registerPlugin = (e) => {
|
|
1619
|
-
|
|
1599
|
+
ue(this, e, this.plugins);
|
|
1620
1600
|
let t = this.plugins[e.name];
|
|
1621
1601
|
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1622
1602
|
};
|
|
1623
1603
|
registerFeature = (e, t) => {
|
|
1624
|
-
|
|
1604
|
+
Be(e, t, this.features);
|
|
1625
1605
|
};
|
|
1626
1606
|
registerPredicate = (e, t) => {
|
|
1627
|
-
|
|
1607
|
+
Ie(e, t, this.predicates);
|
|
1628
1608
|
};
|
|
1629
1609
|
registerCondition = (e) => {
|
|
1630
1610
|
this.conditions.register(e);
|
|
@@ -1633,13 +1613,13 @@ var At = class {
|
|
|
1633
1613
|
this.fields.register(e);
|
|
1634
1614
|
};
|
|
1635
1615
|
registerStep = (e) => {
|
|
1636
|
-
|
|
1616
|
+
Ze(e, this.steps);
|
|
1637
1617
|
};
|
|
1638
1618
|
registerAction = (e, t) => {
|
|
1639
|
-
|
|
1619
|
+
tt(e, t, this.actions);
|
|
1640
1620
|
};
|
|
1641
1621
|
registerExperience = (e) => {
|
|
1642
|
-
e.component &&
|
|
1622
|
+
e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1643
1623
|
};
|
|
1644
1624
|
launchExperienceById = async (e, t) => {
|
|
1645
1625
|
this.experiences.launch({
|
|
@@ -1724,20 +1704,20 @@ var At = class {
|
|
|
1724
1704
|
};
|
|
1725
1705
|
//#endregion
|
|
1726
1706
|
//#region src/entities/component/lazyComponent.ts
|
|
1727
|
-
function
|
|
1707
|
+
function At(e) {
|
|
1728
1708
|
return {
|
|
1729
1709
|
$$type: "lazy-component",
|
|
1730
1710
|
load: e
|
|
1731
1711
|
};
|
|
1732
1712
|
}
|
|
1733
|
-
function
|
|
1713
|
+
function jt(e) {
|
|
1734
1714
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1735
1715
|
}
|
|
1736
1716
|
//#endregion
|
|
1737
1717
|
//#region src/exports.ts
|
|
1738
|
-
var
|
|
1739
|
-
let t = new
|
|
1718
|
+
var Mt = (e) => {
|
|
1719
|
+
let t = new kt(e);
|
|
1740
1720
|
return d(t), t;
|
|
1741
1721
|
};
|
|
1742
1722
|
//#endregion
|
|
1743
|
-
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 };
|