@picked/client 0.0.51-next.1 → 0.0.51-next.11

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 (75) hide show
  1. package/dist/api-CsptHpxs.cjs +1 -0
  2. package/dist/{api-Brluf3C1.js → api-D900ITyE.js} +1 -1
  3. package/dist/cjs/form/index.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/create-experience/index.js +1 -1
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/esm/form/index.js +82 -76
  11. package/dist/esm/index.js +436 -355
  12. package/dist/esm/plugins/create-experience/index.js +181 -154
  13. package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
  14. package/dist/esm/plugins/responses-browser-storage/index.js +6 -8
  15. package/dist/esm/plugins/responses-indexeddb/index.js +8 -4
  16. package/dist/esm/server/index.js +1 -1
  17. package/dist/experience-instance-DOcd8XI1.cjs +1 -0
  18. package/dist/{experience-instance-CIbQp9D7.js → experience-instance-NHU1moID.js} +37 -32
  19. package/dist/{rules-logic-BIkBWZmf.js → rules-logic-CnVktz2l.js} +9 -2
  20. package/dist/{rules-logic-DDxCiq4P.cjs → rules-logic-nMHNVLn7.cjs} +1 -1
  21. package/dist/types/client.d.ts +47 -43
  22. package/dist/types/client.d.ts.map +1 -1
  23. package/dist/types/entities/action/action.d.ts +37 -5
  24. package/dist/types/entities/action/action.d.ts.map +1 -1
  25. package/dist/types/entities/condition/condition.d.ts +20 -0
  26. package/dist/types/entities/condition/condition.d.ts.map +1 -0
  27. package/dist/types/entities/experience/experience.d.ts +63 -47
  28. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  29. package/dist/types/entities/experience-instance/experience-instance.d.ts +22 -2
  30. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  31. package/dist/types/entities/field/field.d.ts +13 -2
  32. package/dist/types/entities/field/field.d.ts.map +1 -1
  33. package/dist/types/entities/response/response-validation.d.ts +74 -0
  34. package/dist/types/entities/response/response-validation.d.ts.map +1 -0
  35. package/dist/types/entities/response/response.d.ts +24 -20
  36. package/dist/types/entities/response/response.d.ts.map +1 -1
  37. package/dist/types/entities/step/step.d.ts +42 -0
  38. package/dist/types/entities/step/step.d.ts.map +1 -0
  39. package/dist/types/form/build-responses.d.ts +12 -9
  40. package/dist/types/form/build-responses.d.ts.map +1 -1
  41. package/dist/types/form/create-field-evaluator.d.ts +11 -3
  42. package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
  43. package/dist/types/form/create-field-validation.d.ts +4 -4
  44. package/dist/types/form/create-field-validation.d.ts.map +1 -1
  45. package/dist/types/form/create-form.d.ts +1 -0
  46. package/dist/types/form/create-form.d.ts.map +1 -1
  47. package/dist/types/form/create-submit-pipeline.d.ts +19 -7
  48. package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
  49. package/dist/types/form/get-step-fields.d.ts +13 -0
  50. package/dist/types/form/get-step-fields.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +2 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/types/picked.d.ts +98 -31
  54. package/dist/types/picked.d.ts.map +1 -1
  55. package/dist/types/plugins/create-experience/create-experience.d.ts +31 -11
  56. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  57. package/dist/types/plugins/create-experience/index.d.ts +2 -2
  58. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  59. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  60. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +21 -4
  61. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  62. package/dist/types/plugins/dynamic-experiences/types.d.ts +45 -0
  63. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  64. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  65. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  66. package/dist/types/utils/events.d.ts +1 -1
  67. package/dist/types/utils/events.d.ts.map +1 -1
  68. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +13 -0
  69. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -1
  70. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  71. package/dist/types/utils/state-snaphot.d.ts +11 -1
  72. package/dist/types/utils/state-snaphot.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/dist/api-A3gUhQJc.cjs +0 -1
  75. package/dist/experience-instance-Dri5yAp1.cjs +0 -1
