@picked/client 0.0.1-dev.1773371977114 → 0.0.1-dev.1773724362573

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