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