@picked/client 0.0.1-dev.1770787109735 → 0.0.1-dev.1771901344537

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