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