@picked/client 0.0.1-dev.1774244905386 → 0.0.1-dev.1774912386475
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-dkMxUUe0.cjs → api-B-wGEgt8.cjs} +1 -1
- package/dist/{api-ENA5t36y.js → api-DwERBrAZ.js} +1 -1
- package/dist/cjs/form/index.js +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/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +472 -0
- package/dist/esm/index.js +351 -369
- package/dist/esm/plugins/create-experience/index.js +218 -221
- package/dist/esm/plugins/dynamic-experiences/index.js +6 -7
- 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 +48 -21
- package/dist/esm/plugins/responses-indexeddb/index.js +5 -9
- package/dist/esm/plugins/single-page-app/index.js +4 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-CwwrKUI8.js +485 -0
- package/dist/experience-instance-DdFUcVRd.cjs +1 -0
- package/dist/{object-Clj5zVr1.js → object-C82v79xc.js} +2 -1
- package/dist/object-CUJOjanb.cjs +1 -0
- package/dist/rules-logic-BIkBWZmf.js +233 -0
- package/dist/rules-logic-DDxCiq4P.cjs +1 -0
- package/dist/{storage-DyxpJ0pg.js → storage-6Xk0uAxB.js} +3 -1
- package/dist/storage-B6lQtc4-.cjs +1 -0
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +33 -5
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +19 -0
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +19 -13
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +76 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +17 -13
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +1 -3
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/form/build-responses.d.ts +17 -0
- package/dist/types/form/build-responses.d.ts.map +1 -0
- package/dist/types/form/create-field-evaluator.d.ts +27 -0
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -0
- package/dist/types/form/create-field-validation.d.ts +59 -0
- package/dist/types/form/create-field-validation.d.ts.map +1 -0
- package/dist/types/form/create-form.d.ts +97 -0
- package/dist/types/form/create-form.d.ts.map +1 -0
- package/dist/types/form/create-submit-pipeline.d.ts +70 -0
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -0
- package/dist/types/form/get-step-fields.d.ts +18 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -0
- package/dist/types/form/index.d.ts +10 -0
- package/dist/types/form/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +12 -10
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +38 -11
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +22 -32
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/serialization.d.ts +7 -0
- package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +11 -17
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -0
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -3
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +0 -1
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +2 -1
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +3 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +8 -4
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +58 -9
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +0 -8
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +31 -0
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +42 -6
- package/dist/experience-instance-BODAwa-_.js +0 -713
- package/dist/experience-instance-DImQh64e.cjs +0 -1
- package/dist/object-BReQiaSS.cjs +0 -1
- package/dist/storage-BFjb8azI.cjs +0 -1
- package/dist/types/entities/project/project.d.ts +0 -9
- package/dist/types/entities/project/project.d.ts.map +0 -1
- package/dist/types/utils/key.d.ts +0 -12
- package/dist/types/utils/key.d.ts.map +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
- /package/dist/{id-CIbS4P60.cjs → id-Bv44ilEo.cjs} +0 -0
- /package/dist/{id-BniPxOdF.js → id-CRqy981z.js} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,150 +1,137 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as
|
|
5
|
-
import { i as
|
|
6
|
-
import { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { n as e, t } from "../rules-logic-BIkBWZmf.js";
|
|
2
|
+
import { t as n } from "../object-C82v79xc.js";
|
|
3
|
+
import { t as r } from "../logger-6z_gb4rA.js";
|
|
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 ee, n as te, o as ne, r as re, s as ie, u as ae } from "../experience-instance-CwwrKUI8.js";
|
|
6
|
+
import { i as y, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as oe, r as se } from "../api-DwERBrAZ.js";
|
|
8
|
+
import { t as ce } from "../id-CRqy981z.js";
|
|
9
|
+
import { attach as C, combine as w, createApi as T, createDomain as E, createEffect as D, createEvent as O, createStore as k, sample as A } from "effector";
|
|
10
|
+
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
10
11
|
//#region src/entities/experience/experience.ts
|
|
11
|
-
var
|
|
12
|
-
let
|
|
12
|
+
var N = E("experience"), le = j(({ client: e, experience: t }) => {
|
|
13
|
+
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
13
14
|
return {
|
|
14
15
|
...e,
|
|
15
16
|
...t.experience
|
|
16
17
|
};
|
|
17
|
-
} }),
|
|
18
|
+
} }), i = n.map((e) => ({
|
|
18
19
|
name: e.name,
|
|
19
20
|
decisionLogic: e.condition,
|
|
20
21
|
targetSelectors: e.targets,
|
|
21
|
-
initializeOpenLogic:
|
|
22
|
-
})),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let a = t.nodes.filter(i).map((e) => {
|
|
28
|
-
let t = s(e);
|
|
29
|
-
return n.find((e) => e.id === t || e.key === t);
|
|
30
|
-
}).filter((e) => e !== void 0), o = t.nodes.filter(l).map((t) => r.find((n) => n.id === e(t))).filter((e) => e !== void 0);
|
|
22
|
+
initializeOpenLogic: e.initializeOpen
|
|
23
|
+
})), a = w(n, 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 }), o = w(n, e.steps.listStore, e.conditions.listStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => {
|
|
25
|
+
let n = e.stepId;
|
|
26
|
+
return t.find((e) => e.id === n || e.key === n);
|
|
27
|
+
}).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n.find((t) => t.id === g(e))).filter((e) => e !== void 0);
|
|
31
28
|
return {
|
|
32
|
-
steps:
|
|
33
|
-
nodes:
|
|
34
|
-
edges:
|
|
35
|
-
conditions:
|
|
29
|
+
steps: r,
|
|
30
|
+
nodes: e.nodes,
|
|
31
|
+
edges: e.edges,
|
|
32
|
+
conditions: i
|
|
36
33
|
};
|
|
37
|
-
}),
|
|
34
|
+
}), s = t.actions ?? [];
|
|
38
35
|
return {
|
|
39
|
-
id:
|
|
40
|
-
key:
|
|
41
|
-
name:
|
|
42
|
-
configStore:
|
|
43
|
-
treeStore:
|
|
44
|
-
componentStore:
|
|
45
|
-
actions:
|
|
46
|
-
merge:
|
|
36
|
+
id: t.id,
|
|
37
|
+
key: t.key,
|
|
38
|
+
name: t.name,
|
|
39
|
+
configStore: i,
|
|
40
|
+
treeStore: o,
|
|
41
|
+
componentStore: a,
|
|
42
|
+
actions: s,
|
|
43
|
+
merge: r.merge
|
|
47
44
|
};
|
|
48
45
|
});
|
|
49
|
-
function
|
|
50
|
-
return
|
|
46
|
+
function ue(e) {
|
|
47
|
+
return M(le, e);
|
|
51
48
|
}
|
|
52
|
-
var
|
|
53
|
-
let t =
|
|
49
|
+
var de = j(({ client: e }) => {
|
|
50
|
+
let t = N.store({}), n = T(t, { register(e, t) {
|
|
54
51
|
return {
|
|
55
52
|
...e,
|
|
56
53
|
[t.id]: t
|
|
57
54
|
};
|
|
58
|
-
} }),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function a(n) {
|
|
65
|
-
let a = t.getState()[n.id];
|
|
66
|
-
if (a) {
|
|
67
|
-
a.merge({
|
|
68
|
-
experience: n,
|
|
55
|
+
} }), r = t.map((e) => Object.fromEntries(Object.values(e).map((e) => [e.key, e.id])));
|
|
56
|
+
function i(r) {
|
|
57
|
+
let i = t.getState()[r.id];
|
|
58
|
+
if (i) {
|
|
59
|
+
i.merge({
|
|
60
|
+
experience: r,
|
|
69
61
|
strategy: "override"
|
|
70
|
-
}), i.register({
|
|
71
|
-
key: n.key,
|
|
72
|
-
id: n.id
|
|
73
62
|
});
|
|
74
63
|
return;
|
|
75
64
|
}
|
|
76
|
-
let
|
|
65
|
+
let a = ue({
|
|
77
66
|
client: e,
|
|
78
|
-
experience:
|
|
79
|
-
});
|
|
80
|
-
r.register(o), i.register({
|
|
81
|
-
key: n.key,
|
|
82
|
-
id: n.id
|
|
67
|
+
experience: r
|
|
83
68
|
});
|
|
69
|
+
n.register(a);
|
|
84
70
|
}
|
|
85
|
-
let
|
|
86
|
-
function
|
|
87
|
-
return
|
|
71
|
+
let a = t.map((e) => Object.values(e));
|
|
72
|
+
function o(e) {
|
|
73
|
+
return w(t, r, (t, n) => t[n[e] ?? ""] ?? t[e], { skipVoid: !1 });
|
|
88
74
|
}
|
|
89
|
-
let
|
|
75
|
+
let s = C({
|
|
90
76
|
source: {
|
|
91
77
|
experiences: t,
|
|
92
|
-
keys:
|
|
78
|
+
keys: r
|
|
93
79
|
},
|
|
94
|
-
effect: async ({ experiences: t, keys: n }, { key: r,
|
|
95
|
-
let
|
|
96
|
-
if (!
|
|
97
|
-
`${
|
|
80
|
+
effect: async ({ experiences: t, keys: n }, { key: r, id: i, options: a }) => {
|
|
81
|
+
let o = r ?? i ?? "", s = t[n[o] ?? ""] ?? t[o];
|
|
82
|
+
if (!s) {
|
|
83
|
+
`${o}`;
|
|
98
84
|
return;
|
|
99
85
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
86
|
+
if (a?.bypassCondition) {
|
|
87
|
+
P(e, s, a);
|
|
102
88
|
return;
|
|
103
89
|
}
|
|
104
|
-
await
|
|
90
|
+
await I(e, s) && P(e, s, a);
|
|
105
91
|
}
|
|
106
92
|
});
|
|
107
93
|
return {
|
|
108
|
-
register:
|
|
109
|
-
get:
|
|
110
|
-
|
|
111
|
-
|
|
94
|
+
register: i,
|
|
95
|
+
get: o,
|
|
96
|
+
getById: o,
|
|
97
|
+
launch: s,
|
|
98
|
+
open: C({
|
|
112
99
|
source: {
|
|
113
100
|
instances: e.experienceInstances.listStore,
|
|
114
|
-
keys:
|
|
101
|
+
keys: r
|
|
115
102
|
},
|
|
116
|
-
effect: ({ instances: e, keys: t }, { key: n,
|
|
117
|
-
let
|
|
118
|
-
if (
|
|
119
|
-
else
|
|
120
|
-
key:
|
|
103
|
+
effect: ({ instances: e, keys: t }, { key: n, id: r, options: i }) => {
|
|
104
|
+
let a = n ?? r ?? "", o = t[a] ?? a, c = e.filter((e) => e.experienceId === o);
|
|
105
|
+
if (c.length > 0) for (let e of c) e.open();
|
|
106
|
+
else s({
|
|
107
|
+
key: o,
|
|
121
108
|
options: {
|
|
122
|
-
...
|
|
109
|
+
...i,
|
|
123
110
|
initialiseOpen: !0
|
|
124
111
|
}
|
|
125
112
|
});
|
|
126
113
|
}
|
|
127
114
|
}),
|
|
128
|
-
listStore:
|
|
115
|
+
listStore: a
|
|
129
116
|
};
|
|
130
117
|
});
|
|
131
|
-
function
|
|
132
|
-
return
|
|
118
|
+
function fe(e) {
|
|
119
|
+
return M(de, e);
|
|
133
120
|
}
|
|
134
|
-
var
|
|
135
|
-
let { targetSelectors:
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
var P = (e, t, n) => {
|
|
122
|
+
let { targetSelectors: r } = t.configStore.getState(), i = _(r, t.id);
|
|
123
|
+
i.forEach(({ elements: e }) => e.forEach((e) => ae(e, t.id))), ne(i, t.id).forEach((r) => {
|
|
124
|
+
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
138
125
|
});
|
|
139
|
-
},
|
|
126
|
+
}, F = async (e) => {
|
|
140
127
|
await Promise.all(e.experiences.listStore.getState().map(async (t) => {
|
|
141
|
-
await
|
|
128
|
+
await I(e, t) && P(e, t);
|
|
142
129
|
}));
|
|
143
|
-
},
|
|
144
|
-
if (!
|
|
145
|
-
let { decisionLogic:
|
|
146
|
-
return a
|
|
147
|
-
},
|
|
130
|
+
}, I = async (n, r) => {
|
|
131
|
+
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
132
|
+
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
133
|
+
return _(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
134
|
+
}, L = (e, t, n) => {
|
|
148
135
|
let r = t.name, i = t.setup(e);
|
|
149
136
|
if (i) {
|
|
150
137
|
let e = n[r] ?? {};
|
|
@@ -153,16 +140,16 @@ var I = (e, t, r) => {
|
|
|
153
140
|
...i
|
|
154
141
|
});
|
|
155
142
|
}
|
|
156
|
-
},
|
|
143
|
+
}, R = E("component"), z = j(({ client: e, component: t, name: n }) => ({
|
|
157
144
|
name: n,
|
|
158
145
|
component: t,
|
|
159
146
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
160
147
|
}));
|
|
161
|
-
function
|
|
162
|
-
return
|
|
148
|
+
function B(e) {
|
|
149
|
+
return M(z, e);
|
|
163
150
|
}
|
|
164
|
-
var
|
|
165
|
-
let t =
|
|
151
|
+
var V = j(({ client: e }) => {
|
|
152
|
+
let t = R.store({}), n = T(t, { register(e, t) {
|
|
166
153
|
return {
|
|
167
154
|
...e,
|
|
168
155
|
[t.name]: t
|
|
@@ -170,7 +157,7 @@ var fe = N(({ client: e }) => {
|
|
|
170
157
|
} });
|
|
171
158
|
function r(r, i) {
|
|
172
159
|
t.getState()[r] && `${r}`;
|
|
173
|
-
let a =
|
|
160
|
+
let a = B({
|
|
174
161
|
client: e,
|
|
175
162
|
name: r,
|
|
176
163
|
component: i
|
|
@@ -188,12 +175,12 @@ var fe = N(({ client: e }) => {
|
|
|
188
175
|
};
|
|
189
176
|
});
|
|
190
177
|
function pe(e) {
|
|
191
|
-
return
|
|
178
|
+
return M(V, e);
|
|
192
179
|
}
|
|
193
|
-
var
|
|
180
|
+
var H = (e, t, n) => {
|
|
194
181
|
n.register(e, t);
|
|
195
|
-
}, me =
|
|
196
|
-
let t = me.store({}), n =
|
|
182
|
+
}, me = E("framework"), he = j(({ client: e }) => {
|
|
183
|
+
let t = me.store({}), n = T(t, { register(e, t) {
|
|
197
184
|
return {
|
|
198
185
|
...e,
|
|
199
186
|
[t.name]: t.framework
|
|
@@ -216,20 +203,20 @@ var U = (e, t, n) => {
|
|
|
216
203
|
};
|
|
217
204
|
});
|
|
218
205
|
function ge(e) {
|
|
219
|
-
return
|
|
206
|
+
return M(he, e);
|
|
220
207
|
}
|
|
221
208
|
var _e = (e, t) => {
|
|
222
209
|
t.register(e.name, e);
|
|
223
|
-
}, ve = 6e3, ye =
|
|
210
|
+
}, ve = 6e3, ye = S("last_ping", "global"), be = async (e) => {
|
|
224
211
|
try {
|
|
225
|
-
let t = Date.now(), n =
|
|
212
|
+
let t = Date.now(), n = b.get(ye), r = 0;
|
|
226
213
|
if (n.isSet() && (r = n.json() ?? 0), r && t - r < ve) return !0;
|
|
227
214
|
let i = {
|
|
228
215
|
projectId: e.projectId,
|
|
229
216
|
path: window.location.pathname
|
|
230
217
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
231
218
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
232
|
-
let s = (await
|
|
219
|
+
let s = (await oe(e.apiUrl, "ping", i, a)).ok;
|
|
233
220
|
return s && n.set(t), s;
|
|
234
221
|
} catch {
|
|
235
222
|
return !1;
|
|
@@ -237,7 +224,7 @@ var _e = (e, t) => {
|
|
|
237
224
|
};
|
|
238
225
|
//#endregion
|
|
239
226
|
//#region src/utils/state-snaphot.ts
|
|
240
|
-
function
|
|
227
|
+
function U(e) {
|
|
241
228
|
let t = typeof window < "u", n = {
|
|
242
229
|
client: e,
|
|
243
230
|
responses: e.responses.listStore.getState(),
|
|
@@ -251,8 +238,8 @@ function W(e) {
|
|
|
251
238
|
}
|
|
252
239
|
//#endregion
|
|
253
240
|
//#region src/entities/predicate/predicate.ts
|
|
254
|
-
var xe =
|
|
255
|
-
let t = xe.store({}), n =
|
|
241
|
+
var xe = E("predicate"), Se = j(({ client: e }) => {
|
|
242
|
+
let t = xe.store({}), n = T(t, { register(e, t) {
|
|
256
243
|
return {
|
|
257
244
|
...e,
|
|
258
245
|
[t.name]: {
|
|
@@ -272,22 +259,22 @@ var xe = O("predicate"), Se = N(({ client: e }) => {
|
|
|
272
259
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
273
260
|
}
|
|
274
261
|
function o(t) {
|
|
275
|
-
let n =
|
|
262
|
+
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
276
263
|
let n = a(t).getState();
|
|
277
264
|
if (!n) return;
|
|
278
|
-
let r =
|
|
265
|
+
let r = U(e);
|
|
279
266
|
return (...e) => n({
|
|
280
267
|
...r,
|
|
281
268
|
args: e
|
|
282
269
|
});
|
|
283
270
|
});
|
|
284
|
-
return
|
|
271
|
+
return A({
|
|
285
272
|
source: {
|
|
286
273
|
responses: e.responses.listStore,
|
|
287
274
|
fields: e.fields.listStore
|
|
288
275
|
},
|
|
289
276
|
target: r
|
|
290
|
-
}),
|
|
277
|
+
}), A({
|
|
291
278
|
clock: r.doneData,
|
|
292
279
|
filter: (e) => e !== void 0,
|
|
293
280
|
target: n
|
|
@@ -301,12 +288,12 @@ var xe = O("predicate"), Se = N(({ client: e }) => {
|
|
|
301
288
|
};
|
|
302
289
|
});
|
|
303
290
|
function Ce(e) {
|
|
304
|
-
return
|
|
291
|
+
return M(Se, e);
|
|
305
292
|
}
|
|
306
293
|
var we = (e, t, n) => {
|
|
307
294
|
n.register(e, t);
|
|
308
|
-
},
|
|
309
|
-
let t =
|
|
295
|
+
}, W = E("feature"), Te = j(({ client: e }) => {
|
|
296
|
+
let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
|
|
310
297
|
return {
|
|
311
298
|
...e,
|
|
312
299
|
[t.id]: t.feature
|
|
@@ -326,19 +313,19 @@ var we = (e, t, n) => {
|
|
|
326
313
|
feature: i
|
|
327
314
|
}));
|
|
328
315
|
}
|
|
329
|
-
let a =
|
|
330
|
-
let r =
|
|
316
|
+
let a = D(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
317
|
+
let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
|
|
331
318
|
return i === null ? null : {
|
|
332
319
|
id: e,
|
|
333
320
|
key: t,
|
|
334
321
|
bucket: i,
|
|
335
322
|
storage: n
|
|
336
323
|
};
|
|
337
|
-
}), o =
|
|
324
|
+
}), o = D((e) => {
|
|
338
325
|
if (!e) return null;
|
|
339
|
-
let t =
|
|
340
|
-
(e.storage === "session" ?
|
|
341
|
-
}), s = /* @__PURE__ */ new Map(), c =
|
|
326
|
+
let t = S(`feature:${e.id}:${e.key}`, "global");
|
|
327
|
+
(e.storage === "session" ? x : b).set(t, e.bucket);
|
|
328
|
+
}), s = /* @__PURE__ */ new Map(), c = C({
|
|
342
329
|
source: {
|
|
343
330
|
allFeaturesStore: t,
|
|
344
331
|
resolvedFeaturesStore: n
|
|
@@ -369,7 +356,7 @@ var we = (e, t, n) => {
|
|
|
369
356
|
};
|
|
370
357
|
}
|
|
371
358
|
});
|
|
372
|
-
|
|
359
|
+
A({
|
|
373
360
|
clock: r.register,
|
|
374
361
|
fn: (e) => {
|
|
375
362
|
let { id: t, feature: n } = e;
|
|
@@ -380,7 +367,7 @@ var we = (e, t, n) => {
|
|
|
380
367
|
};
|
|
381
368
|
},
|
|
382
369
|
target: a
|
|
383
|
-
}),
|
|
370
|
+
}), A({
|
|
384
371
|
source: t,
|
|
385
372
|
clock: c.doneData,
|
|
386
373
|
fn: (e, t) => {
|
|
@@ -394,7 +381,7 @@ var we = (e, t, n) => {
|
|
|
394
381
|
},
|
|
395
382
|
target: o
|
|
396
383
|
});
|
|
397
|
-
let l =
|
|
384
|
+
let l = w({
|
|
398
385
|
allFeaturesStore: t,
|
|
399
386
|
resolvedFeaturesStore: n
|
|
400
387
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -416,7 +403,7 @@ var we = (e, t, n) => {
|
|
|
416
403
|
isResolved: !1
|
|
417
404
|
};
|
|
418
405
|
}));
|
|
419
|
-
|
|
406
|
+
A({
|
|
420
407
|
clock: c.doneData,
|
|
421
408
|
source: { resolvedFeatures: n },
|
|
422
409
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
@@ -425,7 +412,7 @@ var we = (e, t, n) => {
|
|
|
425
412
|
type: "feature_decide",
|
|
426
413
|
feature: e
|
|
427
414
|
}))
|
|
428
|
-
}),
|
|
415
|
+
}), A({
|
|
429
416
|
clock: [a.doneData, c.doneData],
|
|
430
417
|
source: n,
|
|
431
418
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
@@ -438,15 +425,15 @@ var we = (e, t, n) => {
|
|
|
438
425
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
439
426
|
}
|
|
440
427
|
function f(e) {
|
|
441
|
-
let t =
|
|
428
|
+
let t = k(async () => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
442
429
|
let t = u(e).getState();
|
|
443
430
|
if (t) return async () => (await t.getBucket()).bucket;
|
|
444
431
|
});
|
|
445
|
-
return
|
|
432
|
+
return A({
|
|
446
433
|
source: n,
|
|
447
434
|
filter: (t) => t.some((t) => t.id === e),
|
|
448
435
|
target: r
|
|
449
|
-
}),
|
|
436
|
+
}), A({
|
|
450
437
|
clock: r.doneData,
|
|
451
438
|
filter: (e) => e !== void 0,
|
|
452
439
|
target: t
|
|
@@ -461,30 +448,30 @@ var we = (e, t, n) => {
|
|
|
461
448
|
};
|
|
462
449
|
});
|
|
463
450
|
function Ee(e) {
|
|
464
|
-
return
|
|
451
|
+
return M(Te, e);
|
|
465
452
|
}
|
|
466
453
|
var De = (e, t, n) => {
|
|
467
454
|
n.register(e, t);
|
|
468
|
-
},
|
|
469
|
-
function
|
|
455
|
+
}, G = E("history");
|
|
456
|
+
function K(e, t) {
|
|
470
457
|
return {
|
|
471
|
-
id:
|
|
458
|
+
id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
472
459
|
node: t,
|
|
473
460
|
at: Date.now(),
|
|
474
461
|
experienceId: e
|
|
475
462
|
};
|
|
476
463
|
}
|
|
477
|
-
var Oe =
|
|
478
|
-
let e =
|
|
479
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
480
|
-
function
|
|
464
|
+
var Oe = j(() => {
|
|
465
|
+
let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
|
|
466
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, K(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), K(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
467
|
+
function a(e, t) {
|
|
481
468
|
let n = {
|
|
482
469
|
lastStepIndex: -1,
|
|
483
470
|
secondLastStepIndex: -1
|
|
484
471
|
};
|
|
485
472
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
486
|
-
let
|
|
487
|
-
if (!(!
|
|
473
|
+
let i = e[r], a = i?.node;
|
|
474
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
488
475
|
else {
|
|
489
476
|
n.secondLastStepIndex = r;
|
|
490
477
|
break;
|
|
@@ -493,7 +480,7 @@ var Oe = N(() => {
|
|
|
493
480
|
return n;
|
|
494
481
|
}
|
|
495
482
|
return e.on(r, (e, t) => {
|
|
496
|
-
let { secondLastStepIndex: n } =
|
|
483
|
+
let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
|
|
497
484
|
return {
|
|
498
485
|
...e,
|
|
499
486
|
entries: r
|
|
@@ -502,18 +489,18 @@ var Oe = N(() => {
|
|
|
502
489
|
push: t,
|
|
503
490
|
replace: n,
|
|
504
491
|
back: r,
|
|
505
|
-
restore:
|
|
492
|
+
restore: i,
|
|
506
493
|
entriesStore: e.map((e) => e.entries)
|
|
507
494
|
};
|
|
508
495
|
});
|
|
509
496
|
function ke() {
|
|
510
|
-
return
|
|
497
|
+
return M(Oe);
|
|
511
498
|
}
|
|
512
499
|
//#endregion
|
|
513
500
|
//#region src/utils/events.ts
|
|
514
501
|
var Ae = 0, je = (e) => {
|
|
515
|
-
let t =
|
|
516
|
-
return
|
|
502
|
+
let t = k([]);
|
|
503
|
+
return A({
|
|
517
504
|
clock: e,
|
|
518
505
|
source: t,
|
|
519
506
|
fn: (e, t) => [...e, {
|
|
@@ -523,21 +510,31 @@ var Ae = 0, je = (e) => {
|
|
|
523
510
|
}],
|
|
524
511
|
target: t
|
|
525
512
|
}), t;
|
|
526
|
-
}, Me =
|
|
527
|
-
let e = Me.store({}), t =
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
513
|
+
}, Me = E("field"), Ne = j(() => {
|
|
514
|
+
let e = Me.store({}), t = T(e, {
|
|
515
|
+
register(e, t) {
|
|
516
|
+
return {
|
|
517
|
+
...e,
|
|
518
|
+
[t.field.id]: t.field
|
|
519
|
+
};
|
|
520
|
+
},
|
|
521
|
+
updateById(e, t) {
|
|
522
|
+
let n = e[t.fieldId];
|
|
523
|
+
return n ? {
|
|
524
|
+
...e,
|
|
525
|
+
[t.fieldId]: Object.assign({}, n, t.updates)
|
|
526
|
+
} : e;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
533
529
|
function n(e) {
|
|
534
530
|
t.register({ field: e });
|
|
535
531
|
}
|
|
536
532
|
function r(n, r) {
|
|
537
|
-
let i = e.getState()
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
533
|
+
let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.id ?? n;
|
|
534
|
+
t.updateById({
|
|
535
|
+
fieldId: a,
|
|
536
|
+
updates: r
|
|
537
|
+
});
|
|
541
538
|
}
|
|
542
539
|
let i = e.map((e) => Object.values(e));
|
|
543
540
|
function a(t) {
|
|
@@ -559,12 +556,12 @@ var Ae = 0, je = (e) => {
|
|
|
559
556
|
};
|
|
560
557
|
});
|
|
561
558
|
function Pe() {
|
|
562
|
-
return
|
|
559
|
+
return M(Ne);
|
|
563
560
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
let e =
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/entities/step/step.ts
|
|
563
|
+
var Fe = E("step"), Ie = j(() => {
|
|
564
|
+
let e = Fe.store({}), t = T(e, { register(e, t) {
|
|
568
565
|
return {
|
|
569
566
|
...e,
|
|
570
567
|
[t.step.id]: t.step
|
|
@@ -583,16 +580,16 @@ var Fe = (e, t) => {
|
|
|
583
580
|
listStore: r
|
|
584
581
|
};
|
|
585
582
|
});
|
|
586
|
-
function
|
|
587
|
-
return
|
|
583
|
+
function Le() {
|
|
584
|
+
return M(Ie);
|
|
588
585
|
}
|
|
589
|
-
function
|
|
586
|
+
function Re(e, t) {
|
|
590
587
|
t.register(e);
|
|
591
588
|
}
|
|
592
589
|
//#endregion
|
|
593
590
|
//#region src/entities/action/action.ts
|
|
594
|
-
var
|
|
595
|
-
let e =
|
|
591
|
+
var ze = E("action"), Be = j(() => {
|
|
592
|
+
let e = ze.store({}), t = T(e, { register(e, t) {
|
|
596
593
|
return {
|
|
597
594
|
...e,
|
|
598
595
|
[t.name]: {
|
|
@@ -624,18 +621,27 @@ var Be = O("action"), Ve = N(() => {
|
|
|
624
621
|
getEvokableAction: a
|
|
625
622
|
};
|
|
626
623
|
});
|
|
627
|
-
function
|
|
628
|
-
return
|
|
624
|
+
function Ve() {
|
|
625
|
+
return M(Be);
|
|
629
626
|
}
|
|
630
|
-
var
|
|
627
|
+
var He = (e, t, n) => {
|
|
631
628
|
n.register(e, t);
|
|
632
629
|
};
|
|
633
630
|
//#endregion
|
|
634
|
-
//#region src/entities/response/response.ts
|
|
631
|
+
//#region src/entities/response/response-validation.ts
|
|
632
|
+
function q(e, t, n, r) {
|
|
633
|
+
return {
|
|
634
|
+
fieldKey: e.key,
|
|
635
|
+
fieldId: e.id,
|
|
636
|
+
userMessage: n,
|
|
637
|
+
systemMessage: r,
|
|
638
|
+
value: t
|
|
639
|
+
};
|
|
640
|
+
}
|
|
635
641
|
function J(e) {
|
|
636
642
|
return e == null || e === "" || Array.isArray(e) && !e.length;
|
|
637
643
|
}
|
|
638
|
-
function
|
|
644
|
+
function Ue(e) {
|
|
639
645
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
640
646
|
}
|
|
641
647
|
function Y(e) {
|
|
@@ -645,80 +651,53 @@ function Y(e) {
|
|
|
645
651
|
return !1;
|
|
646
652
|
}
|
|
647
653
|
}
|
|
648
|
-
function
|
|
654
|
+
function We(e, t) {
|
|
649
655
|
return t.find((t) => t.id === e) ?? t.find((t) => t.key === e) ?? null;
|
|
650
656
|
}
|
|
651
|
-
function
|
|
657
|
+
function Ge(e, t) {
|
|
652
658
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
653
659
|
}
|
|
654
|
-
function
|
|
655
|
-
if (e.type !== "object" || J(
|
|
660
|
+
function Ke(e, t) {
|
|
661
|
+
if (e.type !== "object" || J(t)) return null;
|
|
656
662
|
if (e.multiple) {
|
|
657
|
-
if (!Array.isArray(
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
value: n
|
|
662
|
-
};
|
|
663
|
-
for (let e of n) {
|
|
664
|
-
if (typeof e != "object" || !e) return {
|
|
665
|
-
fieldId: t,
|
|
666
|
-
userMessage: "This field expects object values",
|
|
667
|
-
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
668
|
-
value: n
|
|
669
|
-
};
|
|
670
|
-
if (!Y(e)) return {
|
|
671
|
-
fieldId: t,
|
|
672
|
-
userMessage: "This field contains non-serializable data",
|
|
673
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
674
|
-
value: n
|
|
675
|
-
};
|
|
663
|
+
if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
664
|
+
for (let n of t) {
|
|
665
|
+
if (typeof n != "object" || !n) return q(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
666
|
+
if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
676
667
|
}
|
|
677
668
|
return null;
|
|
678
669
|
}
|
|
679
|
-
return Array.isArray(
|
|
680
|
-
fieldId: t,
|
|
681
|
-
userMessage: "This field expects a single value",
|
|
682
|
-
systemMessage: "Field expects a single object, not an array.",
|
|
683
|
-
value: n
|
|
684
|
-
} : typeof n != "object" || !n ? {
|
|
685
|
-
fieldId: t,
|
|
686
|
-
userMessage: "This field expects an object value",
|
|
687
|
-
systemMessage: "Field expects an object value.",
|
|
688
|
-
value: n
|
|
689
|
-
} : Y(n) ? null : {
|
|
690
|
-
fieldId: t,
|
|
691
|
-
userMessage: "This field contains non-serializable data",
|
|
692
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
693
|
-
value: n
|
|
694
|
-
};
|
|
670
|
+
return Array.isArray(t) ? q(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? q(e, t, "This field expects an object value", "Field expects an object value.") : Y(t) ? null : q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
695
671
|
}
|
|
696
|
-
function
|
|
672
|
+
function qe(e, t) {
|
|
697
673
|
if (!Array.isArray(e.options) || e.options.length === 0) return null;
|
|
698
|
-
let
|
|
674
|
+
let n = Array.isArray(t) ? t : [t];
|
|
699
675
|
if (e.type === "object") {
|
|
700
|
-
let
|
|
701
|
-
return
|
|
702
|
-
fieldId: t,
|
|
703
|
-
userMessage: "This field expects a valid option",
|
|
704
|
-
systemMessage: "Field expects a valid option from the defined choices.",
|
|
705
|
-
value: n
|
|
706
|
-
};
|
|
676
|
+
let r = e.options.map((e) => JSON.stringify(e.value));
|
|
677
|
+
return n.every((e) => r.includes(JSON.stringify(e))) ? null : q(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
707
678
|
}
|
|
708
|
-
let
|
|
709
|
-
return
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
679
|
+
let r = e.options.map((e) => e.value);
|
|
680
|
+
return n.every((e) => !Ue(e) || e === null ? !1 : r.includes(e)) ? null : q(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
681
|
+
}
|
|
682
|
+
async function Je(e, t, r, i) {
|
|
683
|
+
if (t.validation && !n(t.validation) && !J(r)) {
|
|
684
|
+
let n = i ? {
|
|
685
|
+
$input: r,
|
|
686
|
+
responses: i
|
|
687
|
+
} : { $input: r }, a = await e(t.validation, n);
|
|
688
|
+
if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
|
|
689
|
+
if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
690
|
+
}
|
|
691
|
+
return t.required && J(r) ? q(t, r, "This field is required", "Field is required.") : !t.multiple && Array.isArray(r) && r.length > 1 ? q(t, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
715
692
|
}
|
|
716
|
-
|
|
717
|
-
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/entities/response/response.ts
|
|
695
|
+
var Ye = E("response"), Xe = j(({ client: e }) => {
|
|
696
|
+
let n = Ye.store({}), r = O(), i = O(), a = T(n, {
|
|
718
697
|
register(e, t) {
|
|
719
698
|
return {
|
|
720
699
|
...e,
|
|
721
|
-
[t.
|
|
700
|
+
[t.fieldKey]: t.response
|
|
722
701
|
};
|
|
723
702
|
},
|
|
724
703
|
registerBatch(e, t) {
|
|
@@ -738,136 +717,140 @@ var Ye = O("response"), Xe = N(({ client: e }) => {
|
|
|
738
717
|
if (typeof e == "string") {
|
|
739
718
|
if (t === void 0) throw Error("Response is required when registering a single field");
|
|
740
719
|
a.register({
|
|
741
|
-
|
|
720
|
+
fieldKey: e,
|
|
742
721
|
response: t
|
|
743
722
|
});
|
|
744
723
|
} else a.registerBatch(e);
|
|
745
724
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
725
|
+
let s = (n, r) => t(e, n, r), c = C({
|
|
726
|
+
source: {
|
|
727
|
+
allFields: e.fields.listStore,
|
|
728
|
+
existingResponses: n
|
|
729
|
+
},
|
|
730
|
+
effect: async ({ allFields: e, existingResponses: t }, n) => {
|
|
731
|
+
let r = [], i = {}, a = {
|
|
732
|
+
...t,
|
|
733
|
+
...n
|
|
734
|
+
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
735
|
+
let o = We(t, e);
|
|
736
|
+
if (!o) {
|
|
737
|
+
r.push({
|
|
738
|
+
fieldKey: t,
|
|
739
|
+
userMessage: `Field '${t}' not found`,
|
|
740
|
+
systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
|
|
741
|
+
value: n
|
|
742
|
+
});
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
let c = Ge(o, n), l = await Je(s, o, c, a);
|
|
746
|
+
if (l) {
|
|
747
|
+
r.push(l);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
let u = Ke(o, c);
|
|
751
|
+
if (u) {
|
|
752
|
+
r.push(u);
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
let d = qe(o, c);
|
|
756
|
+
if (d) {
|
|
757
|
+
r.push(d);
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
i[o.key] = n;
|
|
761
|
+
}));
|
|
762
|
+
for (let [e, t] of c.entries()) {
|
|
763
|
+
if (t.status !== "rejected") continue;
|
|
764
|
+
let n = o[e];
|
|
765
|
+
if (!n) continue;
|
|
766
|
+
let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
|
|
767
|
+
r.push({
|
|
768
|
+
fieldKey: i,
|
|
769
|
+
userMessage: "An unexpected error occurred validating this field",
|
|
770
|
+
systemMessage: `Validation threw for field '${i}': ${s}`,
|
|
771
|
+
value: a
|
|
784
772
|
});
|
|
785
|
-
return;
|
|
786
773
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
if (u) {
|
|
794
|
-
n.push(u);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
let d = Je(a, o, c);
|
|
798
|
-
d && n.push(d), r[o] = t;
|
|
799
|
-
})), {
|
|
800
|
-
responsesToCommit: r,
|
|
801
|
-
validationErrors: n
|
|
802
|
-
};
|
|
803
|
-
}
|
|
774
|
+
return {
|
|
775
|
+
responsesToCommit: i,
|
|
776
|
+
validationErrors: r
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
});
|
|
804
780
|
async function l(e) {
|
|
805
|
-
|
|
806
|
-
return n.length ? { errors: n } : (a.registerBatch(t), { errors: [] });
|
|
781
|
+
return c(e);
|
|
807
782
|
}
|
|
808
|
-
let u =
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
for (let [r, i] of Object.entries(e)) {
|
|
814
|
-
let e = t.find((e) => e.id === r);
|
|
815
|
-
n[e?.key ?? r] = i;
|
|
783
|
+
let u = C({
|
|
784
|
+
source: n,
|
|
785
|
+
effect: async (e, t) => {
|
|
786
|
+
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
787
|
+
return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
|
|
816
788
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
789
|
+
});
|
|
790
|
+
async function d(e) {
|
|
791
|
+
return u(e);
|
|
792
|
+
}
|
|
793
|
+
let f = n.map((e) => e), p = w({
|
|
794
|
+
responses: n,
|
|
820
795
|
fields: e.fields.listStore
|
|
821
796
|
}, ({ responses: e, fields: t }) => Object.entries(e).map(([e, n]) => ({
|
|
822
|
-
fieldId: e,
|
|
823
|
-
fieldKey:
|
|
797
|
+
fieldId: t.find((t) => t.key === e)?.id ?? e,
|
|
798
|
+
fieldKey: e,
|
|
824
799
|
value: n
|
|
825
800
|
})));
|
|
826
|
-
function m(
|
|
827
|
-
return
|
|
828
|
-
f: e.fields.listStore.map((e) => e.find((e) => e.id ===
|
|
829
|
-
|
|
830
|
-
}, ({ f: e,
|
|
801
|
+
function m(t) {
|
|
802
|
+
return w({
|
|
803
|
+
f: e.fields.listStore.map((e) => e.find((e) => e.id === t || e.key === t) ?? null),
|
|
804
|
+
s: n
|
|
805
|
+
}, ({ f: e, s: t }) => {
|
|
806
|
+
let n = e ? t[e.key] ?? null : null;
|
|
807
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
808
|
+
});
|
|
831
809
|
}
|
|
832
|
-
function h(
|
|
833
|
-
return
|
|
834
|
-
f: e.fields.getByKey(
|
|
835
|
-
s:
|
|
836
|
-
}, ({ f: e, s: t }) =>
|
|
810
|
+
function h(t) {
|
|
811
|
+
return w({
|
|
812
|
+
f: e.fields.getByKey(t),
|
|
813
|
+
s: n
|
|
814
|
+
}, ({ f: e, s: t }) => {
|
|
815
|
+
let n = e ? t[e.key] ?? null : null;
|
|
816
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
817
|
+
});
|
|
837
818
|
}
|
|
838
|
-
function g(
|
|
839
|
-
return
|
|
840
|
-
f: e.fields.getByName(
|
|
841
|
-
s:
|
|
842
|
-
}, ({ f: e, s: t }) =>
|
|
819
|
+
function g(t) {
|
|
820
|
+
return w({
|
|
821
|
+
f: e.fields.getByName(t),
|
|
822
|
+
s: n
|
|
823
|
+
}, ({ f: e, s: t }) => {
|
|
824
|
+
let n = e ? t[e.key] ?? null : null;
|
|
825
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
826
|
+
});
|
|
843
827
|
}
|
|
844
|
-
return
|
|
845
|
-
clock:
|
|
828
|
+
return A({
|
|
829
|
+
clock: r,
|
|
846
830
|
target: a.clearAll
|
|
847
|
-
}),
|
|
831
|
+
}), A({
|
|
848
832
|
clock: i,
|
|
849
833
|
target: a.clear
|
|
850
834
|
}), {
|
|
851
835
|
register: o,
|
|
852
|
-
clearAll:
|
|
836
|
+
clearAll: r,
|
|
853
837
|
clear: i,
|
|
854
|
-
commit:
|
|
855
|
-
getResponsesToCommit:
|
|
838
|
+
commit: d,
|
|
839
|
+
getResponsesToCommit: l,
|
|
856
840
|
listStore: p,
|
|
857
|
-
getAllStore:
|
|
858
|
-
getAllByKeyStore: d,
|
|
841
|
+
getAllStore: f,
|
|
859
842
|
getByFieldId: m,
|
|
860
843
|
getByFieldKey: h,
|
|
861
844
|
getByFieldName: g
|
|
862
845
|
};
|
|
863
846
|
});
|
|
864
847
|
function Ze(e) {
|
|
865
|
-
return
|
|
848
|
+
return M(Xe, e);
|
|
866
849
|
}
|
|
867
850
|
//#endregion
|
|
868
851
|
//#region src/entities/condition/condition.ts
|
|
869
|
-
var Qe =
|
|
870
|
-
let e = Qe.store({}), t =
|
|
852
|
+
var Qe = E("condition"), $e = j(() => {
|
|
853
|
+
let e = Qe.store({}), t = T(e, { register(e, t) {
|
|
871
854
|
return {
|
|
872
855
|
...e,
|
|
873
856
|
[t.condition.id]: t.condition
|
|
@@ -891,12 +874,12 @@ var Qe = O("condition"), $e = N(() => {
|
|
|
891
874
|
};
|
|
892
875
|
});
|
|
893
876
|
function et() {
|
|
894
|
-
return
|
|
877
|
+
return M($e);
|
|
895
878
|
}
|
|
896
879
|
//#endregion
|
|
897
880
|
//#region src/utils/api-url.ts
|
|
898
881
|
function tt() {
|
|
899
|
-
if (
|
|
882
|
+
if (f()) {
|
|
900
883
|
let e = [
|
|
901
884
|
document.currentScript,
|
|
902
885
|
document.getElementById("picked_script"),
|
|
@@ -911,17 +894,17 @@ function tt() {
|
|
|
911
894
|
//#endregion
|
|
912
895
|
//#region src/utils/search-params.ts
|
|
913
896
|
function nt() {
|
|
914
|
-
if (!
|
|
897
|
+
if (!o()) return {};
|
|
915
898
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
916
899
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
917
900
|
for (let r of n) {
|
|
918
901
|
let n = r.replace("picked-", "");
|
|
919
902
|
t[n] = e.getAll(r);
|
|
920
903
|
}
|
|
921
|
-
let r =
|
|
922
|
-
if (n.size > 0)
|
|
904
|
+
let r = S("s");
|
|
905
|
+
if (n.size > 0) x.set(r, t);
|
|
923
906
|
else {
|
|
924
|
-
let e =
|
|
907
|
+
let e = x.get(r);
|
|
925
908
|
if (e) return e.json() || {};
|
|
926
909
|
}
|
|
927
910
|
return t;
|
|
@@ -929,10 +912,10 @@ function nt() {
|
|
|
929
912
|
//#endregion
|
|
930
913
|
//#region src/utils/user-session.ts
|
|
931
914
|
function rt() {
|
|
932
|
-
return
|
|
915
|
+
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)}`;
|
|
933
916
|
}
|
|
934
|
-
var it =
|
|
935
|
-
let e =
|
|
917
|
+
var it = S("session", "global"), X = () => {
|
|
918
|
+
let e = b.get(it), t;
|
|
936
919
|
e.isSet() && (t = e.json());
|
|
937
920
|
let n = (t) => e.set({
|
|
938
921
|
id: t.id,
|
|
@@ -956,14 +939,14 @@ var it = w("session", "global"), X = () => {
|
|
|
956
939
|
}
|
|
957
940
|
};
|
|
958
941
|
return n(r), r;
|
|
959
|
-
}, at = () =>
|
|
942
|
+
}, at = () => u() ? X() : null;
|
|
960
943
|
//#endregion
|
|
961
944
|
//#region src/utils/picked-config.ts
|
|
962
945
|
function Z() {
|
|
963
|
-
if (
|
|
946
|
+
if (o()) return globalThis.window.pickedConfig;
|
|
964
947
|
}
|
|
965
948
|
function ot() {
|
|
966
|
-
if (!
|
|
949
|
+
if (!o()) return;
|
|
967
950
|
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
968
951
|
return t && n ? {
|
|
969
952
|
organizationId: t,
|
|
@@ -971,7 +954,7 @@ function ot() {
|
|
|
971
954
|
} : void 0;
|
|
972
955
|
}
|
|
973
956
|
function st() {
|
|
974
|
-
if (!
|
|
957
|
+
if (!f()) return;
|
|
975
958
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
976
959
|
if (!e) return;
|
|
977
960
|
let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
|
|
@@ -1054,13 +1037,12 @@ function pt(e, t) {
|
|
|
1054
1037
|
//#endregion
|
|
1055
1038
|
//#region src/picked.ts
|
|
1056
1039
|
var $ = class {
|
|
1057
|
-
static logger =
|
|
1040
|
+
static logger = r;
|
|
1058
1041
|
options;
|
|
1059
1042
|
isReady = !1;
|
|
1060
|
-
project;
|
|
1061
1043
|
plugins = {};
|
|
1062
1044
|
pluginStartHooks = [];
|
|
1063
|
-
eventBus =
|
|
1045
|
+
eventBus = O();
|
|
1064
1046
|
events;
|
|
1065
1047
|
organizationId;
|
|
1066
1048
|
projectId;
|
|
@@ -1074,41 +1056,41 @@ var $ = class {
|
|
|
1074
1056
|
searchParams = nt();
|
|
1075
1057
|
history = ke();
|
|
1076
1058
|
components = pe({ client: this });
|
|
1077
|
-
experienceInstances =
|
|
1078
|
-
experiences =
|
|
1059
|
+
experienceInstances = te({ client: this });
|
|
1060
|
+
experiences = fe({ client: this });
|
|
1079
1061
|
frameworks = ge({ client: this });
|
|
1080
1062
|
predicates = Ce({ client: this });
|
|
1081
1063
|
features = Ee({ client: this });
|
|
1082
1064
|
conditions = et();
|
|
1083
1065
|
fields = Pe();
|
|
1084
1066
|
responses = Ze({ client: this });
|
|
1085
|
-
steps =
|
|
1086
|
-
actions =
|
|
1067
|
+
steps = Le();
|
|
1068
|
+
actions = Ve();
|
|
1087
1069
|
constructor(e) {
|
|
1088
1070
|
this.events = je(this.eventBus);
|
|
1089
1071
|
let { organizationId: t, projectId: n } = ct(e);
|
|
1090
1072
|
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1091
1073
|
type: "load",
|
|
1092
|
-
version:
|
|
1074
|
+
version: se()
|
|
1093
1075
|
});
|
|
1094
1076
|
}
|
|
1095
1077
|
start = () => {
|
|
1096
1078
|
be(this), (async () => {
|
|
1097
|
-
if (!
|
|
1079
|
+
if (!f()) return;
|
|
1098
1080
|
await this.runPluginStartHooks();
|
|
1099
1081
|
let e = await this.evaluateGate(this.precondition);
|
|
1100
1082
|
this.preconditionPassed = e;
|
|
1101
|
-
let
|
|
1102
|
-
e && (
|
|
1103
|
-
let
|
|
1104
|
-
if (typeof
|
|
1105
|
-
let e =
|
|
1083
|
+
let t;
|
|
1084
|
+
e && (t = await this.evaluateGate(this.condition));
|
|
1085
|
+
let n = e && t === !0;
|
|
1086
|
+
if (typeof t == "boolean" && this.session) {
|
|
1087
|
+
let e = t;
|
|
1106
1088
|
this.session.setIsUser(e), this.eventBus({
|
|
1107
1089
|
type: "user_decide",
|
|
1108
1090
|
value: e
|
|
1109
1091
|
});
|
|
1110
1092
|
}
|
|
1111
|
-
if (this.eventBus({ type: "initialize" }),
|
|
1093
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await ie(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1112
1094
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1113
1095
|
this.eventBus({
|
|
1114
1096
|
type: "session",
|
|
@@ -1123,10 +1105,10 @@ var $ = class {
|
|
|
1123
1105
|
_e(e, this.frameworks);
|
|
1124
1106
|
};
|
|
1125
1107
|
registerComponent = (e, t) => {
|
|
1126
|
-
|
|
1108
|
+
H(e, t, this.components);
|
|
1127
1109
|
};
|
|
1128
1110
|
registerPlugin = (e) => {
|
|
1129
|
-
|
|
1111
|
+
L(this, e, this.plugins);
|
|
1130
1112
|
let t = this.plugins[e.name];
|
|
1131
1113
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1132
1114
|
};
|
|
@@ -1140,18 +1122,18 @@ var $ = class {
|
|
|
1140
1122
|
this.conditions.register(e);
|
|
1141
1123
|
};
|
|
1142
1124
|
registerField = (e) => {
|
|
1143
|
-
|
|
1125
|
+
this.fields.register(e);
|
|
1144
1126
|
};
|
|
1145
1127
|
registerStep = (e) => {
|
|
1146
|
-
|
|
1128
|
+
Re(e, this.steps);
|
|
1147
1129
|
};
|
|
1148
1130
|
registerAction = (e, t) => {
|
|
1149
|
-
|
|
1131
|
+
He(e, t, this.actions);
|
|
1150
1132
|
};
|
|
1151
1133
|
registerExperience = (e) => {
|
|
1152
|
-
e.component &&
|
|
1134
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1153
1135
|
};
|
|
1154
|
-
getStateSnapshot = () =>
|
|
1136
|
+
getStateSnapshot = () => U(this);
|
|
1155
1137
|
launchExperienceById = async (e, t) => {
|
|
1156
1138
|
this.experiences.launch({
|
|
1157
1139
|
key: e,
|
|
@@ -1165,7 +1147,7 @@ var $ = class {
|
|
|
1165
1147
|
for (let e of this.pluginStartHooks) await e();
|
|
1166
1148
|
}
|
|
1167
1149
|
async evaluateGate(e) {
|
|
1168
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await
|
|
1150
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
|
|
1169
1151
|
}
|
|
1170
1152
|
setupPlugins() {
|
|
1171
1153
|
this.options.plugins?.forEach((e) => {
|
|
@@ -1252,7 +1234,7 @@ function ht(e) {
|
|
|
1252
1234
|
//#region src/exports.ts
|
|
1253
1235
|
var gt = (e) => {
|
|
1254
1236
|
let t = new $(e);
|
|
1255
|
-
return
|
|
1237
|
+
return d(t), t;
|
|
1256
1238
|
};
|
|
1257
1239
|
//#endregion
|
|
1258
|
-
export { $ as Picked, gt as createClient,
|
|
1240
|
+
export { $ as Picked, gt as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, ht as isLazyLoader, ee as isPickedRoot, mt as lazyComponent, b as localStore, x as sessionStore, y 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 };
|