@picked/client 0.0.12-next.2 → 0.0.12-next.4
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 +1 -1
- package/dist/esm/index.js +445 -436
- package/dist/types/entities/feature/feature.d.ts +5 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +4 -0
- package/dist/types/utils/events.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (t, e,
|
|
4
|
-
import { createDomain as I, createApi as x, createEffect as
|
|
5
|
-
import { createFactory as
|
|
6
|
-
import { g as
|
|
7
|
-
import { f as
|
|
8
|
-
import { l as
|
|
9
|
-
import { c as A, s as $, l as
|
|
1
|
+
var W = Object.defineProperty;
|
|
2
|
+
var Y = (t, e, r) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var m = (t, e, r) => Y(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { createDomain as I, createApi as x, createEffect as M, attach as J, sample as F, combine as C, createEvent as D } from "effector";
|
|
5
|
+
import { createFactory as w, invoke as k } from "@withease/factories";
|
|
6
|
+
import { g as _, t as Q, c as X, e as R, i as Z, a as ee, b as te, d as re } from "../experience-instance-BBz99AXU.js";
|
|
7
|
+
import { f as St } from "../experience-instance-BBz99AXU.js";
|
|
8
|
+
import { l as v } from "../logger-C9a75KZn.js";
|
|
9
|
+
import { c as A, s as $, l as O } from "../storage-Cb_71y48.js";
|
|
10
10
|
import { a as wt } from "../storage-Cb_71y48.js";
|
|
11
|
-
import { g as
|
|
12
|
-
import { i as
|
|
13
|
-
import { s as z, a as
|
|
14
|
-
import { h as
|
|
15
|
-
const
|
|
11
|
+
import { g as se } from "../id-BW-g3y32.js";
|
|
12
|
+
import { i as ne } from "../object-JwZ58NOH.js";
|
|
13
|
+
import { s as z, a as oe, b as ie, c as ae, d as ce } from "../supports-BjhuLJ8z.js";
|
|
14
|
+
import { h as bt, f as It, j as xt, e as Ft, g as Et, i as Pt, k as Rt } from "../supports-BjhuLJ8z.js";
|
|
15
|
+
const H = I("experience"), ue = w(
|
|
16
16
|
({ client: t, experience: e }) => {
|
|
17
|
-
const
|
|
17
|
+
const r = H.store(e), n = x(r, {
|
|
18
18
|
merge(u, h) {
|
|
19
19
|
return {
|
|
20
20
|
...u,
|
|
21
21
|
...h.experience
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
}),
|
|
24
|
+
}), a = r.map((u) => ({
|
|
25
25
|
type: u.type,
|
|
26
26
|
name: u.name,
|
|
27
27
|
decisionLogic: u.decide,
|
|
28
28
|
targetSelectors: u.targets
|
|
29
|
-
})),
|
|
29
|
+
})), l = t.components.listStore.map(
|
|
30
30
|
(u) => u.find((h) => h.name === `experience:${e.id}`) || u.find((h) => h.name === "experience"),
|
|
31
31
|
{ skipVoid: !1 }
|
|
32
|
-
),
|
|
32
|
+
), s = r.map((u) => ({
|
|
33
33
|
steps: u.steps,
|
|
34
34
|
nodes: u.nodes,
|
|
35
35
|
edges: u.edges,
|
|
@@ -37,171 +37,171 @@ const _ = I("experience"), ce = v(
|
|
|
37
37
|
})), o = e.actions ?? [];
|
|
38
38
|
return {
|
|
39
39
|
id: e.id,
|
|
40
|
-
configStore:
|
|
41
|
-
treeStore:
|
|
42
|
-
componentStore:
|
|
40
|
+
configStore: a,
|
|
41
|
+
treeStore: s,
|
|
42
|
+
componentStore: l,
|
|
43
43
|
actions: o,
|
|
44
44
|
merge: n.merge
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
);
|
|
48
|
-
function
|
|
49
|
-
return k(
|
|
48
|
+
function le(t) {
|
|
49
|
+
return k(ue, t);
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
const e =
|
|
53
|
-
register(
|
|
51
|
+
const de = w(({ client: t }) => {
|
|
52
|
+
const e = H.store({}), r = x(e, {
|
|
53
|
+
register(s, o) {
|
|
54
54
|
return {
|
|
55
|
-
...
|
|
55
|
+
...s,
|
|
56
56
|
[o.id]: o
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
function n(
|
|
61
|
-
const o = e.getState()[
|
|
60
|
+
function n(s) {
|
|
61
|
+
const o = e.getState()[s.id];
|
|
62
62
|
if (o) {
|
|
63
|
-
o.merge({ experience:
|
|
63
|
+
o.merge({ experience: s, strategy: "override" });
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
const u =
|
|
67
|
-
|
|
66
|
+
const u = le({ client: t, experience: s });
|
|
67
|
+
r.register(u);
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
71
|
-
return e.map((o) => o[
|
|
69
|
+
const a = e.map((s) => Object.values(s));
|
|
70
|
+
function l(s) {
|
|
71
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
72
72
|
}
|
|
73
73
|
return {
|
|
74
74
|
register: n,
|
|
75
|
-
getById:
|
|
76
|
-
listStore:
|
|
75
|
+
getById: l,
|
|
76
|
+
listStore: a
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
|
-
function
|
|
80
|
-
return k(
|
|
79
|
+
function pe(t) {
|
|
80
|
+
return k(de, t);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const ge = (t, e) => {
|
|
83
83
|
e.register(t);
|
|
84
|
-
},
|
|
85
|
-
const { targetSelectors:
|
|
84
|
+
}, K = (t, e) => {
|
|
85
|
+
const { targetSelectors: r } = e.configStore.getState(), n = _(r, e.id);
|
|
86
86
|
n.forEach(
|
|
87
|
-
({ elements:
|
|
88
|
-
),
|
|
89
|
-
t.experienceInstances.spawn(e,
|
|
87
|
+
({ elements: l }) => l.forEach((s) => Q(s, e.id))
|
|
88
|
+
), X(n, e.id).forEach((l) => {
|
|
89
|
+
t.experienceInstances.spawn(e, l);
|
|
90
90
|
});
|
|
91
|
-
},
|
|
91
|
+
}, T = async (t) => {
|
|
92
92
|
await Promise.all(
|
|
93
93
|
t.experiences.listStore.getState().map(async (e) => {
|
|
94
|
-
await
|
|
94
|
+
await fe(t, e) && K(t, e);
|
|
95
95
|
})
|
|
96
96
|
);
|
|
97
|
-
},
|
|
98
|
-
const { type:
|
|
99
|
-
return
|
|
100
|
-
},
|
|
101
|
-
const n = e.name,
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
({ client: t, component: e, name:
|
|
97
|
+
}, fe = async (t, e) => {
|
|
98
|
+
const { type: r, decisionLogic: n, targetSelectors: a } = e.configStore.getState();
|
|
99
|
+
return _(a, e.id).length < 1 ? !1 : r === "funnel" ? n ? await R(t, n) === !0 : !1 : a.length === 0 ? !1 : Z(n) ? await R(t, n) === !0 : !0;
|
|
100
|
+
}, me = (t, e, r) => {
|
|
101
|
+
const n = e.name, a = e.setup(t);
|
|
102
|
+
if (a) {
|
|
103
|
+
const l = r[n] ?? {};
|
|
104
|
+
r[n] = Object.freeze({ ...l, ...a });
|
|
105
|
+
}
|
|
106
|
+
}, he = I("component"), ye = w(
|
|
107
|
+
({ client: t, component: e, name: r }) => {
|
|
108
108
|
const n = t.frameworks.getByName(e.frameworkName);
|
|
109
109
|
return {
|
|
110
|
-
name:
|
|
110
|
+
name: r,
|
|
111
111
|
component: e,
|
|
112
112
|
frameworkStore: n
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
);
|
|
116
|
-
function
|
|
117
|
-
return k(
|
|
116
|
+
function Se(t) {
|
|
117
|
+
return k(ye, t);
|
|
118
118
|
}
|
|
119
|
-
const
|
|
120
|
-
const e =
|
|
121
|
-
register(
|
|
119
|
+
const ve = w(({ client: t }) => {
|
|
120
|
+
const e = he.store({}), r = x(e, {
|
|
121
|
+
register(s, o) {
|
|
122
122
|
return {
|
|
123
|
-
...
|
|
123
|
+
...s,
|
|
124
124
|
[o.name]: o
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
function n(
|
|
129
|
-
e.getState()[
|
|
128
|
+
function n(s, o) {
|
|
129
|
+
e.getState()[s] && v(
|
|
130
130
|
"warn",
|
|
131
|
-
`Component '${
|
|
131
|
+
`Component '${s}' already registered. Registering again will override the previous registration.`
|
|
132
132
|
);
|
|
133
|
-
const h =
|
|
134
|
-
|
|
133
|
+
const h = Se({ client: t, name: s, component: o });
|
|
134
|
+
r.register(h);
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
function
|
|
138
|
-
return e.map((o) => o[
|
|
136
|
+
const a = e.map((s) => Object.values(s));
|
|
137
|
+
function l(s) {
|
|
138
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
139
139
|
}
|
|
140
140
|
return {
|
|
141
141
|
register: n,
|
|
142
|
-
getByName:
|
|
143
|
-
listStore:
|
|
142
|
+
getByName: l,
|
|
143
|
+
listStore: a
|
|
144
144
|
};
|
|
145
145
|
});
|
|
146
146
|
function we(t) {
|
|
147
|
-
return k(
|
|
147
|
+
return k(ve, t);
|
|
148
148
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
const e =
|
|
153
|
-
register(
|
|
149
|
+
const V = (t, e, r) => {
|
|
150
|
+
r.register(t, e);
|
|
151
|
+
}, ke = I("framework"), be = w(({ client: t }) => {
|
|
152
|
+
const e = ke.store({}), r = x(e, {
|
|
153
|
+
register(s, o) {
|
|
154
154
|
return {
|
|
155
|
-
...
|
|
155
|
+
...s,
|
|
156
156
|
[o.name]: o.framework
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
|
-
function n(
|
|
161
|
-
e.getState()[
|
|
160
|
+
function n(s, o) {
|
|
161
|
+
e.getState()[s] && v(
|
|
162
162
|
"warn",
|
|
163
|
-
`Framework '${
|
|
164
|
-
),
|
|
163
|
+
`Framework '${s}' already registered. Registering again will override the previous registration.`
|
|
164
|
+
), r.register({ name: s, framework: o });
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
168
|
-
return e.map((o) => o[
|
|
166
|
+
const a = e.map((s) => Object.values(s));
|
|
167
|
+
function l(s) {
|
|
168
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
169
169
|
}
|
|
170
170
|
return {
|
|
171
171
|
register: n,
|
|
172
|
-
getByName:
|
|
173
|
-
listStore:
|
|
172
|
+
getByName: l,
|
|
173
|
+
listStore: a
|
|
174
174
|
};
|
|
175
175
|
});
|
|
176
|
-
function
|
|
177
|
-
return k(
|
|
176
|
+
function Ie(t) {
|
|
177
|
+
return k(be, t);
|
|
178
178
|
}
|
|
179
|
-
const
|
|
179
|
+
const xe = (t, e) => {
|
|
180
180
|
e.register(t.name, t);
|
|
181
|
-
},
|
|
181
|
+
}, Fe = 6e3, N = A("last_ping", "global"), Ee = (t) => `${t}/api/v1/ping`, Pe = async (t) => {
|
|
182
182
|
try {
|
|
183
|
-
const e = Date.now(),
|
|
184
|
-
if (
|
|
183
|
+
const e = Date.now(), r = localStorage.getItem(N);
|
|
184
|
+
if (r && e - parseInt(r) < Fe)
|
|
185
185
|
return !0;
|
|
186
|
-
const n =
|
|
186
|
+
const n = Ee(t.apiUrl), a = {
|
|
187
187
|
projectId: t.projectId,
|
|
188
188
|
path: window.location.pathname
|
|
189
|
-
},
|
|
189
|
+
}, l = JSON.stringify(a), s = {
|
|
190
190
|
"Content-Type": "application/json"
|
|
191
191
|
}, o = document.getElementById("picked_script"), u = o == null ? void 0 : o.dataset.verceltoken;
|
|
192
|
-
u && (
|
|
193
|
-
const
|
|
192
|
+
u && (s["x-vercel-protection-bypass"] = u);
|
|
193
|
+
const S = (await fetch(n, {
|
|
194
194
|
method: "POST",
|
|
195
|
-
headers:
|
|
196
|
-
body:
|
|
195
|
+
headers: s,
|
|
196
|
+
body: l
|
|
197
197
|
})).ok;
|
|
198
|
-
return
|
|
198
|
+
return S && localStorage.setItem(N, e.toString()), S;
|
|
199
199
|
} catch (e) {
|
|
200
|
-
return
|
|
200
|
+
return v("error", e), !1;
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
|
-
function
|
|
204
|
-
const e = typeof window < "u",
|
|
203
|
+
function Re(t) {
|
|
204
|
+
const e = typeof window < "u", r = {
|
|
205
205
|
client: t,
|
|
206
206
|
responses: t.responses.listStore.getState(),
|
|
207
207
|
fields: t.fields.listStore.getState(),
|
|
@@ -210,13 +210,13 @@ function Pe(t) {
|
|
|
210
210
|
sessionStorage: e ? window.sessionStorage : void 0,
|
|
211
211
|
localStorage: e ? window.localStorage : void 0
|
|
212
212
|
};
|
|
213
|
-
return Object.freeze(
|
|
213
|
+
return Object.freeze(r);
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
const e =
|
|
217
|
-
register(
|
|
215
|
+
const Ae = I("predicate"), Be = w(({ client: t }) => {
|
|
216
|
+
const e = Ae.store({}), r = x(e, {
|
|
217
|
+
register(s, o) {
|
|
218
218
|
return {
|
|
219
|
-
...
|
|
219
|
+
...s,
|
|
220
220
|
[o.name]: {
|
|
221
221
|
name: o.name,
|
|
222
222
|
predicate: o.predicate
|
|
@@ -224,172 +224,181 @@ const Re = I("predicate"), Ae = v(({ client: t }) => {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
|
-
function n(
|
|
228
|
-
e.getState()[
|
|
227
|
+
function n(s, o) {
|
|
228
|
+
e.getState()[s] && v(
|
|
229
229
|
"warn",
|
|
230
|
-
`Predicate '${
|
|
231
|
-
),
|
|
230
|
+
`Predicate '${s}' already registered. Registering again will override the previous registration.`
|
|
231
|
+
), r.register(Object.freeze({ name: s, predicate: o }));
|
|
232
232
|
}
|
|
233
|
-
const
|
|
234
|
-
function
|
|
235
|
-
return e.map((o) => o[
|
|
233
|
+
const a = e.map((s) => Object.values(s));
|
|
234
|
+
function l(s) {
|
|
235
|
+
return e.map((o) => o[s], { skipVoid: !1 });
|
|
236
236
|
}
|
|
237
237
|
return {
|
|
238
238
|
register: n,
|
|
239
|
-
getByName:
|
|
240
|
-
listStore:
|
|
239
|
+
getByName: l,
|
|
240
|
+
listStore: a
|
|
241
241
|
};
|
|
242
242
|
});
|
|
243
243
|
function $e(t) {
|
|
244
|
-
return k(
|
|
244
|
+
return k(Be, t);
|
|
245
245
|
}
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
},
|
|
249
|
-
const
|
|
250
|
-
register(
|
|
246
|
+
const je = (t, e, r) => {
|
|
247
|
+
r.register(t, e);
|
|
248
|
+
}, L = I("feature"), Ce = w(({ client: t }) => {
|
|
249
|
+
const e = L.store({}), r = L.store([]), n = x(e, {
|
|
250
|
+
register(d, c) {
|
|
251
251
|
return {
|
|
252
|
-
...
|
|
253
|
-
[
|
|
252
|
+
...d,
|
|
253
|
+
[c.id]: c.feature
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
|
-
function
|
|
258
|
-
|
|
257
|
+
function a(d, c) {
|
|
258
|
+
e.getState()[d] && v(
|
|
259
259
|
"warn",
|
|
260
|
-
`Feature '${
|
|
260
|
+
`Feature '${d}' already registered. Registering again will override the previous registration.`
|
|
261
261
|
);
|
|
262
|
-
const
|
|
263
|
-
id:
|
|
262
|
+
const g = {
|
|
263
|
+
id: d,
|
|
264
264
|
feature: {
|
|
265
|
-
...
|
|
266
|
-
id:
|
|
265
|
+
...c,
|
|
266
|
+
id: d
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
|
-
|
|
269
|
+
n.register(
|
|
270
270
|
Object.freeze({
|
|
271
|
-
id:
|
|
272
|
-
feature:
|
|
271
|
+
id: d,
|
|
272
|
+
feature: g
|
|
273
273
|
})
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
const
|
|
276
|
+
const l = M(
|
|
277
277
|
async ({
|
|
278
|
-
id:
|
|
279
|
-
key:
|
|
280
|
-
storage:
|
|
278
|
+
id: d,
|
|
279
|
+
key: c,
|
|
280
|
+
storage: i = "local"
|
|
281
281
|
}) => {
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
return { id: l, bucket: y };
|
|
282
|
+
const g = A(`feature:${d}:${c}`, "global"), p = (i === "session" ? $ : O).get(g).boolean();
|
|
283
|
+
return p ? { id: d, key: c, bucket: p } : null;
|
|
285
284
|
}
|
|
286
|
-
),
|
|
287
|
-
if (!
|
|
285
|
+
), s = M((d) => {
|
|
286
|
+
if (!d)
|
|
288
287
|
return null;
|
|
289
|
-
const
|
|
290
|
-
(
|
|
291
|
-
}),
|
|
292
|
-
source: { allFeaturesStore:
|
|
293
|
-
effect: async ({ allFeaturesStore:
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
return
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
throw new Error(`Feature with id '${
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
302
|
-
const
|
|
303
|
-
return { id:
|
|
288
|
+
const c = A(`feature:${d.id}:${d.key}`, "global");
|
|
289
|
+
(d.storage === "session" ? $ : O).set(c, d.bucket);
|
|
290
|
+
}), o = /* @__PURE__ */ new Map(), u = J({
|
|
291
|
+
source: { allFeaturesStore: e, resolvedFeaturesStore: r },
|
|
292
|
+
effect: async ({ allFeaturesStore: d, resolvedFeaturesStore: c }, { id: i, decide: g, key: f }) => {
|
|
293
|
+
const p = c.find((j) => j.id === i);
|
|
294
|
+
if (p)
|
|
295
|
+
return p;
|
|
296
|
+
const y = d[i];
|
|
297
|
+
if (!y)
|
|
298
|
+
throw new Error(`Feature with id '${i}' not found`);
|
|
299
|
+
const b = o.get(`${i}:${f}`);
|
|
300
|
+
if (b !== void 0) {
|
|
301
|
+
const j = await b;
|
|
302
|
+
return { id: y.id, bucket: j, key: f, storage: y.feature.storage };
|
|
304
303
|
}
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
return { id:
|
|
304
|
+
const B = g();
|
|
305
|
+
o.set(`${i}:${f}`, B);
|
|
306
|
+
const E = await B;
|
|
307
|
+
return { id: y.id, bucket: E, key: f, storage: y.feature.storage };
|
|
309
308
|
}
|
|
310
309
|
});
|
|
311
|
-
|
|
312
|
-
clock:
|
|
313
|
-
fn: (
|
|
314
|
-
const { id:
|
|
315
|
-
return { id:
|
|
310
|
+
F({
|
|
311
|
+
clock: n.register,
|
|
312
|
+
fn: (d) => {
|
|
313
|
+
const { id: c, feature: i } = d;
|
|
314
|
+
return { id: c, key: i.feature.key, storage: i.feature.storage };
|
|
316
315
|
},
|
|
317
|
-
target:
|
|
318
|
-
}),
|
|
316
|
+
target: l
|
|
317
|
+
}), F({
|
|
319
318
|
source: e,
|
|
320
|
-
clock:
|
|
321
|
-
fn: (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
clock: o.doneData,
|
|
326
|
-
fn: (l, f) => {
|
|
327
|
-
var d;
|
|
328
|
-
const { id: a, bucket: p, storage: g } = f, y = (d = l[a]) == null ? void 0 : d.feature.key;
|
|
329
|
-
return y ? { key: y, id: a, bucket: p, storage: g } : null;
|
|
319
|
+
clock: u.doneData,
|
|
320
|
+
fn: (d, c) => {
|
|
321
|
+
var y;
|
|
322
|
+
const { id: i, bucket: g, storage: f } = c, p = (y = d[i]) == null ? void 0 : y.feature.key;
|
|
323
|
+
return p ? { key: p, id: i, bucket: g, storage: f } : null;
|
|
330
324
|
},
|
|
331
|
-
target:
|
|
325
|
+
target: s
|
|
332
326
|
});
|
|
333
|
-
const
|
|
327
|
+
const h = C({ allFeaturesStore: e, resolvedFeaturesStore: r }).map(
|
|
334
328
|
({
|
|
335
|
-
allFeaturesStore:
|
|
336
|
-
resolvedFeaturesStore:
|
|
337
|
-
}) => Object.values(
|
|
338
|
-
const
|
|
339
|
-
return
|
|
340
|
-
id:
|
|
341
|
-
name:
|
|
342
|
-
key:
|
|
343
|
-
getBucket: () => ({ id:
|
|
329
|
+
allFeaturesStore: d,
|
|
330
|
+
resolvedFeaturesStore: c
|
|
331
|
+
}) => Object.values(d).map((i) => {
|
|
332
|
+
const g = c.find((f) => f.id === i.id);
|
|
333
|
+
return g ? {
|
|
334
|
+
id: i.id,
|
|
335
|
+
name: i.feature.name,
|
|
336
|
+
key: i.feature.key,
|
|
337
|
+
getBucket: () => ({ id: i.id, bucket: g.bucket }),
|
|
344
338
|
isResolved: !0
|
|
345
339
|
} : {
|
|
346
|
-
id:
|
|
347
|
-
name:
|
|
348
|
-
key:
|
|
349
|
-
getBucket: async () => await
|
|
340
|
+
id: i.id,
|
|
341
|
+
name: i.feature.name,
|
|
342
|
+
key: i.feature.key,
|
|
343
|
+
getBucket: async () => await u(i.feature),
|
|
350
344
|
isResolved: !1
|
|
351
345
|
};
|
|
352
346
|
})
|
|
353
347
|
);
|
|
354
|
-
|
|
355
|
-
|
|
348
|
+
F({
|
|
349
|
+
clock: u.doneData,
|
|
350
|
+
source: { resolvedFeatures: r },
|
|
351
|
+
filter: ({ resolvedFeatures: d }, { id: c }) => !d.some((i) => i.id === c),
|
|
352
|
+
fn: (d, c) => c,
|
|
353
|
+
target: t.eventBus.prepend((d) => ({
|
|
354
|
+
type: "feature_decide",
|
|
355
|
+
feature: d
|
|
356
|
+
}))
|
|
357
|
+
}), F({
|
|
358
|
+
clock: [l.doneData, u.doneData],
|
|
359
|
+
source: r,
|
|
360
|
+
fn: (d, c) => !c || d.some((i) => i.id === c.id) ? d : [...d, c],
|
|
361
|
+
target: r
|
|
362
|
+
});
|
|
363
|
+
function S(d) {
|
|
364
|
+
return e.map((c) => c[d], { skipVoid: !1 });
|
|
356
365
|
}
|
|
357
366
|
return {
|
|
358
|
-
register:
|
|
359
|
-
getByName:
|
|
360
|
-
listStore:
|
|
367
|
+
register: a,
|
|
368
|
+
getByName: S,
|
|
369
|
+
listStore: h
|
|
361
370
|
};
|
|
362
371
|
});
|
|
363
|
-
function
|
|
364
|
-
return k(
|
|
372
|
+
function De(t) {
|
|
373
|
+
return k(Ce, t);
|
|
365
374
|
}
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
function
|
|
375
|
+
const Oe = (t, e, r) => {
|
|
376
|
+
r.register(t, e);
|
|
377
|
+
}, P = I("history");
|
|
378
|
+
function U(t, e) {
|
|
370
379
|
return {
|
|
371
380
|
// eslint-disable-next-line sonarjs/pseudo-random
|
|
372
|
-
id:
|
|
381
|
+
id: se(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
373
382
|
node: e,
|
|
374
383
|
at: Date.now(),
|
|
375
384
|
experienceId: t
|
|
376
385
|
};
|
|
377
386
|
}
|
|
378
|
-
const
|
|
379
|
-
const t =
|
|
380
|
-
t.on(e, (
|
|
381
|
-
entries: [...
|
|
382
|
-
})), t.on(
|
|
387
|
+
const Me = w(() => {
|
|
388
|
+
const t = P.store({ entries: [] }), e = P.event(), r = P.event(), n = P.event(), a = P.event();
|
|
389
|
+
t.on(e, (s, o) => ({
|
|
390
|
+
entries: [...s.entries, U(o.experienceId, o.node)]
|
|
391
|
+
})), t.on(r, (s, o) => ({
|
|
383
392
|
entries: [
|
|
384
|
-
...
|
|
385
|
-
|
|
393
|
+
...s.entries.slice(0, -1),
|
|
394
|
+
U(o.experienceId, o.node)
|
|
386
395
|
]
|
|
387
|
-
})), t.on(
|
|
388
|
-
function
|
|
396
|
+
})), t.on(a, (s, o) => o);
|
|
397
|
+
function l(s, o) {
|
|
389
398
|
const u = { lastStepIndex: -1, secondLastStepIndex: -1 };
|
|
390
|
-
for (let h =
|
|
391
|
-
const
|
|
392
|
-
if (!(!
|
|
399
|
+
for (let h = s.length - 1; h >= 0; h--) {
|
|
400
|
+
const S = s[h], d = S == null ? void 0 : S.node;
|
|
401
|
+
if (!(!d || !ee(d)) && !(o && (S == null ? void 0 : S.experienceId) !== o))
|
|
393
402
|
if (u.lastStepIndex === -1)
|
|
394
403
|
u.lastStepIndex = h;
|
|
395
404
|
else {
|
|
@@ -399,219 +408,219 @@ const Oe = v(() => {
|
|
|
399
408
|
}
|
|
400
409
|
return u;
|
|
401
410
|
}
|
|
402
|
-
return t.on(n, (
|
|
403
|
-
const { secondLastStepIndex: u } =
|
|
411
|
+
return t.on(n, (s, o) => {
|
|
412
|
+
const { secondLastStepIndex: u } = l(s.entries, o.experienceId), h = u !== -1 ? s.entries.slice(0, u + 1) : s.entries;
|
|
404
413
|
return {
|
|
405
|
-
...
|
|
414
|
+
...s,
|
|
406
415
|
entries: h
|
|
407
416
|
};
|
|
408
417
|
}), {
|
|
409
418
|
push: e,
|
|
410
|
-
replace:
|
|
419
|
+
replace: r,
|
|
411
420
|
back: n,
|
|
412
|
-
restore:
|
|
413
|
-
entriesStore: t.map((
|
|
421
|
+
restore: a,
|
|
422
|
+
entriesStore: t.map((s) => s.entries)
|
|
414
423
|
};
|
|
415
424
|
});
|
|
416
|
-
function
|
|
417
|
-
return k(
|
|
425
|
+
function Te() {
|
|
426
|
+
return k(Me);
|
|
418
427
|
}
|
|
419
|
-
const
|
|
420
|
-
const t =
|
|
421
|
-
register(
|
|
428
|
+
const Ve = () => D(), Ne = I("field"), Le = w(() => {
|
|
429
|
+
const t = Ne.store({}), e = x(t, {
|
|
430
|
+
register(s, o) {
|
|
422
431
|
return {
|
|
423
|
-
...
|
|
432
|
+
...s,
|
|
424
433
|
[o.field.id]: o.field
|
|
425
434
|
};
|
|
426
435
|
}
|
|
427
436
|
});
|
|
428
|
-
function s
|
|
429
|
-
e.register({ field:
|
|
437
|
+
function r(s) {
|
|
438
|
+
e.register({ field: s });
|
|
430
439
|
}
|
|
431
|
-
const n = t.map((
|
|
432
|
-
function
|
|
433
|
-
return t.map((o) => o[
|
|
440
|
+
const n = t.map((s) => Object.values(s));
|
|
441
|
+
function a(s) {
|
|
442
|
+
return t.map((o) => o[s] || null);
|
|
434
443
|
}
|
|
435
|
-
function
|
|
436
|
-
return t.map((o) => Object.values(o).find((u) => u.name ===
|
|
444
|
+
function l(s) {
|
|
445
|
+
return t.map((o) => Object.values(o).find((u) => u.name === s) || null);
|
|
437
446
|
}
|
|
438
447
|
return {
|
|
439
|
-
register:
|
|
440
|
-
getById:
|
|
448
|
+
register: r,
|
|
449
|
+
getById: a,
|
|
441
450
|
listStore: n,
|
|
442
|
-
getByName:
|
|
451
|
+
getByName: l
|
|
443
452
|
};
|
|
444
453
|
});
|
|
445
|
-
function
|
|
446
|
-
return k(
|
|
454
|
+
function Ue() {
|
|
455
|
+
return k(Le);
|
|
447
456
|
}
|
|
448
|
-
const
|
|
457
|
+
const _e = (t, e) => {
|
|
449
458
|
e.register(t);
|
|
450
|
-
}, ze = I("action"),
|
|
459
|
+
}, ze = I("action"), He = w(() => {
|
|
451
460
|
const t = ze.store({}), e = x(t, {
|
|
452
|
-
register(
|
|
461
|
+
register(l, s) {
|
|
453
462
|
return {
|
|
454
|
-
...
|
|
455
|
-
[
|
|
456
|
-
name:
|
|
457
|
-
action:
|
|
463
|
+
...l,
|
|
464
|
+
[s.name]: {
|
|
465
|
+
name: s.name,
|
|
466
|
+
action: s.action
|
|
458
467
|
}
|
|
459
468
|
};
|
|
460
469
|
}
|
|
461
470
|
});
|
|
462
|
-
function
|
|
463
|
-
e.register({ name:
|
|
471
|
+
function r(l, s) {
|
|
472
|
+
e.register({ name: l, action: s });
|
|
464
473
|
}
|
|
465
|
-
const n = t.map((
|
|
466
|
-
function
|
|
467
|
-
return t.map((
|
|
474
|
+
const n = t.map((l) => Object.values(l));
|
|
475
|
+
function a(l) {
|
|
476
|
+
return t.map((s) => s[l], { skipVoid: !1 });
|
|
468
477
|
}
|
|
469
478
|
return {
|
|
470
|
-
register:
|
|
471
|
-
getByName:
|
|
479
|
+
register: r,
|
|
480
|
+
getByName: a,
|
|
472
481
|
listStore: n
|
|
473
482
|
};
|
|
474
483
|
});
|
|
475
|
-
function
|
|
476
|
-
return k(
|
|
484
|
+
function Ke() {
|
|
485
|
+
return k(He);
|
|
477
486
|
}
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
},
|
|
481
|
-
const e =
|
|
482
|
-
register(
|
|
487
|
+
const qe = (t, e, r) => {
|
|
488
|
+
r.register(t, e);
|
|
489
|
+
}, Ge = I("response"), We = w(({ client: t }) => {
|
|
490
|
+
const e = Ge.store({}), r = D(), n = D(), a = x(e, {
|
|
491
|
+
register(c, i) {
|
|
483
492
|
return {
|
|
484
|
-
...
|
|
485
|
-
[
|
|
493
|
+
...c,
|
|
494
|
+
[i.fieldId]: i.response
|
|
486
495
|
};
|
|
487
496
|
},
|
|
488
|
-
registerBatch(
|
|
497
|
+
registerBatch(c, i) {
|
|
489
498
|
return {
|
|
490
|
-
...
|
|
491
|
-
...
|
|
499
|
+
...c,
|
|
500
|
+
...i
|
|
492
501
|
};
|
|
493
502
|
},
|
|
494
|
-
clear(
|
|
495
|
-
const { [
|
|
496
|
-
return
|
|
503
|
+
clear(c, i) {
|
|
504
|
+
const { [i]: g, ...f } = c;
|
|
505
|
+
return f;
|
|
497
506
|
},
|
|
498
507
|
clearAll() {
|
|
499
508
|
return {};
|
|
500
509
|
}
|
|
501
510
|
});
|
|
502
|
-
function c
|
|
503
|
-
|
|
511
|
+
function l(c, i) {
|
|
512
|
+
a.register({ fieldId: c, response: i });
|
|
504
513
|
}
|
|
505
|
-
async function
|
|
506
|
-
const
|
|
514
|
+
async function s(c) {
|
|
515
|
+
const i = [];
|
|
507
516
|
return await Promise.allSettled(
|
|
508
|
-
Object.entries(
|
|
509
|
-
let
|
|
510
|
-
const
|
|
511
|
-
if (!
|
|
512
|
-
|
|
517
|
+
Object.entries(c).map(async ([g, f]) => {
|
|
518
|
+
let p = f;
|
|
519
|
+
const y = t.fields.getById(g).getState();
|
|
520
|
+
if (!y) {
|
|
521
|
+
i.push({
|
|
513
522
|
fieldId: g,
|
|
514
523
|
userMessage: `Field '${g}' not found`,
|
|
515
524
|
systemMessage: `No field with ID '${g}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
|
|
516
|
-
value:
|
|
525
|
+
value: p
|
|
517
526
|
});
|
|
518
527
|
return;
|
|
519
528
|
}
|
|
520
|
-
if (
|
|
521
|
-
const b = await R(t,
|
|
522
|
-
$input:
|
|
529
|
+
if (y.multiple && (typeof p == "string" || typeof p == "number" || typeof p == "boolean") && (p = [p]), y.validation && !ne(y.validation)) {
|
|
530
|
+
const b = await R(t, y.validation, {
|
|
531
|
+
$input: p
|
|
523
532
|
});
|
|
524
533
|
if (typeof b == "string") {
|
|
525
|
-
|
|
534
|
+
i.push({
|
|
526
535
|
fieldId: g,
|
|
527
536
|
userMessage: b,
|
|
528
537
|
systemMessage: `Field validation resulted in an error: ${b}.`,
|
|
529
|
-
value:
|
|
538
|
+
value: p
|
|
530
539
|
});
|
|
531
540
|
return;
|
|
532
541
|
}
|
|
533
542
|
if (b === !1) {
|
|
534
|
-
|
|
543
|
+
i.push({
|
|
535
544
|
fieldId: g,
|
|
536
545
|
userMessage: "This field is invalid",
|
|
537
546
|
systemMessage: "Field validation resulted in an unspecified error.",
|
|
538
|
-
value:
|
|
547
|
+
value: p
|
|
539
548
|
});
|
|
540
549
|
return;
|
|
541
550
|
}
|
|
542
551
|
}
|
|
543
|
-
if (
|
|
544
|
-
|
|
552
|
+
if (y.required && (typeof p > "u" || p === null || p === "" || Array.isArray(p) && !p.length)) {
|
|
553
|
+
i.push({
|
|
545
554
|
fieldId: g,
|
|
546
555
|
userMessage: "This field is required",
|
|
547
556
|
systemMessage: "Field is required.",
|
|
548
|
-
value:
|
|
557
|
+
value: p
|
|
549
558
|
});
|
|
550
559
|
return;
|
|
551
560
|
}
|
|
552
|
-
if (!
|
|
553
|
-
|
|
561
|
+
if (!y.multiple && Array.isArray(p) && p.length > 1) {
|
|
562
|
+
i.push({
|
|
554
563
|
fieldId: g,
|
|
555
564
|
userMessage: "This field expects a single response",
|
|
556
565
|
systemMessage: "Field expects a single response.",
|
|
557
|
-
value:
|
|
566
|
+
value: p
|
|
558
567
|
});
|
|
559
568
|
return;
|
|
560
569
|
}
|
|
561
|
-
if (
|
|
562
|
-
const b =
|
|
563
|
-
Array.isArray(
|
|
570
|
+
if (y.options) {
|
|
571
|
+
const b = y.options.map((E) => E.value), B = Array.isArray(p) ? p : [p];
|
|
572
|
+
Array.isArray(p) && (B.every((E) => b.includes(E)) || i.push({
|
|
564
573
|
fieldId: g,
|
|
565
574
|
userMessage: "This field expects a valid option",
|
|
566
575
|
systemMessage: `Field expects a valid option. Valid options are: ${b.join(", ")}`,
|
|
567
|
-
value:
|
|
576
|
+
value: p
|
|
568
577
|
}));
|
|
569
578
|
}
|
|
570
579
|
})
|
|
571
|
-
), { responsesToCommit:
|
|
580
|
+
), { responsesToCommit: c, validationErrors: i };
|
|
572
581
|
}
|
|
573
|
-
async function o(
|
|
574
|
-
const { responsesToCommit:
|
|
575
|
-
return g.length ? { errors: g } : (
|
|
582
|
+
async function o(c) {
|
|
583
|
+
const { responsesToCommit: i, validationErrors: g } = await s(c);
|
|
584
|
+
return g.length ? { errors: g } : (a.registerBatch(i), { errors: [] });
|
|
576
585
|
}
|
|
577
|
-
const u = e.map((
|
|
586
|
+
const u = e.map((c) => c), h = e.map((c) => Object.keys(c).map((g) => ({
|
|
578
587
|
fieldId: g,
|
|
579
|
-
value:
|
|
588
|
+
value: c[g]
|
|
580
589
|
})));
|
|
581
|
-
function
|
|
582
|
-
const
|
|
583
|
-
return
|
|
584
|
-
}
|
|
585
|
-
function
|
|
586
|
-
const
|
|
587
|
-
return
|
|
588
|
-
const
|
|
589
|
-
return
|
|
590
|
+
function S(c) {
|
|
591
|
+
const i = t.fields.getById(c), g = e.map((f) => f[c] || null);
|
|
592
|
+
return C({ f: i, r: g }, ({ f, r: p }) => p || (f != null && f.defaultValue ? f.defaultValue : null));
|
|
593
|
+
}
|
|
594
|
+
function d(c) {
|
|
595
|
+
const i = t.fields.getByName(c);
|
|
596
|
+
return C({ f: i, s: e }, ({ f: g, s: f }) => {
|
|
597
|
+
const p = g && f[g.id] || null;
|
|
598
|
+
return p || (g != null && g.defaultValue ? g.defaultValue : null);
|
|
590
599
|
});
|
|
591
600
|
}
|
|
592
|
-
return
|
|
593
|
-
clock:
|
|
594
|
-
target:
|
|
595
|
-
}),
|
|
601
|
+
return F({
|
|
602
|
+
clock: r,
|
|
603
|
+
target: a.clearAll
|
|
604
|
+
}), F({
|
|
596
605
|
clock: n,
|
|
597
|
-
target:
|
|
606
|
+
target: a.clear
|
|
598
607
|
}), {
|
|
599
|
-
register:
|
|
600
|
-
clearAll:
|
|
608
|
+
register: l,
|
|
609
|
+
clearAll: r,
|
|
601
610
|
clear: n,
|
|
602
611
|
commit: o,
|
|
603
|
-
getResponsesToCommit:
|
|
612
|
+
getResponsesToCommit: s,
|
|
604
613
|
listStore: h,
|
|
605
614
|
getAllStore: u,
|
|
606
|
-
getByFieldId:
|
|
607
|
-
getByFieldName:
|
|
615
|
+
getByFieldId: S,
|
|
616
|
+
getByFieldName: d
|
|
608
617
|
};
|
|
609
618
|
});
|
|
610
|
-
function
|
|
611
|
-
return k(
|
|
619
|
+
function Ye(t) {
|
|
620
|
+
return k(We, t);
|
|
612
621
|
}
|
|
613
|
-
const
|
|
614
|
-
function
|
|
622
|
+
const Je = () => "0.0.12-next.4";
|
|
623
|
+
function Qe() {
|
|
615
624
|
if (z()) {
|
|
616
625
|
const t = [
|
|
617
626
|
document.currentScript,
|
|
@@ -626,103 +635,103 @@ function Je() {
|
|
|
626
635
|
}
|
|
627
636
|
return "https://api.picked.app";
|
|
628
637
|
}
|
|
629
|
-
function
|
|
630
|
-
if (!
|
|
638
|
+
function Xe() {
|
|
639
|
+
if (!oe())
|
|
631
640
|
return {};
|
|
632
|
-
const t = new URLSearchParams(window.location.search), e = {},
|
|
633
|
-
for (const [
|
|
634
|
-
|
|
635
|
-
for (const
|
|
636
|
-
const
|
|
637
|
-
e[
|
|
641
|
+
const t = new URLSearchParams(window.location.search), e = {}, r = /* @__PURE__ */ new Set();
|
|
642
|
+
for (const [a] of t.entries())
|
|
643
|
+
a.startsWith("picked-") && r.add(a);
|
|
644
|
+
for (const a of r) {
|
|
645
|
+
const l = a.replace("picked-", "");
|
|
646
|
+
e[l] = t.getAll(a);
|
|
638
647
|
}
|
|
639
648
|
const n = A("s");
|
|
640
|
-
if (
|
|
649
|
+
if (r.size > 0)
|
|
641
650
|
$.set(n, e);
|
|
642
651
|
else {
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
645
|
-
return
|
|
652
|
+
const a = $.get(n);
|
|
653
|
+
if (a)
|
|
654
|
+
return a.json() || {};
|
|
646
655
|
}
|
|
647
656
|
return e;
|
|
648
657
|
}
|
|
649
|
-
function
|
|
650
|
-
if (
|
|
658
|
+
function Ze() {
|
|
659
|
+
if (ae())
|
|
651
660
|
return crypto.randomUUID();
|
|
652
|
-
const t = Date.now().toString(36), e = Math.random().toString(36).substring(2, 15),
|
|
653
|
-
return `${t}-${e}-${
|
|
661
|
+
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);
|
|
662
|
+
return `${t}-${e}-${r}-${n}`;
|
|
654
663
|
}
|
|
655
|
-
const
|
|
656
|
-
id:
|
|
657
|
-
}),
|
|
658
|
-
if (!
|
|
659
|
-
const t =
|
|
664
|
+
const et = () => ({
|
|
665
|
+
id: Ze()
|
|
666
|
+
}), tt = A("session", "global"), rt = () => {
|
|
667
|
+
if (!ie()) return null;
|
|
668
|
+
const t = O.get(tt);
|
|
660
669
|
let e = t.isSet() ? t.json() : null;
|
|
661
|
-
return e || (e =
|
|
662
|
-
},
|
|
663
|
-
class
|
|
670
|
+
return e || (e = et(), t.set(e)), e;
|
|
671
|
+
}, st = () => rt();
|
|
672
|
+
class q {
|
|
664
673
|
constructor(e) {
|
|
665
674
|
m(this, "options");
|
|
666
675
|
m(this, "isReady", !1);
|
|
667
676
|
m(this, "project");
|
|
668
677
|
m(this, "plugins", {});
|
|
669
|
-
m(this, "eventBus",
|
|
678
|
+
m(this, "eventBus", Ve());
|
|
670
679
|
m(this, "organizationId");
|
|
671
680
|
m(this, "projectId");
|
|
672
681
|
m(this, "apiUrl");
|
|
673
682
|
m(this, "session");
|
|
674
|
-
m(this, "searchParams",
|
|
675
|
-
m(this, "history",
|
|
683
|
+
m(this, "searchParams", Xe());
|
|
684
|
+
m(this, "history", Te());
|
|
676
685
|
m(this, "components", we({ client: this }));
|
|
677
|
-
m(this, "experienceInstances",
|
|
678
|
-
m(this, "experiences",
|
|
679
|
-
m(this, "frameworks",
|
|
686
|
+
m(this, "experienceInstances", te({ client: this }));
|
|
687
|
+
m(this, "experiences", pe({ client: this }));
|
|
688
|
+
m(this, "frameworks", Ie({ client: this }));
|
|
680
689
|
m(this, "predicates", $e({ client: this }));
|
|
681
|
-
m(this, "features",
|
|
682
|
-
m(this, "responses",
|
|
683
|
-
m(this, "fields",
|
|
684
|
-
m(this, "actions",
|
|
685
|
-
|
|
690
|
+
m(this, "features", De({ client: this }));
|
|
691
|
+
m(this, "responses", Ye({ client: this }));
|
|
692
|
+
m(this, "fields", Ue());
|
|
693
|
+
m(this, "actions", Ke());
|
|
694
|
+
v("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Qe(), this.session = st(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.eventBus({ type: "initialized", version: Je() }), v("info", "Picked client initialized.");
|
|
686
695
|
}
|
|
687
696
|
start() {
|
|
688
|
-
|
|
689
|
-
z() && (document.body &&
|
|
697
|
+
Pe(this), (async () => {
|
|
698
|
+
z() && (document.body && T(this), await re(), await T(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
|
|
690
699
|
})();
|
|
691
700
|
}
|
|
692
701
|
registerFramework(e) {
|
|
693
|
-
|
|
702
|
+
xe(e, this.frameworks);
|
|
694
703
|
}
|
|
695
|
-
registerComponent(e,
|
|
696
|
-
|
|
704
|
+
registerComponent(e, r) {
|
|
705
|
+
V(e, r, this.components);
|
|
697
706
|
}
|
|
698
707
|
registerPlugin(e) {
|
|
699
|
-
|
|
708
|
+
me(this, e, this.plugins);
|
|
700
709
|
}
|
|
701
|
-
registerFeature(e,
|
|
702
|
-
|
|
710
|
+
registerFeature(e, r) {
|
|
711
|
+
Oe(e, r, this.features);
|
|
703
712
|
}
|
|
704
|
-
registerPredicate(e,
|
|
705
|
-
|
|
713
|
+
registerPredicate(e, r) {
|
|
714
|
+
je(e, r, this.predicates);
|
|
706
715
|
}
|
|
707
716
|
registerField(e) {
|
|
708
|
-
|
|
717
|
+
_e(e, this.fields);
|
|
709
718
|
}
|
|
710
|
-
registerAction(e,
|
|
711
|
-
|
|
719
|
+
registerAction(e, r) {
|
|
720
|
+
qe(e, r, this.actions);
|
|
712
721
|
}
|
|
713
722
|
registerExperience(e) {
|
|
714
|
-
e.component &&
|
|
723
|
+
e.component && V(`experience:${e.id}`, e.component, this.components), ge(e, this.experiences);
|
|
715
724
|
}
|
|
716
725
|
getStateSnapshot() {
|
|
717
|
-
return
|
|
726
|
+
return Re(this);
|
|
718
727
|
}
|
|
719
728
|
async launchExperienceById(e) {
|
|
720
|
-
const
|
|
721
|
-
if (!
|
|
722
|
-
|
|
729
|
+
const r = this.experiences.getById(e).getState();
|
|
730
|
+
if (!r) {
|
|
731
|
+
v("warn", `Experience with id '${e}' not found.`);
|
|
723
732
|
return;
|
|
724
733
|
}
|
|
725
|
-
|
|
734
|
+
K(this, r);
|
|
726
735
|
}
|
|
727
736
|
// private async fetchProject() {
|
|
728
737
|
// if (this.project) {
|
|
@@ -735,16 +744,16 @@ class K {
|
|
|
735
744
|
// }
|
|
736
745
|
setupPlugins() {
|
|
737
746
|
var e;
|
|
738
|
-
(e = this.options.plugins) == null || e.forEach((
|
|
739
|
-
if (Array.isArray(
|
|
740
|
-
|
|
741
|
-
this.registerPlugin(
|
|
747
|
+
(e = this.options.plugins) == null || e.forEach((r) => {
|
|
748
|
+
if (Array.isArray(r)) {
|
|
749
|
+
r.forEach((a) => {
|
|
750
|
+
this.registerPlugin(a);
|
|
742
751
|
});
|
|
743
752
|
return;
|
|
744
753
|
}
|
|
745
|
-
const n = typeof
|
|
754
|
+
const n = typeof r == "function" ? r() : r;
|
|
746
755
|
if (Array.isArray(n)) {
|
|
747
|
-
n.forEach((
|
|
756
|
+
n.forEach((a) => this.registerPlugin(a));
|
|
748
757
|
return;
|
|
749
758
|
}
|
|
750
759
|
this.registerPlugin(n);
|
|
@@ -752,21 +761,21 @@ class K {
|
|
|
752
761
|
}
|
|
753
762
|
setupFeatures() {
|
|
754
763
|
const e = this.options.features;
|
|
755
|
-
e && (Object.entries(e).forEach(([
|
|
756
|
-
const
|
|
757
|
-
this.registerFeature(
|
|
758
|
-
}), this.searchParams.feature && this.searchParams.feature.forEach((
|
|
764
|
+
e && (Object.entries(e).forEach(([r, n]) => {
|
|
765
|
+
const a = typeof n == "function" ? n() : n;
|
|
766
|
+
this.registerFeature(r, a);
|
|
767
|
+
}), this.searchParams.feature && this.searchParams.feature.forEach((r) => {
|
|
759
768
|
try {
|
|
760
|
-
const [n,
|
|
761
|
-
if (!n || !
|
|
769
|
+
const [n, a] = r.split(":");
|
|
770
|
+
if (!n || !a)
|
|
762
771
|
return;
|
|
763
|
-
let
|
|
764
|
-
|
|
765
|
-
key: `${
|
|
772
|
+
let l = a;
|
|
773
|
+
l === "true" && (l = !0), l === "false" && (l = !1), this.registerFeature(n, {
|
|
774
|
+
key: `${l}`,
|
|
766
775
|
// use the assigned bucket value as the key
|
|
767
776
|
name: n,
|
|
768
777
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
769
|
-
decide: () =>
|
|
778
|
+
decide: () => l,
|
|
770
779
|
storage: "session"
|
|
771
780
|
});
|
|
772
781
|
} catch {
|
|
@@ -775,73 +784,73 @@ class K {
|
|
|
775
784
|
}
|
|
776
785
|
setupPredicates() {
|
|
777
786
|
const e = this.options.predicates;
|
|
778
|
-
e && Object.entries(e).forEach(([
|
|
787
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
779
788
|
if (typeof n != "function") {
|
|
780
|
-
|
|
789
|
+
v("warn", `Predicate "${r}" is not a function.`);
|
|
781
790
|
return;
|
|
782
791
|
}
|
|
783
|
-
this.registerPredicate(
|
|
792
|
+
this.registerPredicate(r, n);
|
|
784
793
|
});
|
|
785
794
|
}
|
|
786
795
|
setupActions() {
|
|
787
796
|
const e = this.options.actions;
|
|
788
|
-
e && Object.entries(e).forEach(([
|
|
797
|
+
e && Object.entries(e).forEach(([r, n]) => {
|
|
789
798
|
if (typeof n != "function") {
|
|
790
|
-
|
|
799
|
+
v("warn", `Action "${r}" is not a function.`);
|
|
791
800
|
return;
|
|
792
801
|
}
|
|
793
|
-
this.registerAction(
|
|
802
|
+
this.registerAction(r, n);
|
|
794
803
|
});
|
|
795
804
|
}
|
|
796
805
|
getPluginConfig(e) {
|
|
797
806
|
return this.plugins[e] ?? {};
|
|
798
807
|
}
|
|
799
808
|
}
|
|
800
|
-
m(
|
|
801
|
-
function
|
|
809
|
+
m(q, "logger", v);
|
|
810
|
+
function G(t) {
|
|
802
811
|
var e;
|
|
803
|
-
return ((e = t.options) == null ? void 0 : e.some((
|
|
812
|
+
return ((e = t.options) == null ? void 0 : e.some((r) => "condition" in r)) ?? !1;
|
|
804
813
|
}
|
|
805
|
-
function
|
|
806
|
-
return t.some((e) => e.condition ||
|
|
814
|
+
function nt(t) {
|
|
815
|
+
return t.some((e) => e.condition || G(e));
|
|
807
816
|
}
|
|
808
|
-
async function
|
|
809
|
-
return e.length === 0 || !
|
|
817
|
+
async function ft(t, e) {
|
|
818
|
+
return e.length === 0 || !nt(e) ? e : (await Promise.all(
|
|
810
819
|
e.map(async (n) => {
|
|
811
820
|
if (!(n.condition ? await R(t, n.condition) : !0))
|
|
812
821
|
return null;
|
|
813
|
-
if (!n.options || !
|
|
822
|
+
if (!n.options || !G(n))
|
|
814
823
|
return n;
|
|
815
|
-
const
|
|
824
|
+
const s = (await Promise.all(
|
|
816
825
|
n.options.map(async (u) => u.condition ? await R(t, u.condition) ? u : null : u)
|
|
817
826
|
)).filter((u) => u !== null);
|
|
818
|
-
return
|
|
827
|
+
return s.length === n.options.length ? n : s.length === 0 ? null : { ...n, options: s };
|
|
819
828
|
})
|
|
820
829
|
)).filter((n) => n !== null);
|
|
821
830
|
}
|
|
822
|
-
const
|
|
823
|
-
const e = new
|
|
824
|
-
return
|
|
831
|
+
const mt = (t) => {
|
|
832
|
+
const e = new q(t);
|
|
833
|
+
return ce(e), e;
|
|
825
834
|
};
|
|
826
835
|
export {
|
|
827
|
-
|
|
828
|
-
|
|
836
|
+
q as Picked,
|
|
837
|
+
mt as createClient,
|
|
829
838
|
A as createStorageKey,
|
|
830
839
|
R as evaluateRuleLogic,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
840
|
+
ft as getStepFields,
|
|
841
|
+
St as isPickedRoot,
|
|
842
|
+
O as localStore,
|
|
834
843
|
$ as sessionStore,
|
|
835
844
|
wt as subscribe,
|
|
836
|
-
|
|
837
|
-
|
|
845
|
+
bt as supportsCookies,
|
|
846
|
+
ae as supportsCryptoRandomUUID,
|
|
838
847
|
z as supportsDocument,
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
848
|
+
It as supportsHistory,
|
|
849
|
+
xt as supportsIntersectionObserver,
|
|
850
|
+
ie as supportsLocalStorage,
|
|
851
|
+
Ft as supportsLocation,
|
|
852
|
+
Et as supportsSessionStorage,
|
|
853
|
+
Pt as supportsShadowRoot,
|
|
854
|
+
Rt as supportsWebComponents,
|
|
855
|
+
oe as supportsWindow
|
|
847
856
|
};
|