@picked/client 0.0.1-dev.1777938796953 → 0.0.1-dev.1778120127377
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/README.md +0 -8
- package/dist/{api-GE6C0lxp.cjs → api-BM3zWj3k.cjs} +1 -1
- package/dist/{api-Bn4z854o.js → api-zfqEYPyX.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +4 -4
- 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/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/actions.mdx +0 -1
- package/dist/docs/index.md +0 -2
- package/dist/docs/pickedql/dimensions.md +2 -0
- package/dist/docs/pickedql/virtual-functions.md +27 -0
- package/dist/docs/sdk/actions.md +0 -1
- package/dist/docs/sdk/features.md +0 -1
- package/dist/docs/sdk/index.md +0 -1
- package/dist/docs/sdk/plugins/create-experience.md +0 -1
- package/dist/docs/sdk/plugins/dynamic-experiences.md +0 -1
- package/dist/docs/sdk/plugins/window-object.md +0 -1
- package/dist/docs/sdk/predicates.md +0 -1
- package/dist/esm/form/index.js +1 -1
- package/dist/esm/index.js +971 -539
- package/dist/esm/plugins/dynamic-experiences/index.js +51 -49
- package/dist/esm/plugins/experience-browser-storage/index.js +8 -5
- package/dist/esm/plugins/history-browser-storage/index.js +3 -3
- package/dist/esm/plugins/single-page-app/index.js +1 -1
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +23 -13
- package/dist/{experience-instance-CWYRLfFM.js → experience-instance-BrLWgVAN.js} +135 -127
- package/dist/experience-instance-Ct3ogC7n.cjs +1 -0
- package/dist/rules-logic-D_CVBuv7.js +13 -0
- package/dist/rules-logic-H6P8xwHF.cjs +1 -0
- package/dist/types/client.d.ts +2 -2
- package/dist/types/entities/action/action.d.ts +6 -3
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/component/component.d.ts +39 -2
- package/dist/types/entities/component/component.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +49 -113
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +17 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts +26 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/framework/framework.d.ts +24 -3
- package/dist/types/entities/framework/framework.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts +15 -27
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +32 -1
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/entities/predicate/predicate.d.ts +24 -3
- package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
- package/dist/types/entities/session/session.d.ts +45 -0
- package/dist/types/entities/session/session.d.ts.map +1 -0
- package/dist/types/exports.d.ts +9 -3
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/lifecycle.d.ts +47 -0
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -0
- package/dist/types/lifecycle/rules-logic.d.ts +24 -0
- package/dist/types/lifecycle/rules-logic.d.ts.map +1 -0
- package/dist/types/lifecycle/state-snapshot.d.ts +37 -0
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -0
- package/dist/types/logic-engine.d.ts +1 -1
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +111 -190
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -14
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/web-components/plugin.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +12 -4
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +4 -9
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/experience-instance-BDTNGT8a.cjs +0 -1
- package/dist/rules-logic-BTIxfrJJ.js +0 -240
- package/dist/rules-logic-DNLOv90w.cjs +0 -1
- package/dist/types/utils/state-snaphot.d.ts +0 -26
- package/dist/types/utils/state-snaphot.d.ts.map +0 -1
- package/dist/types/utils/user-session.d.ts +0 -12
- package/dist/types/utils/user-session.d.ts.map +0 -1
- /package/dist/{object-C82v79xc.js → object-DvUDOytC.js} +0 -0
- /package/dist/{object-CUJOjanb.cjs → object-ThO1DEyl.cjs} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,108 +1,142 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as n } from "../
|
|
1
|
+
import { t as e } from "../object-DvUDOytC.js";
|
|
2
|
+
import { n as t, t as n } from "../rules-logic-D_CVBuv7.js";
|
|
3
3
|
import { t as r } from "../logger-6z_gb4rA.js";
|
|
4
4
|
import { a as i, c as a, d as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "../supports-0XIfd4-R.js";
|
|
5
|
-
import { a as g, c as _, i as v, l as
|
|
6
|
-
import { i as
|
|
7
|
-
import { n as
|
|
8
|
-
import { t as
|
|
9
|
-
import { attach as
|
|
10
|
-
import { createFactory as
|
|
5
|
+
import { a as g, c as _, i as v, l as y, n as b, o as ee, r as x, s as S } from "../experience-instance-BrLWgVAN.js";
|
|
6
|
+
import { i as C, n as w, r as T, t as E } from "../storage-6Xk0uAxB.js";
|
|
7
|
+
import { n as D, r as te } from "../api-zfqEYPyX.js";
|
|
8
|
+
import { t as ne } from "../id-CRqy981z.js";
|
|
9
|
+
import { attach as O, combine as k, createApi as A, createDomain as j, createEffect as M, createEvent as N, createStore as P, sample as F } from "effector";
|
|
10
|
+
import { createFactory as I, invoke as L } from "@withease/factories";
|
|
11
11
|
//#region src/entities/experience/experience.ts
|
|
12
|
-
var
|
|
13
|
-
let
|
|
12
|
+
var re = j("experience"), ie = I(({ client: e, experience: r }) => {
|
|
13
|
+
let i = re.store(r), a = A(i, { merge(e, t) {
|
|
14
14
|
return {
|
|
15
15
|
...e,
|
|
16
16
|
...t.experience
|
|
17
17
|
};
|
|
18
|
-
} }),
|
|
18
|
+
} }), o = i.map((e) => ({
|
|
19
19
|
name: e.name,
|
|
20
20
|
decisionLogic: e.condition,
|
|
21
21
|
targetSelectors: e.targets,
|
|
22
22
|
initializeOpenLogic: e.initializeOpen
|
|
23
|
-
})),
|
|
24
|
-
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(
|
|
23
|
+
})), s = k(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = k(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
|
|
24
|
+
let r = e.nodes.filter(v).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(x).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
|
|
25
25
|
return {
|
|
26
26
|
steps: r,
|
|
27
27
|
nodes: e.nodes,
|
|
28
28
|
edges: e.edges,
|
|
29
29
|
conditions: i
|
|
30
30
|
};
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
}), l = r.actions ?? [], u, d = O({
|
|
32
|
+
source: o,
|
|
33
|
+
effect: (t, n) => {
|
|
34
|
+
let i = S(t.targetSelectors, r.id);
|
|
35
|
+
i.forEach(({ elements: e }) => e.forEach((e) => y(e, r.id))), g(i, r.id, r.key).forEach((t) => {
|
|
36
|
+
n ? e.experienceInstances.spawn(u, t, n) : e.experienceInstances.spawn(u, t);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}), f = O({
|
|
40
|
+
source: k({
|
|
41
|
+
preconditionPassed: e.preconditionPassedStore,
|
|
42
|
+
isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
|
|
43
|
+
config: o
|
|
44
|
+
}),
|
|
45
|
+
effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
|
|
46
|
+
if (!i || !a) return !1;
|
|
47
|
+
let { decisionLogic: s, targetSelectors: c } = o;
|
|
48
|
+
return c.length === 0 || S(c, r.id).length < 1 ? !1 : s === void 0 ? !0 : t(s) ? await n(e, s) === !0 : !0;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return u = {
|
|
52
|
+
id: r.id,
|
|
53
|
+
key: r.key,
|
|
54
|
+
name: r.name,
|
|
55
|
+
configStore: o,
|
|
56
|
+
treeStore: c,
|
|
57
|
+
componentStore: s,
|
|
58
|
+
actions: l,
|
|
59
|
+
merge: a.merge,
|
|
60
|
+
initialiseFx: d,
|
|
61
|
+
shouldInitialiseFx: f
|
|
62
|
+
}, u;
|
|
42
63
|
});
|
|
43
|
-
function
|
|
44
|
-
return
|
|
64
|
+
function ae(e) {
|
|
65
|
+
return L(ie, e);
|
|
45
66
|
}
|
|
46
|
-
var
|
|
47
|
-
let t =
|
|
67
|
+
var oe = I(({ client: e }) => {
|
|
68
|
+
let t = re.store({}), n = A(t, { register(e, t) {
|
|
48
69
|
return {
|
|
49
70
|
...e,
|
|
50
71
|
[t.id]: t
|
|
51
72
|
};
|
|
52
|
-
} })
|
|
53
|
-
|
|
54
|
-
let i = t.getState()[r.id];
|
|
55
|
-
if (i) {
|
|
56
|
-
i.merge({
|
|
57
|
-
experience: r,
|
|
58
|
-
strategy: "override"
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
let a = ce({
|
|
73
|
+
} }), r = N(), i = M((t) => {
|
|
74
|
+
n.register(ae({
|
|
63
75
|
client: e,
|
|
64
|
-
experience:
|
|
76
|
+
experience: t
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
F({
|
|
80
|
+
clock: r,
|
|
81
|
+
source: t,
|
|
82
|
+
filter: (e, t) => e[t.id] !== void 0,
|
|
83
|
+
fn: (e, t) => ({
|
|
84
|
+
existing: e[t.id],
|
|
85
|
+
experience: t
|
|
86
|
+
})
|
|
87
|
+
}).watch(({ existing: e, experience: t }) => {
|
|
88
|
+
e?.merge({
|
|
89
|
+
experience: t,
|
|
90
|
+
strategy: "override"
|
|
65
91
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
92
|
+
}), F({
|
|
93
|
+
clock: r,
|
|
94
|
+
source: t,
|
|
95
|
+
filter: (e, t) => e[t.id] === void 0,
|
|
96
|
+
fn: (e, t) => t,
|
|
97
|
+
target: i
|
|
98
|
+
});
|
|
99
|
+
let a = t.map((e) => Object.values(e));
|
|
100
|
+
function o(e) {
|
|
70
101
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
71
102
|
}
|
|
72
|
-
function
|
|
103
|
+
function s(e) {
|
|
73
104
|
return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
|
|
74
105
|
}
|
|
75
|
-
let
|
|
106
|
+
let c = O({
|
|
76
107
|
source: t,
|
|
77
|
-
effect: async (
|
|
78
|
-
let
|
|
79
|
-
if (!
|
|
80
|
-
"key" in
|
|
108
|
+
effect: async (e, t) => {
|
|
109
|
+
let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
|
|
110
|
+
if (!n) {
|
|
111
|
+
"key" in t ? `${t.key}` : `${t.id}`;
|
|
81
112
|
return;
|
|
82
113
|
}
|
|
83
|
-
let { options:
|
|
84
|
-
if (
|
|
85
|
-
|
|
114
|
+
let { options: r } = t;
|
|
115
|
+
if (r?.bypassCondition) {
|
|
116
|
+
await n.initialiseFx(r);
|
|
86
117
|
return;
|
|
87
118
|
}
|
|
88
|
-
await
|
|
119
|
+
await n.shouldInitialiseFx() && await n.initialiseFx(r);
|
|
89
120
|
}
|
|
90
121
|
});
|
|
91
122
|
return {
|
|
92
123
|
register: r,
|
|
93
|
-
get:
|
|
94
|
-
getById:
|
|
95
|
-
getByKey:
|
|
96
|
-
launch:
|
|
97
|
-
open:
|
|
124
|
+
get: o,
|
|
125
|
+
getById: o,
|
|
126
|
+
getByKey: s,
|
|
127
|
+
launch: c,
|
|
128
|
+
open: O({
|
|
98
129
|
source: {
|
|
99
130
|
experiences: t,
|
|
100
131
|
instances: e.experienceInstances.listStore
|
|
101
132
|
},
|
|
102
|
-
effect: ({ experiences: e, instances: t }, n) => {
|
|
133
|
+
effect: async ({ experiences: e, instances: t }, n) => {
|
|
103
134
|
let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => r && e.experienceId === r.id);
|
|
104
|
-
if (i.length > 0)
|
|
105
|
-
|
|
135
|
+
if (i.length > 0) {
|
|
136
|
+
for (let e of i) e.open();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
await c("key" in n ? {
|
|
106
140
|
key: n.key,
|
|
107
141
|
options: {
|
|
108
142
|
...n.options,
|
|
@@ -117,26 +151,31 @@ var le = M(({ client: e }) => {
|
|
|
117
151
|
});
|
|
118
152
|
}
|
|
119
153
|
}),
|
|
120
|
-
listStore:
|
|
154
|
+
listStore: a,
|
|
155
|
+
initialiseExperiencesFx: O({
|
|
156
|
+
source: a,
|
|
157
|
+
effect: async (e) => {
|
|
158
|
+
await Promise.all(e.map(async (e) => {
|
|
159
|
+
await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
})
|
|
121
163
|
};
|
|
122
164
|
});
|
|
123
|
-
function
|
|
124
|
-
return
|
|
165
|
+
function se(e) {
|
|
166
|
+
return L(oe, e);
|
|
125
167
|
}
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
168
|
+
var ce = async (e) => {
|
|
169
|
+
await e.experiences.initialiseExperiencesFx();
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/entities/plugin/plugin.ts
|
|
173
|
+
function le(e) {
|
|
174
|
+
return M(async () => {
|
|
175
|
+
await e();
|
|
130
176
|
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
await L(e, t) && F(e, t);
|
|
134
|
-
}));
|
|
135
|
-
}, L = async (n, r) => {
|
|
136
|
-
if (!n.preconditionPassed || !n.session?.isUser) return !1;
|
|
137
|
-
let { decisionLogic: i, targetSelectors: a } = r.configStore.getState();
|
|
138
|
-
return y(a, r.id).length < 1 || a.length === 0 ? !1 : i === void 0 ? !0 : e(i) ? await t(n, i) === !0 : !0;
|
|
139
|
-
}, de = (e, t, n) => {
|
|
177
|
+
}
|
|
178
|
+
var ue = (e, t, n) => {
|
|
140
179
|
let r = t.name, i = t.setup(e);
|
|
141
180
|
if (i) {
|
|
142
181
|
let e = n[r] ?? {};
|
|
@@ -145,106 +184,508 @@ var F = (e, t, n) => {
|
|
|
145
184
|
...i
|
|
146
185
|
});
|
|
147
186
|
}
|
|
148
|
-
},
|
|
187
|
+
}, de = j("component"), fe = I(({ client: e, component: t, name: n }) => ({
|
|
149
188
|
name: n,
|
|
150
189
|
component: t,
|
|
151
190
|
frameworkStore: e.frameworks.getByName(t.frameworkName)
|
|
152
191
|
}));
|
|
153
|
-
function
|
|
154
|
-
return
|
|
192
|
+
function pe(e) {
|
|
193
|
+
return L(fe, e);
|
|
155
194
|
}
|
|
156
|
-
var
|
|
157
|
-
let t =
|
|
195
|
+
var me = I(({ client: e }) => {
|
|
196
|
+
let t = de.store({}), n = A(t, { register(e, t) {
|
|
158
197
|
return {
|
|
159
198
|
...e,
|
|
160
199
|
[t.name]: t
|
|
161
200
|
};
|
|
162
|
-
} });
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
201
|
+
} }), i = N();
|
|
202
|
+
F({
|
|
203
|
+
clock: i,
|
|
204
|
+
source: t,
|
|
205
|
+
filter: (e, { name: t }) => e[t] !== void 0,
|
|
206
|
+
fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
|
|
207
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
208
|
+
clock: i,
|
|
209
|
+
fn: ({ name: t, component: n }) => pe({
|
|
166
210
|
client: e,
|
|
167
|
-
name:
|
|
168
|
-
component:
|
|
169
|
-
})
|
|
170
|
-
n.register
|
|
171
|
-
}
|
|
172
|
-
let
|
|
173
|
-
function
|
|
211
|
+
name: t,
|
|
212
|
+
component: n
|
|
213
|
+
}),
|
|
214
|
+
target: n.register
|
|
215
|
+
});
|
|
216
|
+
let a = t.map((e) => Object.values(e));
|
|
217
|
+
function o(e) {
|
|
174
218
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
175
219
|
}
|
|
176
220
|
return {
|
|
177
|
-
register:
|
|
178
|
-
getByName:
|
|
179
|
-
listStore:
|
|
221
|
+
register: i,
|
|
222
|
+
getByName: o,
|
|
223
|
+
listStore: a
|
|
180
224
|
};
|
|
181
225
|
});
|
|
182
|
-
function
|
|
183
|
-
return
|
|
226
|
+
function he(e) {
|
|
227
|
+
return L(me, e);
|
|
184
228
|
}
|
|
185
|
-
var
|
|
186
|
-
n.register(
|
|
187
|
-
|
|
188
|
-
|
|
229
|
+
var ge = (e, t, n) => {
|
|
230
|
+
n.register({
|
|
231
|
+
name: e,
|
|
232
|
+
component: t
|
|
233
|
+
});
|
|
234
|
+
}, _e = j("framework"), ve = I((e) => {
|
|
235
|
+
let t = _e.store({}), n = A(t, { register(e, t) {
|
|
189
236
|
return {
|
|
190
237
|
...e,
|
|
191
238
|
[t.name]: t.framework
|
|
192
239
|
};
|
|
193
|
-
} });
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
240
|
+
} }), i = N();
|
|
241
|
+
F({
|
|
242
|
+
clock: i,
|
|
243
|
+
source: t,
|
|
244
|
+
filter: (e, { name: t }) => e[t] !== void 0,
|
|
245
|
+
fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
|
|
246
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
247
|
+
clock: i,
|
|
248
|
+
target: n.register
|
|
249
|
+
});
|
|
250
|
+
let a = t.map((e) => Object.values(e));
|
|
251
|
+
function o(e) {
|
|
202
252
|
return t.map((t) => t[e], { skipVoid: !1 });
|
|
203
253
|
}
|
|
204
254
|
return {
|
|
205
|
-
register:
|
|
206
|
-
getByName:
|
|
207
|
-
listStore:
|
|
255
|
+
register: i,
|
|
256
|
+
getByName: o,
|
|
257
|
+
listStore: a
|
|
208
258
|
};
|
|
209
259
|
});
|
|
210
|
-
function
|
|
211
|
-
return
|
|
260
|
+
function ye(e) {
|
|
261
|
+
return L(ve, e);
|
|
212
262
|
}
|
|
213
|
-
var
|
|
214
|
-
t.register(
|
|
215
|
-
|
|
263
|
+
var be = (e, t) => {
|
|
264
|
+
t.register({
|
|
265
|
+
name: e.name,
|
|
266
|
+
framework: e
|
|
267
|
+
});
|
|
268
|
+
}, xe = I(({ client: e }) => {
|
|
269
|
+
let t = typeof window < "u", n = {
|
|
270
|
+
location: t ? window.location : void 0,
|
|
271
|
+
document: t ? window.document : void 0,
|
|
272
|
+
sessionStorage: t ? window.sessionStorage : void 0,
|
|
273
|
+
localStorage: t ? window.localStorage : void 0
|
|
274
|
+
};
|
|
275
|
+
return k(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
|
|
276
|
+
client: e,
|
|
277
|
+
responses: t,
|
|
278
|
+
fields: r,
|
|
279
|
+
...n
|
|
280
|
+
}));
|
|
281
|
+
});
|
|
282
|
+
function Se(e) {
|
|
283
|
+
return L(xe, e);
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/logic-engine.ts
|
|
287
|
+
function Ce(e) {
|
|
288
|
+
return typeof e == "number" && !isNaN(e);
|
|
289
|
+
}
|
|
290
|
+
function R(e) {
|
|
291
|
+
return typeof e == "string";
|
|
292
|
+
}
|
|
293
|
+
function z(e) {
|
|
294
|
+
return Array.isArray(e);
|
|
295
|
+
}
|
|
296
|
+
function B(e) {
|
|
297
|
+
return e instanceof Promise;
|
|
298
|
+
}
|
|
299
|
+
function V(e) {
|
|
300
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
301
|
+
}
|
|
302
|
+
function H(e) {
|
|
303
|
+
if (Ce(e)) return e;
|
|
304
|
+
let t = parseFloat(`${e}`);
|
|
305
|
+
return isNaN(t) ? 0 : t;
|
|
306
|
+
}
|
|
307
|
+
function U(e) {
|
|
308
|
+
return `${e}`;
|
|
309
|
+
}
|
|
310
|
+
var we = {
|
|
311
|
+
"==": (e, t) => e == t,
|
|
312
|
+
"===": (e, t) => e === t,
|
|
313
|
+
"!=": (e, t) => e != t,
|
|
314
|
+
"!==": (e, t) => e !== t,
|
|
315
|
+
">": (e, t) => H(e) > H(t),
|
|
316
|
+
">=": (e, t) => H(e) >= H(t),
|
|
317
|
+
"<": (e, t, n) => {
|
|
318
|
+
let r = H(e), i = H(t);
|
|
319
|
+
if (n === void 0) return r < i;
|
|
320
|
+
let a = H(n);
|
|
321
|
+
return r < i && i < a;
|
|
322
|
+
},
|
|
323
|
+
"<=": (e, t, n) => {
|
|
324
|
+
let r = H(e), i = H(t);
|
|
325
|
+
if (n === void 0) return r <= i;
|
|
326
|
+
let a = H(n);
|
|
327
|
+
return r <= i && i <= a;
|
|
328
|
+
},
|
|
329
|
+
"!!": async (e) => await G(e),
|
|
330
|
+
"!": async (e) => !await G(e),
|
|
331
|
+
"%": (e, t) => H(e) % H(t),
|
|
332
|
+
log: (e) => (console.log(e), e),
|
|
333
|
+
in: (e, t) => t ? R(t) ? t.indexOf(U(e)) !== -1 : z(t) ? t.includes(e) : !1 : !1,
|
|
334
|
+
cat: (...e) => e.map(U).join(""),
|
|
335
|
+
substr: (e, t, n) => {
|
|
336
|
+
let r = U(e), i = H(t);
|
|
337
|
+
if (n === void 0) return r.substr(i);
|
|
338
|
+
let a = H(n);
|
|
339
|
+
if (a < 0) {
|
|
340
|
+
let e = r.substr(i);
|
|
341
|
+
return e.substr(0, e.length + a);
|
|
342
|
+
}
|
|
343
|
+
return r.substr(i, a);
|
|
344
|
+
},
|
|
345
|
+
"+": (...e) => e.reduce((e, t) => H(e) + H(t), 0),
|
|
346
|
+
"*": (...e) => e.reduce((e, t) => H(e) * H(t), 1),
|
|
347
|
+
"-": (e, t) => {
|
|
348
|
+
let n = H(e);
|
|
349
|
+
return t === void 0 ? -n : n - H(t);
|
|
350
|
+
},
|
|
351
|
+
"/": (e, t) => H(e) / H(t),
|
|
352
|
+
min: (...e) => Math.min(...e.map(H)),
|
|
353
|
+
max: (...e) => Math.max(...e.map(H)),
|
|
354
|
+
merge: (...e) => e.reduce((e, t) => z(t) ? e.concat(t) : e.concat([t]), []),
|
|
355
|
+
var(e, t) {
|
|
356
|
+
let n = arguments.length > 1 ? t : null;
|
|
357
|
+
if (e === "" || e === "." || e == null) return this;
|
|
358
|
+
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
359
|
+
let r = U(e);
|
|
360
|
+
if (r === "" || r === ".") return this;
|
|
361
|
+
let i = r.split("."), a = this;
|
|
362
|
+
for (let e of i) {
|
|
363
|
+
if (a == null) return n;
|
|
364
|
+
if (Array.isArray(a)) {
|
|
365
|
+
let t = parseInt(e, 10);
|
|
366
|
+
a = isNaN(t) ? a[e] : a[t];
|
|
367
|
+
} else a = a[e];
|
|
368
|
+
}
|
|
369
|
+
return a === void 0 ? n : a;
|
|
370
|
+
},
|
|
371
|
+
async missing(...e) {
|
|
372
|
+
let t = z(e[0]) ? e[0] : e, n = [];
|
|
373
|
+
for (let e of t) {
|
|
374
|
+
let t = await W({ var: e }, this);
|
|
375
|
+
(t === null || t === "") && n.push(`${e}`);
|
|
376
|
+
}
|
|
377
|
+
return n;
|
|
378
|
+
},
|
|
379
|
+
async missing_some(e, t) {
|
|
380
|
+
let n = await W({ missing: t }, this);
|
|
381
|
+
if (!z(n) || !z(t)) return [];
|
|
382
|
+
let r = n.filter(R);
|
|
383
|
+
return t.filter(R).length - r.length >= H(e) ? [] : r;
|
|
384
|
+
},
|
|
385
|
+
invoke(...e) {
|
|
386
|
+
let [t, ...n] = e;
|
|
387
|
+
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
388
|
+
},
|
|
389
|
+
startsWith: (e, t) => R(e) && R(t) && e.startsWith(t),
|
|
390
|
+
endsWith: (e, t) => R(e) && R(t) && e.endsWith(t),
|
|
391
|
+
regexp_matches(e, t) {
|
|
392
|
+
let n = e, r = "";
|
|
393
|
+
if (z(e)) {
|
|
394
|
+
let [t, i] = e;
|
|
395
|
+
n = t, r = i;
|
|
396
|
+
}
|
|
397
|
+
return !R(n) || !R(r) ? !1 : new RegExp(n, r).test(U(t));
|
|
398
|
+
},
|
|
399
|
+
throw(e) {
|
|
400
|
+
throw Error(U(e));
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
async function W(e, t) {
|
|
404
|
+
if (!e) return e;
|
|
405
|
+
if (B(e)) return W(await e, t);
|
|
406
|
+
if (z(e)) return Promise.all(e.map((e) => W(e, t)));
|
|
407
|
+
if (!V(e)) return e;
|
|
408
|
+
let n = Te(e), r = n ? e[n] ?? [] : [];
|
|
409
|
+
switch (z(r) || (r = [r]), n) {
|
|
410
|
+
case "if":
|
|
411
|
+
case "?:":
|
|
412
|
+
for (let e = 0; e < r.length - 1; e += 2) if (await G(await W(r[e], t))) return W(r[e + 1], t);
|
|
413
|
+
return r.length % 2 == 1 ? W(r[r.length - 1], t) : null;
|
|
414
|
+
case "and": {
|
|
415
|
+
let e = null;
|
|
416
|
+
for (let n of r) if (e = await W(n, t), !await G(e)) return e;
|
|
417
|
+
return e;
|
|
418
|
+
}
|
|
419
|
+
case "or": {
|
|
420
|
+
let e = null;
|
|
421
|
+
for (let n of r) if (e = await W(n, t), await G(e)) return e;
|
|
422
|
+
return e;
|
|
423
|
+
}
|
|
424
|
+
case "map": {
|
|
425
|
+
let e = await W(r[0], t);
|
|
426
|
+
return z(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
|
|
427
|
+
}
|
|
428
|
+
case "filter": {
|
|
429
|
+
let e = await W(r[0], t);
|
|
430
|
+
return z(e) ? (await Promise.all(e.map(async (e) => ({
|
|
431
|
+
item: e,
|
|
432
|
+
shouldInclude: await G(await W(r[1], e))
|
|
433
|
+
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
434
|
+
}
|
|
435
|
+
case "reduce": {
|
|
436
|
+
let e = await W(r[0], t);
|
|
437
|
+
if (!z(e)) return r.length > 2 ? await W(r[2], t) : null;
|
|
438
|
+
let n = r[1], i = r.length > 2 ? await W(r[2], t) : null;
|
|
439
|
+
for (let t of e) i = await W(n, {
|
|
440
|
+
current: t,
|
|
441
|
+
accumulator: i
|
|
442
|
+
});
|
|
443
|
+
return i;
|
|
444
|
+
}
|
|
445
|
+
case "all": {
|
|
446
|
+
let e = await W(r[0], t);
|
|
447
|
+
if (!z(e) || e.length === 0) return !1;
|
|
448
|
+
for (let t of e) if (!await G(await W(r[1], t))) return !1;
|
|
449
|
+
return !0;
|
|
450
|
+
}
|
|
451
|
+
case "some": {
|
|
452
|
+
let e = await W(r[0], t);
|
|
453
|
+
if (!z(e)) return !1;
|
|
454
|
+
for (let t of e) if (await G(await W(r[1], t))) return !0;
|
|
455
|
+
return !1;
|
|
456
|
+
}
|
|
457
|
+
case "none": {
|
|
458
|
+
let e = await W(r[0], t);
|
|
459
|
+
if (!z(e)) return !0;
|
|
460
|
+
for (let t of e) if (await G(await W(r[1], t))) return !1;
|
|
461
|
+
return !0;
|
|
462
|
+
}
|
|
463
|
+
case "catch": try {
|
|
464
|
+
return await W(r[0], t);
|
|
465
|
+
} catch (e) {
|
|
466
|
+
return V(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
let i = await Promise.all(r.map((e) => W(e, t))), a = n ? we[n] : void 0;
|
|
470
|
+
if (!a) throw Error(`Unrecognized operation ${n}`);
|
|
471
|
+
return a.apply(t, i);
|
|
472
|
+
}
|
|
473
|
+
async function G(e) {
|
|
474
|
+
return B(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
475
|
+
}
|
|
476
|
+
function Te(e) {
|
|
477
|
+
return Object.keys(e)[0];
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/lifecycle/rules-logic.ts
|
|
481
|
+
var Ee = I(({ client: e }) => O({
|
|
482
|
+
source: {
|
|
483
|
+
stateSnapshot: e.stateSnapshotStore,
|
|
484
|
+
predicates: e.predicates.listStore,
|
|
485
|
+
actions: e.actions.listStore,
|
|
486
|
+
features: e.features.listStore,
|
|
487
|
+
responses: e.responses.getAllStore
|
|
488
|
+
},
|
|
489
|
+
effect: async ({ stateSnapshot: e, predicates: t, actions: n, features: r, responses: i }, { rule: a, context: o }) => {
|
|
490
|
+
let s = t.reduce((t, n) => (t[n.name] = async (...t) => await n.predicate({
|
|
491
|
+
...e,
|
|
492
|
+
args: t
|
|
493
|
+
}), t), {}), c = n.reduce((t, n) => (t[n.key] = async (...t) => await n.action({
|
|
494
|
+
...e,
|
|
495
|
+
args: t
|
|
496
|
+
}, null) ?? void 0, t), {}), l = r.reduce((e, t) => (e[t.id] = async () => {
|
|
497
|
+
let { bucket: e } = await t.getBucket();
|
|
498
|
+
return e;
|
|
499
|
+
}, e), {});
|
|
500
|
+
return await W(a, {
|
|
501
|
+
responses: i,
|
|
502
|
+
location: typeof e.location == "object" ? {
|
|
503
|
+
hash: e.location.hash,
|
|
504
|
+
host: e.location.host,
|
|
505
|
+
hostname: e.location.hostname,
|
|
506
|
+
href: e.location.href,
|
|
507
|
+
origin: e.location.origin,
|
|
508
|
+
pathname: e.location.pathname,
|
|
509
|
+
port: e.location.port,
|
|
510
|
+
protocol: e.location.protocol,
|
|
511
|
+
search: e.location.search
|
|
512
|
+
} : void 0,
|
|
513
|
+
predicates: s,
|
|
514
|
+
actions: c,
|
|
515
|
+
features: l,
|
|
516
|
+
...o
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}));
|
|
520
|
+
function De(e) {
|
|
521
|
+
return L(Ee, e);
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/ping.ts
|
|
525
|
+
var Oe = 6e3, ke = E("last_ping", "global"), Ae = async (e) => {
|
|
216
526
|
try {
|
|
217
|
-
let t = Date.now(), n =
|
|
218
|
-
if (n.isSet() && (r = n.json() ?? 0), r && t - r <
|
|
527
|
+
let t = Date.now(), n = w.get(ke), r = 0;
|
|
528
|
+
if (n.isSet() && (r = n.json() ?? 0), r && t - r < Oe) return !0;
|
|
219
529
|
let i = {
|
|
220
530
|
projectId: e.projectId,
|
|
221
531
|
path: window.location.pathname
|
|
222
532
|
}, a = {}, o = document.getElementById("picked_script")?.dataset.verceltoken;
|
|
223
533
|
o && (a["x-vercel-protection-bypass"] = o);
|
|
224
|
-
let s = (await
|
|
534
|
+
let s = (await D(e.apiUrl, "ping", i, a)).ok;
|
|
225
535
|
return s && n.set(t), s;
|
|
226
536
|
} catch {
|
|
227
537
|
return !1;
|
|
228
538
|
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
539
|
+
}, K = j("lifecycle"), je = I(({ client: e }) => {
|
|
540
|
+
let t = K.store(!1), r = P(void 0, {
|
|
541
|
+
skipVoid: !1,
|
|
542
|
+
domain: K
|
|
543
|
+
}), i = P(void 0, {
|
|
544
|
+
skipVoid: !1,
|
|
545
|
+
domain: K
|
|
546
|
+
}), a = K.store("idle"), o = K.store([]), s = P(void 0, {
|
|
547
|
+
skipVoid: !1,
|
|
548
|
+
domain: K
|
|
549
|
+
}), c = P(void 0, {
|
|
550
|
+
skipVoid: !1,
|
|
551
|
+
domain: K
|
|
552
|
+
}), l = N(), u = N(), d = N(), p = N(), m = N(), h = N();
|
|
553
|
+
o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), c.on(h, (e, t) => t), t.on(u, () => !0);
|
|
554
|
+
let g = M(() => {
|
|
555
|
+
Ae(e);
|
|
556
|
+
}), _ = M(async () => {
|
|
557
|
+
await ee();
|
|
558
|
+
}), v = M(async () => {
|
|
559
|
+
await ce(e);
|
|
560
|
+
}), y = O({ effect: v }), b = O({
|
|
561
|
+
source: o,
|
|
562
|
+
effect: async (e) => {
|
|
563
|
+
for (let t of e) await t();
|
|
564
|
+
}
|
|
565
|
+
}), x = O({
|
|
566
|
+
source: s,
|
|
567
|
+
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
568
|
+
}), S = O({
|
|
569
|
+
source: c,
|
|
570
|
+
effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
|
|
571
|
+
}), C = F({
|
|
572
|
+
clock: l,
|
|
573
|
+
filter: () => f()
|
|
574
|
+
});
|
|
575
|
+
F({
|
|
576
|
+
clock: C,
|
|
577
|
+
fn: () => "starting",
|
|
578
|
+
target: a
|
|
579
|
+
}), F({
|
|
580
|
+
clock: C,
|
|
581
|
+
target: g
|
|
582
|
+
}), F({
|
|
583
|
+
clock: C,
|
|
584
|
+
target: b
|
|
585
|
+
}), F({
|
|
586
|
+
clock: C,
|
|
587
|
+
target: _
|
|
588
|
+
}), F({
|
|
589
|
+
clock: b.done,
|
|
590
|
+
target: x
|
|
591
|
+
}), F({
|
|
592
|
+
clock: x.doneData,
|
|
593
|
+
target: r
|
|
594
|
+
}), F({
|
|
595
|
+
clock: S.doneData,
|
|
596
|
+
target: i
|
|
597
|
+
}), F({
|
|
598
|
+
clock: x.doneData,
|
|
599
|
+
filter: (e) => e,
|
|
600
|
+
target: S
|
|
601
|
+
}), F({
|
|
602
|
+
clock: S.doneData,
|
|
603
|
+
target: e.session.setIsUser
|
|
604
|
+
}), F({
|
|
605
|
+
clock: S.doneData,
|
|
606
|
+
fn: (e) => ({
|
|
607
|
+
type: "user_decide",
|
|
608
|
+
value: e
|
|
609
|
+
}),
|
|
610
|
+
target: e.eventBus
|
|
611
|
+
}), F({
|
|
612
|
+
clock: x.doneData,
|
|
613
|
+
filter: (e) => !e,
|
|
614
|
+
fn: () => void 0,
|
|
615
|
+
target: d
|
|
616
|
+
}), F({
|
|
617
|
+
clock: S.doneData,
|
|
618
|
+
fn: () => void 0,
|
|
619
|
+
target: d
|
|
620
|
+
}), F({
|
|
621
|
+
clock: d,
|
|
622
|
+
fn: () => ({ type: "initialize" }),
|
|
623
|
+
target: e.eventBus
|
|
624
|
+
});
|
|
625
|
+
let w = P(!1).on(_.done, () => !0), T = P(!1).on(d, () => !0), E = P(!1).on(y.done, () => !0), D = k(r, i, (e, t) => e === !0 && t === !0);
|
|
626
|
+
return F({
|
|
627
|
+
clock: d,
|
|
628
|
+
source: D,
|
|
629
|
+
filter: (e) => e,
|
|
630
|
+
fn: () => void 0,
|
|
631
|
+
target: v
|
|
632
|
+
}), F({
|
|
633
|
+
clock: k(w, T, D, (e, t, n) => e && t && n),
|
|
634
|
+
filter: (e) => e,
|
|
635
|
+
fn: () => void 0,
|
|
636
|
+
target: y
|
|
637
|
+
}), F({
|
|
638
|
+
clock: k(w, T, D, E, (e, t, n, r) => e && t && (!n || r)),
|
|
639
|
+
filter: (e) => e,
|
|
640
|
+
fn: () => void 0,
|
|
641
|
+
target: u
|
|
642
|
+
}), F({
|
|
643
|
+
clock: u,
|
|
644
|
+
fn: () => "ready",
|
|
645
|
+
target: a
|
|
646
|
+
}), F({
|
|
647
|
+
clock: u,
|
|
648
|
+
fn: () => ({ type: "ready" }),
|
|
649
|
+
target: e.eventBus
|
|
650
|
+
}), F({
|
|
651
|
+
clock: u,
|
|
652
|
+
source: e.session.store,
|
|
653
|
+
fn: ({ id: e, isUser: t, identifiers: n }) => ({
|
|
654
|
+
type: "session",
|
|
655
|
+
id: e,
|
|
656
|
+
isUser: t,
|
|
657
|
+
identifiers: n
|
|
658
|
+
}),
|
|
659
|
+
target: e.eventBus
|
|
660
|
+
}), F({
|
|
661
|
+
clock: [
|
|
662
|
+
b.fail,
|
|
663
|
+
x.fail,
|
|
664
|
+
S.fail,
|
|
665
|
+
v.fail,
|
|
666
|
+
y.fail,
|
|
667
|
+
_.fail
|
|
668
|
+
],
|
|
669
|
+
fn: () => "failed",
|
|
670
|
+
target: a
|
|
671
|
+
}), {
|
|
672
|
+
start: l,
|
|
673
|
+
readyStore: t,
|
|
674
|
+
preconditionPassedStore: r,
|
|
675
|
+
conditionPassedStore: i,
|
|
676
|
+
lifecycleStageStore: a,
|
|
677
|
+
registerPluginStartHook: p,
|
|
678
|
+
setPrecondition: m,
|
|
679
|
+
setCondition: h
|
|
241
680
|
};
|
|
242
|
-
|
|
681
|
+
});
|
|
682
|
+
function Me(e) {
|
|
683
|
+
return L(je, e);
|
|
243
684
|
}
|
|
244
685
|
//#endregion
|
|
245
686
|
//#region src/entities/predicate/predicate.ts
|
|
246
|
-
var
|
|
247
|
-
let t =
|
|
687
|
+
var Ne = j("predicate"), Pe = I(({ client: e }) => {
|
|
688
|
+
let t = Ne.store({}), n = A(t, { register(e, t) {
|
|
248
689
|
return {
|
|
249
690
|
...e,
|
|
250
691
|
[t.name]: {
|
|
@@ -252,85 +693,103 @@ var be = D("predicate"), xe = M(({ client: e }) => {
|
|
|
252
693
|
predicate: t.predicate
|
|
253
694
|
}
|
|
254
695
|
};
|
|
255
|
-
} });
|
|
256
|
-
|
|
257
|
-
|
|
696
|
+
} }), i = N();
|
|
697
|
+
F({
|
|
698
|
+
clock: i,
|
|
699
|
+
source: t,
|
|
700
|
+
filter: (e, { name: t }) => e[t] !== void 0,
|
|
701
|
+
fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
|
|
702
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
703
|
+
clock: i,
|
|
704
|
+
fn: ({ name: e, predicate: t }) => Object.freeze({
|
|
258
705
|
name: e,
|
|
259
|
-
predicate:
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
706
|
+
predicate: t
|
|
707
|
+
}),
|
|
708
|
+
target: n.register
|
|
709
|
+
});
|
|
710
|
+
let a = t.map((e) => Object.values(e));
|
|
711
|
+
function o(e) {
|
|
264
712
|
return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
|
|
265
713
|
}
|
|
266
|
-
function
|
|
267
|
-
let n =
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
714
|
+
function s(t) {
|
|
715
|
+
let n = P(() => void 0, { skipVoid: !1 }), r = O({
|
|
716
|
+
source: {
|
|
717
|
+
predicate: o(t),
|
|
718
|
+
snapshot: e.stateSnapshotStore
|
|
719
|
+
},
|
|
720
|
+
effect: ({ predicate: e, snapshot: t }) => {
|
|
721
|
+
if (e) return (...n) => e({
|
|
722
|
+
...t,
|
|
723
|
+
args: n
|
|
724
|
+
});
|
|
725
|
+
}
|
|
275
726
|
});
|
|
276
|
-
return
|
|
727
|
+
return F({
|
|
277
728
|
source: {
|
|
278
729
|
responses: e.responses.listStore,
|
|
279
730
|
fields: e.fields.listStore
|
|
280
731
|
},
|
|
281
732
|
target: r
|
|
282
|
-
}),
|
|
733
|
+
}), F({
|
|
283
734
|
clock: r.doneData,
|
|
284
735
|
filter: (e) => e !== void 0,
|
|
285
736
|
target: n
|
|
286
737
|
}), r(), n;
|
|
287
738
|
}
|
|
288
739
|
return {
|
|
289
|
-
register:
|
|
290
|
-
getByName:
|
|
291
|
-
listStore:
|
|
292
|
-
getEvokablePredicate:
|
|
740
|
+
register: i,
|
|
741
|
+
getByName: o,
|
|
742
|
+
listStore: a,
|
|
743
|
+
getEvokablePredicate: s
|
|
293
744
|
};
|
|
294
745
|
});
|
|
295
|
-
function
|
|
296
|
-
return
|
|
746
|
+
function Fe(e) {
|
|
747
|
+
return L(Pe, e);
|
|
297
748
|
}
|
|
298
|
-
var
|
|
299
|
-
n.register(
|
|
300
|
-
|
|
301
|
-
|
|
749
|
+
var Ie = (e, t, n) => {
|
|
750
|
+
n.register({
|
|
751
|
+
name: e,
|
|
752
|
+
predicate: t
|
|
753
|
+
});
|
|
754
|
+
}, Le = j("feature"), Re = I(({ client: e }) => {
|
|
755
|
+
let t = Le.store({}), n = Le.store([]), i = A(t, { register(e, t) {
|
|
302
756
|
return {
|
|
303
757
|
...e,
|
|
304
758
|
[t.id]: t.feature
|
|
305
759
|
};
|
|
306
|
-
} });
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
760
|
+
} }), a = N();
|
|
761
|
+
F({
|
|
762
|
+
clock: a,
|
|
763
|
+
source: t,
|
|
764
|
+
filter: (e, { id: t }) => e[t] !== void 0,
|
|
765
|
+
fn: (e, { id: t }) => `Feature '${t}' already registered. Registering again will override the previous registration.`
|
|
766
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
767
|
+
clock: a,
|
|
768
|
+
fn: ({ id: e, feature: t }) => Object.freeze({
|
|
310
769
|
id: e,
|
|
311
770
|
feature: {
|
|
312
|
-
|
|
313
|
-
|
|
771
|
+
id: e,
|
|
772
|
+
feature: {
|
|
773
|
+
...t,
|
|
774
|
+
id: e
|
|
775
|
+
}
|
|
314
776
|
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}));
|
|
320
|
-
}
|
|
321
|
-
let a = O(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
322
|
-
let r = S(`feature:${e}:${t}`, "global"), i = (n === "session" ? x : b).get(r).boolean();
|
|
777
|
+
}),
|
|
778
|
+
target: i.register
|
|
779
|
+
});
|
|
780
|
+
let o = M(async ({ id: e, key: t, storage: n = "local" }) => {
|
|
781
|
+
let r = E(`feature:${e}:${t}`, "global"), i = (n === "session" ? T : w).get(r).boolean();
|
|
323
782
|
return i === null ? null : {
|
|
324
783
|
id: e,
|
|
325
784
|
key: t,
|
|
326
785
|
bucket: i,
|
|
327
786
|
storage: n
|
|
328
787
|
};
|
|
329
|
-
}),
|
|
788
|
+
}), s = M((e) => {
|
|
330
789
|
if (!e) return null;
|
|
331
|
-
let t =
|
|
332
|
-
(e.storage === "session" ?
|
|
333
|
-
}),
|
|
790
|
+
let t = E(`feature:${e.id}:${e.key}`, "global");
|
|
791
|
+
(e.storage === "session" ? T : w).set(t, e.bucket);
|
|
792
|
+
}), c = /* @__PURE__ */ new Map(), l = O({
|
|
334
793
|
source: {
|
|
335
794
|
allFeaturesStore: t,
|
|
336
795
|
resolvedFeaturesStore: n
|
|
@@ -340,9 +799,9 @@ var Ce = (e, t, n) => {
|
|
|
340
799
|
if (a) return a;
|
|
341
800
|
let o = e[n];
|
|
342
801
|
if (!o) throw Error(`Feature with id '${n}' not found`);
|
|
343
|
-
let
|
|
344
|
-
if (
|
|
345
|
-
let e = await
|
|
802
|
+
let s = c.get(`${n}:${i}`);
|
|
803
|
+
if (s !== void 0) {
|
|
804
|
+
let e = await s;
|
|
346
805
|
return {
|
|
347
806
|
id: o.id,
|
|
348
807
|
bucket: e,
|
|
@@ -351,7 +810,7 @@ var Ce = (e, t, n) => {
|
|
|
351
810
|
};
|
|
352
811
|
}
|
|
353
812
|
let l = r();
|
|
354
|
-
|
|
813
|
+
c.set(`${n}:${i}`, l);
|
|
355
814
|
let u = await l;
|
|
356
815
|
return {
|
|
357
816
|
id: o.id,
|
|
@@ -361,8 +820,8 @@ var Ce = (e, t, n) => {
|
|
|
361
820
|
};
|
|
362
821
|
}
|
|
363
822
|
});
|
|
364
|
-
|
|
365
|
-
clock:
|
|
823
|
+
F({
|
|
824
|
+
clock: i.register,
|
|
366
825
|
fn: (e) => {
|
|
367
826
|
let { id: t, feature: n } = e;
|
|
368
827
|
return {
|
|
@@ -371,10 +830,10 @@ var Ce = (e, t, n) => {
|
|
|
371
830
|
storage: n.feature.storage
|
|
372
831
|
};
|
|
373
832
|
},
|
|
374
|
-
target:
|
|
375
|
-
}),
|
|
833
|
+
target: o
|
|
834
|
+
}), F({
|
|
376
835
|
source: t,
|
|
377
|
-
clock:
|
|
836
|
+
clock: l.doneData,
|
|
378
837
|
fn: (e, t) => {
|
|
379
838
|
let { id: n, bucket: r, storage: i } = t, a = e[n]?.feature.key;
|
|
380
839
|
return a ? {
|
|
@@ -384,9 +843,9 @@ var Ce = (e, t, n) => {
|
|
|
384
843
|
storage: i
|
|
385
844
|
} : null;
|
|
386
845
|
},
|
|
387
|
-
target:
|
|
846
|
+
target: s
|
|
388
847
|
});
|
|
389
|
-
let
|
|
848
|
+
let u = k({
|
|
390
849
|
allFeaturesStore: t,
|
|
391
850
|
resolvedFeaturesStore: n
|
|
392
851
|
}).map(({ allFeaturesStore: e, resolvedFeaturesStore: t }) => Object.values(e).map((e) => {
|
|
@@ -404,12 +863,12 @@ var Ce = (e, t, n) => {
|
|
|
404
863
|
id: e.id,
|
|
405
864
|
name: e.feature.name,
|
|
406
865
|
key: e.feature.key,
|
|
407
|
-
getBucket: async () => await
|
|
866
|
+
getBucket: async () => await l(e.feature),
|
|
408
867
|
isResolved: !1
|
|
409
868
|
};
|
|
410
869
|
}));
|
|
411
|
-
|
|
412
|
-
clock:
|
|
870
|
+
F({
|
|
871
|
+
clock: l.doneData,
|
|
413
872
|
source: { resolvedFeatures: n },
|
|
414
873
|
filter: ({ resolvedFeatures: e }, { id: t, key: n }) => !e.some((e) => e.id === t && e.key === n),
|
|
415
874
|
fn: (e, t) => t,
|
|
@@ -417,135 +876,106 @@ var Ce = (e, t, n) => {
|
|
|
417
876
|
type: "feature_decide",
|
|
418
877
|
feature: e
|
|
419
878
|
}))
|
|
420
|
-
}),
|
|
421
|
-
clock: [
|
|
879
|
+
}), F({
|
|
880
|
+
clock: [o.doneData, l.doneData],
|
|
422
881
|
source: n,
|
|
423
882
|
fn: (e, t) => !t || e.some((e) => e.id === t.id && e.key === t.key) ? e : [...e, t],
|
|
424
883
|
target: n
|
|
425
884
|
});
|
|
426
|
-
function u(e) {
|
|
427
|
-
return l.map((t) => t.find((t) => t.id === e));
|
|
428
|
-
}
|
|
429
885
|
function d(e) {
|
|
430
|
-
return
|
|
886
|
+
return u.map((t) => t.find((t) => t.id === e));
|
|
431
887
|
}
|
|
432
888
|
function f(e) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
889
|
+
return t.map((t) => t[e], { skipVoid: !1 });
|
|
890
|
+
}
|
|
891
|
+
function p(e) {
|
|
892
|
+
let t = P(async () => void 0, { skipVoid: !1 }), r = O({
|
|
893
|
+
source: d(e),
|
|
894
|
+
effect: async (e) => {
|
|
895
|
+
if (e) return async () => (await e.getBucket()).bucket;
|
|
896
|
+
}
|
|
436
897
|
});
|
|
437
|
-
return
|
|
898
|
+
return F({
|
|
438
899
|
source: n,
|
|
439
900
|
filter: (t) => t.some((t) => t.id === e),
|
|
440
901
|
target: r
|
|
441
|
-
}),
|
|
902
|
+
}), F({
|
|
442
903
|
clock: r.doneData,
|
|
443
904
|
filter: (e) => e !== void 0,
|
|
444
905
|
target: t
|
|
445
906
|
}), r(), t;
|
|
446
907
|
}
|
|
447
908
|
return {
|
|
448
|
-
register:
|
|
449
|
-
getById:
|
|
450
|
-
getByName:
|
|
451
|
-
listStore:
|
|
452
|
-
getEvokableFeature:
|
|
909
|
+
register: a,
|
|
910
|
+
getById: d,
|
|
911
|
+
getByName: f,
|
|
912
|
+
listStore: u,
|
|
913
|
+
getEvokableFeature: p
|
|
453
914
|
};
|
|
454
915
|
});
|
|
455
|
-
function
|
|
456
|
-
return
|
|
916
|
+
function ze(e) {
|
|
917
|
+
return L(Re, e);
|
|
457
918
|
}
|
|
458
|
-
var
|
|
459
|
-
n.register(
|
|
460
|
-
|
|
461
|
-
|
|
919
|
+
var Be = (e, t, n) => {
|
|
920
|
+
n.register({
|
|
921
|
+
id: e,
|
|
922
|
+
feature: t
|
|
923
|
+
});
|
|
924
|
+
}, q = j("history");
|
|
925
|
+
function J(e, t) {
|
|
462
926
|
return {
|
|
463
|
-
id:
|
|
464
|
-
node:
|
|
927
|
+
id: ne(`history-entry-${Date.now()}-${Math.random()}}`),
|
|
928
|
+
node: t,
|
|
465
929
|
at: Date.now(),
|
|
466
|
-
|
|
467
|
-
experienceId: t
|
|
930
|
+
experienceId: e
|
|
468
931
|
};
|
|
469
932
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
let r = K(t.instanceId, t.experienceId, t.node);
|
|
486
|
-
return n === -1 ? [...e, r] : e.map((e, t) => t === n ? r : e);
|
|
487
|
-
}), e.on(r, (e, { instanceId: t }) => {
|
|
488
|
-
let n = 0, r = -1;
|
|
489
|
-
for (let i = e.length - 1; i >= 0; i--) {
|
|
490
|
-
let a = e[i];
|
|
491
|
-
if (!(a?.instanceId !== t || !v(a.node)) && (n += 1, n === 2)) {
|
|
492
|
-
r = i;
|
|
933
|
+
var Ve = I(() => {
|
|
934
|
+
let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
|
|
935
|
+
e.on(t, (e, t) => ({ entries: [...e.entries, J(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), J(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
|
|
936
|
+
function a(e, t) {
|
|
937
|
+
let n = {
|
|
938
|
+
lastStepIndex: -1,
|
|
939
|
+
secondLastStepIndex: -1
|
|
940
|
+
};
|
|
941
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
942
|
+
let i = e[r], a = i?.node;
|
|
943
|
+
if (!(!a || !v(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
|
|
944
|
+
else {
|
|
945
|
+
n.secondLastStepIndex = r;
|
|
493
946
|
break;
|
|
494
947
|
}
|
|
495
948
|
}
|
|
496
|
-
return r === -1 ? e : e.filter((e, n) => e.instanceId !== t || n <= r);
|
|
497
|
-
}), e.on(i, (e, { snapshots: t }) => {
|
|
498
|
-
let n = [];
|
|
499
|
-
for (let e of Object.values(t)) n.push(...e);
|
|
500
949
|
return n;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
let t =
|
|
504
|
-
|
|
505
|
-
let e = t[n.experienceId];
|
|
506
|
-
e ? e.push(n) : t[n.experienceId] = [n];
|
|
507
|
-
}
|
|
508
|
-
return t;
|
|
509
|
-
});
|
|
510
|
-
return j({
|
|
511
|
-
clock: a,
|
|
512
|
-
source: s,
|
|
513
|
-
fn: (e, { instanceId: t, experienceId: n }) => De(e[n] ?? []).map((e) => ({
|
|
950
|
+
}
|
|
951
|
+
return e.on(r, (e, t) => {
|
|
952
|
+
let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
|
|
953
|
+
return {
|
|
514
954
|
...e,
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
at: Date.now()
|
|
518
|
-
})),
|
|
519
|
-
target: o
|
|
955
|
+
entries: r
|
|
956
|
+
};
|
|
520
957
|
}), {
|
|
521
958
|
push: t,
|
|
522
959
|
replace: n,
|
|
523
960
|
back: r,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
entriesStore: e.map((e) => e),
|
|
527
|
-
snapshotStore: s
|
|
961
|
+
restore: i,
|
|
962
|
+
entriesStore: e.map((e) => e.entries)
|
|
528
963
|
};
|
|
529
964
|
});
|
|
530
|
-
function
|
|
531
|
-
return
|
|
965
|
+
function He() {
|
|
966
|
+
return L(Ve);
|
|
532
967
|
}
|
|
533
968
|
//#endregion
|
|
534
969
|
//#region src/utils/events.ts
|
|
535
|
-
var
|
|
536
|
-
let t =
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}],
|
|
545
|
-
target: t
|
|
546
|
-
}), t;
|
|
547
|
-
}, Me = D("field"), Ne = M(() => {
|
|
548
|
-
let e = Me.store({}), t = E(e, {
|
|
970
|
+
var Ue = 0, We = (e) => {
|
|
971
|
+
let t = P([]);
|
|
972
|
+
return t.on(e, (e, t) => [...e, {
|
|
973
|
+
id: Ue++,
|
|
974
|
+
at: /* @__PURE__ */ new Date(),
|
|
975
|
+
payload: t
|
|
976
|
+
}]), t;
|
|
977
|
+
}, Ge = j("field"), Ke = I(() => {
|
|
978
|
+
let e = Ge.store({}), t = A(e, {
|
|
549
979
|
register(e, t) {
|
|
550
980
|
return {
|
|
551
981
|
...e,
|
|
@@ -563,39 +993,43 @@ var Ae = 0, je = (e) => {
|
|
|
563
993
|
function n(e) {
|
|
564
994
|
t.register({ field: e });
|
|
565
995
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
996
|
+
let r = {};
|
|
997
|
+
e.watch((e) => {
|
|
998
|
+
r = e;
|
|
999
|
+
});
|
|
1000
|
+
function i(e, n) {
|
|
1001
|
+
let i = Object.values(r).find((t) => t.key === e)?.key;
|
|
1002
|
+
i && t.updateByKey({
|
|
1003
|
+
fieldKey: i,
|
|
1004
|
+
updates: n
|
|
571
1005
|
});
|
|
572
1006
|
}
|
|
573
|
-
let
|
|
574
|
-
function
|
|
1007
|
+
let a = e.map((e) => Object.values(e));
|
|
1008
|
+
function o(t) {
|
|
575
1009
|
return e.map((e) => e[t] ?? null, { skipVoid: !1 });
|
|
576
1010
|
}
|
|
577
|
-
function
|
|
1011
|
+
function s(t) {
|
|
578
1012
|
return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
|
|
579
1013
|
}
|
|
580
|
-
function
|
|
1014
|
+
function c(t) {
|
|
581
1015
|
return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null, { skipVoid: !1 });
|
|
582
1016
|
}
|
|
583
1017
|
return {
|
|
584
1018
|
register: n,
|
|
585
|
-
update:
|
|
586
|
-
getById:
|
|
587
|
-
getByKey:
|
|
588
|
-
listStore:
|
|
589
|
-
getByName:
|
|
1019
|
+
update: i,
|
|
1020
|
+
getById: o,
|
|
1021
|
+
getByKey: s,
|
|
1022
|
+
listStore: a,
|
|
1023
|
+
getByName: c
|
|
590
1024
|
};
|
|
591
1025
|
});
|
|
592
|
-
function
|
|
593
|
-
return
|
|
1026
|
+
function qe() {
|
|
1027
|
+
return L(Ke);
|
|
594
1028
|
}
|
|
595
1029
|
//#endregion
|
|
596
1030
|
//#region src/entities/step/step.ts
|
|
597
|
-
var
|
|
598
|
-
let e =
|
|
1031
|
+
var Je = j("step"), Ye = I(() => {
|
|
1032
|
+
let e = Je.store({}), t = A(e, { register(e, t) {
|
|
599
1033
|
return {
|
|
600
1034
|
...e,
|
|
601
1035
|
[t.step.id]: t.step
|
|
@@ -619,16 +1053,16 @@ var Fe = D("step"), Ie = M(() => {
|
|
|
619
1053
|
indexStore: e
|
|
620
1054
|
};
|
|
621
1055
|
});
|
|
622
|
-
function
|
|
623
|
-
return
|
|
1056
|
+
function Xe() {
|
|
1057
|
+
return L(Ye);
|
|
624
1058
|
}
|
|
625
|
-
function
|
|
1059
|
+
function Ze(e, t) {
|
|
626
1060
|
t.register(e);
|
|
627
1061
|
}
|
|
628
1062
|
//#endregion
|
|
629
1063
|
//#region src/entities/action/action.ts
|
|
630
|
-
var
|
|
631
|
-
let t =
|
|
1064
|
+
var Qe = j("action"), $e = I(({ client: e }) => {
|
|
1065
|
+
let t = Qe.store({}), n = A(t, { register(e, t) {
|
|
632
1066
|
return {
|
|
633
1067
|
...e,
|
|
634
1068
|
[t.key]: {
|
|
@@ -636,55 +1070,68 @@ var ze = D("action"), Be = M(({ client: e }) => {
|
|
|
636
1070
|
action: t.action
|
|
637
1071
|
}
|
|
638
1072
|
};
|
|
639
|
-
} });
|
|
640
|
-
|
|
641
|
-
|
|
1073
|
+
} }), i = N();
|
|
1074
|
+
F({
|
|
1075
|
+
clock: i,
|
|
1076
|
+
source: t,
|
|
1077
|
+
filter: (e, { key: t }) => e[t] !== void 0,
|
|
1078
|
+
fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
|
|
1079
|
+
}).watch((e) => /* @__PURE__ */ r("warn", e)), F({
|
|
1080
|
+
clock: i,
|
|
1081
|
+
fn: ({ key: e, action: t }) => Object.freeze({
|
|
642
1082
|
key: e,
|
|
643
|
-
action:
|
|
644
|
-
})
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
1083
|
+
action: t
|
|
1084
|
+
}),
|
|
1085
|
+
target: n.register
|
|
1086
|
+
});
|
|
1087
|
+
let a = t.map((e) => Object.values(e));
|
|
1088
|
+
function o(e) {
|
|
648
1089
|
return t.map((t) => t[e]?.action, { skipVoid: !1 });
|
|
649
1090
|
}
|
|
650
|
-
function
|
|
651
|
-
let r =
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
1091
|
+
function s(t, n) {
|
|
1092
|
+
let r = P(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = O({
|
|
1093
|
+
source: {
|
|
1094
|
+
action: o(t),
|
|
1095
|
+
snapshot: e.stateSnapshotStore
|
|
1096
|
+
},
|
|
1097
|
+
effect: ({ action: e, snapshot: t }) => {
|
|
1098
|
+
if (e) return (...n) => e({
|
|
1099
|
+
...t,
|
|
1100
|
+
args: n
|
|
1101
|
+
}, i);
|
|
1102
|
+
}
|
|
659
1103
|
});
|
|
660
|
-
return
|
|
1104
|
+
return F({
|
|
661
1105
|
source: {
|
|
662
1106
|
responses: e.responses.listStore,
|
|
663
1107
|
fields: e.fields.listStore
|
|
664
1108
|
},
|
|
665
|
-
target:
|
|
666
|
-
}),
|
|
667
|
-
clock:
|
|
1109
|
+
target: a
|
|
1110
|
+
}), F({
|
|
1111
|
+
clock: a.doneData,
|
|
668
1112
|
filter: (e) => e !== void 0,
|
|
669
1113
|
target: r
|
|
670
|
-
}),
|
|
1114
|
+
}), a(), r;
|
|
671
1115
|
}
|
|
672
1116
|
return {
|
|
673
|
-
register:
|
|
674
|
-
getByKey:
|
|
675
|
-
listStore:
|
|
676
|
-
getEvokableAction:
|
|
1117
|
+
register: i,
|
|
1118
|
+
getByKey: o,
|
|
1119
|
+
listStore: a,
|
|
1120
|
+
getEvokableAction: s
|
|
677
1121
|
};
|
|
678
1122
|
});
|
|
679
|
-
function
|
|
680
|
-
return
|
|
1123
|
+
function et(e) {
|
|
1124
|
+
return L($e, e);
|
|
681
1125
|
}
|
|
682
|
-
var
|
|
683
|
-
n.register(
|
|
1126
|
+
var tt = (e, t, n) => {
|
|
1127
|
+
n.register({
|
|
1128
|
+
key: e,
|
|
1129
|
+
action: t
|
|
1130
|
+
});
|
|
684
1131
|
};
|
|
685
1132
|
//#endregion
|
|
686
1133
|
//#region src/entities/response/response-validation.ts
|
|
687
|
-
function
|
|
1134
|
+
function Y(e, t, n, r) {
|
|
688
1135
|
return {
|
|
689
1136
|
fieldKey: e.key,
|
|
690
1137
|
userMessage: n,
|
|
@@ -692,62 +1139,62 @@ function q(e, t, n, r) {
|
|
|
692
1139
|
value: t
|
|
693
1140
|
};
|
|
694
1141
|
}
|
|
695
|
-
function
|
|
1142
|
+
function X(e) {
|
|
696
1143
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
697
1144
|
}
|
|
698
|
-
function
|
|
1145
|
+
function nt(e) {
|
|
699
1146
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
700
1147
|
}
|
|
701
|
-
function
|
|
1148
|
+
function Z(e) {
|
|
702
1149
|
try {
|
|
703
1150
|
return JSON.stringify(e), !0;
|
|
704
1151
|
} catch {
|
|
705
1152
|
return !1;
|
|
706
1153
|
}
|
|
707
1154
|
}
|
|
708
|
-
function
|
|
1155
|
+
function rt(e, t) {
|
|
709
1156
|
return t.find((t) => t.key === e) ?? null;
|
|
710
1157
|
}
|
|
711
|
-
function
|
|
1158
|
+
function it(e, t) {
|
|
712
1159
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
713
1160
|
}
|
|
714
|
-
function
|
|
715
|
-
if (e.type !== "object" ||
|
|
1161
|
+
function at(e, t) {
|
|
1162
|
+
if (e.type !== "object" || X(t)) return null;
|
|
716
1163
|
if (e.multiple) {
|
|
717
|
-
if (!Array.isArray(t)) return
|
|
1164
|
+
if (!Array.isArray(t)) return Y(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
718
1165
|
for (let n of t) {
|
|
719
|
-
if (typeof n != "object" || !n) return
|
|
720
|
-
if (!
|
|
1166
|
+
if (typeof n != "object" || !n) return Y(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1167
|
+
if (!Z(n)) return Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
721
1168
|
}
|
|
722
1169
|
return null;
|
|
723
1170
|
}
|
|
724
|
-
return Array.isArray(t) ?
|
|
1171
|
+
return Array.isArray(t) ? Y(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? Y(e, t, "This field expects an object value", "Field expects an object value.") : Z(t) ? null : Y(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
725
1172
|
}
|
|
726
|
-
function
|
|
727
|
-
if (
|
|
1173
|
+
function ot(e, t) {
|
|
1174
|
+
if (X(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
728
1175
|
let n = Array.isArray(t) ? t : [t];
|
|
729
1176
|
if (e.type === "object") {
|
|
730
1177
|
let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
|
|
731
|
-
return n.every((e) => r.has(JSON.stringify(e))) ? null :
|
|
1178
|
+
return n.every((e) => r.has(JSON.stringify(e))) ? null : Y(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
732
1179
|
}
|
|
733
1180
|
let r = e.options.map((e) => e.value);
|
|
734
|
-
return n.every((e) => !
|
|
1181
|
+
return n.every((e) => !nt(e) || e === null ? !1 : r.includes(e)) ? null : Y(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
735
1182
|
}
|
|
736
|
-
async function
|
|
737
|
-
if (
|
|
738
|
-
let
|
|
1183
|
+
async function st(t, n, r, i) {
|
|
1184
|
+
if (n.validation && !e(n.validation) && !X(r)) {
|
|
1185
|
+
let e = i ? {
|
|
739
1186
|
$input: r,
|
|
740
1187
|
responses: i
|
|
741
|
-
} : { $input: r }, a = await
|
|
742
|
-
if (typeof a == "string") return
|
|
743
|
-
if (a === !1) return
|
|
1188
|
+
} : { $input: r }, a = await t(n.validation, e);
|
|
1189
|
+
if (typeof a == "string") return Y(n, r, a, `Field validation resulted in an error: ${a}.`);
|
|
1190
|
+
if (a === !1) return Y(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
|
|
744
1191
|
}
|
|
745
|
-
return
|
|
1192
|
+
return n.required && X(r) ? Y(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? Y(n, r, "This field expects a single response", "Field expects a single response.") : null;
|
|
746
1193
|
}
|
|
747
1194
|
//#endregion
|
|
748
1195
|
//#region src/entities/response/response.ts
|
|
749
|
-
var
|
|
750
|
-
let
|
|
1196
|
+
var ct = j("response"), lt = I(({ client: e }) => {
|
|
1197
|
+
let t = ct.store({}), r = N(), i = N(), a = A(t, {
|
|
751
1198
|
register(e, t) {
|
|
752
1199
|
return {
|
|
753
1200
|
...e,
|
|
@@ -776,17 +1223,17 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
776
1223
|
});
|
|
777
1224
|
} else a.registerBatch(e);
|
|
778
1225
|
}
|
|
779
|
-
let s = (
|
|
1226
|
+
let s = (t, r) => n(e, t, r), c = O({
|
|
780
1227
|
source: {
|
|
781
1228
|
allFields: e.fields.listStore,
|
|
782
|
-
existingResponses:
|
|
1229
|
+
existingResponses: t
|
|
783
1230
|
},
|
|
784
1231
|
effect: async ({ allFields: e, existingResponses: t }, n) => {
|
|
785
1232
|
let r = [], i = {}, a = {
|
|
786
1233
|
...t,
|
|
787
1234
|
...n
|
|
788
1235
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
789
|
-
let o =
|
|
1236
|
+
let o = rt(t, e);
|
|
790
1237
|
if (!o) {
|
|
791
1238
|
r.push({
|
|
792
1239
|
fieldKey: t,
|
|
@@ -796,17 +1243,17 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
796
1243
|
});
|
|
797
1244
|
return;
|
|
798
1245
|
}
|
|
799
|
-
let c =
|
|
1246
|
+
let c = it(o, n), l = await st(s, o, c, a);
|
|
800
1247
|
if (l) {
|
|
801
1248
|
r.push(l);
|
|
802
1249
|
return;
|
|
803
1250
|
}
|
|
804
|
-
let u =
|
|
1251
|
+
let u = at(o, c);
|
|
805
1252
|
if (u) {
|
|
806
1253
|
r.push(u);
|
|
807
1254
|
return;
|
|
808
1255
|
}
|
|
809
|
-
let d =
|
|
1256
|
+
let d = ot(o, c);
|
|
810
1257
|
if (d) {
|
|
811
1258
|
r.push(d);
|
|
812
1259
|
return;
|
|
@@ -834,8 +1281,8 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
834
1281
|
async function l(e) {
|
|
835
1282
|
return c(e);
|
|
836
1283
|
}
|
|
837
|
-
let u =
|
|
838
|
-
source:
|
|
1284
|
+
let u = O({
|
|
1285
|
+
source: t,
|
|
839
1286
|
effect: async (e, t) => {
|
|
840
1287
|
let { responsesToCommit: n, validationErrors: r } = await c(t);
|
|
841
1288
|
return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
|
|
@@ -844,14 +1291,14 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
844
1291
|
async function d(e) {
|
|
845
1292
|
return u(e);
|
|
846
1293
|
}
|
|
847
|
-
let f =
|
|
1294
|
+
let f = t.map((e) => e), p = t.map((e) => Object.entries(e).map(([e, t]) => ({
|
|
848
1295
|
fieldKey: e,
|
|
849
1296
|
value: t
|
|
850
1297
|
})));
|
|
851
1298
|
function m(e) {
|
|
852
|
-
return
|
|
1299
|
+
return k({
|
|
853
1300
|
f: e,
|
|
854
|
-
s:
|
|
1301
|
+
s: t
|
|
855
1302
|
}, ({ f: e, s: t }) => {
|
|
856
1303
|
let n = e ? t[e.key] ?? null : null;
|
|
857
1304
|
return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
|
|
@@ -866,10 +1313,10 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
866
1313
|
function _(t) {
|
|
867
1314
|
return m(e.fields.getByName(t));
|
|
868
1315
|
}
|
|
869
|
-
return
|
|
1316
|
+
return F({
|
|
870
1317
|
clock: r,
|
|
871
1318
|
target: a.clearAll
|
|
872
|
-
}),
|
|
1319
|
+
}), F({
|
|
873
1320
|
clock: i,
|
|
874
1321
|
target: a.clear
|
|
875
1322
|
}), {
|
|
@@ -885,13 +1332,13 @@ var Ye = D("response"), Xe = M(({ client: e }) => {
|
|
|
885
1332
|
getByFieldName: _
|
|
886
1333
|
};
|
|
887
1334
|
});
|
|
888
|
-
function
|
|
889
|
-
return
|
|
1335
|
+
function ut(e) {
|
|
1336
|
+
return L(lt, e);
|
|
890
1337
|
}
|
|
891
1338
|
//#endregion
|
|
892
1339
|
//#region src/entities/condition/condition.ts
|
|
893
|
-
var
|
|
894
|
-
let e =
|
|
1340
|
+
var dt = j("condition"), ft = I(() => {
|
|
1341
|
+
let e = dt.store({}), t = A(e, { register(e, t) {
|
|
895
1342
|
return {
|
|
896
1343
|
...e,
|
|
897
1344
|
[t.condition.id]: t.condition
|
|
@@ -915,12 +1362,12 @@ var Qe = D("condition"), $e = M(() => {
|
|
|
915
1362
|
indexStore: e
|
|
916
1363
|
};
|
|
917
1364
|
});
|
|
918
|
-
function
|
|
919
|
-
return
|
|
1365
|
+
function pt() {
|
|
1366
|
+
return L(ft);
|
|
920
1367
|
}
|
|
921
1368
|
//#endregion
|
|
922
1369
|
//#region src/utils/api-url.ts
|
|
923
|
-
function
|
|
1370
|
+
function mt() {
|
|
924
1371
|
if (f()) {
|
|
925
1372
|
let e = [
|
|
926
1373
|
document.currentScript,
|
|
@@ -935,7 +1382,7 @@ function tt() {
|
|
|
935
1382
|
}
|
|
936
1383
|
//#endregion
|
|
937
1384
|
//#region src/utils/search-params.ts
|
|
938
|
-
function
|
|
1385
|
+
function ht() {
|
|
939
1386
|
if (!o()) return {};
|
|
940
1387
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
941
1388
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -943,89 +1390,104 @@ function nt() {
|
|
|
943
1390
|
let n = r.replace("picked-", "");
|
|
944
1391
|
t[n] = e.getAll(r);
|
|
945
1392
|
}
|
|
946
|
-
let r =
|
|
947
|
-
if (n.size > 0)
|
|
1393
|
+
let r = E("s");
|
|
1394
|
+
if (n.size > 0) T.set(r, t);
|
|
948
1395
|
else {
|
|
949
|
-
let e =
|
|
1396
|
+
let e = T.get(r);
|
|
950
1397
|
if (e) return e.json() || {};
|
|
951
1398
|
}
|
|
952
1399
|
return t;
|
|
953
1400
|
}
|
|
954
1401
|
//#endregion
|
|
955
|
-
//#region src/
|
|
956
|
-
|
|
1402
|
+
//#region src/entities/session/session.ts
|
|
1403
|
+
var Q = E("session", "global");
|
|
1404
|
+
function gt() {
|
|
957
1405
|
return l() ? 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)}`;
|
|
958
1406
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
e
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1407
|
+
function _t() {
|
|
1408
|
+
if (!u()) return null;
|
|
1409
|
+
let e = w.get(Q);
|
|
1410
|
+
if (!e.isSet()) return null;
|
|
1411
|
+
try {
|
|
1412
|
+
return e.json();
|
|
1413
|
+
} catch {
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
var vt = I(() => {
|
|
1418
|
+
let e = _t(), t = { id: e?.id ?? gt() };
|
|
1419
|
+
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1420
|
+
let n = P(t), r = A(n, {
|
|
1421
|
+
setIsUser: (e, t) => ({
|
|
1422
|
+
...e,
|
|
1423
|
+
isUser: t
|
|
1424
|
+
}),
|
|
1425
|
+
setIdentifier: (e, { key: t, value: n }) => ({
|
|
1426
|
+
...e,
|
|
1427
|
+
identifiers: {
|
|
1428
|
+
...e.identifiers ?? {},
|
|
1429
|
+
[t]: n
|
|
1430
|
+
}
|
|
1431
|
+
}),
|
|
1432
|
+
removeIdentifier: (e, t) => {
|
|
1433
|
+
let n = e.identifiers;
|
|
1434
|
+
if (!n || !(t in n)) return e;
|
|
1435
|
+
let r = {};
|
|
1436
|
+
for (let [e, i] of Object.entries(n)) e !== t && (r[e] = i);
|
|
1437
|
+
let i = { id: e.id };
|
|
1438
|
+
return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
|
|
981
1439
|
}
|
|
1440
|
+
});
|
|
1441
|
+
return F({
|
|
1442
|
+
source: n,
|
|
1443
|
+
target: O({
|
|
1444
|
+
source: n,
|
|
1445
|
+
effect: (e) => {
|
|
1446
|
+
if (u()) try {
|
|
1447
|
+
w.get(Q).set(e);
|
|
1448
|
+
} catch {}
|
|
1449
|
+
}
|
|
1450
|
+
})
|
|
1451
|
+
}), {
|
|
1452
|
+
store: n,
|
|
1453
|
+
setIsUser: r.setIsUser,
|
|
1454
|
+
setIdentifier: r.setIdentifier,
|
|
1455
|
+
removeIdentifier: r.removeIdentifier
|
|
982
1456
|
};
|
|
983
|
-
|
|
984
|
-
|
|
1457
|
+
});
|
|
1458
|
+
function yt() {
|
|
1459
|
+
return L(vt, void 0);
|
|
1460
|
+
}
|
|
985
1461
|
//#endregion
|
|
986
1462
|
//#region src/utils/picked-config.ts
|
|
987
|
-
function
|
|
1463
|
+
function bt() {
|
|
988
1464
|
if (o()) return globalThis.window.pickedConfig;
|
|
989
1465
|
}
|
|
990
|
-
function
|
|
991
|
-
if (
|
|
992
|
-
let e = Z(), t = e?.organizationId, n = e?.projectId;
|
|
993
|
-
return t && n ? {
|
|
994
|
-
organizationId: t,
|
|
995
|
-
projectId: n
|
|
996
|
-
} : void 0;
|
|
1466
|
+
function xt() {
|
|
1467
|
+
if (o()) return bt()?.projectId;
|
|
997
1468
|
}
|
|
998
|
-
function
|
|
1469
|
+
function St() {
|
|
999
1470
|
if (!f()) return;
|
|
1000
1471
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1001
|
-
if (
|
|
1002
|
-
let t = e.dataset.organizationid || e.getAttribute("organization-id"), n = e.dataset.projectid || e.getAttribute("project-id");
|
|
1003
|
-
return t && n ? {
|
|
1004
|
-
organizationId: t,
|
|
1005
|
-
projectId: n
|
|
1006
|
-
} : void 0;
|
|
1472
|
+
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1007
1473
|
}
|
|
1008
|
-
function
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
if (r) return r;
|
|
1016
|
-
let i = st();
|
|
1017
|
-
if (i) return i;
|
|
1018
|
-
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.");
|
|
1474
|
+
function Ct(e) {
|
|
1475
|
+
if (e.projectId) return e.projectId;
|
|
1476
|
+
let t = xt();
|
|
1477
|
+
if (t) return t;
|
|
1478
|
+
let n = St();
|
|
1479
|
+
if (n) return n;
|
|
1480
|
+
throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
|
|
1019
1481
|
}
|
|
1020
1482
|
//#endregion
|
|
1021
1483
|
//#region src/utils/render-string.ts
|
|
1022
|
-
function
|
|
1484
|
+
function $(e) {
|
|
1023
1485
|
return e == null || e === "" || Number.isNaN(e);
|
|
1024
1486
|
}
|
|
1025
|
-
var
|
|
1026
|
-
default: (e, t) =>
|
|
1027
|
-
append: (e, t) => t &&
|
|
1028
|
-
prepend: (e, t) => t &&
|
|
1487
|
+
var wt = {
|
|
1488
|
+
default: (e, t) => $(e) ? String(t ?? "") : String(e),
|
|
1489
|
+
append: (e, t) => t && !$(e) ? `${e} ${t}` : e,
|
|
1490
|
+
prepend: (e, t) => t && !$(e) ? `${t} ${e}` : e,
|
|
1029
1491
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
1030
1492
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
1031
1493
|
capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
|
|
@@ -1043,24 +1505,24 @@ var lt = {
|
|
|
1043
1505
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1044
1506
|
}
|
|
1045
1507
|
};
|
|
1046
|
-
function
|
|
1508
|
+
function Tt(e) {
|
|
1047
1509
|
return typeof e == "object" && !!e;
|
|
1048
1510
|
}
|
|
1049
|
-
function
|
|
1511
|
+
function Et(e, t) {
|
|
1050
1512
|
let n = t;
|
|
1051
|
-
for (let t of e.split(".")) if (
|
|
1513
|
+
for (let t of e.split(".")) if (Tt(n) && t in n) n = n[t];
|
|
1052
1514
|
else return;
|
|
1053
1515
|
return typeof n == "function" ? n() : n;
|
|
1054
1516
|
}
|
|
1055
|
-
function
|
|
1056
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1517
|
+
function Dt(e, t) {
|
|
1518
|
+
let n = e.split("|").map((e) => e.trim()), r = Et(n.shift() ?? "", t);
|
|
1057
1519
|
for (let e of n) {
|
|
1058
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1520
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = wt[i];
|
|
1059
1521
|
o && (r = o(r, a));
|
|
1060
1522
|
}
|
|
1061
|
-
return
|
|
1523
|
+
return $(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1062
1524
|
}
|
|
1063
|
-
function
|
|
1525
|
+
function Ot(e, t) {
|
|
1064
1526
|
let n = "", r = 0;
|
|
1065
1527
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1066
1528
|
r += 2;
|
|
@@ -1072,93 +1534,77 @@ function pt(e, t) {
|
|
|
1072
1534
|
}
|
|
1073
1535
|
i += e[r++];
|
|
1074
1536
|
}
|
|
1075
|
-
n +=
|
|
1537
|
+
n += Dt(i.trim(), t);
|
|
1076
1538
|
} else n += e[r++];
|
|
1077
1539
|
return n;
|
|
1078
1540
|
}
|
|
1079
1541
|
//#endregion
|
|
1080
1542
|
//#region src/picked.ts
|
|
1081
|
-
var
|
|
1543
|
+
var kt = class {
|
|
1082
1544
|
static logger = r;
|
|
1083
1545
|
options;
|
|
1084
|
-
isReady = !1;
|
|
1085
1546
|
plugins = {};
|
|
1086
|
-
|
|
1087
|
-
eventBus = k();
|
|
1547
|
+
eventBus = N();
|
|
1088
1548
|
events;
|
|
1089
|
-
organizationId;
|
|
1090
1549
|
projectId;
|
|
1091
1550
|
apiUrl;
|
|
1092
1551
|
dashboardUrl;
|
|
1093
1552
|
documentationSiteUrl;
|
|
1094
|
-
session;
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1553
|
+
session = yt();
|
|
1554
|
+
searchParams = ht();
|
|
1555
|
+
history = He();
|
|
1556
|
+
components = he({ client: this });
|
|
1557
|
+
experienceInstances = b({ client: this });
|
|
1558
|
+
experiences = se({ client: this });
|
|
1559
|
+
frameworks = ye({ client: this });
|
|
1560
|
+
predicates = Fe({ client: this });
|
|
1561
|
+
features = ze({ client: this });
|
|
1562
|
+
conditions = pt();
|
|
1563
|
+
fields = qe();
|
|
1564
|
+
responses = ut({ client: this });
|
|
1565
|
+
steps = Xe();
|
|
1566
|
+
actions = et({ client: this });
|
|
1567
|
+
stateSnapshotStore = Se({ client: this });
|
|
1568
|
+
evaluateRuleLogicFx = De({ client: this });
|
|
1569
|
+
start;
|
|
1570
|
+
readyStore;
|
|
1571
|
+
preconditionPassedStore;
|
|
1572
|
+
conditionPassedStore;
|
|
1573
|
+
lifecycleStageStore;
|
|
1574
|
+
lifecycle = Me({ client: this });
|
|
1575
|
+
renderStringFx = O({
|
|
1576
|
+
source: this.responses.listStore,
|
|
1577
|
+
effect: (e, { template: t, context: n }) => {
|
|
1578
|
+
let r = {};
|
|
1579
|
+
for (let t of e) r[t.fieldKey] = t.value;
|
|
1580
|
+
return Ot(t, {
|
|
1581
|
+
...n,
|
|
1582
|
+
responses: r
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1111
1586
|
constructor(e) {
|
|
1112
|
-
this.events =
|
|
1113
|
-
let { organizationId: t, projectId: n } = ct(e);
|
|
1114
|
-
this.organizationId = t, this.projectId = n, 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 = at(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.precondition = e.precondition, this.condition = e.condition, this.eventBus({
|
|
1587
|
+
this.events = We(this.eventBus), this.projectId = Ct(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || mt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
|
|
1115
1588
|
type: "load",
|
|
1116
|
-
version:
|
|
1589
|
+
version: te()
|
|
1117
1590
|
});
|
|
1118
1591
|
}
|
|
1119
|
-
start = () => {
|
|
1120
|
-
ye(this), (async () => {
|
|
1121
|
-
if (!f()) return;
|
|
1122
|
-
await this.runPluginStartHooks();
|
|
1123
|
-
let e = await this.evaluateGate(this.precondition);
|
|
1124
|
-
this.preconditionPassed = e;
|
|
1125
|
-
let t;
|
|
1126
|
-
e && (t = await this.evaluateGate(this.condition));
|
|
1127
|
-
let n = e && t === !0;
|
|
1128
|
-
if (typeof t == "boolean" && this.session) {
|
|
1129
|
-
let e = t;
|
|
1130
|
-
this.session.setIsUser(e), this.eventBus({
|
|
1131
|
-
type: "user_decide",
|
|
1132
|
-
value: e
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
if (this.eventBus({ type: "initialize" }), n && I(this), await ne(), n && I(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session) {
|
|
1136
|
-
let { id: e, isUser: t, identifiers: n } = this.session;
|
|
1137
|
-
this.eventBus({
|
|
1138
|
-
type: "session",
|
|
1139
|
-
id: e,
|
|
1140
|
-
isUser: t,
|
|
1141
|
-
identifiers: n
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
})();
|
|
1145
|
-
};
|
|
1146
1592
|
registerFramework = (e) => {
|
|
1147
|
-
|
|
1593
|
+
be(e, this.frameworks);
|
|
1148
1594
|
};
|
|
1149
1595
|
registerComponent = (e, t) => {
|
|
1150
|
-
|
|
1596
|
+
ge(e, t, this.components);
|
|
1151
1597
|
};
|
|
1152
1598
|
registerPlugin = (e) => {
|
|
1153
|
-
|
|
1599
|
+
ue(this, e, this.plugins);
|
|
1154
1600
|
let t = this.plugins[e.name];
|
|
1155
|
-
t?.onStart && this.
|
|
1601
|
+
t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
|
|
1156
1602
|
};
|
|
1157
1603
|
registerFeature = (e, t) => {
|
|
1158
|
-
|
|
1604
|
+
Be(e, t, this.features);
|
|
1159
1605
|
};
|
|
1160
1606
|
registerPredicate = (e, t) => {
|
|
1161
|
-
|
|
1607
|
+
Ie(e, t, this.predicates);
|
|
1162
1608
|
};
|
|
1163
1609
|
registerCondition = (e) => {
|
|
1164
1610
|
this.conditions.register(e);
|
|
@@ -1167,15 +1613,14 @@ var $ = class {
|
|
|
1167
1613
|
this.fields.register(e);
|
|
1168
1614
|
};
|
|
1169
1615
|
registerStep = (e) => {
|
|
1170
|
-
|
|
1616
|
+
Ze(e, this.steps);
|
|
1171
1617
|
};
|
|
1172
1618
|
registerAction = (e, t) => {
|
|
1173
|
-
|
|
1619
|
+
tt(e, t, this.actions);
|
|
1174
1620
|
};
|
|
1175
1621
|
registerExperience = (e) => {
|
|
1176
|
-
e.component &&
|
|
1622
|
+
e.component && ge(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
1177
1623
|
};
|
|
1178
|
-
getStateSnapshot = () => U(this);
|
|
1179
1624
|
launchExperienceById = async (e, t) => {
|
|
1180
1625
|
this.experiences.launch({
|
|
1181
1626
|
id: e,
|
|
@@ -1194,12 +1639,6 @@ var $ = class {
|
|
|
1194
1639
|
openExperienceByKey = async (e) => {
|
|
1195
1640
|
this.experiences.open({ key: e });
|
|
1196
1641
|
};
|
|
1197
|
-
async runPluginStartHooks() {
|
|
1198
|
-
for (let e of this.pluginStartHooks) await e();
|
|
1199
|
-
}
|
|
1200
|
-
async evaluateGate(e) {
|
|
1201
|
-
return e === void 0 ? !0 : typeof e == "boolean" ? e : await t(this, e) === !0;
|
|
1202
|
-
}
|
|
1203
1642
|
setupPlugins() {
|
|
1204
1643
|
this.options.plugins?.forEach((e) => {
|
|
1205
1644
|
if (Array.isArray(e)) {
|
|
@@ -1262,30 +1701,23 @@ var $ = class {
|
|
|
1262
1701
|
});
|
|
1263
1702
|
}
|
|
1264
1703
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1265
|
-
renderString = (e, t) => {
|
|
1266
|
-
let n = this.responses.listStore.getState().reduce((e, t) => (e[t.fieldKey] = t.value, e), {});
|
|
1267
|
-
return pt(e, {
|
|
1268
|
-
...t,
|
|
1269
|
-
responses: n
|
|
1270
|
-
});
|
|
1271
|
-
};
|
|
1272
1704
|
};
|
|
1273
1705
|
//#endregion
|
|
1274
1706
|
//#region src/entities/component/lazyComponent.ts
|
|
1275
|
-
function
|
|
1707
|
+
function At(e) {
|
|
1276
1708
|
return {
|
|
1277
1709
|
$$type: "lazy-component",
|
|
1278
1710
|
load: e
|
|
1279
1711
|
};
|
|
1280
1712
|
}
|
|
1281
|
-
function
|
|
1713
|
+
function jt(e) {
|
|
1282
1714
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1283
1715
|
}
|
|
1284
1716
|
//#endregion
|
|
1285
1717
|
//#region src/exports.ts
|
|
1286
|
-
var
|
|
1287
|
-
let t = new
|
|
1718
|
+
var Mt = (e) => {
|
|
1719
|
+
let t = new kt(e);
|
|
1288
1720
|
return d(t), t;
|
|
1289
1721
|
};
|
|
1290
1722
|
//#endregion
|
|
1291
|
-
export {
|
|
1723
|
+
export { kt as Picked, Mt as createClient, le as createPluginEffect, E as createStorageKey, n as evaluateRuleLogic, bt as getPickedConfig, jt as isLazyLoader, _ as isPickedRoot, At as lazyComponent, w as localStore, T as sessionStore, C as subscribe, m as supportsCookies, l as supportsCryptoRandomUUID, f as supportsDocument, s as supportsHistory, i as supportsIntersectionObserver, u as supportsLocalStorage, p as supportsLocation, a as supportsSessionStorage, c as supportsShadowRoot, h as supportsWebComponents, o as supportsWindow };
|