@@ -12,8 +12,14 @@ var t = {
12
12
  setup: (n) => {
13
13
  e.experiences.forEach((e) => {
14
14
  let r = e.serialize(), i = t.deserialize(r);
15
- i.component = e.component, n.registerExperience(i), i.fields.forEach((e) => {
15
+ i.component = e.component;
16
+ let { steps: a, conditions: o, fields: s, ...c } = i;
17
+ n.registerExperience(c), s.forEach((e) => {
16
18
  n.registerField(e);
19
+ }), a.forEach((e) => {
20
+ n.registerStep(e);
21
+ }), o.forEach((e) => {
22
+ n.registerCondition(e);
17
23
  });
18
24
  });
19
25
  }
@@ -27,7 +33,7 @@ var t = {
27
33
  let t = s({
28
34
  sourceNode: this,
29
35
  destinationNode: e.node,
30
- sourceNodeHandle: null
36
+ sourceHandle: null
31
37
  }, r);
32
38
  r.edges.push(t);
33
39
  },
@@ -36,7 +42,7 @@ var t = {
36
42
  let t = s({
37
43
  sourceNode: this,
38
44
  destinationNode: e.node,
39
- sourceNodeHandle: "true"
45
+ sourceHandle: "true"
40
46
  }, r);
41
47
  r.edges.push(t);
42
48
  },
@@ -45,7 +51,7 @@ var t = {
45
51
  let t = s({
46
52
  sourceNode: this,
47
53
  destinationNode: e.node,
48
- sourceNodeHandle: "false"
54
+ sourceHandle: "false"
49
55
  }, r);
50
56
  r.edges.push(t);
51
57
  },
@@ -53,21 +59,28 @@ var t = {
53
59
  return t.serialize({
54
60
  id: this.id,
55
61
  type: this.type,
56
- action: this.action
62
+ actionKey: this.action
57
63
  });
58
64
  }
59
- }), i = (t) => ({
60
- id: t.id ?? e("step"),
61
- label: t.label,
62
- fields: t.fields ?? [],
63
- addField(e) {
64
- let t = "serialize" in e ? e : u(e);
65
- return this.fields.includes(t) || this.fields.push(t), t;
66
- }
67
- }), a = (n, r) => {
68
- let i = {
69
- id: n.id ?? e("step"),
70
- label: n.label,
65
+ }), i = (t) => {
66
+ let n = t.name, r = t.id ?? e("step");
67
+ return {
68
+ id: r,
69
+ name: n,
70
+ key: t.key ?? r,
71
+ label: n,
72
+ fields: t.fields ?? [],
73
+ addField(e) {
74
+ let t = "serialize" in e ? e : l(e);
75
+ return this.fields.includes(t) || this.fields.push(t), t;
76
+ }
77
+ };
78
+ }, a = (n, r) => {
79
+ let i = n.name, a = n.id ?? e("step"), s = {
80
+ id: a,
81
+ name: i,
82
+ key: n.key ?? a,
83
+ label: i,
71
84
  experience: r,
72
85
  fields: n.fields ?? [],
73
86
  node: null,
@@ -89,15 +102,17 @@ var t = {
89
102
  serialize() {
90
103
  return t.serialize({
91
104
  id: this.id,
105
+ key: this.key,
106
+ name: this.name,
92
107
  label: this.label,
93
108
  fieldIds: this.fields.map((e) => e.id)
94
109
  });
95
110
  }
96
111
  };
97
112
  return o({
98
- step: i,
113
+ step: s,
99
114
  type: "step"
100
- }, r), i;
115
+ }, r), s;
101
116
  }, o = (n, r) => {
102
117
  let i = {
103
118
  id: e("node"),
@@ -113,6 +128,7 @@ var t = {
113
128
  id: this.id,
114
129
  type: this.type,
115
130
  stepId: this.connectedStep.id,
131
+ name: this.connectedStep.name,
116
132
  label: this.connectedStep.label
117
133
  });
118
134
  }
