@picked/client 0.0.35-next.1 → 0.0.36-next.1
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 +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +538 -547
- package/dist/esm/plugins/create-experience/index.js +251 -255
- package/dist/esm/plugins/responses-browser-storage/index.js +23 -25
- package/dist/esm/plugins/responses-indexeddb/index.js +49 -67
- package/dist/esm/plugins/single-page-app/index.js +1 -1
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +15 -15
- package/dist/experience-instance-CsMhH0DN.cjs +1 -0
- package/dist/{experience-instance-BstMURAM.js → experience-instance-CwXYJkRx.js} +107 -111
- package/dist/{supports-BjhuLJ8z.js → supports-COb-sl36.js} +1 -1
- package/package.json +5 -5
- package/dist/experience-instance-CqwH_Ayg.cjs +0 -1
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { g as
|
|
1
|
+
import { g as f } from "../../../id-BW-g3y32.js";
|
|
2
2
|
const r = {
|
|
3
|
-
serialize(
|
|
4
|
-
return JSON.stringify(
|
|
3
|
+
serialize(e) {
|
|
4
|
+
return JSON.stringify(e);
|
|
5
5
|
},
|
|
6
|
-
deserialize(
|
|
7
|
-
return JSON.parse(
|
|
6
|
+
deserialize(e) {
|
|
7
|
+
return JSON.parse(e);
|
|
8
8
|
}
|
|
9
|
-
}, v = (
|
|
9
|
+
}, v = (e) => ({
|
|
10
10
|
name: "create-experience",
|
|
11
11
|
setup: (o) => {
|
|
12
|
-
|
|
13
|
-
const s =
|
|
14
|
-
|
|
15
|
-
o.registerField(
|
|
12
|
+
e.experiences.forEach((n) => {
|
|
13
|
+
const s = n.serialize(), d = r.deserialize(s);
|
|
14
|
+
d.component = n.component, o.registerExperience(d), d.fields.forEach((N) => {
|
|
15
|
+
o.registerField(N);
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
}), g = (
|
|
20
|
-
id:
|
|
19
|
+
}), g = (e, o) => ({
|
|
20
|
+
id: f("node"),
|
|
21
21
|
position: [0, 0],
|
|
22
22
|
experience: o,
|
|
23
23
|
type: "action",
|
|
24
|
-
action:
|
|
24
|
+
action: e.action,
|
|
25
25
|
addNext(s) {
|
|
26
26
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
27
|
-
const
|
|
27
|
+
const d = h(
|
|
28
28
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: null },
|
|
29
29
|
o
|
|
30
30
|
);
|
|
31
|
-
o.edges.push(
|
|
31
|
+
o.edges.push(d);
|
|
32
32
|
},
|
|
33
33
|
onSuccess(s) {
|
|
34
34
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
35
|
-
const
|
|
35
|
+
const d = h(
|
|
36
36
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: "true" },
|
|
37
37
|
o
|
|
38
38
|
);
|
|
39
|
-
o.edges.push(
|
|
39
|
+
o.edges.push(d);
|
|
40
40
|
},
|
|
41
41
|
onFail(s) {
|
|
42
42
|
if (!s.node) throw new Error("Cannot connect to node");
|
|
43
|
-
const
|
|
43
|
+
const d = h(
|
|
44
44
|
{ sourceNode: this, destinationNode: s.node, sourceNodeHandle: "false" },
|
|
45
45
|
o
|
|
46
46
|
);
|
|
47
|
-
o.edges.push(
|
|
47
|
+
o.edges.push(d);
|
|
48
48
|
},
|
|
49
49
|
serialize() {
|
|
50
50
|
return r.serialize({
|
|
@@ -54,21 +54,20 @@ const r = {
|
|
|
54
54
|
position: this.position
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
}), E = (
|
|
58
|
-
id:
|
|
59
|
-
label:
|
|
60
|
-
fields:
|
|
57
|
+
}), E = (e) => ({
|
|
58
|
+
id: e.id ?? f("step"),
|
|
59
|
+
label: e.label,
|
|
60
|
+
fields: e.fields ?? [],
|
|
61
61
|
addField(o) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return (s = this.fields) != null && s.includes(d) || (n = this.fields) == null || n.push(d), d;
|
|
62
|
+
const n = "serialize" in o ? o : m(o);
|
|
63
|
+
return this.fields?.includes(n) || this.fields?.push(n), n;
|
|
65
64
|
}
|
|
66
|
-
}), y = (
|
|
67
|
-
const
|
|
68
|
-
id:
|
|
69
|
-
label:
|
|
65
|
+
}), y = (e, o) => {
|
|
66
|
+
const n = {
|
|
67
|
+
id: e.id ?? f("step"),
|
|
68
|
+
label: e.label,
|
|
70
69
|
experience: o,
|
|
71
|
-
fields:
|
|
70
|
+
fields: e.fields ?? [],
|
|
72
71
|
node: null,
|
|
73
72
|
nextStep(s) {
|
|
74
73
|
return this.experience.addStep(s, this);
|
|
@@ -90,18 +89,18 @@ const r = {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
|
-
return
|
|
94
|
-
}, z = () => [0, 0],
|
|
95
|
-
const
|
|
96
|
-
id:
|
|
92
|
+
return p({ step: n, type: "step" }, o), n;
|
|
93
|
+
}, z = () => [0, 0], p = (e, o) => {
|
|
94
|
+
const n = {
|
|
95
|
+
id: f("node"),
|
|
97
96
|
position: z(),
|
|
98
97
|
experience: o
|
|
99
98
|
};
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
...
|
|
99
|
+
if (e.type === "step") {
|
|
100
|
+
const d = {
|
|
101
|
+
...n,
|
|
103
102
|
type: "step",
|
|
104
|
-
connectedStep:
|
|
103
|
+
connectedStep: e.step,
|
|
105
104
|
serialize() {
|
|
106
105
|
return r.serialize({
|
|
107
106
|
id: this.id,
|
|
@@ -112,13 +111,13 @@ const r = {
|
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
113
|
};
|
|
115
|
-
return
|
|
114
|
+
return d.connectedStep.node = d, d;
|
|
116
115
|
}
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
...
|
|
116
|
+
if (e.type === "conditional") {
|
|
117
|
+
const d = {
|
|
118
|
+
...n,
|
|
120
119
|
type: "conditional",
|
|
121
|
-
connectedConditional:
|
|
120
|
+
connectedConditional: e.conditional,
|
|
122
121
|
serialize() {
|
|
123
122
|
return r.serialize({
|
|
124
123
|
id: this.id,
|
|
@@ -128,12 +127,12 @@ const r = {
|
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
129
|
};
|
|
131
|
-
return
|
|
130
|
+
return d.connectedConditional.node = d, d;
|
|
132
131
|
}
|
|
133
|
-
return
|
|
134
|
-
...
|
|
132
|
+
return e.type === "experience" ? {
|
|
133
|
+
...n,
|
|
135
134
|
type: "experience",
|
|
136
|
-
connectedExperience:
|
|
135
|
+
connectedExperience: e.experience,
|
|
137
136
|
serialize() {
|
|
138
137
|
return r.serialize({
|
|
139
138
|
id: this.id,
|
|
@@ -143,7 +142,7 @@ const r = {
|
|
|
143
142
|
});
|
|
144
143
|
}
|
|
145
144
|
} : {
|
|
146
|
-
...
|
|
145
|
+
...n,
|
|
147
146
|
type: "origin",
|
|
148
147
|
serialize() {
|
|
149
148
|
return r.serialize({
|
|
@@ -153,11 +152,11 @@ const r = {
|
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
};
|
|
156
|
-
},
|
|
157
|
-
id:
|
|
158
|
-
sourceNode:
|
|
159
|
-
sourceNodeHandle:
|
|
160
|
-
destinationNode:
|
|
155
|
+
}, h = (e, o) => ({
|
|
156
|
+
id: f("edge"),
|
|
157
|
+
sourceNode: e.sourceNode,
|
|
158
|
+
sourceNodeHandle: e.sourceNodeHandle,
|
|
159
|
+
destinationNode: e.destinationNode,
|
|
161
160
|
experience: o,
|
|
162
161
|
serialize() {
|
|
163
162
|
return r.serialize({
|
|
@@ -167,29 +166,29 @@ const r = {
|
|
|
167
166
|
destinationNodeId: this.destinationNode.id
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
|
-
}), b = (
|
|
171
|
-
const
|
|
172
|
-
id:
|
|
173
|
-
condition:
|
|
169
|
+
}), b = (e, o) => {
|
|
170
|
+
const n = {
|
|
171
|
+
id: f("conditional"),
|
|
172
|
+
condition: e.condition,
|
|
174
173
|
node: null,
|
|
175
174
|
experience: o,
|
|
176
175
|
addTrue(s) {
|
|
177
176
|
if (!this.node || !s.node)
|
|
178
177
|
throw new Error("todo no node");
|
|
179
|
-
const
|
|
178
|
+
const d = h(
|
|
180
179
|
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
|
|
181
180
|
this.experience
|
|
182
181
|
);
|
|
183
|
-
this.experience.edges.push(
|
|
182
|
+
this.experience.edges.push(d);
|
|
184
183
|
},
|
|
185
184
|
addFalse(s) {
|
|
186
185
|
if (!this.node || !s.node)
|
|
187
186
|
throw new Error("todo no node");
|
|
188
|
-
const
|
|
187
|
+
const d = h(
|
|
189
188
|
{ sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
|
|
190
189
|
this.experience
|
|
191
190
|
);
|
|
192
|
-
this.experience.edges.push(
|
|
191
|
+
this.experience.edges.push(d);
|
|
193
192
|
},
|
|
194
193
|
serialize() {
|
|
195
194
|
return r.serialize({
|
|
@@ -198,244 +197,241 @@ const r = {
|
|
|
198
197
|
});
|
|
199
198
|
}
|
|
200
199
|
};
|
|
201
|
-
return
|
|
202
|
-
}, m = (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
typeof t == "string" && e.push(t);
|
|
242
|
-
e.length === 0 && (e = void 0);
|
|
243
|
-
}
|
|
244
|
-
return r.serialize({
|
|
245
|
-
...s,
|
|
246
|
-
type: "text",
|
|
247
|
-
multiple: !0,
|
|
248
|
-
defaultValue: e,
|
|
249
|
-
options: this.options ? this.options.map((t) => ({
|
|
250
|
-
id: t.id,
|
|
251
|
-
label: t.label,
|
|
252
|
-
value: `${t.value}`,
|
|
253
|
-
condition: t.condition
|
|
254
|
-
})) : null
|
|
255
|
-
});
|
|
200
|
+
return p({ conditional: n, type: "conditional" }, o), n;
|
|
201
|
+
}, m = (e) => ({
|
|
202
|
+
id: e.id,
|
|
203
|
+
name: e.name,
|
|
204
|
+
type: e.type,
|
|
205
|
+
label: e.label,
|
|
206
|
+
placeholder: e.placeholder,
|
|
207
|
+
description: e.description,
|
|
208
|
+
helpText: e.helpText,
|
|
209
|
+
defaultValue: e.defaultValue ?? null,
|
|
210
|
+
multiple: e.multiple,
|
|
211
|
+
validation: e.validation ?? {},
|
|
212
|
+
condition: e.condition,
|
|
213
|
+
required: e.required,
|
|
214
|
+
options: e.options?.map((n) => ({
|
|
215
|
+
...n
|
|
216
|
+
})) ?? null,
|
|
217
|
+
policies: e.policies,
|
|
218
|
+
serialize() {
|
|
219
|
+
const n = {
|
|
220
|
+
id: this.id,
|
|
221
|
+
name: this.name,
|
|
222
|
+
label: this.label,
|
|
223
|
+
placeholder: this.placeholder,
|
|
224
|
+
required: this.required,
|
|
225
|
+
description: this.description,
|
|
226
|
+
helpText: this.helpText,
|
|
227
|
+
validation: this.validation,
|
|
228
|
+
condition: this.condition,
|
|
229
|
+
policies: this.policies
|
|
230
|
+
}, s = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
|
|
231
|
+
switch (this.type) {
|
|
232
|
+
case "text":
|
|
233
|
+
if (this.multiple) {
|
|
234
|
+
let t;
|
|
235
|
+
if (Array.isArray(this.defaultValue)) {
|
|
236
|
+
t = [];
|
|
237
|
+
for (const i of this.defaultValue)
|
|
238
|
+
typeof i == "string" && t.push(i);
|
|
239
|
+
t.length === 0 && (t = void 0);
|
|
256
240
|
}
|
|
257
241
|
return r.serialize({
|
|
258
|
-
...
|
|
242
|
+
...n,
|
|
259
243
|
type: "text",
|
|
260
|
-
multiple: !
|
|
261
|
-
defaultValue:
|
|
262
|
-
options: this.options ? this.options.map((
|
|
263
|
-
id:
|
|
264
|
-
label:
|
|
265
|
-
value: `${
|
|
266
|
-
condition:
|
|
244
|
+
multiple: !0,
|
|
245
|
+
defaultValue: t,
|
|
246
|
+
options: this.options ? this.options.map((i) => ({
|
|
247
|
+
id: i.id,
|
|
248
|
+
label: i.label,
|
|
249
|
+
value: `${i.value}`,
|
|
250
|
+
condition: i.condition
|
|
267
251
|
})) : null
|
|
268
252
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
253
|
+
}
|
|
254
|
+
return r.serialize({
|
|
255
|
+
...n,
|
|
256
|
+
type: "text",
|
|
257
|
+
multiple: !1,
|
|
258
|
+
defaultValue: s,
|
|
259
|
+
options: this.options ? this.options.map((t) => ({
|
|
260
|
+
id: t.id,
|
|
261
|
+
label: t.label,
|
|
262
|
+
value: `${t.value}`,
|
|
263
|
+
condition: t.condition
|
|
264
|
+
})) : null
|
|
265
|
+
});
|
|
266
|
+
case "number":
|
|
267
|
+
if (this.multiple) {
|
|
268
|
+
let t;
|
|
269
|
+
if (Array.isArray(this.defaultValue)) {
|
|
270
|
+
t = [];
|
|
271
|
+
for (const i of this.defaultValue)
|
|
272
|
+
typeof i == "number" && t.push(i);
|
|
273
|
+
t.length === 0 && (t = void 0);
|
|
290
274
|
}
|
|
291
275
|
return r.serialize({
|
|
292
|
-
...
|
|
276
|
+
...n,
|
|
293
277
|
type: "number",
|
|
294
|
-
multiple: !
|
|
295
|
-
defaultValue:
|
|
296
|
-
options: this.options ? this.options.map((
|
|
297
|
-
id:
|
|
298
|
-
label:
|
|
299
|
-
value: Number(
|
|
300
|
-
condition:
|
|
278
|
+
multiple: !0,
|
|
279
|
+
defaultValue: t,
|
|
280
|
+
options: this.options ? this.options.map((i) => ({
|
|
281
|
+
id: i.id,
|
|
282
|
+
label: i.label,
|
|
283
|
+
value: Number(i.value),
|
|
284
|
+
condition: i.condition
|
|
301
285
|
})) : null
|
|
302
286
|
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
287
|
+
}
|
|
288
|
+
return r.serialize({
|
|
289
|
+
...n,
|
|
290
|
+
type: "number",
|
|
291
|
+
multiple: !1,
|
|
292
|
+
defaultValue: d,
|
|
293
|
+
options: this.options ? this.options.map((t) => ({
|
|
294
|
+
id: t.id,
|
|
295
|
+
label: t.label,
|
|
296
|
+
value: Number(t.value),
|
|
297
|
+
condition: t.condition
|
|
298
|
+
})) : null
|
|
299
|
+
});
|
|
300
|
+
case "boolean":
|
|
301
|
+
if (this.multiple) {
|
|
302
|
+
let t;
|
|
303
|
+
if (Array.isArray(this.defaultValue)) {
|
|
304
|
+
t = [];
|
|
305
|
+
for (const i of this.defaultValue)
|
|
306
|
+
typeof i == "boolean" && t.push(i);
|
|
307
|
+
t.length === 0 && (t = void 0);
|
|
324
308
|
}
|
|
325
309
|
return r.serialize({
|
|
326
|
-
...
|
|
310
|
+
...n,
|
|
327
311
|
type: "boolean",
|
|
328
|
-
multiple: !
|
|
329
|
-
defaultValue:
|
|
330
|
-
options: this.options ? this.options.map((
|
|
331
|
-
id:
|
|
332
|
-
label:
|
|
333
|
-
value: !!
|
|
334
|
-
condition:
|
|
312
|
+
multiple: !0,
|
|
313
|
+
defaultValue: t,
|
|
314
|
+
options: this.options ? this.options.map((i) => ({
|
|
315
|
+
id: i.id,
|
|
316
|
+
label: i.label,
|
|
317
|
+
value: !!i.value,
|
|
318
|
+
condition: i.condition
|
|
335
319
|
})) : null
|
|
336
320
|
});
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
321
|
+
}
|
|
322
|
+
return r.serialize({
|
|
323
|
+
...n,
|
|
324
|
+
type: "boolean",
|
|
325
|
+
multiple: !1,
|
|
326
|
+
defaultValue: N,
|
|
327
|
+
options: this.options ? this.options.map((t) => ({
|
|
328
|
+
id: t.id,
|
|
329
|
+
label: t.label,
|
|
330
|
+
value: !!t.value,
|
|
331
|
+
condition: t.condition
|
|
332
|
+
})) : null
|
|
333
|
+
});
|
|
334
|
+
// todo: support for object type fields
|
|
335
|
+
// case 'object':
|
|
336
|
+
// if (this.multiple) {
|
|
337
|
+
// return serialization.serialize({
|
|
338
|
+
// ...baseField,
|
|
339
|
+
// type: 'object',
|
|
340
|
+
// multiple: true,
|
|
341
|
+
// defaultValue: this.defaultValue,
|
|
342
|
+
// options: this.options,
|
|
343
|
+
// })
|
|
344
|
+
// }
|
|
345
|
+
// return serialization.serialize({
|
|
346
|
+
// ...baseField,
|
|
347
|
+
// type: 'object',
|
|
348
|
+
// multiple: false,
|
|
349
|
+
// defaultValue: this.defaultValue,
|
|
350
|
+
// options: this.options,
|
|
351
|
+
// })
|
|
352
|
+
default:
|
|
353
|
+
throw new Error("Unsupported field type");
|
|
358
354
|
}
|
|
359
|
-
}
|
|
360
|
-
}, V = (
|
|
361
|
-
const o = [],
|
|
355
|
+
}
|
|
356
|
+
}), V = (e) => {
|
|
357
|
+
const o = [], n = [], s = [], d = [], N = [], t = e.condition ?? e.decide;
|
|
362
358
|
return {
|
|
363
|
-
id:
|
|
364
|
-
component:
|
|
365
|
-
name:
|
|
366
|
-
initializeOpen:
|
|
367
|
-
condition:
|
|
368
|
-
decide:
|
|
369
|
-
targets:
|
|
359
|
+
id: e.id,
|
|
360
|
+
component: e.component,
|
|
361
|
+
name: e.name,
|
|
362
|
+
initializeOpen: e.initializeOpen,
|
|
363
|
+
condition: t,
|
|
364
|
+
decide: e.decide,
|
|
365
|
+
targets: e.targets,
|
|
370
366
|
steps: o,
|
|
371
|
-
nodes:
|
|
367
|
+
nodes: n,
|
|
372
368
|
edges: s,
|
|
373
|
-
fields:
|
|
374
|
-
conditionals:
|
|
375
|
-
addStep(
|
|
376
|
-
let l =
|
|
377
|
-
this.nodes.length === 0 && (l =
|
|
378
|
-
const a = "serialize" in
|
|
369
|
+
fields: N,
|
|
370
|
+
conditionals: d,
|
|
371
|
+
addStep(i, u) {
|
|
372
|
+
let l = u?.node;
|
|
373
|
+
this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
|
|
374
|
+
const a = "serialize" in i ? i : y(i, this);
|
|
379
375
|
if (l) {
|
|
380
376
|
if (!a.node)
|
|
381
377
|
throw new Error("todo no node");
|
|
382
|
-
const
|
|
378
|
+
const c = h(
|
|
383
379
|
{ sourceNode: l, destinationNode: a.node, sourceNodeHandle: null },
|
|
384
380
|
this
|
|
385
381
|
);
|
|
386
|
-
this.edges.push(
|
|
382
|
+
this.edges.push(c);
|
|
387
383
|
}
|
|
388
|
-
return a.fields.length > 0 && a.fields.forEach((
|
|
389
|
-
this.fields.includes(
|
|
384
|
+
return a.fields.length > 0 && a.fields.forEach((c) => {
|
|
385
|
+
this.fields.includes(c) || this.fields.push(c);
|
|
390
386
|
}), this.steps.includes(a) || (this.steps.push(a), a.node && this.nodes.push(a.node)), a;
|
|
391
387
|
},
|
|
392
|
-
addAction(
|
|
393
|
-
let l =
|
|
394
|
-
this.nodes.length === 0 && (l =
|
|
395
|
-
const a = "serialize" in
|
|
388
|
+
addAction(i, u) {
|
|
389
|
+
let l = u?.node;
|
|
390
|
+
this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
|
|
391
|
+
const a = "serialize" in i ? i : g(i, this);
|
|
396
392
|
if (l) {
|
|
397
|
-
const
|
|
393
|
+
const c = h(
|
|
398
394
|
{ sourceNode: l, destinationNode: a, sourceNodeHandle: null },
|
|
399
395
|
this
|
|
400
396
|
);
|
|
401
|
-
this.edges.push(
|
|
397
|
+
this.edges.push(c);
|
|
402
398
|
}
|
|
403
399
|
return this.nodes.push(a), a;
|
|
404
400
|
},
|
|
405
|
-
addConditional(
|
|
406
|
-
let l =
|
|
407
|
-
this.nodes.length === 0 && (l =
|
|
408
|
-
const a = "serialize" in
|
|
401
|
+
addConditional(i, u) {
|
|
402
|
+
let l = u?.node;
|
|
403
|
+
this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
|
|
404
|
+
const a = "serialize" in i ? i : b(i, this);
|
|
409
405
|
if (l) {
|
|
410
406
|
if (!a.node)
|
|
411
407
|
throw new Error("todo no node");
|
|
412
|
-
const
|
|
408
|
+
const c = h(
|
|
413
409
|
{ sourceNode: l, destinationNode: a.node, sourceNodeHandle: null },
|
|
414
410
|
this
|
|
415
411
|
);
|
|
416
|
-
this.edges.push(
|
|
412
|
+
this.edges.push(c);
|
|
417
413
|
}
|
|
418
414
|
return this.conditionals.includes(a) || (this.conditionals.push(a), a.node && this.nodes.push(a.node)), a;
|
|
419
415
|
},
|
|
420
|
-
addExperience(
|
|
421
|
-
let l =
|
|
422
|
-
this.nodes.length === 0 && (l =
|
|
423
|
-
const a =
|
|
424
|
-
{ type: "experience", experience:
|
|
416
|
+
addExperience(i, u) {
|
|
417
|
+
let l = u?.node;
|
|
418
|
+
this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
|
|
419
|
+
const a = p(
|
|
420
|
+
{ type: "experience", experience: i },
|
|
425
421
|
this
|
|
426
422
|
);
|
|
427
423
|
if (this.nodes.push(a), l) {
|
|
428
|
-
const
|
|
424
|
+
const c = h(
|
|
429
425
|
{ sourceNode: l, destinationNode: a, sourceNodeHandle: null },
|
|
430
426
|
this
|
|
431
427
|
);
|
|
432
|
-
this.edges.push(
|
|
428
|
+
this.edges.push(c);
|
|
433
429
|
}
|
|
434
|
-
return
|
|
430
|
+
return i;
|
|
435
431
|
},
|
|
436
|
-
addField(
|
|
437
|
-
const l = "serialize" in
|
|
438
|
-
return
|
|
432
|
+
addField(i, u) {
|
|
433
|
+
const l = "serialize" in i ? i : m(i);
|
|
434
|
+
return u && u.fields.push(l), this.fields.includes(l) || this.fields.push(l), l;
|
|
439
435
|
},
|
|
440
436
|
serialize() {
|
|
441
437
|
return r.serialize({
|
|
@@ -446,24 +442,24 @@ const r = {
|
|
|
446
442
|
condition: this.condition ?? this.decide,
|
|
447
443
|
decide: this.decide,
|
|
448
444
|
targets: this.targets,
|
|
449
|
-
steps: this.steps.map((
|
|
450
|
-
nodes: this.nodes.map((
|
|
451
|
-
edges: this.edges.map((
|
|
445
|
+
steps: this.steps.map((i) => r.deserialize(i.serialize())),
|
|
446
|
+
nodes: this.nodes.map((i) => r.deserialize(i.serialize())),
|
|
447
|
+
edges: this.edges.map((i) => r.deserialize(i.serialize())),
|
|
452
448
|
conditionals: this.conditionals.map(
|
|
453
|
-
(
|
|
449
|
+
(i) => r.deserialize(i.serialize())
|
|
454
450
|
),
|
|
455
|
-
fields: this.fields.map((
|
|
451
|
+
fields: this.fields.map((i) => r.deserialize(i.serialize()))
|
|
456
452
|
});
|
|
457
453
|
}
|
|
458
454
|
};
|
|
459
455
|
};
|
|
460
456
|
export {
|
|
461
457
|
b as createConditional,
|
|
462
|
-
|
|
458
|
+
h as createEdge,
|
|
463
459
|
V as createExperience,
|
|
464
460
|
v as createExperiencePlugin,
|
|
465
461
|
m as createField,
|
|
466
|
-
|
|
462
|
+
p as createNode,
|
|
467
463
|
E as createStep,
|
|
468
464
|
r as serialization
|
|
469
465
|
};
|