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