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