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