@adriansteffan/reactive 0.1.29 → 0.1.30
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/{mod-B1ELalrV.js → mod-CUZcjHfZ.js} +3 -3
- package/dist/reactive.es.js +1 -1
- package/dist/reactive.umd.js +1 -1
- package/dist/{web-CCfG4if-.js → web-BEDMfcxc.js} +1 -1
- package/dist/{web-BTwvRGCD.js → web-Dz1I9Wa3.js} +1 -1
- package/package.json +1 -1
- package/planned.md +103 -0
- package/src/components/tutorial.tsx +1 -1
|
@@ -78797,7 +78797,7 @@ var eg;
|
|
|
78797
78797
|
i.UTF8 = "utf8", i.ASCII = "ascii", i.UTF16 = "utf16";
|
|
78798
78798
|
})(eg || (eg = {}));
|
|
78799
78799
|
const Va = Eu("Filesystem", {
|
|
78800
|
-
web: () => import("./web-
|
|
78800
|
+
web: () => import("./web-BEDMfcxc.js").then((i) => new i.FilesystemWeb())
|
|
78801
78801
|
});
|
|
78802
78802
|
vi("Upload", async (i, e, t, s) => {
|
|
78803
78803
|
const r = i.sessionID || `sim_${Date.now()}_${Math.floor(Lt(0, 2176782336)).toString(36)}`, n = TV({
|
|
@@ -79049,7 +79049,7 @@ var nw;
|
|
|
79049
79049
|
i.None = "NONE", i.Slide = "SLIDE", i.Fade = "FADE";
|
|
79050
79050
|
})(nw || (nw = {}));
|
|
79051
79051
|
const r7 = Eu("StatusBar"), n7 = Eu("ImmersiveMode", {
|
|
79052
|
-
web: () => import("./web-
|
|
79052
|
+
web: () => import("./web-Dz1I9Wa3.js").then((i) => new i.ImmersiveModeWeb())
|
|
79053
79053
|
});
|
|
79054
79054
|
Ai("EnterFullscreen", "session");
|
|
79055
79055
|
vi("EnterFullscreen", Vu, {});
|
|
@@ -85996,7 +85996,7 @@ const X4 = Br({
|
|
|
85996
85996
|
}, [a, o, $, I]), /* @__PURE__ */ A.jsx(I1e, { children: /* @__PURE__ */ A.jsxs(
|
|
85997
85997
|
"div",
|
|
85998
85998
|
{
|
|
85999
|
-
className: `${r ?? c.containerBg} ${n ? "animate-slide-down opacity-0" : ""}`,
|
|
85999
|
+
className: `${r ?? c.containerBg} ${c.text} ${n ? "animate-slide-down opacity-0" : ""}`,
|
|
86000
86000
|
style: {
|
|
86001
86001
|
width: "100vw",
|
|
86002
86002
|
height: "100vh",
|
package/dist/reactive.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as e, C as t, a as i, D as n, c as r, d as o, e as l, f as m, Y as u, z as c, M as p, P as g, g as P, h as T, Q as d, R as C, i as D, j as h, F as x, T as E, k as S, l as f, m as k, n as F, U as v, X as B, o as R, p as M, q as b, r as y, s as A, t as I, u as K, v as U, w, x as _, y as q, A as G, B as H, G as L, I as Q, J as Z, K as j, L as z, N as J, O as N, S as O, V, Z as X, _ as Y, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as na, a7 as ra, a8 as oa, a9 as la, aa as ma, ab as ua, ac as ca, ad as pa, ae as ga, af as Pa, ag as Ta } from "./mod-
|
|
1
|
+
import { H as e, C as t, a as i, D as n, c as r, d as o, e as l, f as m, Y as u, z as c, M as p, P as g, g as P, h as T, Q as d, R as C, i as D, j as h, F as x, T as E, k as S, l as f, m as k, n as F, U as v, X as B, o as R, p as M, q as b, r as y, s as A, t as I, u as K, v as U, w, x as _, y as q, A as G, B as H, G as L, I as Q, J as Z, K as j, L as z, N as J, O as N, S as O, V, Z as X, _ as Y, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as na, a7 as ra, a8 as oa, a9 as la, aa as ma, ab as ua, ac as ca, ad as pa, ae as ga, af as Pa, ag as Ta } from "./mod-CUZcjHfZ.js";
|
|
2
2
|
export {
|
|
3
3
|
e as Bounce,
|
|
4
4
|
t as CanvasBlock,
|
package/dist/reactive.umd.js
CHANGED
|
@@ -10278,6 +10278,6 @@ Click the button below to add a new entry.`,noEntriesReadonlyText:"No entries",t
|
|
|
10278
10278
|
${x}px !important;
|
|
10279
10279
|
${P}px !important;
|
|
10280
10280
|
}
|
|
10281
|
-
`),()=>{var D;(D=o.current)==null||D.removeAttribute("data-motion-pop-id"),A.contains(_)&&A.removeChild(_)}},[e]),L.jsx(Nve,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const qve=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=ev(Bve),c=V.useId();let d=!0,f=V.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:t,custom:r,onExitComplete:y=>{h.set(y,!0);for(const v of h.values())if(!v)return;s&&s()},register:y=>(h.set(y,!1),()=>h.delete(y))}),[t,h,s]);return n&&d&&(f={...f}),V.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=L.jsx(Fve,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),L.jsx(Pd.Provider,{value:f,children:i})};function Bve(){return new Map}function r4(i=!0){const e=V.useContext(Pd);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=V.useId();V.useEffect(()=>{if(i)return r(n)},[i]);const a=V.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Kd=i=>i.key||"";function n4(i){const e=[];return V.Children.forEach(i,t=>{V.isValidElement(t)&&e.push(t)}),e}const $ve=({children:i,custom:e,initial:t=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:n="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[h,c]=r4(a),d=V.useMemo(()=>n4(i),[i]),f=a&&!h?[]:d.map(Kd),y=V.useRef(!0),v=V.useRef(d),m=ev(()=>new Map),g=V.useRef(new Set),[b,x]=V.useState(d),[P,_]=V.useState(d);tv(()=>{y.current=!1,v.current=d;for(let T=0;T<P.length;T++){const M=Kd(P[T]);f.includes(M)?(m.delete(M),g.current.delete(M)):m.get(M)!==!0&&m.set(M,!1)}},[P,f.length,f.join("-")]);const A=[];if(d!==b){let T=[...d];for(let M=0;M<P.length;M++){const O=P[M],H=Kd(O);f.includes(H)||(T.splice(M,0,O),A.push(O))}return n==="wait"&&A.length&&(T=A),_(n4(T)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:D}=V.useContext(bu);return L.jsx(L.Fragment,{children:P.map(T=>{const M=Kd(T),O=a&&!h?!1:d===P||f.includes(M),H=()=>{if(g.current.has(M))return;if(m.has(M))g.current.add(M),m.set(M,!0);else return;let U=!0;m.forEach(R=>{R||(U=!1)}),U&&(D==null||D(),_(v.current),a&&(c==null||c()),s&&s())};return L.jsx(qve,{isPresent:O,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:O?void 0:H,anchorX:o,anchorY:l,children:T},M)})})},Hve=V.createContext(null);function Qve(){const i=V.useRef(!1);return tv(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function Uve(){const i=Qve(),[e,t]=V.useState(0),s=V.useCallback(()=>{i.current&&t(e+1)},[e]);return[V.useCallback(()=>Tt.postRender(s),[s]),e]}const a4=i=>i===!0,jve=i=>a4(i===!0)||i==="id",zve=({children:i,id:e,inherit:t=!0})=>{const s=V.useContext(bu),r=V.useContext(Hve),[n,a]=Uve(),o=V.useRef(null),l=s.id||r;o.current===null&&(jve(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:a4(t)&&s.group||t4()});const u=V.useMemo(()=>({...o.current,forceRender:n}),[a]);return L.jsx(bu.Provider,{value:u,children:i})},o4=V.createContext({strict:!1}),l4={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let u4=!1;function Wve(){if(u4)return;const i={};for(const e in l4)i[e]={isEnabled:t=>l4[e].some(s=>!!t[s])};t7(i),u4=!0}function h4(){return Wve(),Vge()}function Gve(i){const e=h4();for(const t in i)e[t]={...e[t],...i[t]};t7(e)}const Kve=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Zd(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||Kve.has(i)}let c4=i=>!Zd(i);function Zve(i){typeof i=="function"&&(c4=e=>e.startsWith("on")?!Zd(e):i(e))}try{Zve(require("@emotion/is-prop-valid").default)}catch{}function Jve(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||ks(i[r])||(c4(r)||t===!0&&Zd(r)||!e&&!Zd(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const Jd=V.createContext({});function Yve(i,e){if(Hd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Iu(t)?t:void 0,animate:Iu(s)?s:void 0}}return i.inherit!==!1?e:{}}function Xve(i){const{initial:e,animate:t}=Yve(i,V.useContext(Jd));return V.useMemo(()=>({initial:e,animate:t}),[d4(e),d4(t)])}function d4(i){return Array.isArray(i)?i.join(" "):i}const o0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function p4(i,e,t){for(const s in e)!ks(e[s])&&!m7(s,t)&&(i[s]=e[s])}function e0e({transformTemplate:i},e){return V.useMemo(()=>{const t=o0();return Xv(t,e,i),Object.assign({},t.vars,t.style)},[e])}function t0e(i,e){const t=i.style||{},s={};return p4(s,t,i),Object.assign(s,e0e(i,e)),s}function s0e(i,e){const t={},s=t0e(i,e);return i.drag&&i.dragListener!==!1&&(t.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(t.tabIndex=0),t.style=s,t}const f4=()=>({...o0(),attrs:{}});function i0e(i,e,t,s){const r=V.useMemo(()=>{const n=f4();return g7(n,e,y7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};p4(n,i.style,i),r.style={...n,...r.style}}return r}const r0e=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function l0(i){return typeof i!="string"||i.includes("-")?!1:!!(r0e.indexOf(i)>-1||/[A-Z]/u.test(i))}function n0e(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??l0(i)?i0e:s0e)(e,s,r,i),u=Jve(e,typeof i=="string",n),h=i!==V.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=V.useMemo(()=>ks(c)?c.get():c,[c]);return V.createElement(i,{...h,children:d})}function a0e({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:o0e(t,s,r,i),renderState:e()}}function o0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=Wd(n[d]);let{initial:a,animate:o}=i;const l=Hd(i),u=Y3(i);e&&u&&!l&&i.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let h=t?t.initial===!1:!1;h=h||a===!1;const c=h?o:a;if(c&&typeof c!="boolean"&&!$d(c)){const d=Array.isArray(c)?c:[c];for(let f=0;f<d.length;f++){const y=Ov(i,d[f]);if(y){const{transitionEnd:v,transition:m,...g}=y;for(const b in g){let x=g[b];if(Array.isArray(x)){const P=h?x.length-1:0;x=x[P]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const m4=i=>(e,t)=>{const s=V.useContext(Jd),r=V.useContext(Pd),n=()=>a0e(i,e,s,r);return t?n():ev(n)},l0e=m4({scrapeMotionValuesFromProps:t0,createRenderState:o0}),u0e=m4({scrapeMotionValuesFromProps:C7,createRenderState:f4}),h0e=Symbol.for("motionComponentSymbol");function c0e(i,e,t){const s=V.useRef(t);V.useInsertionEffect(()=>{s.current=t});const r=V.useRef(null);return V.useCallback(n=>{var o;n&&((o=i.onMount)==null||o.call(i,n));const a=s.current;if(typeof a=="function")if(n){const l=a(n);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(n);else a&&(a.current=n);e&&(n?e.mount(n):e.unmount())},[e])}const g4=V.createContext({});function Go(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function d0e(i,e,t,s,r,n){var x,P;const{visualElement:a}=V.useContext(Jd),o=V.useContext(o4),l=V.useContext(Pd),u=V.useContext(a0),h=u.reducedMotion,c=u.skipAnimations,d=V.useRef(null),f=V.useRef(!1);s=s||o.renderer,!d.current&&s&&(d.current=s(i,{visualState:e,parent:a,props:t,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:c,isSVG:n}),f.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const y=d.current,v=V.useContext(g4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&p0e(d.current,t,r,v);const m=V.useRef(!1);V.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[L3],b=V.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((P=window.MotionHasOptimisedAnimation)==null?void 0:P.call(window,g)));return tv(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),V.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var _;(_=window.MotionHandoffMarkAsComplete)==null||_.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function p0e(i,e,t,s){const{layoutId:r,layout:n,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:h,layoutCrossfade:c}=e;i.projection=new t(i.latestValues,e["data-framer-portal-id"]?void 0:v4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&Go(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function v4(i){if(i)return i.options.allowProjection!==!1?i.projection:v4(i.parent)}function u0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&Gve(s);const n=t?t==="svg":l0(i),a=n?u0e:l0e;function o(u,h){let c;const d={...V.useContext(a0),...u,layoutId:f0e(u)},{isStatic:f}=d,y=Xve(u),v=a(u,f);if(!f&&typeof window<"u"){m0e(d,s);const m=g0e(d);c=m.MeasureLayout,y.visualElement=d0e(i,v,d,r,m.ProjectionNode,n)}return L.jsxs(Jd.Provider,{value:y,children:[c&&y.visualElement?L.jsx(c,{visualElement:y.visualElement,...d}):null,n0e(i,u,c0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=V.forwardRef(o);return l[h0e]=i,l}function f0e({layoutId:i}){const e=V.useContext(bu).id;return e&&i!==void 0?e+"-"+i:i}function m0e(i,e){const t=V.useContext(o4).strict;if(process.env.NODE_ENV!=="production"&&e&&t){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";i.ignoreStrict?Fo(!1,s,"lazy-strict-mode"):on(!1,s,"lazy-strict-mode")}}function g0e(i){const e=h4(),{drag:t,layout:s}=e;if(!t&&!s)return{};const r={...t,...s};return{MeasureLayout:t!=null&&t.isEnabled(i)||s!=null&&s.isEnabled(i)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function v0e(i,e){if(typeof Proxy>"u")return u0;const t=new Map,s=(n,a)=>u0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&nv(!1,"motion() is deprecated. Use motion.create() instead."),s(n,a));return new Proxy(r,{get:(n,a)=>a==="create"?s:(t.has(a)||t.set(a,u0(a,void 0,i,e)),t.get(a))})}const y0e=(i,e)=>e.isSVG??l0(i)?new $ge(e):new Oge(e,{allowProjection:i!==V.Fragment});class C0e extends Yn{constructor(e){super(e),e.animationState||(e.animationState=zge(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();$d(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let b0e=0;class w0e extends Yn{constructor(){super(...arguments),this.id=b0e++,this.isExitComplete=!1}update(){var n;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Oa(this.node,a,o);if(l){const{transition:u,transitionEnd:h,...c}=l;for(const d in c)(n=this.node.getValue(d))==null||n.jump(c[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const x0e={animation:{Feature:C0e},exit:{Feature:w0e}};function _u(i){return{point:{x:i.pageX,y:i.pageY}}}const E0e=i=>e=>Uv(e)&&i(e,_u(e));function Du(i,e,t,s){return Lu(i,e,E0e(t),s)}const y4=({current:i})=>i?i.ownerDocument.defaultView:null,C4=(i,e)=>Math.abs(i-e);function V0e(i,e){const t=C4(i.x,e.x),s=C4(i.y,e.y);return Math.sqrt(t**2+s**2)}const b4=new Set(["auto","scroll"]);class w4{constructor(e,t,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:n=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Yd(this.lastRawMoveEventInfo,this.transformPagePoint));const f=h0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=V0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ds;this.history.push({...m,timestamp:g});const{onStart:b,onMove:x}=this.handlers;y||(b&&b(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,y)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=y,this.lastMoveEventInfo=Yd(y,this.transformPagePoint),Tt.update(this.updatePoint,!0)},this.handlePointerUp=(f,y)=>{this.end();const{onEnd:v,onSessionEnd:m,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=h0(f.type==="pointercancel"?this.lastMoveEventInfo:Yd(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!Uv(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=_u(e),u=Yd(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ds;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,h0(u,this.history)),this.removeListeners=wu(Du(this.contextWindow,"pointermove",this.handlePointerMove),Du(this.contextWindow,"pointerup",this.handlePointerUp),Du(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(b4.has(s.overflowX)||b4.has(s.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},n={x:r.x-t.x,y:r.y-t.y};n.x===0&&n.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=n.x,this.lastMoveEventInfo.point.y+=n.y):this.history.length>0&&(this.history[0].x-=n.x,this.history[0].y-=n.y),this.scrollPositions.set(e,r),Tt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Gn(this.updatePoint)}}function Yd(i,e){return e?{point:e(i.point)}:i}function x4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function h0({point:i},e){return{point:i,delta:x4(i,E4(e)),offset:x4(i,S0e(e)),velocity:T0e(e,.1)}}function S0e(i){return i[0]}function E4(i){return i[i.length-1]}function T0e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=E4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>di(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>di(e)*2&&(s=i[1]);const n=Qi(r.timestamp-s.timestamp);if(n===0)return{x:0,y:0};const a={x:(r.x-s.x)/n,y:(r.y-s.y)/n};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function P0e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?qt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?qt(t,i,s.max):Math.min(i,t)),i}function V4(i,e,t){return{min:e!==void 0?i.min+e:void 0,max:t!==void 0?i.max+t-(i.max-i.min):void 0}}function I0e(i,{top:e,left:t,bottom:s,right:r}){return{x:V4(i.x,t,r),y:V4(i.y,e,s)}}function S4(i,e){let t=e.min-i.min,s=e.max-i.max;return e.max-e.min<i.max-i.min&&([t,s]=[s,t]),{min:t,max:s}}function R0e(i,e){return{x:S4(i.x,e.x),y:S4(i.y,e.y)}}function A0e(i,e){let t=.5;const s=Gs(i),r=Gs(e);return r>s?t=xu(e.min,e.max-s,i.min):s>r&&(t=xu(i.min,i.max-r,e.min)),Lr(0,1,t)}function L0e(i,e){const t={};return e.min!==void 0&&(t.min=e.min-i.min),e.max!==void 0&&(t.max=e.max-i.min),t}const c0=.35;function _0e(i=c0){return i===!1?i=0:i===!0&&(i=c0),{x:T4(i,"left","right"),y:T4(i,"top","bottom")}}function T4(i,e,t){return{min:P4(i,e),max:P4(i,t)}}function P4(i,e){return typeof i=="number"?i:i[e]||0}const D0e=new WeakMap;class k0e{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ys(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const n=c=>{t&&this.snapToCursor(_u(c).point),this.stopAnimation()},a=(c,d)=>{const{drag:f,dragPropagation:y,onDragStart:v}=this.getProps();if(f&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ege(f),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kr(g=>{let b=this.getAxisMotionValue(g).get()||0;if(_r.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const P=x.layout.layoutBox[g];P&&(b=Gs(P)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Tt.update(()=>v(c,d),!1,!0),Nv(this.visualElement,"transform");const{animationState:m}=this.visualElement;m&&m.setActive("whileDrag",!0)},o=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d;const{dragPropagation:f,dragDirectionLock:y,onDirectionLock:v,onDrag:m}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:g}=d;if(y&&this.currentDirection===null){this.currentDirection=M0e(g),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",d.point,g),this.updateAxis("y",d.point,g),this.visualElement.render(),m&&Tt.update(()=>m(c,d),!1,!0)},l=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d,this.stop(c,d),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new w4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:y4(this.visualElement),element:this.visualElement.current})}stop(e,t){const s=e||this.latestPointerEvent,r=t||this.latestPanInfo,n=this.isDragging;if(this.cancel(),!n||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&Tt.postRender(()=>o(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,s){const{drag:r}=this.getProps();if(!s||!Xd(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=P0e(a,this.constraints[e],this.elastic[e])),n.set(a)}resolveConstraints(){var n;const{dragConstraints:e,dragElastic:t}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(n=this.visualElement.projection)==null?void 0:n.layout,r=this.constraints;e&&Go(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=I0e(s.layoutBox,e):this.constraints=!1,this.elastic=_0e(t),r!==this.constraints&&!Go(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&kr(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=L0e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Go(e))return!1;const s=e.current;on(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const n=Rge(s,r.root,this.visualElement.getTransformPagePoint());let a=R0e(r.layout.layoutBox,n);if(t){const o=t(Tge(a));this.hasMutatedConstraints=!!o,o&&(a=i7(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=kr(h=>{if(!Xd(h,t,this.currentDirection))return;let c=l&&l[h]||{};(a===!0||a===h)&&(c={min:0,max:0});const d=r?200:1e6,f=r?40:1e7,y={type:"inertia",velocity:s?e[h]:0,bounceStiffness:d,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...n,...c};return this.startAxisValueAnimation(h,y)});return Promise.all(u).then(o)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return Nv(this.visualElement,e),s.start(kv(e,s,0,t,this.visualElement,!1))}stopAnimation(){kr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),r=s[t];return r||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){kr(t=>{const{drag:s}=this.getProps();if(!Xd(t,s,this.currentDirection))return;const{projection:r}=this.visualElement,n=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[t],l=n.get()||0;n.set(e[t]-qt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!Go(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};kr(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=A0e({min:l,max:l},this.constraints[a])}});const{transformTemplate:n}=this.visualElement.getProps();this.visualElement.current.style.transform=n?n({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),kr(a=>{if(!Xd(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(qt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;D0e.set(this.visualElement,this);const e=this.visualElement.current,t=Du(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&age(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Go(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=O0e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Tt.read(r);const o=Lu(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(kr(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=u[c].translate,d.set(d.get()+u[c].translate))}),this.visualElement.render())});return()=>{o(),t(),a(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:n=!1,dragElastic:a=c0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function I4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function O0e(i,e,t){const s=K3(i,I4(t)),r=K3(e,I4(t));return()=>{s(),r()}}function Xd(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function M0e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class N0e extends Yn{constructor(e){super(e),this.removeGroupControls=Hi,this.removeListeners=Hi,this.controls=new k0e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hi}update(){const{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const d0=i=>(e,t)=>{i&&Tt.update(()=>i(e,t),!1,!0)};class F0e extends Yn{constructor(){super(...arguments),this.removePointerDownListener=Hi}onPointerDown(e){this.session=new w4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:y4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:d0(e),onStart:d0(t),onMove:d0(s),onEnd:(n,a)=>{delete this.session,r&&Tt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Du(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let p0=!1;class q0e extends V.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:r}=this.props,{projection:n}=e;n&&(t.group&&t.group.add(n),s&&s.register&&r&&s.register(n),p0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Gd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:r,isPresent:n}=this.props,{projection:a}=s;return a&&(a.isPresent=n,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),p0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Tt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=t,s.root.didUpdate(),Qv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;p0=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function R4(i){const[e,t]=r4(),s=V.useContext(bu);return L.jsx(q0e,{...i,layoutGroup:s,switchLayoutGroup:V.useContext(g4),isPresent:e,safeToRemove:t})}const B0e={pan:{Feature:F0e},drag:{Feature:N0e,ProjectionNode:s4,MeasureLayout:R4}};function A4(i,e,t){const{props:s}=i;i.animationState&&s.whileHover&&i.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,n=s[r];n&&Tt.postRender(()=>n(e,_u(e)))}class $0e extends Yn{mount(){const{current:e}=this.node;e&&(this.unmount=sge(e,(t,s)=>(A4(this.node,s,"Start"),r=>A4(this.node,r,"End"))))}unmount(){}}class H0e extends Yn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=wu(Lu(this.node.current,"focus",()=>this.onFocus()),Lu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function L4(i,e,t){const{props:s}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&s.whileTap&&i.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),n=s[r];n&&Tt.postRender(()=>n(e,_u(e)))}class Q0e extends Yn{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=lge(e,(r,n)=>(L4(this.node,n,"Start"),(a,{success:o})=>L4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const f0=new WeakMap,m0=new WeakMap,U0e=i=>{const e=f0.get(i.target);e&&e(i)},j0e=i=>{i.forEach(U0e)};function z0e({root:i,...e}){const t=i||document;m0.has(t)||m0.set(t,{});const s=m0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(j0e,{root:i,...e})),s[r]}function W0e(i,e,t){const s=z0e(e);return f0.set(i,t),s.observe(i),()=>{f0.delete(i),s.unobserve(i)}}const G0e={some:0,all:1};class K0e extends Yn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:r="some",once:n}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:G0e[r]},o=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,n&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=h?c:d;f&&f(u)};this.stopObserver=W0e(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Z0e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Z0e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const J0e={...x0e,...{inView:{Feature:K0e},tap:{Feature:Q0e},focus:{Feature:H0e},hover:{Feature:$0e}},...B0e,...{layout:{ProjectionNode:s4,MeasureLayout:R4}}},_4=v0e(J0e,y0e);ni("Tutorial",null),Qs("Tutorial",(i,e,t,s)=>{var o;const r=((o=i.slides)==null?void 0:o.length)??0,n={};let a=0;for(let l=0;l<r;l++){const u=t.respondToSlide(l,i,s);s=u.participantState,n[l]=u.value??{},a+=u.duration??500}return{responseData:{slides:n},participantState:s,duration:a}},{respondToSlide:(i,e,t)=>({value:{},participantState:t,duration:500})});const D4=V.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),Y0e=({locked:i=!1}={})=>{const e=V.useContext(D4),t=V.useRef(!1);return!t.current&&i&&(t.current=!0,e.setCanProgress(!1)),{setData:e.setSlideData,unlock:({autoAdvanceMs:s}={})=>{e.setCanProgress(!0),s!==void 0&&e.autoAdvance(s)}}},k4="px-4 py-3 border-2 font-bold text-lg rounded-xl transition-all duration-100 outline-none focus:outline-none focus:ring-0",O4=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,animate:n=!1,nextKey:a="ArrowRight",backKey:o="ArrowLeft",theme:l})=>{const u=An(),c=Gr(l??u),d=`${k4} ${c.buttonBg} ${c.buttonText} ${c.buttonBorder} ${c.buttonShadow} cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`,f=`${k4} ${c.buttonDisabledBg} ${c.buttonDisabledText} ${c.buttonDisabledBorder} ${c.buttonDisabledShadow} cursor-default`,[y,v]=V.useState(0),[m,g]=V.useState({}),b=V.useRef(),x=V.useRef({}),P=m[y]!==!1,_=V.useRef(P),[A,D]=V.useState(!1);V.useEffect(()=>{if(P&&!_.current){D(!0);const F=setTimeout(()=>D(!1),300);return()=>clearTimeout(F)}_.current=P},[P]);const T=V.useCallback(F=>{g($=>({...$,[y]:F}))},[y]),M=V.useCallback(F=>{x.current[y]={...x.current[y],...F}},[y]),O=V.useCallback(()=>{y===e.length-1?i({slides:x.current}):v(F=>F+1)},[y,e.length,i]),H=V.useCallback(()=>{P&&O()},[P,O]),U=V.useCallback((F=0)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>O(),F)},[O]);V.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const R=V.useCallback(()=>{y>0&&v(F=>F-1)},[y]);return V.useEffect(()=>{if(a===!1&&o===!1)return;const F=$=>{a&&$.key===a&&($.preventDefault(),H()),o&&$.key===o&&($.preventDefault(),R())};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[a,o,H,R]),L.jsx(zve,{children:L.jsxs("div",{className:`${r??c.containerBg} ${n?"animate-slide-down opacity-0":""}`,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[L.jsx("div",{style:{flex:1,position:"relative"},children:L.jsx($ve,{mode:"popLayout",children:L.jsx(_4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:t},style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:L.jsx(D4.Provider,{value:{setCanProgress:T,autoAdvance:U,setSlideData:M},children:e[y]})},y)})}),L.jsxs("div",{style:{padding:"1.5rem 1.5rem 3rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[L.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:L.jsx("button",{onClick:R,className:d,tabIndex:-1,onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&F.preventDefault()},style:{visibility:y>0?"visible":"hidden"},children:"←"})}),L.jsx("div",{style:{display:"flex",gap:6},children:e.map((F,$)=>L.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:$===y?c.dotActive:c.dotInactive,transition:"background-color 0.2s"}},$))}),L.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:L.jsx(_4.button,{onClick:H,tabIndex:-1,onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&F.preventDefault()},animate:{scale:A?1.2:1},transition:{type:"spring",stiffness:500,damping:15},className:(P?d:f)+(y===e.length-1?" px-8":""),children:y===e.length-1?s:"→"})})]})]})})};ni("RandomDotKinematogram","rdk");const Or={validKeys:[],duration:1e3,responseEndsTrial:!0,dotCount:300,dotSetCount:1,direction:0,coherence:.5,opposite:0,speed:60,dotLifetime:-1,dotRadius:2,dotColor:"white",backgroundColor:"gray",apertureShape:"ellipse",apertureWidth:600,apertureHeight:400,reinsertMode:"opposite",noiseMovement:"randomDirection",fixationTime:500,showFixation:!1,fixationWidth:15,fixationHeight:15,fixationColor:"white",fixationThickness:2,showBorder:!1,borderWidth:1,borderColor:"black"};Qs("RandomDotKinematogram",(i,e,t,s)=>{const r={...Or,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=r.fixationTime??Or.fixationTime,u=r.duration??Or.duration,c=(r.responseEndsTrial??Or.responseEndsTrial)&&a!=null?a:u,d=Array.isArray(r.correctResponse)?r.correctResponse.map(f=>f.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null;return{responseData:{...r,rt:a,response:o,correct:o&&d?d.includes(o.toLowerCase()):null,framesDisplayed:0,measuredRefreshRate:null},participantState:n.participantState,duration:l+c}},{respond:(i,e)=>{const t=$w({driftRate:{type:"normal",mean:.005*(i.coherence??Or.coherence),sd:.0012},boundaries:.75,startingPoint:0,noiseLevel:.02,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??Or.duration,stimOffset:i.stimulusDuration??i.duration??Or.duration,postStimStrategy:{type:"continue"}}),s=Hw(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const X0e=10,M4=.1,e1e=(i,e,t,s)=>{const r=Math.floor(i*e),n=Math.floor(i*t),a=[...Array(r).fill("coherent"),...Array(n).fill("opposite"),...Array(i-r-n).fill(s)];return gm(a)},Fa=(i,e)=>i+Math.random()*(e-i),t1e=(i,e,t,s,r)=>{const n=e/2,a=i==="circle"||i==="square"?n:t/2,o=(l,u)=>{const h=n*2,c=a*2,d=s-n,f=r-a;return[((l-d)%h+h)%h+d,((u-f)%c+c)%c+f]};return i==="circle"||i==="ellipse"?{centerX:s,centerY:r,getRandomPosition(){const l=Fa(-Math.PI,Math.PI),u=Math.sqrt(Math.random());return[Math.cos(l)*u*n+s,Math.sin(l)*u*a+r]},isOutside(l,u,h){const c=n+h,d=a+h,f=(l-s)/c,y=(u-r)/d;return f*f+y*y>1},getOppositePosition(l,u,h){if(u!==void 0&&h!==void 0){const c=u*u+h*h;if(c>1e-10){const d=Math.sqrt(c),f=u/d,y=h/d,v=l.x-s,m=l.y-r,g=n*n,b=a*a,x=f*f/g+y*y/b,P=v*f/g+m*y/b,_=v*v/g+m*m/b-1,A=P*P-x*_;if(A>=0){const D=(P+Math.sqrt(A))/x;if(D>0&&Number.isFinite(D))return[l.x-f*D,l.y-y*D]}}}return this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=2*s-l.x,h=2*r-l.y,c=(u-s)/n,d=(h-r)/a,f=Math.sqrt(c*c+d*d);return f>1?[s+c/f*n,r+d/f*a]:[u,h]},wrap:o,clip(l){l.beginPath(),l.ellipse(s,r,n,a,0,0,Math.PI*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.beginPath(),l.ellipse(s,r,n+h/2,a+h/2,0,0,Math.PI*2),l.stroke()}}:{centerX:s,centerY:r,getRandomPosition(){return[Fa(s-n,s+n),Fa(r-a,r+a)]},isOutside(l,u,h){const c=n+h,d=a+h;return l<s-c||l>s+c||u<r-d||u>r+d},getOppositePosition(l,u,h){if(u===void 0||h===void 0)return this.getOppositePositionSimple(l);const c=Math.sqrt(u*u+h*h);if(c<1e-10)return this.getOppositePositionSimple(l);const d=-u/c,f=-h/c,y=s-n,v=s+n,m=r-a,g=r+a,b=d!==0?(y-l.x)/d:-1/0,x=d!==0?(v-l.x)/d:-1/0,P=f!==0?(m-l.y)/f:-1/0,_=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(P,_)),D=Math.min(Math.max(b,x),Math.max(P,_));return D>0&&A<=D&&Number.isFinite(D)?[l.x+d*D,l.y+f*D]:this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=s-n,h=s+n,c=r-a,d=r+a;let f=l.x,y=l.y;return l.x<u?f=h:l.x>h&&(f=u),l.y<c?y=d:l.y>d&&(y=c),[f,y]},wrap:o,clip(l){l.beginPath(),l.rect(s-n,r-a,n*2,a*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.strokeRect(s-n-h/2,r-a-h/2,n*2+h,a*2+h)}}},s1e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Fa(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Fa(0,e>0?e:0),assignedMovement:i}},i1e=(i,e,t,s,r,n,a,o,l)=>{const u={...i};if(u.lifeCount+=t,s>0&&u.lifeCount>=s)return[u.x,u.y]=r.getRandomPosition(),u.lifeCount=0,u;let h=i.assignedMovement;if(l!==void 0&&(h=l,u.assignedMovement=h,h==="randomDirection")){const y=Fa(-Math.PI,Math.PI);u.randomDirX=Math.cos(y),u.randomDirY=-Math.sin(y)}let c=0,d=0;switch(h){case"coherent":c=o[0],d=o[1];break;case"opposite":c=-o[0],d=-o[1];break;case"randomTeleport":return[u.x,u.y]=r.getRandomPosition(),u;case"randomWalk":{const y=Fa(-Math.PI,Math.PI);c=Math.cos(y),d=-Math.sin(y);break}case"randomDirection":c=u.randomDirX,d=u.randomDirY;break}if(u.x+=c*e,u.y+=d*e,r.isOutside(u.x,u.y,a))if(n==="random")[u.x,u.y]=r.getRandomPosition();else if(n==="oppositeSimple")[u.x,u.y]=r.getOppositePositionSimple(u);else if(n==="opposite")[u.x,u.y]=r.getOppositePosition(u,c,d);else if(n==="wrap")[u.x,u.y]=r.wrap(u.x,u.y);else throw new Error(`Unknown reinsertType: ${n}`);return u},N4=V.forwardRef((i,e)=>{const{width:t,height:s,dotCount:r,dotSetCount:n,direction:a,coherence:o,opposite:l,speed:u,dotLifetime:h,updateRate:c,dotRadius:d,dotCharacter:f,dotColor:y,coherentDotColor:v,backgroundColor:m,apertureShape:g,apertureWidth:b,apertureHeight:x,apertureCenterX:P,apertureCenterY:_,reinsertMode:A,noiseMovement:D,reassignEveryMs:T,showFixation:M,fixationWidth:O,fixationHeight:H,fixationColor:U,fixationThickness:R,showBorder:F,borderWidth:$,borderColor:Q,active:W=!0,initialRefreshRate:G,style:ue,className:ee}={...Or,...i},oe=V.useRef(null),re=V.useRef(),ce=V.useRef(),xe=V.useRef(),ge=V.useRef(0),ie=V.useRef(0),Ee=V.useRef([]),et=V.useRef(null),Xt=V.useRef(!1),zt=P??t/2,Os=_??s/2,Et=V.useMemo(()=>t1e(g,b,x,zt,Os),[g,b,x,zt,Os]),fs=V.useMemo(()=>{const Oe=(90-a)*Math.PI/180;return[Math.cos(Oe),-Math.sin(Oe)]},[a]),is=V.useRef([]),_e=V.useRef(0);V.useEffect(()=>{const Oe=Math.floor(r*o),Ke=Math.floor(r*l);is.current=Array.from({length:n},()=>Array.from({length:r},(Ie,rs)=>{let Cs;return rs<Oe?Cs="coherent":rs<Oe+Ke?Cs="opposite":Cs=D,s1e(Cs,h,Et)}))},[]),V.useEffect(()=>{typeof G=="number"&&G>=20&&G<=300&&(et.current=1e3/G,Xt.current=!0)},[G]),V.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:ie.current,measuredRefreshRate:et.current?Math.round(1e3/et.current):null})}));const tt=V.useCallback((Oe,Ke)=>{Ke.forEach(Ie=>{const rs=v&&Ie.assignedMovement==="coherent"?v:y;if(Oe.fillStyle=rs,f){const Cs=d*2.5;Oe.font=`${Cs}px monospace`,Oe.textAlign="center",Oe.textBaseline="middle",Oe.fillText(f,Ie.x,Ie.y)}else Oe.beginPath(),Oe.arc(Ie.x,Ie.y,d,0,Math.PI*2),Oe.fill()})},[y,v,d,f]),Bt=V.useCallback((Oe,Ke,Ie)=>{M&&(Oe.fillStyle=U,Oe.fillRect(Ke-O,Ie-R/2,O*2,R),Oe.fillRect(Ke-R/2,Ie-H,R,H*2))},[M,U,R,O,H]),Ht=V.useCallback(Oe=>{F&&Et.drawBorder(Oe,Q,$)},[F,Q,$,Et]),gt=V.useCallback(Oe=>{const Ke=oe.current,Ie=Ke==null?void 0:Ke.getContext("2d");if(!Ke||!Ie)return;ce.current===void 0&&(ce.current=Oe),xe.current===void 0&&(xe.current=Oe);const rs=Oe-xe.current;if(xe.current=Oe,ie.current++,rs>0&&rs<500){if(Xt.current)et.current=M4*rs+(1-M4)*et.current;else if(Ee.current.push(rs),Ee.current.length>=X0e){const Js=[...Ee.current].sort((Ys,zi)=>Ys-zi),ji=Math.floor(Js.length/2);et.current=Js.length%2?Js[ji]:(Js[ji-1]+Js[ji])/2,Xt.current=!0}}const Cs=Oe-(ce.current??Oe),bs=Math.min(Cs,100),hn=c&&c>0?1e3/c:0,Zs=!c||c<=0||bs>=hn;if(Ie.clearRect(0,0,Ke.width,Ke.height),Ie.save(),Et.clip(Ie),Ie.fillStyle=m,Ie.fillRect(0,0,Ke.width,Ke.height),Ie.restore(),!W)Bt(Ie,Et.centerX,Et.centerY);else{if(Zs){const ji=u*bs/1e3;let Ys=!1;if(T!==void 0)if(T===0)Ys=!0;else{ge.current+=bs;const Y=Xt.current&&et.current?et.current*.5:0;Ys=ge.current+Y>=T,Ys&&(ge.current%=T)}const zi=Ys?e1e(r,o,l,D):null,aa=is.current[_e.current].map((Y,ne)=>i1e(Y,ji,bs,h,Et,A,d,fs,zi==null?void 0:zi[ne]));is.current[_e.current]=aa,_e.current=(_e.current+1)%n,ce.current=Oe}const Js=is.current[_e.current];Ie.save(),Et.clip(Ie),tt(Ie,Js),Ie.restore(),Ie.save(),Ie.beginPath(),Bt(Ie,Et.centerX,Et.centerY),Ht(Ie),Ie.restore()}re.current=requestAnimationFrame(gt)},[W,m,D,o,l,r,u,h,Et,A,n,d,fs,c,tt,Bt,Ht,T]);return V.useEffect(()=>(re.current=requestAnimationFrame(gt),()=>{re.current&&cancelAnimationFrame(re.current)}),[gt]),V.useEffect(()=>{const Oe=oe.current;if(!Oe)return;const Ke=window.devicePixelRatio||1;Oe.width=t*Ke,Oe.height=s*Ke,Oe.style.width=`${t}px`,Oe.style.height=`${s}px`;const Ie=Oe.getContext("2d");Ie&&Ie.scale(Ke,Ke)},[t,s]),L.jsx("canvas",{ref:oe,style:{display:"block",...ue},className:ee})}),F4=i=>{const{store:e,stimulusDuration:t,updateRate:s,dotCharacter:r,coherentDotColor:n,apertureCenterX:a=window.innerWidth/2,apertureCenterY:o=window.innerHeight/2,reassignEveryMs:l,responseHint:u,validKeys:h,duration:c,responseEndsTrial:d,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,dotRadius:P,dotColor:_,backgroundColor:A,apertureShape:D,apertureWidth:T,apertureHeight:M,reinsertMode:O,noiseMovement:H,showFixation:U,fixationTime:R,fixationWidth:F,fixationHeight:$,fixationColor:Q,fixationThickness:W,showBorder:G,borderWidth:ue,borderColor:ee}={...Or,...i},oe=V.useRef(i);oe.current=i;const re=V.useRef(null),ce=V.useRef(performance.now()),xe=V.useRef(!1),ge=V.useRef(null),ie=V.useRef(null),[Ee,et]=V.useState(null),[Xt,zt]=V.useState(R<=0),[Os,Et]=V.useState(!0),fs=e==null?void 0:e._reactiveScreenRefreshRate,is=V.useCallback((_e,tt)=>{var Cs;if(xe.current)return;xe.current=!0;const{next:Bt,data:Ht,store:gt,updateStore:Oe,...Ke}=oe.current,Ie=(Cs=re.current)==null?void 0:Cs.getStats(),rs=Array.isArray(Ke.correctResponse)?Ke.correctResponse.map(bs=>bs.toLowerCase()):Ke.correctResponse?[Ke.correctResponse.toLowerCase()]:null;Bt({...Or,...Ke,rt:tt,response:_e,correct:_e&&rs?rs.includes(_e):null,framesDisplayed:(Ie==null?void 0:Ie.framesDisplayed)??0,measuredRefreshRate:(Ie==null?void 0:Ie.measuredRefreshRate)??null})},[]);return V.useEffect(()=>{if(R<=0)return;const _e=setTimeout(()=>zt(!0),R);return()=>clearTimeout(_e)},[R]),V.useEffect(()=>{const _e=t??c;if(_e<=0)return;const tt=setTimeout(()=>Et(!1),R+_e);return()=>clearTimeout(tt)},[R,t,c]),V.useEffect(()=>{if(c<=0)return;const _e=setTimeout(()=>{is(ge.current,ie.current)},R+c);return()=>clearTimeout(_e)},[R,c,is]),V.useEffect(()=>{const _e=tt=>{if(xe.current||ge.current)return;const Bt=tt.key.toLowerCase(),Ht=h.length>0?h.map(gt=>gt.toLowerCase()):null;if(!Ht||Ht.includes(Bt)){const gt=performance.now()-ce.current;ge.current=Bt,ie.current=gt,et(Bt),d&&is(Bt,gt)}};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[h,d,is]),L.jsxs("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:[L.jsx(N4,{ref:re,width:window.innerWidth,height:window.innerHeight,active:Xt&&Os,initialRefreshRate:fs,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:P,dotCharacter:r,dotColor:_,coherentDotColor:n,backgroundColor:A,apertureShape:D,apertureWidth:T,apertureHeight:M,apertureCenterX:a,apertureCenterY:o,reinsertMode:O,noiseMovement:H,reassignEveryMs:l,showFixation:U,fixationWidth:F,fixationHeight:$,fixationColor:Q,fixationThickness:W,showBorder:G,borderWidth:ue,borderColor:ee}),u&&!Os&&!Ee&&L.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]})},r1e={Text:ac,ProlificEnding:zw,EnterFullscreen:oS,ExitFullscreen:lS,Quest:G5,Upload:sS,MicrophoneCheck:Yw,PlainInput:jw,RequestFilePermission:ES,CanvasBlock:VS,CheckDevice:SS,StoreUI:Jpe,Tutorial:O4,RandomDotKinematogram:F4},n1e={voicerecorder:Tne};function g0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function a1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r}){const n=Wpe(),a=V.useMemo(()=>tc(i),[i]),o=V.useRef((()=>{const R={},F=new URLSearchParams(window.location.search);for(const[G,ue]of F.entries())R[G]=ue;const $=Ol.getRegistry()||[],Q={};for(const[G,ue]of Object.entries(R))Q[G]={value:ue,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const G of $)Q[G.name]={value:G.value!==void 0?G.value:R[G.name],registered:!0,defaultValue:G.defaultValue,type:G.type,description:G.description};return[{index:-1,trialNumber:-1,start:Ps(),end:Ps(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:Q}}]})()),[l,u]=V.useState(0),h=V.useRef(Ps()),c=V.useRef({}),[d,f]=V.useState(()=>Rn(a,0,()=>c.current,()=>o.current,R=>{c.current={...c.current,...R}})),y=!n&&va("hybridSimulation",!1,"boolean")?"hybrid":"none",v=V.useRef(r||{}),m=V.useRef(-1),g={...r1e,...t},b={...n1e,...s},x=V.useMemo(()=>{const R=a.instructions.length;return R>0?d/R:0},[d,a.instructions]);V.useEffect(()=>{window.scrollTo(0,0)},[d]);function P(R){c.current={...c.current,...R}}function _(R,F,$){const Q=Ps(),W=a.instructions[d],G=F!==void 0?F:h.current,ue=$!==void 0?$:Q;if((W==null?void 0:W.type)==="ExecuteContent"){const oe=W.content;if(g0(oe)){let re={index:d,trialNumber:l+1,start:G,end:ue,duration:ue-G,type:oe.type,name:oe.name??"",...oe.csv!==void 0?{csv:oe.csv}:{},responseData:R};re=sc(re,oe,o.current,c.current),o.current=[...o.current,re],u(ce=>ce+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",oe)}const ee=Rn(a,d+1,()=>c.current,()=>o.current,oe=>P(oe));ee<a.instructions.length&&(h.current=Ps()),f(ee)}const A=V.useCallback(R=>{let F=0;const $=Ps(),Q=2e4;let W,G=$;const ue=1e3,ee=()=>{const xe=Ps()-$;return xe>0?Math.round(F*1e3/xe):null},oe=()=>{W&&cancelAnimationFrame(W)},re=ce=>{F++;const xe=ce-$;ce-G>=ue&&(R(ee()),G=ce),xe<Q?W=requestAnimationFrame(re):(oe(),R(ee()))};return W=requestAnimationFrame(re),oe},[]),D=({children:R,collectRefreshRate:F})=>{const $=V.useRef(null),Q=V.useRef(null);V.useEffect(()=>{if($.current=Ps(),F)return A(ue=>{Q.current=ue,P({_reactiveScreenRefreshRate:ue})})},[]);const W=V.Children.map(R,G=>{if(V.isValidElement(G)){const ue=(ee,oe,re)=>{const ce=Ps(),xe=oe!==void 0?oe:$.current;_(ee,xe??void 0,(re!==void 0?re:ce)??void 0)};return V.cloneElement(G,{...G.props,next:ue})}return G});return L.jsx(L.Fragment,{children:W})},T=a.instructions[d],M=V.useMemo(()=>{if(y==="none"||(T==null?void 0:T.type)!=="ExecuteContent")return!1;const R=T.content;return!g0(R)||R.simulate===!1?!1:!!R.simulate||!!R.simulators},[d,y,T]);V.useEffect(()=>{M&&m.current!==d&&(m.current=d,(async()=>{const R=T.content,{trialProps:F,simulateFn:$,simulators:Q}=wm(R,o.current,c.current),W=await $(F,{data:o.current,store:c.current},Q,v.current);v.current=W.participantState,W.storeUpdates&&P(W.storeUpdates),_(W.responseData)})())},[M,d]);let O=null;if((T==null?void 0:T.type)==="ExecuteContent"&&!M){const R=T.content;if(g0(R)){const F=g[R.type];if(F){const $=typeof R.props=="function"?R.props(o.current,c.current):R.props||{};O=L.jsx(D,{collectRefreshRate:R.collectRefreshRate,children:L.jsx(F,{next:_,updateStore:P,store:c.current,data:o.current,...R.type==="Quest"?{customQuestions:b}:{},...$})},d)}else console.error(`No component found for type: ${R.type}`),O=L.jsxs("div",{children:['Error: Component type "',R.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",R),O=L.jsx("div",{children:"Non-component content encountered."})}else d>=a.instructions.length&&(O=L.jsx(L.Fragment,{}));const H=e.theme??"light",U=Gr(H);return L.jsx(xm.Provider,{value:H,children:L.jsxs("div",{className:"w-full h-full",children:[L.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:L.jsx("div",{className:`flex-1 h-6 ${U.progressBg} rounded-full overflow-hidden`,children:L.jsx("div",{className:`h-full ${U.progressBg} rounded-full duration-300 ${x>0?" border-black border-2":""}`,style:{width:`${x*100}%`,backgroundImage:`repeating-linear-gradient(
|
|
10281
|
+
`),()=>{var D;(D=o.current)==null||D.removeAttribute("data-motion-pop-id"),A.contains(_)&&A.removeChild(_)}},[e]),L.jsx(Nve,{isPresent:e,childRef:o,sizeRef:l,pop:n,children:n===!1?i:p.cloneElement(i,{ref:c})})}const qve=({children:i,initial:e,isPresent:t,onExitComplete:s,custom:r,presenceAffectsLayout:n,mode:a,anchorX:o,anchorY:l,root:u})=>{const h=ev(Bve),c=V.useId();let d=!0,f=V.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:t,custom:r,onExitComplete:y=>{h.set(y,!0);for(const v of h.values())if(!v)return;s&&s()},register:y=>(h.set(y,!1),()=>h.delete(y))}),[t,h,s]);return n&&d&&(f={...f}),V.useMemo(()=>{h.forEach((y,v)=>h.set(v,!1))},[t]),p.useEffect(()=>{!t&&!h.size&&s&&s()},[t]),i=L.jsx(Fve,{pop:a==="popLayout",isPresent:t,anchorX:o,anchorY:l,root:u,children:i}),L.jsx(Pd.Provider,{value:f,children:i})};function Bve(){return new Map}function r4(i=!0){const e=V.useContext(Pd);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,n=V.useId();V.useEffect(()=>{if(i)return r(n)},[i]);const a=V.useCallback(()=>i&&s&&s(n),[n,s,i]);return!t&&s?[!1,a]:[!0]}const Kd=i=>i.key||"";function n4(i){const e=[];return V.Children.forEach(i,t=>{V.isValidElement(t)&&e.push(t)}),e}const $ve=({children:i,custom:e,initial:t=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:n="sync",propagate:a=!1,anchorX:o="left",anchorY:l="top",root:u})=>{const[h,c]=r4(a),d=V.useMemo(()=>n4(i),[i]),f=a&&!h?[]:d.map(Kd),y=V.useRef(!0),v=V.useRef(d),m=ev(()=>new Map),g=V.useRef(new Set),[b,x]=V.useState(d),[P,_]=V.useState(d);tv(()=>{y.current=!1,v.current=d;for(let T=0;T<P.length;T++){const M=Kd(P[T]);f.includes(M)?(m.delete(M),g.current.delete(M)):m.get(M)!==!0&&m.set(M,!1)}},[P,f.length,f.join("-")]);const A=[];if(d!==b){let T=[...d];for(let M=0;M<P.length;M++){const O=P[M],H=Kd(O);f.includes(H)||(T.splice(M,0,O),A.push(O))}return n==="wait"&&A.length&&(T=A),_(n4(T)),x(d),null}process.env.NODE_ENV!=="production"&&n==="wait"&&P.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:D}=V.useContext(bu);return L.jsx(L.Fragment,{children:P.map(T=>{const M=Kd(T),O=a&&!h?!1:d===P||f.includes(M),H=()=>{if(g.current.has(M))return;if(m.has(M))g.current.add(M),m.set(M,!0);else return;let U=!0;m.forEach(R=>{R||(U=!1)}),U&&(D==null||D(),_(v.current),a&&(c==null||c()),s&&s())};return L.jsx(qve,{isPresent:O,initial:!y.current||t?void 0:!1,custom:e,presenceAffectsLayout:r,mode:n,root:u,onExitComplete:O?void 0:H,anchorX:o,anchorY:l,children:T},M)})})},Hve=V.createContext(null);function Qve(){const i=V.useRef(!1);return tv(()=>(i.current=!0,()=>{i.current=!1}),[]),i}function Uve(){const i=Qve(),[e,t]=V.useState(0),s=V.useCallback(()=>{i.current&&t(e+1)},[e]);return[V.useCallback(()=>Tt.postRender(s),[s]),e]}const a4=i=>i===!0,jve=i=>a4(i===!0)||i==="id",zve=({children:i,id:e,inherit:t=!0})=>{const s=V.useContext(bu),r=V.useContext(Hve),[n,a]=Uve(),o=V.useRef(null),l=s.id||r;o.current===null&&(jve(t)&&l&&(e=e?l+"-"+e:l),o.current={id:e,group:a4(t)&&s.group||t4()});const u=V.useMemo(()=>({...o.current,forceRender:n}),[a]);return L.jsx(bu.Provider,{value:u,children:i})},o4=V.createContext({strict:!1}),l4={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let u4=!1;function Wve(){if(u4)return;const i={};for(const e in l4)i[e]={isEnabled:t=>l4[e].some(s=>!!t[s])};t7(i),u4=!0}function h4(){return Wve(),Vge()}function Gve(i){const e=h4();for(const t in i)e[t]={...e[t],...i[t]};t7(e)}const Kve=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Zd(i){return i.startsWith("while")||i.startsWith("drag")&&i!=="draggable"||i.startsWith("layout")||i.startsWith("onTap")||i.startsWith("onPan")||i.startsWith("onLayout")||Kve.has(i)}let c4=i=>!Zd(i);function Zve(i){typeof i=="function"&&(c4=e=>e.startsWith("on")?!Zd(e):i(e))}try{Zve(require("@emotion/is-prop-valid").default)}catch{}function Jve(i,e,t){const s={};for(const r in i)r==="values"&&typeof i.values=="object"||ks(i[r])||(c4(r)||t===!0&&Zd(r)||!e&&!Zd(r)||i.draggable&&r.startsWith("onDrag"))&&(s[r]=i[r]);return s}const Jd=V.createContext({});function Yve(i,e){if(Hd(i)){const{initial:t,animate:s}=i;return{initial:t===!1||Iu(t)?t:void 0,animate:Iu(s)?s:void 0}}return i.inherit!==!1?e:{}}function Xve(i){const{initial:e,animate:t}=Yve(i,V.useContext(Jd));return V.useMemo(()=>({initial:e,animate:t}),[d4(e),d4(t)])}function d4(i){return Array.isArray(i)?i.join(" "):i}const o0=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function p4(i,e,t){for(const s in e)!ks(e[s])&&!m7(s,t)&&(i[s]=e[s])}function e0e({transformTemplate:i},e){return V.useMemo(()=>{const t=o0();return Xv(t,e,i),Object.assign({},t.vars,t.style)},[e])}function t0e(i,e){const t=i.style||{},s={};return p4(s,t,i),Object.assign(s,e0e(i,e)),s}function s0e(i,e){const t={},s=t0e(i,e);return i.drag&&i.dragListener!==!1&&(t.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=i.drag===!0?"none":`pan-${i.drag==="x"?"y":"x"}`),i.tabIndex===void 0&&(i.onTap||i.onTapStart||i.whileTap)&&(t.tabIndex=0),t.style=s,t}const f4=()=>({...o0(),attrs:{}});function i0e(i,e,t,s){const r=V.useMemo(()=>{const n=f4();return g7(n,e,y7(s),i.transformTemplate,i.style),{...n.attrs,style:{...n.style}}},[e]);if(i.style){const n={};p4(n,i.style,i),r.style={...n,...r.style}}return r}const r0e=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function l0(i){return typeof i!="string"||i.includes("-")?!1:!!(r0e.indexOf(i)>-1||/[A-Z]/u.test(i))}function n0e(i,e,t,{latestValues:s},r,n=!1,a){const l=(a??l0(i)?i0e:s0e)(e,s,r,i),u=Jve(e,typeof i=="string",n),h=i!==V.Fragment?{...u,...l,ref:t}:{},{children:c}=e,d=V.useMemo(()=>ks(c)?c.get():c,[c]);return V.createElement(i,{...h,children:d})}function a0e({scrapeMotionValuesFromProps:i,createRenderState:e},t,s,r){return{latestValues:o0e(t,s,r,i),renderState:e()}}function o0e(i,e,t,s){const r={},n=s(i,{});for(const d in n)r[d]=Wd(n[d]);let{initial:a,animate:o}=i;const l=Hd(i),u=Y3(i);e&&u&&!l&&i.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let h=t?t.initial===!1:!1;h=h||a===!1;const c=h?o:a;if(c&&typeof c!="boolean"&&!$d(c)){const d=Array.isArray(c)?c:[c];for(let f=0;f<d.length;f++){const y=Ov(i,d[f]);if(y){const{transitionEnd:v,transition:m,...g}=y;for(const b in g){let x=g[b];if(Array.isArray(x)){const P=h?x.length-1:0;x=x[P]}x!==null&&(r[b]=x)}for(const b in v)r[b]=v[b]}}}return r}const m4=i=>(e,t)=>{const s=V.useContext(Jd),r=V.useContext(Pd),n=()=>a0e(i,e,s,r);return t?n():ev(n)},l0e=m4({scrapeMotionValuesFromProps:t0,createRenderState:o0}),u0e=m4({scrapeMotionValuesFromProps:C7,createRenderState:f4}),h0e=Symbol.for("motionComponentSymbol");function c0e(i,e,t){const s=V.useRef(t);V.useInsertionEffect(()=>{s.current=t});const r=V.useRef(null);return V.useCallback(n=>{var o;n&&((o=i.onMount)==null||o.call(i,n));const a=s.current;if(typeof a=="function")if(n){const l=a(n);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(n);else a&&(a.current=n);e&&(n?e.mount(n):e.unmount())},[e])}const g4=V.createContext({});function Go(i){return i&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,"current")}function d0e(i,e,t,s,r,n){var x,P;const{visualElement:a}=V.useContext(Jd),o=V.useContext(o4),l=V.useContext(Pd),u=V.useContext(a0),h=u.reducedMotion,c=u.skipAnimations,d=V.useRef(null),f=V.useRef(!1);s=s||o.renderer,!d.current&&s&&(d.current=s(i,{visualState:e,parent:a,props:t,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:h,skipAnimations:c,isSVG:n}),f.current&&d.current&&(d.current.manuallyAnimateOnMount=!0));const y=d.current,v=V.useContext(g4);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&p0e(d.current,t,r,v);const m=V.useRef(!1);V.useInsertionEffect(()=>{y&&m.current&&y.update(t,l)});const g=t[L3],b=V.useRef(!!g&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,g))&&((P=window.MotionHasOptimisedAnimation)==null?void 0:P.call(window,g)));return tv(()=>{f.current=!0,y&&(m.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),b.current&&y.animationState&&y.animationState.animateChanges())}),V.useEffect(()=>{y&&(!b.current&&y.animationState&&y.animationState.animateChanges(),b.current&&(queueMicrotask(()=>{var _;(_=window.MotionHandoffMarkAsComplete)==null||_.call(window,g)}),b.current=!1),y.enteringChildren=void 0)}),y}function p0e(i,e,t,s){const{layoutId:r,layout:n,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:u,layoutAnchor:h,layoutCrossfade:c}=e;i.projection=new t(i.latestValues,e["data-framer-portal-id"]?void 0:v4(i.parent)),i.projection.setOptions({layoutId:r,layout:n,alwaysMeasureLayout:!!a||o&&Go(o),visualElement:i,animationType:typeof n=="string"?n:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u,layoutAnchor:h})}function v4(i){if(i)return i.options.allowProjection!==!1?i.projection:v4(i.parent)}function u0(i,{forwardMotionProps:e=!1,type:t}={},s,r){s&&Gve(s);const n=t?t==="svg":l0(i),a=n?u0e:l0e;function o(u,h){let c;const d={...V.useContext(a0),...u,layoutId:f0e(u)},{isStatic:f}=d,y=Xve(u),v=a(u,f);if(!f&&typeof window<"u"){m0e(d,s);const m=g0e(d);c=m.MeasureLayout,y.visualElement=d0e(i,v,d,r,m.ProjectionNode,n)}return L.jsxs(Jd.Provider,{value:y,children:[c&&y.visualElement?L.jsx(c,{visualElement:y.visualElement,...d}):null,n0e(i,u,c0e(v,y.visualElement,h),v,f,e,n)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${i.displayName??i.name??""})`}`;const l=V.forwardRef(o);return l[h0e]=i,l}function f0e({layoutId:i}){const e=V.useContext(bu).id;return e&&i!==void 0?e+"-"+i:i}function m0e(i,e){const t=V.useContext(o4).strict;if(process.env.NODE_ENV!=="production"&&e&&t){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";i.ignoreStrict?Fo(!1,s,"lazy-strict-mode"):on(!1,s,"lazy-strict-mode")}}function g0e(i){const e=h4(),{drag:t,layout:s}=e;if(!t&&!s)return{};const r={...t,...s};return{MeasureLayout:t!=null&&t.isEnabled(i)||s!=null&&s.isEnabled(i)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function v0e(i,e){if(typeof Proxy>"u")return u0;const t=new Map,s=(n,a)=>u0(n,a,i,e),r=(n,a)=>(process.env.NODE_ENV!=="production"&&nv(!1,"motion() is deprecated. Use motion.create() instead."),s(n,a));return new Proxy(r,{get:(n,a)=>a==="create"?s:(t.has(a)||t.set(a,u0(a,void 0,i,e)),t.get(a))})}const y0e=(i,e)=>e.isSVG??l0(i)?new $ge(e):new Oge(e,{allowProjection:i!==V.Fragment});class C0e extends Yn{constructor(e){super(e),e.animationState||(e.animationState=zge(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();$d(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let b0e=0;class w0e extends Yn{constructor(){super(...arguments),this.id=b0e++,this.isExitComplete=!1}update(){var n;if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"){const l=Oa(this.node,a,o);if(l){const{transition:u,transitionEnd:h,...c}=l;for(const d in c)(n=this.node.getValue(d))==null||n.jump(c[d])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const x0e={animation:{Feature:C0e},exit:{Feature:w0e}};function _u(i){return{point:{x:i.pageX,y:i.pageY}}}const E0e=i=>e=>Uv(e)&&i(e,_u(e));function Du(i,e,t,s){return Lu(i,e,E0e(t),s)}const y4=({current:i})=>i?i.ownerDocument.defaultView:null,C4=(i,e)=>Math.abs(i-e);function V0e(i,e){const t=C4(i.x,e.x),s=C4(i.y,e.y);return Math.sqrt(t**2+s**2)}const b4=new Set(["auto","scroll"]);class w4{constructor(e,t,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:n=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Yd(this.lastRawMoveEventInfo,this.transformPagePoint));const f=h0(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,v=V0e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!y&&!v)return;const{point:m}=f,{timestamp:g}=Ds;this.history.push({...m,timestamp:g});const{onStart:b,onMove:x}=this.handlers;y||(b&&b(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,f)},this.handlePointerMove=(f,y)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=y,this.lastMoveEventInfo=Yd(y,this.transformPagePoint),Tt.update(this.updatePoint,!0)},this.handlePointerUp=(f,y)=>{this.end();const{onEnd:v,onSessionEnd:m,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=h0(f.type==="pointercancel"?this.lastMoveEventInfo:Yd(y,this.transformPagePoint),this.history);this.startEvent&&v&&v(f,b),m&&m(f,b)},!Uv(e))return;this.dragSnapToOrigin=n,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const l=_u(e),u=Yd(l,this.transformPagePoint),{point:h}=u,{timestamp:c}=Ds;this.history=[{...h,timestamp:c}];const{onSessionStart:d}=t;d&&d(e,h0(u,this.history)),this.removeListeners=wu(Du(this.contextWindow,"pointermove",this.handlePointerMove),Du(this.contextWindow,"pointerup",this.handlePointerUp),Du(this.contextWindow,"pointercancel",this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(b4.has(s.overflowX)||b4.has(s.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},n={x:r.x-t.x,y:r.y-t.y};n.x===0&&n.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=n.x,this.lastMoveEventInfo.point.y+=n.y):this.history.length>0&&(this.history[0].x-=n.x,this.history[0].y-=n.y),this.scrollPositions.set(e,r),Tt.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Gn(this.updatePoint)}}function Yd(i,e){return e?{point:e(i.point)}:i}function x4(i,e){return{x:i.x-e.x,y:i.y-e.y}}function h0({point:i},e){return{point:i,delta:x4(i,E4(e)),offset:x4(i,S0e(e)),velocity:T0e(e,.1)}}function S0e(i){return i[0]}function E4(i){return i[i.length-1]}function T0e(i,e){if(i.length<2)return{x:0,y:0};let t=i.length-1,s=null;const r=E4(i);for(;t>=0&&(s=i[t],!(r.timestamp-s.timestamp>di(e)));)t--;if(!s)return{x:0,y:0};s===i[0]&&i.length>2&&r.timestamp-s.timestamp>di(e)*2&&(s=i[1]);const n=Qi(r.timestamp-s.timestamp);if(n===0)return{x:0,y:0};const a={x:(r.x-s.x)/n,y:(r.y-s.y)/n};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function P0e(i,{min:e,max:t},s){return e!==void 0&&i<e?i=s?qt(e,i,s.min):Math.max(i,e):t!==void 0&&i>t&&(i=s?qt(t,i,s.max):Math.min(i,t)),i}function V4(i,e,t){return{min:e!==void 0?i.min+e:void 0,max:t!==void 0?i.max+t-(i.max-i.min):void 0}}function I0e(i,{top:e,left:t,bottom:s,right:r}){return{x:V4(i.x,t,r),y:V4(i.y,e,s)}}function S4(i,e){let t=e.min-i.min,s=e.max-i.max;return e.max-e.min<i.max-i.min&&([t,s]=[s,t]),{min:t,max:s}}function R0e(i,e){return{x:S4(i.x,e.x),y:S4(i.y,e.y)}}function A0e(i,e){let t=.5;const s=Gs(i),r=Gs(e);return r>s?t=xu(e.min,e.max-s,i.min):s>r&&(t=xu(i.min,i.max-r,e.min)),Lr(0,1,t)}function L0e(i,e){const t={};return e.min!==void 0&&(t.min=e.min-i.min),e.max!==void 0&&(t.max=e.max-i.min),t}const c0=.35;function _0e(i=c0){return i===!1?i=0:i===!0&&(i=c0),{x:T4(i,"left","right"),y:T4(i,"top","bottom")}}function T4(i,e,t){return{min:P4(i,e),max:P4(i,t)}}function P4(i,e){return typeof i=="number"?i:i[e]||0}const D0e=new WeakMap;class k0e{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ys(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const n=c=>{t&&this.snapToCursor(_u(c).point),this.stopAnimation()},a=(c,d)=>{const{drag:f,dragPropagation:y,onDragStart:v}=this.getProps();if(f&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ege(f),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kr(g=>{let b=this.getAxisMotionValue(g).get()||0;if(_r.test(b)){const{projection:x}=this.visualElement;if(x&&x.layout){const P=x.layout.layoutBox[g];P&&(b=Gs(P)*(parseFloat(b)/100))}}this.originPoint[g]=b}),v&&Tt.update(()=>v(c,d),!1,!0),Nv(this.visualElement,"transform");const{animationState:m}=this.visualElement;m&&m.setActive("whileDrag",!0)},o=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d;const{dragPropagation:f,dragDirectionLock:y,onDirectionLock:v,onDrag:m}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:g}=d;if(y&&this.currentDirection===null){this.currentDirection=M0e(g),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",d.point,g),this.updateAxis("y",d.point,g),this.visualElement.render(),m&&Tt.update(()=>m(c,d),!1,!0)},l=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d,this.stop(c,d),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new w4(e,{onSessionStart:n,onStart:a,onMove:o,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:y4(this.visualElement),element:this.visualElement.current})}stop(e,t){const s=e||this.latestPointerEvent,r=t||this.latestPanInfo,n=this.isDragging;if(this.cancel(),!n||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&Tt.postRender(()=>o(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,s){const{drag:r}=this.getProps();if(!s||!Xd(e,r,this.currentDirection))return;const n=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=P0e(a,this.constraints[e],this.elastic[e])),n.set(a)}resolveConstraints(){var n;const{dragConstraints:e,dragElastic:t}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(n=this.visualElement.projection)==null?void 0:n.layout,r=this.constraints;e&&Go(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=I0e(s.layoutBox,e):this.constraints=!1,this.elastic=_0e(t),r!==this.constraints&&!Go(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&kr(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=L0e(s.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Go(e))return!1;const s=e.current;on(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const n=Rge(s,r.root,this.visualElement.getTransformPagePoint());let a=R0e(r.layout.layoutBox,n);if(t){const o=t(Tge(a));this.hasMutatedConstraints=!!o,o&&(a=i7(o))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:n,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},u=kr(h=>{if(!Xd(h,t,this.currentDirection))return;let c=l&&l[h]||{};(a===!0||a===h)&&(c={min:0,max:0});const d=r?200:1e6,f=r?40:1e7,y={type:"inertia",velocity:s?e[h]:0,bounceStiffness:d,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...n,...c};return this.startAxisValueAnimation(h,y)});return Promise.all(u).then(o)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return Nv(this.visualElement,e),s.start(kv(e,s,0,t,this.visualElement,!1))}stopAnimation(){kr(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),r=s[t];return r||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){kr(t=>{const{drag:s}=this.getProps();if(!Xd(t,s,this.currentDirection))return;const{projection:r}=this.visualElement,n=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:o}=r.layout.layoutBox[t],l=n.get()||0;n.set(e[t]-qt(a,o,.5)+l)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!Go(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};kr(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();r[a]=A0e({min:l,max:l},this.constraints[a])}});const{transformTemplate:n}=this.visualElement.getProps();this.visualElement.current.style.transform=n?n({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),kr(a=>{if(!Xd(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:u}=this.constraints[a];o.set(qt(l,u,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;D0e.set(this.visualElement,this);const e=this.visualElement.current,t=Du(e,"pointerdown",u=>{const{drag:h,dragListener:c=!0}=this.getProps(),d=u.target,f=d!==e&&age(d);h&&c&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Go(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=O0e(e,u.current,()=>this.scalePositionWithinConstraints())))},{projection:n}=this.visualElement,a=n.addEventListener("measure",r);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),Tt.read(r);const o=Lu(window,"resize",()=>this.scalePositionWithinConstraints()),l=n.addEventListener("didUpdate",({delta:u,hasLayoutChanged:h})=>{this.isDragging&&h&&(kr(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=u[c].translate,d.set(d.get()+u[c].translate))}),this.visualElement.render())});return()=>{o(),t(),a(),l&&l(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:n=!1,dragElastic:a=c0,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:n,dragElastic:a,dragMomentum:o}}}function I4(i){let e=!0;return()=>{if(e){e=!1;return}i()}}function O0e(i,e,t){const s=K3(i,I4(t)),r=K3(e,I4(t));return()=>{s(),r()}}function Xd(i,e,t){return(e===!0||e===i)&&(t===null||t===i)}function M0e(i,e=10){let t=null;return Math.abs(i.y)>e?t="y":Math.abs(i.x)>e&&(t="x"),t}class N0e extends Yn{constructor(e){super(e),this.removeGroupControls=Hi,this.removeListeners=Hi,this.controls=new k0e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hi}update(){const{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const d0=i=>(e,t)=>{i&&Tt.update(()=>i(e,t),!1,!0)};class F0e extends Yn{constructor(){super(...arguments),this.removePointerDownListener=Hi}onPointerDown(e){this.session=new w4(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:y4(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:d0(e),onStart:d0(t),onMove:d0(s),onEnd:(n,a)=>{delete this.session,r&&Tt.postRender(()=>r(n,a))}}}mount(){this.removePointerDownListener=Du(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let p0=!1;class q0e extends V.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:r}=this.props,{projection:n}=e;n&&(t.group&&t.group.add(n),s&&s.register&&r&&s.register(n),p0&&n.root.didUpdate(),n.addEventListener("animationComplete",()=>{this.safeToRemove()}),n.setOptions({...n.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Gd.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:r,isPresent:n}=this.props,{projection:a}=s;return a&&(a.isPresent=n,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),p0=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==n?a.willUpdate():this.safeToRemove(),e.isPresent!==n&&(n?a.promote():a.relegate()||Tt.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=t,s.root.didUpdate(),Qv.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;p0=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function R4(i){const[e,t]=r4(),s=V.useContext(bu);return L.jsx(q0e,{...i,layoutGroup:s,switchLayoutGroup:V.useContext(g4),isPresent:e,safeToRemove:t})}const B0e={pan:{Feature:F0e},drag:{Feature:N0e,ProjectionNode:s4,MeasureLayout:R4}};function A4(i,e,t){const{props:s}=i;i.animationState&&s.whileHover&&i.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,n=s[r];n&&Tt.postRender(()=>n(e,_u(e)))}class $0e extends Yn{mount(){const{current:e}=this.node;e&&(this.unmount=sge(e,(t,s)=>(A4(this.node,s,"Start"),r=>A4(this.node,r,"End"))))}unmount(){}}class H0e extends Yn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=wu(Lu(this.node.current,"focus",()=>this.onFocus()),Lu(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function L4(i,e,t){const{props:s}=i;if(i.current instanceof HTMLButtonElement&&i.current.disabled)return;i.animationState&&s.whileTap&&i.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),n=s[r];n&&Tt.postRender(()=>n(e,_u(e)))}class Q0e extends Yn{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=lge(e,(r,n)=>(L4(this.node,n,"Start"),(a,{success:o})=>L4(this.node,a,o?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const f0=new WeakMap,m0=new WeakMap,U0e=i=>{const e=f0.get(i.target);e&&e(i)},j0e=i=>{i.forEach(U0e)};function z0e({root:i,...e}){const t=i||document;m0.has(t)||m0.set(t,{});const s=m0.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(j0e,{root:i,...e})),s[r]}function W0e(i,e,t){const s=z0e(e);return f0.set(i,t),s.observe(i),()=>{f0.delete(i),s.unobserve(i)}}const G0e={some:0,all:1};class K0e extends Yn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var l;(l=this.stopObserver)==null||l.call(this);const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:r="some",once:n}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:G0e[r]},o=u=>{const{isIntersecting:h}=u;if(this.isInView===h||(this.isInView=h,n&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=h?c:d;f&&f(u)};this.stopObserver=W0e(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Z0e(e,t))&&this.startObserver()}unmount(){var e;(e=this.stopObserver)==null||e.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Z0e({viewport:i={}},{viewport:e={}}={}){return t=>i[t]!==e[t]}const J0e={...x0e,...{inView:{Feature:K0e},tap:{Feature:Q0e},focus:{Feature:H0e},hover:{Feature:$0e}},...B0e,...{layout:{ProjectionNode:s4,MeasureLayout:R4}}},_4=v0e(J0e,y0e);ni("Tutorial",null),Qs("Tutorial",(i,e,t,s)=>{var o;const r=((o=i.slides)==null?void 0:o.length)??0,n={};let a=0;for(let l=0;l<r;l++){const u=t.respondToSlide(l,i,s);s=u.participantState,n[l]=u.value??{},a+=u.duration??500}return{responseData:{slides:n},participantState:s,duration:a}},{respondToSlide:(i,e,t)=>({value:{},participantState:t,duration:500})});const D4=V.createContext({setCanProgress:()=>{},autoAdvance:()=>{},setSlideData:()=>{}}),Y0e=({locked:i=!1}={})=>{const e=V.useContext(D4),t=V.useRef(!1);return!t.current&&i&&(t.current=!0,e.setCanProgress(!1)),{setData:e.setSlideData,unlock:({autoAdvanceMs:s}={})=>{e.setCanProgress(!0),s!==void 0&&e.autoAdvance(s)}}},k4="px-4 py-3 border-2 font-bold text-lg rounded-xl transition-all duration-100 outline-none focus:outline-none focus:ring-0",O4=({next:i,slides:e,fadeDuration:t=.3,finishText:s="Start",containerClass:r,animate:n=!1,nextKey:a="ArrowRight",backKey:o="ArrowLeft",theme:l})=>{const u=An(),c=Gr(l??u),d=`${k4} ${c.buttonBg} ${c.buttonText} ${c.buttonBorder} ${c.buttonShadow} cursor-pointer hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-none`,f=`${k4} ${c.buttonDisabledBg} ${c.buttonDisabledText} ${c.buttonDisabledBorder} ${c.buttonDisabledShadow} cursor-default`,[y,v]=V.useState(0),[m,g]=V.useState({}),b=V.useRef(),x=V.useRef({}),P=m[y]!==!1,_=V.useRef(P),[A,D]=V.useState(!1);V.useEffect(()=>{if(P&&!_.current){D(!0);const F=setTimeout(()=>D(!1),300);return()=>clearTimeout(F)}_.current=P},[P]);const T=V.useCallback(F=>{g($=>({...$,[y]:F}))},[y]),M=V.useCallback(F=>{x.current[y]={...x.current[y],...F}},[y]),O=V.useCallback(()=>{y===e.length-1?i({slides:x.current}):v(F=>F+1)},[y,e.length,i]),H=V.useCallback(()=>{P&&O()},[P,O]),U=V.useCallback((F=0)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>O(),F)},[O]);V.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const R=V.useCallback(()=>{y>0&&v(F=>F-1)},[y]);return V.useEffect(()=>{if(a===!1&&o===!1)return;const F=$=>{a&&$.key===a&&($.preventDefault(),H()),o&&$.key===o&&($.preventDefault(),R())};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[a,o,H,R]),L.jsx(zve,{children:L.jsxs("div",{className:`${r??c.containerBg} ${c.text} ${n?"animate-slide-down opacity-0":""}`,style:{width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[L.jsx("div",{style:{flex:1,position:"relative"},children:L.jsx($ve,{mode:"popLayout",children:L.jsx(_4.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:t},style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:L.jsx(D4.Provider,{value:{setCanProgress:T,autoAdvance:U,setSlideData:M},children:e[y]})},y)})}),L.jsxs("div",{style:{padding:"1.5rem 1.5rem 3rem",display:"grid",gridTemplateColumns:"1fr auto 1fr",alignItems:"center"},children:[L.jsx("div",{style:{justifySelf:"end",marginRight:"1rem"},children:L.jsx("button",{onClick:R,className:d,tabIndex:-1,onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&F.preventDefault()},style:{visibility:y>0?"visible":"hidden"},children:"←"})}),L.jsx("div",{style:{display:"flex",gap:6},children:e.map((F,$)=>L.jsx("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:$===y?c.dotActive:c.dotInactive,transition:"background-color 0.2s"}},$))}),L.jsx("div",{style:{justifySelf:"start",marginLeft:"1rem"},children:L.jsx(_4.button,{onClick:H,tabIndex:-1,onKeyDown:F=>{(F.key===" "||F.key==="Enter")&&F.preventDefault()},animate:{scale:A?1.2:1},transition:{type:"spring",stiffness:500,damping:15},className:(P?d:f)+(y===e.length-1?" px-8":""),children:y===e.length-1?s:"→"})})]})]})})};ni("RandomDotKinematogram","rdk");const Or={validKeys:[],duration:1e3,responseEndsTrial:!0,dotCount:300,dotSetCount:1,direction:0,coherence:.5,opposite:0,speed:60,dotLifetime:-1,dotRadius:2,dotColor:"white",backgroundColor:"gray",apertureShape:"ellipse",apertureWidth:600,apertureHeight:400,reinsertMode:"opposite",noiseMovement:"randomDirection",fixationTime:500,showFixation:!1,fixationWidth:15,fixationHeight:15,fixationColor:"white",fixationThickness:2,showBorder:!1,borderWidth:1,borderColor:"black"};Qs("RandomDotKinematogram",(i,e,t,s)=>{const r={...Or,...i},n=t.respond(r,s),{rt:a,response:o}=n.value,l=r.fixationTime??Or.fixationTime,u=r.duration??Or.duration,c=(r.responseEndsTrial??Or.responseEndsTrial)&&a!=null?a:u,d=Array.isArray(r.correctResponse)?r.correctResponse.map(f=>f.toLowerCase()):r.correctResponse?[r.correctResponse.toLowerCase()]:null;return{responseData:{...r,rt:a,response:o,correct:o&&d?d.includes(o.toLowerCase()):null,framesDisplayed:0,measuredRefreshRate:null},participantState:n.participantState,duration:l+c}},{respond:(i,e)=>{const t=$w({driftRate:{type:"normal",mean:.005*(i.coherence??Or.coherence),sd:.0012},boundaries:.75,startingPoint:0,noiseLevel:.02,sensoryDelay:{type:"uniform",min:150,max:250},motorDelay:{type:"uniform",min:130,max:210},timeLimit:i.duration??Or.duration,stimOffset:i.stimulusDuration??i.duration??Or.duration,postStimStrategy:{type:"continue"}}),s=Hw(t.choice,i.validKeys,i.correctResponse);return{value:{rt:s?t.rt:null,response:s},participantState:e}}});const X0e=10,M4=.1,e1e=(i,e,t,s)=>{const r=Math.floor(i*e),n=Math.floor(i*t),a=[...Array(r).fill("coherent"),...Array(n).fill("opposite"),...Array(i-r-n).fill(s)];return gm(a)},Fa=(i,e)=>i+Math.random()*(e-i),t1e=(i,e,t,s,r)=>{const n=e/2,a=i==="circle"||i==="square"?n:t/2,o=(l,u)=>{const h=n*2,c=a*2,d=s-n,f=r-a;return[((l-d)%h+h)%h+d,((u-f)%c+c)%c+f]};return i==="circle"||i==="ellipse"?{centerX:s,centerY:r,getRandomPosition(){const l=Fa(-Math.PI,Math.PI),u=Math.sqrt(Math.random());return[Math.cos(l)*u*n+s,Math.sin(l)*u*a+r]},isOutside(l,u,h){const c=n+h,d=a+h,f=(l-s)/c,y=(u-r)/d;return f*f+y*y>1},getOppositePosition(l,u,h){if(u!==void 0&&h!==void 0){const c=u*u+h*h;if(c>1e-10){const d=Math.sqrt(c),f=u/d,y=h/d,v=l.x-s,m=l.y-r,g=n*n,b=a*a,x=f*f/g+y*y/b,P=v*f/g+m*y/b,_=v*v/g+m*m/b-1,A=P*P-x*_;if(A>=0){const D=(P+Math.sqrt(A))/x;if(D>0&&Number.isFinite(D))return[l.x-f*D,l.y-y*D]}}}return this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=2*s-l.x,h=2*r-l.y,c=(u-s)/n,d=(h-r)/a,f=Math.sqrt(c*c+d*d);return f>1?[s+c/f*n,r+d/f*a]:[u,h]},wrap:o,clip(l){l.beginPath(),l.ellipse(s,r,n,a,0,0,Math.PI*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.beginPath(),l.ellipse(s,r,n+h/2,a+h/2,0,0,Math.PI*2),l.stroke()}}:{centerX:s,centerY:r,getRandomPosition(){return[Fa(s-n,s+n),Fa(r-a,r+a)]},isOutside(l,u,h){const c=n+h,d=a+h;return l<s-c||l>s+c||u<r-d||u>r+d},getOppositePosition(l,u,h){if(u===void 0||h===void 0)return this.getOppositePositionSimple(l);const c=Math.sqrt(u*u+h*h);if(c<1e-10)return this.getOppositePositionSimple(l);const d=-u/c,f=-h/c,y=s-n,v=s+n,m=r-a,g=r+a,b=d!==0?(y-l.x)/d:-1/0,x=d!==0?(v-l.x)/d:-1/0,P=f!==0?(m-l.y)/f:-1/0,_=f!==0?(g-l.y)/f:-1/0,A=Math.max(Math.min(b,x),Math.min(P,_)),D=Math.min(Math.max(b,x),Math.max(P,_));return D>0&&A<=D&&Number.isFinite(D)?[l.x+d*D,l.y+f*D]:this.getOppositePositionSimple(l)},getOppositePositionSimple(l){const u=s-n,h=s+n,c=r-a,d=r+a;let f=l.x,y=l.y;return l.x<u?f=h:l.x>h&&(f=u),l.y<c?y=d:l.y>d&&(y=c),[f,y]},wrap:o,clip(l){l.beginPath(),l.rect(s-n,r-a,n*2,a*2),l.clip()},drawBorder(l,u,h){l.strokeStyle=u,l.lineWidth=h,l.strokeRect(s-n-h/2,r-a-h/2,n*2+h,a*2+h)}}},s1e=(i,e,t)=>{const[s,r]=t.getRandomPosition(),n=i==="randomDirection"?Fa(-Math.PI,Math.PI):0;return{x:s,y:r,randomDirX:n?Math.cos(n):0,randomDirY:n?-Math.sin(n):0,lifeCount:Fa(0,e>0?e:0),assignedMovement:i}},i1e=(i,e,t,s,r,n,a,o,l)=>{const u={...i};if(u.lifeCount+=t,s>0&&u.lifeCount>=s)return[u.x,u.y]=r.getRandomPosition(),u.lifeCount=0,u;let h=i.assignedMovement;if(l!==void 0&&(h=l,u.assignedMovement=h,h==="randomDirection")){const y=Fa(-Math.PI,Math.PI);u.randomDirX=Math.cos(y),u.randomDirY=-Math.sin(y)}let c=0,d=0;switch(h){case"coherent":c=o[0],d=o[1];break;case"opposite":c=-o[0],d=-o[1];break;case"randomTeleport":return[u.x,u.y]=r.getRandomPosition(),u;case"randomWalk":{const y=Fa(-Math.PI,Math.PI);c=Math.cos(y),d=-Math.sin(y);break}case"randomDirection":c=u.randomDirX,d=u.randomDirY;break}if(u.x+=c*e,u.y+=d*e,r.isOutside(u.x,u.y,a))if(n==="random")[u.x,u.y]=r.getRandomPosition();else if(n==="oppositeSimple")[u.x,u.y]=r.getOppositePositionSimple(u);else if(n==="opposite")[u.x,u.y]=r.getOppositePosition(u,c,d);else if(n==="wrap")[u.x,u.y]=r.wrap(u.x,u.y);else throw new Error(`Unknown reinsertType: ${n}`);return u},N4=V.forwardRef((i,e)=>{const{width:t,height:s,dotCount:r,dotSetCount:n,direction:a,coherence:o,opposite:l,speed:u,dotLifetime:h,updateRate:c,dotRadius:d,dotCharacter:f,dotColor:y,coherentDotColor:v,backgroundColor:m,apertureShape:g,apertureWidth:b,apertureHeight:x,apertureCenterX:P,apertureCenterY:_,reinsertMode:A,noiseMovement:D,reassignEveryMs:T,showFixation:M,fixationWidth:O,fixationHeight:H,fixationColor:U,fixationThickness:R,showBorder:F,borderWidth:$,borderColor:Q,active:W=!0,initialRefreshRate:G,style:ue,className:ee}={...Or,...i},oe=V.useRef(null),re=V.useRef(),ce=V.useRef(),xe=V.useRef(),ge=V.useRef(0),ie=V.useRef(0),Ee=V.useRef([]),et=V.useRef(null),Xt=V.useRef(!1),zt=P??t/2,Os=_??s/2,Et=V.useMemo(()=>t1e(g,b,x,zt,Os),[g,b,x,zt,Os]),fs=V.useMemo(()=>{const Oe=(90-a)*Math.PI/180;return[Math.cos(Oe),-Math.sin(Oe)]},[a]),is=V.useRef([]),_e=V.useRef(0);V.useEffect(()=>{const Oe=Math.floor(r*o),Ke=Math.floor(r*l);is.current=Array.from({length:n},()=>Array.from({length:r},(Ie,rs)=>{let Cs;return rs<Oe?Cs="coherent":rs<Oe+Ke?Cs="opposite":Cs=D,s1e(Cs,h,Et)}))},[]),V.useEffect(()=>{typeof G=="number"&&G>=20&&G<=300&&(et.current=1e3/G,Xt.current=!0)},[G]),V.useImperativeHandle(e,()=>({getStats:()=>({framesDisplayed:ie.current,measuredRefreshRate:et.current?Math.round(1e3/et.current):null})}));const tt=V.useCallback((Oe,Ke)=>{Ke.forEach(Ie=>{const rs=v&&Ie.assignedMovement==="coherent"?v:y;if(Oe.fillStyle=rs,f){const Cs=d*2.5;Oe.font=`${Cs}px monospace`,Oe.textAlign="center",Oe.textBaseline="middle",Oe.fillText(f,Ie.x,Ie.y)}else Oe.beginPath(),Oe.arc(Ie.x,Ie.y,d,0,Math.PI*2),Oe.fill()})},[y,v,d,f]),Bt=V.useCallback((Oe,Ke,Ie)=>{M&&(Oe.fillStyle=U,Oe.fillRect(Ke-O,Ie-R/2,O*2,R),Oe.fillRect(Ke-R/2,Ie-H,R,H*2))},[M,U,R,O,H]),Ht=V.useCallback(Oe=>{F&&Et.drawBorder(Oe,Q,$)},[F,Q,$,Et]),gt=V.useCallback(Oe=>{const Ke=oe.current,Ie=Ke==null?void 0:Ke.getContext("2d");if(!Ke||!Ie)return;ce.current===void 0&&(ce.current=Oe),xe.current===void 0&&(xe.current=Oe);const rs=Oe-xe.current;if(xe.current=Oe,ie.current++,rs>0&&rs<500){if(Xt.current)et.current=M4*rs+(1-M4)*et.current;else if(Ee.current.push(rs),Ee.current.length>=X0e){const Js=[...Ee.current].sort((Ys,zi)=>Ys-zi),ji=Math.floor(Js.length/2);et.current=Js.length%2?Js[ji]:(Js[ji-1]+Js[ji])/2,Xt.current=!0}}const Cs=Oe-(ce.current??Oe),bs=Math.min(Cs,100),hn=c&&c>0?1e3/c:0,Zs=!c||c<=0||bs>=hn;if(Ie.clearRect(0,0,Ke.width,Ke.height),Ie.save(),Et.clip(Ie),Ie.fillStyle=m,Ie.fillRect(0,0,Ke.width,Ke.height),Ie.restore(),!W)Bt(Ie,Et.centerX,Et.centerY);else{if(Zs){const ji=u*bs/1e3;let Ys=!1;if(T!==void 0)if(T===0)Ys=!0;else{ge.current+=bs;const Y=Xt.current&&et.current?et.current*.5:0;Ys=ge.current+Y>=T,Ys&&(ge.current%=T)}const zi=Ys?e1e(r,o,l,D):null,aa=is.current[_e.current].map((Y,ne)=>i1e(Y,ji,bs,h,Et,A,d,fs,zi==null?void 0:zi[ne]));is.current[_e.current]=aa,_e.current=(_e.current+1)%n,ce.current=Oe}const Js=is.current[_e.current];Ie.save(),Et.clip(Ie),tt(Ie,Js),Ie.restore(),Ie.save(),Ie.beginPath(),Bt(Ie,Et.centerX,Et.centerY),Ht(Ie),Ie.restore()}re.current=requestAnimationFrame(gt)},[W,m,D,o,l,r,u,h,Et,A,n,d,fs,c,tt,Bt,Ht,T]);return V.useEffect(()=>(re.current=requestAnimationFrame(gt),()=>{re.current&&cancelAnimationFrame(re.current)}),[gt]),V.useEffect(()=>{const Oe=oe.current;if(!Oe)return;const Ke=window.devicePixelRatio||1;Oe.width=t*Ke,Oe.height=s*Ke,Oe.style.width=`${t}px`,Oe.style.height=`${s}px`;const Ie=Oe.getContext("2d");Ie&&Ie.scale(Ke,Ke)},[t,s]),L.jsx("canvas",{ref:oe,style:{display:"block",...ue},className:ee})}),F4=i=>{const{store:e,stimulusDuration:t,updateRate:s,dotCharacter:r,coherentDotColor:n,apertureCenterX:a=window.innerWidth/2,apertureCenterY:o=window.innerHeight/2,reassignEveryMs:l,responseHint:u,validKeys:h,duration:c,responseEndsTrial:d,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,dotRadius:P,dotColor:_,backgroundColor:A,apertureShape:D,apertureWidth:T,apertureHeight:M,reinsertMode:O,noiseMovement:H,showFixation:U,fixationTime:R,fixationWidth:F,fixationHeight:$,fixationColor:Q,fixationThickness:W,showBorder:G,borderWidth:ue,borderColor:ee}={...Or,...i},oe=V.useRef(i);oe.current=i;const re=V.useRef(null),ce=V.useRef(performance.now()),xe=V.useRef(!1),ge=V.useRef(null),ie=V.useRef(null),[Ee,et]=V.useState(null),[Xt,zt]=V.useState(R<=0),[Os,Et]=V.useState(!0),fs=e==null?void 0:e._reactiveScreenRefreshRate,is=V.useCallback((_e,tt)=>{var Cs;if(xe.current)return;xe.current=!0;const{next:Bt,data:Ht,store:gt,updateStore:Oe,...Ke}=oe.current,Ie=(Cs=re.current)==null?void 0:Cs.getStats(),rs=Array.isArray(Ke.correctResponse)?Ke.correctResponse.map(bs=>bs.toLowerCase()):Ke.correctResponse?[Ke.correctResponse.toLowerCase()]:null;Bt({...Or,...Ke,rt:tt,response:_e,correct:_e&&rs?rs.includes(_e):null,framesDisplayed:(Ie==null?void 0:Ie.framesDisplayed)??0,measuredRefreshRate:(Ie==null?void 0:Ie.measuredRefreshRate)??null})},[]);return V.useEffect(()=>{if(R<=0)return;const _e=setTimeout(()=>zt(!0),R);return()=>clearTimeout(_e)},[R]),V.useEffect(()=>{const _e=t??c;if(_e<=0)return;const tt=setTimeout(()=>Et(!1),R+_e);return()=>clearTimeout(tt)},[R,t,c]),V.useEffect(()=>{if(c<=0)return;const _e=setTimeout(()=>{is(ge.current,ie.current)},R+c);return()=>clearTimeout(_e)},[R,c,is]),V.useEffect(()=>{const _e=tt=>{if(xe.current||ge.current)return;const Bt=tt.key.toLowerCase(),Ht=h.length>0?h.map(gt=>gt.toLowerCase()):null;if(!Ht||Ht.includes(Bt)){const gt=performance.now()-ce.current;ge.current=Bt,ie.current=gt,et(Bt),d&&is(Bt,gt)}};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[h,d,is]),L.jsxs("div",{style:{width:"100vw",height:"100vh",overflow:"hidden",margin:0,padding:0,backgroundColor:A},children:[L.jsx(N4,{ref:re,width:window.innerWidth,height:window.innerHeight,active:Xt&&Os,initialRefreshRate:fs,dotCount:f,dotSetCount:y,direction:v,coherence:m,opposite:g,speed:b,dotLifetime:x,updateRate:s,dotRadius:P,dotCharacter:r,dotColor:_,coherentDotColor:n,backgroundColor:A,apertureShape:D,apertureWidth:T,apertureHeight:M,apertureCenterX:a,apertureCenterY:o,reinsertMode:O,noiseMovement:H,reassignEveryMs:l,showFixation:U,fixationWidth:F,fixationHeight:$,fixationColor:Q,fixationThickness:W,showBorder:G,borderWidth:ue,borderColor:ee}),u&&!Os&&!Ee&&L.jsx("div",{style:{position:"absolute",top:"60%",width:"100%",textAlign:"center",color:"white",fontSize:"1.25rem"},children:u})]})},r1e={Text:ac,ProlificEnding:zw,EnterFullscreen:oS,ExitFullscreen:lS,Quest:G5,Upload:sS,MicrophoneCheck:Yw,PlainInput:jw,RequestFilePermission:ES,CanvasBlock:VS,CheckDevice:SS,StoreUI:Jpe,Tutorial:O4,RandomDotKinematogram:F4},n1e={voicerecorder:Tne};function g0(i){return typeof i=="object"&&i!==null&&typeof i.type=="string"}function a1e({timeline:i,config:e={showProgressBar:!1},components:t={},questions:s={},hybridParticipant:r}){const n=Wpe(),a=V.useMemo(()=>tc(i),[i]),o=V.useRef((()=>{const R={},F=new URLSearchParams(window.location.search);for(const[G,ue]of F.entries())R[G]=ue;const $=Ol.getRegistry()||[],Q={};for(const[G,ue]of Object.entries(R))Q[G]={value:ue,registered:!1,defaultValue:void 0,type:void 0,description:void 0};for(const G of $)Q[G.name]={value:G.value!==void 0?G.value:R[G.name],registered:!0,defaultValue:G.defaultValue,type:G.type,description:G.description};return[{index:-1,trialNumber:-1,start:Ps(),end:Ps(),duration:0,type:"",name:"",responseData:{userAgent:navigator.userAgent,params:Q}}]})()),[l,u]=V.useState(0),h=V.useRef(Ps()),c=V.useRef({}),[d,f]=V.useState(()=>Rn(a,0,()=>c.current,()=>o.current,R=>{c.current={...c.current,...R}})),y=!n&&va("hybridSimulation",!1,"boolean")?"hybrid":"none",v=V.useRef(r||{}),m=V.useRef(-1),g={...r1e,...t},b={...n1e,...s},x=V.useMemo(()=>{const R=a.instructions.length;return R>0?d/R:0},[d,a.instructions]);V.useEffect(()=>{window.scrollTo(0,0)},[d]);function P(R){c.current={...c.current,...R}}function _(R,F,$){const Q=Ps(),W=a.instructions[d],G=F!==void 0?F:h.current,ue=$!==void 0?$:Q;if((W==null?void 0:W.type)==="ExecuteContent"){const oe=W.content;if(g0(oe)){let re={index:d,trialNumber:l+1,start:G,end:ue,duration:ue-G,type:oe.type,name:oe.name??"",...oe.csv!==void 0?{csv:oe.csv}:{},responseData:R};re=sc(re,oe,o.current,c.current),o.current=[...o.current,re],u(ce=>ce+1)}else console.log("ExecuteContent finished, but content wasn't standard component format:",oe)}const ee=Rn(a,d+1,()=>c.current,()=>o.current,oe=>P(oe));ee<a.instructions.length&&(h.current=Ps()),f(ee)}const A=V.useCallback(R=>{let F=0;const $=Ps(),Q=2e4;let W,G=$;const ue=1e3,ee=()=>{const xe=Ps()-$;return xe>0?Math.round(F*1e3/xe):null},oe=()=>{W&&cancelAnimationFrame(W)},re=ce=>{F++;const xe=ce-$;ce-G>=ue&&(R(ee()),G=ce),xe<Q?W=requestAnimationFrame(re):(oe(),R(ee()))};return W=requestAnimationFrame(re),oe},[]),D=({children:R,collectRefreshRate:F})=>{const $=V.useRef(null),Q=V.useRef(null);V.useEffect(()=>{if($.current=Ps(),F)return A(ue=>{Q.current=ue,P({_reactiveScreenRefreshRate:ue})})},[]);const W=V.Children.map(R,G=>{if(V.isValidElement(G)){const ue=(ee,oe,re)=>{const ce=Ps(),xe=oe!==void 0?oe:$.current;_(ee,xe??void 0,(re!==void 0?re:ce)??void 0)};return V.cloneElement(G,{...G.props,next:ue})}return G});return L.jsx(L.Fragment,{children:W})},T=a.instructions[d],M=V.useMemo(()=>{if(y==="none"||(T==null?void 0:T.type)!=="ExecuteContent")return!1;const R=T.content;return!g0(R)||R.simulate===!1?!1:!!R.simulate||!!R.simulators},[d,y,T]);V.useEffect(()=>{M&&m.current!==d&&(m.current=d,(async()=>{const R=T.content,{trialProps:F,simulateFn:$,simulators:Q}=wm(R,o.current,c.current),W=await $(F,{data:o.current,store:c.current},Q,v.current);v.current=W.participantState,W.storeUpdates&&P(W.storeUpdates),_(W.responseData)})())},[M,d]);let O=null;if((T==null?void 0:T.type)==="ExecuteContent"&&!M){const R=T.content;if(g0(R)){const F=g[R.type];if(F){const $=typeof R.props=="function"?R.props(o.current,c.current):R.props||{};O=L.jsx(D,{collectRefreshRate:R.collectRefreshRate,children:L.jsx(F,{next:_,updateStore:P,store:c.current,data:o.current,...R.type==="Quest"?{customQuestions:b}:{},...$})},d)}else console.error(`No component found for type: ${R.type}`),O=L.jsxs("div",{children:['Error: Component type "',R.type,'" not found.']})}else console.warn("ExecuteContent instruction does not contain standard component data:",R),O=L.jsx("div",{children:"Non-component content encountered."})}else d>=a.instructions.length&&(O=L.jsx(L.Fragment,{}));const H=e.theme??"light",U=Gr(H);return L.jsx(xm.Provider,{value:H,children:L.jsxs("div",{className:"w-full h-full",children:[L.jsx("div",{className:` ${e.showProgressBar?"":"hidden "} px-4 mt-4 sm:mt-12 max-w-2xl mx-auto`,children:L.jsx("div",{className:`flex-1 h-6 ${U.progressBg} rounded-full overflow-hidden`,children:L.jsx("div",{className:`h-full ${U.progressBg} rounded-full duration-300 ${x>0?" border-black border-2":""}`,style:{width:`${x*100}%`,backgroundImage:`repeating-linear-gradient(
|
|
10282
10282
|
-45deg, ${U.progressStripe1}, ${U.progressStripe1} 10px, ${U.progressStripe2} 10px, ${U.progressStripe2} 20px
|
|
10283
10283
|
)`,transition:"width 300ms ease-in-out"}})})}),O]})})}function q4(i){const e=i.split("/").filter(s=>s!=="."),t=[];return e.forEach(s=>{s===".."&&t.length>0&&t[t.length-1]!==".."?t.pop():t.push(s)}),t.join("/")}function o1e(i,e){i=q4(i),e=q4(e);const t=i.split("/"),s=e.split("/");return i!==e&&t.every((r,n)=>r===s[n])}class ep extends Xh{constructor(){super(...arguments),this.DB_VERSION=1,this.DB_NAME="Disc",this._writeCmds=["add","put","delete"],this.downloadFile=async e=>{var t,s;const r=Pw(e,e.webFetchExtra),n=await fetch(e.url,r);let a;if(!e.progress)a=await n.blob();else if(!(n!=null&&n.body))a=new Blob;else{const l=n.body.getReader();let u=0;const h=[],c=n.headers.get("content-type"),d=parseInt(n.headers.get("content-length")||"0",10);for(;;){const{done:v,value:m}=await l.read();if(v)break;h.push(m),u+=(m==null?void 0:m.length)||0;const g={url:e.url,bytes:u,contentLength:d};this.notifyListeners("progress",g)}const f=new Uint8Array(u);let y=0;for(const v of h)typeof v>"u"||(f.set(v,y),y+=v.length);a=new Blob([f.buffer],{type:c||void 0})}return{path:(await this.writeFile({path:e.path,directory:(t=e.directory)!==null&&t!==void 0?t:void 0,recursive:(s=e.recursive)!==null&&s!==void 0?s:!1,data:a})).uri,blob:a}}}async initDb(){if(this._db!==void 0)return this._db;if(!("indexedDB"in window))throw this.unavailable("This browser doesn't support IndexedDB");return new Promise((e,t)=>{const s=indexedDB.open(this.DB_NAME,this.DB_VERSION);s.onupgradeneeded=ep.doUpgrade,s.onsuccess=()=>{this._db=s.result,e(s.result)},s.onerror=()=>t(s.error),s.onblocked=()=>{console.warn("db blocked")}})}static doUpgrade(e){const s=e.target.result;switch(e.oldVersion){case 0:case 1:default:s.objectStoreNames.contains("FileStorage")&&s.deleteObjectStore("FileStorage"),s.createObjectStore("FileStorage",{keyPath:"path"}).createIndex("by_folder","folder")}}async dbRequest(e,t){const s=this._writeCmds.indexOf(e)!==-1?"readwrite":"readonly";return this.initDb().then(r=>new Promise((n,a)=>{const u=r.transaction(["FileStorage"],s).objectStore("FileStorage")[e](...t);u.onsuccess=()=>n(u.result),u.onerror=()=>a(u.error)}))}async dbIndexRequest(e,t,s){const r=this._writeCmds.indexOf(t)!==-1?"readwrite":"readonly";return this.initDb().then(n=>new Promise((a,o)=>{const c=n.transaction(["FileStorage"],r).objectStore("FileStorage").index(e)[t](...s);c.onsuccess=()=>a(c.result),c.onerror=()=>o(c.error)}))}getPath(e,t){const s=t!==void 0?t.replace(/^[/]+|[/]+$/g,""):"";let r="";return e!==void 0&&(r+="/"+e),t!==""&&(r+="/"+s),r}async clear(){(await this.initDb()).transaction(["FileStorage"],"readwrite").objectStore("FileStorage").clear()}async readFile(e){const t=this.getPath(e.directory,e.path),s=await this.dbRequest("get",[t]);if(s===void 0)throw Error("File does not exist.");return{data:s.content?s.content:""}}async writeFile(e){const t=this.getPath(e.directory,e.path);let s=e.data;const r=e.encoding,n=e.recursive,a=await this.dbRequest("get",[t]);if(a&&a.type==="directory")throw Error("The supplied path is a directory.");const o=t.substr(0,t.lastIndexOf("/"));if(await this.dbRequest("get",[o])===void 0){const c=o.indexOf("/",1);if(c!==-1){const d=o.substr(c);await this.mkdir({path:d,directory:e.directory,recursive:n})}}if(!r&&!(s instanceof Blob)&&(s=s.indexOf(",")>=0?s.split(",")[1]:s,!this.isBase64String(s)))throw Error("The supplied data is not valid base64 content.");const u=Date.now(),h={path:t,folder:o,type:"file",size:s instanceof Blob?s.size:s.length,ctime:u,mtime:u,content:s};return await this.dbRequest("put",[h]),{uri:h.path}}async appendFile(e){const t=this.getPath(e.directory,e.path);let s=e.data;const r=e.encoding,n=t.substr(0,t.lastIndexOf("/")),a=Date.now();let o=a;const l=await this.dbRequest("get",[t]);if(l&&l.type==="directory")throw Error("The supplied path is a directory.");if(await this.dbRequest("get",[n])===void 0){const c=n.indexOf("/",1);if(c!==-1){const d=n.substr(c);await this.mkdir({path:d,directory:e.directory,recursive:!0})}}if(!r&&!this.isBase64String(s))throw Error("The supplied data is not valid base64 content.");if(l!==void 0){if(l.content instanceof Blob)throw Error("The occupied entry contains a Blob object which cannot be appended to.");l.content!==void 0&&!r?s=btoa(atob(l.content)+atob(s)):s=l.content+s,o=l.ctime}const h={path:t,folder:n,type:"file",size:s.length,ctime:o,mtime:a,content:s};await this.dbRequest("put",[h])}async deleteFile(e){const t=this.getPath(e.directory,e.path);if(await this.dbRequest("get",[t])===void 0)throw Error("File does not exist.");if((await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(t)])).length!==0)throw Error("Folder is not empty.");await this.dbRequest("delete",[t])}async mkdir(e){const t=this.getPath(e.directory,e.path),s=e.recursive,r=t.substr(0,t.lastIndexOf("/")),n=(t.match(/\//g)||[]).length,a=await this.dbRequest("get",[r]),o=await this.dbRequest("get",[t]);if(n===1)throw Error("Cannot create Root directory");if(o!==void 0)throw Error("Current directory does already exist.");if(!s&&n!==2&&a===void 0)throw Error("Parent directory must exist");if(s&&n!==2&&a===void 0){const h=r.substr(r.indexOf("/",1));await this.mkdir({path:h,directory:e.directory,recursive:s})}const l=Date.now(),u={path:t,folder:r,type:"directory",size:0,ctime:l,mtime:l};await this.dbRequest("put",[u])}async rmdir(e){const{path:t,directory:s,recursive:r}=e,n=this.getPath(s,t),a=await this.dbRequest("get",[n]);if(a===void 0)throw Error("Folder does not exist.");if(a.type!=="directory")throw Error("Requested path is not a directory");const o=await this.readdir({path:t,directory:s});if(o.files.length!==0&&!r)throw Error("Folder is not empty");for(const l of o.files){const u=`${t}/${l.name}`;(await this.stat({path:u,directory:s})).type==="file"?await this.deleteFile({path:u,directory:s}):await this.rmdir({path:u,directory:s,recursive:r})}await this.dbRequest("delete",[n])}async readdir(e){const t=this.getPath(e.directory,e.path),s=await this.dbRequest("get",[t]);if(e.path!==""&&s===void 0)throw Error("Folder does not exist.");const r=await this.dbIndexRequest("by_folder","getAllKeys",[IDBKeyRange.only(t)]);return{files:await Promise.all(r.map(async a=>{let o=await this.dbRequest("get",[a]);return o===void 0&&(o=await this.dbRequest("get",[a+"/"])),{name:a.substring(t.length+1),type:o.type,size:o.size,ctime:o.ctime,mtime:o.mtime,uri:o.path}}))}}async getUri(e){const t=this.getPath(e.directory,e.path);let s=await this.dbRequest("get",[t]);return s===void 0&&(s=await this.dbRequest("get",[t+"/"])),{uri:(s==null?void 0:s.path)||t}}async stat(e){const t=this.getPath(e.directory,e.path);let s=await this.dbRequest("get",[t]);if(s===void 0&&(s=await this.dbRequest("get",[t+"/"])),s===void 0)throw Error("Entry does not exist.");return{type:s.type,size:s.size,ctime:s.ctime,mtime:s.mtime,uri:s.path}}async rename(e){await this._copy(e,!0)}async copy(e){return this._copy(e,!1)}async requestPermissions(){return{publicStorage:"granted"}}async checkPermissions(){return{publicStorage:"granted"}}async _copy(e,t=!1){let{toDirectory:s}=e;const{to:r,from:n,directory:a}=e;if(!r||!n)throw Error("Both to and from must be provided");s||(s=a);const o=this.getPath(a,n),l=this.getPath(s,r);if(o===l)return{uri:l};if(o1e(o,l))throw Error("To path cannot contain the from path");let u;try{u=await this.stat({path:r,directory:s})}catch{const y=r.split("/");y.pop();const v=y.join("/");if(y.length>0&&(await this.stat({path:v,directory:s})).type!=="directory")throw new Error("Parent directory of the to path is a file")}if(u&&u.type==="directory")throw new Error("Cannot overwrite a directory with a file");const h=await this.stat({path:n,directory:a}),c=async(f,y,v)=>{const m=this.getPath(s,f),g=await this.dbRequest("get",[m]);g.ctime=y,g.mtime=v,await this.dbRequest("put",[g])},d=h.ctime?h.ctime:Date.now();switch(h.type){case"file":{const f=await this.readFile({path:n,directory:a});t&&await this.deleteFile({path:n,directory:a});let y;!(f.data instanceof Blob)&&!this.isBase64String(f.data)&&(y=bd.UTF8);const v=await this.writeFile({path:r,directory:s,data:f.data,encoding:y});return t&&await c(r,d,h.mtime),v}case"directory":{if(u)throw Error("Cannot move a directory over an existing object");try{await this.mkdir({path:r,directory:s,recursive:!1}),t&&await c(r,d,h.mtime)}catch{}const f=(await this.readdir({path:n,directory:a})).files;for(const y of f)await this._copy({from:`${n}/${y.name}`,to:`${r}/${y.name}`,directory:a,toDirectory:s},t);t&&await this.rmdir({path:n,directory:a})}}return{uri:l}}isBase64String(e){try{return btoa(atob(e))==e}catch{return!1}}}ep._debug=!0;const l1e=Object.freeze(Object.defineProperty({__proto__:null,FilesystemWeb:ep},Symbol.toStringTag,{value:"Module"}));class u1e extends Xh{async enable(){console.log("Immersive mode is only available on Android")}async disable(){console.log("Immersive mode is only available on Android")}}const h1e=Object.freeze(Object.defineProperty({__proto__:null,ImmersiveModeWeb:u1e},Symbol.toStringTag,{value:"Module"}));J.Bounce=CS,J.CanvasBlock=VS,J.CheckDevice=SS,J.DARK_BG_CLASS=dne,J.EnterFullscreen=oS,J.ExitFullscreen=lS,J.ExperimentProvider=Gpe,J.ExperimentRunner=a1e,J.Flip=Qpe,J.Icons=Sd,J.MicCheck=Yw,J.Param=Ol,J.PlainInput=jw,J.ProlificEnding=zw,J.Quest=G5,J.RDKCanvas=N4,J.RandomDotKinematogram=F4,J.RequestFilePermission=ES,J.Slide=$pe,J.THEME=qw,J.Text=ac,J.ThemeContext=xm,J.ToastContainer=bS,J.Tutorial=O4,J.Upload=sS,J.Zoom=Hpe,J.arrayFlattener=Ow,J.canvasCountdown=rne,J.chunk=Vw,J.collapseToast=hS,J.cssTransition=vu,J.getBackendUrl=_w,J.getInitialParticipant=kw,J.getParam=va,J.getPlatform=Ml,J.getSimulation=nne,J.halton=ww,J.isDesktop=sne,J.isFullscreen=co,J.mapDDMChoice=Hw,J.noopSimulate=po,J.now=Ps,J.orchestrateSimulation=lne,J.pipe=Ew,J.registerArrayExtensions=Gre,J.registerComponentParams=Cm,J.registerExperimentParams=Rw,J.registerFlattener=ni,J.registerSimulation=Qs,J.resolveSimulation=wm,J.sample=xw,J.sampleParticipants=zre,J.seedDistributions=Bre,J.setBackendUrl=ane,J.shuffle=gm,J.simulateDDMTrial=$w,J.simulateParticipant=one,J.sobol=bw,J.subsetExperimentByParam=ine,J.t=Gr,J.toast=_t,J.useTheme=An,J.useToast=vS,J.useToastContainer=gS,J.useTutorialSlide=Y0e,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/planned.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Planned: Browser-based simulation mode
|
|
2
|
+
|
|
3
|
+
## Motivation
|
|
4
|
+
|
|
5
|
+
The current simulation framework is headless — it bypasses rendering entirely and computes responseData directly in Node. This is fast (hundreds of participants in seconds) but doesn't test that the UI actually works. A browser-based mode would render components in a real browser and drive them with programmatic interactions, catching rendering bugs, event handler issues, and timing problems.
|
|
6
|
+
|
|
7
|
+
## Key design insight
|
|
8
|
+
|
|
9
|
+
The existing **simulators stay unchanged**. They already encode *what* the participant decides (pick choice B, wait 2800ms, type "hello"). Only the execution layer changes — instead of directly building responseData from simulator output, a DOM driver translates decisions into browser interactions and lets components call `next()` naturally.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Simulator (shared): "participant picks choice B after 2800ms"
|
|
13
|
+
Headless driver (current): constructs responseData directly → fast, no DOM
|
|
14
|
+
DOM driver (new): waits 2800ms, clicks the radio button → component calls next() with real data
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
### Two simulation modes
|
|
20
|
+
|
|
21
|
+
- `headless` (existing) — Node subprocesses, no browser, fast bulk data generation
|
|
22
|
+
- `browser` (new) — Playwright browser contexts, real rendering, slow but thorough
|
|
23
|
+
|
|
24
|
+
The consumer chooses the mode in their simulate.ts config. Participant definitions, simulators, and timeline are identical between modes.
|
|
25
|
+
|
|
26
|
+
### Component DOM drivers
|
|
27
|
+
|
|
28
|
+
Each component type gets a DOM driver function that maps simulator output to browser actions:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
type DOMDriver = (
|
|
32
|
+
page: Page, // Playwright page
|
|
33
|
+
simulatorOutput: { value: any; duration: number },
|
|
34
|
+
trialProps: Record<string, any>,
|
|
35
|
+
) => Promise<void>;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The generic driver loop per trial:
|
|
39
|
+
1. Wait for the component to mount (detect a known selector or mutation)
|
|
40
|
+
2. Call the simulator to get the participant's decision
|
|
41
|
+
3. Wait `duration` ms
|
|
42
|
+
4. Call the component-specific DOM driver
|
|
43
|
+
5. Wait for the experiment runner to advance (next component mounts)
|
|
44
|
+
|
|
45
|
+
### Per-component complexity
|
|
46
|
+
|
|
47
|
+
| Component | DOM driver complexity | Notes |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| Text | Trivial (~10 lines) | Wait, click button |
|
|
50
|
+
| PlainInput | Trivial (~10 lines) | Type into input, click button |
|
|
51
|
+
| Tutorial | Simple (~15 lines) | Click next arrow per slide |
|
|
52
|
+
| Upload | Trivial (~10 lines) | Click submit button |
|
|
53
|
+
| EnterFullscreen | Trivial (~5 lines) | Click button (fullscreen API may need mocking) |
|
|
54
|
+
| ExitFullscreen | Zero | Auto-advances |
|
|
55
|
+
| CheckDevice | Zero | Auto-advances |
|
|
56
|
+
| CanvasBlock | Medium (~30-50 lines) | Simulate mouse/keyboard events on canvas |
|
|
57
|
+
| RDK | Medium (~20-30 lines) | Keyboard response on canvas |
|
|
58
|
+
| **Quest (SurveyJS)** | **Hard (~80-100 lines)** | Per-question-type selectors against SurveyJS DOM |
|
|
59
|
+
|
|
60
|
+
**Quest is the riskiest part** — SurveyJS's internal DOM structure is an implementation detail that can change between versions. Each question type (rating, radiogroup, checkbox, text, boolean, matrix, dropdown) needs its own selector logic.
|
|
61
|
+
|
|
62
|
+
### Orchestration
|
|
63
|
+
|
|
64
|
+
Replace `child_process.spawn` workers with Playwright browser contexts:
|
|
65
|
+
|
|
66
|
+
1. Start Vite dev server (or serve the built app)
|
|
67
|
+
2. For each participant: open a new browser context, navigate to the app URL with appropriate params
|
|
68
|
+
3. Run the driver loop until the experiment completes
|
|
69
|
+
4. Collect results from the backend (same upload path as headless)
|
|
70
|
+
5. Tear down contexts and server
|
|
71
|
+
|
|
72
|
+
Concurrency is limited by browser resources rather than CPU cores. 4-8 parallel contexts is realistic.
|
|
73
|
+
|
|
74
|
+
### Synchronization
|
|
75
|
+
|
|
76
|
+
The main technical challenge beyond SurveyJS DOM selectors. Need to reliably detect:
|
|
77
|
+
- Component has mounted and is interactive (not mid-animation)
|
|
78
|
+
- `next()` has been called and the next component is rendering
|
|
79
|
+
- The experiment has completed
|
|
80
|
+
|
|
81
|
+
Options: MutationObserver polling, custom data attributes on the experiment runner, or Playwright's `waitForSelector` / `waitForFunction`.
|
|
82
|
+
|
|
83
|
+
## Estimated scope
|
|
84
|
+
|
|
85
|
+
~400-500 lines of new code:
|
|
86
|
+
- Browser orchestrator: ~100-150 lines
|
|
87
|
+
- Generic driver loop: ~50 lines
|
|
88
|
+
- All component DOM drivers: ~200-250 lines
|
|
89
|
+
|
|
90
|
+
Existing code changes: minimal. Possibly add data attributes to ExperimentRunner for synchronization (e.g., `data-reactive-component-type` on the active component wrapper).
|
|
91
|
+
|
|
92
|
+
## Constraints
|
|
93
|
+
|
|
94
|
+
- **Speed**: ~100x slower than headless. This is for smoke testing (1-5 participants), not bulk generation.
|
|
95
|
+
- **Dependency**: Playwright becomes a (dev) dependency for consumers using this mode.
|
|
96
|
+
- **Fragility**: SurveyJS DOM selectors will need maintenance when upgrading survey-core.
|
|
97
|
+
- **Fullscreen**: Browser automation and fullscreen API don't mix well. EnterFullscreen/ExitFullscreen may need to be mocked or skipped in browser mode.
|
|
98
|
+
|
|
99
|
+
## Not in scope
|
|
100
|
+
|
|
101
|
+
- Replacing the headless simulation mode (it remains the default)
|
|
102
|
+
- Visual regression testing (screenshot comparison)
|
|
103
|
+
- Recording/replaying real participant sessions
|
|
@@ -166,7 +166,7 @@ export const Tutorial = ({
|
|
|
166
166
|
return (
|
|
167
167
|
<LayoutGroup>
|
|
168
168
|
<div
|
|
169
|
-
className={`${containerClass ?? th.containerBg} ${animate ? 'animate-slide-down opacity-0' : ''}`}
|
|
169
|
+
className={`${containerClass ?? th.containerBg} ${th.text} ${animate ? 'animate-slide-down opacity-0' : ''}`}
|
|
170
170
|
style={{
|
|
171
171
|
width: '100vw',
|
|
172
172
|
height: '100vh',
|