@picked/client 0.0.1-dev.1772412203098 → 0.0.1-dev.1772493269328

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