@picked/client 0.0.1-dev.1769473835566 → 0.0.1-dev.1769486944066

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 (33) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/cjs/plugins/create-experience/index.js +1 -1
  3. package/dist/cjs/plugins/data-layer/index.js +1 -0
  4. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  5. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/esm/index.js +270 -997
  8. package/dist/esm/plugins/create-experience/index.js +251 -255
  9. package/dist/esm/plugins/data-layer/index.js +198 -0
  10. package/dist/esm/plugins/responses-browser-storage/index.js +23 -25
  11. package/dist/esm/plugins/responses-indexeddb/index.js +49 -67
  12. package/dist/esm/plugins/single-page-app/index.js +3 -3
  13. package/dist/esm/plugins/web-components/index.js +1 -1
  14. package/dist/esm/plugins/window-object/index.js +1 -1
  15. package/dist/esm/server/index.js +19 -19
  16. package/dist/experience-instance-CsMhH0DN.cjs +1 -0
  17. package/dist/{experience-instance-Bg6BWuwI.js → experience-instance-DJCJUe0h.js} +227 -218
  18. package/dist/{supports-BjhuLJ8z.js → supports-DCSoenK6.js} +11 -11
  19. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  20. package/dist/types/plugins/data-layer/custom-event.d.ts +5 -0
  21. package/dist/types/plugins/data-layer/custom-event.d.ts.map +1 -0
  22. package/dist/types/plugins/data-layer/index.d.ts +2 -0
  23. package/dist/types/plugins/data-layer/index.d.ts.map +1 -0
  24. package/dist/types/plugins/data-layer/plugin.d.ts +55 -0
  25. package/dist/types/plugins/data-layer/plugin.d.ts.map +1 -0
  26. package/dist/types/plugins/data-layer/utils.d.ts +39 -0
  27. package/dist/types/plugins/data-layer/utils.d.ts.map +1 -0
  28. package/dist/types/utils/events.d.ts +7 -1
  29. package/dist/types/utils/events.d.ts.map +1 -1
  30. package/dist/user-session-DQh0BBTx.cjs +1 -0
  31. package/dist/user-session-XidjAPGf.js +747 -0
  32. package/package.json +11 -5
  33. package/dist/experience-instance-DBi45xr9.cjs +0 -1
