@picked/client 0.0.1-dev.1772083499814 → 0.0.1-dev.1772085077346
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.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +506 -534
- package/dist/esm/plugins/web-components/index.js +5 -5
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-fvSEb72i.js → experience-instance-CU_pYPyd.js} +25 -24
- package/dist/{experience-instance-BsXG5XJ4.cjs → experience-instance-D_Mwuzb4.cjs} +1 -1
- package/dist/types/entities/experience/experience.d.ts +1 -45
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts +4 -34
- package/dist/types/picked.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as s, k as i } from "../../../supports-8YT4QKI7.js";
|
|
2
2
|
const p = () => ({
|
|
3
3
|
name: "web-components",
|
|
4
4
|
setup: (e) => {
|
|
5
|
-
if (!
|
|
5
|
+
if (!s() || !i())
|
|
6
6
|
return;
|
|
7
7
|
const n = "picked-root";
|
|
8
8
|
if (window.customElements.get(n))
|
|
9
9
|
return;
|
|
10
|
-
class
|
|
10
|
+
class o extends HTMLElement {
|
|
11
11
|
connectedCallback() {
|
|
12
12
|
const t = this.getAttribute("experience-id");
|
|
13
|
-
e.isReady && t && e.
|
|
13
|
+
e.isReady && t && e.launchExperienceById(t);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
window.customElements.define(n,
|
|
16
|
+
window.customElements.define(n, o);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
export {
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
|
|
2
|
-
import { h as F } from "../../experience-instance-
|
|
2
|
+
import { h as F } from "../../experience-instance-CU_pYPyd.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
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
2
|
import { createFactory as dt, invoke as pt } from "@withease/factories";
|
|
3
|
-
import {
|
|
3
|
+
import { j as vt, s as gt, a as At } from "./supports-8YT4QKI7.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
5
5
|
import { i as Ot } from "./object-JwZ58NOH.js";
|
|
6
|
-
function
|
|
6
|
+
function Bt(t) {
|
|
7
7
|
return typeof t == "number" && !isNaN(t);
|
|
8
8
|
}
|
|
9
9
|
function j(t) {
|
|
@@ -19,14 +19,14 @@ 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 (
|
|
22
|
+
if (Bt(t)) return t;
|
|
23
23
|
const e = parseFloat(`${t}`);
|
|
24
24
|
return isNaN(e) ? 0 : e;
|
|
25
25
|
}
|
|
26
26
|
function R(t) {
|
|
27
27
|
return `${t}`;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const Ft = {
|
|
30
30
|
// eslint-disable-next-line eqeqeq
|
|
31
31
|
"==": (t, e) => t == e,
|
|
32
32
|
"===": (t, e) => t === e,
|
|
@@ -220,7 +220,7 @@ async function p(t, e) {
|
|
|
220
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))), a = r ?
|
|
223
|
+
const s = await Promise.all(n.map((o) => p(o, e))), a = r ? Ft[r] : void 0;
|
|
224
224
|
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
225
225
|
return a.apply(e, s);
|
|
226
226
|
}
|
|
@@ -263,13 +263,13 @@ async function at(t, e, r) {
|
|
|
263
263
|
return await p(e, o);
|
|
264
264
|
}
|
|
265
265
|
function Mt(t) {
|
|
266
|
-
return !
|
|
266
|
+
return !At() || !gt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
267
267
|
(e) => e instanceof HTMLElement
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
const Tt = "open";
|
|
271
271
|
function Lt(t) {
|
|
272
|
-
if (!
|
|
272
|
+
if (!vt())
|
|
273
273
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
274
274
|
return t.attachShadow({ mode: Tt });
|
|
275
275
|
}
|
|
@@ -377,14 +377,14 @@ const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
377
377
|
for (const d of a) {
|
|
378
378
|
const y = t.find((M) => M.id === d.destinationNodeId);
|
|
379
379
|
if (!y) continue;
|
|
380
|
-
const [b,
|
|
380
|
+
const [b, B] = yt(
|
|
381
381
|
t,
|
|
382
382
|
e,
|
|
383
383
|
y,
|
|
384
384
|
!1,
|
|
385
385
|
new Set(s)
|
|
386
386
|
);
|
|
387
|
-
b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u,
|
|
387
|
+
b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u, B + 1));
|
|
388
388
|
}
|
|
389
389
|
return o === 1 / 0 ? [-1, -1] : [o, u];
|
|
390
390
|
}, Wt = (t, e, r) => yt(t, e, r, !0, /* @__PURE__ */ new Set()), ht = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
@@ -394,7 +394,7 @@ const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
394
394
|
if (s.length === 0) return [-1, -1];
|
|
395
395
|
let a = 1 / 0, o = -1 / 0;
|
|
396
396
|
for (const u of s) {
|
|
397
|
-
const d = t.find((
|
|
397
|
+
const d = t.find((B) => B.id === u.sourceNodeId);
|
|
398
398
|
if (!d) continue;
|
|
399
399
|
const [y, b] = ht(
|
|
400
400
|
t,
|
|
@@ -427,7 +427,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
427
427
|
target: r,
|
|
428
428
|
options: n
|
|
429
429
|
}) => {
|
|
430
|
-
const s = k(), a = k(), o = k(), u = k(), d = k(), y = k(), b = e.componentStore,
|
|
430
|
+
const s = k(), a = k(), o = k(), u = k(), d = k(), y = k(), b = e.componentStore, B = 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(
|
|
431
431
|
e.treeStore,
|
|
432
432
|
c,
|
|
433
433
|
({ steps: i }, l) => i.find((f) => l && P(l) && f.id === l.stepId) || null
|
|
@@ -439,7 +439,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
439
439
|
if (!f || !P(f.node))
|
|
440
440
|
return null;
|
|
441
441
|
const h = f.node;
|
|
442
|
-
return i.find((
|
|
442
|
+
return i.find((F) => F.id === h.stepId) || null;
|
|
443
443
|
}
|
|
444
444
|
), T = D(
|
|
445
445
|
e.treeStore,
|
|
@@ -484,10 +484,10 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
484
484
|
effect: async ({ nodes: i, edges: l, conditionals: f }, h) => {
|
|
485
485
|
if (!ct(h))
|
|
486
486
|
return;
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
487
|
+
const F = f.find((A) => A.id === h.conditionalId);
|
|
488
|
+
if (!F)
|
|
489
489
|
return;
|
|
490
|
-
const E = h.id, w = await at(t,
|
|
490
|
+
const E = h.id, w = await at(t, F.condition);
|
|
491
491
|
return Kt(!!w, E, i, l);
|
|
492
492
|
}
|
|
493
493
|
}), nt = O({
|
|
@@ -500,15 +500,15 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
500
500
|
I("warn", `Action node ${f.id} has no action name`);
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
|
-
const
|
|
504
|
-
if (!
|
|
503
|
+
const F = t.actions.getByName(h).getState();
|
|
504
|
+
if (!F) {
|
|
505
505
|
I("warn", `Action '${h}' not registered on client`);
|
|
506
506
|
const E = l.find(
|
|
507
507
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
508
508
|
);
|
|
509
509
|
return E ? i.find((w) => w.id === E.destinationNodeId) : null;
|
|
510
510
|
}
|
|
511
|
-
if (typeof
|
|
511
|
+
if (typeof F.action != "function") {
|
|
512
512
|
I("warn", `Action '${h}' is not a function`);
|
|
513
513
|
const E = l.find(
|
|
514
514
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
@@ -516,7 +516,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
516
516
|
return E ? i.find((w) => w.id === E.destinationNodeId) : null;
|
|
517
517
|
}
|
|
518
518
|
try {
|
|
519
|
-
I("info", `Executing action: ${h}`), await
|
|
519
|
+
I("info", `Executing action: ${h}`), await F.action(h);
|
|
520
520
|
const E = l.find(
|
|
521
521
|
(A) => A.sourceNodeId === f.id && A.sourceNodeHandle === "true"
|
|
522
522
|
);
|
|
@@ -536,7 +536,8 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
}), It = _((i) => {
|
|
539
|
-
ut(i)
|
|
539
|
+
if (ut(i))
|
|
540
|
+
return t.launchExperienceById(i.experienceId);
|
|
540
541
|
}), rt = O({
|
|
541
542
|
source: [c, e.treeStore],
|
|
542
543
|
effect: async ([i, { nodes: l, edges: f }]) => Z(i, l, f)
|
|
@@ -556,7 +557,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
556
557
|
target: r,
|
|
557
558
|
componentStore: b,
|
|
558
559
|
// state
|
|
559
|
-
stateStore:
|
|
560
|
+
stateStore: B,
|
|
560
561
|
// open close
|
|
561
562
|
isOpenStore: L,
|
|
562
563
|
open: W.open,
|
|
@@ -652,7 +653,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
652
653
|
H.pending
|
|
653
654
|
]),
|
|
654
655
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
655
|
-
target:
|
|
656
|
+
target: B
|
|
656
657
|
}), m({
|
|
657
658
|
clock: et.doneData,
|
|
658
659
|
source: S,
|
|
@@ -789,7 +790,7 @@ const zt = dt(({ client: t }) => {
|
|
|
789
790
|
clock: n,
|
|
790
791
|
target: b
|
|
791
792
|
});
|
|
792
|
-
function
|
|
793
|
+
function B(c, S, x) {
|
|
793
794
|
r({ experience: c, target: S, options: x });
|
|
794
795
|
}
|
|
795
796
|
const M = e.map((c) => Object.values(c).flat());
|
|
@@ -797,7 +798,7 @@ const zt = dt(({ client: t }) => {
|
|
|
797
798
|
return e.map((S) => S[c] || [], { skipVoid: !1 });
|
|
798
799
|
}
|
|
799
800
|
return {
|
|
800
|
-
spawn:
|
|
801
|
+
spawn: B,
|
|
801
802
|
getByExperienceId: U,
|
|
802
803
|
listStore: M
|
|
803
804
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("effector"),W=require("@withease/factories"),j=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),xe=require("./object-BbFTsGh3.cjs");function Ne(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function x(e){return Array.isArray(e)}function ue(e){return e instanceof Promise}function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(Ne(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function M(e){return`${e}`}const Ie={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>m(e)>m(t),">=":(e,t)=>m(e)>=m(t),"<":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<c;const a=m(r);return n<c&&c<a},"<=":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<=c;const a=m(r);return n<=c&&c<=a},"!!":async e=>await v(e),"!":async e=>!await v(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(M(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(M).join(""),substr:(e,t,r)=>{const n=M(e),c=m(t);if(r===void 0)return n.substr(c);const a=m(r);if(a<0){const o=n.substr(c);return o.substr(0,o.length+a)}return n.substr(c,a)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>x(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=M(e);if(n===""||n===".")return this;const c=n.split(".");let a=this;for(const o of c){if(a==null)return r;if(Array.isArray(a)){const f=parseInt(o,10);isNaN(f)?a=a[o]:a=a[f]}else a=a[o]}return a!==void 0?a:r},async missing(...e){const t=x(e[0])?e[0]:e,r=[];for(const n of t){const c=await g({var:n},this);(c===null||c==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!x(r)||!x(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(x(e)){const[a,o]=e;r=a,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(M(t))},throw(e){throw new Error(M(e))}};async function g(e,t){if(!e)return e;if(ue(e))return g(await e,t);if(x(e))return Promise.all(e.map(o=>g(o,t)));if(!ie(e))return e;const r=ke(e);let n=r?e[r]??[]:[];switch(x(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await v(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const f of n)if(o=await g(f,t),!await v(o))return o;return o}case"or":{let o=null;for(const f of n)if(o=await g(f,t),await v(o))return o;return o}case"map":{const o=await g(n[0],t);return x(o)?await Promise.all(o.map(f=>g(n[1],f))):[]}case"filter":{const o=await g(n[0],t);return x(o)?(await Promise.all(o.map(async p=>{const h=await v(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!x(o))return n.length>2?await g(n[2],t):null;const f=n[1];let h=n.length>2?await g(n[2],t):null;for(const k of o)h=await g(f,{current:k,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!x(o)||o.length===0)return!1;for(const f of o)if(!await v(await g(n[1],f)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!x(o))return!1;for(const f of o)if(await v(await g(n[1],f)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!x(o))return!0;for(const f of o)if(await v(await g(n[1],f)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return ie(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const c=await Promise.all(n.map(o=>g(o,t))),a=r?Ie[r]:void 0;if(!a)throw new Error(`Unrecognized operation ${r}`);return a.apply(t,c)}async function v(e){return ue(e)?v(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function ke(e){return Object.keys(e)[0]}function fe(e){return!xe.isEmpty(e)}async function Y(e,t,r){const n=e.getStateSnapshot(),c=e.predicates.listStore.getState().reduce((f,p)=>({...f,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),a=e.features.listStore.getState().reduce((f,p)=>({...f,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:c,features:a};return await g(t,o)}function ve(e){return!j.supportsWindow()||!j.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const be="open";function Ae(e){if(!j.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:be})}function Oe(){return new Promise((e,t)=>{if(!j.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Fe(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const q="picked-root",U="picked-target",Be="picked-root";function _e(e,t){return[...e,{selector:`${Be}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const c=ve(n.selector).filter(a=>!Me(a,t)&&!le(a,t));return{...n,elements:c}})}function $e(e,t){return e.flatMap(r=>r.elements.map(n=>De(n,r.placement,t)))}function Te(e,t){e.classList.add(U),e.classList.add(`${U}-${t}`)}function Me(e,t){return t?e.classList.contains(`${U}-${t}`):e.classList.contains(`${U}`)}function le(e,t){return t?e.classList.contains(`${q}-${t}`):e.classList.contains(q)}function Le(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(q),t.classList.add(`${q}-${e}`),t}function De(e,t,r){let n;const c=Le(r);if(e instanceof Document)n=e.body.appendChild(c);else{switch(t){case"replace":e.replaceWith(c);break;case"before":e.before(c);break;case"after":e.after(c);break;case"prepend":e.prepend(c);break;default:e.append(c);break}n=c}return n}function se(e){return e.type==="conditional"}function B(e){return e.type==="step"}function ce(e){return e.type==="experience"}function J(e){return e.type==="origin"}function ae(e){return e.type==="action"}const de=(e,t,r,n,c=new Set)=>c.has(r.id)?[]:(c.add(r.id),B(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const f=e.find(p=>p.id===o.destinationNodeId);return f?de(e,t,f,!1,c):[]})),Re=(e,t,r)=>de(e,t,r,!0,new Set),pe=(e,t,r,n,c=new Set)=>{if(c.has(r.id))return[-1,-1];c.add(r.id);const a=t.filter(p=>p.sourceNodeId===r.id);if(a.length===0)return[0,0];let o=1/0,f=-1/0;for(const p of a){const h=e.find(_=>_.id===p.destinationNodeId);if(!h)continue;const[k,A]=pe(e,t,h,!1,new Set(c));k!==-1&&(o=Math.min(o,k+1),f=Math.max(f,A+1))}return o===1/0?[-1,-1]:[o,f]},Pe=(e,t,r)=>pe(e,t,r,!0,new Set),ge=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const c=t.filter(f=>f.destinationNodeId===r.id);if(c.length===0)return[-1,-1];let a=1/0,o=-1/0;for(const f of c){const p=e.find(A=>A.id===f.sourceNodeId);if(!p)continue;const[h,k]=ge(e,t,p,new Set(n));h!==-1&&(a=Math.min(a,h+1),o=Math.max(o,k+1))}return a===1/0?[-1,-1]:[a,o]},He=(e,t,r)=>ge(e,t,r,new Set),me=e=>e.find(r=>r.type==="origin")||null,Q=(e,t,r)=>{if(!e)return me(t);const n=r.find(a=>a.sourceNodeId===e.id);if(!n)return null;const c=t.find(a=>a.id===n.destinationNodeId);return c||null};async function Ce(e,t,r,n){const c=e?"true":"false",a=n.find(o=>o.sourceNodeHandle===c&&o.sourceNodeId===t);return r.find(o=>o.id===a?.destinationNodeId)}const Z=s.createDomain("experience-instance"),je=W.createFactory(({client:e,experience:t,target:r,options:n})=>{const c=s.createEvent(),a=s.createEvent(),o=s.createEvent(),f=s.createEvent(),p=s.createEvent(),h=s.createEvent(),k=t.componentStore,A=Z.store("transitioning"),_=e.history.entriesStore.map(i=>i.filter(d=>d.experienceId===t.id)),P=_.map(i=>i.filter(d=>B(d.node))),u=_.map(i=>i.at(-1)?.node||null),S=s.combine(t.treeStore,u,({steps:i},d)=>i.find(l=>d&&B(d)&&l.id===d.stepId)||null),E=s.combine(t.treeStore,P,({steps:i},d)=>{const l=d.at(-2);if(!l||!B(l.node))return null;const y=l.node;return i.find(O=>O.id===y.stepId)||null}),$=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Re(i,d,l):[]),L=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?He(i,d,l):[-1,-1]),G=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Pe(i,d,l):[-1,-1]),T=Z.store(!1),H=s.createApi(T,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,d)=>d}),he=s.createEffect(async()=>{e.history.back({experienceId:t.id})}),ye=s.attach({source:t.treeStore,effect:async(i,d)=>{const l=i.nodes.find(y=>B(y)&&y.stepId===d);l&&e.history.push({experienceId:t.id,node:l})}}),ee=s.attach({source:u,effect:i=>{}}),K=s.attach({source:t.treeStore,effect:async({nodes:i})=>me(i)}),V=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(J(l))return Q(l,i,d)}}),z=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d,conditionals:l},y)=>{if(!se(y))return;const O=l.find(b=>b.id===y.conditionalId);if(!O)return;const I=y.id,w=await Y(e,O.condition);return Ce(!!w,I,i,d)}}),te=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(!ae(l))return;const y=l.action;if(!y){N.logger("warn",`Action node ${l.id} has no action name`);return}const O=e.actions.getByName(y).getState();if(!O){N.logger("warn",`Action '${y}' not registered on client`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}if(typeof O.action!="function"){N.logger("warn",`Action '${y}' is not a function`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}try{N.logger("info",`Executing action: ${y}`),await O.action(y);const I=d.find(b=>b.sourceNodeId===l.id&&b.sourceNodeHandle==="true");if(!I)return N.logger("warn",`No 'true' edge found for action node ${l.id}`),null;const w=i.find(b=>b.id===I.destinationNodeId);return N.logger("info",`Action '${y}' succeeded, moving to node ${w?.id}`),w||null}catch(I){N.logger("warn",`Action '${y}' failed:`,I);const w=d.find(C=>C.sourceNodeId===l.id&&C.sourceNodeHandle==="false");if(!w)return N.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const b=i.find(C=>C.id===w.destinationNodeId);return N.logger("info",`Action '${y}' failed, moving to node ${b?.id}`),b||null}}}),we=s.createEffect(i=>{ce(i)&&e.experiences.launch({id:i.experienceId})}),ne=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),D=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),Ee=s.createEffect(i=>{e.history.push({experienceId:t.id,node:i})}),re=s.attach({source:t.configStore,effect:async({initializeOpenLogic:i})=>n?.initialiseOpen!==void 0?n.initialiseOpen:fe(i)?!!await Y(e,i):i??!1}),F=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:k,stateStore:A,isOpenStore:T,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,fieldsStore:t.fieldsStore,currentNodeStore:u,currentStepStore:S,previousStepStore:E,nextReachableStepNodesStore:$,stepsToOriginStore:L,stepsToLeafStore:G,goToNextStep:a,goToPreviousStep:o,goToStepById:f,stepsHistoryStore:P}),X=s.createEvent(),oe=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:K}),s.sample({clock:X,filter:i=>i!==null,target:oe}),s.split({source:oe,match:i=>se(i)?"condition":B(i)?"step":ce(i)?"launchExperience":J(i)?"origin":ae(i)?"action":"other",cases:{origin:V,condition:z,step:ee,launchExperience:we,action:te,__:s.createEvent()}}),s.sample({clock:[z.doneData,V.doneData,K.doneData,D.doneData,ne.doneData,te.doneData],filter:Boolean,target:Ee}),s.sample({clock:a,target:D}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:F}))}),s.sample({clock:D.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:F}))}),s.sample({clock:D.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:F}))}),s.sample({clock:o,target:he}),s.sample({clock:f,target:ye}),s.sample({source:s.combine([z.pending,V.pending,K.pending,D.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:A}),s.sample({clock:ee.doneData,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:F}))}),s.sample({clock:h,target:re}),s.sample({source:re.doneData,fn:Boolean,target:T}),s.sample({source:u,clock:c,filter:i=>i?J(i):!0,target:ne}),s.sample({source:T,filter:Boolean,target:c}),s.sample({source:T,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:F}))}),s.sample({source:T,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:F}))}),s.sample({clock:p,target:[h]}),p(),F});function Se(e){return W.invoke(je,e)}const qe=W.createFactory(({client:e})=>{const t=Z.store({}),r=s.createEvent(),n=s.createEvent(),c=s.createEvent(),a=s.createApi(t,{register(u,S){const E=[...u[S.experienceId]??[]];return E.push(S),{...u,[S.experienceId]:E}},unregister(u,S){const E=S.experienceId,$=u[E]?.filter(L=>L!==S);return{...u,[E]:$??[]}}}),o=s.createEffect(({experience:u,target:S,options:E})=>Se({client:e,experience:u,target:S,options:E})),f=s.createEffect(u=>{a.register(u)}),p=s.createEffect(u=>{u.target&&Fe(u.target,()=>{c(u)})}),h=s.createEffect(u=>{a.unregister(u)}),k=s.createEffect(u=>{const S=u.componentStore.getState();if(!S){N.logger("warn","No app component registered. Skipping init.");return}const E=S.frameworkStore.getState();if(!E){N.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const $=u.target;if(!$){N.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const L=Ae($);try{E.render(L,S.component,e,u)}catch(G){N.logger("error",G)}});s.sample({clock:r,target:o}),s.sample({clock:c,target:h}),s.sample({clock:o.doneData,target:[f,p,n]}),s.sample({clock:o.doneData,target:e.eventBus.prepend(u=>({type:"experience_initialize",experience:u}))}),s.sample({clock:n,target:k});function A(u,S,E){r({experience:u,target:S,options:E})}const _=t.map(u=>Object.values(u).flat());function P(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:A,getByExperienceId:P,listStore:_}});function Ue(e){return W.invoke(qe,e)}exports.createAppHosts=$e;exports.createExperienceInstance=Se;exports.createExperienceInstanceIndex=Ue;exports.domInteractive=Oe;exports.evaluateRuleLogic=Y;exports.getTargetElements=_e;exports.isPickedRoot=le;exports.isRulesLogic=fe;exports.isStepNode=B;exports.tagTargetElement=Te;
|
|
1
|
+
"use strict";const s=require("effector"),W=require("@withease/factories"),j=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),xe=require("./object-BbFTsGh3.cjs");function Ne(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function x(e){return Array.isArray(e)}function ue(e){return e instanceof Promise}function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(Ne(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function M(e){return`${e}`}const Ie={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>m(e)>m(t),">=":(e,t)=>m(e)>=m(t),"<":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<c;const a=m(r);return n<c&&c<a},"<=":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<=c;const a=m(r);return n<=c&&c<=a},"!!":async e=>await v(e),"!":async e=>!await v(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(M(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(M).join(""),substr:(e,t,r)=>{const n=M(e),c=m(t);if(r===void 0)return n.substr(c);const a=m(r);if(a<0){const o=n.substr(c);return o.substr(0,o.length+a)}return n.substr(c,a)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>x(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=M(e);if(n===""||n===".")return this;const c=n.split(".");let a=this;for(const o of c){if(a==null)return r;if(Array.isArray(a)){const f=parseInt(o,10);isNaN(f)?a=a[o]:a=a[f]}else a=a[o]}return a!==void 0?a:r},async missing(...e){const t=x(e[0])?e[0]:e,r=[];for(const n of t){const c=await g({var:n},this);(c===null||c==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!x(r)||!x(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(x(e)){const[a,o]=e;r=a,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(M(t))},throw(e){throw new Error(M(e))}};async function g(e,t){if(!e)return e;if(ue(e))return g(await e,t);if(x(e))return Promise.all(e.map(o=>g(o,t)));if(!ie(e))return e;const r=ke(e);let n=r?e[r]??[]:[];switch(x(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await v(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const f of n)if(o=await g(f,t),!await v(o))return o;return o}case"or":{let o=null;for(const f of n)if(o=await g(f,t),await v(o))return o;return o}case"map":{const o=await g(n[0],t);return x(o)?await Promise.all(o.map(f=>g(n[1],f))):[]}case"filter":{const o=await g(n[0],t);return x(o)?(await Promise.all(o.map(async p=>{const h=await v(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!x(o))return n.length>2?await g(n[2],t):null;const f=n[1];let h=n.length>2?await g(n[2],t):null;for(const k of o)h=await g(f,{current:k,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!x(o)||o.length===0)return!1;for(const f of o)if(!await v(await g(n[1],f)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!x(o))return!1;for(const f of o)if(await v(await g(n[1],f)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!x(o))return!0;for(const f of o)if(await v(await g(n[1],f)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return ie(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const c=await Promise.all(n.map(o=>g(o,t))),a=r?Ie[r]:void 0;if(!a)throw new Error(`Unrecognized operation ${r}`);return a.apply(t,c)}async function v(e){return ue(e)?v(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function ke(e){return Object.keys(e)[0]}function fe(e){return!xe.isEmpty(e)}async function Y(e,t,r){const n=e.getStateSnapshot(),c=e.predicates.listStore.getState().reduce((f,p)=>({...f,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),a=e.features.listStore.getState().reduce((f,p)=>({...f,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:c,features:a};return await g(t,o)}function ve(e){return!j.supportsWindow()||!j.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const be="open";function Ae(e){if(!j.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:be})}function Oe(){return new Promise((e,t)=>{if(!j.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Fe(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const q="picked-root",U="picked-target",Be="picked-root";function _e(e,t){return[...e,{selector:`${Be}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const c=ve(n.selector).filter(a=>!Me(a,t)&&!le(a,t));return{...n,elements:c}})}function $e(e,t){return e.flatMap(r=>r.elements.map(n=>De(n,r.placement,t)))}function Te(e,t){e.classList.add(U),e.classList.add(`${U}-${t}`)}function Me(e,t){return t?e.classList.contains(`${U}-${t}`):e.classList.contains(`${U}`)}function le(e,t){return t?e.classList.contains(`${q}-${t}`):e.classList.contains(q)}function Le(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(q),t.classList.add(`${q}-${e}`),t}function De(e,t,r){let n;const c=Le(r);if(e instanceof Document)n=e.body.appendChild(c);else{switch(t){case"replace":e.replaceWith(c);break;case"before":e.before(c);break;case"after":e.after(c);break;case"prepend":e.prepend(c);break;default:e.append(c);break}n=c}return n}function se(e){return e.type==="conditional"}function B(e){return e.type==="step"}function ce(e){return e.type==="experience"}function J(e){return e.type==="origin"}function ae(e){return e.type==="action"}const de=(e,t,r,n,c=new Set)=>c.has(r.id)?[]:(c.add(r.id),B(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const f=e.find(p=>p.id===o.destinationNodeId);return f?de(e,t,f,!1,c):[]})),Re=(e,t,r)=>de(e,t,r,!0,new Set),pe=(e,t,r,n,c=new Set)=>{if(c.has(r.id))return[-1,-1];c.add(r.id);const a=t.filter(p=>p.sourceNodeId===r.id);if(a.length===0)return[0,0];let o=1/0,f=-1/0;for(const p of a){const h=e.find(_=>_.id===p.destinationNodeId);if(!h)continue;const[k,A]=pe(e,t,h,!1,new Set(c));k!==-1&&(o=Math.min(o,k+1),f=Math.max(f,A+1))}return o===1/0?[-1,-1]:[o,f]},Pe=(e,t,r)=>pe(e,t,r,!0,new Set),ge=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const c=t.filter(f=>f.destinationNodeId===r.id);if(c.length===0)return[-1,-1];let a=1/0,o=-1/0;for(const f of c){const p=e.find(A=>A.id===f.sourceNodeId);if(!p)continue;const[h,k]=ge(e,t,p,new Set(n));h!==-1&&(a=Math.min(a,h+1),o=Math.max(o,k+1))}return a===1/0?[-1,-1]:[a,o]},He=(e,t,r)=>ge(e,t,r,new Set),me=e=>e.find(r=>r.type==="origin")||null,Q=(e,t,r)=>{if(!e)return me(t);const n=r.find(a=>a.sourceNodeId===e.id);if(!n)return null;const c=t.find(a=>a.id===n.destinationNodeId);return c||null};async function Ce(e,t,r,n){const c=e?"true":"false",a=n.find(o=>o.sourceNodeHandle===c&&o.sourceNodeId===t);return r.find(o=>o.id===a?.destinationNodeId)}const Z=s.createDomain("experience-instance"),je=W.createFactory(({client:e,experience:t,target:r,options:n})=>{const c=s.createEvent(),a=s.createEvent(),o=s.createEvent(),f=s.createEvent(),p=s.createEvent(),h=s.createEvent(),k=t.componentStore,A=Z.store("transitioning"),_=e.history.entriesStore.map(i=>i.filter(d=>d.experienceId===t.id)),P=_.map(i=>i.filter(d=>B(d.node))),u=_.map(i=>i.at(-1)?.node||null),S=s.combine(t.treeStore,u,({steps:i},d)=>i.find(l=>d&&B(d)&&l.id===d.stepId)||null),E=s.combine(t.treeStore,P,({steps:i},d)=>{const l=d.at(-2);if(!l||!B(l.node))return null;const y=l.node;return i.find(O=>O.id===y.stepId)||null}),$=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Re(i,d,l):[]),L=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?He(i,d,l):[-1,-1]),G=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Pe(i,d,l):[-1,-1]),T=Z.store(!1),H=s.createApi(T,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,d)=>d}),he=s.createEffect(async()=>{e.history.back({experienceId:t.id})}),ye=s.attach({source:t.treeStore,effect:async(i,d)=>{const l=i.nodes.find(y=>B(y)&&y.stepId===d);l&&e.history.push({experienceId:t.id,node:l})}}),ee=s.attach({source:u,effect:i=>{}}),K=s.attach({source:t.treeStore,effect:async({nodes:i})=>me(i)}),V=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(J(l))return Q(l,i,d)}}),z=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d,conditionals:l},y)=>{if(!se(y))return;const O=l.find(b=>b.id===y.conditionalId);if(!O)return;const I=y.id,w=await Y(e,O.condition);return Ce(!!w,I,i,d)}}),te=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(!ae(l))return;const y=l.action;if(!y){N.logger("warn",`Action node ${l.id} has no action name`);return}const O=e.actions.getByName(y).getState();if(!O){N.logger("warn",`Action '${y}' not registered on client`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}if(typeof O.action!="function"){N.logger("warn",`Action '${y}' is not a function`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}try{N.logger("info",`Executing action: ${y}`),await O.action(y);const I=d.find(b=>b.sourceNodeId===l.id&&b.sourceNodeHandle==="true");if(!I)return N.logger("warn",`No 'true' edge found for action node ${l.id}`),null;const w=i.find(b=>b.id===I.destinationNodeId);return N.logger("info",`Action '${y}' succeeded, moving to node ${w?.id}`),w||null}catch(I){N.logger("warn",`Action '${y}' failed:`,I);const w=d.find(C=>C.sourceNodeId===l.id&&C.sourceNodeHandle==="false");if(!w)return N.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const b=i.find(C=>C.id===w.destinationNodeId);return N.logger("info",`Action '${y}' failed, moving to node ${b?.id}`),b||null}}}),we=s.createEffect(i=>{if(ce(i))return e.launchExperienceById(i.experienceId)}),ne=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),D=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),Ee=s.createEffect(i=>{e.history.push({experienceId:t.id,node:i})}),re=s.attach({source:t.configStore,effect:async({initializeOpenLogic:i})=>n?.initialiseOpen!==void 0?n.initialiseOpen:fe(i)?!!await Y(e,i):i??!1}),F=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:k,stateStore:A,isOpenStore:T,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,fieldsStore:t.fieldsStore,currentNodeStore:u,currentStepStore:S,previousStepStore:E,nextReachableStepNodesStore:$,stepsToOriginStore:L,stepsToLeafStore:G,goToNextStep:a,goToPreviousStep:o,goToStepById:f,stepsHistoryStore:P}),X=s.createEvent(),oe=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:K}),s.sample({clock:X,filter:i=>i!==null,target:oe}),s.split({source:oe,match:i=>se(i)?"condition":B(i)?"step":ce(i)?"launchExperience":J(i)?"origin":ae(i)?"action":"other",cases:{origin:V,condition:z,step:ee,launchExperience:we,action:te,__:s.createEvent()}}),s.sample({clock:[z.doneData,V.doneData,K.doneData,D.doneData,ne.doneData,te.doneData],filter:Boolean,target:Ee}),s.sample({clock:a,target:D}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:F}))}),s.sample({clock:D.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:F}))}),s.sample({clock:D.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:F}))}),s.sample({clock:o,target:he}),s.sample({clock:f,target:ye}),s.sample({source:s.combine([z.pending,V.pending,K.pending,D.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:A}),s.sample({clock:ee.doneData,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:F}))}),s.sample({clock:h,target:re}),s.sample({source:re.doneData,fn:Boolean,target:T}),s.sample({source:u,clock:c,filter:i=>i?J(i):!0,target:ne}),s.sample({source:T,filter:Boolean,target:c}),s.sample({source:T,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:F}))}),s.sample({source:T,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:F}))}),s.sample({clock:p,target:[h]}),p(),F});function Se(e){return W.invoke(je,e)}const qe=W.createFactory(({client:e})=>{const t=Z.store({}),r=s.createEvent(),n=s.createEvent(),c=s.createEvent(),a=s.createApi(t,{register(u,S){const E=[...u[S.experienceId]??[]];return E.push(S),{...u,[S.experienceId]:E}},unregister(u,S){const E=S.experienceId,$=u[E]?.filter(L=>L!==S);return{...u,[E]:$??[]}}}),o=s.createEffect(({experience:u,target:S,options:E})=>Se({client:e,experience:u,target:S,options:E})),f=s.createEffect(u=>{a.register(u)}),p=s.createEffect(u=>{u.target&&Fe(u.target,()=>{c(u)})}),h=s.createEffect(u=>{a.unregister(u)}),k=s.createEffect(u=>{const S=u.componentStore.getState();if(!S){N.logger("warn","No app component registered. Skipping init.");return}const E=S.frameworkStore.getState();if(!E){N.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const $=u.target;if(!$){N.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const L=Ae($);try{E.render(L,S.component,e,u)}catch(G){N.logger("error",G)}});s.sample({clock:r,target:o}),s.sample({clock:c,target:h}),s.sample({clock:o.doneData,target:[f,p,n]}),s.sample({clock:o.doneData,target:e.eventBus.prepend(u=>({type:"experience_initialize",experience:u}))}),s.sample({clock:n,target:k});function A(u,S,E){r({experience:u,target:S,options:E})}const _=t.map(u=>Object.values(u).flat());function P(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:A,getByExperienceId:P,listStore:_}});function Ue(e){return W.invoke(qe,e)}exports.createAppHosts=$e;exports.createExperienceInstance=Se;exports.createExperienceInstanceIndex=Ue;exports.domInteractive=Oe;exports.evaluateRuleLogic=Y;exports.getTargetElements=_e;exports.isPickedRoot=le;exports.isRulesLogic=fe;exports.isStepNode=B;exports.tagTargetElement=Te;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdaptedComponent } from '../component/component';
|
|
2
|
-
import { Picked } from '../../picked';
|
|
2
|
+
import { LaunchExperienceOptions, Picked } from '../../picked';
|
|
3
3
|
import { LogicRule, LogicValue } from '../../logic-engine';
|
|
4
4
|
import { Field } from '../field/field';
|
|
5
5
|
export type ExperiencesListStore = ReturnType<typeof createExperienceIndex>;
|
|
@@ -34,46 +34,10 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
36
|
export declare function createExperience<T extends Parameters<typeof createExperienceFactory>[0]>(params: T): ReturnType<typeof createExperienceFactory>;
|
|
37
|
-
/** Options for launching an experience. */
|
|
38
|
-
export interface LaunchExperienceOptions {
|
|
39
|
-
/** When true, the experience will be opened immediately after initialization. */
|
|
40
|
-
initialiseOpen?: boolean;
|
|
41
|
-
/** When true, the experience's condition logic is skipped and it is launched unconditionally. */
|
|
42
|
-
bypassCondition?: boolean;
|
|
43
|
-
}
|
|
44
37
|
declare const createExperienceIndexFactory: ({ client }: {
|
|
45
38
|
client: Picked;
|
|
46
39
|
}) => {
|
|
47
|
-
/** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
|
|
48
40
|
register: (experience: Experience) => void;
|
|
49
|
-
/** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
|
|
50
|
-
get: (id: Experience["id"]) => import('effector').Store<{
|
|
51
|
-
id: string;
|
|
52
|
-
configStore: import('effector').Store<{
|
|
53
|
-
name: string;
|
|
54
|
-
decisionLogic: string | number | boolean | import('../../logic-engine').LogicArray | import('../../logic-engine').LogicObject | (() => LogicValue) | Promise<import('../../logic-engine').SyncLogicValue> | undefined;
|
|
55
|
-
targetSelectors: ExperienceTarget[];
|
|
56
|
-
initializeOpenLogic: LogicValue | LogicRule;
|
|
57
|
-
}>;
|
|
58
|
-
treeStore: import('effector').Store<{
|
|
59
|
-
steps: ExperienceStep[];
|
|
60
|
-
nodes: ExperienceNode[];
|
|
61
|
-
edges: ExperienceEdge[];
|
|
62
|
-
conditionals: ExperienceConditional[];
|
|
63
|
-
}>;
|
|
64
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
65
|
-
componentStore: import('effector').Store<{
|
|
66
|
-
name: string;
|
|
67
|
-
component: AdaptedComponent<string, unknown>;
|
|
68
|
-
frameworkStore: import('effector').Store<import('../..').Framework | undefined>;
|
|
69
|
-
} | undefined>;
|
|
70
|
-
actions: ExperienceAction[];
|
|
71
|
-
merge: import('effector').EventCallable<{
|
|
72
|
-
experience: Partial<Experience>;
|
|
73
|
-
strategy: "override";
|
|
74
|
-
}>;
|
|
75
|
-
} | undefined>;
|
|
76
|
-
/** @deprecated Use `experiences.get(id)` instead. */
|
|
77
41
|
getById: (id: Experience["id"]) => import('effector').Store<{
|
|
78
42
|
id: string;
|
|
79
43
|
configStore: import('effector').Store<{
|
|
@@ -100,14 +64,6 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
100
64
|
strategy: "override";
|
|
101
65
|
}>;
|
|
102
66
|
} | undefined>;
|
|
103
|
-
/** Effector effect that launches an experience by ID, creating instances for each DOM target. */
|
|
104
|
-
launch: import('effector').Effect<{
|
|
105
|
-
id: string;
|
|
106
|
-
options?: LaunchExperienceOptions;
|
|
107
|
-
}, void, Error>;
|
|
108
|
-
/** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
|
|
109
|
-
open: import('effector').Effect<string, void, Error>;
|
|
110
|
-
/** Derived store containing all registered experiences as an array. */
|
|
111
67
|
listStore: import('effector').Store<{
|
|
112
68
|
id: string;
|
|
113
69
|
configStore: import('effector').Store<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAC3E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIjE,QAAA,MAAM,uBAAuB,2BACF;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;oBAIjB,OAAO,C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CAAA;IACvB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED,eAAO,MAAM,eAAe,GAC1B,YAAY,UAAU,EACtB,iBAAiB,oBAAoB,KACpC,IAEF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EACd,YAAY,eAAe,EAC3B,UAAU,uBAAuB,SAkBlC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,kBASzD,CAAA;AAsBD,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,EACd,YAAY,eAAe,KAC1B,OAAO,CAAC,OAAO,CAsBjB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventCallable, Store } from 'effector';
|
|
2
|
-
import { Experience, ExperienceNode, ExperienceStep, ExperienceStore, ExperienceTarget
|
|
3
|
-
import { Picked } from '../../picked';
|
|
2
|
+
import { Experience, ExperienceNode, ExperienceStep, ExperienceStore, ExperienceTarget } from '../experience/experience';
|
|
3
|
+
import { LaunchExperienceOptions, Picked } from '../../picked';
|
|
4
4
|
import { HistoryEntry } from '../history/history';
|
|
5
5
|
export interface ExperienceInstance {
|
|
6
6
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,eA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IACjC,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;IACrC,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACnC,iBAAiB,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAA;CACzC;AAED,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACtF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;CACzC;AAED,QAAA,MAAM,+BAA+B,6CAMhC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAClC,iCA6cF,CAAA;AAED,wBAAgB,wBAAwB,CACtC,CAAC,SAAS,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,EAC/D,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAE/D;AAED,QAAA,MAAM,oCAAoC,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;wBA+I1E,eAAe,UACnB,WAAW,YACT,uBAAuB;4BASJ,UAAU,CAAC,IAAI,CAAC;;CAS/C,CAAA;AAEF,wBAAgB,6BAA6B,CAC3C,CAAC,SAAS,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAEpE"}
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CreateClientOptions } from './client';
|
|
2
2
|
import { Picked } from './picked';
|
|
3
|
+
export type { LaunchExperienceOptions } from './picked';
|
|
3
4
|
export { isPickedRoot } from './utils/dom';
|
|
4
5
|
export * from './utils/supports';
|
|
5
6
|
export * from './utils/storage';
|
|
@@ -15,5 +16,4 @@ export { lazyComponent, isLazyLoader } from './entities/component/lazyComponent'
|
|
|
15
16
|
* @returns The initialized Picked client instance
|
|
16
17
|
*/
|
|
17
18
|
export declare const createClient: (options: CreateClientOptions) => Picked;
|
|
18
|
-
export type { LaunchExperienceOptions } from './entities/experience/experience';
|
|
19
19
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,WAIxD,CAAA
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,WAIxD,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Experience
|
|
1
|
+
import { Experience } from './entities/experience/experience';
|
|
2
2
|
import { Plugin, PluginConfigIndex } from './entities/plugin/plugin';
|
|
3
3
|
import { CreateClientOptions } from './client';
|
|
4
4
|
import { AdaptableComponents, AdaptedComponent } from './entities/component/component';
|
|
@@ -11,6 +11,9 @@ import { Field } from './entities/field/field';
|
|
|
11
11
|
import { Action } from './entities/action/action';
|
|
12
12
|
import { SessionStore } from './utils/user-session';
|
|
13
13
|
import { LogicRule } from './logic-engine';
|
|
14
|
+
export interface LaunchExperienceOptions {
|
|
15
|
+
initialiseOpen?: boolean;
|
|
16
|
+
}
|
|
14
17
|
export declare class Picked {
|
|
15
18
|
static readonly logger: (level: "log" | "warn" | "info" | "error", ...args: Parameters<Console["log"]>) => void;
|
|
16
19
|
private readonly options;
|
|
@@ -65,32 +68,6 @@ export declare class Picked {
|
|
|
65
68
|
};
|
|
66
69
|
readonly experiences: {
|
|
67
70
|
register: (experience: Experience) => void;
|
|
68
|
-
get: (id: Experience["id"]) => import('effector').Store<{
|
|
69
|
-
id: string;
|
|
70
|
-
configStore: import('effector').Store<{
|
|
71
|
-
name: string;
|
|
72
|
-
decisionLogic: string | number | boolean | import('./logic-engine').LogicArray | import('./logic-engine').LogicObject | (() => import('./logic-engine').LogicValue) | Promise<import('./logic-engine').SyncLogicValue> | undefined;
|
|
73
|
-
targetSelectors: import('.').ExperienceTarget[];
|
|
74
|
-
initializeOpenLogic: import('./logic-engine').LogicValue | LogicRule;
|
|
75
|
-
}>;
|
|
76
|
-
treeStore: import('effector').Store<{
|
|
77
|
-
steps: import('.').ExperienceStep[];
|
|
78
|
-
nodes: import('.').ExperienceNode[];
|
|
79
|
-
edges: import('.').ExperienceEdge[];
|
|
80
|
-
conditionals: import('.').ExperienceConditional[];
|
|
81
|
-
}>;
|
|
82
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
83
|
-
componentStore: import('effector').Store<{
|
|
84
|
-
name: string;
|
|
85
|
-
component: AdaptedComponent<string, unknown>;
|
|
86
|
-
frameworkStore: import('effector').Store<Framework | undefined>;
|
|
87
|
-
} | undefined>;
|
|
88
|
-
actions: import('.').ExperienceAction[];
|
|
89
|
-
merge: import('effector').EventCallable<{
|
|
90
|
-
experience: Partial<Experience>;
|
|
91
|
-
strategy: "override";
|
|
92
|
-
}>;
|
|
93
|
-
} | undefined>;
|
|
94
71
|
getById: (id: Experience["id"]) => import('effector').Store<{
|
|
95
72
|
id: string;
|
|
96
73
|
configStore: import('effector').Store<{
|
|
@@ -117,11 +94,6 @@ export declare class Picked {
|
|
|
117
94
|
strategy: "override";
|
|
118
95
|
}>;
|
|
119
96
|
} | undefined>;
|
|
120
|
-
launch: import('effector').Effect<{
|
|
121
|
-
id: string;
|
|
122
|
-
options?: LaunchExperienceOptions;
|
|
123
|
-
}, void, Error>;
|
|
124
|
-
open: import('effector').Effect<string, void, Error>;
|
|
125
97
|
listStore: import('effector').Store<{
|
|
126
98
|
id: string;
|
|
127
99
|
configStore: import('effector').Store<{
|
|
@@ -221,9 +193,7 @@ export declare class Picked {
|
|
|
221
193
|
registerAction: (name: string, action: Action) => void;
|
|
222
194
|
registerExperience: (experience: Experience) => void;
|
|
223
195
|
getStateSnapshot: () => StateSnapshot;
|
|
224
|
-
/** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
|
|
225
196
|
launchExperienceById: (experienceId: string, options?: LaunchExperienceOptions) => Promise<void>;
|
|
226
|
-
/** @deprecated Use `client.experiences.open(experienceId)` instead. */
|
|
227
197
|
openExperienceById: (experienceId: string) => Promise<void>;
|
|
228
198
|
private runPluginStartHooks;
|
|
229
199
|
private evaluateGate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AAGvC,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAKzD,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAOtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK/C,MAAM,WAAW,uBAAuB;IACtC,cAAc,CAAC,EAAE,OAAO,CAAA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