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