@picked/client 0.0.51-next.1 → 0.0.51-next.11
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-CsptHpxs.cjs +1 -0
- package/dist/{api-Brluf3C1.js → api-D900ITyE.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- 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/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/form/index.js +82 -76
- package/dist/esm/index.js +436 -355
- package/dist/esm/plugins/create-experience/index.js +181 -154
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- package/dist/esm/plugins/responses-browser-storage/index.js +6 -8
- package/dist/esm/plugins/responses-indexeddb/index.js +8 -4
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-DOcd8XI1.cjs +1 -0
- package/dist/{experience-instance-CIbQp9D7.js → experience-instance-NHU1moID.js} +37 -32
- package/dist/{rules-logic-BIkBWZmf.js → rules-logic-CnVktz2l.js} +9 -2
- package/dist/{rules-logic-DDxCiq4P.cjs → rules-logic-nMHNVLn7.cjs} +1 -1
- package/dist/types/client.d.ts +47 -43
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +37 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +20 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +63 -47
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +22 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +13 -2
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +74 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -20
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +42 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/form/build-responses.d.ts +12 -9
- package/dist/types/form/build-responses.d.ts.map +1 -1
- package/dist/types/form/create-field-evaluator.d.ts +11 -3
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
- package/dist/types/form/create-field-validation.d.ts +4 -4
- package/dist/types/form/create-field-validation.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +1 -0
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +19 -7
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/form/get-step-fields.d.ts +13 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +98 -31
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +31 -11
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +2 -2
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +45 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -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/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +13 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/state-snaphot.d.ts +11 -1
- package/dist/types/utils/state-snaphot.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/api-A3gUhQJc.cjs +0 -1
- package/dist/experience-instance-Dri5yAp1.cjs +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { n as e, t } from "../rules-logic-
|
|
1
|
+
import { n as e, t } from "../rules-logic-CnVktz2l.js";
|
|
2
2
|
import { t as n } from "../object-C82v79xc.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
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
5
|
+
import { a as g, c as _, i as v, l as ee, n as te, o as ne, r as re, s as y } from "../experience-instance-NHU1moID.js";
|
|
6
|
+
import { i as ie, n as b, r as x, t as S } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as ae, r as oe } from "../api-D900ITyE.js";
|
|
8
|
+
import { t as se } from "../id-CRqy981z.js";
|
|
9
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
10
|
import { createFactory as j, invoke as M } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var N = E("experience"),
|
|
12
|
+
var N = E("experience"), ce = j(({ client: e, experience: t }) => {
|
|
13
13
|
let n = N.store(t), r = T(n, { merge(e, t) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
@@ -19,27 +19,31 @@ var N = E("experience"), se = j(({ client: e, experience: t }) => {
|
|
|
19
19
|
name: e.name,
|
|
20
20
|
decisionLogic: e.condition,
|
|
21
21
|
targetSelectors: e.targets,
|
|
22
|
-
initializeOpenLogic:
|
|
23
|
-
})), a = e.components.listStore
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(re).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
25
|
+
return {
|
|
26
|
+
steps: r,
|
|
27
|
+
nodes: e.nodes,
|
|
28
|
+
edges: e.edges,
|
|
29
|
+
conditions: i
|
|
30
|
+
};
|
|
31
|
+
}), s = t.actions ?? [];
|
|
29
32
|
return {
|
|
30
33
|
id: t.id,
|
|
34
|
+
key: t.key,
|
|
35
|
+
name: t.name,
|
|
31
36
|
configStore: i,
|
|
32
37
|
treeStore: o,
|
|
33
|
-
fieldsStore: s,
|
|
34
38
|
componentStore: a,
|
|
35
|
-
actions:
|
|
39
|
+
actions: s,
|
|
36
40
|
merge: r.merge
|
|
37
41
|
};
|
|
38
42
|
});
|
|
39
|
-
function
|
|
40
|
-
return M(
|
|
43
|
+
function le(e) {
|
|
44
|
+
return M(ce, e);
|
|
41
45
|
}
|
|
42
|
-
var
|
|
46
|
+
var ue = j(({ client: e }) => {
|
|
43
47
|
let t = N.store({}), n = T(t, { register(e, t) {
|
|
44
48
|
return {
|
|
45
49
|
...e,
|
|
@@ -55,7 +59,7 @@ var le = j(({ client: e }) => {
|
|
|
55
59
|
});
|
|
56
60
|
return;
|
|
57
61
|
}
|
|
58
|
-
let a =
|
|
62
|
+
let a = le({
|
|
59
63
|
client: e,
|
|
60
64
|
experience: r
|
|
61
65
|
});
|
|
@@ -65,35 +69,49 @@ var le = j(({ client: e }) => {
|
|
|
65
69
|
function a(e) {
|
|
66
70
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
function o(e) {
|
|
73
|
+
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
74
|
+
}
|
|
75
|
+
let s = C({
|
|
69
76
|
source: t,
|
|
70
|
-
effect: async (t,
|
|
71
|
-
let
|
|
72
|
-
if (!
|
|
73
|
-
`${n}`;
|
|
77
|
+
effect: async (t, n) => {
|
|
78
|
+
let r = "key" in n ? Object.values(t).find((e) => e.key === n.key) : t[n.id];
|
|
79
|
+
if (!r) {
|
|
80
|
+
"key" in n ? `${n.key}` : `${n.id}`;
|
|
74
81
|
return;
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
let { options: i } = n;
|
|
84
|
+
if (i?.bypassCondition) {
|
|
85
|
+
P(e, r, i);
|
|
78
86
|
return;
|
|
79
87
|
}
|
|
80
|
-
await I(e,
|
|
88
|
+
await I(e, r) && P(e, r, i);
|
|
81
89
|
}
|
|
82
90
|
});
|
|
83
91
|
return {
|
|
84
92
|
register: r,
|
|
85
93
|
get: a,
|
|
86
94
|
getById: a,
|
|
87
|
-
|
|
95
|
+
getByKey: o,
|
|
96
|
+
launch: s,
|
|
88
97
|
open: C({
|
|
89
|
-
source:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
source: {
|
|
99
|
+
experiences: t,
|
|
100
|
+
instances: e.experienceInstances.listStore
|
|
101
|
+
},
|
|
102
|
+
effect: ({ experiences: e, instances: t }, n) => {
|
|
103
|
+
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
|
|
104
|
+
if (i.length > 0) for (let e of i) e.open();
|
|
105
|
+
else s("key" in n ? {
|
|
106
|
+
key: n.key,
|
|
95
107
|
options: {
|
|
96
|
-
...n,
|
|
108
|
+
...n.options,
|
|
109
|
+
initialiseOpen: !0
|
|
110
|
+
}
|
|
111
|
+
} : {
|
|
112
|
+
id: n.id,
|
|
113
|
+
options: {
|
|
114
|
+
...n.options,
|
|
97
115
|
initialiseOpen: !0
|
|
98
116
|
}
|
|
99
117
|
});
|
|
@@ -102,14 +120,12 @@ var le = j(({ client: e }) => {
|
|
|
102
120
|
listStore: i
|
|
103
121
|
};
|
|
104
122
|
});
|
|
105
|
-
function
|
|
106
|
-
return M(
|
|
123
|
+
function de(e) {
|
|
124
|
+
return M(ue, e);
|
|
107
125
|
}
|
|
108
|
-
var
|
|
109
|
-
t.
|
|
110
|
-
}
|
|
111
|
-
let { targetSelectors: r } = t.configStore.getState(), i = v(r, t.id);
|
|
112
|
-
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), te(i, t.id).forEach((r) => {
|
|
126
|
+
var P = (e, t, n) => {
|
|
127
|
+
let { targetSelectors: r } = t.configStore.getState(), i = y(r, t.id);
|
|
128
|
+
i.forEach(({ elements: e }) => e.forEach((e) => ee(e, t.id))), g(i, t.id).forEach((r) => {
|
|
113
129
|
n ? e.experienceInstances.spawn(t, r, n) : e.experienceInstances.spawn(t, r);
|
|
114
130
|
});
|
|
115
131
|
}, F = async (e) => {
|
|
@@ -119,8 +135,8 @@ var de = (e, t) => {
|
|
|
119
135
|
}, I = async (n, r) => {
|
|
120
136
|
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
121
137
|
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
122
|
-
return
|
|
123
|
-
},
|
|
138
|
+
return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
139
|
+
}, fe = (e, t, n) => {
|
|
124
140
|
let r = t.name, i = t.setup(e);
|
|
125
141
|
if (i) {
|
|
126
142
|
let e = n[r] ?? {};
|
|
@@ -129,16 +145,16 @@ var de = (e, t) => {
|
|
|
129
145
|
...i
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
},
|
|
148
|
+
}, L = E("component"), R = j(({ client: e, component: t, name: n }) => ({
|
|
133
149
|
name: n,
|
|
134
150
|
component: t,
|
|
135
151
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
136
152
|
}));
|
|
137
|
-
function
|
|
138
|
-
return M(
|
|
153
|
+
function z(e) {
|
|
154
|
+
return M(R, e);
|
|
139
155
|
}
|
|
140
|
-
var
|
|
141
|
-
let t =
|
|
156
|
+
var B = j(({ client: e }) => {
|
|
157
|
+
let t = L.store({}), n = T(t, { register(e, t) {
|
|
142
158
|
return {
|
|
143
159
|
...e,
|
|
144
160
|
[t.name]: t
|
|
@@ -146,7 +162,7 @@ var V = j(({ client: e }) => {
|
|
|
146
162
|
} });
|
|
147
163
|
function r(r, i) {
|
|
148
164
|
t.getState()[r] && `${r}`;
|
|
149
|
-
let a =
|
|
165
|
+
let a = z({
|
|
150
166
|
client: e,
|
|
151
167
|
name: r,
|
|
152
168
|
component: i
|
|
@@ -163,13 +179,13 @@ var V = j(({ client: e }) => {
|
|
|
163
179
|
listStore: i
|
|
164
180
|
};
|
|
165
181
|
});
|
|
166
|
-
function
|
|
167
|
-
return M(
|
|
182
|
+
function V(e) {
|
|
183
|
+
return M(B, e);
|
|
168
184
|
}
|
|
169
|
-
var
|
|
185
|
+
var H = (e, t, n) => {
|
|
170
186
|
n.register(e, t);
|
|
171
|
-
},
|
|
172
|
-
let t =
|
|
187
|
+
}, pe = E("framework"), me = j(({ client: e }) => {
|
|
188
|
+
let t = pe.store({}), n = T(t, { register(e, t) {
|
|
173
189
|
return {
|
|
174
190
|
...e,
|
|
175
191
|
[t.name]: t.framework
|
|
@@ -191,21 +207,21 @@ var U = (e, t, n) => {
|
|
|
191
207
|
listStore: i
|
|
192
208
|
};
|
|
193
209
|
});
|
|
194
|
-
function
|
|
195
|
-
return M(
|
|
210
|
+
function he(e) {
|
|
211
|
+
return M(me, e);
|
|
196
212
|
}
|
|
197
|
-
var
|
|
213
|
+
var ge = (e, t) => {
|
|
198
214
|
t.register(e.name, e);
|
|
199
|
-
},
|
|
215
|
+
}, _e = 6e3, ve = S("last_ping", "global"), ye = async (e) => {
|
|
200
216
|
try {
|
|
201
|
-
let t = Date.now(), n = b.get(
|
|
202
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
217
|
+
let t = Date.now(), n = b.get(ve), r = 0;
|
|
218
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < _e) return !0;
|
|
203
219
|
let i = {
|
|
204
220
|
projectId: e.projectId,
|
|
205
221
|
path: window.location.pathname
|
|
206
222
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
207
223
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
208
|
-
let s = (await
|
|
224
|
+
let s = (await ae(e.apiUrl, "ping", i, a)).ok;
|
|
209
225
|
return s && n.set(t), s;
|
|
210
226
|
} catch {
|
|
211
227
|
return !1;
|
|
@@ -213,7 +229,7 @@ var he = (e, t) => {
|
|
|
213
229
|
};
|
|
214
230
|
//#endregion
|
|
215
231
|
//#region src/utils/state-snaphot.ts
|
|
216
|
-
function
|
|
232
|
+
function U(e) {
|
|
217
233
|
let t = typeof window < "u", n = {
|
|
218
234
|
client: e,
|
|
219
235
|
responses: e.responses.listStore.getState(),
|
|
@@ -227,8 +243,8 @@ function W(e) {
|
|
|
227
243
|
}
|
|
228
244
|
//#endregion
|
|
229
245
|
//#region src/entities/predicate/predicate.ts
|
|
230
|
-
var
|
|
231
|
-
let t =
|
|
246
|
+
var be = E("predicate"), xe = j(({ client: e }) => {
|
|
247
|
+
let t = be.store({}), n = T(t, { register(e, t) {
|
|
232
248
|
return {
|
|
233
249
|
...e,
|
|
234
250
|
[t.name]: {
|
|
@@ -251,7 +267,7 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
251
267
|
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
252
268
|
let n = a(t).getState();
|
|
253
269
|
if (!n) return;
|
|
254
|
-
let r =
|
|
270
|
+
let r = U(e);
|
|
255
271
|
return (...e) => n({
|
|
256
272
|
...r,
|
|
257
273
|
args: e
|
|
@@ -276,13 +292,13 @@ var ye = E("predicate"), be = j(({ client: e }) => {
|
|
|
276
292
|
getEvokablePredicate: o
|
|
277
293
|
};
|
|
278
294
|
});
|
|
279
|
-
function
|
|
280
|
-
return M(
|
|
295
|
+
function Se(e) {
|
|
296
|
+
return M(xe, e);
|
|
281
297
|
}
|
|
282
|
-
var
|
|
298
|
+
var Ce = (e, t, n) => {
|
|
283
299
|
n.register(e, t);
|
|
284
|
-
},
|
|
285
|
-
let t =
|
|
300
|
+
}, W = E("feature"), we = j(({ client: e }) => {
|
|
301
|
+
let t = W.store({}), n = W.store([]), r = T(t, { register(e, t) {
|
|
286
302
|
return {
|
|
287
303
|
...e,
|
|
288
304
|
[t.id]: t.feature
|
|
@@ -436,23 +452,23 @@ var Se = (e, t, n) => {
|
|
|
436
452
|
getEvokableFeature: f
|
|
437
453
|
};
|
|
438
454
|
});
|
|
439
|
-
function
|
|
440
|
-
return M(
|
|
455
|
+
function Te(e) {
|
|
456
|
+
return M(we, e);
|
|
441
457
|
}
|
|
442
|
-
var
|
|
458
|
+
var Ee = (e, t, n) => {
|
|
443
459
|
n.register(e, t);
|
|
444
|
-
},
|
|
445
|
-
function
|
|
460
|
+
}, G = E("history");
|
|
461
|
+
function K(e, t) {
|
|
446
462
|
return {
|
|
447
|
-
id:
|
|
463
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
448
464
|
node: t,
|
|
449
465
|
at: Date.now(),
|
|
450
466
|
experienceId: e
|
|
451
467
|
};
|
|
452
468
|
}
|
|
453
|
-
var
|
|
454
|
-
let e =
|
|
455
|
-
e.on(t, (e, t) => ({ entries: [...e.entries,
|
|
469
|
+
var De = j(() => {
|
|
470
|
+
let e = G.store({ entries: [] }), t = G.event(), n = G.event(), r = G.event(), i = G.event();
|
|
471
|
+
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);
|
|
456
472
|
function a(e, t) {
|
|
457
473
|
let n = {
|
|
458
474
|
lastStepIndex: -1,
|
|
@@ -460,7 +476,7 @@ var Ee = j(() => {
|
|
|
460
476
|
};
|
|
461
477
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
462
478
|
let i = e[r], a = i?.node;
|
|
463
|
-
if (!(!a || !
|
|
479
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
464
480
|
else {
|
|
465
481
|
n.secondLastStepIndex = r;
|
|
466
482
|
break;
|
|
@@ -482,70 +498,108 @@ var Ee = j(() => {
|
|
|
482
498
|
entriesStore: e.map((e) => e.entries)
|
|
483
499
|
};
|
|
484
500
|
});
|
|
485
|
-
function
|
|
486
|
-
return M(
|
|
501
|
+
function Oe() {
|
|
502
|
+
return M(De);
|
|
487
503
|
}
|
|
488
504
|
//#endregion
|
|
489
505
|
//#region src/utils/events.ts
|
|
490
|
-
var
|
|
506
|
+
var ke = 0, Ae = (e) => {
|
|
491
507
|
let t = k([]);
|
|
492
508
|
return A({
|
|
493
509
|
clock: e,
|
|
494
510
|
source: t,
|
|
495
511
|
fn: (e, t) => [...e, {
|
|
496
|
-
id:
|
|
512
|
+
id: ke++,
|
|
497
513
|
at: /* @__PURE__ */ new Date(),
|
|
498
514
|
payload: t
|
|
499
515
|
}],
|
|
500
516
|
target: t
|
|
501
517
|
}), t;
|
|
502
|
-
},
|
|
503
|
-
let e =
|
|
518
|
+
}, je = E("field"), Me = j(() => {
|
|
519
|
+
let e = je.store({}), t = T(e, {
|
|
504
520
|
register(e, t) {
|
|
505
521
|
return {
|
|
506
522
|
...e,
|
|
507
523
|
[t.field.id]: t.field
|
|
508
524
|
};
|
|
509
525
|
},
|
|
510
|
-
|
|
511
|
-
let n = e
|
|
526
|
+
updateByKey(e, t) {
|
|
527
|
+
let n = Object.values(e).find((e) => e.key === t.fieldKey);
|
|
512
528
|
return n ? {
|
|
513
529
|
...e,
|
|
514
|
-
[
|
|
530
|
+
[n.id]: Object.assign({}, n, t.updates)
|
|
515
531
|
} : e;
|
|
516
532
|
}
|
|
517
533
|
});
|
|
518
534
|
function n(e) {
|
|
519
535
|
t.register({ field: e });
|
|
520
536
|
}
|
|
521
|
-
function r(
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
537
|
+
function r(n, r) {
|
|
538
|
+
let i = e.getState(), a = Object.values(i).find((e) => e.key === n)?.key;
|
|
539
|
+
a && t.updateByKey({
|
|
540
|
+
fieldKey: a,
|
|
541
|
+
updates: r
|
|
525
542
|
});
|
|
526
543
|
}
|
|
527
544
|
let i = e.map((e) => Object.values(e));
|
|
528
545
|
function a(t) {
|
|
529
|
-
return e.map((e) => e[t]
|
|
546
|
+
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
530
547
|
}
|
|
531
548
|
function o(t) {
|
|
532
|
-
return e.map((e) => Object.values(e).find((e) => e.
|
|
549
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
|
|
550
|
+
}
|
|
551
|
+
function s(t) {
|
|
552
|
+
return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null, { skipVoid: !1 });
|
|
533
553
|
}
|
|
534
554
|
return {
|
|
535
555
|
register: n,
|
|
536
556
|
update: r,
|
|
537
557
|
getById: a,
|
|
558
|
+
getByKey: o,
|
|
538
559
|
listStore: i,
|
|
539
|
-
getByName:
|
|
560
|
+
getByName: s
|
|
540
561
|
};
|
|
541
562
|
});
|
|
542
|
-
function
|
|
543
|
-
return M(
|
|
563
|
+
function Ne() {
|
|
564
|
+
return M(Me);
|
|
544
565
|
}
|
|
545
|
-
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/entities/step/step.ts
|
|
568
|
+
var Pe = E("step"), Fe = j(() => {
|
|
569
|
+
let e = Pe.store({}), t = T(e, { register(e, t) {
|
|
570
|
+
return {
|
|
571
|
+
...e,
|
|
572
|
+
[t.step.id]: t.step
|
|
573
|
+
};
|
|
574
|
+
} });
|
|
575
|
+
function n(e) {
|
|
576
|
+
t.register({ step: e });
|
|
577
|
+
}
|
|
578
|
+
let r = e.map((e) => Object.values(e));
|
|
579
|
+
function i(t) {
|
|
580
|
+
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
581
|
+
}
|
|
582
|
+
function a(t) {
|
|
583
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
register: n,
|
|
587
|
+
getById: i,
|
|
588
|
+
getByKey: a,
|
|
589
|
+
listStore: r,
|
|
590
|
+
indexStore: e
|
|
591
|
+
};
|
|
592
|
+
});
|
|
593
|
+
function Ie() {
|
|
594
|
+
return M(Fe);
|
|
595
|
+
}
|
|
596
|
+
function Le(e, t) {
|
|
546
597
|
t.register(e);
|
|
547
|
-
}
|
|
548
|
-
|
|
598
|
+
}
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region src/entities/action/action.ts
|
|
601
|
+
var Re = E("action"), ze = j(({ client: e }) => {
|
|
602
|
+
let t = Re.store({}), n = T(t, { register(e, t) {
|
|
549
603
|
return {
|
|
550
604
|
...e,
|
|
551
605
|
[t.name]: {
|
|
@@ -554,56 +608,121 @@ var Me = (e, t) => {
|
|
|
554
608
|
}
|
|
555
609
|
};
|
|
556
610
|
} });
|
|
557
|
-
function
|
|
558
|
-
t.register({
|
|
611
|
+
function r(e, r) {
|
|
612
|
+
t.getState()[e] && `${e}`, n.register(Object.freeze({
|
|
559
613
|
name: e,
|
|
560
|
-
action:
|
|
561
|
-
});
|
|
614
|
+
action: r
|
|
615
|
+
}));
|
|
562
616
|
}
|
|
563
|
-
let
|
|
564
|
-
function
|
|
565
|
-
return
|
|
617
|
+
let i = t.map((e) => Object.values(e));
|
|
618
|
+
function a(e) {
|
|
619
|
+
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
566
620
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
569
|
-
let n =
|
|
570
|
-
|
|
571
|
-
|
|
621
|
+
function o(t) {
|
|
622
|
+
let n = k(() => void 0, { skipVoid: !1 }), r = D(async () => {
|
|
623
|
+
let n = a(t).getState();
|
|
624
|
+
if (!n) return;
|
|
625
|
+
let r = U(e);
|
|
626
|
+
return (...e) => n({
|
|
627
|
+
...r,
|
|
628
|
+
args: e
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
return A({
|
|
632
|
+
source: {
|
|
633
|
+
responses: e.responses.listStore,
|
|
634
|
+
fields: e.fields.listStore
|
|
635
|
+
},
|
|
636
|
+
target: r
|
|
637
|
+
}), A({
|
|
638
|
+
clock: r.doneData,
|
|
639
|
+
filter: (e) => e !== void 0,
|
|
640
|
+
target: n
|
|
641
|
+
}), r(), n;
|
|
572
642
|
}
|
|
573
643
|
return {
|
|
574
|
-
register:
|
|
575
|
-
getByName:
|
|
576
|
-
listStore:
|
|
577
|
-
getEvokableAction:
|
|
644
|
+
register: r,
|
|
645
|
+
getByName: a,
|
|
646
|
+
listStore: i,
|
|
647
|
+
getEvokableAction: o
|
|
578
648
|
};
|
|
579
649
|
});
|
|
580
|
-
function
|
|
581
|
-
return M(
|
|
650
|
+
function Be(e) {
|
|
651
|
+
return M(ze, e);
|
|
582
652
|
}
|
|
583
|
-
var
|
|
653
|
+
var Ve = (e, t, n) => {
|
|
584
654
|
n.register(e, t);
|
|
585
655
|
};
|
|
586
656
|
//#endregion
|
|
587
|
-
//#region src/entities/response/response.ts
|
|
588
|
-
function
|
|
657
|
+
//#region src/entities/response/response-validation.ts
|
|
658
|
+
function q(e, t, n, r) {
|
|
659
|
+
return {
|
|
660
|
+
fieldKey: e.key,
|
|
661
|
+
userMessage: n,
|
|
662
|
+
systemMessage: r,
|
|
663
|
+
value: t
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
function J(e) {
|
|
589
667
|
return e == null || e === "" || Array.isArray(e) && !e.length;
|
|
590
668
|
}
|
|
591
|
-
function
|
|
669
|
+
function He(e) {
|
|
592
670
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
593
671
|
}
|
|
594
|
-
function
|
|
672
|
+
function Y(e) {
|
|
595
673
|
try {
|
|
596
674
|
return JSON.stringify(e), !0;
|
|
597
675
|
} catch {
|
|
598
676
|
return !1;
|
|
599
677
|
}
|
|
600
678
|
}
|
|
601
|
-
|
|
602
|
-
|
|
679
|
+
function Ue(e, t) {
|
|
680
|
+
return t.find((t) => t.key === e) ?? null;
|
|
681
|
+
}
|
|
682
|
+
function We(e, t) {
|
|
683
|
+
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
684
|
+
}
|
|
685
|
+
function Ge(e, t) {
|
|
686
|
+
if (e.type !== "object" || J(t)) return null;
|
|
687
|
+
if (e.multiple) {
|
|
688
|
+
if (!Array.isArray(t)) return q(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
689
|
+
for (let n of t) {
|
|
690
|
+
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.");
|
|
691
|
+
if (!Y(n)) return q(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
692
|
+
}
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
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.).");
|
|
696
|
+
}
|
|
697
|
+
function Ke(e, t) {
|
|
698
|
+
if (!Array.isArray(e.options) || e.options.length === 0) return null;
|
|
699
|
+
let n = Array.isArray(t) ? t : [t];
|
|
700
|
+
if (e.type === "object") {
|
|
701
|
+
let r = e.options.map((e) => JSON.stringify(e.value));
|
|
702
|
+
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.");
|
|
703
|
+
}
|
|
704
|
+
let r = e.options.map((e) => e.value);
|
|
705
|
+
return n.every((e) => !He(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(", ")}`);
|
|
706
|
+
}
|
|
707
|
+
async function qe(e, t, r, i) {
|
|
708
|
+
if (t.validation && !n(t.validation) && !J(r)) {
|
|
709
|
+
let n = i ? {
|
|
710
|
+
$input: r,
|
|
711
|
+
responses: i
|
|
712
|
+
} : { $input: r }, a = await e(t.validation, n);
|
|
713
|
+
if (typeof a == "string") return q(t, r, a, `Field validation resulted in an error: ${a}.`);
|
|
714
|
+
if (a === !1) return q(t, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
715
|
+
}
|
|
716
|
+
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;
|
|
717
|
+
}
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/entities/response/response.ts
|
|
720
|
+
var Je = E("response"), Ye = j(({ client: e }) => {
|
|
721
|
+
let n = Je.store({}), r = O(), i = O(), a = T(n, {
|
|
603
722
|
register(e, t) {
|
|
604
723
|
return {
|
|
605
724
|
...e,
|
|
606
|
-
[t.
|
|
725
|
+
[t.fieldKey]: t.response
|
|
607
726
|
};
|
|
608
727
|
},
|
|
609
728
|
registerBatch(e, t) {
|
|
@@ -613,221 +732,166 @@ var Re = E("response"), ze = j(({ client: e }) => {
|
|
|
613
732
|
};
|
|
614
733
|
},
|
|
615
734
|
clear(e, t) {
|
|
616
|
-
|
|
617
|
-
return r;
|
|
735
|
+
return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
|
|
618
736
|
},
|
|
619
737
|
clearAll() {
|
|
620
738
|
return {};
|
|
621
739
|
}
|
|
622
740
|
});
|
|
623
|
-
function
|
|
741
|
+
function o(e, t) {
|
|
624
742
|
if (typeof e == "string") {
|
|
625
743
|
if (t === void 0) throw Error("Response is required when registering a single field");
|
|
626
|
-
|
|
627
|
-
|
|
744
|
+
a.register({
|
|
745
|
+
fieldKey: e,
|
|
628
746
|
response: t
|
|
629
747
|
});
|
|
630
|
-
} else
|
|
748
|
+
} else a.registerBatch(e);
|
|
631
749
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}, s = await t(e, l.validation, {
|
|
650
|
-
$input: c,
|
|
651
|
-
responses: n
|
|
652
|
-
});
|
|
653
|
-
if (typeof s == "string") {
|
|
654
|
-
a.push({
|
|
655
|
-
fieldId: o,
|
|
656
|
-
userMessage: s,
|
|
657
|
-
systemMessage: `Field validation resulted in an error: ${s}.`,
|
|
658
|
-
value: c
|
|
659
|
-
});
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
if (s === !1) {
|
|
663
|
-
a.push({
|
|
664
|
-
fieldId: o,
|
|
665
|
-
userMessage: "This field is invalid",
|
|
666
|
-
systemMessage: "Field validation resulted in an unspecified error.",
|
|
667
|
-
value: c
|
|
668
|
-
});
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
if (l.required && Y(c)) {
|
|
673
|
-
a.push({
|
|
674
|
-
fieldId: o,
|
|
675
|
-
userMessage: "This field is required",
|
|
676
|
-
systemMessage: "Field is required.",
|
|
677
|
-
value: c
|
|
678
|
-
});
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
if (!l.multiple && Array.isArray(c) && c.length > 1) {
|
|
682
|
-
a.push({
|
|
683
|
-
fieldId: o,
|
|
684
|
-
userMessage: "This field expects a single response",
|
|
685
|
-
systemMessage: "Field expects a single response.",
|
|
686
|
-
value: c
|
|
687
|
-
});
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
if (l.type === "object" && !Y(c)) if (l.multiple) {
|
|
691
|
-
if (!Array.isArray(c)) {
|
|
692
|
-
a.push({
|
|
693
|
-
fieldId: o,
|
|
694
|
-
userMessage: "This field expects multiple values",
|
|
695
|
-
systemMessage: "Field expects an array of objects.",
|
|
696
|
-
value: c
|
|
750
|
+
let s = (n, r) => t(e, n, r), c = C({
|
|
751
|
+
source: {
|
|
752
|
+
allFields: e.fields.listStore,
|
|
753
|
+
existingResponses: n
|
|
754
|
+
},
|
|
755
|
+
effect: async ({ allFields: e, existingResponses: t }, n) => {
|
|
756
|
+
let r = [], i = {}, a = {
|
|
757
|
+
...t,
|
|
758
|
+
...n
|
|
759
|
+
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
760
|
+
let o = Ue(t, e);
|
|
761
|
+
if (!o) {
|
|
762
|
+
r.push({
|
|
763
|
+
fieldKey: t,
|
|
764
|
+
userMessage: `Field '${t}' not found`,
|
|
765
|
+
systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
|
|
766
|
+
value: n
|
|
697
767
|
});
|
|
698
768
|
return;
|
|
699
769
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
fieldId: o,
|
|
704
|
-
userMessage: "This field expects object values",
|
|
705
|
-
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
706
|
-
value: c
|
|
707
|
-
});
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
if (!X(e)) {
|
|
711
|
-
a.push({
|
|
712
|
-
fieldId: o,
|
|
713
|
-
userMessage: "This field contains non-serializable data",
|
|
714
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
715
|
-
value: c
|
|
716
|
-
});
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
} else {
|
|
721
|
-
if (Array.isArray(c)) {
|
|
722
|
-
a.push({
|
|
723
|
-
fieldId: o,
|
|
724
|
-
userMessage: "This field expects a single value",
|
|
725
|
-
systemMessage: "Field expects a single object, not an array.",
|
|
726
|
-
value: c
|
|
727
|
-
});
|
|
770
|
+
let c = We(o, n), l = await qe(s, o, c, a);
|
|
771
|
+
if (l) {
|
|
772
|
+
r.push(l);
|
|
728
773
|
return;
|
|
729
774
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
userMessage: "This field expects an object value",
|
|
734
|
-
systemMessage: "Field expects an object value.",
|
|
735
|
-
value: c
|
|
736
|
-
});
|
|
775
|
+
let u = Ge(o, c);
|
|
776
|
+
if (u) {
|
|
777
|
+
r.push(u);
|
|
737
778
|
return;
|
|
738
779
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
userMessage: "This field contains non-serializable data",
|
|
743
|
-
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
744
|
-
value: c
|
|
745
|
-
});
|
|
780
|
+
let d = Ke(o, c);
|
|
781
|
+
if (d) {
|
|
782
|
+
r.push(d);
|
|
746
783
|
return;
|
|
747
784
|
}
|
|
785
|
+
i[o.key] = n;
|
|
786
|
+
}));
|
|
787
|
+
for (let [e, t] of c.entries()) {
|
|
788
|
+
if (t.status !== "rejected") continue;
|
|
789
|
+
let n = o[e];
|
|
790
|
+
if (!n) continue;
|
|
791
|
+
let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
|
|
792
|
+
r.push({
|
|
793
|
+
fieldKey: i,
|
|
794
|
+
userMessage: "An unexpected error occurred validating this field",
|
|
795
|
+
systemMessage: `Validation threw for field '${i}': ${s}`,
|
|
796
|
+
value: a
|
|
797
|
+
});
|
|
748
798
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
fieldId: o,
|
|
755
|
-
userMessage: "This field expects a valid option",
|
|
756
|
-
systemMessage: "Field expects a valid option from the defined choices.",
|
|
757
|
-
value: c
|
|
758
|
-
});
|
|
759
|
-
} else {
|
|
760
|
-
let t = l.options.map((e) => e.value);
|
|
761
|
-
e.every((e) => !Le(e) || e === null ? !1 : t.includes(e)) || a.push({
|
|
762
|
-
fieldId: o,
|
|
763
|
-
userMessage: "This field expects a valid option",
|
|
764
|
-
systemMessage: `Field expects a valid option. Valid options are: ${t.join(", ")}`,
|
|
765
|
-
value: c
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
})), {
|
|
770
|
-
responsesToCommit: i,
|
|
771
|
-
validationErrors: a
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
let l = C({
|
|
775
|
-
source: r,
|
|
776
|
-
effect: (e, t) => c(e, t)
|
|
799
|
+
return {
|
|
800
|
+
responsesToCommit: i,
|
|
801
|
+
validationErrors: r
|
|
802
|
+
};
|
|
803
|
+
}
|
|
777
804
|
});
|
|
778
|
-
async function
|
|
779
|
-
return
|
|
805
|
+
async function l(e) {
|
|
806
|
+
return c(e);
|
|
780
807
|
}
|
|
781
|
-
let
|
|
782
|
-
source:
|
|
808
|
+
let u = C({
|
|
809
|
+
source: n,
|
|
783
810
|
effect: async (e, t) => {
|
|
784
|
-
let { responsesToCommit: n, validationErrors: r } = await c(
|
|
785
|
-
return r.length ? { errors: r } : (
|
|
811
|
+
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
812
|
+
return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
|
|
786
813
|
}
|
|
787
814
|
});
|
|
788
|
-
async function
|
|
789
|
-
return
|
|
815
|
+
async function d(e) {
|
|
816
|
+
return u(e);
|
|
790
817
|
}
|
|
791
|
-
let
|
|
792
|
-
|
|
793
|
-
value:
|
|
818
|
+
let f = n.map((e) => e), p = n.map((e) => Object.entries(e).map(([e, t]) => ({
|
|
819
|
+
fieldKey: e,
|
|
820
|
+
value: t
|
|
794
821
|
})));
|
|
795
|
-
function
|
|
822
|
+
function m(e) {
|
|
796
823
|
return w({
|
|
797
|
-
f: e
|
|
798
|
-
|
|
799
|
-
}, ({ f: e,
|
|
824
|
+
f: e,
|
|
825
|
+
s: n
|
|
826
|
+
}, ({ f: e, s: t }) => {
|
|
827
|
+
let n = e ? t[e.key] ?? null : null;
|
|
828
|
+
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
function h(t) {
|
|
832
|
+
return m(e.fields.getById(t));
|
|
800
833
|
}
|
|
801
834
|
function g(t) {
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
835
|
+
return m(e.fields.getByKey(t));
|
|
836
|
+
}
|
|
837
|
+
function _(t) {
|
|
838
|
+
return m(e.fields.getByName(t));
|
|
806
839
|
}
|
|
807
840
|
return A({
|
|
808
|
-
clock:
|
|
809
|
-
target:
|
|
841
|
+
clock: r,
|
|
842
|
+
target: a.clearAll
|
|
810
843
|
}), A({
|
|
811
|
-
clock:
|
|
812
|
-
target:
|
|
844
|
+
clock: i,
|
|
845
|
+
target: a.clear
|
|
813
846
|
}), {
|
|
814
|
-
register:
|
|
815
|
-
clearAll:
|
|
816
|
-
clear:
|
|
817
|
-
commit:
|
|
818
|
-
getResponsesToCommit:
|
|
819
|
-
listStore:
|
|
820
|
-
getAllStore:
|
|
847
|
+
register: o,
|
|
848
|
+
clearAll: r,
|
|
849
|
+
clear: i,
|
|
850
|
+
commit: d,
|
|
851
|
+
getResponsesToCommit: l,
|
|
852
|
+
listStore: p,
|
|
853
|
+
getAllStore: f,
|
|
821
854
|
getByFieldId: h,
|
|
822
|
-
|
|
855
|
+
getByFieldKey: g,
|
|
856
|
+
getByFieldName: _
|
|
823
857
|
};
|
|
824
858
|
});
|
|
825
|
-
function
|
|
826
|
-
return M(
|
|
859
|
+
function Xe(e) {
|
|
860
|
+
return M(Ye, e);
|
|
861
|
+
}
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/entities/condition/condition.ts
|
|
864
|
+
var Ze = E("condition"), Qe = j(() => {
|
|
865
|
+
let e = Ze.store({}), t = T(e, { register(e, t) {
|
|
866
|
+
return {
|
|
867
|
+
...e,
|
|
868
|
+
[t.condition.id]: t.condition
|
|
869
|
+
};
|
|
870
|
+
} });
|
|
871
|
+
function n(e) {
|
|
872
|
+
t.register({ condition: e });
|
|
873
|
+
}
|
|
874
|
+
let r = e.map((e) => Object.values(e));
|
|
875
|
+
function i(t) {
|
|
876
|
+
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
877
|
+
}
|
|
878
|
+
function a(t) {
|
|
879
|
+
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
|
|
880
|
+
}
|
|
881
|
+
return {
|
|
882
|
+
register: n,
|
|
883
|
+
getById: i,
|
|
884
|
+
getByKey: a,
|
|
885
|
+
listStore: r,
|
|
886
|
+
indexStore: e
|
|
887
|
+
};
|
|
888
|
+
});
|
|
889
|
+
function $e() {
|
|
890
|
+
return M(Qe);
|
|
827
891
|
}
|
|
828
892
|
//#endregion
|
|
829
893
|
//#region src/utils/api-url.ts
|
|
830
|
-
function
|
|
894
|
+
function et() {
|
|
831
895
|
if (f()) {
|
|
832
896
|
let e = [
|
|
833
897
|
document.currentScript,
|
|
@@ -842,7 +906,7 @@ function Ve() {
|
|
|
842
906
|
}
|
|
843
907
|
//#endregion
|
|
844
908
|
//#region src/utils/search-params.ts
|
|
845
|
-
function
|
|
909
|
+
function tt() {
|
|
846
910
|
if (!o()) return {};
|
|
847
911
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
848
912
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -860,18 +924,18 @@ function He() {
|
|
|
860
924
|
}
|
|
861
925
|
//#endregion
|
|
862
926
|
//#region src/utils/user-session.ts
|
|
863
|
-
function
|
|
927
|
+
function nt() {
|
|
864
928
|
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)}`;
|
|
865
929
|
}
|
|
866
|
-
var
|
|
867
|
-
let e = b.get(
|
|
930
|
+
var rt = S("session", "global"), it = () => {
|
|
931
|
+
let e = b.get(rt), t;
|
|
868
932
|
e.isSet() && (t = e.json());
|
|
869
933
|
let n = (t) => e.set({
|
|
870
934
|
id: t.id,
|
|
871
935
|
isUser: t.isUser,
|
|
872
936
|
identifiers: t.identifiers
|
|
873
937
|
}), r = {
|
|
874
|
-
id: t?.id ??
|
|
938
|
+
id: t?.id ?? nt(),
|
|
875
939
|
isUser: t?.isUser ?? void 0,
|
|
876
940
|
identifiers: t?.identifiers ?? void 0,
|
|
877
941
|
setIsUser(e) {
|
|
@@ -888,13 +952,13 @@ var We = S("session", "global"), Ge = () => {
|
|
|
888
952
|
}
|
|
889
953
|
};
|
|
890
954
|
return n(r), r;
|
|
891
|
-
},
|
|
955
|
+
}, X = () => u() ? it() : null;
|
|
892
956
|
//#endregion
|
|
893
957
|
//#region src/utils/picked-config.ts
|
|
894
958
|
function Z() {
|
|
895
959
|
if (o()) return globalThis.window.pickedConfig;
|
|
896
960
|
}
|
|
897
|
-
function
|
|
961
|
+
function at() {
|
|
898
962
|
if (!o()) return;
|
|
899
963
|
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
900
964
|
return t && n ? {
|
|
@@ -902,7 +966,7 @@ function qe() {
|
|
|
902
966
|
projectId: n
|
|
903
967
|
} : void 0;
|
|
904
968
|
}
|
|
905
|
-
function
|
|
969
|
+
function ot() {
|
|
906
970
|
if (!f()) return;
|
|
907
971
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
908
972
|
if (!e) return;
|
|
@@ -912,15 +976,15 @@ function Je() {
|
|
|
912
976
|
projectId: n
|
|
913
977
|
} : void 0;
|
|
914
978
|
}
|
|
915
|
-
function
|
|
979
|
+
function st(e) {
|
|
916
980
|
let { organizationId: t, projectId: n } = e;
|
|
917
981
|
if (t && n) return {
|
|
918
982
|
organizationId: t,
|
|
919
983
|
projectId: n
|
|
920
984
|
};
|
|
921
|
-
let r =
|
|
985
|
+
let r = at();
|
|
922
986
|
if (r) return r;
|
|
923
|
-
let i =
|
|
987
|
+
let i = ot();
|
|
924
988
|
if (i) return i;
|
|
925
989
|
throw Error("organizationId and projectId are required. You can provide them via one of:\n (1) createClient({ organizationId, projectId }) options;\n (2) window.pickedConfig = { organizationId, projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.");
|
|
926
990
|
}
|
|
@@ -929,7 +993,7 @@ function Ye(e) {
|
|
|
929
993
|
function Q(e) {
|
|
930
994
|
return e == null || e === "" || Number.isNaN(e);
|
|
931
995
|
}
|
|
932
|
-
var
|
|
996
|
+
var ct = {
|
|
933
997
|
default: (e, t) => Q(e) ? String(t ?? "") : String(e),
|
|
934
998
|
append: (e, t) => t && !Q(e) ? `${e} ${t}` : e,
|
|
935
999
|
prepend: (e, t) => t && !Q(e) ? `${t} ${e}` : e,
|
|
@@ -950,24 +1014,24 @@ var Xe = {
|
|
|
950
1014
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
951
1015
|
}
|
|
952
1016
|
};
|
|
953
|
-
function
|
|
1017
|
+
function lt(e) {
|
|
954
1018
|
return typeof e == "object" && !!e;
|
|
955
1019
|
}
|
|
956
|
-
function
|
|
1020
|
+
function ut(e, t) {
|
|
957
1021
|
let n = t;
|
|
958
|
-
for (let t of e.split(".")) if (
|
|
1022
|
+
for (let t of e.split(".")) if (lt(n) && t in n) n = n[t];
|
|
959
1023
|
else return;
|
|
960
1024
|
return typeof n == "function" ? n() : n;
|
|
961
1025
|
}
|
|
962
|
-
function
|
|
963
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1026
|
+
function dt(e, t) {
|
|
1027
|
+
let n = e.split("|").map((e) => e.trim()), r = ut(n.shift() ?? "", t);
|
|
964
1028
|
for (let e of n) {
|
|
965
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1029
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = ct[i];
|
|
966
1030
|
o && (r = o(r, a));
|
|
967
1031
|
}
|
|
968
1032
|
return Q(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
969
1033
|
}
|
|
970
|
-
function
|
|
1034
|
+
function ft(e, t) {
|
|
971
1035
|
let n = "", r = 0;
|
|
972
1036
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
973
1037
|
r += 2;
|
|
@@ -979,7 +1043,7 @@ function et(e, t) {
|
|
|
979
1043
|
}
|
|
980
1044
|
i += e[r++];
|
|
981
1045
|
}
|
|
982
|
-
n +=
|
|
1046
|
+
n += dt(i.trim(), t);
|
|
983
1047
|
} else n += e[r++];
|
|
984
1048
|
return n;
|
|
985
1049
|
}
|
|
@@ -1002,27 +1066,29 @@ var $ = class {
|
|
|
1002
1066
|
precondition;
|
|
1003
1067
|
condition;
|
|
1004
1068
|
preconditionPassed;
|
|
1005
|
-
searchParams =
|
|
1006
|
-
history =
|
|
1007
|
-
components =
|
|
1008
|
-
experienceInstances =
|
|
1009
|
-
experiences =
|
|
1010
|
-
frameworks =
|
|
1011
|
-
predicates =
|
|
1012
|
-
features =
|
|
1013
|
-
|
|
1014
|
-
fields =
|
|
1015
|
-
|
|
1069
|
+
searchParams = tt();
|
|
1070
|
+
history = Oe();
|
|
1071
|
+
components = V({ client: this });
|
|
1072
|
+
experienceInstances = te({ client: this });
|
|
1073
|
+
experiences = de({ client: this });
|
|
1074
|
+
frameworks = he({ client: this });
|
|
1075
|
+
predicates = Se({ client: this });
|
|
1076
|
+
features = Te({ client: this });
|
|
1077
|
+
conditions = $e();
|
|
1078
|
+
fields = Ne();
|
|
1079
|
+
responses = Xe({ client: this });
|
|
1080
|
+
steps = Ie();
|
|
1081
|
+
actions = Be({ client: this });
|
|
1016
1082
|
constructor(e) {
|
|
1017
|
-
this.events =
|
|
1018
|
-
let { organizationId: t, projectId: n } =
|
|
1019
|
-
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1083
|
+
this.events = Ae(this.eventBus);
|
|
1084
|
+
let { organizationId: t, projectId: n } = st(e);
|
|
1085
|
+
this.organizationId = t, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || et(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.session = X(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1020
1086
|
type: "load",
|
|
1021
|
-
version:
|
|
1087
|
+
version: oe()
|
|
1022
1088
|
});
|
|
1023
1089
|
}
|
|
1024
1090
|
start = () => {
|
|
1025
|
-
|
|
1091
|
+
ye(this), (async () => {
|
|
1026
1092
|
if (!f()) return;
|
|
1027
1093
|
await this.runPluginStartHooks();
|
|
1028
1094
|
let e = await this.evaluateGate(this.precondition);
|
|
@@ -1037,7 +1103,7 @@ var $ = class {
|
|
|
1037
1103
|
value: e
|
|
1038
1104
|
});
|
|
1039
1105
|
}
|
|
1040
|
-
if (this.eventBus({ type: "initialize" }), n && F(this), await
|
|
1106
|
+
if (this.eventBus({ type: "initialize" }), n && F(this), await ne(), n && F(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1041
1107
|
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1042
1108
|
this.eventBus({
|
|
1043
1109
|
type: "session",
|
|
@@ -1049,41 +1115,56 @@ var $ = class {
|
|
|
1049
1115
|
})();
|
|
1050
1116
|
};
|
|
1051
1117
|
registerFramework = (e) => {
|
|
1052
|
-
|
|
1118
|
+
ge(e, this.frameworks);
|
|
1053
1119
|
};
|
|
1054
1120
|
registerComponent = (e, t) => {
|
|
1055
|
-
|
|
1121
|
+
H(e, t, this.components);
|
|
1056
1122
|
};
|
|
1057
1123
|
registerPlugin = (e) => {
|
|
1058
|
-
|
|
1124
|
+
fe(this, e, this.plugins);
|
|
1059
1125
|
let t = this.plugins[e.name];
|
|
1060
1126
|
t?.onStart && this.pluginStartHooks.push(t.onStart);
|
|
1061
1127
|
};
|
|
1062
1128
|
registerFeature = (e, t) => {
|
|
1063
|
-
|
|
1129
|
+
Ee(e, t, this.features);
|
|
1064
1130
|
};
|
|
1065
1131
|
registerPredicate = (e, t) => {
|
|
1066
|
-
|
|
1132
|
+
Ce(e, t, this.predicates);
|
|
1133
|
+
};
|
|
1134
|
+
registerCondition = (e) => {
|
|
1135
|
+
this.conditions.register(e);
|
|
1067
1136
|
};
|
|
1068
1137
|
registerField = (e) => {
|
|
1069
|
-
|
|
1138
|
+
this.fields.register(e);
|
|
1139
|
+
};
|
|
1140
|
+
registerStep = (e) => {
|
|
1141
|
+
Le(e, this.steps);
|
|
1070
1142
|
};
|
|
1071
1143
|
registerAction = (e, t) => {
|
|
1072
|
-
|
|
1144
|
+
Ve(e, t, this.actions);
|
|
1073
1145
|
};
|
|
1074
1146
|
registerExperience = (e) => {
|
|
1075
|
-
e.component &&
|
|
1147
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1076
1148
|
};
|
|
1077
|
-
getStateSnapshot = () =>
|
|
1149
|
+
getStateSnapshot = () => U(this);
|
|
1078
1150
|
launchExperienceById = async (e, t) => {
|
|
1079
1151
|
this.experiences.launch({
|
|
1080
1152
|
id: e,
|
|
1081
1153
|
options: t
|
|
1082
1154
|
});
|
|
1083
1155
|
};
|
|
1156
|
+
launchExperienceByKey = async (e, t) => {
|
|
1157
|
+
this.experiences.launch({
|
|
1158
|
+
key: e,
|
|
1159
|
+
options: t
|
|
1160
|
+
});
|
|
1161
|
+
};
|
|
1084
1162
|
openExperienceById = async (e) => {
|
|
1085
1163
|
this.experiences.open({ id: e });
|
|
1086
1164
|
};
|
|
1165
|
+
openExperienceByKey = async (e) => {
|
|
1166
|
+
this.experiences.open({ key: e });
|
|
1167
|
+
};
|
|
1087
1168
|
async runPluginStartHooks() {
|
|
1088
1169
|
for (let e of this.pluginStartHooks) await e();
|
|
1089
1170
|
}
|
|
@@ -1153,8 +1234,8 @@ var $ = class {
|
|
|
1153
1234
|
}
|
|
1154
1235
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1155
1236
|
renderString = (e, t) => {
|
|
1156
|
-
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.
|
|
1157
|
-
return
|
|
1237
|
+
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
|
|
1238
|
+
return ft(e, {
|
|
1158
1239
|
...t,
|
|
1159
1240
|
responses: n
|
|
1160
1241
|
});
|
|
@@ -1162,20 +1243,20 @@ var $ = class {
|
|
|
1162
1243
|
};
|
|
1163
1244
|
//#endregion
|
|
1164
1245
|
//#region src/entities/component/lazyComponent.ts
|
|
1165
|
-
function
|
|
1246
|
+
function pt(e) {
|
|
1166
1247
|
return {
|
|
1167
1248
|
$$type: "lazy-component",
|
|
1168
1249
|
load: e
|
|
1169
1250
|
};
|
|
1170
1251
|
}
|
|
1171
|
-
function
|
|
1252
|
+
function mt(e) {
|
|
1172
1253
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1173
1254
|
}
|
|
1174
1255
|
//#endregion
|
|
1175
1256
|
//#region src/exports.ts
|
|
1176
|
-
var
|
|
1257
|
+
var ht = (e) => {
|
|
1177
1258
|
let t = new $(e);
|
|
1178
1259
|
return d(t), t;
|
|
1179
1260
|
};
|
|
1180
1261
|
//#endregion
|
|
1181
|
-
export { $ as Picked,
|
|
1262
|
+
export { $ as Picked, ht as createClient, S as createStorageKey, t as evaluateRuleLogic, Z as getPickedConfig, mt as isLazyLoader, _ as isPickedRoot, pt as lazyComponent, b as localStore, x as sessionStore, ie 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 };
|