@picked/client 0.0.1-dev.1772068485198 → 0.0.1-dev.1772083499814

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 (55) 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/cjs/plugins/web-components/index.js +1 -1
  7. package/dist/cjs/server/index.js +1 -1
  8. package/dist/esm/index.js +662 -712
  9. package/dist/esm/plugins/create-experience/index.js +228 -194
  10. package/dist/esm/plugins/dynamic-experiences/index.js +115 -0
  11. package/dist/esm/plugins/web-components/index.js +5 -5
  12. package/dist/esm/server/index.js +1 -1
  13. package/dist/experience-instance-BsXG5XJ4.cjs +1 -0
  14. package/dist/{experience-instance-CLR80xop.js → experience-instance-fvSEb72i.js} +358 -358
  15. package/dist/types/client.d.ts +10 -12
  16. package/dist/types/client.d.ts.map +1 -1
  17. package/dist/types/entities/action/action.d.ts +2 -5
  18. package/dist/types/entities/action/action.d.ts.map +1 -1
  19. package/dist/types/entities/component/component.d.ts +2 -1
  20. package/dist/types/entities/component/component.d.ts.map +1 -1
  21. package/dist/types/entities/component/lazyComponent.d.ts +11 -0
  22. package/dist/types/entities/component/lazyComponent.d.ts.map +1 -0
  23. package/dist/types/entities/experience/experience.d.ts +49 -5
  24. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  25. package/dist/types/entities/experience-instance/experience-instance.d.ts +4 -3
  26. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  27. package/dist/types/entities/field/field.d.ts +14 -51
  28. package/dist/types/entities/field/field.d.ts.map +1 -1
  29. package/dist/types/entities/plugin/plugin.d.ts +4 -1
  30. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  31. package/dist/types/entities/response/response.d.ts.map +1 -1
  32. package/dist/types/exports.d.ts +2 -0
  33. package/dist/types/exports.d.ts.map +1 -1
  34. package/dist/types/index.d.ts +1 -1
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/picked.d.ts +48 -18
  37. package/dist/types/picked.d.ts.map +1 -1
  38. package/dist/types/ping.d.ts.map +1 -1
  39. package/dist/types/plugins/create-experience/create-experience.d.ts +23 -26
  40. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  41. package/dist/types/plugins/dynamic-experiences/hash.d.ts +18 -0
  42. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -0
  43. package/dist/types/plugins/dynamic-experiences/index.d.ts +3 -0
  44. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -0
  45. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +23 -0
  46. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -0
  47. package/dist/types/plugins/dynamic-experiences/types.d.ts +15 -0
  48. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -0
  49. package/dist/types/utils/api.d.ts +3 -0
  50. package/dist/types/utils/api.d.ts.map +1 -0
  51. package/dist/types/utils/get-step-fields.d.ts +1 -2
  52. package/dist/types/utils/get-step-fields.d.ts.map +1 -1
  53. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  54. package/package.json +7 -1
  55. package/dist/experience-instance-5rr_D--s.cjs +0 -1