@@ -142,7 +158,8 @@ var t = {
142
158
  return t.serialize({
143
159
  id: this.id,
144
160
  type: this.type,
145
- experienceId: this.connectedExperience.id
161
+ experienceId: this.connectedExperience.id,
162
+ experienceKey: this.connectedExperience.key
146
163
  });
147
164
  }
148
165
  } : {
@@ -158,22 +175,24 @@ var t = {
158
175
  }, s = (n, r) => ({
159
176
  id: e("edge"),
160
177
  sourceNode: n.sourceNode,
161
- sourceNodeHandle: n.sourceNodeHandle,
178
+ sourceHandle: n.sourceHandle,
162
179
  destinationNode: n.destinationNode,
163
180
  experience: r,
164
181
  serialize() {
165
182
  return t.serialize({
166
183
  id: this.id,
167
- sourceNodeHandle: this.sourceNodeHandle ?? void 0,
184
+ sourceHandle: this.sourceHandle ?? void 0,
168
185
  sourceNodeId: this.sourceNode.id,
169
186
  destinationNodeId: this.destinationNode.id
170
187
  });
171
188
  }
172
189
  }), c = (n, r) => {
173
- let i = {
174
- id: e("condition"),
190
+ let i = e("conditional"), a = n.name ?? n.label ?? i, c = {
191
+ id: i,
192
+ key: n.key ?? i,
193
+ name: a,
175
194
  label: n.label,
176
- condition: n.condition,
195
+ logic: n.condition,
177
196
  node: null,
178
197
  experience: r,
179
198
  addTrue(e) {
@@ -181,7 +200,7 @@ var t = {
181
200
  let t = s({
182
201
  sourceNode: this.node,
183
202
  destinationNode: e.node,
184
- sourceNodeHandle: "true"
203
+ sourceHandle: "true"
185
204
  }, this.experience);
186
205
  this.experience.edges.push(t);
187
206
  },
@@ -190,66 +209,84 @@ var t = {
190
209
  let t = s({
191
210
  sourceNode: this.node,
192
211
  destinationNode: e.node,
193
- sourceNodeHandle: "false"
212
+ sourceHandle: "false"
194
213
  }, this.experience);
195
214
  this.experience.edges.push(t);
196
215
  },
197
216
  serialize() {
198
217
  return t.serialize({
199
218
  id: this.id,
200
- label: this.label,
201
- condition: this.condition
219
+ key: this.key,
220
+ name: this.name,
221
+ logic: this.logic
202
222
  });
203
223
  }
204
224
  };
205
225
  return o({
206
- condition: i,
226
+ condition: c,
207
227
  type: "condition"
208
- }, r), i;
209
- }, l = c, u = (n) => ({
210
- id: n.id,
211
- name: n.name,
212
- type: n.type,
213
- label: n.label,
214
- placeholder: n.placeholder,
215
- description: n.description,
216
- helpText: n.helpText,
217
- defaultValue: n.defaultValue ?? null,
218
- multiple: n.multiple,
219
- validation: n.validation ?? {},
220
- condition: n.condition,
221
- required: n.required,
222
- options: n.options?.map((t) => ({
223
- id: "id" in t ? t.id : e("option"),
224
- ...t
225
- })) ?? null,
226
- policies: n.policies,
227
- serialize() {
228
- let e = {
229
- id: this.id,
230
- name: this.name,
231
- label: this.label,
232
- placeholder: this.placeholder,
233
- required: this.required,
234
- description: this.description,
235
- helpText: this.helpText,
236
- validation: this.validation,
237
- condition: this.condition,
238
- policies: this.policies
239
- }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
240
- switch (this.type) {
241
- case "text":
242
- if (this.multiple) {
243
- let n;
244
- if (Array.isArray(this.defaultValue)) {
245
- n = [];
246
- for (let e of this.defaultValue) typeof e == "string" && n.push(e);
247
- n.length === 0 && (n = void 0);
228
+ }, r), c;
229
+ }, l = (n) => {
230
+ let r = n.id ?? e("field");
231
+ return {
232
+ id: r,
233
+ key: n.key ?? r,
234
+ name: n.name,
235
+ type: n.type,
236
+ label: n.label,
237
+ placeholder: n.placeholder,
238
+ description: n.description,
239
+ helpText: n.helpText,
240
+ defaultValue: n.defaultValue ?? null,
241
+ multiple: n.multiple,
242
+ validation: n.validation ?? {},
243
+ condition: n.condition,
244
+ required: n.required,
245
+ options: n.options?.map((t) => ({
246
+ id: "id" in t ? t.id : e("option"),
247
+ ...t
248
+ })) ?? null,
249
+ policies: n.policies,
250
+ serialize() {
251
+ let e = {
252
+ id: this.id,
253
+ key: this.key,
254
+ name: this.name,
255
+ label: this.label,
256
+ placeholder: this.placeholder,
257
+ required: this.required,
258
+ description: this.description,
259
+ helpText: this.helpText,
260
+ validation: this.validation,
261
+ condition: this.condition,
262
+ policies: this.policies
263
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
264
+ switch (this.type) {
265
+ case "text":
266
+ if (this.multiple) {
267
+ let n;
268
+ if (Array.isArray(this.defaultValue)) {
269
+ n = [];
270
+ for (let e of this.defaultValue) typeof e == "string" && n.push(e);
271
+ n.length === 0 && (n = void 0);
272
+ }
273
+ return t.serialize({
274
+ ...e,
275
+ type: "text",
276
+ multiple: !0,
277
+ defaultValue: n,
278
+ options: this.options ? this.options.map((e) => ({
279
+ id: e.id,
280
+ label: e.label,
281
+ value: `${e.value}`,
282
+ condition: e.condition
283
+ })) : null
284
+ });
248
285
  }
249
286
  return t.serialize({
250
287
  ...e,
251
288
  type: "text",
252
- multiple: !0,
289
+ multiple: !1,
253
290
  defaultValue: n,
254
291
  options: this.options ? this.options.map((e) => ({
255
292
  id: e.id,
@@ -258,32 +295,32 @@ var t = {
258
295
  condition: e.condition
259
296
  })) : null
260
297
  });
261
- }
262
- return t.serialize({
263
- ...e,
264
- type: "text",
265
- multiple: !1,
266
- defaultValue: n,
267
- options: this.options ? this.options.map((e) => ({
268
- id: e.id,
269
- label: e.label,
270
- value: `${e.value}`,
271
- condition: e.condition
272
- })) : null
273
- });
274
- case "number":
275
- if (this.multiple) {
276
- let n;
277
- if (Array.isArray(this.defaultValue)) {
278
- n = [];
279
- for (let e of this.defaultValue) typeof e == "number" && n.push(e);
280
- n.length === 0 && (n = void 0);
298
+ case "number":
299
+ if (this.multiple) {
300
+ let n;
301
+ if (Array.isArray(this.defaultValue)) {
302
+ n = [];
303
+ for (let e of this.defaultValue) typeof e == "number" && n.push(e);
304
+ n.length === 0 && (n = void 0);
305
+ }
306
+ return t.serialize({
307
+ ...e,
308
+ type: "number",
309
+ multiple: !0,
310
+ defaultValue: n,
311
+ options: this.options ? this.options.map((e) => ({
312
+ id: e.id,
313
+ label: e.label,
314
+ value: Number(e.value),
315
+ condition: e.condition
316
+ })) : null
317
+ });
281
318
  }
282
319
  return t.serialize({
283
320
  ...e,
284
321
  type: "number",
285
- multiple: !0,
286
- defaultValue: n,
322
+ multiple: !1,
323
+ defaultValue: r,
287
324
  options: this.options ? this.options.map((e) => ({
288
325
  id: e.id,
289
326
  label: e.label,
@@ -291,32 +328,32 @@ var t = {
291
328
  condition: e.condition
292
329
  })) : null
293
330
  });
294
- }
295
- return t.serialize({
296
- ...e,
297
- type: "number",
298
- multiple: !1,
299
- defaultValue: r,
300
- options: this.options ? this.options.map((e) => ({
301
- id: e.id,
302
- label: e.label,
303
- value: Number(e.value),
304
- condition: e.condition
305
- })) : null
306
- });
307
- case "boolean":
308
- if (this.multiple) {
309
- let n;
310
- if (Array.isArray(this.defaultValue)) {
311
- n = [];
312
- for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
313
- n.length === 0 && (n = void 0);
331
+ case "boolean":
332
+ if (this.multiple) {
333
+ let n;
334
+ if (Array.isArray(this.defaultValue)) {
335
+ n = [];
336
+ for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
337
+ n.length === 0 && (n = void 0);
338
+ }
339
+ return t.serialize({
340
+ ...e,
341
+ type: "boolean",
342
+ multiple: !0,
343
+ defaultValue: n,
344
+ options: this.options ? this.options.map((e) => ({
345
+ id: e.id,
346
+ label: e.label,
347
+ value: !!e.value,
348
+ condition: e.condition
349
+ })) : null
350
+ });
314
351
  }
315
352
  return t.serialize({
316
353
  ...e,
317
354
  type: "boolean",
318
- multiple: !0,
319
- defaultValue: n,
355
+ multiple: !1,
356
+ defaultValue: i,
320
357
  options: this.options ? this.options.map((e) => ({
321
358
  id: e.id,
322
359
  label: e.label,
@@ -324,49 +361,38 @@ var t = {
324
361
  condition: e.condition
325
362
  })) : null
326
363
  });
327
- }
328
- return t.serialize({
364
+ case "object": return this.multiple ? t.serialize({
365
+ ...e,
366
+ type: "object",
367
+ multiple: !0,
368
+ defaultValue: this.defaultValue,
369
+ options: this.options ? this.options.map((e) => ({
370
+ id: e.id,
371
+ label: e.label,
372
+ description: e.description,
373
+ value: e.value,
374
+ condition: e.condition
375
+ })) : null
376
+ }) : t.serialize({
329
377
  ...e,
330
- type: "boolean",
378
+ type: "object",
331
379
  multiple: !1,
332
- defaultValue: i,
380
+ defaultValue: this.defaultValue,
333
381
  options: this.options ? this.options.map((e) => ({
334
382
  id: e.id,
335
383
  label: e.label,
336
- value: !!e.value,
384
+ description: e.description,
385
+ value: e.value,
337
386
  condition: e.condition
338
387
  })) : null
339
388
  });
340
- case "object": return this.multiple ? t.serialize({
341
- ...e,
342
- type: "object",
343
- multiple: !0,
344
- defaultValue: this.defaultValue,
345
- options: this.options ? this.options.map((e) => ({
346
- id: e.id,
347
- label: e.label,
348
- description: e.description,
349
- value: e.value,
350
- condition: e.condition
351
- })) : null
352
- }) : t.serialize({
353
- ...e,
354
- type: "object",
355
- multiple: !1,
356
- defaultValue: this.defaultValue,
357
- options: this.options ? this.options.map((e) => ({
358
- id: e.id,
359
- label: e.label,
360
- description: e.description,
361
- value: e.value,
362
- condition: e.condition
363
- })) : null
364
- });
365
- default: throw Error("Unsupported field type");
389
+ default: throw Error("Unsupported field type");
390
+ }
366
391
  }
367
- }
368
- }), d = (e) => ({
392
+ };
393
+ }, u = (e) => ({
369
394
  id: e.id,
395
+ key: e.key ?? e.id,
370
396
  component: e.component,
371
397
  name: e.name,
372
398
  initializeOpen: e.initializeOpen,
@@ -386,7 +412,7 @@ var t = {
386
412
  let e = s({
387
413
  sourceNode: n,
388
414
  destinationNode: r.node,
389
- sourceNodeHandle: null
415
+ sourceHandle: null
390
416
  }, this);
391
417
  this.edges.push(e);
392
418
  }
@@ -402,7 +428,7 @@ var t = {
402
428
  let e = s({
403
429
  sourceNode: n,
404
430
  destinationNode: i,
405
- sourceNodeHandle: null
431
+ sourceHandle: null
406
432
  }, this);
407
433
  this.edges.push(e);
408
434
  }
@@ -417,7 +443,7 @@ var t = {
417
443
  let e = s({
418
444
  sourceNode: n,
419
445
  destinationNode: r.node,
420
- sourceNodeHandle: null
446
+ sourceHandle: null
421
447
  }, this);
422
448
  this.edges.push(e);
423
449
  }
@@ -437,19 +463,20 @@ var t = {
437
463
  let e = s({
438
464
  sourceNode: n,
439
465
  destinationNode: r,
440
- sourceNodeHandle: null
466
+ sourceHandle: null
441
467
  }, this);
442
468
  this.edges.push(e);
443
469
  }
444
470
  return e;
445
471
  },
446
472
  addField(e, t) {
447
- let n = "serialize" in e ? e : u(e);
473
+ let n = "serialize" in e ? e : l(e);
448
474
  return t && t.fields.push(n), this.fields.includes(n) || this.fields.push(n), n;
449
475
  },
450
476
  serialize() {
451
477
  return t.serialize({
452
478
  id: this.id,
479
+ key: this.key,
453
480
  component: this.component,
454
481
  name: this.name,
455
482
  initializeOpen: this.initializeOpen,
@@ -464,4 +491,4 @@ var t = {
464
491
  }
465
492
  });
466
493
  //#endregion
467
- export { c as createCondition, l as createConditional, s as createEdge, d as createExperience, n as createExperiencePlugin, u as createField, o as createNode, i as createStep, t as serialization };
494
+ export { c as createCondition, s as createEdge, u as createExperience, n as createExperiencePlugin, l as createField, o as createNode, i as createStep };
@@ -1,5 +1,5 @@
1
1
  import "../../../logger-6z_gb4rA.js";
2
- import { i as e, t } from "../../../api-Brluf3C1.js";
2
+ import { i as e, t } from "../../../api-D900ITyE.js";
3
3
  //#region src/plugins/dynamic-experiences/hash.ts
4
4
  function n(e) {
5
5
  let t = 2166136261;
@@ -15,16 +15,38 @@ function i(e, t) {
15
15
  //#endregion
16
16
  //#region src/plugins/dynamic-experiences/plugin.ts
17
17
  function a(e) {
18
- return typeof e != "object" || !e || !("id" in e && "name" in e && "enabled" in e && "weight" in e && "version" in e) ? !1 : typeof e.id == "string" && typeof e.name == "string" && typeof e.enabled == "boolean" && typeof e.weight == "number" && typeof e.version == "number";
18
+ return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
19
19
  }
20
- function o(e) {
21
- return typeof e != "object" || !e || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(a);
20
+ function o(e, t) {
21
+ if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
22
22
  }
23
- function s(e) {
23
+ function s(e, t) {
24
+ e.registerExperience({
25
+ id: t.id,
26
+ key: t.key,
27
+ name: t.name,
28
+ targets: t.targets,
29
+ nodes: t.nodes,
30
+ edges: t.edges,
31
+ condition: t.condition,
32
+ initializeOpen: t.initializeOpen,
33
+ componentName: t.componentName
34
+ });
35
+ }
36
+ function c(e, t) {
37
+ if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
38
+ }
39
+ function l(e, t) {
40
+ if (Array.isArray(t.steps)) for (let n of t.steps) e.registerStep(n);
41
+ }
42
+ function u(e, t) {
43
+ if (Array.isArray(t.experiences)) for (let n of t.experiences) s(e, n);
44
+ }
45
+ function d(e) {
24
46
  let t = e.searchParams["preview-token"];
25
47
  if (t && t.length > 0) return t[0];
26
48
  }
27
- function c(e) {
49
+ function f(e) {
28
50
  let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
29
51
  if (!n) return t;
30
52
  for (let e of n) {
@@ -33,13 +55,13 @@ function c(e) {
33
55
  }
34
56
  return t;
35
57
  }
36
- function l(e, t, n) {
37
- let i = c(e), a = e.session?.id;
58
+ function p(e, t, n) {
59
+ let i = f(e), a = e.session?.id;
38
60
  if (!a) throw Error("Session ID is required for feature registration");
39
61
  let o = r(a);
40
- for (let r of t.features) i.has(r.id) || u(e, r, n, o);
62
+ for (let r of t.features) i.has(r.id) || m(e, r, n, o);
41
63
  }
42
- function u(e, t, n, r) {
64
+ function m(e, t, n, r) {
43
65
  e.registerFeature(t.id, {
44
66
  key: `v${t.version}`,
45
67
  name: t.name,
@@ -47,7 +69,7 @@ function u(e, t, n, r) {
47
69
  decide: () => t.enabled ? i(r, t.weight) : !1
48
70
  });
49
71
  }
50
- function d() {
72
+ function h() {
51
73
  let e;
52
74
  try {
53
75
  e = __PICKED_PROJECT_CONFIG__;
@@ -62,9 +84,9 @@ function d() {
62
84
  return;
63
85
  }
64
86
  else t = e;
65
- if (o(t)) return t;
87
+ if (a(t)) return t;
66
88
  }
67
- function f(e) {
89
+ function g(e) {
68
90
  try {
69
91
  let t = new URL(e).hostname;
70
92
  return t === "localhost" || t === "127.0.0.1" || t === "::1";
@@ -72,49 +94,49 @@ function f(e) {
72
94
  return !1;
73
95
  }
74
96
  }
75
- function p(e) {
97
+ function _(e) {
76
98
  if (typeof e != "object" || !e || !("cause" in e)) return !1;
77
99
  let { cause: t } = e;
78
100
  return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
79
101
  }
80
- async function m(e, n, r) {
81
- let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
102
+ async function v(e, n, r) {
103
+ let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, o;
82
104
  try {
83
- a = await t(e, i, r?.headers);
105
+ o = await t(e, i, r?.headers);
84
106
  } catch (t) {
85
- return f(e) && p(t), null;
107
+ return g(e) && _(t), null;
86
108
  }
87
- if (!a.ok) return `${a.status.toString()}`, null;
109
+ if (!o.ok) return `${o.status.toString()}`, null;
88
110
  let s;
89
111
  try {
90
- s = await a.json();
112
+ s = await o.json();
91
113
  } catch {
92
114
  return null;
93
115
  }
94
- return o(s) ? s : null;
116
+ return a(s) ? s : null;
95
117
  }
96
- function h(e) {
118
+ function y(e) {
97
119
  return {
98
120
  name: "dynamic-experiences",
99
121
  setup: (t) => {
100
122
  let n = e?.apiUrl ?? t.apiUrl;
101
123
  return { onStart: async () => {
102
- let r = s(t);
124
+ let r = d(t);
103
125
  if (r) {
104
- let e = await m(n, t.projectId, { previewToken: r });
105
- e && l(t, e, !0);
126
+ let e = await v(n, t.projectId, { previewToken: r });
127
+ e && (p(t, e, !0), o(t, e), c(t, e), l(t, e), u(t, e));
106
128
  return;
107
129
  }
108
- let i = e?.projectConfig ?? d();
130
+ let i = e?.projectConfig ?? h();
109
131
  if (i) {
110
- l(t, i, !1);
132
+ p(t, i, !1), o(t, i), c(t, i), l(t, i), u(t, i);
111
133
  return;
112
134
  }
113
- let a = await m(n, t.projectId);
114
- a && l(t, a, !1);
135
+ let a = await v(n, t.projectId);
136
+ a && (p(t, a, !1), o(t, a), c(t, a), l(t, a), u(t, a));
115
137
  } };
116
138
  }
117
139
  };
118
140
  }
119
141
  //#endregion
120
- export { e as createClientHeaders, h as dynamicExperiencesPlugin, m as fetchProject };
142
+ export { e as createClientHeaders, y as dynamicExperiencesPlugin, v as fetchProject };