@@ -1,9 +1,9 @@
1
- import { createDomain as ht, createEvent as O, combine as C, createApi as ot, createEffect as M, attach as F, split as yt, sample as m } from "effector";
2
- import { createFactory as it, invoke as st } from "@withease/factories";
3
- import { i as wt, s as at, a as Nt } from "./supports-BjhuLJ8z.js";
4
- import { l as I } from "./logger-C9a75KZn.js";
5
- import { i as It } from "./object-JwZ58NOH.js";
6
- function xt(t) {
1
+ import { createDomain as xt, createEvent as k, combine as C, createApi as ct, createEffect as $, attach as F, sample as m, split as It } from "effector";
2
+ import { createFactory as ut, invoke as ft } from "@withease/factories";
3
+ import { h as Et, s as lt, a as kt } from "./supports-DCSoenK6.js";
4
+ import { l as x } from "./logger-C9a75KZn.js";
5
+ import { i as At } from "./object-JwZ58NOH.js";
6
+ function bt(t) {
7
7
  return typeof t == "number" && !isNaN(t);
8
8
  }
9
9
  function H(t) {
@@ -12,21 +12,21 @@ function H(t) {
12
12
  function N(t) {
13
13
  return Array.isArray(t);
14
14
  }
15
- function ct(t) {
15
+ function dt(t) {
16
16
  return t instanceof Promise;
17
17
  }
18
- function tt(t) {
18
+ function rt(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 (xt(t)) return t;
22
+ if (bt(t)) return t;
23
23
  const e = parseFloat(`${t}`);
24
24
  return isNaN(e) ? 0 : e;
25
25
  }
26
26
  function D(t) {
27
27
  return `${t}`;
28
28
  }
29
- const Et = {
29
+ const vt = {
30
30
  // eslint-disable-next-line eqeqeq
31
31
  "==": (t, e) => t == e,
32
32
  "===": (t, e) => t === e,
@@ -47,8 +47,8 @@ const Et = {
47
47
  const a = g(r);
48
48
  return n <= s && s <= a;
49
49
  },
50
- "!!": async (t) => await B(t),
51
- "!": async (t) => !await B(t),
50
+ "!!": async (t) => await O(t),
51
+ "!": async (t) => !await O(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),
@@ -142,31 +142,31 @@ const Et = {
142
142
  };
143
143
  async function p(t, e) {
144
144
  if (!t) return t;
145
- if (ct(t))
145
+ if (dt(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 (!tt(t)) return t;
150
- const r = kt(t);
149
+ if (!rt(t)) return t;
150
+ const r = Ot(t);
151
151
  let n = r ? t[r] ?? [] : [];
152
152
  switch (N(n) || (n = [n]), r) {
153
153
  case "if":
154
154
  case "?:":
155
155
  for (let o = 0; o < n.length - 1; o += 2)
156
- if (await B(await p(n[o], e)))
156
+ if (await O(await p(n[o], e)))
157
157
  return p(n[o + 1], e);
158
158
  return n.length % 2 === 1 ? p(n[n.length - 1], e) : null;
159
159
  case "and": {
160
160
  let o = null;
161
161
  for (const c of n)
162
- if (o = await p(c, e), !await B(o))
162
+ if (o = await p(c, e), !await O(o))
163
163
  return o;
164
164
  return o;
165
165
  }
166
166
  case "or": {
167
167
  let o = null;
168
168
  for (const c of n)
169
- if (o = await p(c, e), await B(o)) return o;
169
+ if (o = await p(c, e), await O(o)) return o;
170
170
  return o;
171
171
  }
172
172
  case "map": {
@@ -177,7 +177,7 @@ 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 S = await B(await p(n[1], d));
180
+ const S = await O(await p(n[1], d));
181
181
  return { item: d, shouldInclude: S };
182
182
  })
183
183
  )).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
@@ -188,52 +188,52 @@ async function p(t, e) {
188
188
  return n.length > 2 ? await p(n[2], e) : null;
189
189
  const c = n[1];
190
190
  let S = n.length > 2 ? await p(n[2], e) : null;
191
- for (const k of o)
192
- S = await p(c, { current: k, accumulator: S });
191
+ for (const A of o)
192
+ S = await p(c, { current: A, accumulator: S });
193
193
  return S;
194
194
  }
195
195
  case "all": {
196
196
  const o = await p(n[0], e);
197
197
  if (!N(o) || o.length === 0) return !1;
198
198
  for (const c of o)
199
- if (!await B(await p(n[1], c))) return !1;
199
+ if (!await O(await p(n[1], c))) return !1;
200
200
  return !0;
201
201
  }
202
202
  case "some": {
203
203
  const o = await p(n[0], e);
204
204
  if (!N(o)) return !1;
205
205
  for (const c of o)
206
- if (await B(await p(n[1], c))) return !0;
206
+ if (await O(await p(n[1], c))) return !0;
207
207
  return !1;
208
208
  }
209
209
  case "none": {
210
210
  const o = await p(n[0], e);
211
211
  if (!N(o)) return !0;
212
212
  for (const c of o)
213
- if (await B(await p(n[1], c))) return !1;
213
+ if (await O(await p(n[1], c))) return !1;
214
214
  return !0;
215
215
  }
216
216
  case "catch":
217
217
  try {
218
218
  return await p(n[0], e);
219
219
  } catch (o) {
220
- return tt(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
220
+ return rt(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))), a = r ? Et[r] : void 0;
223
+ const s = await Promise.all(n.map((o) => p(o, e))), a = r ? vt[r] : void 0;
224
224
  if (!a) throw new Error(`Unrecognized operation ${r}`);
225
225
  return a.apply(e, s);
226
226
  }
227
- async function B(t) {
228
- return ct(t) ? B(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
227
+ async function O(t) {
228
+ return dt(t) ? O(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
229
229
  }
230
- function kt(t) {
230
+ function Ot(t) {
231
231
  return Object.keys(t)[0];
232
232
  }
233
- function At(t) {
234
- return !It(t);
233
+ function Bt(t) {
234
+ return !At(t);
235
235
  }
236
- async function et(t, e, r) {
236
+ async function ot(t, e, r) {
237
237
  const n = t.getStateSnapshot(), s = t.predicates.listStore.getState().reduce((c, d) => ({
238
238
  ...c,
239
239
  [d.name]: (...S) => d.predicate({ ...n, args: S })
@@ -262,44 +262,44 @@ async function et(t, e, r) {
262
262
  };
263
263
  return await p(e, o);
264
264
  }
265
- function bt(t) {
266
- return !Nt() || !at() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
265
+ function Ft(t) {
266
+ return !kt() || !lt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
267
267
  (e) => e instanceof HTMLElement
268
268
  );
269
269
  }
270
- const vt = "open";
271
- function Ot(t) {
272
- if (!wt())
270
+ const _t = "open";
271
+ function $t(t) {
272
+ if (!Et())
273
273
  throw new Error("Shadow DOM is not supported in this environment");
274
- return t.attachShadow({ mode: vt });
274
+ return t.attachShadow({ mode: _t });
275
275
  }
276
- function zt() {
276
+ function Qt() {
277
277
  return new Promise((t, e) => {
278
- if (!at()) {
278
+ if (!lt()) {
279
279
  e();
280
280
  return;
281
281
  }
282
282
  document.readyState !== "loading" ? t() : document.addEventListener("readystatechange", () => t(), { once: !0 });
283
283
  });
284
284
  }
285
- function Bt(t, e) {
285
+ function Mt(t, e) {
286
286
  const r = new MutationObserver((n) => {
287
287
  document.contains(t) || (r.disconnect(), e());
288
288
  });
289
289
  r.observe(document.body, { childList: !0, subtree: !0 });
290
290
  }
291
- const G = "picked-root", K = "picked-target", Ft = "picked-root";
292
- function Jt(t, e) {
291
+ const W = "picked-root", G = "picked-target", Tt = "picked-root";
292
+ function Yt(t, e) {
293
293
  return [
294
294
  ...t,
295
295
  // Target and replace picked-root web components
296
296
  {
297
- selector: `${Ft}[experience-id="${e}"]`,
297
+ selector: `${Tt}[experience-id="${e}"]`,
298
298
  placement: "replace"
299
299
  }
300
300
  ].flatMap((n) => {
301
- const s = bt(n.selector).filter(
302
- (a) => !_t(a, e) && !$t(a, e)
301
+ const s = Ft(n.selector).filter(
302
+ (a) => !Lt(a, e) && !Dt(a, e)
303
303
  );
304
304
  return {
305
305
  ...n,
@@ -307,25 +307,25 @@ function Jt(t, e) {
307
307
  };
308
308
  });
309
309
  }
310
- function Qt(t, e) {
311
- return t.flatMap((r) => r.elements.map((n) => Tt(n, r.placement, e)));
310
+ function Zt(t, e) {
311
+ return t.flatMap((r) => r.elements.map((n) => Pt(n, r.placement, e)));
312
312
  }
313
- function Yt(t, e) {
314
- t.classList.add(K), t.classList.add(`${K}-${e}`);
313
+ function te(t, e) {
314
+ t.classList.add(G), t.classList.add(`${G}-${e}`);
315
315
  }
316
- function _t(t, e) {
317
- return e ? t.classList.contains(`${K}-${e}`) : t.classList.contains(`${K}`);
316
+ function Lt(t, e) {
317
+ return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(`${G}`);
318
318
  }
319
- function $t(t, e) {
320
- return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(G);
319
+ function Dt(t, e) {
320
+ return e ? t.classList.contains(`${W}-${e}`) : t.classList.contains(W);
321
321
  }
322
- function Mt(t) {
322
+ function Rt(t) {
323
323
  const e = document.createElement("div");
324
- return e.style.display = "block", e.classList.add(G), e.classList.add(`${G}-${t}`), e;
324
+ return e.style.display = "block", e.classList.add(W), e.classList.add(`${W}-${t}`), e;
325
325
  }
326
- function Tt(t, e, r) {
326
+ function Pt(t, e, r) {
327
327
  let n;
328
- const s = Mt(r);
328
+ const s = Rt(r);
329
329
  if (t instanceof Document)
330
330
  n = t.body.appendChild(s);
331
331
  else {
@@ -350,25 +350,25 @@ function Tt(t, e, r) {
350
350
  }
351
351
  return n;
352
352
  }
353
- function Lt(t) {
353
+ function it(t) {
354
354
  return t.type === "conditional";
355
355
  }
356
356
  function j(t) {
357
357
  return t.type === "step";
358
358
  }
359
- function Dt(t) {
359
+ function st(t) {
360
360
  return t.type === "experience";
361
361
  }
362
- function nt(t) {
362
+ function z(t) {
363
363
  return t.type === "origin";
364
364
  }
365
- function rt(t) {
365
+ function at(t) {
366
366
  return t.type === "action";
367
367
  }
368
- const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), j(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
368
+ const pt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), j(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
369
369
  const c = t.find((d) => d.id === o.destinationNodeId);
370
- return c ? ut(t, e, c, !1, s) : [];
371
- })), Rt = (t, e, r) => ut(t, e, r, !0, /* @__PURE__ */ new Set()), ft = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
370
+ return c ? pt(t, e, c, !1, s) : [];
371
+ })), Ct = (t, e, r) => pt(t, e, r, !0, /* @__PURE__ */ new Set()), gt = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
372
372
  if (s.has(r.id)) return [-1, -1];
373
373
  s.add(r.id);
374
374
  const a = e.filter((d) => d.sourceNodeId === r.id);
@@ -377,17 +377,17 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
377
377
  for (const d of a) {
378
378
  const S = t.find((R) => R.id === d.destinationNodeId);
379
379
  if (!S) continue;
380
- const [k, _] = ft(
380
+ const [A, _] = gt(
381
381
  t,
382
382
  e,
383
383
  S,
384
384
  !1,
385
385
  new Set(s)
386
386
  );
387
- k !== -1 && (o = Math.min(o, k + 1), c = Math.max(c, _ + 1));
387
+ A !== -1 && (o = Math.min(o, A + 1), c = Math.max(c, _ + 1));
388
388
  }
389
389
  return o === 1 / 0 ? [-1, -1] : [o, c];
390
- }, Pt = (t, e, r) => ft(t, e, r, !0, /* @__PURE__ */ new Set()), lt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
390
+ }, Ht = (t, e, r) => gt(t, e, r, !0, /* @__PURE__ */ new Set()), mt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
391
391
  if (n.has(r.id)) return [-1, -1];
392
392
  if (n.add(r.id), r.type === "origin") return [0, 0];
393
393
  const s = e.filter((c) => c.destinationNodeId === r.id);
@@ -396,172 +396,182 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
396
396
  for (const c of s) {
397
397
  const d = t.find((_) => _.id === c.sourceNodeId);
398
398
  if (!d) continue;
399
- const [S, k] = lt(
399
+ const [S, A] = mt(
400
400
  t,
401
401
  e,
402
402
  d,
403
403
  new Set(n)
404
404
  );
405
- S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o, k + 1));
405
+ S !== -1 && (a = Math.min(a, S + 1), o = Math.max(o, A + 1));
406
406
  }
407
407
  return a === 1 / 0 ? [-1, -1] : [a, o];
408
- }, Ct = (t, e, r) => lt(t, e, r, /* @__PURE__ */ new Set()), dt = (t) => t.find((r) => r.type === "origin") || null, X = (t, e, r) => {
408
+ }, jt = (t, e, r) => mt(t, e, r, /* @__PURE__ */ new Set()), St = (t) => t.find((r) => r.type === "origin") || null, J = (t, e, r) => {
409
409
  if (!t)
410
- return dt(e);
410
+ return St(e);
411
411
  const n = r.find((a) => a.sourceNodeId === t.id);
412
412
  if (!n)
413
413
  return null;
414
414
  const s = e.find((a) => a.id === n.destinationNodeId);
415
415
  return s || null;
416
416
  };
417
- async function Ht(t, e, r, n) {
417
+ async function Ut(t, e, r, n) {
418
418
  const s = t ? "true" : "false", a = n.find(
419
419
  (o) => o.sourceNodeHandle === s && o.sourceNodeId === e
420
420
  );
421
- return r.find((o) => o.id === (a == null ? void 0 : a.destinationNodeId));
421
+ return r.find((o) => o.id === a?.destinationNodeId);
422
422
  }
423
- const z = ht("experience-instance"), jt = it(
423
+ const Q = xt("experience-instance"), Wt = ut(
424
424
  ({
425
425
  client: t,
426
426
  experience: e,
427
427
  target: r
428
428
  }) => {
429
- const n = O(), s = O(), a = O(), o = O(), c = O(), d = O(), S = e.componentStore, k = z.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((f) => f.experienceId === e.id)), R = _.map((i) => i.filter((f) => j(f.node))), x = _.map((i) => {
430
- var f;
431
- return ((f = i[i.length - 1]) == null ? void 0 : f.node) || null;
432
- }), u = C(
429
+ const n = k(), s = k(), a = k(), o = k(), c = k(), d = k(), S = e.componentStore, A = Q.store("transitioning"), _ = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), R = _.map((i) => i.filter((l) => j(l.node))), I = _.map((i) => i[i.length - 1]?.node || null), u = C(
433
430
  e.treeStore,
434
- x,
435
- ({ steps: i }, f) => i.find((l) => f && j(f) && l.id === f.stepId) || null
431
+ I,
432
+ ({ steps: i }, l) => i.find((f) => l && j(l) && f.id === l.stepId) || null
436
433
  ), h = C(
437
434
  e.treeStore,
438
- x,
439
- ({ nodes: i, edges: f }, l) => l ? Rt(i, f, l) : []
440
- ), v = C(
435
+ I,
436
+ ({ nodes: i, edges: l }, f) => f ? Ct(i, l, f) : []
437
+ ), b = C(
441
438
  e.treeStore,
442
- x,
443
- ({ nodes: i, edges: f }, l) => l ? Ct(i, f, l) : [-1, -1]
444
- ), T = C(
439
+ I,
440
+ ({ nodes: i, edges: l }, f) => f ? jt(i, l, f) : [-1, -1]
441
+ ), M = C(
445
442
  e.treeStore,
446
- x,
447
- ({ nodes: i, edges: f }, l) => l ? Pt(i, f, l) : [-1, -1]
448
- ), A = z.store(!1), $ = ot(A, {
443
+ I,
444
+ ({ nodes: i, edges: l }, f) => f ? Ht(i, l, f) : [-1, -1]
445
+ ), v = Q.store(!1), T = ct(v, {
449
446
  open: () => !0,
450
447
  close: () => !1,
451
448
  toggle: (i) => !i,
452
- set: (i, f) => f
453
- }), pt = M(async () => {
449
+ set: (i, l) => l
450
+ }), ht = $(async () => {
454
451
  t.history.back({ experienceId: e.id });
455
- }), gt = F({
452
+ }), yt = F({
456
453
  source: e.treeStore,
457
- effect: async (i, f) => {
458
- const l = i.nodes.find((w) => j(w) && w.stepId === f);
459
- l && t.history.push({ experienceId: e.id, node: l });
454
+ effect: async (i, l) => {
455
+ const f = i.nodes.find((w) => j(w) && w.stepId === l);
456
+ f && t.history.push({ experienceId: e.id, node: f });
460
457
  }
461
- }), J = F({
462
- source: x,
458
+ }), Y = F({
459
+ source: I,
463
460
  effect: (i) => {
464
461
  }
465
- }), U = F({
462
+ }), K = F({
466
463
  source: e.treeStore,
467
- effect: async ({ nodes: i }) => dt(i)
464
+ effect: async ({ nodes: i }) => St(i)
468
465
  }), V = F({
469
466
  source: e.treeStore,
470
- effect: async ({ nodes: i, edges: f }, l) => X(l, i, f)
467
+ effect: async ({ nodes: i, edges: l }, f) => {
468
+ if (z(f))
469
+ return J(f, i, l);
470
+ }
471
471
  }), q = F({
472
472
  source: e.treeStore,
473
- effect: async ({ nodes: i, edges: f, conditionals: l }, w) => {
474
- if (!w)
473
+ effect: async ({ nodes: i, edges: l, conditionals: f }, w) => {
474
+ if (!it(w))
475
475
  return;
476
- const L = l.find((b) => b.id === w.conditionalId);
476
+ const L = f.find((B) => B.id === w.conditionalId);
477
477
  if (!L)
478
478
  return;
479
- const E = w.id, y = await et(t, L.condition);
480
- return Ht(!!y, E, i, f);
479
+ const E = w.id, y = await ot(t, L.condition);
480
+ return Ut(!!y, E, i, l);
481
481
  }
482
- }), Q = F({
482
+ }), Z = F({
483
483
  source: e.treeStore,
484
- effect: async ({ nodes: i, edges: f }, l) => {
485
- if (!l || !rt(l))
484
+ effect: async ({ nodes: i, edges: l }, f) => {
485
+ if (!at(f))
486
486
  return;
487
- const w = l.action;
487
+ const w = f.action;
488
488
  if (!w) {
489
- I("warn", `Action node ${l.id} has no action name`);
489
+ x("warn", `Action node ${f.id} has no action name`);
490
490
  return;
491
491
  }
492
492
  const L = t.actions.getByName(w).getState();
493
493
  if (!L) {
494
- I("warn", `Action '${w}' not registered on client`);
495
- const E = f.find(
496
- (y) => y.sourceNodeId === l.id && y.sourceNodeHandle === "false"
494
+ x("warn", `Action '${w}' not registered on client`);
495
+ const E = l.find(
496
+ (y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
497
497
  );
498
498
  return E ? i.find((y) => y.id === E.destinationNodeId) : null;
499
499
  }
500
500
  if (typeof L.action != "function") {
501
- I("warn", `Action '${w}' is not a function`);
502
- const E = f.find(
503
- (y) => y.sourceNodeId === l.id && y.sourceNodeHandle === "false"
501
+ x("warn", `Action '${w}' is not a function`);
502
+ const E = l.find(
503
+ (y) => y.sourceNodeId === f.id && y.sourceNodeHandle === "false"
504
504
  );
505
505
  return E ? i.find((y) => y.id === E.destinationNodeId) : null;
506
506
  }
507
507
  try {
508
- I("info", `Executing action: ${w}`), await L.action(w);
509
- const E = f.find(
510
- (b) => b.sourceNodeId === l.id && b.sourceNodeHandle === "true"
508
+ x("info", `Executing action: ${w}`), await L.action(w);
509
+ const E = l.find(
510
+ (B) => B.sourceNodeId === f.id && B.sourceNodeHandle === "true"
511
511
  );
512
512
  if (!E)
513
- return I("warn", `No 'true' edge found for action node ${l.id}`), null;
514
- const y = i.find((b) => b.id === E.destinationNodeId);
515
- return I("info", `Action '${w}' succeeded, moving to node ${y == null ? void 0 : y.id}`), y || null;
513
+ return x("warn", `No 'true' edge found for action node ${f.id}`), null;
514
+ const y = i.find((B) => B.id === E.destinationNodeId);
515
+ return x("info", `Action '${w}' succeeded, moving to node ${y?.id}`), y || null;
516
516
  } catch (E) {
517
- I("warn", `Action '${w}' failed:`, E);
518
- const y = f.find(
519
- (W) => W.sourceNodeId === l.id && W.sourceNodeHandle === "false"
517
+ x("warn", `Action '${w}' failed:`, E);
518
+ const y = l.find(
519
+ (U) => U.sourceNodeId === f.id && U.sourceNodeHandle === "false"
520
520
  );
521
521
  if (!y)
522
- return I("warn", `No 'false' edge found for action node ${l.id}`), null;
523
- const b = i.find((W) => W.id === y.destinationNodeId);
524
- return I("info", `Action '${w}' failed, moving to node ${b == null ? void 0 : b.id}`), b || null;
522
+ return x("warn", `No 'false' edge found for action node ${f.id}`), null;
523
+ const B = i.find((U) => U.id === y.destinationNodeId);
524
+ return x("info", `Action '${w}' failed, moving to node ${B?.id}`), B || null;
525
525
  }
526
526
  }
527
- }), mt = M((i) => {
528
- if (i)
527
+ }), wt = $((i) => {
528
+ if (st(i))
529
529
  return t.launchExperienceById(i.experienceId);
530
- }), Y = F({
531
- source: [x, e.treeStore],
532
- effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
530
+ }), tt = F({
531
+ source: [I, e.treeStore],
532
+ effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
533
533
  }), P = F({
534
- source: [x, e.treeStore],
535
- effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
536
- }), St = M((i) => {
534
+ source: [I, e.treeStore],
535
+ effect: async ([i, { nodes: l, edges: f }]) => J(i, l, f)
536
+ }), Nt = $((i) => {
537
537
  t.history.push({ experienceId: e.id, node: i });
538
- }), Z = F({
538
+ }), et = F({
539
539
  source: e.configStore,
540
- effect: async ({ initializeOpenLogic: i }) => At(i) ? !!await et(t, i) : i ?? !1
541
- });
542
- return yt({
543
- source: x,
544
- match: (i) => i ? Lt(i) ? "condition" : j(i) ? "step" : Dt(i) ? "launchExperience" : nt(i) ? "origin" : rt(i) ? "action" : "other" : "none",
540
+ effect: async ({ initializeOpenLogic: i }) => Bt(i) ? !!await ot(t, i) : i ?? !1
541
+ }), X = k(), nt = k();
542
+ return m({
543
+ source: I,
544
+ target: X
545
+ }), m({
546
+ clock: X,
547
+ filter: (i) => i === null,
548
+ target: K
549
+ }), m({
550
+ clock: X,
551
+ filter: (i) => i !== null,
552
+ target: nt
553
+ }), It({
554
+ source: nt,
555
+ match: (i) => it(i) ? "condition" : j(i) ? "step" : st(i) ? "launchExperience" : z(i) ? "origin" : at(i) ? "action" : "other",
545
556
  cases: {
546
- none: U,
547
557
  origin: V,
548
558
  condition: q,
549
- step: J,
550
- launchExperience: mt,
551
- action: Q,
552
- __: O()
559
+ step: Y,
560
+ launchExperience: wt,
561
+ action: Z,
562
+ __: k()
553
563
  }
554
564
  }), m({
555
565
  clock: [
556
566
  q.doneData,
557
567
  V.doneData,
558
- U.doneData,
568
+ K.doneData,
559
569
  P.doneData,
560
- Y.doneData,
561
- Q.doneData
570
+ tt.doneData,
571
+ Z.doneData
562
572
  ],
563
573
  filter: Boolean,
564
- target: St
574
+ target: Nt
565
575
  }), m({
566
576
  clock: s,
567
577
  target: P
@@ -594,18 +604,18 @@ const z = ht("experience-instance"), jt = it(
594
604
  }))
595
605
  }), m({
596
606
  clock: a,
597
- target: pt
598
- }), m({ clock: o, target: gt }), m({
607
+ target: ht
608
+ }), m({ clock: o, target: yt }), m({
599
609
  source: C([
600
610
  q.pending,
601
611
  V.pending,
602
- U.pending,
612
+ K.pending,
603
613
  P.pending
604
614
  ]),
605
615
  fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
606
- target: k
616
+ target: A
607
617
  }), m({
608
- clock: J.doneData,
618
+ clock: Y.doneData,
609
619
  source: u,
610
620
  filter: Boolean,
611
621
  target: t.eventBus.prepend((i) => ({
@@ -615,29 +625,29 @@ const z = ht("experience-instance"), jt = it(
615
625
  }))
616
626
  }), m({
617
627
  clock: d,
618
- target: Z
628
+ target: et
619
629
  }), m({
620
- source: Z.doneData,
630
+ source: et.doneData,
621
631
  fn: Boolean,
622
- target: A
632
+ target: v
623
633
  }), m({
624
- source: x,
634
+ source: I,
625
635
  clock: n,
626
- filter: (i) => i ? nt(i) : !0,
627
- target: Y
636
+ filter: (i) => i ? z(i) : !0,
637
+ target: tt
628
638
  }), m({
629
- source: A,
639
+ source: v,
630
640
  filter: Boolean,
631
641
  target: n
632
642
  }), m({
633
- source: A,
643
+ source: v,
634
644
  filter: Boolean,
635
645
  target: t.eventBus.prepend(() => ({
636
646
  type: "experience_open",
637
647
  experience: e
638
648
  }))
639
649
  }), m({
640
- source: A,
650
+ source: v,
641
651
  filter: (i) => !i,
642
652
  target: t.eventBus.prepend(() => ({
643
653
  type: "experience_close",
@@ -654,20 +664,20 @@ const z = ht("experience-instance"), jt = it(
654
664
  target: r,
655
665
  componentStore: S,
656
666
  // state
657
- stateStore: k,
667
+ stateStore: A,
658
668
  // open close
659
- isOpenStore: A,
660
- open: $.open,
661
- close: $.close,
662
- toggleOpen: $.toggle,
663
- setOpen: $.set,
669
+ isOpenStore: v,
670
+ open: T.open,
671
+ close: T.close,
672
+ toggleOpen: T.toggle,
673
+ setOpen: T.set,
664
674
  // nodes
665
675
  treeStore: e.treeStore,
666
- currentNodeStore: x,
676
+ currentNodeStore: I,
667
677
  currentStepStore: u,
668
678
  nextReachableStepNodesStore: h,
669
- stepsToOriginStore: v,
670
- stepsToLeafStore: T,
679
+ stepsToOriginStore: b,
680
+ stepsToLeafStore: M,
671
681
  // history
672
682
  goToNextStep: s,
673
683
  goToPreviousStep: a,
@@ -676,69 +686,68 @@ const z = ht("experience-instance"), jt = it(
676
686
  };
677
687
  }
678
688
  );
679
- function Wt(t) {
680
- return st(jt, t);
689
+ function Gt(t) {
690
+ return ft(Wt, t);
681
691
  }
682
- const Gt = it(({ client: t }) => {
683
- const e = z.store({}), r = O(), n = O(), s = O(), a = ot(e, {
692
+ const Kt = ut(({ client: t }) => {
693
+ const e = Q.store({}), r = k(), n = k(), s = k(), a = ct(e, {
684
694
  register(u, h) {
685
- const v = [
695
+ const b = [
686
696
  ...u[h.experienceId] ?? []
687
697
  ];
688
- return v.push(h), {
698
+ return b.push(h), {
689
699
  ...u,
690
- [h.experienceId]: v
700
+ [h.experienceId]: b
691
701
  };
692
702
  },
693
703
  unregister(u, h) {
694
- var A;
695
- const v = h.experienceId, T = (A = u[v]) == null ? void 0 : A.filter(
696
- ($) => $ !== h
704
+ const b = h.experienceId, M = u[b]?.filter(
705
+ (v) => v !== h
697
706
  );
698
707
  return {
699
708
  ...u,
700
- [v]: T ?? []
709
+ [b]: M ?? []
701
710
  };
702
711
  }
703
- }), o = M(
704
- ({ experience: u, target: h }) => Wt({ client: t, experience: u, target: h })
705
- ), c = M((u) => {
712
+ }), o = $(
713
+ ({ experience: u, target: h }) => Gt({ client: t, experience: u, target: h })
714
+ ), c = $((u) => {
706
715
  a.register(u);
707
- }), d = M(
716
+ }), d = $(
708
717
  (u) => {
709
- u.target && Bt(u.target, () => {
718
+ u.target && Mt(u.target, () => {
710
719
  s(u);
711
720
  });
712
721
  }
713
- ), S = M((u) => {
722
+ ), S = $((u) => {
714
723
  a.unregister(u);
715
- }), k = M((u) => {
724
+ }), A = $((u) => {
716
725
  const h = u.componentStore.getState();
717
726
  if (!h) {
718
- I("warn", "No app component registered. Skipping init.");
727
+ x("warn", "No app component registered. Skipping init.");
719
728
  return;
720
729
  }
721
- const v = h.frameworkStore.getState();
722
- if (!v) {
723
- I(
730
+ const b = h.frameworkStore.getState();
731
+ if (!b) {
732
+ x(
724
733
  "error",
725
734
  `No framework registered for component '${h.name}'. Skipping rendering.`
726
735
  );
727
736
  return;
728
737
  }
729
- const T = u.target;
730
- if (!T) {
731
- I(
738
+ const M = u.target;
739
+ if (!M) {
740
+ x(
732
741
  "error",
733
742
  `No target element registered for experience '${u.experienceId}'. Skipping rendering.`
734
743
  );
735
744
  return;
736
745
  }
737
- const A = Ot(T);
746
+ const v = $t(M);
738
747
  try {
739
- v.render(A, h.component, t, u);
740
- } catch ($) {
741
- I("error", $);
748
+ b.render(v, h.component, t, u);
749
+ } catch (T) {
750
+ x("error", T);
742
751
  }
743
752
  });
744
753
  m({
@@ -762,33 +771,33 @@ const Gt = it(({ client: t }) => {
762
771
  }))
763
772
  }), m({
764
773
  clock: n,
765
- target: k
774
+ target: A
766
775
  });
767
776
  function _(u, h) {
768
777
  r({ experience: u, target: h });
769
778
  }
770
779
  const R = e.map((u) => Object.values(u).flat());
771
- function x(u) {
780
+ function I(u) {
772
781
  return e.map((h) => h[u] || [], { skipVoid: !1 });
773
782
  }
774
783
  return {
775
784
  spawn: _,
776
- getByExperienceId: x,
785
+ getByExperienceId: I,
777
786
  listStore: R
778
787
  };
779
788
  });
780
- function Zt(t) {
781
- return st(Gt, t);
789
+ function ee(t) {
790
+ return ft(Kt, t);
782
791
  }
783
792
  export {
784
- j as a,
793
+ Gt as a,
785
794
  Zt as b,
786
- Qt as c,
787
- zt as d,
788
- et as e,
789
- $t as f,
790
- Jt as g,
791
- Wt as h,
792
- At as i,
793
- Yt as t
795
+ ee as c,
796
+ Qt as d,
797
+ ot as e,
798
+ Bt as f,
799
+ Yt as g,
800
+ j as h,
801
+ Dt as i,
802
+ te as t
794
803
  };