@@ -1,29 +1,29 @@
1
- import { createDomain as It, createEvent as b, combine as R, createApi as ft, createEffect as M, attach as B, sample as S, split as kt } from "effector";
2
- import { createFactory as lt, invoke as dt } from "@withease/factories";
3
- import { j as bt, s as pt, a as At } from "./supports-8YT4QKI7.js";
4
- import { l as E } from "./logger-C9a75KZn.js";
5
- import { i as vt } from "./object-JwZ58NOH.js";
6
- function Ot(t) {
1
+ import { createDomain as kt, createEvent as k, combine as D, createApi as lt, createEffect as _, attach as O, sample as m, split as bt } from "effector";
2
+ import { createFactory as dt, invoke as pt } from "@withease/factories";
3
+ import { a as vt, s as gt, j as At } from "./supports-8YT4QKI7.js";
4
+ import { l as I } from "./logger-C9a75KZn.js";
5
+ import { i as Ot } from "./object-JwZ58NOH.js";
6
+ function Ft(t) {
7
7
  return typeof t == "number" && !isNaN(t);
8
8
  }
9
- function U(t) {
9
+ function j(t) {
10
10
  return typeof t == "string";
11
11
  }
12
12
  function N(t) {
13
13
  return Array.isArray(t);
14
14
  }
15
- function gt(t) {
15
+ function mt(t) {
16
16
  return t instanceof Promise;
17
17
  }
18
- function it(t) {
18
+ function st(t) {
19
19
  return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
20
20
  }
21
21
  function g(t) {
22
- if (Ot(t)) return t;
22
+ if (Ft(t)) return t;
23
23
  const e = parseFloat(`${t}`);
24
24
  return isNaN(e) ? 0 : e;
25
25
  }
26
- function P(t) {
26
+ function R(t) {
27
27
  return `${t}`;
28
28
  }
29
29
  const Bt = {
@@ -38,32 +38,32 @@ const Bt = {
38
38
  "<": (t, e, r) => {
39
39
  const n = g(t), s = g(e);
40
40
  if (r === void 0) return n < s;
41
- const c = g(r);
42
- return n < s && s < c;
41
+ const a = g(r);
42
+ return n < s && s < a;
43
43
  },
44
44
  "<=": (t, e, r) => {
45
45
  const n = g(t), s = g(e);
46
46
  if (r === void 0) return n <= s;
47
- const c = g(r);
48
- return n <= s && s <= c;
47
+ const a = g(r);
48
+ return n <= s && s <= a;
49
49
  },
50
50
  "!!": async (t) => await v(t),
51
51
  "!": async (t) => !await v(t),
52
52
  "%": (t, e) => g(t) % g(e),
53
53
  // eslint-disable-next-line sonarjs/function-return-type
54
54
  log: (t) => (console.log(t), t),
55
- in: (t, e) => e ? U(e) ? e.indexOf(P(t)) !== -1 : N(e) ? e.includes(t) : !1 : !1,
56
- cat: (...t) => t.map(P).join(""),
55
+ in: (t, e) => e ? j(e) ? e.indexOf(R(t)) !== -1 : N(e) ? e.includes(t) : !1 : !1,
56
+ cat: (...t) => t.map(R).join(""),
57
57
  /* eslint-disable sonarjs/deprecation */
58
58
  substr: (t, e, r) => {
59
- const n = P(t), s = g(e);
59
+ const n = R(t), s = g(e);
60
60
  if (r === void 0) return n.substr(s);
61
- const c = g(r);
62
- if (c < 0) {
61
+ const a = g(r);
62
+ if (a < 0) {
63
63
  const o = n.substr(s);
64
- return o.substr(0, o.length + c);
64
+ return o.substr(0, o.length + a);
65
65
  }
66
- return n.substr(s, c);
66
+ return n.substr(s, a);
67
67
  },
68
68
  /* eslint-enable sonarjs/deprecation */
69
69
  "+": (...t) => t.reduce((e, r) => g(e) + g(r), 0),
@@ -82,21 +82,21 @@ const Bt = {
82
82
  return this;
83
83
  if (typeof t == "number" && Array.isArray(this))
84
84
  return t >= 0 && t < this.length ? this[t] : r;
85
- const n = P(t);
85
+ const n = R(t);
86
86
  if (n === "" || n === ".")
87
87
  return this;
88
88
  const s = n.split(".");
89
- let c = this;
89
+ let a = this;
90
90
  for (const o of s) {
91
- if (c == null)
91
+ if (a == null)
92
92
  return r;
93
- if (Array.isArray(c)) {
93
+ if (Array.isArray(a)) {
94
94
  const u = parseInt(o, 10);
95
- isNaN(u) ? c = c[o] : c = c[u];
95
+ isNaN(u) ? a = a[o] : a = a[u];
96
96
  } else
97
- c = c[o];
97
+ a = a[o];
98
98
  }
99
- return c !== void 0 ? c : r;
99
+ return a !== void 0 ? a : r;
100
100
  },
101
101
  async missing(...t) {
102
102
  const e = N(t[0]) ? t[0] : t, r = [];
@@ -109,8 +109,8 @@ const Bt = {
109
109
  async missing_some(t, e) {
110
110
  const r = await p({ missing: e }, this);
111
111
  if (!N(r) || !N(e)) return [];
112
- const n = r.filter(U);
113
- return e.filter(U).length - n.length >= g(t) ? [] : n;
112
+ const n = r.filter(j);
113
+ return e.filter(j).length - n.length >= g(t) ? [] : n;
114
114
  },
115
115
  /**
116
116
  * Invoke operator - executes a function with optional arguments
@@ -131,23 +131,23 @@ const Bt = {
131
131
  regexp_matches(t, e) {
132
132
  let r = t, n = "";
133
133
  if (N(t)) {
134
- const [c, o] = t;
135
- r = c, n = o;
134
+ const [a, o] = t;
135
+ r = a, n = o;
136
136
  }
137
- return !U(r) || !U(n) ? !1 : new RegExp(r, n).test(P(e));
137
+ return !j(r) || !j(n) ? !1 : new RegExp(r, n).test(R(e));
138
138
  },
139
139
  throw(t) {
140
- throw new Error(P(t));
140
+ throw new Error(R(t));
141
141
  }
142
142
  };
143
143
  async function p(t, e) {
144
144
  if (!t) return t;
145
- if (gt(t))
145
+ if (mt(t))
146
146
  return p(await t, e);
147
147
  if (N(t))
148
148
  return Promise.all(t.map((o) => p(o, e)));
149
- if (!it(t)) return t;
150
- const r = Ft(t);
149
+ if (!st(t)) return t;
150
+ const r = _t(t);
151
151
  let n = r ? t[r] ?? [] : [];
152
152
  switch (N(n) || (n = [n]), r) {
153
153
  case "if":
@@ -177,8 +177,8 @@ async function p(t, e) {
177
177
  const o = await p(n[0], e);
178
178
  return N(o) ? (await Promise.all(
179
179
  o.map(async (d) => {
180
- const m = await v(await p(n[1], d));
181
- return { item: d, shouldInclude: m };
180
+ const y = await v(await p(n[1], d));
181
+ return { item: d, shouldInclude: y };
182
182
  })
183
183
  )).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
184
184
  }
@@ -187,10 +187,10 @@ async function p(t, e) {
187
187
  if (!N(o))
188
188
  return n.length > 2 ? await p(n[2], e) : null;
189
189
  const u = n[1];
190
- let m = n.length > 2 ? await p(n[2], e) : null;
191
- for (const w of o)
192
- m = await p(u, { current: w, accumulator: m });
193
- return m;
190
+ let y = n.length > 2 ? await p(n[2], e) : null;
191
+ for (const b of o)
192
+ y = await p(u, { current: b, accumulator: y });
193
+ return y;
194
194
  }
195
195
  case "all": {
196
196
  const o = await p(n[0], e);
@@ -217,36 +217,34 @@ async function p(t, e) {
217
217
  try {
218
218
  return await p(n[0], e);
219
219
  } catch (o) {
220
- return it(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
220
+ return st(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
221
221
  }
222
222
  }
223
- const s = await Promise.all(n.map((o) => p(o, e))), c = r ? Bt[r] : void 0;
224
- if (!c) throw new Error(`Unrecognized operation ${r}`);
225
- return c.apply(e, s);
223
+ const s = await Promise.all(n.map((o) => p(o, e))), a = r ? Bt[r] : void 0;
224
+ if (!a) throw new Error(`Unrecognized operation ${r}`);
225
+ return a.apply(e, s);
226
226
  }
227
227
  async function v(t) {
228
- return gt(t) ? v(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
228
+ return mt(t) ? v(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
229
229
  }
230
- function Ft(t) {
230
+ function _t(t) {
231
231
  return Object.keys(t)[0];
232
232
  }
233
- function _t(t) {
234
- return !vt(t);
233
+ function $t(t) {
234
+ return !Ot(t);
235
235
  }
236
- async function st(t, e, r) {
237
- const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((d, m) => ({
238
- ...d,
239
- [m.name]: (...w) => m.predicate({ ...n, args: w })
240
- }), {}), c = t.features.listStore.getState().reduce((d, m) => ({
241
- ...d,
242
- [m.id]: async () => {
243
- const { bucket: w } = await m.getBucket();
244
- return w;
236
+ async function at(t, e, r) {
237
+ const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((u, d) => ({
238
+ ...u,
239
+ [d.name]: (...y) => d.predicate({ ...n, args: y })
240
+ }), {}), a = t.features.listStore.getState().reduce((u, d) => ({
241
+ ...u,
242
+ [d.id]: async () => {
243
+ const { bucket: y } = await d.getBucket();
244
+ return y;
245
245
  }
246
- }), {}), o = t.actions.listStore.getState().reduce((d, m) => ({
247
- ...d,
248
- [m.name]: (w) => m.action(w)
249
- }), {}), u = {
246
+ }), {}), o = {
247
+ ...r,
250
248
  responses: t.responses.getAllStore.getState(),
251
249
  location: typeof n.location == "object" ? {
252
250
  hash: n.location.hash,
@@ -260,50 +258,48 @@ async function st(t, e, r) {
260
258
  search: n.location.search
261
259
  } : void 0,
262
260
  predicates: s,
263
- features: c,
264
- actions: o,
265
- ...r
261
+ features: a
266
262
  };
267
- return await p(e, u);
263
+ return await p(e, o);
268
264
  }
269
- function $t(t) {
270
- return !At() || !pt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
265
+ function Mt(t) {
266
+ return !vt() || !gt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
271
267
  (e) => e instanceof HTMLElement
272
268
  );
273
269
  }
274
- const Mt = "open";
275
- function Tt(t) {
276
- if (!bt())
270
+ const Tt = "open";
271
+ function Lt(t) {
272
+ if (!At())
277
273
  throw new Error("Shadow DOM is not supported in this environment");
278
- return t.attachShadow({ mode: Mt });
274
+ return t.attachShadow({ mode: Tt });
279
275
  }
280
- function Zt() {
276
+ function te() {
281
277
  return new Promise((t, e) => {
282
- if (!pt()) {
278
+ if (!gt()) {
283
279
  e();
284
280
  return;
285
281
  }
286
282
  document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
287
283
  });
288
284
  }
289
- function Lt(t, e) {
285
+ function Dt(t, e) {
290
286
  const r = new MutationObserver((n) => {
291
287
  document.contains(t) || (r.disconnect(), e());
292
288
  });
293
289
  r.observe(document.body, { childList: !0, subtree: !0 });
294
290
  }
295
- const K = "picked-root", V = "picked-target", Dt = "picked-root";
296
- function te(t, e) {
291
+ const K = "picked-root", V = "picked-target", Rt = "picked-root";
292
+ function ee(t, e) {
297
293
  return [
298
294
  ...t,
299
295
  // Target and replace picked-root web components
300
296
  {
301
- selector: `${Dt}[experience-id="${e}"]`,
297
+ selector: `${Rt}[experience-id="${e}"]`,
302
298
  placement: "replace"
303
299
  }
304
300
  ].flatMap((n) => {
305
- const s = $t(n.selector).filter(
306
- (c) => !Rt(c, e) && !Pt(c, e)
301
+ const s = Mt(n.selector).filter(
302
+ (a) => !Pt(a, e) && !Ct(a, e)
307
303
  );
308
304
  return {
309
305
  ...n,
@@ -311,25 +307,25 @@ function te(t, e) {
311
307
  };
312
308
  });
313
309
  }
314
- function ee(t, e) {
315
- return t.flatMap((r) => r.elements.map((n) => Ht(n, r.placement, e)));
316
- }
317
310
  function ne(t, e) {
311
+ return t.flatMap((r) => r.elements.map((n) => jt(n, r.placement, e)));
312
+ }
313
+ function re(t, e) {
318
314
  t.classList.add(V), t.classList.add(`${V}-${e}`);
319
315
  }
320
- function Rt(t, e) {
316
+ function Pt(t, e) {
321
317
  return e ? t.classList.contains(`${V}-${e}`) : t.classList.contains(`${V}`);
322
318
  }
323
- function Pt(t, e) {
319
+ function Ct(t, e) {
324
320
  return e ? t.classList.contains(`${K}-${e}`) : t.classList.contains(K);
325
321
  }
326
- function Ct(t) {
322
+ function Ht(t) {
327
323
  const e = document.createElement("div");
328
324
  return e.style.display = "block", e.classList.add(K), e.classList.add(`${K}-${t}`), e;
329
325
  }
330
- function Ht(t, e, r) {
326
+ function jt(t, e, r) {
331
327
  let n;
332
- const s = Ct(r);
328
+ const s = Ht(r);
333
329
  if (t instanceof Document)
334
330
  n = t.body.appendChild(s);
335
331
  else {
@@ -357,212 +353,212 @@ function Ht(t, e, r) {
357
353
  function ct(t) {
358
354
  return t.type === "conditional";
359
355
  }
360
- function C(t) {
356
+ function P(t) {
361
357
  return t.type === "step";
362
358
  }
363
- function at(t) {
359
+ function ut(t) {
364
360
  return t.type === "experience";
365
361
  }
366
- function Q(t) {
362
+ function Y(t) {
367
363
  return t.type === "origin";
368
364
  }
369
- function ut(t) {
365
+ function ft(t) {
370
366
  return t.type === "action";
371
367
  }
372
- const mt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), C(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
368
+ const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), P(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
373
369
  const u = t.find((d) => d.id === o.destinationNodeId);
374
- return u ? mt(t, e, u, !1, s) : [];
375
- })), jt = (t, e, r) => mt(t, e, r, !0, /* @__PURE__ */ new Set()), St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
370
+ return u ? St(t, e, u, !1, s) : [];
371
+ })), Ut = (t, e, r) => St(t, e, r, !0, /* @__PURE__ */ new Set()), yt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
376
372
  if (s.has(r.id)) return [-1, -1];
377
373
  s.add(r.id);
378
- const c = e.filter((d) => d.sourceNodeId === r.id);
379
- if (c.length === 0) return [0, 0];
374
+ const a = e.filter((d) => d.sourceNodeId === r.id);
375
+ if (a.length === 0) return [0, 0];
380
376
  let o = 1 / 0, u = -1 / 0;
381
- for (const d of c) {
382
- const m = t.find((L) => L.id === d.destinationNodeId);
383
- if (!m) continue;
384
- const [w, F] = St(
377
+ for (const d of a) {
378
+ const y = t.find((M) => M.id === d.destinationNodeId);
379
+ if (!y) continue;
380
+ const [b, F] = yt(
385
381
  t,
386
382
  e,
387
- m,
383
+ y,
388
384
  !1,
389
385
  new Set(s)
390
386
  );
391
- w !== -1 && (o = Math.min(o, w + 1), u = Math.max(u, F + 1));
387
+ b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u, F + 1));
392
388
  }
393
389
  return o === 1 / 0 ? [-1, -1] : [o, u];
394
- }, Ut = (t, e, r) => St(t, e, r, !0, /* @__PURE__ */ new Set()), yt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
390
+ }, Wt = (t, e, r) => yt(t, e, r, !0, /* @__PURE__ */ new Set()), ht = (t, e, r, n = /* @__PURE__ */ new Set()) => {
395
391
  if (n.has(r.id)) return [-1, -1];
396
392
  if (n.add(r.id), r.type === "origin") return [0, 0];
397
393
  const s = e.filter((u) => u.destinationNodeId === r.id);
398
394
  if (s.length === 0) return [-1, -1];
399
- let c = 1 / 0, o = -1 / 0;
395
+ let a = 1 / 0, o = -1 / 0;
400
396
  for (const u of s) {
401
397
  const d = t.find((F) => F.id === u.sourceNodeId);
402
398
  if (!d) continue;
403
- const [m, w] = yt(
399
+ const [y, b] = ht(
404
400
  t,
405
401
  e,
406
402
  d,
407
403
  new Set(n)
408
404
  );
409
- m !== -1 && (c = Math.min(c, m + 1), o = Math.max(o, w + 1));
405
+ y !== -1 && (a = Math.min(a, y + 1), o = Math.max(o, b + 1));
410
406
  }
411
- return c === 1 / 0 ? [-1, -1] : [c, o];
412
- }, Wt = (t, e, r) => yt(t, e, r, /* @__PURE__ */ new Set()), ht = (t) => t.find((r) => r.type === "origin") || null, Y = (t, e, r) => {
407
+ return a === 1 / 0 ? [-1, -1] : [a, o];
408
+ }, Gt = (t, e, r) => ht(t, e, r, /* @__PURE__ */ new Set()), wt = (t) => t.find((r) => r.type === "origin") || null, Z = (t, e, r) => {
413
409
  if (!t)
414
- return ht(e);
415
- const n = r.find((c) => c.sourceNodeId === t.id);
410
+ return wt(e);
411
+ const n = r.find((a) => a.sourceNodeId === t.id);
416
412
  if (!n)
417
413
  return null;
418
- const s = e.find((c) => c.id === n.destinationNodeId);
414
+ const s = e.find((a) => a.id === n.destinationNodeId);
419
415
  return s || null;
420
416
  };
421
- async function Gt(t, e, r, n) {
422
- const s = t ? "true" : "false", c = n.find(
417
+ async function Kt(t, e, r, n) {
418
+ const s = t ? "true" : "false", a = n.find(
423
419
  (o) => o.sourceNodeHandle === s && o.sourceNodeId === e
424
420
  );
425
- return r.find((o) => o.id === c?.destinationNodeId);
421
+ return r.find((o) => o.id === a?.destinationNodeId);
426
422
  }
427
- const Z = It("experience-instance"), Kt = lt(
423
+ const tt = kt("experience-instance"), Vt = dt(
428
424
  ({
429
425
  client: t,
430
426
  experience: e,
431
- target: r
427
+ target: r,
428
+ options: n
432
429
  }) => {
433
- const n = b(), s = b(), c = b(), o = b(), u = b(), d = b(), m = e.componentStore, w = Z.store("transitioning"), F = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), L = F.map((i) => i.filter((l) => C(l.node))), I = F.map((i) => i.at(-1)?.node || null), f = R(
430
+ const s = k(), a = k(), o = k(), u = k(), d = k(), y = k(), b = e.componentStore, F = tt.store("transitioning"), M = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), U = M.map((i) => i.filter((l) => P(l.node))), c = M.map((i) => i.at(-1)?.node || null), S = D(
434
431
  e.treeStore,
435
- I,
436
- ({ steps: i }, l) => i.find((a) => l && C(l) && a.id === l.stepId) || null
437
- ), y = R(
432
+ c,
433
+ ({ steps: i }, l) => i.find((f) => l && P(l) && f.id === l.stepId) || null
434
+ ), x = D(
438
435
  e.treeStore,
439
- L,
436
+ U,
440
437
  ({ steps: i }, l) => {
441
- const a = l.at(-2);
442
- if (!a || !C(a.node))
438
+ const f = l.at(-2);
439
+ if (!f || !P(f.node))
443
440
  return null;
444
- const h = a.node;
445
- return i.find(($) => $.id === h.stepId) || null;
441
+ const h = f.node;
442
+ return i.find((B) => B.id === h.stepId) || null;
446
443
  }
447
- ), A = R(
444
+ ), T = D(
448
445
  e.treeStore,
449
- I,
450
- ({ nodes: i, edges: l }, a) => a ? jt(i, l, a) : []
451
- ), D = R(
446
+ c,
447
+ ({ nodes: i, edges: l }, f) => f ? Ut(i, l, f) : []
448
+ ), C = D(
452
449
  e.treeStore,
453
- I,
454
- ({ nodes: i, edges: l }, a) => a ? Wt(i, l, a) : [-1, -1]
455
- ), H = R(
450
+ c,
451
+ ({ nodes: i, edges: l }, f) => f ? Gt(i, l, f) : [-1, -1]
452
+ ), q = D(
456
453
  e.treeStore,
457
- I,
458
- ({ nodes: i, edges: l }, a) => a ? Ut(i, l, a) : [-1, -1]
459
- ), _ = Z.store(!1), W = ft(_, {
454
+ c,
455
+ ({ nodes: i, edges: l }, f) => f ? Wt(i, l, f) : [-1, -1]
456
+ ), L = tt.store(!1), W = lt(L, {
460
457
  open: () => !0,
461
458
  close: () => !1,
462
459
  toggle: (i) => !i,
463
460
  set: (i, l) => l
464
- }), wt = M(async () => {
461
+ }), xt = _(async () => {
465
462
  t.history.back({ experienceId: e.id });
466
- }), xt = B({
463
+ }), Nt = O({
467
464
  source: e.treeStore,
468
465
  effect: async (i, l) => {
469
- const a = i.nodes.find((h) => C(h) && h.stepId === l);
470
- a && t.history.push({ experienceId: e.id, node: a });
466
+ const f = i.nodes.find((h) => P(h) && h.stepId === l);
467
+ f && t.history.push({ experienceId: e.id, node: f });
471
468
  }
472
- }), tt = B({
473
- source: I,
469
+ }), et = O({
470
+ source: c,
474
471
  effect: (i) => {
475
472
  }
476
- }), q = B({
473
+ }), z = O({
477
474
  source: e.treeStore,
478
- effect: async ({ nodes: i }) => ht(i)
479
- }), z = B({
475
+ effect: async ({ nodes: i }) => wt(i)
476
+ }), X = O({
480
477
  source: e.treeStore,
481
- effect: async ({ nodes: i, edges: l }, a) => {
482
- if (Q(a))
483
- return Y(a, i, l);
478
+ effect: async ({ nodes: i, edges: l }, f) => {
479
+ if (Y(f))
480
+ return Z(f, i, l);
484
481
  }
485
- }), X = B({
482
+ }), J = O({
486
483
  source: e.treeStore,
487
- effect: async ({ nodes: i, edges: l, conditionals: a }, h) => {
484
+ effect: async ({ nodes: i, edges: l, conditionals: f }, h) => {
488
485
  if (!ct(h))
489
486
  return;
490
- const $ = a.find((O) => O.id === h.conditionalId);
491
- if (!$)
487
+ const B = f.find((A) => A.id === h.conditionalId);
488
+ if (!B)
492
489
  return;
493
- const k = h.id, x = await st(t, $.condition);
494
- return Gt(!!x, k, i, l);
490
+ const E = h.id, w = await at(t, B.condition);
491
+ return Kt(!!w, E, i, l);
495
492
  }
496
- }), et = B({
493
+ }), nt = O({
497
494
  source: e.treeStore,
498
- effect: async ({ nodes: i, edges: l }, a) => {
499
- if (!ut(a))
495
+ effect: async ({ nodes: i, edges: l }, f) => {
496
+ if (!ft(f))
500
497
  return;
501
- const h = a.action;
498
+ const h = f.action;
502
499
  if (!h) {
503
- E("warn", `Action node ${a.id} has no action name`);
500
+ I("warn", `Action node ${f.id} has no action name`);
504
501
  return;
505
502
  }
506
- const $ = t.actions.getByName(h).getState();
507
- if (!$) {
508
- E("warn", `Action '${h}' not registered on client`);
509
- const k = l.find(
510
- (x) => x.sourceNodeId === a.id && x.sourceNodeHandle === "false"
503
+ const B = t.actions.getByName(h).getState();
504
+ if (!B) {
505
+ I("warn", `Action '${h}' not registered on client`);
506
+ const E = l.find(
507
+ (w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
511
508
  );
512
- return k ? i.find((x) => x.id === k.destinationNodeId) : null;
509
+ return E ? i.find((w) => w.id === E.destinationNodeId) : null;
513
510
  }
514
- if (typeof $.action != "function") {
515
- E("warn", `Action '${h}' is not a function`);
516
- const k = l.find(
517
- (x) => x.sourceNodeId === a.id && x.sourceNodeHandle === "false"
511
+ if (typeof B.action != "function") {
512
+ I("warn", `Action '${h}' is not a function`);
513
+ const E = l.find(
514
+ (w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
518
515
  );
519
- return k ? i.find((x) => x.id === k.destinationNodeId) : null;
516
+ return E ? i.find((w) => w.id === E.destinationNodeId) : null;
520
517
  }
521
518
  try {
522
- E("info", `Executing action: ${h}`), await $.action(h);
523
- const k = l.find(
524
- (O) => O.sourceNodeId === a.id && O.sourceNodeHandle === "true"
519
+ I("info", `Executing action: ${h}`), await B.action(h);
520
+ const E = l.find(
521
+ (A) => A.sourceNodeId === f.id && A.sourceNodeHandle === "true"
525
522
  );
526
- if (!k)
527
- return E("warn", `No 'true' edge found for action node ${a.id}`), null;
528
- const x = i.find((O) => O.id === k.destinationNodeId);
529
- return E("info", `Action '${h}' succeeded, moving to node ${x?.id}`), x || null;
530
- } catch (k) {
531
- E("warn", `Action '${h}' failed:`, k);
532
- const x = l.find(
533
- (G) => G.sourceNodeId === a.id && G.sourceNodeHandle === "false"
523
+ if (!E)
524
+ return I("warn", `No 'true' edge found for action node ${f.id}`), null;
525
+ const w = i.find((A) => A.id === E.destinationNodeId);
526
+ return I("info", `Action '${h}' succeeded, moving to node ${w?.id}`), w || null;
527
+ } catch (E) {
528
+ I("warn", `Action '${h}' failed:`, E);
529
+ const w = l.find(
530
+ (G) => G.sourceNodeId === f.id && G.sourceNodeHandle === "false"
534
531
  );
535
- if (!x)
536
- return E("warn", `No 'false' edge found for action node ${a.id}`), null;
537
- const O = i.find((G) => G.id === x.destinationNodeId);
538
- return E("info", `Action '${h}' failed, moving to node ${O?.id}`), O || null;
532
+ if (!w)
533
+ return I("warn", `No 'false' edge found for action node ${f.id}`), null;
534
+ const A = i.find((G) => G.id === w.destinationNodeId);
535
+ return I("info", `Action '${h}' failed, moving to node ${A?.id}`), A || null;
539
536
  }
540
537
  }
541
- }), Nt = M((i) => {
542
- if (at(i))
543
- return t.launchExperienceById(i.experienceId);
544
- }), nt = B({
545
- source: [I, e.treeStore],
546
- effect: async ([i, { nodes: l, edges: a }]) => Y(i, l, a)
547
- }), j = B({
548
- source: [I, e.treeStore],
549
- effect: async ([i, { nodes: l, edges: a }]) => Y(i, l, a)
550
- }), Et = M((i) => {
538
+ }), It = _((i) => {
539
+ ut(i) && t.experiences.launch({ id: i.experienceId });
540
+ }), rt = O({
541
+ source: [c, e.treeStore],
542
+ effect: async ([i, { nodes: l, edges: f }]) => Z(i, l, f)
543
+ }), H = O({
544
+ source: [c, e.treeStore],
545
+ effect: async ([i, { nodes: l, edges: f }]) => Z(i, l, f)
546
+ }), Et = _((i) => {
551
547
  t.history.push({ experienceId: e.id, node: i });
552
- }), rt = B({
548
+ }), ot = O({
553
549
  source: e.configStore,
554
- effect: async ({ initializeOpenLogic: i }) => _t(i) ? !!await st(t, i) : i ?? !1
555
- }), T = Object.freeze({
550
+ effect: async ({ initializeOpenLogic: i }) => n?.initialiseOpen !== void 0 ? n.initialiseOpen : $t(i) ? !!await at(t, i) : i ?? !1
551
+ }), $ = Object.freeze({
556
552
  id: Math.random().toString(36).substring(7),
557
553
  // config
558
554
  experienceId: e.id,
559
555
  configStore: e.configStore,
560
556
  target: r,
561
- componentStore: m,
557
+ componentStore: b,
562
558
  // state
563
- stateStore: w,
559
+ stateStore: F,
564
560
  // open close
565
- isOpenStore: _,
561
+ isOpenStore: L,
566
562
  open: W.open,
567
563
  close: W.close,
568
564
  toggleOpen: W.toggle,
@@ -570,250 +566,254 @@ const Z = It("experience-instance"), Kt = lt(
570
566
  // nodes
571
567
  treeStore: e.treeStore,
572
568
  fieldsStore: e.fieldsStore,
573
- currentNodeStore: I,
574
- currentStepStore: f,
575
- previousStepStore: y,
576
- nextReachableStepNodesStore: A,
577
- stepsToOriginStore: D,
578
- stepsToLeafStore: H,
569
+ currentNodeStore: c,
570
+ currentStepStore: S,
571
+ previousStepStore: x,
572
+ nextReachableStepNodesStore: T,
573
+ stepsToOriginStore: C,
574
+ stepsToLeafStore: q,
579
575
  // history
580
- goToNextStep: s,
581
- goToPreviousStep: c,
582
- goToStepById: o,
583
- stepsHistoryStore: L
584
- }), J = b(), ot = b();
585
- return S({
586
- source: I,
587
- target: J
588
- }), S({
589
- clock: J,
576
+ goToNextStep: a,
577
+ goToPreviousStep: o,
578
+ goToStepById: u,
579
+ stepsHistoryStore: U
580
+ }), Q = k(), it = k();
581
+ return m({
582
+ source: c,
583
+ target: Q
584
+ }), m({
585
+ clock: Q,
590
586
  filter: (i) => i === null,
591
- target: q
592
- }), S({
593
- clock: J,
587
+ target: z
588
+ }), m({
589
+ clock: Q,
594
590
  filter: (i) => i !== null,
595
- target: ot
596
- }), kt({
597
- source: ot,
598
- match: (i) => ct(i) ? "condition" : C(i) ? "step" : at(i) ? "launchExperience" : Q(i) ? "origin" : ut(i) ? "action" : "other",
591
+ target: it
592
+ }), bt({
593
+ source: it,
594
+ match: (i) => ct(i) ? "condition" : P(i) ? "step" : ut(i) ? "launchExperience" : Y(i) ? "origin" : ft(i) ? "action" : "other",
599
595
  cases: {
600
- origin: z,
601
- condition: X,
602
- step: tt,
603
- launchExperience: Nt,
604
- action: et,
605
- __: b()
596
+ origin: X,
597
+ condition: J,
598
+ step: et,
599
+ launchExperience: It,
600
+ action: nt,
601
+ __: k()
606
602
  }
607
- }), S({
603
+ }), m({
608
604
  clock: [
605
+ J.doneData,
609
606
  X.doneData,
610
607
  z.doneData,
611
- q.doneData,
612
- j.doneData,
613
- nt.doneData,
614
- et.doneData
608
+ H.doneData,
609
+ rt.doneData,
610
+ nt.doneData
615
611
  ],
616
612
  filter: Boolean,
617
613
  target: Et
618
- }), S({
619
- clock: s,
620
- target: j
621
- }), S({
622
- clock: s,
623
- source: f,
614
+ }), m({
615
+ clock: a,
616
+ target: H
617
+ }), m({
618
+ clock: a,
619
+ source: S,
624
620
  filter: Boolean,
625
621
  target: t.eventBus.prepend((i) => ({
626
622
  type: "step_submit",
627
623
  step: i,
628
- experience: T
624
+ experience: $
629
625
  }))
630
- }), S({
631
- clock: j.done,
632
- source: f,
626
+ }), m({
627
+ clock: H.done,
628
+ source: S,
633
629
  filter: Boolean,
634
630
  target: t.eventBus.prepend((i) => ({
635
631
  type: "step_submit_success",
636
632
  step: i,
637
- experience: T
633
+ experience: $
638
634
  }))
639
- }), S({
640
- clock: j.fail,
641
- source: f,
635
+ }), m({
636
+ clock: H.fail,
637
+ source: S,
642
638
  filter: Boolean,
643
639
  target: t.eventBus.prepend((i) => ({
644
640
  type: "step_submit_error",
645
641
  step: i,
646
- experience: T
642
+ experience: $
647
643
  }))
648
- }), S({
649
- clock: c,
650
- target: wt
651
- }), S({ clock: o, target: xt }), S({
652
- source: R([
644
+ }), m({
645
+ clock: o,
646
+ target: xt
647
+ }), m({ clock: u, target: Nt }), m({
648
+ source: D([
649
+ J.pending,
653
650
  X.pending,
654
651
  z.pending,
655
- q.pending,
656
- j.pending
652
+ H.pending
657
653
  ]),
658
654
  fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
659
- target: w
660
- }), S({
661
- clock: tt.doneData,
662
- source: f,
655
+ target: F
656
+ }), m({
657
+ clock: et.doneData,
658
+ source: S,
663
659
  filter: Boolean,
664
660
  target: t.eventBus.prepend((i) => ({
665
661
  type: "step_enter",
666
662
  step: i,
667
- experience: T
663
+ experience: $
668
664
  }))
669
- }), S({
670
- clock: d,
671
- target: rt
672
- }), S({
673
- source: rt.doneData,
665
+ }), m({
666
+ clock: y,
667
+ target: ot
668
+ }), m({
669
+ source: ot.doneData,
674
670
  fn: Boolean,
675
- target: _
676
- }), S({
677
- source: I,
678
- clock: n,
679
- filter: (i) => i ? Q(i) : !0,
680
- target: nt
681
- }), S({
682
- source: _,
671
+ target: L
672
+ }), m({
673
+ source: c,
674
+ clock: s,
675
+ filter: (i) => i ? Y(i) : !0,
676
+ target: rt
677
+ }), m({
678
+ source: L,
683
679
  filter: Boolean,
684
- target: n
685
- }), S({
686
- source: _,
680
+ target: s
681
+ }), m({
682
+ source: L,
687
683
  filter: Boolean,
688
684
  target: t.eventBus.prepend(() => ({
689
685
  type: "experience_open",
690
- experience: T
686
+ experience: $
691
687
  }))
692
- }), S({
693
- source: _,
688
+ }), m({
689
+ source: L,
694
690
  filter: (i) => !i,
695
691
  target: t.eventBus.prepend(() => ({
696
692
  type: "experience_close",
697
- experience: T
693
+ experience: $
698
694
  }))
699
- }), S({
700
- clock: u,
701
- target: [d]
702
- }), u(), T;
695
+ }), m({
696
+ clock: d,
697
+ target: [y]
698
+ }), d(), $;
703
699
  }
704
700
  );
705
- function Vt(t) {
706
- return dt(Kt, t);
701
+ function qt(t) {
702
+ return pt(Vt, t);
707
703
  }
708
- const qt = lt(({ client: t }) => {
709
- const e = Z.store({}), r = b(), n = b(), s = b(), c = ft(e, {
710
- register(f, y) {
711
- const A = [
712
- ...f[y.experienceId] ?? []
704
+ const zt = dt(({ client: t }) => {
705
+ const e = tt.store({}), r = k(), n = k(), s = k(), a = lt(e, {
706
+ register(c, S) {
707
+ const x = [
708
+ ...c[S.experienceId] ?? []
713
709
  ];
714
- return A.push(y), {
715
- ...f,
716
- [y.experienceId]: A
710
+ return x.push(S), {
711
+ ...c,
712
+ [S.experienceId]: x
717
713
  };
718
714
  },
719
- unregister(f, y) {
720
- const A = y.experienceId, D = f[A]?.filter(
721
- (H) => H !== y
715
+ unregister(c, S) {
716
+ const x = S.experienceId, T = c[x]?.filter(
717
+ (C) => C !== S
722
718
  );
723
719
  return {
724
- ...f,
725
- [A]: D ?? []
720
+ ...c,
721
+ [x]: T ?? []
726
722
  };
727
723
  }
728
- }), o = M(
729
- ({ experience: f, target: y }) => Vt({ client: t, experience: f, target: y })
730
- ), u = M((f) => {
731
- c.register(f);
732
- }), d = M(
733
- (f) => {
734
- f.target && Lt(f.target, () => {
735
- s(f);
724
+ }), o = _(
725
+ ({
726
+ experience: c,
727
+ target: S,
728
+ options: x
729
+ }) => qt({ client: t, experience: c, target: S, options: x })
730
+ ), u = _((c) => {
731
+ a.register(c);
732
+ }), d = _(
733
+ (c) => {
734
+ c.target && Dt(c.target, () => {
735
+ s(c);
736
736
  });
737
737
  }
738
- ), m = M((f) => {
739
- c.unregister(f);
740
- }), w = M((f) => {
741
- const y = f.componentStore.getState();
742
- if (!y) {
743
- E("warn", "No app component registered. Skipping init.");
738
+ ), y = _((c) => {
739
+ a.unregister(c);
740
+ }), b = _((c) => {
741
+ const S = c.componentStore.getState();
742
+ if (!S) {
743
+ I("warn", "No app component registered. Skipping init.");
744
744
  return;
745
745
  }
746
- const A = y.frameworkStore.getState();
747
- if (!A) {
748
- E(
746
+ const x = S.frameworkStore.getState();
747
+ if (!x) {
748
+ I(
749
749
  "error",
750
- `No framework registered for component '${y.name}'. Skipping rendering.`
750
+ `No framework registered for component '${S.name}'. Skipping rendering.`
751
751
  );
752
752
  return;
753
753
  }
754
- const D = f.target;
755
- if (!D) {
756
- E(
754
+ const T = c.target;
755
+ if (!T) {
756
+ I(
757
757
  "error",
758
- `No target element registered for experience '${f.experienceId}'. Skipping rendering.`
758
+ `No target element registered for experience '${c.experienceId}'. Skipping rendering.`
759
759
  );
760
760
  return;
761
761
  }
762
- const H = Tt(D);
762
+ const C = Lt(T);
763
763
  try {
764
- A.render(H, y.component, t, f);
765
- } catch (_) {
766
- E("error", _);
764
+ x.render(C, S.component, t, c);
765
+ } catch (q) {
766
+ I("error", q);
767
767
  }
768
768
  });
769
- S({
769
+ m({
770
770
  clock: r,
771
771
  target: o
772
- }), S({
772
+ }), m({
773
773
  clock: s,
774
- target: m
775
- }), S({
774
+ target: y
775
+ }), m({
776
776
  clock: o.doneData,
777
777
  target: [
778
778
  u,
779
779
  d,
780
780
  n
781
781
  ]
782
- }), S({
782
+ }), m({
783
783
  clock: o.doneData,
784
- target: t.eventBus.prepend((f) => ({
784
+ target: t.eventBus.prepend((c) => ({
785
785
  type: "experience_initialize",
786
- experience: f
786
+ experience: c
787
787
  }))
788
- }), S({
788
+ }), m({
789
789
  clock: n,
790
- target: w
790
+ target: b
791
791
  });
792
- function F(f, y) {
793
- r({ experience: f, target: y });
792
+ function F(c, S, x) {
793
+ r({ experience: c, target: S, options: x });
794
794
  }
795
- const L = e.map((f) => Object.values(f).flat());
796
- function I(f) {
797
- return e.map((y) => y[f] || [], { skipVoid: !1 });
795
+ const M = e.map((c) => Object.values(c).flat());
796
+ function U(c) {
797
+ return e.map((S) => S[c] || [], { skipVoid: !1 });
798
798
  }
799
799
  return {
800
800
  spawn: F,
801
- getByExperienceId: I,
802
- listStore: L
801
+ getByExperienceId: U,
802
+ listStore: M
803
803
  };
804
804
  });
805
- function re(t) {
806
- return dt(qt, t);
805
+ function oe(t) {
806
+ return pt(zt, t);
807
807
  }
808
808
  export {
809
- C as a,
810
- re as b,
811
- ee as c,
812
- Zt as d,
813
- st as e,
814
- Pt as f,
815
- te as g,
816
- Vt as h,
817
- _t as i,
818
- ne as t
809
+ P as a,
810
+ oe as b,
811
+ ne as c,
812
+ te as d,
813
+ at as e,
814
+ Ct as f,
815
+ ee as g,
816
+ qt as h,
817
+ $t as i,
818
+ re as t
819
819
  };