@picked/client 0.0.1-dev.1773804563218 → 0.0.1-dev.1773807602703

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