@picked/client 0.0.1-dev.1771981674305 → 0.0.1-dev.1772064704206
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/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +630 -552
- package/dist/esm/plugins/create-experience/index.js +194 -228
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-5rr_D--s.cjs +1 -0
- package/dist/experience-instance-CLR80xop.js +819 -0
- package/dist/types/client.d.ts +0 -10
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +5 -2
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/component/component.d.ts +1 -2
- package/dist/types/entities/component/component.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +2 -2
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +3 -4
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +51 -14
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +1 -4
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +0 -2
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +15 -15
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/ping.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +25 -22
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/utils/get-step-fields.d.ts +2 -1
- package/dist/types/utils/get-step-fields.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +1 -7
- package/dist/api-CbXfbi_s.js +0 -19
- package/dist/api-DzSCgBQ2.cjs +0 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +0 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +0 -102
- package/dist/experience-instance-CU_pYPyd.js +0 -820
- package/dist/experience-instance-D_Mwuzb4.cjs +0 -1
- package/dist/types/entities/component/lazyComponent.d.ts +0 -11
- package/dist/types/entities/component/lazyComponent.d.ts.map +0 -1
- package/dist/types/plugins/dynamic-experiences/hash.d.ts +0 -12
- package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +0 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -3
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +0 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +0 -23
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +0 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -15
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +0 -1
- package/dist/types/utils/api.d.ts +0 -3
- package/dist/types/utils/api.d.ts.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { createDomain as
|
|
2
|
-
import { createFactory as
|
|
3
|
-
import { g as
|
|
4
|
-
import { f as
|
|
5
|
-
import { l as
|
|
6
|
-
import { c as
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const K = F("experience"), pe = w(
|
|
1
|
+
import { createDomain as x, createApi as j, createStore as U, createEffect as C, sample as w, attach as te, combine as E, createEvent as R } from "effector";
|
|
2
|
+
import { createFactory as I, invoke as F } from "@withease/factories";
|
|
3
|
+
import { g as W, t as re, c as ne, i as se, e as A, a as ie, b as oe, d as ae } from "../experience-instance-CLR80xop.js";
|
|
4
|
+
import { f as $t } from "../experience-instance-CLR80xop.js";
|
|
5
|
+
import { l as b } from "../logger-C9a75KZn.js";
|
|
6
|
+
import { c as B, l as O, s as D } from "../storage-Co_LbKr_.js";
|
|
7
|
+
import { a as Ct } from "../storage-Co_LbKr_.js";
|
|
8
|
+
import { g as ce } from "../id-BW-g3y32.js";
|
|
9
|
+
import { i as ue } from "../object-JwZ58NOH.js";
|
|
10
|
+
import { s as _, a as L, b as le, c as de, d as pe } from "../supports-8YT4QKI7.js";
|
|
11
|
+
import { e as Ot, f as Dt, g as Vt, h as Nt, i as Tt, j as Ut, k as _t } from "../supports-8YT4QKI7.js";
|
|
12
|
+
const Y = x("experience"), fe = I(
|
|
14
13
|
({ client: t, experience: e }) => {
|
|
15
|
-
const r =
|
|
16
|
-
merge(p,
|
|
14
|
+
const r = Y.store(e), n = j(r, {
|
|
15
|
+
merge(p, y) {
|
|
17
16
|
return {
|
|
18
17
|
...p,
|
|
19
|
-
...
|
|
18
|
+
...y.experience
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
}), i = r.map((p) => ({
|
|
@@ -25,49 +24,49 @@ const K = F("experience"), pe = w(
|
|
|
25
24
|
targetSelectors: p.targets,
|
|
26
25
|
initializeOpenLogic: e.initializeOpen
|
|
27
26
|
})), d = t.components.listStore.map(
|
|
28
|
-
(p) => p.find((
|
|
27
|
+
(p) => p.find((y) => y.name === `experience:${e.id}`) || p.find((y) => y.name === "experience"),
|
|
29
28
|
{ skipVoid: !1 }
|
|
30
|
-
),
|
|
29
|
+
), l = r.map((p) => ({
|
|
31
30
|
steps: p.steps,
|
|
32
31
|
nodes: p.nodes,
|
|
33
32
|
edges: p.edges,
|
|
34
33
|
conditionals: p.conditionals
|
|
35
|
-
})),
|
|
34
|
+
})), c = r.map((p) => p.fields), g = e.actions ?? [];
|
|
36
35
|
return {
|
|
37
36
|
id: e.id,
|
|
38
37
|
configStore: i,
|
|
39
|
-
treeStore:
|
|
40
|
-
fieldsStore:
|
|
38
|
+
treeStore: l,
|
|
39
|
+
fieldsStore: c,
|
|
41
40
|
componentStore: d,
|
|
42
|
-
actions:
|
|
41
|
+
actions: g,
|
|
43
42
|
merge: n.merge
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
45
|
);
|
|
47
|
-
function
|
|
48
|
-
return
|
|
46
|
+
function ge(t) {
|
|
47
|
+
return F(fe, t);
|
|
49
48
|
}
|
|
50
|
-
const
|
|
51
|
-
const e =
|
|
52
|
-
register(
|
|
49
|
+
const me = I(({ client: t }) => {
|
|
50
|
+
const e = Y.store({}), r = j(e, {
|
|
51
|
+
register(l, c) {
|
|
53
52
|
return {
|
|
54
|
-
...
|
|
55
|
-
[
|
|
53
|
+
...l,
|
|
54
|
+
[c.id]: c
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
|
-
function n(
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
58
|
+
function n(l) {
|
|
59
|
+
const c = e.getState()[l.id];
|
|
60
|
+
if (c) {
|
|
61
|
+
c.merge({ experience: l, strategy: "override" });
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
|
-
const
|
|
66
|
-
r.register(
|
|
64
|
+
const g = ge({ client: t, experience: l });
|
|
65
|
+
r.register(g);
|
|
67
66
|
}
|
|
68
|
-
const i = e.map((
|
|
69
|
-
function d(
|
|
70
|
-
return e.map((
|
|
67
|
+
const i = e.map((l) => Object.values(l));
|
|
68
|
+
function d(l) {
|
|
69
|
+
return e.map((c) => c[l], { skipVoid: !1 });
|
|
71
70
|
}
|
|
72
71
|
return {
|
|
73
72
|
register: n,
|
|
@@ -75,34 +74,34 @@ const ge = w(({ client: t }) => {
|
|
|
75
74
|
listStore: i
|
|
76
75
|
};
|
|
77
76
|
});
|
|
78
|
-
function
|
|
79
|
-
return
|
|
77
|
+
function ye(t) {
|
|
78
|
+
return F(me, t);
|
|
80
79
|
}
|
|
81
80
|
const he = (t, e) => {
|
|
82
81
|
e.register(t);
|
|
83
|
-
},
|
|
84
|
-
const { targetSelectors:
|
|
85
|
-
|
|
86
|
-
({ elements:
|
|
87
|
-
),
|
|
88
|
-
t.experienceInstances.spawn(e,
|
|
82
|
+
}, Q = (t, e) => {
|
|
83
|
+
const { targetSelectors: r } = e.configStore.getState(), n = W(r, e.id);
|
|
84
|
+
n.forEach(
|
|
85
|
+
({ elements: d }) => d.forEach((l) => re(l, e.id))
|
|
86
|
+
), ne(n, e.id).forEach((d) => {
|
|
87
|
+
t.experienceInstances.spawn(e, d);
|
|
89
88
|
});
|
|
90
|
-
},
|
|
89
|
+
}, J = async (t) => {
|
|
91
90
|
await Promise.all(
|
|
92
91
|
t.experiences.listStore.getState().map(async (e) => {
|
|
93
|
-
await
|
|
92
|
+
await ve(t, e) && Q(t, e);
|
|
94
93
|
})
|
|
95
94
|
);
|
|
96
|
-
},
|
|
95
|
+
}, ve = async (t, e) => {
|
|
97
96
|
const { decisionLogic: r, targetSelectors: n } = e.configStore.getState();
|
|
98
|
-
return
|
|
97
|
+
return W(n, e.id).length < 1 || n.length === 0 ? !1 : r && se(r) ? await A(t, r) === !0 : !0;
|
|
99
98
|
}, Se = (t, e, r) => {
|
|
100
99
|
const n = e.name, i = e.setup(t);
|
|
101
100
|
if (i) {
|
|
102
101
|
const d = r[n] ?? {};
|
|
103
102
|
r[n] = Object.freeze({ ...d, ...i });
|
|
104
103
|
}
|
|
105
|
-
},
|
|
104
|
+
}, ke = x("component"), we = I(
|
|
106
105
|
({ client: t, component: e, name: r }) => {
|
|
107
106
|
const n = t.frameworks.getByName(e.frameworkName);
|
|
108
107
|
return {
|
|
@@ -112,29 +111,29 @@ const he = (t, e) => {
|
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
113
|
);
|
|
115
|
-
function
|
|
116
|
-
return
|
|
114
|
+
function be(t) {
|
|
115
|
+
return F(we, t);
|
|
117
116
|
}
|
|
118
|
-
const
|
|
119
|
-
const e =
|
|
120
|
-
register(
|
|
117
|
+
const Ie = I(({ client: t }) => {
|
|
118
|
+
const e = ke.store({}), r = j(e, {
|
|
119
|
+
register(l, c) {
|
|
121
120
|
return {
|
|
122
|
-
...
|
|
123
|
-
[
|
|
121
|
+
...l,
|
|
122
|
+
[c.name]: c
|
|
124
123
|
};
|
|
125
124
|
}
|
|
126
125
|
});
|
|
127
|
-
function n(
|
|
128
|
-
e.getState()[
|
|
126
|
+
function n(l, c) {
|
|
127
|
+
e.getState()[l] && b(
|
|
129
128
|
"warn",
|
|
130
|
-
`Component '${
|
|
129
|
+
`Component '${l}' already registered. Registering again will override the previous registration.`
|
|
131
130
|
);
|
|
132
|
-
const p =
|
|
131
|
+
const p = be({ client: t, name: l, component: c });
|
|
133
132
|
r.register(p);
|
|
134
133
|
}
|
|
135
|
-
const i = e.map((
|
|
136
|
-
function d(
|
|
137
|
-
return e.map((
|
|
134
|
+
const i = e.map((l) => Object.values(l));
|
|
135
|
+
function d(l) {
|
|
136
|
+
return e.map((c) => c[l], { skipVoid: !1 });
|
|
138
137
|
}
|
|
139
138
|
return {
|
|
140
139
|
register: n,
|
|
@@ -142,29 +141,29 @@ const be = w(({ client: t }) => {
|
|
|
142
141
|
listStore: i
|
|
143
142
|
};
|
|
144
143
|
});
|
|
145
|
-
function
|
|
146
|
-
return
|
|
144
|
+
function Fe(t) {
|
|
145
|
+
return F(Ie, t);
|
|
147
146
|
}
|
|
148
|
-
const
|
|
147
|
+
const H = (t, e, r) => {
|
|
149
148
|
r.register(t, e);
|
|
150
|
-
},
|
|
151
|
-
const e =
|
|
152
|
-
register(
|
|
149
|
+
}, xe = x("framework"), je = I(({ client: t }) => {
|
|
150
|
+
const e = xe.store({}), r = j(e, {
|
|
151
|
+
register(l, c) {
|
|
153
152
|
return {
|
|
154
|
-
...
|
|
155
|
-
[
|
|
153
|
+
...l,
|
|
154
|
+
[c.name]: c.framework
|
|
156
155
|
};
|
|
157
156
|
}
|
|
158
157
|
});
|
|
159
|
-
function n(
|
|
160
|
-
e.getState()[
|
|
158
|
+
function n(l, c) {
|
|
159
|
+
e.getState()[l] && b(
|
|
161
160
|
"warn",
|
|
162
|
-
`Framework '${
|
|
163
|
-
), r.register({ name:
|
|
161
|
+
`Framework '${l}' already registered. Registering again will override the previous registration.`
|
|
162
|
+
), r.register({ name: l, framework: c });
|
|
164
163
|
}
|
|
165
|
-
const i = e.map((
|
|
166
|
-
function d(
|
|
167
|
-
return e.map((
|
|
164
|
+
const i = e.map((l) => Object.values(l));
|
|
165
|
+
function d(l) {
|
|
166
|
+
return e.map((c) => c[l], { skipVoid: !1 });
|
|
168
167
|
}
|
|
169
168
|
return {
|
|
170
169
|
register: n,
|
|
@@ -172,29 +171,35 @@ const _ = (t, e, r) => {
|
|
|
172
171
|
listStore: i
|
|
173
172
|
};
|
|
174
173
|
});
|
|
175
|
-
function
|
|
176
|
-
return
|
|
174
|
+
function Ae(t) {
|
|
175
|
+
return F(je, t);
|
|
177
176
|
}
|
|
178
177
|
const Ee = (t, e) => {
|
|
179
178
|
e.register(t.name, t);
|
|
180
|
-
}, Pe = 6e3,
|
|
179
|
+
}, Pe = 6e3, Re = B("last_ping", "global"), Be = (t) => `${t}/api/v1/ping`, $e = async (t) => {
|
|
181
180
|
try {
|
|
182
|
-
const e = Date.now(), r =
|
|
181
|
+
const e = Date.now(), r = O.get(Re);
|
|
183
182
|
let n = 0;
|
|
184
183
|
if (r.isSet() && (n = r.json() ?? 0), n && e - n < Pe)
|
|
185
184
|
return !0;
|
|
186
|
-
const i = {
|
|
185
|
+
const i = Be(t.apiUrl), d = {
|
|
187
186
|
projectId: t.projectId,
|
|
188
187
|
path: window.location.pathname
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
}, l = JSON.stringify(d), c = {
|
|
189
|
+
"Content-Type": "application/json"
|
|
190
|
+
}, p = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
191
|
+
p && (c["x-vercel-protection-bypass"] = p);
|
|
192
|
+
const v = (await fetch(i, {
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: c,
|
|
195
|
+
body: l
|
|
196
|
+
})).ok;
|
|
197
|
+
return v && r.set(e), v;
|
|
193
198
|
} catch (e) {
|
|
194
|
-
return
|
|
199
|
+
return b("error", e), !1;
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
|
-
function
|
|
202
|
+
function X(t) {
|
|
198
203
|
const e = typeof window < "u", r = {
|
|
199
204
|
client: t,
|
|
200
205
|
responses: t.responses.listStore.getState(),
|
|
@@ -206,259 +211,259 @@ function Y(t) {
|
|
|
206
211
|
};
|
|
207
212
|
return Object.freeze(r);
|
|
208
213
|
}
|
|
209
|
-
const
|
|
210
|
-
const e =
|
|
211
|
-
register(
|
|
214
|
+
const ze = x("predicate"), Ce = I(({ client: t }) => {
|
|
215
|
+
const e = ze.store({}), r = j(e, {
|
|
216
|
+
register(c, g) {
|
|
212
217
|
return {
|
|
213
|
-
...
|
|
214
|
-
[
|
|
215
|
-
name:
|
|
216
|
-
predicate:
|
|
218
|
+
...c,
|
|
219
|
+
[g.name]: {
|
|
220
|
+
name: g.name,
|
|
221
|
+
predicate: g.predicate
|
|
217
222
|
}
|
|
218
223
|
};
|
|
219
224
|
}
|
|
220
225
|
});
|
|
221
|
-
function n(
|
|
222
|
-
e.getState()[
|
|
226
|
+
function n(c, g) {
|
|
227
|
+
e.getState()[c] && b(
|
|
223
228
|
"warn",
|
|
224
|
-
`Predicate '${
|
|
225
|
-
), r.register(Object.freeze({ name:
|
|
229
|
+
`Predicate '${c}' already registered. Registering again will override the previous registration.`
|
|
230
|
+
), r.register(Object.freeze({ name: c, predicate: g }));
|
|
226
231
|
}
|
|
227
|
-
const i = e.map((
|
|
228
|
-
function d(
|
|
229
|
-
return e.map((
|
|
232
|
+
const i = e.map((c) => Object.values(c));
|
|
233
|
+
function d(c) {
|
|
234
|
+
return e.map((g) => g[c]?.predicate, { skipVoid: !1 });
|
|
230
235
|
}
|
|
231
|
-
function
|
|
232
|
-
const
|
|
236
|
+
function l(c) {
|
|
237
|
+
const g = U(() => {
|
|
233
238
|
}, {
|
|
234
239
|
skipVoid: !1
|
|
235
|
-
}), p =
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
240
|
+
}), p = C(async () => {
|
|
241
|
+
const y = d(c).getState();
|
|
242
|
+
if (!y)
|
|
238
243
|
return;
|
|
239
|
-
const
|
|
240
|
-
return (...m) =>
|
|
244
|
+
const v = X(t);
|
|
245
|
+
return (...m) => y({ ...v, args: m });
|
|
241
246
|
});
|
|
242
|
-
return
|
|
247
|
+
return w({
|
|
243
248
|
source: { responses: t.responses.listStore, fields: t.fields.listStore },
|
|
244
249
|
target: p
|
|
245
|
-
}),
|
|
250
|
+
}), w({
|
|
246
251
|
clock: p.doneData,
|
|
247
|
-
filter: (
|
|
248
|
-
target:
|
|
249
|
-
}), p(),
|
|
252
|
+
filter: (y) => y !== void 0,
|
|
253
|
+
target: g
|
|
254
|
+
}), p(), g;
|
|
250
255
|
}
|
|
251
256
|
return {
|
|
252
257
|
register: n,
|
|
253
258
|
getByName: d,
|
|
254
259
|
listStore: i,
|
|
255
|
-
getEvokablePredicate:
|
|
260
|
+
getEvokablePredicate: l
|
|
256
261
|
};
|
|
257
262
|
});
|
|
258
|
-
function
|
|
259
|
-
return
|
|
263
|
+
function Me(t) {
|
|
264
|
+
return F(Ce, t);
|
|
260
265
|
}
|
|
261
|
-
const
|
|
266
|
+
const Oe = (t, e, r) => {
|
|
262
267
|
r.register(t, e);
|
|
263
|
-
},
|
|
264
|
-
const e =
|
|
265
|
-
register(
|
|
268
|
+
}, G = x("feature"), De = I(({ client: t }) => {
|
|
269
|
+
const e = G.store({}), r = G.store([]), n = j(e, {
|
|
270
|
+
register(u, s) {
|
|
266
271
|
return {
|
|
267
|
-
...
|
|
268
|
-
[
|
|
272
|
+
...u,
|
|
273
|
+
[s.id]: s.feature
|
|
269
274
|
};
|
|
270
275
|
}
|
|
271
276
|
});
|
|
272
|
-
function i(
|
|
273
|
-
e.getState()[
|
|
277
|
+
function i(u, s) {
|
|
278
|
+
e.getState()[u] && b(
|
|
274
279
|
"warn",
|
|
275
|
-
`Feature '${
|
|
280
|
+
`Feature '${u}' already registered. Registering again will override the previous registration.`
|
|
276
281
|
);
|
|
277
|
-
const
|
|
278
|
-
id:
|
|
282
|
+
const a = {
|
|
283
|
+
id: u,
|
|
279
284
|
feature: {
|
|
280
|
-
...
|
|
281
|
-
id:
|
|
285
|
+
...s,
|
|
286
|
+
id: u
|
|
282
287
|
}
|
|
283
288
|
};
|
|
284
289
|
n.register(
|
|
285
290
|
Object.freeze({
|
|
286
|
-
id:
|
|
287
|
-
feature:
|
|
291
|
+
id: u,
|
|
292
|
+
feature: a
|
|
288
293
|
})
|
|
289
294
|
);
|
|
290
295
|
}
|
|
291
|
-
const d =
|
|
296
|
+
const d = C(
|
|
292
297
|
async ({
|
|
293
|
-
id:
|
|
294
|
-
key:
|
|
295
|
-
storage:
|
|
298
|
+
id: u,
|
|
299
|
+
key: s,
|
|
300
|
+
storage: o = "local"
|
|
296
301
|
}) => {
|
|
297
|
-
const
|
|
298
|
-
return
|
|
302
|
+
const a = B(`feature:${u}:${s}`, "global"), h = (o === "session" ? D : O).get(a).boolean();
|
|
303
|
+
return h === null ? null : { id: u, key: s, bucket: h, storage: o };
|
|
299
304
|
}
|
|
300
|
-
),
|
|
301
|
-
if (!
|
|
305
|
+
), l = C((u) => {
|
|
306
|
+
if (!u)
|
|
302
307
|
return null;
|
|
303
|
-
const
|
|
304
|
-
(
|
|
305
|
-
}),
|
|
308
|
+
const s = B(`feature:${u.id}:${u.key}`, "global");
|
|
309
|
+
(u.storage === "session" ? D : O).set(s, u.bucket);
|
|
310
|
+
}), c = /* @__PURE__ */ new Map(), g = te({
|
|
306
311
|
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
307
|
-
effect: async ({ allFeaturesStore:
|
|
308
|
-
const
|
|
309
|
-
(
|
|
312
|
+
effect: async ({ allFeaturesStore: u, resolvedFeaturesStore: s }, { id: o, decide: a, key: f }) => {
|
|
313
|
+
const h = s.find(
|
|
314
|
+
(z) => z.id === o && z.key === f
|
|
310
315
|
);
|
|
311
|
-
if (
|
|
312
|
-
return
|
|
313
|
-
const
|
|
314
|
-
if (!
|
|
315
|
-
throw new Error(`Feature with id '${
|
|
316
|
-
const $ =
|
|
316
|
+
if (h)
|
|
317
|
+
return h;
|
|
318
|
+
const S = u[o];
|
|
319
|
+
if (!S)
|
|
320
|
+
throw new Error(`Feature with id '${o}' not found`);
|
|
321
|
+
const $ = c.get(`${o}:${f}`);
|
|
317
322
|
if ($ !== void 0) {
|
|
318
|
-
const
|
|
319
|
-
return { id:
|
|
323
|
+
const z = await $;
|
|
324
|
+
return { id: S.id, bucket: z, key: f, storage: S.feature.storage };
|
|
320
325
|
}
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
return { id:
|
|
326
|
+
const k = a();
|
|
327
|
+
c.set(`${o}:${f}`, k);
|
|
328
|
+
const ee = await k;
|
|
329
|
+
return { id: S.id, bucket: ee, key: f, storage: S.feature.storage };
|
|
325
330
|
}
|
|
326
331
|
});
|
|
327
|
-
|
|
332
|
+
w({
|
|
328
333
|
clock: n.register,
|
|
329
|
-
fn: (
|
|
330
|
-
const { id:
|
|
331
|
-
return { id:
|
|
334
|
+
fn: (u) => {
|
|
335
|
+
const { id: s, feature: o } = u;
|
|
336
|
+
return { id: s, key: o.feature.key, storage: o.feature.storage };
|
|
332
337
|
},
|
|
333
338
|
target: d
|
|
334
|
-
}),
|
|
339
|
+
}), w({
|
|
335
340
|
source: e,
|
|
336
|
-
clock:
|
|
337
|
-
fn: (
|
|
338
|
-
const { id:
|
|
339
|
-
return
|
|
341
|
+
clock: g.doneData,
|
|
342
|
+
fn: (u, s) => {
|
|
343
|
+
const { id: o, bucket: a, storage: f } = s, h = u[o]?.feature.key;
|
|
344
|
+
return h ? { key: h, id: o, bucket: a, storage: f } : null;
|
|
340
345
|
},
|
|
341
|
-
target:
|
|
346
|
+
target: l
|
|
342
347
|
});
|
|
343
|
-
const p =
|
|
348
|
+
const p = E({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
344
349
|
({
|
|
345
|
-
allFeaturesStore:
|
|
346
|
-
resolvedFeaturesStore:
|
|
347
|
-
}) => Object.values(
|
|
348
|
-
const
|
|
349
|
-
(
|
|
350
|
+
allFeaturesStore: u,
|
|
351
|
+
resolvedFeaturesStore: s
|
|
352
|
+
}) => Object.values(u).map((o) => {
|
|
353
|
+
const a = s.find(
|
|
354
|
+
(f) => f.id === o.id && f.key === o.feature.key
|
|
350
355
|
);
|
|
351
|
-
return
|
|
352
|
-
id:
|
|
353
|
-
name:
|
|
354
|
-
key:
|
|
355
|
-
getBucket: () => ({ id:
|
|
356
|
+
return a ? {
|
|
357
|
+
id: o.id,
|
|
358
|
+
name: o.feature.name,
|
|
359
|
+
key: o.feature.key,
|
|
360
|
+
getBucket: () => ({ id: o.id, bucket: a.bucket }),
|
|
356
361
|
isResolved: !0
|
|
357
362
|
} : {
|
|
358
|
-
id:
|
|
359
|
-
name:
|
|
360
|
-
key:
|
|
361
|
-
getBucket: async () => await
|
|
363
|
+
id: o.id,
|
|
364
|
+
name: o.feature.name,
|
|
365
|
+
key: o.feature.key,
|
|
366
|
+
getBucket: async () => await g(o.feature),
|
|
362
367
|
isResolved: !1
|
|
363
368
|
};
|
|
364
369
|
})
|
|
365
370
|
);
|
|
366
|
-
|
|
367
|
-
clock:
|
|
371
|
+
w({
|
|
372
|
+
clock: g.doneData,
|
|
368
373
|
source: { resolvedFeatures: r },
|
|
369
|
-
filter: ({ resolvedFeatures:
|
|
370
|
-
(
|
|
374
|
+
filter: ({ resolvedFeatures: u }, { id: s, key: o }) => !u.some(
|
|
375
|
+
(f) => f.id === s && f.key === o
|
|
371
376
|
),
|
|
372
|
-
fn: (
|
|
373
|
-
target: t.eventBus.prepend((
|
|
377
|
+
fn: (u, s) => s,
|
|
378
|
+
target: t.eventBus.prepend((u) => ({
|
|
374
379
|
type: "feature_decide",
|
|
375
|
-
feature:
|
|
380
|
+
feature: u
|
|
376
381
|
}))
|
|
377
|
-
}),
|
|
378
|
-
clock: [d.doneData,
|
|
382
|
+
}), w({
|
|
383
|
+
clock: [d.doneData, g.doneData],
|
|
379
384
|
source: r,
|
|
380
|
-
fn: (
|
|
381
|
-
(
|
|
382
|
-
) ?
|
|
385
|
+
fn: (u, s) => !s || u.some(
|
|
386
|
+
(a) => a.id === s.id && a.key === s.key
|
|
387
|
+
) ? u : [...u, s],
|
|
383
388
|
target: r
|
|
384
389
|
});
|
|
385
|
-
function
|
|
386
|
-
return p.map((
|
|
390
|
+
function y(u) {
|
|
391
|
+
return p.map((s) => s.find((o) => o.id === u));
|
|
387
392
|
}
|
|
388
|
-
function
|
|
389
|
-
return e.map((
|
|
393
|
+
function v(u) {
|
|
394
|
+
return e.map((s) => s[u], { skipVoid: !1 });
|
|
390
395
|
}
|
|
391
|
-
function m(
|
|
392
|
-
const
|
|
396
|
+
function m(u) {
|
|
397
|
+
const s = U(
|
|
393
398
|
async () => {
|
|
394
399
|
},
|
|
395
400
|
{ skipVoid: !1 }
|
|
396
|
-
),
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
return async () => (await
|
|
401
|
+
), o = C(async () => {
|
|
402
|
+
const a = y(u).getState();
|
|
403
|
+
if (a)
|
|
404
|
+
return async () => (await a.getBucket()).bucket;
|
|
400
405
|
});
|
|
401
|
-
return
|
|
406
|
+
return w({
|
|
402
407
|
source: r,
|
|
403
|
-
filter: (
|
|
404
|
-
target:
|
|
405
|
-
}),
|
|
406
|
-
clock:
|
|
407
|
-
filter: (
|
|
408
|
-
target:
|
|
409
|
-
}),
|
|
408
|
+
filter: (a) => a.some((f) => f.id === u),
|
|
409
|
+
target: o
|
|
410
|
+
}), w({
|
|
411
|
+
clock: o.doneData,
|
|
412
|
+
filter: (a) => a !== void 0,
|
|
413
|
+
target: s
|
|
414
|
+
}), o(), s;
|
|
410
415
|
}
|
|
411
416
|
return {
|
|
412
417
|
register: i,
|
|
413
|
-
getById:
|
|
414
|
-
getByName:
|
|
418
|
+
getById: y,
|
|
419
|
+
getByName: v,
|
|
415
420
|
listStore: p,
|
|
416
421
|
getEvokableFeature: m
|
|
417
422
|
};
|
|
418
423
|
});
|
|
419
|
-
function
|
|
420
|
-
return
|
|
424
|
+
function Ve(t) {
|
|
425
|
+
return F(De, t);
|
|
421
426
|
}
|
|
422
|
-
const
|
|
427
|
+
const Ne = (t, e, r) => {
|
|
423
428
|
r.register(t, e);
|
|
424
|
-
},
|
|
425
|
-
function
|
|
429
|
+
}, P = x("history");
|
|
430
|
+
function q(t, e) {
|
|
426
431
|
return {
|
|
427
432
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
428
|
-
id:
|
|
433
|
+
id: ce(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
429
434
|
node: e,
|
|
430
435
|
at: Date.now(),
|
|
431
436
|
experienceId: t
|
|
432
437
|
};
|
|
433
438
|
}
|
|
434
|
-
const
|
|
435
|
-
const t =
|
|
436
|
-
t.on(e, (
|
|
437
|
-
entries: [...
|
|
438
|
-
})), t.on(r, (
|
|
439
|
+
const Te = I(() => {
|
|
440
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), i = P.event();
|
|
441
|
+
t.on(e, (l, c) => ({
|
|
442
|
+
entries: [...l.entries, q(c.experienceId, c.node)]
|
|
443
|
+
})), t.on(r, (l, c) => ({
|
|
439
444
|
entries: [
|
|
440
|
-
...
|
|
441
|
-
|
|
445
|
+
...l.entries.slice(0, -1),
|
|
446
|
+
q(c.experienceId, c.node)
|
|
442
447
|
]
|
|
443
|
-
})), t.on(i, (
|
|
444
|
-
function d(
|
|
445
|
-
const
|
|
446
|
-
for (let p =
|
|
447
|
-
const
|
|
448
|
-
if (!(!
|
|
449
|
-
if (
|
|
450
|
-
|
|
448
|
+
})), t.on(i, (l, c) => c);
|
|
449
|
+
function d(l, c) {
|
|
450
|
+
const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
451
|
+
for (let p = l.length - 1; p >= 0; p--) {
|
|
452
|
+
const y = l[p], v = y?.node;
|
|
453
|
+
if (!(!v || !ie(v)) && !(c && y?.experienceId !== c))
|
|
454
|
+
if (g.lastStepIndex === -1)
|
|
455
|
+
g.lastStepIndex = p;
|
|
451
456
|
else {
|
|
452
|
-
|
|
457
|
+
g.secondLastStepIndex = p;
|
|
453
458
|
break;
|
|
454
459
|
}
|
|
455
460
|
}
|
|
456
|
-
return
|
|
461
|
+
return g;
|
|
457
462
|
}
|
|
458
|
-
return t.on(n, (
|
|
459
|
-
const { secondLastStepIndex:
|
|
463
|
+
return t.on(n, (l, c) => {
|
|
464
|
+
const { secondLastStepIndex: g } = d(l.entries, c.experienceId), p = g !== -1 ? l.entries.slice(0, g + 1) : l.entries;
|
|
460
465
|
return {
|
|
461
|
-
...
|
|
466
|
+
...l,
|
|
462
467
|
entries: p
|
|
463
468
|
};
|
|
464
469
|
}), {
|
|
@@ -466,335 +471,430 @@ const Ue = w(() => {
|
|
|
466
471
|
replace: r,
|
|
467
472
|
back: n,
|
|
468
473
|
restore: i,
|
|
469
|
-
entriesStore: t.map((
|
|
474
|
+
entriesStore: t.map((l) => l.entries)
|
|
470
475
|
};
|
|
471
476
|
});
|
|
472
|
-
function
|
|
473
|
-
return
|
|
477
|
+
function Ue() {
|
|
478
|
+
return F(Te);
|
|
474
479
|
}
|
|
475
|
-
let
|
|
476
|
-
const
|
|
477
|
-
const e =
|
|
478
|
-
return
|
|
480
|
+
let _e = 0;
|
|
481
|
+
const Le = (t) => {
|
|
482
|
+
const e = U([]);
|
|
483
|
+
return w({
|
|
479
484
|
clock: t,
|
|
480
485
|
source: e,
|
|
481
486
|
fn: (r, n) => [
|
|
482
487
|
...r,
|
|
483
488
|
{
|
|
484
|
-
id:
|
|
489
|
+
id: _e++,
|
|
485
490
|
at: /* @__PURE__ */ new Date(),
|
|
486
491
|
payload: n
|
|
487
492
|
}
|
|
488
493
|
],
|
|
489
494
|
target: e
|
|
490
495
|
}), e;
|
|
491
|
-
},
|
|
492
|
-
|
|
493
|
-
|
|
496
|
+
}, V = x("field");
|
|
497
|
+
function Je(t) {
|
|
498
|
+
return Array.isArray(t) && t.every(
|
|
499
|
+
(e) => typeof e == "object" && e !== null && "id" in e && "label" in e && "value" in e
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
function N(t, e) {
|
|
503
|
+
const r = e ?? {
|
|
504
|
+
status: "idle",
|
|
505
|
+
options: Array.isArray(t.options) ? t.options : null
|
|
506
|
+
};
|
|
507
|
+
return {
|
|
508
|
+
...t,
|
|
509
|
+
...r,
|
|
510
|
+
options: r.options ?? (Array.isArray(t.options) ? t.options : null)
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
const He = I(({ client: t }) => {
|
|
514
|
+
const e = V.store({}), r = j(e, {
|
|
515
|
+
register(s, o) {
|
|
494
516
|
return {
|
|
495
517
|
...s,
|
|
496
|
-
[
|
|
518
|
+
[o.field.id]: o.field
|
|
497
519
|
};
|
|
498
520
|
}
|
|
499
521
|
});
|
|
500
|
-
function
|
|
501
|
-
|
|
522
|
+
function n(s) {
|
|
523
|
+
r.register({ field: s });
|
|
502
524
|
}
|
|
503
|
-
function
|
|
504
|
-
const
|
|
505
|
-
if (!
|
|
525
|
+
function i(s, o) {
|
|
526
|
+
const a = e.getState()[s];
|
|
527
|
+
if (!a)
|
|
506
528
|
return;
|
|
507
|
-
const
|
|
508
|
-
...
|
|
529
|
+
const f = Object.assign({}, a, {
|
|
530
|
+
...o
|
|
531
|
+
});
|
|
532
|
+
r.register({ field: { ...f } });
|
|
533
|
+
}
|
|
534
|
+
const d = V.store({}), l = E(
|
|
535
|
+
e,
|
|
536
|
+
d,
|
|
537
|
+
(s, o) => Object.values(s).map((a) => N(a, o[a.id]))
|
|
538
|
+
);
|
|
539
|
+
function c(s) {
|
|
540
|
+
return E(e, d, (o, a) => {
|
|
541
|
+
const f = o[s];
|
|
542
|
+
return f ? N(f, a[s]) : null;
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
function g(s) {
|
|
546
|
+
return E(e, d, (o, a) => {
|
|
547
|
+
const f = Object.values(o).find((h) => h.name === s);
|
|
548
|
+
return f ? N(f, a[f.id]) : null;
|
|
509
549
|
});
|
|
510
|
-
e.register({ field: { ...h } });
|
|
511
550
|
}
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
551
|
+
const p = V.effect(
|
|
552
|
+
async ({
|
|
553
|
+
fieldId: s,
|
|
554
|
+
fieldOptions: o,
|
|
555
|
+
context: a
|
|
556
|
+
}) => {
|
|
557
|
+
if (t && !Array.isArray(o) && o !== null) {
|
|
558
|
+
const f = await A(t, o, a);
|
|
559
|
+
return Je(f) ? { fieldId: s, options: f } : { fieldId: s, options: null };
|
|
560
|
+
}
|
|
561
|
+
return { fieldId: s, options: Array.isArray(o) ? o : null };
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
d.on(p, (s, { fieldId: o }) => {
|
|
565
|
+
const a = s[o];
|
|
566
|
+
return {
|
|
567
|
+
...s,
|
|
568
|
+
[o]: {
|
|
569
|
+
status: "loading",
|
|
570
|
+
// Preserve stale options during re-fetch so the UI doesn't flash blank
|
|
571
|
+
options: a?.status === "resolved" ? a.options : null
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
}), d.on(p.doneData, (s, { fieldId: o, options: a }) => ({
|
|
575
|
+
...s,
|
|
576
|
+
[o]: { status: "resolved", options: a }
|
|
577
|
+
})), d.on(p.fail, (s, { params: { fieldId: o } }) => ({
|
|
578
|
+
...s,
|
|
579
|
+
[o]: { status: "error", options: null, error: "Failed to resolve field options" }
|
|
580
|
+
}));
|
|
581
|
+
const y = R();
|
|
582
|
+
d.on(y, (s, o) => ({
|
|
583
|
+
...s,
|
|
584
|
+
[o]: { status: "waiting", options: null }
|
|
585
|
+
}));
|
|
586
|
+
const v = R();
|
|
587
|
+
t && w({
|
|
588
|
+
clock: v,
|
|
589
|
+
source: {
|
|
590
|
+
states: d,
|
|
591
|
+
fields: e
|
|
592
|
+
},
|
|
593
|
+
filter: ({ states: s }, { fieldId: o, force: a }) => {
|
|
594
|
+
if (a) return !0;
|
|
595
|
+
const f = s[o];
|
|
596
|
+
return !f || f.status === "idle";
|
|
597
|
+
},
|
|
598
|
+
fn: ({ fields: s }, { fieldId: o, context: a }) => {
|
|
599
|
+
const f = s[o] ?? null;
|
|
600
|
+
return {
|
|
601
|
+
fieldId: o,
|
|
602
|
+
fieldOptions: f?.options ?? null,
|
|
603
|
+
context: a
|
|
604
|
+
};
|
|
605
|
+
},
|
|
606
|
+
target: p
|
|
607
|
+
});
|
|
608
|
+
function m(s, o) {
|
|
609
|
+
v({ fieldId: s, force: o?.force, context: o?.context });
|
|
515
610
|
}
|
|
516
|
-
function
|
|
517
|
-
|
|
611
|
+
function u(s, o) {
|
|
612
|
+
for (const a of s)
|
|
613
|
+
v({ fieldId: a, force: o?.force, context: o?.context });
|
|
518
614
|
}
|
|
519
615
|
return {
|
|
520
|
-
register:
|
|
521
|
-
update:
|
|
522
|
-
getById:
|
|
523
|
-
listStore:
|
|
524
|
-
getByName:
|
|
616
|
+
register: n,
|
|
617
|
+
update: i,
|
|
618
|
+
getById: c,
|
|
619
|
+
listStore: l,
|
|
620
|
+
getByName: g,
|
|
621
|
+
resolve: m,
|
|
622
|
+
resolveAll: u,
|
|
623
|
+
setWaiting: y
|
|
525
624
|
};
|
|
526
625
|
});
|
|
527
|
-
function
|
|
528
|
-
return
|
|
626
|
+
function Ge(t) {
|
|
627
|
+
return F(He, t ?? {});
|
|
529
628
|
}
|
|
530
|
-
const
|
|
629
|
+
const qe = (t, e) => {
|
|
531
630
|
e.register(t);
|
|
532
|
-
},
|
|
533
|
-
const
|
|
534
|
-
register(
|
|
631
|
+
}, Ke = x("action"), We = I(({ client: t }) => {
|
|
632
|
+
const e = Ke.store({}), r = j(e, {
|
|
633
|
+
register(c, g) {
|
|
535
634
|
return {
|
|
536
|
-
...
|
|
537
|
-
[
|
|
538
|
-
name:
|
|
539
|
-
action:
|
|
635
|
+
...c,
|
|
636
|
+
[g.name]: {
|
|
637
|
+
name: g.name,
|
|
638
|
+
action: g.action
|
|
540
639
|
}
|
|
541
640
|
};
|
|
542
641
|
}
|
|
543
642
|
});
|
|
544
|
-
function
|
|
545
|
-
|
|
643
|
+
function n(c, g) {
|
|
644
|
+
r.register({ name: c, action: g });
|
|
546
645
|
}
|
|
547
|
-
const
|
|
548
|
-
function
|
|
549
|
-
return
|
|
646
|
+
const i = e.map((c) => Object.values(c));
|
|
647
|
+
function d(c) {
|
|
648
|
+
return e.map((g) => g[c], { skipVoid: !1 });
|
|
550
649
|
}
|
|
551
|
-
function
|
|
552
|
-
return
|
|
553
|
-
(
|
|
554
|
-
const
|
|
555
|
-
return
|
|
650
|
+
function l(c) {
|
|
651
|
+
return e.map(
|
|
652
|
+
(g) => {
|
|
653
|
+
const p = g[c];
|
|
654
|
+
return p ? p.action : void 0;
|
|
556
655
|
},
|
|
557
656
|
{ skipVoid: !1 }
|
|
558
657
|
);
|
|
559
658
|
}
|
|
560
659
|
return {
|
|
561
|
-
register:
|
|
562
|
-
getByName:
|
|
563
|
-
listStore:
|
|
564
|
-
getEvokableAction:
|
|
660
|
+
register: n,
|
|
661
|
+
getByName: d,
|
|
662
|
+
listStore: i,
|
|
663
|
+
getEvokableAction: l
|
|
565
664
|
};
|
|
566
665
|
});
|
|
567
|
-
function
|
|
568
|
-
return
|
|
666
|
+
function Ye(t) {
|
|
667
|
+
return F(We, t);
|
|
569
668
|
}
|
|
570
|
-
const
|
|
669
|
+
const Qe = (t, e, r) => {
|
|
571
670
|
r.register(t, e);
|
|
572
671
|
};
|
|
573
|
-
function
|
|
672
|
+
function T(t) {
|
|
574
673
|
return typeof t > "u" || t === null || t === "" || Array.isArray(t) && !t.length;
|
|
575
674
|
}
|
|
576
|
-
function
|
|
675
|
+
function Xe(t) {
|
|
577
676
|
return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null;
|
|
578
677
|
}
|
|
579
|
-
function
|
|
678
|
+
function K(t) {
|
|
580
679
|
try {
|
|
581
680
|
return JSON.stringify(t), !0;
|
|
582
681
|
} catch {
|
|
583
682
|
return !1;
|
|
584
683
|
}
|
|
585
684
|
}
|
|
586
|
-
const
|
|
587
|
-
const e =
|
|
588
|
-
register(m,
|
|
685
|
+
const Ze = x("response"), et = I(({ client: t }) => {
|
|
686
|
+
const e = Ze.store({}), r = R(), n = R(), i = j(e, {
|
|
687
|
+
register(m, u) {
|
|
589
688
|
return {
|
|
590
689
|
...m,
|
|
591
|
-
[
|
|
690
|
+
[u.fieldId]: u.response
|
|
592
691
|
};
|
|
593
692
|
},
|
|
594
|
-
registerBatch(m,
|
|
693
|
+
registerBatch(m, u) {
|
|
595
694
|
return {
|
|
596
695
|
...m,
|
|
597
|
-
...
|
|
696
|
+
...u
|
|
598
697
|
};
|
|
599
698
|
},
|
|
600
|
-
clear(m,
|
|
601
|
-
const { [
|
|
602
|
-
return
|
|
699
|
+
clear(m, u) {
|
|
700
|
+
const { [u]: s, ...o } = m;
|
|
701
|
+
return o;
|
|
603
702
|
},
|
|
604
703
|
clearAll() {
|
|
605
704
|
return {};
|
|
606
705
|
}
|
|
607
706
|
});
|
|
608
|
-
function d(m,
|
|
707
|
+
function d(m, u) {
|
|
609
708
|
if (typeof m == "string") {
|
|
610
|
-
if (
|
|
709
|
+
if (u === void 0)
|
|
611
710
|
throw new Error("Response is required when registering a single field");
|
|
612
|
-
i.register({ fieldId: m, response:
|
|
711
|
+
i.register({ fieldId: m, response: u });
|
|
613
712
|
} else
|
|
614
713
|
i.registerBatch(m);
|
|
615
714
|
}
|
|
616
|
-
async function
|
|
617
|
-
const
|
|
715
|
+
async function l(m) {
|
|
716
|
+
const u = [];
|
|
618
717
|
return await Promise.allSettled(
|
|
619
|
-
Object.entries(m).map(async ([
|
|
620
|
-
let
|
|
621
|
-
const
|
|
622
|
-
if (!
|
|
623
|
-
|
|
624
|
-
fieldId:
|
|
625
|
-
userMessage: `Field '${
|
|
626
|
-
systemMessage: `No field with ID '${
|
|
627
|
-
value:
|
|
718
|
+
Object.entries(m).map(async ([s, o]) => {
|
|
719
|
+
let a = o;
|
|
720
|
+
const f = t.fields.getById(s).getState();
|
|
721
|
+
if (!f) {
|
|
722
|
+
u.push({
|
|
723
|
+
fieldId: s,
|
|
724
|
+
userMessage: `Field '${s}' not found`,
|
|
725
|
+
systemMessage: `No field with ID '${s}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
726
|
+
value: a
|
|
628
727
|
});
|
|
629
728
|
return;
|
|
630
729
|
}
|
|
631
|
-
if (
|
|
632
|
-
const
|
|
633
|
-
$input:
|
|
730
|
+
if (f.multiple && (typeof a == "string" || typeof a == "number" || typeof a == "boolean") && (a = [a]), f.validation && !ue(f.validation) && !T(a)) {
|
|
731
|
+
const h = { ...e.getState(), ...m }, S = await A(t, f.validation, {
|
|
732
|
+
$input: a,
|
|
733
|
+
responses: h
|
|
634
734
|
});
|
|
635
|
-
if (typeof
|
|
636
|
-
|
|
637
|
-
fieldId:
|
|
638
|
-
userMessage:
|
|
639
|
-
systemMessage: `Field validation resulted in an error: ${
|
|
640
|
-
value:
|
|
735
|
+
if (typeof S == "string") {
|
|
736
|
+
u.push({
|
|
737
|
+
fieldId: s,
|
|
738
|
+
userMessage: S,
|
|
739
|
+
systemMessage: `Field validation resulted in an error: ${S}.`,
|
|
740
|
+
value: a
|
|
641
741
|
});
|
|
642
742
|
return;
|
|
643
743
|
}
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
fieldId:
|
|
744
|
+
if (S === !1) {
|
|
745
|
+
u.push({
|
|
746
|
+
fieldId: s,
|
|
647
747
|
userMessage: "This field is invalid",
|
|
648
748
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
649
|
-
value:
|
|
749
|
+
value: a
|
|
650
750
|
});
|
|
651
751
|
return;
|
|
652
752
|
}
|
|
653
753
|
}
|
|
654
|
-
if (
|
|
655
|
-
|
|
656
|
-
fieldId:
|
|
754
|
+
if (f.required && T(a)) {
|
|
755
|
+
u.push({
|
|
756
|
+
fieldId: s,
|
|
657
757
|
userMessage: "This field is required",
|
|
658
758
|
systemMessage: "Field is required.",
|
|
659
|
-
value:
|
|
759
|
+
value: a
|
|
660
760
|
});
|
|
661
761
|
return;
|
|
662
762
|
}
|
|
663
|
-
if (!
|
|
664
|
-
|
|
665
|
-
fieldId:
|
|
763
|
+
if (!f.multiple && Array.isArray(a) && a.length > 1) {
|
|
764
|
+
u.push({
|
|
765
|
+
fieldId: s,
|
|
666
766
|
userMessage: "This field expects a single response",
|
|
667
767
|
systemMessage: "Field expects a single response.",
|
|
668
|
-
value:
|
|
768
|
+
value: a
|
|
669
769
|
});
|
|
670
770
|
return;
|
|
671
771
|
}
|
|
672
|
-
if (
|
|
673
|
-
if (
|
|
674
|
-
if (!Array.isArray(
|
|
675
|
-
|
|
676
|
-
fieldId:
|
|
772
|
+
if (f.type === "object" && !T(a))
|
|
773
|
+
if (f.multiple) {
|
|
774
|
+
if (!Array.isArray(a)) {
|
|
775
|
+
u.push({
|
|
776
|
+
fieldId: s,
|
|
677
777
|
userMessage: "This field expects multiple values",
|
|
678
778
|
systemMessage: "Field expects an array of objects.",
|
|
679
|
-
value:
|
|
779
|
+
value: a
|
|
680
780
|
});
|
|
681
781
|
return;
|
|
682
782
|
}
|
|
683
|
-
for (const
|
|
684
|
-
if (typeof
|
|
685
|
-
|
|
686
|
-
fieldId:
|
|
783
|
+
for (const h of a) {
|
|
784
|
+
if (typeof h != "object" || h === null) {
|
|
785
|
+
u.push({
|
|
786
|
+
fieldId: s,
|
|
687
787
|
userMessage: "This field expects object values",
|
|
688
788
|
systemMessage: "Field expects an array of objects, but received non-object value.",
|
|
689
|
-
value:
|
|
789
|
+
value: a
|
|
690
790
|
});
|
|
691
791
|
return;
|
|
692
792
|
}
|
|
693
|
-
if (!
|
|
694
|
-
|
|
695
|
-
fieldId:
|
|
793
|
+
if (!K(h)) {
|
|
794
|
+
u.push({
|
|
795
|
+
fieldId: s,
|
|
696
796
|
userMessage: "This field contains non-serializable data",
|
|
697
797
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
698
|
-
value:
|
|
798
|
+
value: a
|
|
699
799
|
});
|
|
700
800
|
return;
|
|
701
801
|
}
|
|
702
802
|
}
|
|
703
803
|
} else {
|
|
704
|
-
if (Array.isArray(
|
|
705
|
-
|
|
706
|
-
fieldId:
|
|
804
|
+
if (Array.isArray(a)) {
|
|
805
|
+
u.push({
|
|
806
|
+
fieldId: s,
|
|
707
807
|
userMessage: "This field expects a single value",
|
|
708
808
|
systemMessage: "Field expects a single object, not an array.",
|
|
709
|
-
value:
|
|
809
|
+
value: a
|
|
710
810
|
});
|
|
711
811
|
return;
|
|
712
812
|
}
|
|
713
|
-
if (typeof
|
|
714
|
-
|
|
715
|
-
fieldId:
|
|
813
|
+
if (typeof a != "object" || a === null) {
|
|
814
|
+
u.push({
|
|
815
|
+
fieldId: s,
|
|
716
816
|
userMessage: "This field expects an object value",
|
|
717
817
|
systemMessage: "Field expects an object value.",
|
|
718
|
-
value:
|
|
818
|
+
value: a
|
|
719
819
|
});
|
|
720
820
|
return;
|
|
721
821
|
}
|
|
722
|
-
if (!
|
|
723
|
-
|
|
724
|
-
fieldId:
|
|
822
|
+
if (!K(a)) {
|
|
823
|
+
u.push({
|
|
824
|
+
fieldId: s,
|
|
725
825
|
userMessage: "This field contains non-serializable data",
|
|
726
826
|
systemMessage: "Field value contains non-JSON-serializable data (functions, circular references, etc.).",
|
|
727
|
-
value:
|
|
827
|
+
value: a
|
|
728
828
|
});
|
|
729
829
|
return;
|
|
730
830
|
}
|
|
731
831
|
}
|
|
732
|
-
if (
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
fieldId:
|
|
832
|
+
if (Array.isArray(f.options)) {
|
|
833
|
+
const h = Array.isArray(a) ? a : [a];
|
|
834
|
+
if (f.type === "object") {
|
|
835
|
+
const S = f.options.map((k) => JSON.stringify(k.value));
|
|
836
|
+
h.every((k) => S.includes(JSON.stringify(k))) || u.push({
|
|
837
|
+
fieldId: s,
|
|
738
838
|
userMessage: "This field expects a valid option",
|
|
739
839
|
systemMessage: "Field expects a valid option from the defined choices.",
|
|
740
|
-
value:
|
|
840
|
+
value: a
|
|
741
841
|
});
|
|
742
842
|
} else {
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
fieldId:
|
|
843
|
+
const S = f.options.map((k) => k.value);
|
|
844
|
+
h.every((k) => !Xe(k) || k === null ? !1 : S.includes(k)) || u.push({
|
|
845
|
+
fieldId: s,
|
|
746
846
|
userMessage: "This field expects a valid option",
|
|
747
|
-
systemMessage: `Field expects a valid option. Valid options are: ${
|
|
748
|
-
value:
|
|
847
|
+
systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
|
|
848
|
+
value: a
|
|
749
849
|
});
|
|
750
850
|
}
|
|
751
851
|
}
|
|
752
852
|
})
|
|
753
|
-
), { responsesToCommit: m, validationErrors:
|
|
853
|
+
), { responsesToCommit: m, validationErrors: u };
|
|
754
854
|
}
|
|
755
|
-
async function
|
|
756
|
-
const { responsesToCommit:
|
|
757
|
-
return
|
|
855
|
+
async function c(m) {
|
|
856
|
+
const { responsesToCommit: u, validationErrors: s } = await l(m);
|
|
857
|
+
return s.length ? { errors: s } : (i.registerBatch(u), { errors: [] });
|
|
758
858
|
}
|
|
759
|
-
const
|
|
760
|
-
fieldId:
|
|
761
|
-
value: m[
|
|
859
|
+
const g = e.map((m) => m), p = e.map((m) => Object.keys(m).map((s) => ({
|
|
860
|
+
fieldId: s,
|
|
861
|
+
value: m[s]
|
|
762
862
|
})));
|
|
763
|
-
function
|
|
764
|
-
const
|
|
765
|
-
return
|
|
863
|
+
function y(m) {
|
|
864
|
+
const u = t.fields.getById(m), s = e.map((o) => o[m] || null);
|
|
865
|
+
return E({ f: u, r: s }, ({ f: o, r: a }) => a || (o?.defaultValue ? o.defaultValue : null));
|
|
766
866
|
}
|
|
767
|
-
function
|
|
768
|
-
const
|
|
769
|
-
return
|
|
770
|
-
const
|
|
771
|
-
return
|
|
867
|
+
function v(m) {
|
|
868
|
+
const u = t.fields.getByName(m);
|
|
869
|
+
return E({ f: u, s: e }, ({ f: s, s: o }) => {
|
|
870
|
+
const a = s && o[s.id] || null;
|
|
871
|
+
return a || (s?.defaultValue ? s.defaultValue : null);
|
|
772
872
|
});
|
|
773
873
|
}
|
|
774
|
-
return
|
|
874
|
+
return w({
|
|
775
875
|
clock: r,
|
|
776
876
|
target: i.clearAll
|
|
777
|
-
}),
|
|
877
|
+
}), w({
|
|
778
878
|
clock: n,
|
|
779
879
|
target: i.clear
|
|
780
880
|
}), {
|
|
781
881
|
register: d,
|
|
782
882
|
clearAll: r,
|
|
783
883
|
clear: n,
|
|
784
|
-
commit:
|
|
785
|
-
getResponsesToCommit:
|
|
884
|
+
commit: c,
|
|
885
|
+
getResponsesToCommit: l,
|
|
786
886
|
listStore: p,
|
|
787
|
-
getAllStore:
|
|
788
|
-
getByFieldId:
|
|
789
|
-
getByFieldName:
|
|
887
|
+
getAllStore: g,
|
|
888
|
+
getByFieldId: y,
|
|
889
|
+
getByFieldName: v
|
|
790
890
|
};
|
|
791
891
|
});
|
|
792
|
-
function
|
|
793
|
-
return
|
|
892
|
+
function tt(t) {
|
|
893
|
+
return F(et, t);
|
|
794
894
|
}
|
|
795
|
-
const
|
|
796
|
-
function
|
|
797
|
-
if (
|
|
895
|
+
const rt = () => "0.0.1-dev.1772064704206";
|
|
896
|
+
function nt() {
|
|
897
|
+
if (_()) {
|
|
798
898
|
const t = [
|
|
799
899
|
document.currentScript,
|
|
800
900
|
document.getElementById("picked_script"),
|
|
@@ -808,8 +908,8 @@ function tt() {
|
|
|
808
908
|
}
|
|
809
909
|
return "https://api.picked.app";
|
|
810
910
|
}
|
|
811
|
-
function
|
|
812
|
-
if (!
|
|
911
|
+
function st() {
|
|
912
|
+
if (!L())
|
|
813
913
|
return {};
|
|
814
914
|
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
815
915
|
for (const [i] of t.entries())
|
|
@@ -818,24 +918,24 @@ function rt() {
|
|
|
818
918
|
const d = i.replace("picked-", "");
|
|
819
919
|
e[d] = t.getAll(i);
|
|
820
920
|
}
|
|
821
|
-
const n =
|
|
921
|
+
const n = B("s");
|
|
822
922
|
if (r.size > 0)
|
|
823
|
-
|
|
923
|
+
D.set(n, e);
|
|
824
924
|
else {
|
|
825
|
-
const i =
|
|
925
|
+
const i = D.get(n);
|
|
826
926
|
if (i)
|
|
827
927
|
return i.json() || {};
|
|
828
928
|
}
|
|
829
929
|
return e;
|
|
830
930
|
}
|
|
831
|
-
function
|
|
931
|
+
function it() {
|
|
832
932
|
if (de())
|
|
833
933
|
return crypto.randomUUID();
|
|
834
934
|
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15), r = Math.random().toString(36).substring(2, 15), n = Math.random().toString(36).substring(2, 15);
|
|
835
935
|
return `${t}-${e}-${r}-${n}`;
|
|
836
936
|
}
|
|
837
|
-
const
|
|
838
|
-
const t =
|
|
937
|
+
const ot = B("session", "global"), at = () => {
|
|
938
|
+
const t = O.get(ot);
|
|
839
939
|
let e;
|
|
840
940
|
t.isSet() && (e = t.json());
|
|
841
941
|
const r = (i) => t.set({
|
|
@@ -843,7 +943,7 @@ const st = A("session", "global"), it = () => {
|
|
|
843
943
|
isUser: i.isUser,
|
|
844
944
|
identifiers: i.identifiers
|
|
845
945
|
}), n = {
|
|
846
|
-
id: e?.id ??
|
|
946
|
+
id: e?.id ?? it(),
|
|
847
947
|
isUser: e?.isUser ?? void 0,
|
|
848
948
|
identifiers: e?.identifiers ?? void 0,
|
|
849
949
|
setIsUser(i) {
|
|
@@ -859,19 +959,19 @@ const st = A("session", "global"), it = () => {
|
|
|
859
959
|
}
|
|
860
960
|
};
|
|
861
961
|
return r(n), n;
|
|
862
|
-
},
|
|
863
|
-
function
|
|
864
|
-
if (
|
|
962
|
+
}, ct = () => le() ? at() : null;
|
|
963
|
+
function ut() {
|
|
964
|
+
if (L())
|
|
865
965
|
return globalThis.window.pickedConfig;
|
|
866
966
|
}
|
|
867
|
-
function
|
|
868
|
-
if (!
|
|
967
|
+
function lt() {
|
|
968
|
+
if (!L())
|
|
869
969
|
return;
|
|
870
|
-
const t =
|
|
970
|
+
const t = ut(), e = t?.organizationId, r = t?.projectId;
|
|
871
971
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
872
972
|
}
|
|
873
|
-
function
|
|
874
|
-
if (!
|
|
973
|
+
function dt() {
|
|
974
|
+
if (!_())
|
|
875
975
|
return;
|
|
876
976
|
const t = document.getElementById("picked_script") || document.querySelector("script#picked") || // legacy support for 'cvly' script tag
|
|
877
977
|
document.getElementById("cvly");
|
|
@@ -880,14 +980,14 @@ function ut() {
|
|
|
880
980
|
const e = t.dataset.organizationid || t.getAttribute("organization-id"), r = t.dataset.projectid || t.getAttribute("project-id");
|
|
881
981
|
return e && r ? { organizationId: e, projectId: r } : void 0;
|
|
882
982
|
}
|
|
883
|
-
function
|
|
983
|
+
function pt(t) {
|
|
884
984
|
const { organizationId: e, projectId: r } = t;
|
|
885
985
|
if (e && r)
|
|
886
986
|
return { organizationId: e, projectId: r };
|
|
887
|
-
const n =
|
|
987
|
+
const n = lt();
|
|
888
988
|
if (n)
|
|
889
989
|
return n;
|
|
890
|
-
const i =
|
|
990
|
+
const i = dt();
|
|
891
991
|
if (i)
|
|
892
992
|
return i;
|
|
893
993
|
throw new Error(
|
|
@@ -897,13 +997,13 @@ function dt(t) {
|
|
|
897
997
|
(3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes data-organizationid/data-projectid (or organization-id/project-id) attributes.`
|
|
898
998
|
);
|
|
899
999
|
}
|
|
900
|
-
function
|
|
1000
|
+
function M(t) {
|
|
901
1001
|
return t == null || t === "" || Number.isNaN(t);
|
|
902
1002
|
}
|
|
903
|
-
const
|
|
904
|
-
default: (t, e) =>
|
|
905
|
-
append: (t, e) => e && !
|
|
906
|
-
prepend: (t, e) => e && !
|
|
1003
|
+
const ft = {
|
|
1004
|
+
default: (t, e) => M(t) ? String(e ?? "") : String(t),
|
|
1005
|
+
append: (t, e) => e && !M(t) ? `${t} ${e}` : t,
|
|
1006
|
+
prepend: (t, e) => e && !M(t) ? `${e} ${t}` : t,
|
|
907
1007
|
upper: (t) => typeof t == "string" ? t.toUpperCase() : t,
|
|
908
1008
|
lower: (t) => typeof t == "string" ? t.toLowerCase() : t,
|
|
909
1009
|
capitalize: (t) => typeof t == "string" ? t.charAt(0).toUpperCase() + t.slice(1) : t,
|
|
@@ -920,28 +1020,28 @@ const lt = {
|
|
|
920
1020
|
return t instanceof Set ? e.format(Array.from(t).map(String)) : t;
|
|
921
1021
|
}
|
|
922
1022
|
};
|
|
923
|
-
function
|
|
1023
|
+
function gt(t) {
|
|
924
1024
|
return typeof t == "object" && t !== null;
|
|
925
1025
|
}
|
|
926
|
-
function
|
|
1026
|
+
function mt(t, e) {
|
|
927
1027
|
let r = e;
|
|
928
1028
|
for (const n of t.split("."))
|
|
929
|
-
if (
|
|
1029
|
+
if (gt(r) && n in r)
|
|
930
1030
|
r = r[n];
|
|
931
1031
|
else
|
|
932
1032
|
return;
|
|
933
1033
|
return typeof r == "function" ? r() : r;
|
|
934
1034
|
}
|
|
935
|
-
function
|
|
1035
|
+
function yt(t, e) {
|
|
936
1036
|
const r = t.split("|").map((d) => d.trim()), n = r.shift() ?? "";
|
|
937
|
-
let i =
|
|
1037
|
+
let i = mt(n, e);
|
|
938
1038
|
for (const d of r) {
|
|
939
|
-
const [
|
|
940
|
-
|
|
1039
|
+
const [l, ...c] = d.split(":"), g = l?.trim() ?? "", p = c.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), y = ft[g];
|
|
1040
|
+
y && (i = y(i, p));
|
|
941
1041
|
}
|
|
942
|
-
return
|
|
1042
|
+
return M(i) ? "" : typeof i == "object" ? JSON.stringify(i) : String(i);
|
|
943
1043
|
}
|
|
944
|
-
function
|
|
1044
|
+
function ht(t, e) {
|
|
945
1045
|
let r = "", n = 0;
|
|
946
1046
|
for (; n < t.length; )
|
|
947
1047
|
if (t[n] === "{" && t[n + 1] === "{") {
|
|
@@ -954,60 +1054,57 @@ function mt(t, e) {
|
|
|
954
1054
|
}
|
|
955
1055
|
i += t[n++];
|
|
956
1056
|
}
|
|
957
|
-
r +=
|
|
1057
|
+
r += yt(i.trim(), e);
|
|
958
1058
|
} else
|
|
959
1059
|
r += t[n++];
|
|
960
1060
|
return r;
|
|
961
1061
|
}
|
|
962
|
-
class
|
|
963
|
-
static logger =
|
|
1062
|
+
class vt {
|
|
1063
|
+
static logger = b;
|
|
964
1064
|
options;
|
|
965
1065
|
isReady = !1;
|
|
966
1066
|
project;
|
|
967
1067
|
plugins = {};
|
|
968
|
-
|
|
969
|
-
eventBus = U();
|
|
1068
|
+
eventBus = R();
|
|
970
1069
|
events;
|
|
971
1070
|
organizationId;
|
|
972
1071
|
projectId;
|
|
973
1072
|
apiUrl;
|
|
974
|
-
dashboardUrl;
|
|
975
|
-
documentationSiteUrl;
|
|
976
1073
|
session;
|
|
977
1074
|
precondition;
|
|
978
1075
|
condition;
|
|
979
|
-
searchParams =
|
|
980
|
-
history =
|
|
981
|
-
components =
|
|
982
|
-
experienceInstances =
|
|
983
|
-
experiences =
|
|
984
|
-
frameworks =
|
|
985
|
-
predicates =
|
|
986
|
-
features =
|
|
987
|
-
responses =
|
|
988
|
-
fields =
|
|
989
|
-
actions =
|
|
1076
|
+
searchParams = st();
|
|
1077
|
+
history = Ue();
|
|
1078
|
+
components = Fe({ client: this });
|
|
1079
|
+
experienceInstances = oe({ client: this });
|
|
1080
|
+
experiences = ye({ client: this });
|
|
1081
|
+
frameworks = Ae({ client: this });
|
|
1082
|
+
predicates = Me({ client: this });
|
|
1083
|
+
features = Ve({ client: this });
|
|
1084
|
+
responses = tt({ client: this });
|
|
1085
|
+
fields = Ge({ client: this });
|
|
1086
|
+
actions = Ye({ client: this });
|
|
990
1087
|
constructor(e) {
|
|
991
|
-
|
|
992
|
-
const { organizationId: r, projectId: n } =
|
|
993
|
-
this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl ||
|
|
1088
|
+
b("info", "Picked client initializing."), this.events = Le(this.eventBus);
|
|
1089
|
+
const { organizationId: r, projectId: n } = pt(e);
|
|
1090
|
+
this.organizationId = r, this.projectId = n, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || nt(), this.session = ct(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({ type: "load", version: rt() }), b("info", "Picked client initialized.");
|
|
994
1091
|
}
|
|
995
1092
|
start = () => {
|
|
996
1093
|
$e(this), (async () => {
|
|
997
|
-
if (!
|
|
1094
|
+
if (!_())
|
|
998
1095
|
return;
|
|
999
|
-
|
|
1000
|
-
|
|
1096
|
+
let r;
|
|
1097
|
+
typeof this.precondition > "u" ? r = !0 : typeof this.precondition == "boolean" ? r = this.precondition : r = await A(this, this.precondition) === !0;
|
|
1001
1098
|
let n;
|
|
1002
|
-
r && (n =
|
|
1099
|
+
r && (this.condition === void 0 ? n = !0 : typeof this.condition == "boolean" ? n = this.condition : n = await A(this, this.condition) === !0);
|
|
1003
1100
|
const i = r && n === !0;
|
|
1004
1101
|
if (typeof n == "boolean" && this.session) {
|
|
1005
1102
|
const d = n;
|
|
1006
1103
|
this.session.setIsUser(d), this.eventBus({ type: "user_decide", value: d });
|
|
1007
1104
|
}
|
|
1008
|
-
if (this.eventBus({ type: "initialize" }), i &&
|
|
1009
|
-
const { id: d, isUser:
|
|
1010
|
-
this.eventBus({ type: "session", id: d, isUser:
|
|
1105
|
+
if (this.eventBus({ type: "initialize" }), document.body && i && J(this), await ae(), i && J(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1106
|
+
const { id: d, isUser: l, identifiers: c } = this.session;
|
|
1107
|
+
this.eventBus({ type: "session", id: d, isUser: l, identifiers: c });
|
|
1011
1108
|
}
|
|
1012
1109
|
})();
|
|
1013
1110
|
};
|
|
@@ -1015,52 +1112,44 @@ class ht {
|
|
|
1015
1112
|
Ee(e, this.frameworks);
|
|
1016
1113
|
};
|
|
1017
1114
|
registerComponent = (e, r) => {
|
|
1018
|
-
|
|
1115
|
+
H(e, r, this.components);
|
|
1019
1116
|
};
|
|
1020
1117
|
registerPlugin = (e) => {
|
|
1021
1118
|
Se(this, e, this.plugins);
|
|
1022
|
-
const r = this.plugins[e.name];
|
|
1023
|
-
r?.onStart && this.pluginStartHooks.push(r.onStart);
|
|
1024
1119
|
};
|
|
1025
1120
|
registerFeature = (e, r) => {
|
|
1026
|
-
|
|
1121
|
+
Ne(e, r, this.features);
|
|
1027
1122
|
};
|
|
1028
1123
|
registerPredicate = (e, r) => {
|
|
1029
|
-
|
|
1124
|
+
Oe(e, r, this.predicates);
|
|
1030
1125
|
};
|
|
1031
1126
|
registerField = (e) => {
|
|
1032
|
-
|
|
1127
|
+
qe(e, this.fields);
|
|
1033
1128
|
};
|
|
1034
1129
|
registerAction = (e, r) => {
|
|
1035
|
-
|
|
1130
|
+
Qe(e, r, this.actions);
|
|
1036
1131
|
};
|
|
1037
1132
|
registerExperience = (e) => {
|
|
1038
|
-
e.component &&
|
|
1133
|
+
e.component && H(`experience:${e.id}`, e.component, this.components), he(e, this.experiences);
|
|
1039
1134
|
};
|
|
1040
|
-
getStateSnapshot = () =>
|
|
1041
|
-
launchExperienceById = async (e
|
|
1042
|
-
const
|
|
1043
|
-
if (!
|
|
1044
|
-
|
|
1135
|
+
getStateSnapshot = () => X(this);
|
|
1136
|
+
launchExperienceById = async (e) => {
|
|
1137
|
+
const r = this.experiences.getById(e).getState();
|
|
1138
|
+
if (!r) {
|
|
1139
|
+
b("warn", `Experience with id '${e}' not found.`);
|
|
1045
1140
|
return;
|
|
1046
1141
|
}
|
|
1047
|
-
|
|
1142
|
+
Q(this, r);
|
|
1048
1143
|
};
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
for (const e of this.pluginStartHooks)
|
|
1059
|
-
await e();
|
|
1060
|
-
}
|
|
1061
|
-
async evaluateGate(e) {
|
|
1062
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await P(this, e) === !0;
|
|
1063
|
-
}
|
|
1144
|
+
// private async fetchProject() {
|
|
1145
|
+
// if (this.project) {
|
|
1146
|
+
// return
|
|
1147
|
+
// }
|
|
1148
|
+
//
|
|
1149
|
+
// // todo: fetch project
|
|
1150
|
+
//
|
|
1151
|
+
// this.project.experiences.forEach((experience) => setupExperience(experience, this.experiences))
|
|
1152
|
+
// }
|
|
1064
1153
|
setupPlugins() {
|
|
1065
1154
|
this.options.plugins?.forEach((e) => {
|
|
1066
1155
|
if (Array.isArray(e)) {
|
|
@@ -1104,7 +1193,7 @@ class ht {
|
|
|
1104
1193
|
const e = this.options.predicates;
|
|
1105
1194
|
e && Object.entries(e).forEach(([r, n]) => {
|
|
1106
1195
|
if (typeof n != "function") {
|
|
1107
|
-
|
|
1196
|
+
b("warn", `Predicate "${r}" is not a function.`);
|
|
1108
1197
|
return;
|
|
1109
1198
|
}
|
|
1110
1199
|
this.registerPredicate(r, n);
|
|
@@ -1114,7 +1203,7 @@ class ht {
|
|
|
1114
1203
|
const e = this.options.actions;
|
|
1115
1204
|
e && Object.entries(e).forEach(([r, n]) => {
|
|
1116
1205
|
if (typeof n != "function") {
|
|
1117
|
-
|
|
1206
|
+
b("warn", `Action "${r}" is not a function.`);
|
|
1118
1207
|
return;
|
|
1119
1208
|
}
|
|
1120
1209
|
this.registerAction(r, n);
|
|
@@ -1165,67 +1254,56 @@ class ht {
|
|
|
1165
1254
|
*/
|
|
1166
1255
|
renderString = (e, r) => {
|
|
1167
1256
|
const n = this.responses.listStore.getState().reduce((i, d) => (i[d.fieldId] = d.value, i), {});
|
|
1168
|
-
return
|
|
1257
|
+
return ht(e, {
|
|
1169
1258
|
...r,
|
|
1170
1259
|
responses: n
|
|
1171
1260
|
});
|
|
1172
1261
|
};
|
|
1173
1262
|
}
|
|
1174
|
-
function
|
|
1175
|
-
return t.options
|
|
1263
|
+
function Z(t) {
|
|
1264
|
+
return Array.isArray(t.options) && t.options.some((e) => "condition" in e);
|
|
1176
1265
|
}
|
|
1177
|
-
function
|
|
1178
|
-
return t.some((e) => e.condition ||
|
|
1266
|
+
function St(t) {
|
|
1267
|
+
return t.some((e) => e.condition || Z(e));
|
|
1179
1268
|
}
|
|
1180
|
-
async function Et(t, e) {
|
|
1181
|
-
return e.length === 0 || !
|
|
1182
|
-
e.map(async (
|
|
1183
|
-
if (!(
|
|
1269
|
+
async function Et(t, e, r) {
|
|
1270
|
+
return e.length === 0 || !St(e) ? e : (await Promise.all(
|
|
1271
|
+
e.map(async (i) => {
|
|
1272
|
+
if (!(i.condition ? await A(t, i.condition, r) : !0))
|
|
1184
1273
|
return null;
|
|
1185
|
-
if (!
|
|
1186
|
-
return
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
)).filter((
|
|
1190
|
-
return
|
|
1274
|
+
if (!Array.isArray(i.options) || !Z(i))
|
|
1275
|
+
return i;
|
|
1276
|
+
const c = (await Promise.all(
|
|
1277
|
+
i.options.map(async (p) => p.condition ? await A(t, p.condition, r) ? p : null : p)
|
|
1278
|
+
)).filter((p) => p !== null);
|
|
1279
|
+
return c.length === i.options.length ? i : c.length === 0 ? null : { ...i, options: c };
|
|
1191
1280
|
})
|
|
1192
|
-
)).filter((
|
|
1193
|
-
}
|
|
1194
|
-
function Pt(t) {
|
|
1195
|
-
return {
|
|
1196
|
-
$$type: "lazy-component",
|
|
1197
|
-
load: t
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
function At(t) {
|
|
1201
|
-
return typeof t == "object" && t !== null && "$$type" in t && t.$$type === "lazy-component";
|
|
1281
|
+
)).filter((i) => i !== null);
|
|
1202
1282
|
}
|
|
1203
|
-
const
|
|
1204
|
-
const e = new
|
|
1205
|
-
return
|
|
1283
|
+
const Pt = (t) => {
|
|
1284
|
+
const e = new vt(t);
|
|
1285
|
+
return pe(e), e;
|
|
1206
1286
|
};
|
|
1207
1287
|
export {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1288
|
+
vt as Picked,
|
|
1289
|
+
Pt as createClient,
|
|
1290
|
+
B as createStorageKey,
|
|
1291
|
+
A as evaluateRuleLogic,
|
|
1292
|
+
ut as getPickedConfig,
|
|
1213
1293
|
Et as getStepFields,
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
Ot as subscribe,
|
|
1220
|
-
Dt as supportsCookies,
|
|
1294
|
+
$t as isPickedRoot,
|
|
1295
|
+
O as localStore,
|
|
1296
|
+
D as sessionStore,
|
|
1297
|
+
Ct as subscribe,
|
|
1298
|
+
Ot as supportsCookies,
|
|
1221
1299
|
de as supportsCryptoRandomUUID,
|
|
1222
|
-
|
|
1223
|
-
|
|
1300
|
+
_ as supportsDocument,
|
|
1301
|
+
Dt as supportsHistory,
|
|
1224
1302
|
Vt as supportsIntersectionObserver,
|
|
1225
|
-
|
|
1303
|
+
le as supportsLocalStorage,
|
|
1226
1304
|
Nt as supportsLocation,
|
|
1227
1305
|
Tt as supportsSessionStorage,
|
|
1228
|
-
|
|
1306
|
+
Ut as supportsShadowRoot,
|
|
1229
1307
|
_t as supportsWebComponents,
|
|
1230
|
-
|
|
1308
|
+
L as supportsWindow
|
|
1231
1309
|
};
|