@picked/client 0.0.38 → 0.0.39-next.2

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