@algorisys/tinyfly 0.82.0 → 0.87.0
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/README.md +13 -4
- package/bin/tinyfly.mjs +44 -6
- package/lib/addons/adapters.js +411 -248
- package/lib/addons/characters.js +1652 -1470
- package/lib/addons/dom-adapter-Cphr2HZn.js +372 -0
- package/lib/addons/gsap-compat.js +197 -187
- package/lib/addons/load-scene-vp14_Jj-.js +324 -0
- package/lib/addons/maps.js +1 -1
- package/lib/addons/scene-3d-webgl.js +240 -0
- package/lib/addons/scene-3d.js +306 -0
- package/lib/addons/shading-o5T_v9DT.js +89 -0
- package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +116 -0
- package/lib/browser/tinyfly-scene-3d.iife.js +3 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4333 -3726
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +137 -22
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +921 -833
- package/lib/engine/tinyfly-engine.js +1022 -776
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +410 -8
- package/lib/player/tinyfly-player.es.js +459 -371
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/bloom.d.ts +33 -0
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +36 -0
- package/lib/types/adapters/canvas/index.d.ts +2 -0
- package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
- package/lib/types/adapters/transform-3d.d.ts +99 -0
- package/lib/types/adapters/webgl/webgl-adapter.d.ts +17 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/characters/character.d.ts +20 -1
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/rig/body-plan.d.ts +3 -1
- package/lib/types/characters/rig/skeleton.d.ts +57 -0
- package/lib/types/characters/scene-objects.d.ts +2 -0
- package/lib/types/compat/gsap/vars.d.ts +8 -0
- package/lib/types/engine/core/bake.d.ts +3 -1
- package/lib/types/engine/index.d.ts +1 -0
- package/lib/types/engine/interpolation/interpolators.d.ts +10 -3
- package/lib/types/engine/math/index.d.ts +11 -0
- package/lib/types/engine/math/mat4.d.ts +37 -0
- package/lib/types/engine/math/quat.d.ts +39 -0
- package/lib/types/engine/math/vec3.d.ts +16 -0
- package/lib/types/engine/types.d.ts +23 -2
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/loop-check.d.ts +41 -0
- package/lib/types/headless/node-video.d.ts +8 -0
- package/lib/types/headless/video-scene.d.ts +7 -1
- package/lib/types/scene-3d/camera.d.ts +27 -0
- package/lib/types/scene-3d/canvas-2d-renderer.d.ts +21 -0
- package/lib/types/scene-3d/geometry/extrude.d.ts +17 -0
- package/lib/types/scene-3d/geometry/mesh.d.ts +36 -0
- package/lib/types/scene-3d/geometry/primitives.d.ts +16 -0
- package/lib/types/scene-3d/geometry/triangulate.d.ts +24 -0
- package/lib/types/scene-3d/index.d.ts +20 -0
- package/lib/types/scene-3d/load-scene.d.ts +31 -0
- package/lib/types/scene-3d/object-kind.d.ts +54 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +122 -0
- package/lib/types/scene-3d/scene-3d-adapter.d.ts +46 -0
- package/lib/types/scene-3d/scene-types.d.ts +192 -0
- package/lib/types/scene-3d/shading.d.ts +20 -0
- package/lib/types/scene-3d/validate-scene.d.ts +11 -0
- package/lib/types/scene-3d/webgl/gl-data.d.ts +29 -0
- package/lib/types/scene-3d/webgl/index.d.ts +16 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +29 -0
- package/lib/types/scene-3d/webgl/webgl2-renderer.d.ts +33 -0
- package/package.json +10 -2
- package/lib/addons/dom-adapter-CrNwoomd.js +0 -243
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b){"use strict";function Li(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function Ut(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const Vt=1;function ye(e){return e.property==="text"&&"textConfig"in e}function ft(e){return e.kind==="inertia"&&"inertia"in e}function dt(e){return e.kind==="spring"&&"spring"in e}function fn(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Go(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function Oi(e){return"keyframes"in e}class Jo{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(t){this._currentTime+=t,this.onTick?.(t,this._currentTime)}reset(){this._currentTime=0}seek(t){this._currentTime=t}}class Zo{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(t={}){this._speed=t.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(t){this._speed=t}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(t){this._currentTime=t}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(t){if(this._isRunning){if(this._lastFrameTime!==null){const i=(t-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=t,this._scheduleFrame()}}}function dn(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function pn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,dn(i,e,t));return n}function be(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=dn(e,t,i);if(n.amount!==void 0){const r=pn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function we(e,t){return Array.from({length:e},(n,i)=>be(i,e,t))}function zt(e,t){return e<=1?0:Math.max(...we(e,t))}const _t=1,mn=6e4,ve=mn/_t,Z={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},ke={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class jt{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??Z.stiffness,this.damping=t.damping??Z.damping,this.mass=t.mass??Z.mass,this.restDelta=t.restDelta??Z.restDelta,this.restSpeed=t.restSpeed??Z.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??Z.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/_t);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/_t-n;return i+(s-i)*r}settleTime(){return this.simulateTo(ve+1),this.settledStep!==null?this.settledStep*_t:mn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,ve+1),i=_t/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*i;const h=s+this.velocity*i;if(this.samples.push(h),this.isAtRest(h)){this.settledStep=this.samples.length-1;return}}this.samples.length>ve&&(this.settledStep=ve)}}function Qo(e,t){return new jt(e).valueAt(t)}function Bi(e){return new jt(e).settleTime()}function ta(e){const t=e.stiffness??Z.stiffness,n=e.damping??Z.damping,i=e.mass??Z.mass;return n<2*Math.sqrt(t*i)}function ea(e){const t=e.stiffness??Z.stiffness,n=e.mass??Z.mass;return 2*Math.sqrt(t*n)}const gn=4,na=.002,ia=1e-4,Di=6e4;function Se(e){const t=e.friction??gn;return t>0?t:gn}function Gt(e){return e.from+e.velocity/Se(e)}function sa(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Ct(e){let t=sa(Gt(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function Ht(e){const t=Math.abs(Ct(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(ia,t*na);if(n>=t)return 0;const i=Math.log(t/n)/Se(e);return Math.min(Di,i*1e3)}function Te(e,t){if(t<=0)return e.from;const n=Ct(e);if(t>=Ht(e))return n;const i=Se(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function ra(e,t){const n=Se(e),i=Ct(e);return t>=Ht(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Me=e=>e,Ni=e=>e*e,Wi=e=>1-(1-e)*(1-e),Ki=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,yn=e=>e*e*e,bn=e=>1-Math.pow(1-e,3),Jt=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Yi=yn,qi=bn,Xi=Jt,oa={linear:Me,"ease-in":Yi,"ease-out":qi,"ease-in-out":Xi,"ease-in-quad":Ni,"ease-out-quad":Wi,"ease-in-out-quad":Ki,"ease-in-cubic":yn,"ease-out-cubic":bn,"ease-in-out-cubic":Jt};function Ui(e){const[t,n,i,s]=e,r=3*t,o=3*(i-t)-r,a=1-r-o,l=3*n,h=3*(s-n)-l,c=1-l-h,f=p=>((a*p+o)*p+r)*p,u=p=>((c*p+h)*p+l)*p,d=p=>(3*a*p+2*o)*p+r,m=p=>{let g=p;for(let w=0;w<8;w++){const T=f(g)-p;if(Math.abs(T)<1e-7)return g;const k=d(g);if(Math.abs(k)<1e-7)break;g-=T/k}let y=0,v=1;for(g=p;y<v;){const w=f(g);if(Math.abs(w-p)<1e-7)return g;p>w?y=g:v=g,g=(y+v)/2}return g};return p=>{if(p<=0)return 0;if(p>=1)return 1;const g=m(p);return u(g)}}function wn(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function Vi(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const zi=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function ji(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Gi(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function Ji(e){switch(e.type){case"steps":return Gi(e.count,e.position);case"elastic":return wn(Vi(e.amplitude,e.period),e.mode);case"bounce":return wn(zi,e.mode);case"back":return wn(ji(e.overshoot),e.mode)}}function V(e){return e===void 0?Me:Li(e)?Ui(e.points):Ut(e)?Ji(e):oa[e]??Me}const Zi=32,aa=256,It=new Map,la=/[MmLlHhVvCcSsQqTtAaZz]/,ha=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,ca={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function ua(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(la.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const o=i.type==="A"||i.type==="a",a=i.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const l=ha.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function fa(e,t,n,i,s,r,o,a,l){if(e===a&&t===l)return[];let h=Math.abs(n),c=Math.abs(i);if(h===0||c===0)return[[e,t,a,l,a,l]];const f=s*Math.PI/180,u=Math.cos(f),d=Math.sin(f),m=(e-a)/2,p=(t-l)/2,g=u*m+d*p,y=-d*m+u*p,v=g*g/(h*h)+y*y/(c*c);if(v>1){const F=Math.sqrt(v);h*=F,c*=F}const w=r===o?-1:1,T=h*h*c*c-h*h*y*y-c*c*g*g,k=h*h*y*y+c*c*g*g,S=w*Math.sqrt(Math.max(0,T/k)),M=S*h*y/c,C=-S*c*g/h,x=u*M-d*C+(e+a)/2,_=d*M+u*C+(t+l)/2,P=(F,B,D,X)=>{const nt=F*D+B*X,kt=Math.sqrt((F*F+B*B)*(D*D+X*X)),Pt=Math.acos(Math.max(-1,Math.min(1,nt/kt)));return F*X-B*D<0?-Pt:Pt},A=P(1,0,(g-M)/h,(y-C)/c);let E=P((g-M)/h,(y-C)/c,(-g-M)/h,(-y-C)/c);!o&&E>0&&(E-=2*Math.PI),o&&E<0&&(E+=2*Math.PI);const H=Math.max(1,Math.ceil(Math.abs(E)/(Math.PI/2))),I=E/H,R=4/3*Math.tan(I/4),$=F=>{const B=h*Math.cos(F),D=c*Math.sin(F);return[u*B-d*D+x,d*B+u*D+_]},O=F=>{const B=-h*Math.sin(F),D=c*Math.cos(F);return[u*B-d*D,d*B+u*D]},L=[];for(let F=0;F<H;F++){const B=A+F*I,D=B+I,[X,nt]=$(B),[kt,Pt]=F===H-1?[a,l]:$(D),[un,ge]=O(B),[Fi,$f]=O(D);L.push([X+R*un,nt+R*ge,kt-R*Fi,Pt-R*$f,kt,Pt])}return L}function pt(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function Qi(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function Zt(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function Ee(e,t,n){const[i,s,r,o,a,l]=n,h=[0];let c=e,f=t,u=0;for(let d=1;d<=Zi;d++){const m=d/Zi,p=pt(e,i,r,a,m),g=pt(t,s,o,l,m);u+=Math.hypot(p-c,g-f),h.push(u),c=p,f=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:u,lengths:h}}function St(e){const t=It.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,o=0,a=null,l=null,h=-1;const c=new Set,f=p=>{h<0&&(h=0),p.subpath=h,n.push(p)};for(const{type:p,args:g}of ua(e)){const y=p.toUpperCase(),v=p!==y,w=ca[y];if(y==="Z"){(i!==r||s!==o)&&f(Zt(i,s,r,o)),h>=0&&c.add(h),i=r,s=o,a=l=null;continue}for(let T=0;T+w<=g.length;T+=w){const k=g.slice(T,T+w),S=v?i:0,M=v?s:0;let C=null,x=null;switch(y){case"M":T===0?(i=k[0]+S,s=k[1]+M,r=i,o=s,(h<0||n[n.length-1]?.subpath===h)&&h++):(f(Zt(i,s,k[0]+S,k[1]+M)),i=k[0]+S,s=k[1]+M);break;case"L":f(Zt(i,s,k[0]+S,k[1]+M)),i=k[0]+S,s=k[1]+M;break;case"H":f(Zt(i,s,k[0]+S,s)),i=k[0]+S;break;case"V":f(Zt(i,s,i,k[0]+M)),s=k[0]+M;break;case"C":{const _=[k[0]+S,k[1]+M,k[2]+S,k[3]+M,k[4]+S,k[5]+M];f(Ee(i,s,_)),C=[_[2],_[3]],i=_[4],s=_[5];break}case"S":{const[_,P]=a?[2*i-a[0],2*s-a[1]]:[i,s],A=[_,P,k[0]+S,k[1]+M,k[2]+S,k[3]+M];f(Ee(i,s,A)),C=[A[2],A[3]],i=A[4],s=A[5];break}case"Q":case"T":{let _=i,P=s;y==="Q"?(_=k[0]+S,P=k[1]+M):l&&(_=2*i-l[0],P=2*s-l[1]);const A=y==="Q"?k[2]+S:k[0]+S,E=y==="Q"?k[3]+M:k[1]+M;f(Ee(i,s,[i+2/3*(_-i),s+2/3*(P-s),A+2/3*(_-A),E+2/3*(P-E),A,E])),x=[_,P],i=A,s=E;break}case"A":{const _=k[5]+S,P=k[6]+M;let A=i,E=s;for(const H of fa(i,s,k[0],k[1],k[2],k[3],k[4],_,P))f(Ee(A,E,H)),A=H[4],E=H[5];i=_,s=P;break}}a=C,l=x}}const u=n.reduce((p,g)=>p+g.length,0),d=[];for(let p=0;p<n.length;){const g=n[p].subpath;let y=p,v=0;for(;y<n.length&&n[y].subpath===g;)v+=n[y++].length;const w=n[p],T=n[y-1],k=c.has(g)||Math.abs(T.endX-w.startX)<1e-9&&Math.abs(T.endY-w.startY)<1e-9;d.push({start:p,end:y,length:v,closed:k}),p=y}const m={segments:n,totalLength:u,subpaths:d};return It.size>=aa&&It.delete(It.keys().next().value),It.set(e,m),m}function da(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<t?i=a:s=a}const r=n[s]-n[i],o=r>0?(t-n[i])/r:0;return(i+o)/(n.length-1)}function pa(e,t){if(e.type==="L"){const f=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*f,y:e.startY+(e.endY-e.startY)*f,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=da(e,t);let h=Qi(e.startX,n,s,o,l),c=Qi(e.startY,i,r,a,l);if(Math.hypot(h,c)<1e-9){const f=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=pt(e.startX,n,s,o,f),d=pt(e.startY,i,r,a,f),m=pt(e.startX,n,s,o,l),p=pt(e.startY,i,r,a,l);h=l<.5?u-m:m-u,c=l<.5?d-p:p-d}return{x:pt(e.startX,n,s,o,l),y:pt(e.startY,i,r,a,l),angle:Math.atan2(c,h)*180/Math.PI}}function vn(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const o=e[r];if(s+o.length>=t||r===i-1)return pa(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function ts(e,t){const{segments:n,totalLength:i}=St(e);return vn(n,Math.max(0,Math.min(1,t))*i)}function ma(){It.clear()}function ga(e){return St(e).totalLength}const ya=24,ba=320,wa=2.5,Qt=72,va=64,ka=.2,Sa=128,te=new Map;let Ae=0,mt;const es=e=>Math.round(e*100)/100;function ns(e,t){const{segments:n,subpaths:i,totalLength:s}=St(e);if(n.length===0)return[];if(t){const r=i.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function kn(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=vn(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function is(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function ss(e,t){const n=[];for(let i=0;i<t;i++)n.push(kn(e,e.closed?i/t:i/(t-1)));return n}function rs(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function Ta(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%Qt/Qt:0,reversed:n<0};const s=rs(ss(e,Qt)),r=rs(ss(t,Qt)),o=Qt;let a={offset:0,reversed:!1},l=1/0;for(const h of[!1,!0]){const c=i?o:1;for(let f=0;f<c;f++){let u=0;for(let d=0;d<o&&u<l;d++){const m=i?h?(f-d+o)%o:(d+f)%o:h?o-1-d:d,p=s[d][0]-r[m][0],g=s[d][1]-r[m][1];u+=p*p+g*g}u<l&&(l=u,a={offset:i?f/o:0,reversed:h})}}return a}function Ma(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function Ea(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function Aa(e,t,n){const i=e.closed&&t.closed,s=Ta(e,t,n.shapeIndex),r=Math.max(ya,Math.min(ba,Math.ceil(Math.max(e.length,t.length)/wa))),o=new Set,a=f=>o.add(Math.round(f*1e7)/1e7);for(let f=0;f<=r;f++)a(f/r);for(const f of is(e))a(f);for(const f of is(t))a(Ea(f,s,i));let l=[...o].sort((f,u)=>f-u);i&&(l=l.filter(f=>f<1));const h=[],c=[];for(const f of l)h.push(...kn(e,f)),c.push(...kn(t,Ma(f,s,i)));return xa({from:h,to:c,closed:i})}function xa(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[o,a]=i.pop();let l=-1,h=ka;for(let c=o+1;c<a;c++){const f=Math.max(os(e.from,o,a,c),os(e.to,o,a,c));f>h&&(h=f,l=c)}l!==-1&&(n[l]=1,i.push([o,l],[l,a]))}const s=[],r=[];for(let o=0;o<t;o++)n[o]&&(s.push(e.from[o*2],e.from[o*2+1]),r.push(e.to[o*2],e.to[o*2+1]));return{from:s,to:r,closed:e.closed}}function os(e,t,n,i){const s=e[t*2],r=e[t*2+1],o=e[n*2]-s,a=e[n*2+1]-r,l=e[i*2]-s,h=e[i*2+1]-r,c=o*o+a*a,f=c===0?0:Math.max(0,Math.min(1,(l*o+h*a)/c));return Math.hypot(l-f*o,h-f*a)}function Pa(e,t,n){const i=n.shapeIndex;if(mt&&mt.from===e&&mt.to===t&&mt.shapeIndex===i)return mt.plan;const r=te.get(String(i??"auto"))?.get(e)?.get(t);if(r)return mt={from:e,to:t,shapeIndex:i,plan:r},r;const o=St(e).subpaths.filter(d=>d.length>0).length===St(t).subpaths.filter(d=>d.length>0).length,a=ns(e,!o),l=ns(t,!o),h={pairs:a.map((d,m)=>Aa(d,l[m],n))};Ae>=Sa&&(te.clear(),Ae=0);const c=String(i??"auto"),f=te.get(c)??new Map;te.set(c,f);const u=f.get(e)??new Map;return f.set(e,u),u.set(t,h),Ae++,mt={from:e,to:t,shapeIndex:i,plan:h},h}function as(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=Pa(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const h=es(a.from[l]+(a.to[l]-a.from[l])*s),c=es(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);o+=`${l===0?o?" M":"M":" L"}${h} ${c}`}a.closed&&(o+=" Z")}return o}function _a(){te.clear(),Ae=0,mt=void 0}function Rt(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const st=(e,t,n)=>e+(t-e)*n,ls=512,Sn=new Map,Tn=new Map;function hs(e){const t=Sn.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return Sn.size<ls&&Sn.set(e,i),i}const cs=e=>e.charCodeAt(0)===35,us=e=>e.startsWith("rgb"),fs=e=>e.startsWith("rgba"),Ca=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Mn=e=>Math.round(e).toString(16).padStart(2,"0");function Ha(e,t,n){return`#${Mn(e)}${Mn(t)}${Mn(n)}`}function ds(e){const t=Tn.get(e);if(t)return t;const n=e.match(Ca);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return Tn.size<ls&&Tn.set(e,o),o}const ps=(e,t,n)=>{if(cs(e)&&cs(t)){const[i,s,r]=hs(e),[o,a,l]=hs(t),h=st(i,o,n),c=st(s,a,n),f=st(r,l,n);return Ha(h,c,f)}if((us(e)||fs(e))&&(us(t)||fs(t))){const i=ds(e),s=ds(t),r=Math.round(st(i[0],s[0],n)),o=Math.round(st(i[1],s[1],n)),a=Math.round(st(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,h=s[3]??1,c=st(l,h,n);return`rgba(${r}, ${o}, ${a}, ${c})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},ms=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(st(e[r],t[r],n));return s},En=(e,t,n)=>n<1?e:t,gs=(e,t,n)=>as(e,t,n);function ee(e){return typeof e=="number"?st:Array.isArray(e)?ms:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?ps:Rt(e)?gs:En:En}const An=1e3/60;function xn(e,t={}){if(!dt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new jt(e.spring);return ys(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function Pn(e,t={}){if(!ft(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return ys(e,i=>Te(n,i),Ht(n),n.from,Ct(n),t)}function ys(e,t,n,i,s,r){const o=r.intervalMs??An,a=r.tolerance??.01,l=e.delay??0,h=[];for(let f=0;f<=n;f+=o)h.push({time:f+l,value:t(f),easing:"linear"});const c=h[h.length-1];return!c||c.time<n+l?h.push({time:n+l,value:s,easing:"linear"}):c.value=s,l>0&&h.unshift({time:0,value:i,easing:"linear"}),{id:e.id,target:e.target,property:e.property,keyframes:a>0?ws(h,a):h,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function _n(e,t,n,i={}){const s=i.intervalMs??An,r=typeof n=="function"?n:V(n),o=ee(e.value),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let c=s;c<a;c+=s){const f=c/a;l.push({time:e.time+c,value:o(e.value,t.value,r(f)),easing:"linear"})}const h=r(1);return l.push({...t,...h!==1&&{value:o(e.value,t.value,h)},easing:"linear"}),l}function Ia(e,t){return dt(e)?xn(e,t):ft(e)?Pn(e,t):e}function bs(e,t={}){const n=e.keyframes;if(!n.some(s=>Ut(s.easing)))return e;const i=n.length>0?[n[0]]:[];for(let s=1;s<n.length;s++){const r=n[s];Ut(r.easing)?i.push(..._n(n[s-1],r,r.easing,t)):i.push(r)}return{...e,keyframes:i}}function Ra(e,t){return e.filter(Oi).map(n=>bs(n,t)).concat(e.filter(dt).map(n=>xn(n,t)),e.filter(ft).map(n=>Pn(n,t)))}function ws(e,t){if(e.length<=2)return e;const n=[e[0]];for(let i=1;i<e.length-1;i++){const s=n[n.length-1],r=e[i],o=e[i+1],a=o.time-s.time;if(a<=0)continue;const l=(r.time-s.time)/a,h=s.value+(o.value-s.value)*l;Math.abs(r.value-h)>t&&n.push(r)}return n.push(e[e.length-1]),n}function xe(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function gt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function $t(e,t,n,i){const s=n??0;return!i||t<=1?s:s+be(e,t,i)}class Pe{track;targets;constructor(t){this.track=t,this.targets=gt(t)}getValueAtTime(t){return this.valueForOffset(t-$t(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=$t(s,n,this.track.delay,this.track.stagger),o=this.valueForOffset(t-r);o!==void 0&&i.push({target:this.targets[s],value:o,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?zt(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,o=(t-i.time)/r,l=V(s.easing)(o);return ee(i.value)(i.value,s.value,l)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class vs{track;targets;sampler;constructor(t){this.track=t,this.targets=gt(t),this.sampler=new jt(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-$t(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=$t(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?zt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class ks{track;targets;duration;constructor(t){this.track=t,this.targets=gt(t),this.duration=Ht(t.inertia)}getValueAtTime(t){return Te(this.track.inertia,t-$t(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=$t(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:Te(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?zt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Cn(e,t){const n={...ts(e.pathData,t)};if(e.matrix){const[i,s,r,o,a,l]=e.matrix,{x:h,y:c}=n;n.x=i*h+r*c+a,n.y=s*h+o*c+l;const f=n.angle*Math.PI/180,u=Math.cos(f),d=Math.sin(f);n.angle=Math.atan2(s*u+o*d,i*u+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function $a(e,t,n,i){const s=t+(n-t)*i;return Cn(e,s)}const Hn={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Fa=20;function Ss(e){const t=Hn[e??"upperCase"]??e??Hn.upperCase,n=Array.from(t);return n.length>0?n:Array.from(Hn.upperCase)}function La(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function Ts(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const o=Array.from(i),a=Array.from(s),l=e.rightToLeft??!1;if(e.mode==="type"){const v=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-v)).join("")+a.slice(Math.max(0,a.length-v)).join(""):a.slice(0,v).join("")+o.slice(v).join("")}const h=Math.max(0,Math.min(.999,e.revealDelay??0)),c=Math.max(0,(r-h)/(1-h)),f=Math.floor(c*a.length),u=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),d=Ss(e.chars),m=e.refreshRate??Fa,p=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let v=0;v<u;v++){const w=l?v>=u-f:v<f,T=l?a[a.length-(u-v)]:a[v];w&&T!==void 0||T===" "||T===`
|
|
2
|
-
`?y+=T:y+=d[La(g,v,p)%d.length]}return y}class In{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=a,s-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&s>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(s>=l){if(s-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const l=this._currentTime;if(s>=l){if(s-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(t){const n=new Map;if(this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:o,value:a,start:l}of s.getTargetValues(t))this._write(n,i,o,r,a,t-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:h}of r.getTargetValues(t)){const c=`${a}\0${o}`,f=h<=t,u=i.get(c);(!u||(f!==u.started?f:f?h>=u.start:h<=u.start))&&i.set(c,{trackId:s,target:a,property:o,value:l,start:h,started:f})}}for(const{trackId:s,target:r,property:o,value:a,start:l}of i.values())this._write(n,s,r,o,a,t-l)}_write(t,n,i,s,r,o){if(r===void 0)return;let a=t.get(i);a||(a=new Map,t.set(i,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",Ts(l.textConfig,r,Math.max(0,o)));return}const h=this._motionPathTracks.get(n);if(h&&typeof r=="number"){const c=Cn(h.motionPathConfig,r);a.set("motionPathX",c.x),a.set("motionPathY",c.y),h.motionPathConfig.autoRotate&&a.set("motionPathRotate",c.angle)}else a.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of gt(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,ft(t)){this._trackPlayers.set(t.id,new ks(t));return}if(dt(t)){this._trackPlayers.set(t.id,new vs(t)),this._springTracks.set(t.id,t);return}if(ye(t))this._trackPlayers.set(t.id,new Pe(t)),this._textTracks.set(t.id,t);else if(fn(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new Pe(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Pe(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(dt(i)||ft(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==i.property)continue;const a=gt(o).filter(f=>gt(i).includes(f));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const c=s.from>=l.from;for(const f of a)t.push({target:f,property:i.property,losingTrackId:c?o.id:i.id,winningTrackId:c?i.id:o.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!gt(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Vt,id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Oa=100;function Rn(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(d,m,p,g)=>{r.push([d,m]);const y=[];e.forEach((v,w)=>{(p==="forward"?(g?v>=d:v>d)&&v<=m:(g?v<=d:v<d)&&v>=m)&&y.push(w)}),y.sort((v,w)=>(p==="forward"?e[v]-e[w]:e[w]-e[v])||v-w);for(const v of y)s.push({kind:"event",index:v,direction:p})};let h=t.time,c=t.direction,f=t.fresh===!0;const u=Math.min(Oa,Math.max(0,n.iteration-t.iteration));for(let d=0;d<u;d++){const m=c==="forward"?o:0;l(h,m,c,f),s.push({kind:"repeat"}),a?(c=c==="forward"?"reverse":"forward",h=m,f=!1):(h=c==="forward"?0:o,f=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:r}:(l(h,n.time,c,f),{crossings:s,passes:r})}function Ms(e){return ft(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Es(e.inertia),...rt(e)}:dt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...rt(e)}:ye(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map($n),...rt(e)}:fn(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map($n),...rt(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map($n),...rt(e)}}function Es(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function $n(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function rt(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function As(e){if(ft(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Es(t.inertia),...rt(t)}}if(dt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...rt(t)}}if(ye(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...rt(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...rt(t)}}return xe({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...rt(e)})}function xs(e){const t=e._config.markers;return{formatVersion:Vt,id:e.id,name:e.name,config:{duration:e.duration>0?e.duration:void 0,loop:e._config.loop,speed:e._config.speed,alternate:e._config.alternate,repeatDelay:e._config.repeatDelay,...t&&{markers:t.map(n=>({...n}))}},tracks:e.tracks.map(Ms),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function Ft(e){const t=e.formatVersion??1;if(t>Vt)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Vt}. Update tinyfly to play it.`);return new In({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(As),captions:e.captions})}function Ba(e){return JSON.stringify(xs(e))}function Da(e){const t=JSON.parse(e);return Ft(t)}function Fn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function _e(e){let t=e>>>0||2654435769;return{seed:e>>>0,next(){return t^=t<<13,t>>>=0,t^=t>>17,t^=t<<5,t>>>=0,t/4294967296}}}function Ln(e,t,n){return t+e.next()*(n-t)}function Ps(e,t,n,i){if(i<=0)return Ln(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Na(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const _s=/^([+\-*/])=\s*(-?[\d.]+)$/,Cs=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Wa(e){return typeof e!="string"?!1:_s.test(e.trim())||Cs.test(e.trim())}function On(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=_s.exec(n);if(i){const[,r,o]=i,a=t.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=Cs.exec(n);if(s){if(!t.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(s[1]),o=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?Ps(t.random,r,o,a):Ln(t.random,r,o)}return e}function Hs(e,t=0,n){const i=[];let s=t;for(const r of e){const o=On(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Ka{random;constructor(t){this.random=_e(t)}get seed(){return this.random.seed}resolve(t,n=0){return On(t,{base:n,random:this.random})}resolveSequence(t,n=0){return Hs(t,n,this.random)}}const Ya=600;function Is(e){if(Array.isArray(e)){const[u,d,m,p]=e;return{fn:Fs(u,d,m,p),bezier:[u,d,m,p]}}const{segments:t}=St(e);if(t.length===0)throw new Error(`customEase: no curve in "${e}"`);const n=t[0].startX,i=t[0].startY,s=t[t.length-1],r=s.endX-n,o=s.endY-i;if(r===0||o===0)throw new Error(`customEase: "${e}" must move along both axes`);const a=u=>(u-n)/r,l=u=>(u-i)/o;if(t.length===1&&s.type==="C"){const[u,d,m,p]=s.points,g=[a(u),l(d),a(m),l(p)];return{fn:Fs(...g),bezier:g}}const h=[],c=[],f=Math.max(8,Math.ceil(Ya/t.length));for(const u of t)for(let d=h.length===0?0:1;d<=f;d++){const[m,p]=qa(u,d/f);h.push(a(m)),c.push(l(p))}return{fn:Xa(h,c)}}function Rs(e={}){const n=.1+Math.max(0,Math.min(1,e.strength??.7))*.7,i=[1];for(let r=n;r>.002;r*=n)i.push(2*Math.sqrt(r));const s=i.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*s;for(let a=0;a<i.length;a++){if(o<=i[a]){if(a===0)return(o/i[0])**2;const l=i[a]/2,h=l*l,c=o-l;return 1-(h-c*c)}o-=i[a]}return 1}}function $s(e={}){const t=Math.max(1,e.wiggles??10),n=e.type??"easeOut",i=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*t*Math.PI*2)*i(s)}function qa(e,t){if(e.type==="L"){const[h,c]=e.points;return[e.startX+(h-e.startX)*t,e.startY+(c-e.startY)*t]}const[n,i,s,r,o,a]=e.points,l=1-t;return[l*l*l*e.startX+3*l*l*t*n+3*l*t*t*s+t*t*t*o,l*l*l*e.startY+3*l*l*t*i+3*l*t*t*r+t*t*t*a]}function Xa(e,t){return n=>{if(n<=e[0])return t[0];if(n>=e[e.length-1])return t[t.length-1];let i=0,s=e.length-1;for(;s-i>1;){const o=i+s>>1;e[o]<=n?i=o:s=o}const r=e[s]-e[i];return r===0?t[s]:t[i]+(n-e[i])/r*(t[s]-t[i])}}function Fs(e,t,n,i){const s=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let c=0;c<8;c++){const f=s(a,e,n)-o,u=r(a,e,n);if(Math.abs(f)<1e-6)return s(a,t,i);if(Math.abs(u)<1e-6)break;a-=f/u}let l=0,h=1;a=o;for(let c=0;c<40;c++)s(a,e,n)<o?l=a:h=a,a=(l+h)/2;return s(a,t,i)}}const Ua=350,Va=300,za=550;function ja(e,t={}){const n=t.lead??Ua,i=t.gap??Va,s=t.tail??za,r=[];let o=0;return e.forEach((a,l)=>{const h=[];let c=o+n;a.lines.forEach((u,d)=>{if(!(u.duration>=0))throw new Error(`narration: scene ${l} line ${d} has an invalid duration (${u.duration})`);d>0&&(c+=i),h.push({id:u.id??`s${l}-l${d}`,scene:l,line:d,start:c,end:c+u.duration,text:u.text}),c+=u.duration});const f=c+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:f-o,cues:h}),o=f}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function Ga(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Ja(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const Bn=e=>6e4/e.bpm;function Ce(e,t){return e.offset+t*Bn(e)}function He(e,t){return(t-e.offset)/Bn(e)}function Za(e,t){return Ce(e,Math.round(He(e,t)))}function Qa(e,t){return Ce(e,Math.ceil(He(e,t)-1e-9))}function tl(e,t,n){const i=Math.max(1,Math.round(e.beatsPerBar??4)),s=[];if(!(e.bpm>0)||n<t)return s;for(let r=Math.ceil(He(e,t)-1e-9);;r++){const o=Ce(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const Lt=100;function el(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/Lt)),o=Math.min(e.length,Math.round((n.maxSeconds??60)*t)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let x=0;x<a;x++){let _=0;for(let P=x*r;P<(x+1)*r;P++)_+=e[P]*e[P];l[x]=Math.log(1e-6+_/r)}const h=new Float64Array(a);for(let x=1;x<a;x++)h[x]=Math.max(0,l[x]-l[x-1]);const c=h.reduce((x,_)=>x+_,0)/a;for(let x=0;x<a;x++)h[x]=Math.max(0,h[x]-c);const f=Math.max(1,Math.floor(60*Lt/s)),u=Math.min(a-1,Math.ceil(60*Lt/i)),d=x=>{let _=0;for(let P=x;P<a;P++)_+=h[P]*h[P-x];return _/(a-x)};let m=0;for(let x=0;x<a;x++)m+=h[x]*h[x];m/=a;let p=f,g=-1/0;for(let x=f;x<=u;x++){const _=60*Lt/x,P=Math.exp(-.5*(Math.log2(_/120)/.9)**2),A=d(x)*P;A>g&&(g=A,p=x)}const y=x=>{const _=Math.floor(x);return _<0||_+1>=a?0:h[_]+(h[_+1]-h[_])*(x-_)},v=(x,_)=>{let P=0;for(let A=_;A<a;A+=x)P+=y(A);return P};let w=p,T=0,k=-1/0;for(let x=p-.6;x<=p+.6+1e-9;x+=.02){if(x<1)continue;const _=Math.max(1,Math.round(x*4));for(let P=0;P<_;P++){const A=P/_*x,E=v(x,A);E>k&&(k=E,T=A,w=x)}}const S=60*Lt/w,M=m>0?Math.max(0,Math.min(1,d(p)/m)):0,C=(T+.5)*1e3/Lt;return{bpm:Math.round(S*100)/100,offset:Math.round(C%(6e4/S)),confidence:M}}const ot=e=>Math.round(e*1e3)/1e3;function Ls(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${ot(e[0].x)} ${ot(e[0].y)}`;if(s===1)return r;const o=l=>i?e[(l%s+s)%s]:e[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const h=o(l-1),c=o(l),f=o(l+1),u=o(l+2);if(n===0){r+=` L${ot(f.x)} ${ot(f.y)}`;continue}const d=n/6,m=c.x+(f.x-h.x)*d,p=c.y+(f.y-h.y)*d,g=f.x-(u.x-c.x)*d,y=f.y-(u.y-c.y)*d;r+=` C${ot(m)} ${ot(p)} ${ot(g)} ${ot(y)} ${ot(f.x)} ${ot(f.y)}`}return i?`${r} Z`:r}const K=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function nl(e){const t=(e??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<t.length;i+=2)n.push({x:t[i],y:t[i+1]});return n}function Ie(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=K(t.cx),i=K(t.cy),s=e.tag.toLowerCase()==="circle"?K(t.r):K(t.rx),r=e.tag.toLowerCase()==="circle"?K(t.r):K(t.ry);return`M${n+s} ${i} A${s} ${r} 0 1 1 ${n-s} ${i} A${s} ${r} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=K(t.x),i=K(t.y),s=K(t.width),r=K(t.height);let o=t.rx!=null?K(t.rx):t.ry!=null?K(t.ry):0,a=t.ry!=null?K(t.ry):o;return o=Math.min(o,s/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${i} H${n+s} V${i+r} H${n} Z`:`M${n+o} ${i} H${n+s-o} A${o} ${a} 0 0 1 ${n+s} ${i+a} V${i+r-a} A${o} ${a} 0 0 1 ${n+s-o} ${i+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${i+r-a} V${i+a} A${o} ${a} 0 0 1 ${n+o} ${i} Z`}case"line":return`M${K(t.x1)} ${K(t.y1)} L${K(t.x2)} ${K(t.y2)}`;case"polyline":case"polygon":{const n=nl(t.points);if(n.length===0)return null;const i=n.map((s,r)=>`${r===0?"M":"L"}${s.x} ${s.y}`).join(" ");return e.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}const Re={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},Os={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function il(e){let t=e.trim().toLowerCase();t=t.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(t);return n&&n[1]!=="steps"&&t!=="none"&&t!=="linear"&&(t=`${n[1]}.out${n[2]??""}`),t}V({type:"bounce",mode:"in"}),V({type:"bounce",mode:"in-out"});function ne(e){const t=Bs.get(e.trim().toLowerCase());if(t)return t;const n=il(e),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const o={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:o,fn:V(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(f=>Number.parseFloat(f)).filter(f=>Number.isFinite(f)),h=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in Re)return{easing:{type:"cubic-bezier",points:Re[n]}};const c=r==="elastic"?{type:"elastic",mode:h,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:h}:{type:"back",mode:h,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:c,fn:V(c)}}return n in Os?{easing:Os[n]}:n in Re?{easing:{type:"cubic-bezier",points:Re[n]}}:{easing:"ease-out"}}const Bs=new Map;function Dn(e,t){return Bs.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function Nn(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const Ds=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function Ns(e){return typeof e=="string"&&Ds.test(e)}function sl(e=1){let t=Nn(e);const n=(l,h)=>((...c)=>c.length>=l?h(...c):f=>h(...c,f)),i=(l,h,c)=>Math.min(Math.max(c,Math.min(l,h)),Math.max(l,h)),s=(l,h,c,f,u)=>h===l?c:c+(u-l)/(h-l)*(f-c),r=(l,h)=>{if(typeof l=="number")return l===0?h:Math.round(h/l)*l;if(Array.isArray(l))return Ws(l,h,1/0);if("values"in l)return Ws(l.values,h,l.radius??1/0);const c=Math.round(h/l.increment)*l.increment;return Math.abs(c-h)<=(l.radius??1/0)?c:h},o=(l,h,c)=>{const f=l+t()*(h-l);return c?Math.round(f/c)*c:f};return{clamp:n(3,i),mapRange:n(5,s),normalize:n(3,(l,h,c)=>s(l,h,0,1,c)),interpolate:n(3,(l,h,c)=>{if(typeof l=="object"&&!Array.isArray(l)){const f={};for(const u of Object.keys(l))f[u]=ee(l[u])(l[u],h[u],c);return f}return ee(l)(l,h,c)}),wrap:((l,h,c)=>{if(Array.isArray(l)){const p=l,g=y=>p[(Math.round(y)%p.length+p.length)%p.length];return h===void 0?g:g(h)}const f=l,d=h-f,m=p=>d===0?f:((p-f)%d+d)%d+f;return c===void 0?m:m(c)}),wrapYoyo:n(3,(l,h,c)=>{const f=h-l;if(f===0)return l;const u=((c-l)%(f*2)+f*2)%(f*2);return l+(u>f?f*2-u:u)}),snap:n(2,r),random:((l,h,c,f)=>{if(Array.isArray(l)){const d=()=>l[Math.floor(t()*l.length)];return h===!0?d:d()}const u=()=>o(l,h,c);return f?u:u()}),shuffle:l=>{for(let h=l.length-1;h>0;h--){const c=Math.floor(t()*(h+1));[l[h],l[c]]=[l[c],l[h]]}return l},distribute:({base:l=0,amount:h,each:c,from:f="start",ease:u})=>(d,m,p)=>{const g=p.length,v=be(d,g,{...h!==void 0?{amount:h}:{each:c??1},from:f}),w=h!==void 0?h:(c??1)*pn(g,f),T=u&&w>0?u(v/w)*w:v;return l+T},pipe:(...l)=>h=>l.reduce((c,f)=>f(c),h),splitColor:l=>rl(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=Nn(l)},resolveRandomString:l=>{const h=Ds.exec(l)?.[1]??"";if(h.startsWith("[")){const m=h.slice(1,-1).split(",").map(p=>p.trim()).filter(Boolean).map(p=>Number.isFinite(Number(p))?Number(p):p.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[c,f,u]=h.split(",").map(d=>Number.parseFloat(d));return o(c,f,Number.isFinite(u)?u:void 0)}}}function Ws(e,t,n){let i=t,s=1/0;for(const r of e){const o=Math.abs(r-t);o<s&&(s=o,i=r)}return s<=n?i:t}function rl(e){const t=e.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(t)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(t)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(s=>Number.parseFloat(s));return i.length>=4?[i[0],i[1],i[2],i[3]]:[i[0]??0,i[1]??0,i[2]??0]}const ol=/^([+-])=\s*(-?[\d.]+)$/,al=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function ie(e,t){const n=t.scale??1,i=h=>Number.parseFloat(h)*n;if(e===void 0)return t.cursor;if(typeof e=="number")return e*n;const s=e.trim();if(s==="")return t.cursor;const r=ol.exec(s);if(r){const h=i(r[2]);return t.cursor+(r[1]==="-"?-h:h)}const o=al.exec(s);if(o){const h=o[1]==="<"?t.previousStart:t.previousEnd;if(o[3]===void 0)return h;const c=i(o[3]);return h+(o[2]==="-"?-c:c)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const h=t.labels.get(a[1].trim());if(h!==void 0){const c=i(a[3]);return h+(a[2]==="-"?-c:c)}}const l=t.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):t.cursor}function ll(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.grid!==void 0||t.from==="random"||Array.isArray(t.from)||t.ease!==void 0||t.axis!==void 0}function hl(e,t,n={}){if(e===0)return[];const i=t.grid==="auto"?Math.max(1,Math.min(e,n.columnsFromLayout?.()??e)):Array.isArray(t.grid)?Math.max(1,t.grid[1]):e,s=Array.isArray(t.grid)?Math.max(1,t.grid[0]):Math.ceil(e/i),r=m=>({x:m%i,y:Math.floor(m/i)}),o=t.from??"start",a=Array.isArray(o)?{x:o[0]*(i-1),y:o[1]*(s-1)}:typeof o=="number"?r(Math.max(0,Math.min(e-1,o))):o==="end"?r(e-1):o==="center"||o==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=m=>{const{x:p,y:g}=r(m),y=Math.abs(p-a.x),v=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?v:Math.hypot(y,v)};let h=Array.from({length:e},(m,p)=>l(p));const c=Math.max(...h);if(o==="edges"&&(h=h.map(m=>c-m)),o==="random"){const m=n.random??Math.random;h=h.map(()=>m()*c)}const f=t.amount!==void 0?t.amount:(t.each??0)*c,u=t.ease?ne(t.ease):void 0,d=u?u.fn??V(u.easing):void 0;return h.map(m=>{const p=c===0?0:m/c;return(d?d(p):p)*f})}const Wn=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]);function $e(e){const t={},n={};for(const[i,s]of Object.entries(e))Wn.has(i)?t[i]=s:n[i]=s;return{config:t,properties:n}}function Fe(e,t){return e===void 0?t:e*1e3}function Kn(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:ll(e)?{offsets:hl(t?.count??0,e,t??{}).map(i=>i*1e3)}:{...e.each!==void 0&&{each:e.each*1e3},...e.amount!==void 0&&{amount:e.amount*1e3},...e.from!==void 0&&{from:e.from}}}const cl={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,rotation:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function Ks(e){return cl[e]}function ul(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:e;if(!t||typeof t.path!="string"&&!Array.isArray(t.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(t.path))n=Ls(t.path,{curviness:t.curviness});else if(Rt(t.path))n=t.path;else throw new Error(`gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const i={pathData:n};return t.autoRotate!==void 0&&t.autoRotate!==!1&&(i.autoRotate=!0,typeof t.autoRotate=="number"&&(i.rotateOffset=t.autoRotate)),t.matrix&&(i.matrix=t.matrix),{config:i,start:t.start??0,end:t.end??1}}function fl(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function Ys(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function dl(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=Ys(t);if(typeof i!="string"||!Rt(i))throw new Error(`gsap-compat: morphSVG "${String(i)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:i}}function pl(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,qs(e,t)];const n=e.trim().split(/[\s,]+/).filter(Boolean),i=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${e}" is not a length or percentage`);return qs(o.endsWith("%")?t*a/100:a,t)};if(n.length===0)return[0,t];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),r=i(n[1]);return s<=r?[s,r]:[r,s]}function ml(e,t){const[n,i]=pl(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function gl(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...ml(n,t)}}function yl(e){if(e.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return e}function qs(e,t){return Math.max(0,Math.min(t,e))}function bl(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function wl(e,t,n){if(e.scrambleText!==void 0){const i=e.scrambleText,s=typeof i=="string"?{text:i}:i;if(typeof s?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=s.revealDelay&&n>0?s.revealDelay*1e3/n:void 0;return{to:s.text,mode:"scramble",...s.chars!==void 0&&{chars:s.chars},...s.speed!==void 0&&{refreshRate:20*s.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??bl(`${t}|${s.text}`)}}if(e.text!==void 0){const i=e.text,s=typeof i=="string"?{value:i}:i;if(typeof s?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:s.value,mode:"type",...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft}}}}function Yn(e){return Math.max(.1,e/25)}function vl(e,t){const n=typeof t=="number"?{velocity:t}:t;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const i=n.friction??(n.resistance!==void 0?Yn(n.resistance):void 0),s={from:e,velocity:n.velocity,...i!==void 0&&{friction:i},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?s.end=[n.end(Gt(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function kl(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in ke))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(ke).join(", ")}`);return{...t.preset?ke[t.preset]:{},...t.stiffness!==void 0&&{stiffness:t.stiffness},...t.damping!==void 0&&{damping:t.damping},...t.mass!==void 0&&{mass:t.mass},...t.restDelta!==void 0&&{restDelta:t.restDelta}}}function Sl(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class Tt{timeline;options;cursor=0;fallbackRandom=Nn(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new In({id:t.id??"gsap-compat",name:t.name,config:{...t.repeat!==void 0&&{loop:t.repeat},...t.yoyo!==void 0&&{alternate:t.yoyo},...t.repeatDelay!==void 0&&{repeatDelay:t.repeatDelay*1e3},...t.timeScale!==void 0&&{speed:t.timeScale}}})}to(t,n,i){return this.build(t,void 0,se(n),i)}from(t,n,i){const{config:s,properties:r}=$e(se(n)),{motionPath:o,text:a,scrambleText:l,...h}=r,c=this.targetsOf(t)[0],f={...s};for(const m of Object.keys(h))f[m]=this.resolveStart(c,m);o!==void 0&&(f.motionPath=fl(o));const u={},d=String(this.resolveStart(c,"text"));return a!==void 0&&(u.text=qn(a),f.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(u.text=qn(l),f.scrambleText=typeof l=="object"?{...l,text:d}:d),this.build(t,{...h,...u},f,i)}fromTo(t,n,i,s){const{properties:r}=$e(se(n));return this.build(t,r,se(i),s)}set(t,n,i){return this.build(t,void 0,{...se(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,ie(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return ie(t,this.context())}addLabel(t,n){return this.labels.set(t,ie(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((t,n)=>t-n)}labelTime(t){return this.labels.get(t)}add(t,n){const i=ie(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=xe({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(o)}const s=i+t.timeline.duration;return this.previousStart=i,this.previousEnd=s,this.cursor=Math.max(this.cursor,s),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(t){if(typeof t=="string"){const n=this.labels.get(t);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(t*1e3),this}progress(t){const n=this.timeline.duration;return t!==void 0&&n>0&&this.timeline.seek(t*n),n>0?this.timeline.currentTime/n:0}timeScale(t){return t!==void 0&&(this.timeline.speed=t),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(t){return this.timeline.tick(t),this}toDefinition(){return this.timeline.toDefinition()}build(t,n,i,s){const{config:r,properties:o}=$e(i),{motionPath:a,text:l,scrambleText:h,inertia:c,...f}=o,u=this.targetsOf(t),d=ie(s,this.context()),m=Fe(r.delay,0),p=Fe(r.duration,500),g=Kn(r.stagger,{count:u.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(u):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),v=[],w=r.spring;let T=0,k=!1;for(const[P,A]of Object.entries(f)){const E=A;let H=n?.[P]!==void 0?n[P]:this.resolveStart(u[0],P);if(typeof H!=typeof E&&(this.warn(`no usable start value for "${P}" on "${u[0]}" — it will snap to ${String(E)}. Use fromTo() to animate it.`),H=E),w!==void 0&&(typeof H!="number"||typeof E!="number")&&this.warn(`spring works on numbers, so "${P}" on "${u[0]}" eases instead`),w!==void 0&&typeof H=="number"&&typeof E=="number"){const $={...kl(w),from:H,to:E,velocity:Sl(w,P)??this.options.startVelocity?.(u[0],P)??0},O=this.nextTrackId(`${u[0]}-${P}-spring`),L={id:O,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:P,kind:"spring",spring:$,delay:d+m};this.timeline.addTrack(L),v.push(O),T=Math.max(T,Bi($));for(const F of u)this.lastValues.set(`${F}|${P}`,E);continue}k=!0;const I=this.keyframesFor(H,E,p,y,r.ease),R=this.nextTrackId(`${u[0]}-${P}`);this.timeline.addTrack(xe({id:R,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:P,delay:d+m,keyframes:I})),v.push(R);for(const $ of u)this.lastValues.set(`${$}|${P}`,E)}const S=wl({text:l,scrambleText:h},u[0],p);if(S){const P=n?.text??n?.scrambleText,A=P!==void 0?qn(P):this.resolveStart(u[0],"text"),E=this.nextTrackId(`${u[0]}-text`),H={id:E,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"text",textConfig:{from:typeof A=="string"?A:String(A??""),...S},delay:d+m,keyframes:this.keyframesFor(0,1,p,y,r.ease)};this.timeline.addTrack(H),v.push(E);for(const I of u)this.lastValues.set(`${I}|text`,S.to)}if(a!==void 0){const{config:P,start:A,end:E}=ul(a),H=this.nextTrackId(`${u[0]}-motionPath`),I={id:H,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"motionPath",motionPathConfig:P,delay:d+m,keyframes:this.keyframesFor(A,E,p,y,r.ease)};this.timeline.addTrack(I),v.push(H)}if(c!==void 0)for(const[P,A]of Object.entries(c)){const E=this.resolveStart(u[0],P);if(typeof E!="number"){this.warn(`inertia on "${P}" needs a numeric start value; skipped`);continue}const H=vl(E,A),I=this.nextTrackId(`${u[0]}-${P}-inertia`),R={id:I,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:P,kind:"inertia",inertia:H,delay:d+m};this.timeline.addTrack(R),v.push(I),T=Math.max(T,Ht(H));for(const $ of u)this.lastValues.set(`${$}|${P}`,Ct(H))}const x=((c!==void 0||w!==void 0)&&!k&&!S&&a===void 0?T:Math.max(p,T))+(g&&u.length>1?zt(u.length,g):0),_=d+m+x;return this.previousStart=d+m,this.previousEnd=_,this.cursor=Math.max(this.cursor,_),{trackIds:v,start:d+m,end:_,kill:()=>{for(const P of v)this.timeline.removeTrack(P)}}}keyframesFor(t,n,i,s,r){const o={time:0,value:t};if(i<=0)return[{time:0,value:n}];const a=typeof r=="string"?ne(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Ut(s)){const h=a?.fn??V(s);return[o,..._n(o,{time:i,value:n},h,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:i,value:n,...s&&{easing:s}}]}resolveStart(t,n){const i=this.lastValues.get(`${t}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(t,n);if(s!==void 0)return s;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="d")throw new Error(`gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=Ks(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${t}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${t}" — using 0`),0)}easingFor(t){if(t!==void 0){if(typeof t=="string")return ne(t).easing;if(typeof t=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return t}}targetsOf(t){return Array.isArray(t)?t:[t]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(t){return this.trackCounter+=1,`${t}-${this.trackCounter}`}warn(t){this.options.onWarning?.(`gsap-compat: ${t}`)}}function qn(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return String(t.value??t.text??"")}return String(e??"")}function Tl(e){return new Tt(e)}function se(e){return yl(dl(e))}const Ml=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),El="#ffffff",Al="rgba(0, 0, 0, 0.5)";function xl(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??El})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??Al})`)}return t.length>0?t.join(" "):null}function Pl(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function _l(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Xs=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),Cl=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),Hl=new Set(["originX","originY"]),Il=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Rl=new Set(["drawOn"]),$l={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Us={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Fl="http://www.w3.org/2000/svg";class Mt{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){const i=[];let s=null,r=null,o=null;const a=n.has("motionPathX"),l=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[u,d]of n)if(!(u==="x"&&a)&&!(u==="y"&&l)&&!((u==="rotate"||u==="rotateZ")&&h)&&!Rl.has(u)){if(Cl.has(u)){const m=this.buildTransformPart(u,d);m&&i.push(m)}else if(Hl.has(u))typeof d=="number"&&((s??={})[u]=d);else if(Il.has(u))typeof d=="number"&&((r??={})[u]=d);else if(Ml.has(u))(o??={})[u]=d;else if(u!=="perspective"){if(u!=="shine")if(u==="text"&&typeof d=="string")Pl(t,d);else if(u==="d"&&typeof d=="string"){const m=t;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,u,d)}}const c=n.get("shine");typeof c=="number"&&this.applyShine(t,c);const f=n.get("perspective");if(typeof f=="number"&&i.unshift(`perspective(${f}px)`),i.length>0&&(t.style.transform=i.join(" "),_l(t)),s){const u=s.originX??50,d=s.originY??50;t.style.transformOrigin=`${u}% ${d}%`}if(r){const u=r.clipTop??0,d=r.clipRight??0,m=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${u}% ${d}% ${m}% ${p}%)`}if(o){const u=xl(o);u&&(t.style.filter=u)}}buildTransformPart(t,n){if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===Fl&&n in Us){const a=Array.isArray(i)?i.join(", "):String(i);t.style[Us[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=$l[n]??n;let o;typeof i=="number"?Xs.has(n)||Xs.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Ll={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class Vs{adapter=new Mt;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=sl();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Ll,this.rootOption=t.root,this.onWarning=t.onWarning}get root(){return this.rootOption??document}resolveTargets(t){const n=[];for(const i of this.targetsOf(t)){const s=this.nameFor(i);Xn(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(t){return this.selectorRoot.querySelector(t)}get collector(){return this.currentCollector}setCollector(t){this.currentCollector=t}forget(t){this.applied.delete(t),this.dirty.delete(t)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(t){return this.elements.get(t)}objectFor(t){return this.objects.get(t)}appliedValue(t,n){return this.applied.get(t)?.get(n)}velocityOf(t,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:t,property:n}).length===0)continue;const r=s.currentTime;if(r<4)return 0;const o=s.getStateAtTime(r).values.get(t)?.get(n),a=s.getStateAtTime(r-4).values.get(t)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:t=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(t),this.currentCollector?.track({revert:()=>this.ticker.remove(t)}),this.startLoop())},remove:t=>{this.tickerCallbacks.delete(t),this.running||this.stopLoop()}};activate(t,n={}){this.destroyed||(t.onUpdate=i=>this.write(i),this.active.delete(t),this.active.set(t,n),this.startLoop())}deactivate(t){this.active.delete(t),this.running||this.stopLoop()}own(t){return this.destroyed?t.destroy():this.owned.add(t),t}destroy(){this.destroyed=!0;for(const t of this.owned)t.destroy();this.owned.clear();for(const t of this.active.keys())t.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(t,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[t,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(t){this.destroyed||(this.write(t.getStateAtTime(t.currentTime)),this.flush())}tick(t){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(t);this.flush();for(const[i,s]of n)s.onUpdate?.(),i.playbackState!=="playing"&&this.active.get(i)===s&&this.active.delete(i);this.flush(),this.runTicker(t),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(t){if(this.tickerCallbacks.size!==0){this.tickerTime+=t,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,t,this.tickerFrame)}}write(t){for(const[n,i]of t.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[r,o]of i)s.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const t=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[r,o]of i)s[r]=o;else t.set(n,i)}this.dirty.clear(),t.size!==0&&this.adapter.applyState({values:t,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=t=>{this.frameId=null;const n=this.lastTimestamp===null?0:t-this.lastTimestamp;this.lastTimestamp=t,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(t){if(typeof t=="string")return Array.from(this.selectorRoot.querySelectorAll(t));if(Xn(t))return[t];if(!Ol(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return Xn(t)?this.elementName(t):this.objectName(t)}objectName(t){const n=this.objectNames.get(t);if(n)return n;let i;do this.nameCounter+=1,i=`obj-${this.nameCounter}`;while(this.objects.has(i)||this.elements.has(i));return this.objectNames.set(t,i),this.objects.set(i,t),i}elementName(t){const n=this.names.get(t);if(n)return n;let i=t.id?`#${t.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(t,i),this.elements.set(i,t),this.adapter.registerTarget(i,t),i}}function Xn(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Ol(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function Le(e){const t=e.style;if(!t)return e.getBoundingClientRect();const n=t.transform;t.transform="none";const i=e.getBoundingClientRect();return t.transform=n,i}const zs=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Bl(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Dl(e){const t=e.getScreenCTM?.();if(t)return[t.a,t.b,t.c,t.d,t.e,t.f];const n=e.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function Nl(e,t){const n=typeof e=="string"||Array.isArray(e)||zs(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=S=>{const M=zs(S)?S:t.query(S);return M||t.warn(`gsap-compat: motionPath could not find "${String(S)}"`),M};let l=null,h="";if(Array.isArray(r)||typeof r=="string"&&Rt(r))h=r;else{l=a(r);const S=l&&Ie({tag:l.localName,attributes:Bl(l)});l&&!S&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),h=S??""}const c={...o,path:h};if(i===void 0||i===!1)return c;const f=i===!0?l:a(i);if(!f)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),c;const u=t.targets[0];if(!u)return c;const[d,m,p,g,y,v]=Dl(f),w=Le(u),[T,k]=s??[.5,.5];for(const S of t.targets.slice(1)){const M=Le(S);if(Math.abs(M.left-w.left)>.5||Math.abs(M.top-w.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return c.matrix=[d,m,p,g,y-w.left-T*w.width,v-w.top-k*w.height],c}const js=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Gs(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Js(e){if(!e)return null;const t=Ie({tag:e.localName,attributes:Gs(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function Wl(e,t,n){const i=Ys(e);if(typeof i=="string"&&Rt(i))return i;const s=js(i)?i:typeof i=="string"?t(i):null,r=Js(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Kl=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Yl(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):js(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=Ie({tag:i.localName,attributes:Gs(i)});if(!s||!i.parentNode)return i;const r=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(i.attributes))Kl.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const Zs=.3;class Qs{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(t){this.options=t,this.target=t.target}start(){if(this.running)return;this.running=!0;const t=this.options.type??["pointer","touch"];t.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),t.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),t.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(t,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=t,this.startY=n,this.lastX=t,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=tr(),this.options.onPress?.(this.stateFrom(0,0,i))}move(t,n,i){if(!this.dragging)return;const s=t-this.lastX,r=n-this.lastY;this.lastX=t,this.lastY=n;const o=t-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,r),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,r,i))}end(t){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,t)))}updateVelocity(t,n){const i=tr(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*Zs,this.velocityY+=(o-this.velocityY)*Zs}stateFrom(t,n,i){return{deltaX:t,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=t=>{const n=t,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,t)};onPointerMove=t=>{const n=t;this.move(n.clientX,n.clientY,t)};onPointerUp=t=>this.end(t);onTouchStart=t=>{const n=t.touches[0];n&&this.begin(n.clientX,n.clientY,t)};onTouchMove=t=>{const n=t.touches[0];n&&this.move(n.clientX,n.clientY,t)};onTouchEnd=t=>this.end(t);onWheel=t=>{const n=t;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:t})}}function tr(){return typeof performance<"u"?performance.now():Date.now()}function er(e,t,n){let i={delta:0,line:null},s=n;for(const r of e)for(const o of t){const a=Math.abs(o-r);a<=s&&(s=a,i={delta:o-r,line:o})}return i}function nr(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class Un{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(t){this.options=t,this.x=t.initialX??0,this.y=t.initialY??0,this.observer=new Qs({target:t.target,onPress:n=>{const i=t.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,t.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>t.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(t,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(t,"x"),this.y=i==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const t=this.options.snap??0;return t>0?t/2:8}handleMove(t){this.setPosition(this.originX+t.totalX,this.originY+t.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,t),this.options.onSnap?.(this.snapLines)}scrub(){const t=this.options.timeline;if(!t)return;const n=t.duration;if(n<=0)return;const i=this.options.scrubDistance??500;if(i===0)return;const s=(this.options.axis??"both")==="y"?this.y:this.x,r=ql(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...nr([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=er([i],s,this.snapThreshold());i+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function ql(e){return e<0?0:e>1?1:e}function Xl(e){const t=new Un(e);return t.start(),t}const Ul={x:"x",y:"y","x,y":"both"},Vn=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function ir(e,t){const n=Le(e),i=t.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function sr(e){return Array.isArray(e)?[...e]:e}function Vl(e,t,n,i={}){const[s]=t.resolveTargets(n),r=s?t.elementFor(s):void 0;if(!s||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return zl(e,t,s,r,i);const o=Ul[i.type??"x,y"],a=()=>{const p=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof p=="number"?p:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):Vn(i.bounds)?i.bounds:null,c={bounds:(!l&&i.bounds&&!Vn(i.bounds)?i.bounds:void 0)??(l?ir(r,l):void 0)};let f=null;const u=()=>{f?.kill(),f=null},d=p=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?Yn(g.resistance):4),v=a(),w=c.bounds??{};let T,k;const S=g.end;if(Array.isArray(S)){const C=Gt({from:v.x,velocity:o==="y"?0:p.x,friction:y}),x=Gt({from:v.y,velocity:o==="x"?0:p.y,friction:y});let _=S[0];for(const P of S)Math.hypot(P.x-C,P.y-x)<Math.hypot(_.x-C,_.y-x)&&(_=P);_&&(T=[_.x],k=[_.y])}else typeof S=="number"?(T=S,k=S):S&&(T=sr(S.x),k=sr(S.y));const M={};o!=="y"&&(M.x={velocity:p.x,friction:y,min:w.minX,max:w.maxX,end:T}),o!=="x"&&(M.y={velocity:p.y,friction:y,min:w.minY,max:w.maxY,end:k}),f=e.to(r,{inertia:M,onComplete:()=>i.onThrowComplete?.()})},m=new Un({target:r,axis:o,snap:i.snap,get bounds(){return c.bounds},getPosition:a,onPress:()=>{u(),l&&(c.bounds=ir(r,l)),i.onPress?.()},onDrag:p=>{t.apply(s,o==="x"?{x:p.x}:o==="y"?{y:p.y}:{x:p.x,y:p.y}),i.onDrag?.(p)},onRelease:()=>{const p=m.velocity;i.onRelease?.(p),i.inertia&&d(p)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const p=t.appliedValue(s,"rotate");return typeof p=="number"?p:0},destroy(){u(),m.destroy()}}}function zl(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!Vn(s.bounds)?s.bounds:{},o=()=>{const w=t.appliedValue(n,"rotate");return typeof w=="number"?w:0},a=w=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,w));let l=null,h=!1,c,f={x:0,y:0},u=0,d=0,m=[];const p=w=>Math.atan2(w.clientY-f.y,w.clientX-f.x)*180/Math.PI,g=w=>{if(h)return;l?.kill(),l=null,h=!0,c=w.pointerId,i.setPointerCapture?.(w.pointerId);const T=i.getBoundingClientRect();f={x:T.left+T.width/2,y:T.top+T.height/2},u=p(w),d=o(),m=[{time:performance.now(),rotation:d}],s.onPress?.()},y=w=>{if(!h||w.pointerId!==c)return;const T=p(w);let k=T-u;k>180&&(k-=360),k<-180&&(k+=360),u=T,d+=k;let S=a(d);s.snap&&(S=a(Math.round(S/s.snap)*s.snap)),t.apply(n,{rotate:S});const M=performance.now();for(m.push({time:M,rotation:S});m.length>2&&M-m[0].time>100;)m.shift();const C={x:0,y:0};s.onDrag?.(C)},v=w=>{if(!h||w.pointerId!==c)return;h=!1;const T=m[0],k=m[m.length-1],S=T&&k?(k.time-T.time)/1e3:0,M=S>0?(k.rotation-T.rotation)/S:0;if(s.onRelease?.({x:M,y:0}),!s.inertia)return;const C=s.inertia===!0?{}:s.inertia,x=C.friction??(C.resistance!==void 0?Yn(C.resistance):4),_=typeof C.end=="number"||Array.isArray(C.end)?C.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:M,friction:x,min:r.minRotation,max:r.maxRotation,end:Array.isArray(_)?_.filter(P=>typeof P=="number"):_}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",v),i.addEventListener("pointercancel",v),i.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),i.removeEventListener("pointerdown",g),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",v),i.removeEventListener("pointercancel",v)}}}const jl={opacity:0,scale:.6};function Gl(e){const t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function rr(e){const t=Le(e);return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function zn(e,t){const i=e.resolveTargets(t).map(o=>e.elementFor(o)).filter(o=>!!o),s=new Map,r=new Map;for(const o of i){const a=Gl(o);s.set(o,a);const l=or(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const jn=new WeakMap;function Gn(e,t,n,i={}){const s=i.duration??.6,r=i.ease??"power2.inOut",o=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?jl:i.enter,h=new Set(n.elements);if(i.targets!==void 0)for(const d of e.resolveTargets(i.targets)){const m=e.elementFor(d);m&&h.add(m)}const c=[...h].sort((d,m)=>d===m?0:d.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),f=t({onComplete:i.onComplete});let u=0;for(const d of c){const m=rr(d);if(!m)continue;let p=n.boxes.get(d)??null,g;const y=or(d),v=!p&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==d&&(p=v.box,g=v.element);const[w]=e.resolveTargets(d);jn.get(d)?.timeline.removeTracks({target:w});const T=u*o;if(!p){if(l===!1)continue;f.fromTo(d,{x:0,y:0,scaleX:1,scaleY:1,...l},{...ar(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:T},0),jn.set(d,f),u++;continue}const k=p.cx-m.cx,S=p.cy-m.cy,M=a?p.width/m.width:1,C=a?p.height/m.height:1;if(!(Math.abs(k)>.5||Math.abs(S)>.5||Math.abs(M-1)>.001||Math.abs(C-1)>.001)){const P=(A,E)=>{const H=e.appliedValue(w,A);return typeof H=="number"&&Math.abs(H-E)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&f.set(d,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const _=i.fade===!0&&g!==void 0;f.fromTo(d,{x:k,y:S,scaleX:M,scaleY:C,..._&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,..._&&{opacity:1},duration:s,ease:r,delay:T},0),_&&g&&rr(g)&&f.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:T},0),jn.set(d,f),u++}return f}function or(e){return e.dataset?.flipId}function ar(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function Jl(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(p=>p.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(p=>({element:p,html:p.innerHTML,ariaLabel:p.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,h=!1;const c=()=>{for(const{element:p,html:g,ariaLabel:y}of r)p.innerHTML=g,y===null?p.removeAttribute("aria-label"):p.setAttribute("aria-label",y)},f=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},u=()=>{const p={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),v=Zl(g,i.words),w=n.has("chars")?v.flatMap(S=>Ql(S,i.chars)):[],T=n.has("lines")?eh(g,v,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const S of v)S.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...v);else for(const S of v)S.removeAttribute("class");p.chars.push(...w),p.lines.push(...T);const k=t.mask==="lines"?T:t.mask==="words"?v:t.mask==="chars"?w:[];for(const S of k)p.masks.push(nh(S,`${i[t.mask]}-mask`))}o=p},d={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){h||(f(),c(),u(),a=t.onSplit?.(d))},revert(){h=!0,l?.disconnect(),f(),c()}};u(),a=t.onSplit?.(d),t.autoSplit&&m();function m(){const p=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const w=()=>{g=!1,d.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(w):setTimeout(w,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(w=>{let T=!1;for(const k of w){const S=Math.round(k.contentRect.width),M=p.get(k.target);p.set(k.target,S),M!==void 0&&M!==S&&(T=!0)}T&&y()});for(const w of e)l.observe(w)}const v=e[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return d}function Zl(e,t){const n=e.ownerDocument,i=[],s=n.createTreeWalker(e,4),r=[];for(let o=s.nextNode();o;o=s.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const h of a){if(/^\s/.test(h)){l.appendChild(n.createTextNode(h));continue}const c=n.createElement("span");c.className=t,c.style.display="inline-block",c.textContent=h,l.appendChild(c),i.push(c)}o.replaceWith(l)}return i}function Ql(e,t){const n=e.ownerDocument,i=th(e.textContent??"").map(s=>{const r=n.createElement("span");return r.className=t,r.style.display="inline-block",r.textContent=s,r});return e.replaceChildren(...i),i}function th(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function eh(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const p of Array.from(m.childNodes))p.nodeType===3||s.has(p)||p.tagName==="BR"?r.push(p):o(p)};o(e);const a=[];let l=null,h=0,c=0,f=!1,u=[];const d=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),u=[]};for(const m of r){if(m.tagName==="BR"){f=!0;continue}const p=s.get(m);if(p&&(!l||f||p.top>h+c)&&(d(),h=p.top,c=p.height/2,f=!1),!l)continue;const g=[];for(let w=m.parentNode;w&&w!==e;w=w.parentNode)g.unshift(w);let y=0;for(;y<u.length&&y<g.length&&u[y].original===g[y];)y++;u.length=y;let v=y===0?l:u[y-1].clone;for(const w of g.slice(y)){const T=w.cloneNode(!1);v.appendChild(T),u.push({original:w,clone:T}),v=T}v.appendChild(m)}return e.replaceChildren(...a),a}function nh(e,t){const n=e.ownerDocument.createElement("span");return n.className=t,n.style.display=e.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",e.replaceWith(n),n.appendChild(e),n}const lr={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function Jn(e){const t=e.trim().toLowerCase();if(t in lr)return lr[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Zn(e){if(typeof e=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:e};let t=0;const i=e.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(t+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(i.length===1&&/^-?[\d.]+$/.test(i[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(i[0])+t};const s=i[0]!==void 0?Jn(i[0]):void 0,r=i[1]!==void 0?Jn(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Ot(e,t,n){const i=Zn(n),s=i.absolutePx!==void 0?e.top+i.absolutePx:e.top+e.height*i.elementFraction,r=t*i.viewportFraction;return s-r+i.offsetPx}function ih(e,t,n,i){const s=Ot(e,t,n),o=Ot(e,t,i)-s;return o<=0?s<=0?1:0:Qn(-s/o)}function Qn(e){return e<0?0:e>1?1:e===0?0:e}function hr(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function ti(e,t,n,i,s){const r=c=>Ot({top:e+s(c),bottom:e+s(c)+t,height:t},n,i),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,h=1;for(let c=0;c<40;c++){const f=(l+h)/2;Math.sign(r(f))===Math.sign(o)?l=f:h=f}return(l+h)/2}class cr{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(t){this.timeline=t.timeline,this.trigger=t.trigger,this.behaviour=t.behaviour??"once",this.options=t}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function sh(e){const t=new cr(e);return t.start(),t}class ur{element;spacer;saved;axis;spacing;constructor(t,n={}){this.element=t,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=t.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:t.style.position,top:t.style.top,left:t.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),t.replaceWith(this.spacer),this.spacer.appendChild(t)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(t,n){const i=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+i}px`,this.spacer.style.marginRight=this.spacing?"":`-${i}px`,this.element.style.left=`${t}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${t}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const rh=.15;function fr(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function dr(e,t,n){const i=Oe(e+t*rh);if(typeof n=="function")return Oe(n(i));if(typeof n=="number")return n<=0?e:Oe(Math.round(i/n)*n);if(n.length===0)return e;let s=n[0];for(const r of n)Math.abs(r-i)<Math.abs(s-i)&&(s=r);return Oe(s)}function pr(e,t,n){const i=e.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(t)/Math.max(1,n));return i.min+(i.max-i.min)*s}class mr{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(t,n){this.write=t,this.eventTarget=n}get active(){return this.rafId!==null}animate(t,n,i,s=Jt,r){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const h=Math.min(1,(l-o)/(i*1e3));this.write(t+(n-t)*s(h)),h<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const t of this.cancelEvents)this.eventTarget?.removeEventListener(t,this.onInterrupt)}}function Oe(e){return Math.max(0,Math.min(1,e))}class gr{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(t,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(h,c,f)=>{const u=t.createElement("div");return u.textContent=`${a}${h}`,u.setAttribute("aria-hidden","true"),u.className="scroll-marker",Object.assign(u.style,{position:f?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${c}`,color:c,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??t.body).appendChild(u),this.nodes.push(u),u};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",s,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(t,n){this.start.style.top=`${t.startPage}px`,this.end.style.top=`${t.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+t.startViewport}px`,this.scrollerEnd.style.top=`${i+t.endViewport}px`}follow(t,n){this.scroller&&this.place(t,n)}destroy(){for(const t of this.nodes.splice(0))t.remove()}}const oh=120,Bt=[],Dt=new Set;let ei=!1;const ah=()=>{ei||Dt.size===0||(ei=!0,queueMicrotask(()=>{ei=!1;for(const e of Dt)e.afterRefresh()}))},yr=()=>{for(const e of Dt)e.beforeRefresh();for(const e of Bt)e.refresh();for(const e of Dt)e.afterRefresh()};let Nt={width:0,height:0};const br=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===Nt.width&&t!==Nt.height,i=Math.abs(t-Nt.height)<Nt.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(Nt={width:e,height:t},yr())};class re{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(t){this.timeline=t.timeline,this.options=t,this.snapper=new mr(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const t=this.options.pin===!0?this.options.trigger:this.options.pin||null;t&&!this.options.container&&(this.pin=new ur(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new gr(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Bt.length===0&&typeof window<"u"&&(Nt={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",br,{passive:!0})),Bt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Bt.splice(Bt.indexOf(this),1),Bt.length===0&&typeof window<"u"&&window.removeEventListener("resize",br),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){yr()}static onRefresh(t){return Dt.add(t),()=>Dt.delete(t)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const t=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const i=this.viewportHeight();if(this.startPx=t+Ot(n,i,oe(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,t),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-t),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,t),this.lastScroll=null,this.updateFrom(t,!this.measured),this.measured=!0,ah()}sample(){this.refresh()}update(t){this.running&&this.updateFrom(t??this.scrollPosition(),!1)}updateFrom(t,n){this.trackVelocity(t),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,t);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?Qn((t-this.startPx)/i):t>=this.startPx?1:0,this.zone=i>0?t<=this.startPx?"before":t>=this.endPx?"after":"active":t>=this.startPx?"after":"before",this.fireBoundaryCallbacks(s,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const t=this.options.scrub;return typeof t=="number"?Math.max(0,t):0}resolveEnd(t,n,i){const s=oe(this.options.end)??"bottom top",r=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return i+Ot(t,n,s)}applyProgress(){const t=this.timeline?.duration??0;this.timeline&&t>0&&this.timeline.seek(this.displayProgress*t),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const t=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===t[0]&&this.lastEmitted[1]===t[1]||(this.lastEmitted=t,this.options.onUpdate(t[0],t[1]))}trackVelocity(t){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&t!==this.lastScroll&&(this.velocityPxPerSecond=(t-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||t!==this.lastScroll)&&(this.lastScroll=t,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},oh))}fireBoundaryCallbacks(t,n){if(t===n)return;const{onEnter:i,onLeave:s,onEnterBack:r,onLeaveBack:o}=this.options;t==="before"?(i?.(),n==="after"&&s?.()):t==="after"?(r?.(),n==="before"&&o?.()):n==="after"?s?.():o?.()}scheduleSnap(){const t=this.options.snap;if(t===void 0||this.snapper.active)return;const n=fr(t),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||s<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/s,a=this.startPx+dr(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,pr(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(t){const n=this.options.scroller,i=this.options.horizontal?{left:t}:{top:t};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=t:n.scrollTop=t:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(t){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=i.left-s-t.shiftAt(t.progress()),{start:a,end:l}=t.range(),h=d=>a+d*(l-a),c=ti(o,i.width,r,oe(this.options.start)??"left right",t.shiftAt);this.startPx=h(c);const f=oe(this.options.end)??"right left",u=typeof f=="string"?f.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=u?this.startPx+Number.parseFloat(u[1]):h(ti(o,i.width,r,f,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=oe(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Zn(a);return t*l.viewportFraction-l.offsetPx},i=n(this.options.start,"top bottom")??0,s=n(this.options.end,"bottom top")??i;return{startViewport:i,endViewport:s,startPage:this.startPx+i,endPage:this.endPx+s}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const t=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=hr(this.displayProgress,this.targetProgress,this.smoothing(),i);const s=Math.abs(this.targetProgress-this.displayProgress)<1e-4;s&&(this.displayProgress=this.targetProgress),this.applyProgress(),s?this.lastFrameTime=null:this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const t=this.options.scroller,n=this.options.horizontal;return t?(n?t.scrollLeft:t.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const t=this.options.trigger;return typeof t?.getBoundingClientRect!="function"?null:this.relativeRect(t.getBoundingClientRect())}relativeRect(t){const n=this.options.horizontal,i=n?t.left??0:t.top,s=n?t.right??0:t.bottom,r=n?t.width??0:t.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:r}}return{top:i,bottom:s,height:r}}viewportHeight(){const t=this.options.scroller,n=this.options.horizontal;return t?n?t.clientWidth:t.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function oe(e){return typeof e=="function"?e():e}function lh(e){const t=new re(e);return t.start(),t}const ni=new Set,hh=16,wr=.5,ch=2;class ii{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=t=>this.wheel(t);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(t={}){this.options=t,this.frames=t.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const t=this.options.scroller??window;return t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),ni.add(this),this.stopListening=re.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of ni)t.refresh()}stop(){if(!this.running)return this;this.running=!1;const t=this.options.scroller??window;return t.removeEventListener("wheel",this.onWheel),t.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),ni.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)si(t.element,t.saved);this.effects=[]}kill(){this.destroy()}get state(){const t=this.limit();return{scroll:this.current,target:this.target,progress:t>0?this.current/t:0,velocity:this.velocityPxPerSecond}}paused(t){return t!==void 0&&(this.pausedState=t,t&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(t,n={}){if(!this.running)return;const i=this.clamp(this.resolve(t)+(n.offset??0)),s=Math.abs(i-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(r<=0){this.journey=null,this.current=this.target=i,this.write(i),this.applyEffects(0);return}this.target=i,this.journey={from:this.current,to:i,ms:r*1e3,ease:n.ease??Jt,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const t=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(t&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(t)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),h=o.getBoundingClientRect(),c=h.top-r+i;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:c+h.height/2-s/2,lagged:i,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const t of this.effects)si(t.element,t.saved)}wheel(t){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||this.nestedScrollerTakes(t))return;const n=t.deltaMode===1?hh:t.deltaMode===2?this.viewportHeight():1,i=t.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(t.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const t=this.position();this.written!==null&&Math.abs(t-this.written)<=ch||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=t,this.requestFrame())}nestedScrollerTakes(t){const n=this.options.scroller??document.documentElement;for(let i=t.target;i&&i!==n&&i!==document.body;i=i.parentElement){if(i.hasAttribute?.("data-smooth-ignore"))return!0;const s=getComputedStyle(i);if(!/(auto|scroll)/.test(s.overflowY)||i.scrollHeight<=i.clientHeight)continue;if(t.deltaY<0?i.scrollTop>0:i.scrollTop+i.clientHeight<i.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(t=>this.frame(t)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(t){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,t-this.lastTime);this.lastTime=t;const i=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<wr&&(this.current=this.target)}this.current!==i&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-i)*1e3/n:0;const s=this.applyEffects(n);this.current!==i&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||s?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(t){let n=!1;const i=this.current;for(const s of this.effects){let r=0;if(s.speed!==void 0&&(r+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const o=s.lag*1e3/3;s.lagged=t===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-t/o)),Math.abs(i-s.lagged)<wr?s.lagged=i:n=!0,r+=i-s.lagged}si(s.element,r===0?s.saved:`0 ${uh(r)}px`),s.shift=r}return n}write(t){const n=Math.round(t);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const t=this.options.scroller;return t?t.scrollTop:window.scrollY}viewportHeight(){const t=this.options.scroller;return t?t.clientHeight:window.innerHeight}limit(){const t=this.options.scroller??document.documentElement;return Math.max(0,t.scrollHeight-this.viewportHeight())}clamp(t){return Math.max(0,Math.min(this.limit(),t))}resolve(t){if(typeof t=="number")return t;const n=this.options.scroller??document,i=typeof t=="string"?n.querySelector(t):t;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-r}}function si(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function uh(e){return Math.round(e*100)/100}function fh(e,t){switch(t){case"play":if(e.progress()>=1)break;e.reversed()?e.reverse():e.play();break;case"reverse":if(e.progress()<=0)break;e.reversed()?e.play():e.reverse();break;case"pause":e.pause();break;case"resume":e.resume();break;case"restart":e.restart();break;case"reset":e.pause(),e.progress(0);break;case"complete":e.pause(),e.progress(1);break}}function ri(e,t,n,i,s=()=>{}){const r=d=>typeof d=="string"?e.query(d)??void 0:d,o=r(t.trigger)??i;if(!o){s(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger=="string"?` for "${t.trigger}"`:""}`);return}const a=t.scrub===void 0||t.scrub===!1?!1:t.scrub,l=(t.toggleActions??"play none none none").trim().split(/\s+/);let h=0,c;const f=(d,m)=>()=>{m?.(),n&&!a&&fh(n,l[d]??"none"),t.once&&d===0&&queueMicrotask(()=>c.destroy())},u=t.containerAnimation?mh(e,t.containerAnimation,o,s):void 0;return c=new re({trigger:o,start:t.start,end:t.end,scrub:a===!1?void 0:a,pin:t.pin===!0?!0:r(t.pin),scroller:r(t.scroller),horizontal:t.horizontal,pinSpacing:t.pinSpacing,onRefresh:t.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:t.snap===void 0?void 0:dh(t.snap,n),markers:t.markers,container:u,onUpdate:(d,m)=>{if(n&&a!==!1&&n.progress(d),t.onUpdate){const p=d<h||m<0?-1:1;t.onUpdate({progress:d,velocity:m,direction:p})}h=d},onEnter:f(0,t.onEnter),onLeave:f(1,t.onLeave),onEnterBack:f(2,t.onEnterBack),onLeaveBack:f(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),c.start(),e.own(c)}function dh(e,t){const n=s=>s==="labels"?r=>ph(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?ne(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??V(i.easing):void 0}}function ph(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function mh(e,t,n,i){const s=()=>t.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=e.elementFor(r);return!!o&&o!==n&&o.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=t.scrollTrigger;return r||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>t.progress(),shiftAt:r=>{const o=t.timeline.getStateAtTime(r*t.timeline.duration);let a=0;for(const l of s()){const h=o.values.get(l)?.get("x");typeof h=="number"&&(a+=h)}return a}}}class vr{conditions={};scope;host;items=[];snapshots=new Map;constructor(t,n){this.host=t,this.scope=n}add(t){const n=this.host.collector;this.host.setCollector(this);try{const i=t();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(t){this.items.push(t)}touch(t,n){this.snapshots.has(t)||this.snapshots.set(t,{name:n,style:t.getAttribute("style"),d:t.getAttribute("d")})}revert(){for(const t of this.items.splice(0).reverse())t.revert?t.revert():t.kill?t.kill():t.destroy?.();for(const[t,{name:n,style:i,d:s}]of this.snapshots)i===null?t.removeAttribute("style"):t.setAttribute("style",i),s!==null&&t.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class gh{host;scope;entries=[];listeners=[];scheduled=!1;constructor(t,n){this.host=t,this.scope=n}add(t,n){const i={conditions:t,setup:n,queries:new Map},s=typeof t=="string"?{matches:t}:t;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(s)){const a=window.matchMedia(o);i.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(i),this.update(i),this}revert(){for(const t of this.listeners.splice(0))t();for(const t of this.entries.splice(0))t.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const t of this.entries)this.update(t)}))}update(t){const n={};for(const[o,a]of t.queries)n[o]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===t.key||(t.context?.revert(),t.context=void 0,t.key=s,!i))return;const r=new vr(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class yh{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(t,n){this.canvas=t,this.context=t.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(t){this.current=Math.max(0,Math.min(this.frames-1,t)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const t of this.images)t&&(t.src="")}resize(){const t=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*t),i=Math.round(this.canvas.clientHeight*t);n>0&&i>0&&(this.canvas.width!==n||this.canvas.height!==i)&&(this.canvas.width=n,this.canvas.height=i),this.drawn=-1,this.draw()}draw(){const t=Math.round(this.current),n=this.nearestReady(t);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,r/i.naturalHeight):Math.min(s/i.naturalWidth,r/i.naturalHeight),a=i.naturalWidth*o,l=i.naturalHeight*o;this.context.clearRect(0,0,s,r),this.context.drawImage(i,(s-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(t){for(let n=0;n<this.frames;n++){if(t-n>=0&&this.ready[t-n])return t-n;if(t+n<this.frames&&this.ready[t+n])return t+n}return-1}pump(){const t=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<t;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=t||this.load(s)}load(t){const n=new Image;n.decoding="async",this.images[t]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[t]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(t-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(t)}}const bh={opacity:0,y:-16},wh={opacity:0,y:16};async function vh(e,t,n,i){const s=t.collector?.scope??t.root,r=s.ownerDocument??s,o=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof r.startViewTransition=="function")return kh(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",h=g=>new Promise(y=>{g(y)||y()}),c=o(),f=c.length?zn(t,c):void 0,u=i.from!==void 0?kr(t,i.from,i.shared):[];if(u.length&&i.leave!==!1){const g=i.leave??bh;await h(y=>e.to(u,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const d=[],m=typeof i.to=="function"?i.to():i.to,p=m!==void 0?kr(t,m,i.shared):[];if(p.length&&i.enter!==!1){const g=i.enter??wh;d.push(h(y=>e.fromTo(p,g,{...ar(g),duration:a,ease:l,onComplete:y})))}if(f){const g=o().filter(y=>!c.includes(y));g.length&&d.push(h(y=>Gn(t,n,f,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(d)}function kr(e,t,n){const i=e.resolveTargets(t).map(s=>e.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):i}async function kh(e,t,n){const i=(a,l)=>{const h=a.dataset?.flipId;h&&a.style.setProperty("view-transition-name",l?`tf-${h.replace(/[^\w-]/g,"-")}`:"")},s=n();s.forEach(a=>i(a,!0));let r=[];await e.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await t.update(),r=n(),r.forEach(a=>i(a,!0))}).finished,r.forEach(a=>i(a,!1))}const Sr={create:(e,t)=>Dn(e,Is(t))},Tr={create:(e,t)=>Dn(e,{fn:Rs(t)})},Mr={create:(e,t)=>Dn(e,{fn:$s(t)})},Sh=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Er=.5,Th="power1.inOut";function Mh(e){return e.keyframes!==void 0&&e.keyframes!==null}function Eh(e){const t=e.keyframes,n={};for(const[h,c]of Object.entries(e))Sh.has(h)||(n[h]=c);if(Array.isArray(t))return t.map(h=>({...n,...h,duration:h.duration??e.duration??Er}));const i=Object.entries(t),s=e.duration??Er,r=t.easeEach??e.easeEach??Th;if(i.length>0&&i.every(([h])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(h)||h==="easeEach")){const h=i.filter(([u])=>u!=="easeEach").map(([u,d])=>({at:Number.parseFloat(u)/100,step:d})).sort((u,d)=>u.at-d.at),c=[];let f=0;for(const{at:u,step:d}of h){const m=Math.max(0,u-f);c.push({...n,ease:r,...d,duration:m*s}),f=u}return c}const o=i.filter(([h,c])=>h!=="easeEach"&&Array.isArray(c)),a=Math.max(0,...o.map(([,h])=>h.length)),l=[];for(let h=0;h<a;h++){const c={...n,ease:r,duration:s/a};for(const[f,u]of o)h<u.length&&(c[f]=u[h]);l.push(c)}return l}function Ar(e,t,n,i={}){const s=t.collector?.scope??t.root,r=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(v,w)=>{if(w===void 0)return o[v];if(typeof w=="number")return w;if(w==="max")return a[v];const T=typeof w=="string"?s.querySelector(w):w;if(!T)return o[v];const k=T.getBoundingClientRect(),S=r?.getBoundingClientRect(),M=(v==="x"?i.offsetX:i.offsetY)??i.offset??0;return v==="x"?k.left-(S?.left??0)+o.x-M:k.top-(S?.top??0)+o.y-M},h=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},c={x:Math.max(0,Math.min(a.x,h.x)),y:Math.max(0,Math.min(a.y,h.y))},f={...o},u=()=>{r?(r.scrollLeft=f.x,r.scrollTop=f.y):window.scrollTo({left:f.x,top:f.y,behavior:"instant"})},d=["wheel","touchstart","keydown"],m=r??window,p=()=>{y.kill(),g()},g=()=>{for(const v of d)m.removeEventListener(v,p)},y=e.to(f,{x:c.x,y:c.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{u(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const v of d)m.addEventListener(v,p,{passive:!0});return y}function Ah(e,t,n){const i=e.collector?.scope??e.root,s=typeof t=="string"?[...i.querySelectorAll(t)]:"nodeType"in t?[t]:Array.from(t),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:h,onLeaveBack:c,...f}=n,u={onEnter:a,onLeave:l,onEnterBack:h,onLeaveBack:c},d={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},p=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const v=d[y].splice(0);v.length>0&&u[y]?.(v)},g=(y,v)=>{if(u[y]){if(d[y].push(v),o!==void 0&&d[y].length>=o)return p(y);m[y]===void 0&&(m[y]=setTimeout(()=>p(y),r*1e3))}};return s.map(y=>ri(e,{...f,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class at{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(t,n={}){this.stage=t;const i={...n,onWarning:n.onWarning??t.onWarning};if(this.options=i,this.compat=new Tt({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return _h(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return Js(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=Hr(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>Cr(s.map(r=>t.elementFor(r))),random:()=>t.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},t.collector?.track(this),t.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=ri(t,s,this,this.firstElement,r=>i.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(t,n,i){return Mh(n)?this.record(()=>this.keyframed(t,n,i)):this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.to(r,s,o)))}from(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.from(r,s,o)))}fromTo(t,n,i,s){return this.record(()=>this.tween(t,[n,i],s,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.set(r,s,o)))}addLabel(t,n){return this.record(()=>this.compat.addLabel(t,n))}add(t,n){return this.record(()=>{t.autoplayPending=!1,t.timeline.stop(),t.stage.deactivate(t.timeline),this.compat.add(t.compat,n)})}invalidate(){const t=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(t),this.stage.render(this.timeline),this}call(t,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>t(...n)})})}addPause(t,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(t);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(t,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,t,n)}tweenFromTo(t,n,i={}){this.pause(),this.seek(t);const s=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:s},a=i.duration??Math.abs(r-s)/1e3/(this.timeScale()||1),l=new at(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(o,{time:r,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(o.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const t=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!t){const i=this.timeline,s=i.direction==="forward"?i.currentTime===0:i.currentTime===i.duration;this.playhead={...this.readPlayhead(),fresh:s&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const t=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),t&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const t=this.timeline.duration;return t>0?this.compat.labelTimes().map(n=>n/t):[]}reversed(){return this.timeline.direction==="reverse"}seek(t){return this.autoplayPending=!1,this.compat.seek(t),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(t){return t===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,t))*this.timeline.duration),this.compat.progress())}timeScale(t){return this.compat.timeScale(t)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(t,n){for(const i of t)for(const s of n??[void 0])this.timeline.removeTracks({target:i,...s!==void 0&&{property:s}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(t){return this.recipe.push(t),t(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const t=Math.max(...this.events.map(n=>n.time));t>this.timeline.duration&&this.timeline.setDuration(t)}readPlayhead(){const t=this.timeline;return{time:t.currentTime,iteration:t.loopIteration,direction:t.direction}}moveTo(t){const n=this.playhead;this.timeline.seek(t),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:t>=n.time?"forward":"reverse"},s={...n,iteration:i.iteration,direction:i.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(s,i,!1),this.options.onUpdate?.()}refreshForRepeat(){const t=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(t,this.timeline.duration))}afterFrame(){const t=this.timeline,n=t.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const r=this.options.yoyo===!0;n&&!r&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=t.currentTime===0&&t.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(t,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:r,passes:o}=Rn(s.map(a=>a.time),t,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=s[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([h,c])=>h!==c&&Math.max(h,c)>=a.start&&Math.min(h,c)<=a.end)&&a.run();return!1}tween(t,n,i,s){const r=this.resolve(t);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let h=1/0,c=-1/0;const f=(u,d,m)=>{s(u,d,m),h=Math.min(h,this.compat.lastStart),c=Math.max(c,this.compat.lastEnd)};if(this.buildTween(r,n,i,f),h===1/0)return;o&&this.events.push({time:h,direction:"forward",run:o}),a&&this.ranges.push({start:h,end:c,run:a}),l&&this.events.push({time:c,direction:"forward",run:l});return}this.buildTween(r,n,i,s)}keyframed(t,n,i){const s=this.resolve(t);if(!s)return;const r=Eh(n);if(r.length===0)return;const o=s.length>1?Kn(n.stagger,this.staggerContext(s)):void 0,a=s.map(g=>this.targetFor(g)).filter(g=>g!==void 0),l=o?a.map(g=>[g]):[a],h=o?we(s.length,o).map(g=>g/1e3):[0],c=this.compat.timeOf(i)/1e3+Fe(n.delay,0)/1e3;let f=1/0,u=-1/0;if(l.forEach((g,y)=>{r.forEach((v,w)=>{const T=w===0?c+h[y]:">";this.tween(g,[v],T,([k],S,M)=>this.compat.to(S,k,M)),f=Math.min(f,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),f===1/0)return;const{onStart:d,onUpdate:m,onComplete:p}=n;d&&this.events.push({time:f,direction:"forward",run:d}),m&&this.ranges.push({start:f,end:u,run:m}),p&&this.events.push({time:u,direction:"forward",run:p})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>Cr(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(u=>this.targetFor(u));if(!(t.length>1&&(n.some(Ph)||t.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(t[0]);s(n.map(d=>this.prepare(_r(d,0,u,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...h}=n[a],c=Kn(l,this.staggerContext(t)),f=c?we(t.length,c).map(u=>u/1e3):t.map(()=>0);t.forEach((u,d)=>{const m=d===0?Fe(h.delay,0)/1e3+f[0]:0,p=d===0?0:f[d]-f[d-1],g=d===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,v=n.map((w,T)=>T===a?{...h,delay:m}:w).map(w=>this.prepare(_r(w,d,this.targetFor(u),this.stage.utils,r),[u]));s(v,[u],g)})}targetFor(t){return this.stage.elementFor(t)??this.stage.objectFor(t)}prepare(t,n){const i=o=>this.options.onWarning?.(o),s=o=>this.stage.query(o);let r=t;if(t.motionPath!==void 0){const o=Nl(t.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});r={...r,motionPath:o}}if(t.morphSVG!==void 0){const o=Wl(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=Hr(this.stage.elementFor(n[0]));if(o===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=gl(r,o)}return r}resolve(t){const n=this.stage.resolveTargets(t);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${Ch(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function xr(e=new Vs){const t=r=>{const{config:o}=$e(r);return new at(e,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:h,onReverseComplete:c,repeatRefresh:f,...u}=r;return u},i=r=>(r&&e.collector?.track(r),r),s={stage:e,ticker:e.ticker,utils:e.utils,getProperty:(r,o)=>{const[a]=e.resolveTargets(r);if(a===void 0)return;const l=e.objectFor(a);return l?l[o]:e.appliedValue(a,o)??Ks(o)},scrollTrigger:r=>i(ri(e,r)),scrollBatch:(r,o)=>Ah(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Ar(s,e,r,o),refreshScroll:()=>{re.refreshAll(),ii.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new ii({...r,scroller:o}).start())},context:(r,o)=>{const a=new vr(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new gh(e,r),customEase:Sr.create,customBounce:Tr.create,customWiggle:Mr.create,pageTransition:r=>vh(s,e,o=>new at(e,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(e.collector?.scope??e.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return i(new yh(a,o))},quickTo:(r,o,a={})=>{const l=new at(e,{paused:!0}),[h]=e.resolveTargets(r);return Object.assign(f=>{if(!h)return;const u=a.spring!==void 0?e.velocityOf(h,o)??0:0;l.compat.reset(),l.compat.to(h,{[o]:f,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:xh(a.spring,o,u)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new at(e,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,h=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},c=typeof r!="string"&&r!==window&&r.nodeType===1;return Ar(s,e,a,{...l,offsetX:h.offsetX,offsetY:h.offsetY,scroller:c?r:void 0})}return t(o).to(r,n(o))},from:(r,o)=>t(o).from(r,n(o)),fromTo:(r,o,a)=>t(a).fromTo(r,o,n(a)),set:(r,o)=>t(o).set(r,n(o)),delayedCall:(r,o,a)=>new at(e).call(o,a,r),killTweensOf:(r,o)=>{const a=e.resolveTargets(r),l=typeof o=="string"?o.split(",").map(h=>h.trim()).filter(Boolean):o;for(const h of[...e.liveTimelines])h.killTweensOf(a,l)},convertToPath:r=>Yl(r,e.root),splitText:(r,o)=>{const a=e.collector?.scope??e.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return i(Jl(l,o))},draggable:(r,o)=>i(Vl(s,e,r,o)),getFlipState:r=>zn(e,r),flipFrom:(r,o)=>Gn(e,a=>new at(e,a),r,o),flip:(r,o,a)=>{const l=zn(e,r);return o(),Gn(e,h=>new at(e,h),l,{targets:r,...a})}};return s}const j=xr();function xh(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Ph(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Pr(e)}function Pr(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||Ns(n))&&!Wn.has(t))}function _r(e,t,n,i,s){if(!Pr(e))return e;const r={};for(const[o,a]of Object.entries(e))Wn.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):Ns(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function Cr(e){const t=e.map(i=>i?.getBoundingClientRect().top);if(t[0]===void 0)return e.length;let n=0;for(const i of t){if(i===void 0||Math.abs(i-t[0])>1)break;n++}return Math.max(1,n)}function Hr(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function _h(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Ch(e){return typeof e=="string"?`"${e}"`:String(e)}class oi{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Ir(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class Be{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new Mt}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=Ft({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(a=>a.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||s?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(o=>o.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=o=>o?.[s]?.[i.id]??o?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new oi(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Ir(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const o=new Mt;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Ft(r.timeline)})})}attachMedia(t,n){this.mediaSync=new oi(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=Rn(s.map(o=>o.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=s[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function Hh(e,t,n={}){const i=new Be(e,{...n,autoplay:!0});return await i.load(t),i}function Ih(e,t={}){return new Be(e,t)}const Rr={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},$r="tinyfly-controls-style",Rh=`
|
|
1
|
+
(function(b){"use strict";function is(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function Gt(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const Mn=2;function En(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Te(e){return e.property==="text"&&"textConfig"in e}function ft(e){return e.kind==="inertia"&&"inertia"in e}function dt(e){return e.kind==="spring"&&"spring"in e}function An(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Fa(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function ss(e){return"keyframes"in e}class Oa{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(t){this._currentTime+=t,this.onTick?.(t,this._currentTime)}reset(){this._currentTime=0}seek(t){this._currentTime=t}}class La{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(t={}){this._speed=t.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(t){this._speed=t}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(t){this._currentTime=t}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(t){if(this._isRunning){if(this._lastFrameTime!==null){const i=(t-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=t,this._scheduleFrame()}}}function xn(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function Pn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,xn(i,e,t));return n}function Me(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=xn(e,t,i);if(n.amount!==void 0){const r=Pn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function Ee(e,t){return Array.from({length:e},(n,i)=>Me(i,e,t))}function Jt(e,t){return e<=1?0:Math.max(...Ee(e,t))}const It=1,_n=6e4,Ae=_n/It,Q={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},xe={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class Zt{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??Q.stiffness,this.damping=t.damping??Q.damping,this.mass=t.mass??Q.mass,this.restDelta=t.restDelta??Q.restDelta,this.restSpeed=t.restSpeed??Q.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??Q.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/It);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/It-n;return i+(s-i)*r}settleTime(){return this.simulateTo(Ae+1),this.settledStep!==null?this.settledStep*It:_n}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,Ae+1),i=It/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*i;const c=s+this.velocity*i;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>Ae&&(this.settledStep=Ae)}}function Ba(e,t){return new Zt(e).valueAt(t)}function rs(e){return new Zt(e).settleTime()}function Da(e){const t=e.stiffness??Q.stiffness,n=e.damping??Q.damping,i=e.mass??Q.mass;return n<2*Math.sqrt(t*i)}function Na(e){const t=e.stiffness??Q.stiffness,n=e.mass??Q.mass;return 2*Math.sqrt(t*n)}const Cn=4,Wa=.002,Ya=1e-4,os=6e4;function Pe(e){const t=e.friction??Cn;return t>0?t:Cn}function Qt(e){return e.from+e.velocity/Pe(e)}function Ka(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Ht(e){let t=Ka(Qt(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function $t(e){const t=Math.abs(Ht(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Ya,t*Wa);if(n>=t)return 0;const i=Math.log(t/n)/Pe(e);return Math.min(os,i*1e3)}function _e(e,t){if(t<=0)return e.from;const n=Ht(e);if(t>=$t(e))return n;const i=Pe(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function qa(e,t){const n=Pe(e),i=Ht(e);return t>=$t(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Ce=e=>e,as=e=>e*e,ls=e=>1-(1-e)*(1-e),cs=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,In=e=>e*e*e,Hn=e=>1-Math.pow(1-e,3),te=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,hs=In,us=Hn,fs=te,Xa={linear:Ce,"ease-in":hs,"ease-out":us,"ease-in-out":fs,"ease-in-quad":as,"ease-out-quad":ls,"ease-in-out-quad":cs,"ease-in-cubic":In,"ease-out-cubic":Hn,"ease-in-out-cubic":te};function ds(e){const[t,n,i,s]=e,r=3*t,o=3*(i-t)-r,a=1-r-o,l=3*n,c=3*(s-n)-l,h=1-l-c,f=d=>((a*d+o)*d+r)*d,u=d=>((h*d+c)*d+l)*d,p=d=>(3*a*d+2*o)*d+r,m=d=>{let g=d;for(let w=0;w<8;w++){const T=f(g)-d;if(Math.abs(T)<1e-7)return g;const k=p(g);if(Math.abs(k)<1e-7)break;g-=T/k}let y=0,v=1;for(g=d;y<v;){const w=f(g);if(Math.abs(w-d)<1e-7)return g;d>w?y=g:v=g,g=(y+v)/2}return g};return d=>{if(d<=0)return 0;if(d>=1)return 1;const g=m(d);return u(g)}}function $n(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function ps(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const ms=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function gs(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function ys(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function bs(e){switch(e.type){case"steps":return ys(e.count,e.position);case"elastic":return $n(ps(e.amplitude,e.period),e.mode);case"bounce":return $n(ms,e.mode);case"back":return $n(gs(e.overshoot),e.mode)}}function V(e){return e===void 0?Ce:is(e)?ds(e.points):Gt(e)?bs(e):Xa[e]??Ce}const ws=32,Va=256,Rt=new Map,Ua=/[MmLlHhVvCcSsQqTtAaZz]/,za=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,ja={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Ga(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(Ua.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const o=i.type==="A"||i.type==="a",a=i.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const l=za.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function Ja(e,t,n,i,s,r,o,a,l){if(e===a&&t===l)return[];let c=Math.abs(n),h=Math.abs(i);if(c===0||h===0)return[[e,t,a,l,a,l]];const f=s*Math.PI/180,u=Math.cos(f),p=Math.sin(f),m=(e-a)/2,d=(t-l)/2,g=u*m+p*d,y=-p*m+u*d,v=g*g/(c*c)+y*y/(h*h);if(v>1){const R=Math.sqrt(v);c*=R,h*=R}const w=r===o?-1:1,T=c*c*h*h-c*c*y*y-h*h*g*g,k=c*c*y*y+h*h*g*g,S=w*Math.sqrt(Math.max(0,T/k)),E=S*c*y/h,_=-S*h*g/c,M=u*E-p*_+(e+a)/2,x=p*E+u*_+(t+l)/2,A=(R,B,D,Z)=>{const St=R*D+B*Z,Tn=Math.sqrt((R*R+B*B)*(D*D+Z*Z)),Se=Math.acos(Math.max(-1,Math.min(1,St/Tn)));return R*Z-B*D<0?-Se:Se},P=A(1,0,(g-E)/c,(y-_)/h);let C=A((g-E)/c,(y-_)/h,(-g-E)/c,(-y-_)/h);!o&&C>0&&(C-=2*Math.PI),o&&C<0&&(C+=2*Math.PI);const I=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),H=C/I,$=4/3*Math.tan(H/4),F=R=>{const B=c*Math.cos(R),D=h*Math.sin(R);return[u*B-p*D+M,p*B+u*D+x]},L=R=>{const B=-c*Math.sin(R),D=h*Math.cos(R);return[u*B-p*D,p*B+u*D]},O=[];for(let R=0;R<I;R++){const B=P+R*H,D=B+H,[Z,St]=F(B),[Tn,Se]=R===I-1?[a,l]:F(D),[jd,Gd]=L(B),[Jd,Zd]=L(D);O.push([Z+$*jd,St+$*Gd,Tn-$*Jd,Se-$*Zd,Tn,Se])}return O}function pt(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function vs(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function ee(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function Ie(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,f=t,u=0;for(let p=1;p<=ws;p++){const m=p/ws,d=pt(e,i,r,a,m),g=pt(t,s,o,l,m);u+=Math.hypot(d-h,g-f),c.push(u),h=d,f=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:u,lengths:c}}function Tt(e){const t=Rt.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,o=0,a=null,l=null,c=-1;const h=new Set,f=d=>{c<0&&(c=0),d.subpath=c,n.push(d)};for(const{type:d,args:g}of Ga(e)){const y=d.toUpperCase(),v=d!==y,w=ja[y];if(y==="Z"){(i!==r||s!==o)&&f(ee(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let T=0;T+w<=g.length;T+=w){const k=g.slice(T,T+w),S=v?i:0,E=v?s:0;let _=null,M=null;switch(y){case"M":T===0?(i=k[0]+S,s=k[1]+E,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(f(ee(i,s,k[0]+S,k[1]+E)),i=k[0]+S,s=k[1]+E);break;case"L":f(ee(i,s,k[0]+S,k[1]+E)),i=k[0]+S,s=k[1]+E;break;case"H":f(ee(i,s,k[0]+S,s)),i=k[0]+S;break;case"V":f(ee(i,s,i,k[0]+E)),s=k[0]+E;break;case"C":{const x=[k[0]+S,k[1]+E,k[2]+S,k[3]+E,k[4]+S,k[5]+E];f(Ie(i,s,x)),_=[x[2],x[3]],i=x[4],s=x[5];break}case"S":{const[x,A]=a?[2*i-a[0],2*s-a[1]]:[i,s],P=[x,A,k[0]+S,k[1]+E,k[2]+S,k[3]+E];f(Ie(i,s,P)),_=[P[2],P[3]],i=P[4],s=P[5];break}case"Q":case"T":{let x=i,A=s;y==="Q"?(x=k[0]+S,A=k[1]+E):l&&(x=2*i-l[0],A=2*s-l[1]);const P=y==="Q"?k[2]+S:k[0]+S,C=y==="Q"?k[3]+E:k[1]+E;f(Ie(i,s,[i+2/3*(x-i),s+2/3*(A-s),P+2/3*(x-P),C+2/3*(A-C),P,C])),M=[x,A],i=P,s=C;break}case"A":{const x=k[5]+S,A=k[6]+E;let P=i,C=s;for(const I of Ja(i,s,k[0],k[1],k[2],k[3],k[4],x,A))f(Ie(P,C,I)),P=I[4],C=I[5];i=x,s=A;break}}a=_,l=M}}const u=n.reduce((d,g)=>d+g.length,0),p=[];for(let d=0;d<n.length;){const g=n[d].subpath;let y=d,v=0;for(;y<n.length&&n[y].subpath===g;)v+=n[y++].length;const w=n[d],T=n[y-1],k=h.has(g)||Math.abs(T.endX-w.startX)<1e-9&&Math.abs(T.endY-w.startY)<1e-9;p.push({start:d,end:y,length:v,closed:k}),d=y}const m={segments:n,totalLength:u,subpaths:p};return Rt.size>=Va&&Rt.delete(Rt.keys().next().value),Rt.set(e,m),m}function Za(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<t?i=a:s=a}const r=n[s]-n[i],o=r>0?(t-n[i])/r:0;return(i+o)/(n.length-1)}function Qa(e,t){if(e.type==="L"){const f=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*f,y:e.startY+(e.endY-e.startY)*f,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=Za(e,t);let c=vs(e.startX,n,s,o,l),h=vs(e.startY,i,r,a,l);if(Math.hypot(c,h)<1e-9){const f=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=pt(e.startX,n,s,o,f),p=pt(e.startY,i,r,a,f),m=pt(e.startX,n,s,o,l),d=pt(e.startY,i,r,a,l);c=l<.5?u-m:m-u,h=l<.5?p-d:d-p}return{x:pt(e.startX,n,s,o,l),y:pt(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function Rn(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const o=e[r];if(s+o.length>=t||r===i-1)return Qa(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function ks(e,t){const{segments:n,totalLength:i}=Tt(e);return Rn(n,Math.max(0,Math.min(1,t))*i)}function tl(){Rt.clear()}function el(e){return Tt(e).totalLength}const nl=24,il=320,sl=2.5,ne=72,rl=64,ol=.2,al=128,ie=new Map;let He=0,mt;const Ss=e=>Math.round(e*100)/100;function Ts(e,t){const{segments:n,subpaths:i,totalLength:s}=Tt(e);if(n.length===0)return[];if(t){const r=i.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function Fn(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=Rn(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Ms(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function Es(e,t){const n=[];for(let i=0;i<t;i++)n.push(Fn(e,e.closed?i/t:i/(t-1)));return n}function As(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function ll(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%ne/ne:0,reversed:n<0};const s=As(Es(e,ne)),r=As(Es(t,ne)),o=ne;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let f=0;f<h;f++){let u=0;for(let p=0;p<o&&u<l;p++){const m=i?c?(f-p+o)%o:(p+f)%o:c?o-1-p:p,d=s[p][0]-r[m][0],g=s[p][1]-r[m][1];u+=d*d+g*g}u<l&&(l=u,a={offset:i?f/o:0,reversed:c})}}return a}function cl(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function hl(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function ul(e,t,n){const i=e.closed&&t.closed,s=ll(e,t,n.shapeIndex),r=Math.max(nl,Math.min(il,Math.ceil(Math.max(e.length,t.length)/sl))),o=new Set,a=f=>o.add(Math.round(f*1e7)/1e7);for(let f=0;f<=r;f++)a(f/r);for(const f of Ms(e))a(f);for(const f of Ms(t))a(hl(f,s,i));let l=[...o].sort((f,u)=>f-u);i&&(l=l.filter(f=>f<1));const c=[],h=[];for(const f of l)c.push(...Fn(e,f)),h.push(...Fn(t,cl(f,s,i)));return fl({from:c,to:h,closed:i})}function fl(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[o,a]=i.pop();let l=-1,c=ol;for(let h=o+1;h<a;h++){const f=Math.max(xs(e.from,o,a,h),xs(e.to,o,a,h));f>c&&(c=f,l=h)}l!==-1&&(n[l]=1,i.push([o,l],[l,a]))}const s=[],r=[];for(let o=0;o<t;o++)n[o]&&(s.push(e.from[o*2],e.from[o*2+1]),r.push(e.to[o*2],e.to[o*2+1]));return{from:s,to:r,closed:e.closed}}function xs(e,t,n,i){const s=e[t*2],r=e[t*2+1],o=e[n*2]-s,a=e[n*2+1]-r,l=e[i*2]-s,c=e[i*2+1]-r,h=o*o+a*a,f=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-f*o,c-f*a)}function dl(e,t,n){const i=n.shapeIndex;if(mt&&mt.from===e&&mt.to===t&&mt.shapeIndex===i)return mt.plan;const r=ie.get(String(i??"auto"))?.get(e)?.get(t);if(r)return mt={from:e,to:t,shapeIndex:i,plan:r},r;const o=Tt(e).subpaths.filter(p=>p.length>0).length===Tt(t).subpaths.filter(p=>p.length>0).length,a=Ts(e,!o),l=Ts(t,!o),c={pairs:a.map((p,m)=>ul(p,l[m],n))};He>=al&&(ie.clear(),He=0);const h=String(i??"auto"),f=ie.get(h)??new Map;ie.set(h,f);const u=f.get(e)??new Map;return f.set(e,u),u.set(t,c),He++,mt={from:e,to:t,shapeIndex:i,plan:c},c}function Ps(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=dl(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const c=Ss(a.from[l]+(a.to[l]-a.from[l])*s),h=Ss(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);o+=`${l===0?o?" M":"M":" L"}${c} ${h}`}a.closed&&(o+=" Z")}return o}function pl(){ie.clear(),He=0,mt=void 0}function Ft(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const Ot=Math.PI/180,ml=.9995;function On(){return[0,0,0,1]}function Lt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return On();const i=t*Ot/2,s=Math.sin(i)/n;return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]}function gl(e,t,n){return Ln(Ln(Lt([0,1,0],t),Lt([1,0,0],e)),Lt([0,0,1],n))}function yl(e){const[t,n,i,s]=gt(e),r=2*(t*i+n*s),o=2*(t*n+i*s),a=1-2*(t*t+i*i),l=2*(n*i-t*s),c=1-2*(n*n+i*i),h=2*(t*i-n*s),f=1-2*(t*t+n*n),u=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[u/Ot,Math.atan2(r,f)/Ot,Math.atan2(o,a)/Ot]:[u/Ot,Math.atan2(-h,c)/Ot,0]}function Ln(e,t){const[n,i,s,r]=e,[o,a,l,c]=t;return[r*o+n*c+i*l-s*a,r*a-n*l+i*c+s*o,r*l+n*a-i*o+s*c,r*c-n*o-i*a-s*l]}function _s(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Cs(e){return Math.hypot(e[0],e[1],e[2],e[3])}function gt(e){const t=Cs(e);return t===0?On():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function bl(e){return[-e[0],-e[1],-e[2],e[3]]}function Is(e,t,n){const i=gt(e);let s=gt(t),r=_s(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>ml)return gt([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const o=Math.acos(r),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a;return gt([i[0]*l+s[0]*c,i[1]*l+s[1]*c,i[2]*l+s[2]*c,i[3]*l+s[3]*c])}function wl(e,t){const[n,i,s,r]=gt(e),o=2*(i*t[2]-s*t[1]),a=2*(s*t[0]-n*t[2]),l=2*(n*t[1]-i*t[0]);return[t[0]+r*o+(i*l-s*a),t[1]+r*a+(s*o-n*l),t[2]+r*l+(n*a-i*o)]}const vl=Object.freeze(Object.defineProperty({__proto__:null,conjugate:bl,dot:_s,fromAxisAngle:Lt,fromEuler:gl,identity:On,length:Cs,multiply:Ln,normalize:gt,rotateVec3:wl,slerp:Is,toEuler:yl},Symbol.toStringTag,{value:"Module"})),rt=(e,t,n)=>e+(t-e)*n,Hs=512,Bn=new Map,Dn=new Map;function $s(e){const t=Bn.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return Bn.size<Hs&&Bn.set(e,i),i}const Rs=e=>e.charCodeAt(0)===35,Fs=e=>e.startsWith("rgb"),Os=e=>e.startsWith("rgba"),kl=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Nn=e=>Math.round(e).toString(16).padStart(2,"0");function Sl(e,t,n){return`#${Nn(e)}${Nn(t)}${Nn(n)}`}function Ls(e){const t=Dn.get(e);if(t)return t;const n=e.match(kl);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return Dn.size<Hs&&Dn.set(e,o),o}const Bs=(e,t,n)=>{if(Rs(e)&&Rs(t)){const[i,s,r]=$s(e),[o,a,l]=$s(t),c=rt(i,o,n),h=rt(s,a,n),f=rt(r,l,n);return Sl(c,h,f)}if((Fs(e)||Os(e))&&(Fs(t)||Os(t))){const i=Ls(e),s=Ls(t),r=Math.round(rt(i[0],s[0],n)),o=Math.round(rt(i[1],s[1],n)),a=Math.round(rt(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=rt(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},Ds=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(rt(e[r],t[r],n));return s},Ns=(e,t,n)=>Is(e,t,n),Wn=(e,t,n)=>n<1?e:t,Ws=(e,t,n)=>Ps(e,t,n);function se(e,t){return t==="slerp"?Ns:typeof e=="number"?rt:Array.isArray(e)?Ds:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?Bs:Ft(e)?Ws:Wn:Wn}const Yn=1e3/60;function Kn(e,t={}){if(!dt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new Zt(e.spring);return Ys(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function qn(e,t={}){if(!ft(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return Ys(e,i=>_e(n,i),$t(n),n.from,Ht(n),t)}function Ys(e,t,n,i,s,r){const o=r.intervalMs??Yn,a=r.tolerance??.01,l=e.delay??0,c=[];for(let f=0;f<=n;f+=o)c.push({time:f+l,value:t(f),easing:"linear"});const h=c[c.length-1];return!h||h.time<n+l?c.push({time:n+l,value:s,easing:"linear"}):h.value=s,l>0&&c.unshift({time:0,value:i,easing:"linear"}),{id:e.id,target:e.target,property:e.property,keyframes:a>0?qs(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function Xn(e,t,n,i={}){const s=i.intervalMs??Yn,r=typeof n=="function"?n:V(n),o=se(e.value,i.interpolation),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let h=s;h<a;h+=s){const f=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(f)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function Tl(e,t){return dt(e)?Kn(e,t):ft(e)?qn(e,t):e}function Ks(e,t={}){const n=e.keyframes;if(!n.some(r=>Gt(r.easing)))return e;const i=n.length>0?[n[0]]:[],s={...t,interpolation:e.interpolation??t.interpolation};for(let r=1;r<n.length;r++){const o=n[r];Gt(o.easing)?i.push(...Xn(n[r-1],o,o.easing,s)):i.push(o)}return{...e,keyframes:i}}function Ml(e,t){return e.filter(ss).map(n=>Ks(n,t)).concat(e.filter(dt).map(n=>Kn(n,t)),e.filter(ft).map(n=>qn(n,t)))}function qs(e,t){if(e.length<=2)return e;const n=[e[0]];for(let i=1;i<e.length-1;i++){const s=n[n.length-1],r=e[i],o=e[i+1],a=o.time-s.time;if(a<=0)continue;const l=(r.time-s.time)/a,c=s.value+(o.value-s.value)*l;Math.abs(r.value-c)>t&&n.push(r)}return n.push(e[e.length-1]),n}function $e(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function yt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function Bt(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Me(e,t,i)}class Re{track;targets;constructor(t){this.track=t,this.targets=yt(t)}getValueAtTime(t){return this.valueForOffset(t-Bt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Bt(s,n,this.track.delay,this.track.stagger),o=this.valueForOffset(t-r);o!==void 0&&i.push({target:this.targets[s],value:o,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?Jt(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,o=(t-i.time)/r,l=V(s.easing)(o);return se(i.value,this.track.interpolation)(i.value,s.value,l)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class Xs{track;targets;sampler;constructor(t){this.track=t,this.targets=yt(t),this.sampler=new Zt(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-Bt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Bt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?Jt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Vs{track;targets;duration;constructor(t){this.track=t,this.targets=yt(t),this.duration=$t(t.inertia)}getValueAtTime(t){return _e(this.track.inertia,t-Bt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Bt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:_e(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?Jt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Vn(e,t){const n={...ks(e.pathData,t)};if(e.matrix){const[i,s,r,o,a,l]=e.matrix,{x:c,y:h}=n;n.x=i*c+r*h+a,n.y=s*c+o*h+l;const f=n.angle*Math.PI/180,u=Math.cos(f),p=Math.sin(f);n.angle=Math.atan2(s*u+o*p,i*u+r*p)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function El(e,t,n,i){const s=t+(n-t)*i;return Vn(e,s)}const Un={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Al=20;function Us(e){const t=Un[e??"upperCase"]??e??Un.upperCase,n=Array.from(t);return n.length>0?n:Array.from(Un.upperCase)}function xl(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function zs(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const o=Array.from(i),a=Array.from(s),l=e.rightToLeft??!1;if(e.mode==="type"){const v=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-v)).join("")+a.slice(Math.max(0,a.length-v)).join(""):a.slice(0,v).join("")+o.slice(v).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),f=Math.floor(h*a.length),u=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),p=Us(e.chars),m=e.refreshRate??Al,d=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let v=0;v<u;v++){const w=l?v>=u-f:v<f,T=l?a[a.length-(u-v)]:a[v];w&&T!==void 0||T===" "||T===`
|
|
2
|
+
`?y+=T:y+=p[xl(g,v,d)%p.length]}return y}class zn{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=a,s-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&s>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(s>=l){if(s-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const l=this._currentTime;if(s>=l){if(s-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(t){const n=new Map;if(this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:o,value:a,start:l}of s.getTargetValues(t))this._write(n,i,o,r,a,t-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(t)){const h=`${a}\0${o}`,f=c<=t,u=i.get(h);(!u||(f!==u.started?f:f?c>=u.start:c<=u.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:f})}}for(const{trackId:s,target:r,property:o,value:a,start:l}of i.values())this._write(n,s,r,o,a,t-l)}_write(t,n,i,s,r,o){if(r===void 0)return;let a=t.get(i);a||(a=new Map,t.set(i,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",zs(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=Vn(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of yt(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,ft(t)){this._trackPlayers.set(t.id,new Vs(t));return}if(dt(t)){this._trackPlayers.set(t.id,new Xs(t)),this._springTracks.set(t.id,t);return}if(Te(t))this._trackPlayers.set(t.id,new Re(t)),this._textTracks.set(t.id,t);else if(An(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new Re(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Re(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(dt(i)||ft(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==i.property)continue;const a=yt(o).filter(f=>yt(i).includes(f));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const h=s.from>=l.from;for(const f of a)t.push({target:f,property:i.property,losingTrackId:h?o.id:i.id,winningTrackId:h?i.id:o.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!yt(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:En(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Pl=100;function jn(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(p,m,d,g)=>{r.push([p,m]);const y=[];e.forEach((v,w)=>{(d==="forward"?(g?v>=p:v>p)&&v<=m:(g?v<=p:v<p)&&v>=m)&&y.push(w)}),y.sort((v,w)=>(d==="forward"?e[v]-e[w]:e[w]-e[v])||v-w);for(const v of y)s.push({kind:"event",index:v,direction:d})};let c=t.time,h=t.direction,f=t.fresh===!0;const u=Math.min(Pl,Math.max(0,n.iteration-t.iteration));for(let p=0;p<u;p++){const m=h==="forward"?o:0;l(c,m,h,f),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=m,f=!1):(c=h==="forward"?0:o,f=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,f),{crossings:s,passes:r})}function js(e){return ft(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Gs(e.inertia),...ot(e)}:dt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...ot(e)}:Te(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(Gn),...ot(e)}:An(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(Gn),...ot(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(Gn),...e.interpolation!==void 0&&{interpolation:e.interpolation},...ot(e)}}function Gs(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function Gn(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function ot(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function Js(e){if(ft(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Gs(t.inertia),...ot(t)}}if(dt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...ot(t)}}if(Te(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...ot(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...ot(t)}}return $e({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...ot(e)})}function Zs(e){const t=e._config.markers;return{formatVersion:En(e.tracks),id:e.id,name:e.name,config:{duration:e.duration>0?e.duration:void 0,loop:e._config.loop,speed:e._config.speed,alternate:e._config.alternate,repeatDelay:e._config.repeatDelay,...t&&{markers:t.map(n=>({...n}))}},tracks:e.tracks.map(js),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function Dt(e){const t=e.formatVersion??1;if(t>Mn)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Mn}. Update tinyfly to play it.`);return new zn({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Js),captions:e.captions})}function _l(e){return JSON.stringify(Zs(e))}function Cl(e){const t=JSON.parse(e);return Dt(t)}function Jn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Fe(e){let t=e>>>0||2654435769;return{seed:e>>>0,next(){return t^=t<<13,t>>>=0,t^=t>>17,t^=t<<5,t>>>=0,t/4294967296}}}function Zn(e,t,n){return t+e.next()*(n-t)}function Qs(e,t,n,i){if(i<=0)return Zn(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Il(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const tr=/^([+\-*/])=\s*(-?[\d.]+)$/,er=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Hl(e){return typeof e!="string"?!1:tr.test(e.trim())||er.test(e.trim())}function Qn(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=tr.exec(n);if(i){const[,r,o]=i,a=t.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=er.exec(n);if(s){if(!t.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(s[1]),o=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?Qs(t.random,r,o,a):Zn(t.random,r,o)}return e}function nr(e,t=0,n){const i=[];let s=t;for(const r of e){const o=Qn(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class $l{random;constructor(t){this.random=Fe(t)}get seed(){return this.random.seed}resolve(t,n=0){return Qn(t,{base:n,random:this.random})}resolveSequence(t,n=0){return nr(t,n,this.random)}}const Rl=600;function ir(e){if(Array.isArray(e)){const[u,p,m,d]=e;return{fn:or(u,p,m,d),bezier:[u,p,m,d]}}const{segments:t}=Tt(e);if(t.length===0)throw new Error(`customEase: no curve in "${e}"`);const n=t[0].startX,i=t[0].startY,s=t[t.length-1],r=s.endX-n,o=s.endY-i;if(r===0||o===0)throw new Error(`customEase: "${e}" must move along both axes`);const a=u=>(u-n)/r,l=u=>(u-i)/o;if(t.length===1&&s.type==="C"){const[u,p,m,d]=s.points,g=[a(u),l(p),a(m),l(d)];return{fn:or(...g),bezier:g}}const c=[],h=[],f=Math.max(8,Math.ceil(Rl/t.length));for(const u of t)for(let p=c.length===0?0:1;p<=f;p++){const[m,d]=Fl(u,p/f);c.push(a(m)),h.push(l(d))}return{fn:Ol(c,h)}}function sr(e={}){const n=.1+Math.max(0,Math.min(1,e.strength??.7))*.7,i=[1];for(let r=n;r>.002;r*=n)i.push(2*Math.sqrt(r));const s=i.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*s;for(let a=0;a<i.length;a++){if(o<=i[a]){if(a===0)return(o/i[0])**2;const l=i[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=i[a]}return 1}}function rr(e={}){const t=Math.max(1,e.wiggles??10),n=e.type??"easeOut",i=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*t*Math.PI*2)*i(s)}function Fl(e,t){if(e.type==="L"){const[c,h]=e.points;return[e.startX+(c-e.startX)*t,e.startY+(h-e.startY)*t]}const[n,i,s,r,o,a]=e.points,l=1-t;return[l*l*l*e.startX+3*l*l*t*n+3*l*t*t*s+t*t*t*o,l*l*l*e.startY+3*l*l*t*i+3*l*t*t*r+t*t*t*a]}function Ol(e,t){return n=>{if(n<=e[0])return t[0];if(n>=e[e.length-1])return t[t.length-1];let i=0,s=e.length-1;for(;s-i>1;){const o=i+s>>1;e[o]<=n?i=o:s=o}const r=e[s]-e[i];return r===0?t[s]:t[i]+(n-e[i])/r*(t[s]-t[i])}}function or(e,t,n,i){const s=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const f=s(a,e,n)-o,u=r(a,e,n);if(Math.abs(f)<1e-6)return s(a,t,i);if(Math.abs(u)<1e-6)break;a-=f/u}let l=0,c=1;a=o;for(let h=0;h<40;h++)s(a,e,n)<o?l=a:c=a,a=(l+c)/2;return s(a,t,i)}}const Ll=350,Bl=300,Dl=550;function Nl(e,t={}){const n=t.lead??Ll,i=t.gap??Bl,s=t.tail??Dl,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((u,p)=>{if(!(u.duration>=0))throw new Error(`narration: scene ${l} line ${p} has an invalid duration (${u.duration})`);p>0&&(h+=i),c.push({id:u.id??`s${l}-l${p}`,scene:l,line:p,start:h,end:h+u.duration,text:u.text}),h+=u.duration});const f=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:f-o,cues:c}),o=f}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function Wl(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Yl(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const ti=e=>6e4/e.bpm;function Oe(e,t){return e.offset+t*ti(e)}function Le(e,t){return(t-e.offset)/ti(e)}function Kl(e,t){return Oe(e,Math.round(Le(e,t)))}function ql(e,t){return Oe(e,Math.ceil(Le(e,t)-1e-9))}function Xl(e,t,n){const i=Math.max(1,Math.round(e.beatsPerBar??4)),s=[];if(!(e.bpm>0)||n<t)return s;for(let r=Math.ceil(Le(e,t)-1e-9);;r++){const o=Oe(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const Nt=100;function Vl(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/Nt)),o=Math.min(e.length,Math.round((n.maxSeconds??60)*t)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let M=0;M<a;M++){let x=0;for(let A=M*r;A<(M+1)*r;A++)x+=e[A]*e[A];l[M]=Math.log(1e-6+x/r)}const c=new Float64Array(a);for(let M=1;M<a;M++)c[M]=Math.max(0,l[M]-l[M-1]);const h=c.reduce((M,x)=>M+x,0)/a;for(let M=0;M<a;M++)c[M]=Math.max(0,c[M]-h);const f=Math.max(1,Math.floor(60*Nt/s)),u=Math.min(a-1,Math.ceil(60*Nt/i)),p=M=>{let x=0;for(let A=M;A<a;A++)x+=c[A]*c[A-M];return x/(a-M)};let m=0;for(let M=0;M<a;M++)m+=c[M]*c[M];m/=a;let d=f,g=-1/0;for(let M=f;M<=u;M++){const x=60*Nt/M,A=Math.exp(-.5*(Math.log2(x/120)/.9)**2),P=p(M)*A;P>g&&(g=P,d=M)}const y=M=>{const x=Math.floor(M);return x<0||x+1>=a?0:c[x]+(c[x+1]-c[x])*(M-x)},v=(M,x)=>{let A=0;for(let P=x;P<a;P+=M)A+=y(P);return A};let w=d,T=0,k=-1/0;for(let M=d-.6;M<=d+.6+1e-9;M+=.02){if(M<1)continue;const x=Math.max(1,Math.round(M*4));for(let A=0;A<x;A++){const P=A/x*M,C=v(M,P);C>k&&(k=C,T=P,w=M)}}const S=60*Nt/w,E=m>0?Math.max(0,Math.min(1,p(d)/m)):0,_=(T+.5)*1e3/Nt;return{bpm:Math.round(S*100)/100,offset:Math.round(_%(6e4/S)),confidence:E}}const at=e=>Math.round(e*1e3)/1e3;function ar(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${at(e[0].x)} ${at(e[0].y)}`;if(s===1)return r;const o=l=>i?e[(l%s+s)%s]:e[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),f=o(l+1),u=o(l+2);if(n===0){r+=` L${at(f.x)} ${at(f.y)}`;continue}const p=n/6,m=h.x+(f.x-c.x)*p,d=h.y+(f.y-c.y)*p,g=f.x-(u.x-h.x)*p,y=f.y-(u.y-h.y)*p;r+=` C${at(m)} ${at(d)} ${at(g)} ${at(y)} ${at(f.x)} ${at(f.y)}`}return i?`${r} Z`:r}const Y=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function Ul(e){const t=(e??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<t.length;i+=2)n.push({x:t[i],y:t[i+1]});return n}function Be(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=Y(t.cx),i=Y(t.cy),s=e.tag.toLowerCase()==="circle"?Y(t.r):Y(t.rx),r=e.tag.toLowerCase()==="circle"?Y(t.r):Y(t.ry);return`M${n+s} ${i} A${s} ${r} 0 1 1 ${n-s} ${i} A${s} ${r} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=Y(t.x),i=Y(t.y),s=Y(t.width),r=Y(t.height);let o=t.rx!=null?Y(t.rx):t.ry!=null?Y(t.ry):0,a=t.ry!=null?Y(t.ry):o;return o=Math.min(o,s/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${i} H${n+s} V${i+r} H${n} Z`:`M${n+o} ${i} H${n+s-o} A${o} ${a} 0 0 1 ${n+s} ${i+a} V${i+r-a} A${o} ${a} 0 0 1 ${n+s-o} ${i+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${i+r-a} V${i+a} A${o} ${a} 0 0 1 ${n+o} ${i} Z`}case"line":return`M${Y(t.x1)} ${Y(t.y1)} L${Y(t.x2)} ${Y(t.y2)}`;case"polyline":case"polygon":{const n=Ul(t.points);if(n.length===0)return null;const i=n.map((s,r)=>`${r===0?"M":"L"}${s.x} ${s.y}`).join(" ");return e.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}function De(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function Ne(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function re(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function oe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function We(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ei(e){return Math.hypot(e[0],e[1],e[2])}function lr(e,t){return ei(Ne(e,t))}function ae(e){const t=ei(e);return t===0?[0,0,0]:re(e,1/t)}function cr(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}const zl=Object.freeze(Object.defineProperty({__proto__:null,add:De,cross:We,distance:lr,dot:oe,length:ei,lerp:cr,normalize:ae,scale:re,subtract:Ne},Symbol.toStringTag,{value:"Module"})),jl=Math.PI/180;function hr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Mt(e,t){const n=new Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let r=0;for(let o=0;o<4;o++)r+=e[o*4+s]*t[i*4+o];n[i*4+s]=r}return n}function ur(e){return[1,0,0,0,0,1,0,0,0,0,1,0,e[0],e[1],e[2],1]}function Ye(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function le(e){const[t,n,i,s]=e;return[1-2*(n*n+i*i),2*(t*n+i*s),2*(t*i-n*s),0,2*(t*n-i*s),1-2*(t*t+i*i),2*(n*i+t*s),0,2*(t*i+n*s),2*(n*i-t*s),1-2*(t*t+n*n),0,0,0,0,1]}function fr(e,t,n){const i=le(t);for(let s=0;s<3;s++)i[s]*=n[0],i[4+s]*=n[1],i[8+s]*=n[2];return i[12]=e[0],i[13]=e[1],i[14]=e[2],i}function Gl(e){const t=new Array(16);for(let n=0;n<4;n++)for(let i=0;i<4;i++)t[i*4+n]=e[n*4+i];return t}function Jl(e){const[t,n,i,s,r,o,a,l,c,h,f,u,p,m,d,g]=e,y=t*o-n*r,v=t*a-i*r,w=t*l-s*r,T=n*a-i*o,k=n*l-s*o,S=i*l-s*a,E=c*m-h*p,_=c*d-f*p,M=c*g-u*p,x=h*d-f*m,A=h*g-u*m,P=f*g-u*d,C=y*P-v*A+w*x+T*M-k*_+S*E;if(Math.abs(C)<1e-12)return null;const I=1/C;return[(o*P-a*A+l*x)*I,(i*A-n*P-s*x)*I,(m*S-d*k+g*T)*I,(f*k-h*S-u*T)*I,(a*M-r*P-l*_)*I,(t*P-i*M+s*_)*I,(d*w-p*S-g*v)*I,(c*S-f*w+u*v)*I,(r*A-o*M+l*E)*I,(n*M-t*A-s*E)*I,(p*k-m*w+g*y)*I,(h*w-c*k-u*y)*I,(o*_-r*x-a*E)*I,(t*x-n*_+i*E)*I,(m*v-p*T-d*y)*I,(c*T-h*v+f*y)*I]}function Zl(e,t,n,i){const s=1/Math.tan(e*jl/2),r=1/(n-i);return[s/t,0,0,0,0,s,0,0,0,0,(i+n)*r,-1,0,0,2*i*n*r,0]}function Ql(e,t,n,i,s,r){const o=1/(t-e),a=1/(i-n),l=1/(r-s);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(t+e)*o,-(i+n)*a,-(r+s)*l,1]}function tc(e,t,n=[0,1,0]){const i=ae(Ne(e,t)),s=ae(We(n,i)),r=We(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-oe(s,e),-oe(r,e),-oe(i,e),1]}function dr(e,t){const n=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12],i=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13],s=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14],r=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15];return r===1||r===0?[n,i,s]:[n/r,i/r,s/r]}const ec=Object.freeze(Object.defineProperty({__proto__:null,compose:fr,fromQuat:le,identity:hr,invert:Jl,lookAt:tc,multiply:Mt,orthographic:Ql,perspective:Zl,scaling:Ye,transformPoint:dr,translation:ur,transpose:Gl},Symbol.toStringTag,{value:"Module"})),Ke={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},pr={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function nc(e){let t=e.trim().toLowerCase();t=t.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(t);return n&&n[1]!=="steps"&&t!=="none"&&t!=="linear"&&(t=`${n[1]}.out${n[2]??""}`),t}V({type:"bounce",mode:"in"}),V({type:"bounce",mode:"in-out"});function ce(e){const t=mr.get(e.trim().toLowerCase());if(t)return t;const n=nc(e),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const o={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:o,fn:V(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(f=>Number.parseFloat(f)).filter(f=>Number.isFinite(f)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in Ke)return{easing:{type:"cubic-bezier",points:Ke[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:V(h)}}return n in pr?{easing:pr[n]}:n in Ke?{easing:{type:"cubic-bezier",points:Ke[n]}}:{easing:"ease-out"}}const mr=new Map;function ni(e,t){return mr.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function ii(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const gr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function yr(e){return typeof e=="string"&&gr.test(e)}function ic(e=1){let t=ii(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):f=>c(...h,f)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,f,u)=>c===l?h:h+(u-l)/(c-l)*(f-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return br(l,c,1/0);if("values"in l)return br(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const f=l+t()*(c-l);return h?Math.round(f/h)*h:f};return{clamp:n(3,i),mapRange:n(5,s),normalize:n(3,(l,c,h)=>s(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const f={};for(const u of Object.keys(l))f[u]=se(l[u])(l[u],c[u],h);return f}return se(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const d=l,g=y=>d[(Math.round(y)%d.length+d.length)%d.length];return c===void 0?g:g(c)}const f=l,p=c-f,m=d=>p===0?f:((d-f)%p+p)%p+f;return h===void 0?m:m(h)}),wrapYoyo:n(3,(l,c,h)=>{const f=c-l;if(f===0)return l;const u=((h-l)%(f*2)+f*2)%(f*2);return l+(u>f?f*2-u:u)}),snap:n(2,r),random:((l,c,h,f)=>{if(Array.isArray(l)){const p=()=>l[Math.floor(t()*l.length)];return c===!0?p:p()}const u=()=>o(l,c,h);return f?u:u()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(t()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:f="start",ease:u})=>(p,m,d)=>{const g=d.length,v=Me(p,g,{...c!==void 0?{amount:c}:{each:h??1},from:f}),w=c!==void 0?c:(h??1)*Pn(g,f),T=u&&w>0?u(v/w)*w:v;return l+T},pipe:(...l)=>c=>l.reduce((h,f)=>f(h),c),splitColor:l=>sc(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=ii(l)},resolveRandomString:l=>{const c=gr.exec(l)?.[1]??"";if(c.startsWith("[")){const m=c.slice(1,-1).split(",").map(d=>d.trim()).filter(Boolean).map(d=>Number.isFinite(Number(d))?Number(d):d.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[h,f,u]=c.split(",").map(p=>Number.parseFloat(p));return o(h,f,Number.isFinite(u)?u:void 0)}}}function br(e,t,n){let i=t,s=1/0;for(const r of e){const o=Math.abs(r-t);o<s&&(s=o,i=r)}return s<=n?i:t}function sc(e){const t=e.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(t)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(t)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(s=>Number.parseFloat(s));return i.length>=4?[i[0],i[1],i[2],i[3]]:[i[0]??0,i[1]??0,i[2]??0]}const rc=/^([+-])=\s*(-?[\d.]+)$/,oc=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function he(e,t){const n=t.scale??1,i=c=>Number.parseFloat(c)*n;if(e===void 0)return t.cursor;if(typeof e=="number")return e*n;const s=e.trim();if(s==="")return t.cursor;const r=rc.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=oc.exec(s);if(o){const c=o[1]==="<"?t.previousStart:t.previousEnd;if(o[3]===void 0)return c;const h=i(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const c=t.labels.get(a[1].trim());if(c!==void 0){const h=i(a[3]);return c+(a[2]==="-"?-h:h)}}const l=t.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):t.cursor}function ac(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.grid!==void 0||t.from==="random"||Array.isArray(t.from)||t.ease!==void 0||t.axis!==void 0}function lc(e,t,n={}){if(e===0)return[];const i=t.grid==="auto"?Math.max(1,Math.min(e,n.columnsFromLayout?.()??e)):Array.isArray(t.grid)?Math.max(1,t.grid[1]):e,s=Array.isArray(t.grid)?Math.max(1,t.grid[0]):Math.ceil(e/i),r=m=>({x:m%i,y:Math.floor(m/i)}),o=t.from??"start",a=Array.isArray(o)?{x:o[0]*(i-1),y:o[1]*(s-1)}:typeof o=="number"?r(Math.max(0,Math.min(e-1,o))):o==="end"?r(e-1):o==="center"||o==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=m=>{const{x:d,y:g}=r(m),y=Math.abs(d-a.x),v=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?v:Math.hypot(y,v)};let c=Array.from({length:e},(m,d)=>l(d));const h=Math.max(...c);if(o==="edges"&&(c=c.map(m=>h-m)),o==="random"){const m=n.random??Math.random;c=c.map(()=>m()*h)}const f=t.amount!==void 0?t.amount:(t.each??0)*h,u=t.ease?ce(t.ease):void 0,p=u?u.fn??V(u.easing):void 0;return c.map(m=>{const d=h===0?0:m/h;return(p?p(d):d)*f})}const si=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),cc={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function qe(e){const t={},n={};for(const[i,s]of Object.entries(e))si.has(i)?t[i]=s:n[cc[i]??i]=s;return{config:t,properties:n}}function Xe(e,t){return e===void 0?t:e*1e3}function ri(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:ac(e)?{offsets:lc(t?.count??0,e,t??{}).map(i=>i*1e3)}:{...e.each!==void 0&&{each:e.each*1e3},...e.amount!==void 0&&{amount:e.amount*1e3},...e.from!==void 0&&{from:e.from}}}const hc={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function wr(e){return hc[e]}function uc(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:e;if(!t||typeof t.path!="string"&&!Array.isArray(t.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(t.path))n=ar(t.path,{curviness:t.curviness});else if(Ft(t.path))n=t.path;else throw new Error(`gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const i={pathData:n};return t.autoRotate!==void 0&&t.autoRotate!==!1&&(i.autoRotate=!0,typeof t.autoRotate=="number"&&(i.rotateOffset=t.autoRotate)),t.matrix&&(i.matrix=t.matrix),{config:i,start:t.start??0,end:t.end??1}}function fc(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function vr(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function dc(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=vr(t);if(typeof i!="string"||!Ft(i))throw new Error(`gsap-compat: morphSVG "${String(i)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:i}}function pc(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,kr(e,t)];const n=e.trim().split(/[\s,]+/).filter(Boolean),i=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${e}" is not a length or percentage`);return kr(o.endsWith("%")?t*a/100:a,t)};if(n.length===0)return[0,t];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),r=i(n[1]);return s<=r?[s,r]:[r,s]}function mc(e,t){const[n,i]=pc(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function gc(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...mc(n,t)}}function yc(e){if(e.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return e}function kr(e,t){return Math.max(0,Math.min(t,e))}function bc(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function wc(e,t,n){if(e.scrambleText!==void 0){const i=e.scrambleText,s=typeof i=="string"?{text:i}:i;if(typeof s?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=s.revealDelay&&n>0?s.revealDelay*1e3/n:void 0;return{to:s.text,mode:"scramble",...s.chars!==void 0&&{chars:s.chars},...s.speed!==void 0&&{refreshRate:20*s.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??bc(`${t}|${s.text}`)}}if(e.text!==void 0){const i=e.text,s=typeof i=="string"?{value:i}:i;if(typeof s?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:s.value,mode:"type",...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft}}}}function oi(e){return Math.max(.1,e/25)}function vc(e,t){const n=typeof t=="number"?{velocity:t}:t;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const i=n.friction??(n.resistance!==void 0?oi(n.resistance):void 0),s={from:e,velocity:n.velocity,...i!==void 0&&{friction:i},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?s.end=[n.end(Qt(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function kc(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in xe))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(xe).join(", ")}`);return{...t.preset?xe[t.preset]:{},...t.stiffness!==void 0&&{stiffness:t.stiffness},...t.damping!==void 0&&{damping:t.damping},...t.mass!==void 0&&{mass:t.mass},...t.restDelta!==void 0&&{restDelta:t.restDelta}}}function Sc(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class Et{timeline;options;cursor=0;fallbackRandom=ii(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new zn({id:t.id??"gsap-compat",name:t.name,config:{...t.repeat!==void 0&&{loop:t.repeat},...t.yoyo!==void 0&&{alternate:t.yoyo},...t.repeatDelay!==void 0&&{repeatDelay:t.repeatDelay*1e3},...t.timeScale!==void 0&&{speed:t.timeScale}}})}to(t,n,i){return this.build(t,void 0,ue(n),i)}from(t,n,i){const{config:s,properties:r}=qe(ue(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],f={...s};for(const m of Object.keys(c))f[m]=this.resolveStart(h,m);o!==void 0&&(f.motionPath=fc(o));const u={},p=String(this.resolveStart(h,"text"));return a!==void 0&&(u.text=ai(a),f.text=typeof a=="object"?{...a,value:p}:p),l!==void 0&&(u.text=ai(l),f.scrambleText=typeof l=="object"?{...l,text:p}:p),this.build(t,{...c,...u},f,i)}fromTo(t,n,i,s){const{properties:r}=qe(ue(n));return this.build(t,r,ue(i),s)}set(t,n,i){return this.build(t,void 0,{...ue(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,he(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return he(t,this.context())}addLabel(t,n){return this.labels.set(t,he(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((t,n)=>t-n)}labelTime(t){return this.labels.get(t)}add(t,n){const i=he(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=$e({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(o)}const s=i+t.timeline.duration;return this.previousStart=i,this.previousEnd=s,this.cursor=Math.max(this.cursor,s),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(t){if(typeof t=="string"){const n=this.labels.get(t);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(t*1e3),this}progress(t){const n=this.timeline.duration;return t!==void 0&&n>0&&this.timeline.seek(t*n),n>0?this.timeline.currentTime/n:0}timeScale(t){return t!==void 0&&(this.timeline.speed=t),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(t){return this.timeline.tick(t),this}toDefinition(){return this.timeline.toDefinition()}build(t,n,i,s){const{config:r,properties:o}=qe(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...f}=o,u=this.targetsOf(t),p=he(s,this.context()),m=Xe(r.delay,0),d=Xe(r.duration,500),g=ri(r.stagger,{count:u.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(u):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),v=[],w=r.spring;let T=0,k=!1;for(const[A,P]of Object.entries(f)){const C=P;let I=n?.[A]!==void 0?n[A]:this.resolveStart(u[0],A);if(typeof I!=typeof C&&(this.warn(`no usable start value for "${A}" on "${u[0]}" — it will snap to ${String(C)}. Use fromTo() to animate it.`),I=C),w!==void 0&&(typeof I!="number"||typeof C!="number")&&this.warn(`spring works on numbers, so "${A}" on "${u[0]}" eases instead`),w!==void 0&&typeof I=="number"&&typeof C=="number"){const F={...kc(w),from:I,to:C,velocity:Sc(w,A)??this.options.startVelocity?.(u[0],A)??0},L=this.nextTrackId(`${u[0]}-${A}-spring`),O={id:L,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"spring",spring:F,delay:p+m};this.timeline.addTrack(O),v.push(L),T=Math.max(T,rs(F));for(const R of u)this.lastValues.set(`${R}|${A}`,C);continue}k=!0;const H=this.keyframesFor(I,C,d,y,r.ease),$=this.nextTrackId(`${u[0]}-${A}`);this.timeline.addTrack($e({id:$,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,delay:p+m,keyframes:H,...A==="quaternion"&&{interpolation:"slerp"}})),v.push($);for(const F of u)this.lastValues.set(`${F}|${A}`,C)}const S=wc({text:l,scrambleText:c},u[0],d);if(S){const A=n?.text??n?.scrambleText,P=A!==void 0?ai(A):this.resolveStart(u[0],"text"),C=this.nextTrackId(`${u[0]}-text`),I={id:C,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"text",textConfig:{from:typeof P=="string"?P:String(P??""),...S},delay:p+m,keyframes:this.keyframesFor(0,1,d,y,r.ease)};this.timeline.addTrack(I),v.push(C);for(const H of u)this.lastValues.set(`${H}|text`,S.to)}if(a!==void 0){const{config:A,start:P,end:C}=uc(a),I=this.nextTrackId(`${u[0]}-motionPath`),H={id:I,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"motionPath",motionPathConfig:A,delay:p+m,keyframes:this.keyframesFor(P,C,d,y,r.ease)};this.timeline.addTrack(H),v.push(I)}if(h!==void 0)for(const[A,P]of Object.entries(h)){const C=this.resolveStart(u[0],A);if(typeof C!="number"){this.warn(`inertia on "${A}" needs a numeric start value; skipped`);continue}const I=vc(C,P),H=this.nextTrackId(`${u[0]}-${A}-inertia`),$={id:H,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"inertia",inertia:I,delay:p+m};this.timeline.addTrack($),v.push(H),T=Math.max(T,$t(I));for(const F of u)this.lastValues.set(`${F}|${A}`,Ht(I))}const M=((h!==void 0||w!==void 0)&&!k&&!S&&a===void 0?T:Math.max(d,T))+(g&&u.length>1?Jt(u.length,g):0),x=p+m+M;return this.previousStart=p+m,this.previousEnd=x,this.cursor=Math.max(this.cursor,x),{trackIds:v,start:p+m,end:x,kill:()=>{for(const A of v)this.timeline.removeTrack(A)}}}keyframesFor(t,n,i,s,r){const o={time:0,value:t};if(i<=0)return[{time:0,value:n}];const a=typeof r=="string"?ce(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Gt(s)){const c=a?.fn??V(s);return[o,...Xn(o,{time:i,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:i,value:n,...s&&{easing:s}}]}resolveStart(t,n){const i=this.lastValues.get(`${t}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(t,n);if(s!==void 0)return s;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=wr(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${t}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${t}" — using 0`),0)}easingFor(t){if(t!==void 0){if(typeof t=="string")return ce(t).easing;if(typeof t=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return t}}targetsOf(t){return Array.isArray(t)?t:[t]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(t){return this.trackCounter+=1,`${t}-${this.trackCounter}`}warn(t){this.options.onWarning?.(`gsap-compat: ${t}`)}}function ai(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return String(t.value??t.text??"")}return String(e??"")}function Tc(e){return new Et(e)}function ue(e){return yc(dc(e))}function Mc(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${le(gt(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Ec=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Ac="#ffffff",xc="rgba(0, 0, 0, 0.5)";function Pc(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??Ac})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??xc})`)}return t.length>0?t.join(" "):null}function _c(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function Cc(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Sr=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),Ic=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Hc=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],$c=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),Rc=new Set(["originX","originY"]),Fc=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Oc=new Set(["drawOn"]),Lc={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Tr={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Bc="http://www.w3.org/2000/svg";class At{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){let i=null,s=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[m,d]of n)if(!(m==="x"&&l)&&!(m==="y"&&c)&&!((m==="rotate"||m==="rotateZ")&&h)&&!Oc.has(m)){if(Ic.has(m))(i??={})[m]=d;else if($c.has(m))typeof d=="number"&&((s??={})[m]=d);else if(Rc.has(m))typeof d=="number"&&((r??={})[m]=d);else if(Fc.has(m))typeof d=="number"&&((o??={})[m]=d);else if(Ec.has(m))(a??={})[m]=d;else if(m!=="perspective"){if(m!=="shine")if(m==="text"&&typeof d=="string")_c(t,d);else if(m==="d"&&typeof d=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,m,d)}}const f=n.get("shine");typeof f=="number"&&this.applyShine(t,f);const u=[],p=n.get("perspective");if(typeof p=="number"&&p>0&&u.push(`perspective(${p}px)`),i)for(const m of Hc){const d=i[m];if(d===void 0)continue;const g=this.buildTransformPart(m,d);g&&u.push(g)}if(u.length>0&&(t.style.transform=u.join(" "),Cc(t)),s&&(s.childPerspective!==void 0&&(t.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(t.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),r){const m=r.originX??50,d=r.originY??50;t.style.transformOrigin=`${m}% ${d}%`}if(o){const m=o.clipTop??0,d=o.clipRight??0,g=o.clipBottom??0,y=o.clipLeft??0;t.style.clipPath=`inset(${m}% ${d}% ${g}% ${y}%)`}if(a){const m=Pc(a);m&&(t.style.filter=m)}}buildTransformPart(t,n){if(t==="quaternion")return Mc(n);if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===Bc&&n in Tr){const a=Array.isArray(i)?i.join(", "):String(i);t.style[Tr[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Lc[n]??n;let o;typeof i=="number"?Sr.has(n)||Sr.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Dc={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class Mr{adapter=new At;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=ic();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Dc,this.rootOption=t.root,this.onWarning=t.onWarning}get root(){return this.rootOption??document}resolveTargets(t){const n=[];for(const i of this.targetsOf(t)){const s=this.nameFor(i);li(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(t){return this.selectorRoot.querySelector(t)}get collector(){return this.currentCollector}setCollector(t){this.currentCollector=t}forget(t){this.applied.delete(t),this.dirty.delete(t)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(t){return this.elements.get(t)}objectFor(t){return this.objects.get(t)}appliedValue(t,n){return this.applied.get(t)?.get(n)}velocityOf(t,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:t,property:n}).length===0)continue;const r=s.currentTime;if(r<4)return 0;const o=s.getStateAtTime(r).values.get(t)?.get(n),a=s.getStateAtTime(r-4).values.get(t)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:t=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(t),this.currentCollector?.track({revert:()=>this.ticker.remove(t)}),this.startLoop())},remove:t=>{this.tickerCallbacks.delete(t),this.running||this.stopLoop()}};activate(t,n={}){this.destroyed||(t.onUpdate=i=>this.write(i),this.active.delete(t),this.active.set(t,n),this.startLoop())}deactivate(t){this.active.delete(t),this.running||this.stopLoop()}own(t){return this.destroyed?t.destroy():this.owned.add(t),t}destroy(){this.destroyed=!0;for(const t of this.owned)t.destroy();this.owned.clear();for(const t of this.active.keys())t.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(t,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[t,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(t){this.destroyed||(this.write(t.getStateAtTime(t.currentTime)),this.flush())}tick(t){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(t);this.flush();for(const[i,s]of n)s.onUpdate?.(),i.playbackState!=="playing"&&this.active.get(i)===s&&this.active.delete(i);this.flush(),this.runTicker(t),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(t){if(this.tickerCallbacks.size!==0){this.tickerTime+=t,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,t,this.tickerFrame)}}write(t){for(const[n,i]of t.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[r,o]of i)s.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const t=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[r,o]of i)s[r]=o;else t.set(n,i)}this.dirty.clear(),t.size!==0&&this.adapter.applyState({values:t,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=t=>{this.frameId=null;const n=this.lastTimestamp===null?0:t-this.lastTimestamp;this.lastTimestamp=t,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(t){if(typeof t=="string")return Array.from(this.selectorRoot.querySelectorAll(t));if(li(t))return[t];if(!Nc(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return li(t)?this.elementName(t):this.objectName(t)}objectName(t){const n=this.objectNames.get(t);if(n)return n;let i;do this.nameCounter+=1,i=`obj-${this.nameCounter}`;while(this.objects.has(i)||this.elements.has(i));return this.objectNames.set(t,i),this.objects.set(i,t),i}elementName(t){const n=this.names.get(t);if(n)return n;let i=t.id?`#${t.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(t,i),this.elements.set(i,t),this.adapter.registerTarget(i,t),i}}function li(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Nc(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function Ve(e){const t=e.style;if(!t)return e.getBoundingClientRect();const n=t.transform;t.transform="none";const i=e.getBoundingClientRect();return t.transform=n,i}const Er=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Wc(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Yc(e){const t=e.getScreenCTM?.();if(t)return[t.a,t.b,t.c,t.d,t.e,t.f];const n=e.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function Kc(e,t){const n=typeof e=="string"||Array.isArray(e)||Er(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=S=>{const E=Er(S)?S:t.query(S);return E||t.warn(`gsap-compat: motionPath could not find "${String(S)}"`),E};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&Ft(r))c=r;else{l=a(r);const S=l&&Be({tag:l.localName,attributes:Wc(l)});l&&!S&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=S??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const f=i===!0?l:a(i);if(!f)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const u=t.targets[0];if(!u)return h;const[p,m,d,g,y,v]=Yc(f),w=Ve(u),[T,k]=s??[.5,.5];for(const S of t.targets.slice(1)){const E=Ve(S);if(Math.abs(E.left-w.left)>.5||Math.abs(E.top-w.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[p,m,d,g,y-w.left-T*w.width,v-w.top-k*w.height],h}const Ar=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function xr(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Pr(e){if(!e)return null;const t=Be({tag:e.localName,attributes:xr(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function qc(e,t,n){const i=vr(e);if(typeof i=="string"&&Ft(i))return i;const s=Ar(i)?i:typeof i=="string"?t(i):null,r=Pr(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Xc=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Vc(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):Ar(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=Be({tag:i.localName,attributes:xr(i)});if(!s||!i.parentNode)return i;const r=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(i.attributes))Xc.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const _r=.3;class Cr{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(t){this.options=t,this.target=t.target}start(){if(this.running)return;this.running=!0;const t=this.options.type??["pointer","touch"];t.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),t.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),t.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(t,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=t,this.startY=n,this.lastX=t,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=Ir(),this.options.onPress?.(this.stateFrom(0,0,i))}move(t,n,i){if(!this.dragging)return;const s=t-this.lastX,r=n-this.lastY;this.lastX=t,this.lastY=n;const o=t-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,r),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,r,i))}end(t){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,t)))}updateVelocity(t,n){const i=Ir(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*_r,this.velocityY+=(o-this.velocityY)*_r}stateFrom(t,n,i){return{deltaX:t,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=t=>{const n=t,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,t)};onPointerMove=t=>{const n=t;this.move(n.clientX,n.clientY,t)};onPointerUp=t=>this.end(t);onTouchStart=t=>{const n=t.touches[0];n&&this.begin(n.clientX,n.clientY,t)};onTouchMove=t=>{const n=t.touches[0];n&&this.move(n.clientX,n.clientY,t)};onTouchEnd=t=>this.end(t);onWheel=t=>{const n=t;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:t})}}function Ir(){return typeof performance<"u"?performance.now():Date.now()}function Hr(e,t,n){let i={delta:0,line:null},s=n;for(const r of e)for(const o of t){const a=Math.abs(o-r);a<=s&&(s=a,i={delta:o-r,line:o})}return i}function $r(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class ci{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(t){this.options=t,this.x=t.initialX??0,this.y=t.initialY??0,this.observer=new Cr({target:t.target,onPress:n=>{const i=t.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,t.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>t.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(t,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(t,"x"),this.y=i==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const t=this.options.snap??0;return t>0?t/2:8}handleMove(t){this.setPosition(this.originX+t.totalX,this.originY+t.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,t),this.options.onSnap?.(this.snapLines)}scrub(){const t=this.options.timeline;if(!t)return;const n=t.duration;if(n<=0)return;const i=this.options.scrubDistance??500;if(i===0)return;const s=(this.options.axis??"both")==="y"?this.y:this.x,r=Uc(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...$r([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=Hr([i],s,this.snapThreshold());i+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function Uc(e){return e<0?0:e>1?1:e}function zc(e){const t=new ci(e);return t.start(),t}const jc={x:"x",y:"y","x,y":"both"},hi=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Rr(e,t){const n=Ve(e),i=t.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function Fr(e){return Array.isArray(e)?[...e]:e}function Gc(e,t,n,i={}){const[s]=t.resolveTargets(n),r=s?t.elementFor(s):void 0;if(!s||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return Jc(e,t,s,r,i);const o=jc[i.type??"x,y"],a=()=>{const d=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof d=="number"?d:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):hi(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!hi(i.bounds)?i.bounds:void 0)??(l?Rr(r,l):void 0)};let f=null;const u=()=>{f?.kill(),f=null},p=d=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?oi(g.resistance):4),v=a(),w=h.bounds??{};let T,k;const S=g.end;if(Array.isArray(S)){const _=Qt({from:v.x,velocity:o==="y"?0:d.x,friction:y}),M=Qt({from:v.y,velocity:o==="x"?0:d.y,friction:y});let x=S[0];for(const A of S)Math.hypot(A.x-_,A.y-M)<Math.hypot(x.x-_,x.y-M)&&(x=A);x&&(T=[x.x],k=[x.y])}else typeof S=="number"?(T=S,k=S):S&&(T=Fr(S.x),k=Fr(S.y));const E={};o!=="y"&&(E.x={velocity:d.x,friction:y,min:w.minX,max:w.maxX,end:T}),o!=="x"&&(E.y={velocity:d.y,friction:y,min:w.minY,max:w.maxY,end:k}),f=e.to(r,{inertia:E,onComplete:()=>i.onThrowComplete?.()})},m=new ci({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{u(),l&&(h.bounds=Rr(r,l)),i.onPress?.()},onDrag:d=>{t.apply(s,o==="x"?{x:d.x}:o==="y"?{y:d.y}:{x:d.x,y:d.y}),i.onDrag?.(d)},onRelease:()=>{const d=m.velocity;i.onRelease?.(d),i.inertia&&p(d)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const d=t.appliedValue(s,"rotate");return typeof d=="number"?d:0},destroy(){u(),m.destroy()}}}function Jc(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!hi(s.bounds)?s.bounds:{},o=()=>{const w=t.appliedValue(n,"rotate");return typeof w=="number"?w:0},a=w=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,w));let l=null,c=!1,h,f={x:0,y:0},u=0,p=0,m=[];const d=w=>Math.atan2(w.clientY-f.y,w.clientX-f.x)*180/Math.PI,g=w=>{if(c)return;l?.kill(),l=null,c=!0,h=w.pointerId,i.setPointerCapture?.(w.pointerId);const T=i.getBoundingClientRect();f={x:T.left+T.width/2,y:T.top+T.height/2},u=d(w),p=o(),m=[{time:performance.now(),rotation:p}],s.onPress?.()},y=w=>{if(!c||w.pointerId!==h)return;const T=d(w);let k=T-u;k>180&&(k-=360),k<-180&&(k+=360),u=T,p+=k;let S=a(p);s.snap&&(S=a(Math.round(S/s.snap)*s.snap)),t.apply(n,{rotate:S});const E=performance.now();for(m.push({time:E,rotation:S});m.length>2&&E-m[0].time>100;)m.shift();const _={x:0,y:0};s.onDrag?.(_)},v=w=>{if(!c||w.pointerId!==h)return;c=!1;const T=m[0],k=m[m.length-1],S=T&&k?(k.time-T.time)/1e3:0,E=S>0?(k.rotation-T.rotation)/S:0;if(s.onRelease?.({x:E,y:0}),!s.inertia)return;const _=s.inertia===!0?{}:s.inertia,M=_.friction??(_.resistance!==void 0?oi(_.resistance):4),x=typeof _.end=="number"||Array.isArray(_.end)?_.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:E,friction:M,min:r.minRotation,max:r.maxRotation,end:Array.isArray(x)?x.filter(A=>typeof A=="number"):x}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",v),i.addEventListener("pointercancel",v),i.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),i.removeEventListener("pointerdown",g),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",v),i.removeEventListener("pointercancel",v)}}}const Zc={opacity:0,scale:.6};function Qc(e){const t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function Or(e){const t=Ve(e);return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function ui(e,t){const i=e.resolveTargets(t).map(o=>e.elementFor(o)).filter(o=>!!o),s=new Map,r=new Map;for(const o of i){const a=Qc(o);s.set(o,a);const l=Lr(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const fi=new WeakMap;function di(e,t,n,i={}){const s=i.duration??.6,r=i.ease??"power2.inOut",o=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?Zc:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const p of e.resolveTargets(i.targets)){const m=e.elementFor(p);m&&c.add(m)}const h=[...c].sort((p,m)=>p===m?0:p.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),f=t({onComplete:i.onComplete});let u=0;for(const p of h){const m=Or(p);if(!m)continue;let d=n.boxes.get(p)??null,g;const y=Lr(p),v=!d&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==p&&(d=v.box,g=v.element);const[w]=e.resolveTargets(p);fi.get(p)?.timeline.removeTracks({target:w});const T=u*o;if(!d){if(l===!1)continue;f.fromTo(p,{x:0,y:0,scaleX:1,scaleY:1,...l},{...Br(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:T},0),fi.set(p,f),u++;continue}const k=d.cx-m.cx,S=d.cy-m.cy,E=a?d.width/m.width:1,_=a?d.height/m.height:1;if(!(Math.abs(k)>.5||Math.abs(S)>.5||Math.abs(E-1)>.001||Math.abs(_-1)>.001)){const A=(P,C)=>{const I=e.appliedValue(w,P);return typeof I=="number"&&Math.abs(I-C)>1e-6};(A("x",0)||A("y",0)||A("scaleX",1)||A("scaleY",1))&&f.set(p,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const x=i.fade===!0&&g!==void 0;f.fromTo(p,{x:k,y:S,scaleX:E,scaleY:_,...x&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...x&&{opacity:1},duration:s,ease:r,delay:T},0),x&&g&&Or(g)&&f.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:T},0),fi.set(p,f),u++}return f}function Lr(e){return e.dataset?.flipId}function Br(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function th(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(d=>d.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(d=>({element:d,html:d.innerHTML,ariaLabel:d.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:d,html:g,ariaLabel:y}of r)d.innerHTML=g,y===null?d.removeAttribute("aria-label"):d.setAttribute("aria-label",y)},f=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},u=()=>{const d={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),v=eh(g,i.words),w=n.has("chars")?v.flatMap(S=>nh(S,i.chars)):[],T=n.has("lines")?sh(g,v,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const S of v)S.setAttribute("aria-hidden","true")}if(n.has("words"))d.words.push(...v);else for(const S of v)S.removeAttribute("class");d.chars.push(...w),d.lines.push(...T);const k=t.mask==="lines"?T:t.mask==="words"?v:t.mask==="chars"?w:[];for(const S of k)d.masks.push(rh(S,`${i[t.mask]}-mask`))}o=d},p={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(f(),h(),u(),a=t.onSplit?.(p))},revert(){c=!0,l?.disconnect(),f(),h()}};u(),a=t.onSplit?.(p),t.autoSplit&&m();function m(){const d=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const w=()=>{g=!1,p.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(w):setTimeout(w,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(w=>{let T=!1;for(const k of w){const S=Math.round(k.contentRect.width),E=d.get(k.target);d.set(k.target,S),E!==void 0&&E!==S&&(T=!0)}T&&y()});for(const w of e)l.observe(w)}const v=e[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return p}function eh(e,t){const n=e.ownerDocument,i=[],s=n.createTreeWalker(e,4),r=[];for(let o=s.nextNode();o;o=s.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=t,h.style.display="inline-block",h.textContent=c,l.appendChild(h),i.push(h)}o.replaceWith(l)}return i}function nh(e,t){const n=e.ownerDocument,i=ih(e.textContent??"").map(s=>{const r=n.createElement("span");return r.className=t,r.style.display="inline-block",r.textContent=s,r});return e.replaceChildren(...i),i}function ih(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function sh(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const d of Array.from(m.childNodes))d.nodeType===3||s.has(d)||d.tagName==="BR"?r.push(d):o(d)};o(e);const a=[];let l=null,c=0,h=0,f=!1,u=[];const p=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),u=[]};for(const m of r){if(m.tagName==="BR"){f=!0;continue}const d=s.get(m);if(d&&(!l||f||d.top>c+h)&&(p(),c=d.top,h=d.height/2,f=!1),!l)continue;const g=[];for(let w=m.parentNode;w&&w!==e;w=w.parentNode)g.unshift(w);let y=0;for(;y<u.length&&y<g.length&&u[y].original===g[y];)y++;u.length=y;let v=y===0?l:u[y-1].clone;for(const w of g.slice(y)){const T=w.cloneNode(!1);v.appendChild(T),u.push({original:w,clone:T}),v=T}v.appendChild(m)}return e.replaceChildren(...a),a}function rh(e,t){const n=e.ownerDocument.createElement("span");return n.className=t,n.style.display=e.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",e.replaceWith(n),n.appendChild(e),n}const Dr={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function pi(e){const t=e.trim().toLowerCase();if(t in Dr)return Dr[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function mi(e){if(typeof e=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:e};let t=0;const i=e.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(t+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(i.length===1&&/^-?[\d.]+$/.test(i[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(i[0])+t};const s=i[0]!==void 0?pi(i[0]):void 0,r=i[1]!==void 0?pi(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Wt(e,t,n){const i=mi(n),s=i.absolutePx!==void 0?e.top+i.absolutePx:e.top+e.height*i.elementFraction,r=t*i.viewportFraction;return s-r+i.offsetPx}function oh(e,t,n,i){const s=Wt(e,t,n),o=Wt(e,t,i)-s;return o<=0?s<=0?1:0:gi(-s/o)}function gi(e){return e<0?0:e>1?1:e===0?0:e}function Nr(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function yi(e,t,n,i,s){const r=h=>Wt({top:e+s(h),bottom:e+s(h)+t,height:t},n,i),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const f=(l+c)/2;Math.sign(r(f))===Math.sign(o)?l=f:c=f}return(l+c)/2}class Wr{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(t){this.timeline=t.timeline,this.trigger=t.trigger,this.behaviour=t.behaviour??"once",this.options=t}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function ah(e){const t=new Wr(e);return t.start(),t}class Yr{element;spacer;saved;axis;spacing;constructor(t,n={}){this.element=t,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=t.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:t.style.position,top:t.style.top,left:t.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),t.replaceWith(this.spacer),this.spacer.appendChild(t)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(t,n){const i=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+i}px`,this.spacer.style.marginRight=this.spacing?"":`-${i}px`,this.element.style.left=`${t}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${t}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const lh=.15;function Kr(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function qr(e,t,n){const i=Ue(e+t*lh);if(typeof n=="function")return Ue(n(i));if(typeof n=="number")return n<=0?e:Ue(Math.round(i/n)*n);if(n.length===0)return e;let s=n[0];for(const r of n)Math.abs(r-i)<Math.abs(s-i)&&(s=r);return Ue(s)}function Xr(e,t,n){const i=e.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(t)/Math.max(1,n));return i.min+(i.max-i.min)*s}class Vr{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(t,n){this.write=t,this.eventTarget=n}get active(){return this.rafId!==null}animate(t,n,i,s=te,r){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(i*1e3));this.write(t+(n-t)*s(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const t of this.cancelEvents)this.eventTarget?.removeEventListener(t,this.onInterrupt)}}function Ue(e){return Math.max(0,Math.min(1,e))}class Ur{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(t,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,f)=>{const u=t.createElement("div");return u.textContent=`${a}${c}`,u.setAttribute("aria-hidden","true"),u.className="scroll-marker",Object.assign(u.style,{position:f?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??t.body).appendChild(u),this.nodes.push(u),u};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",s,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(t,n){this.start.style.top=`${t.startPage}px`,this.end.style.top=`${t.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+t.startViewport}px`,this.scrollerEnd.style.top=`${i+t.endViewport}px`}follow(t,n){this.scroller&&this.place(t,n)}destroy(){for(const t of this.nodes.splice(0))t.remove()}}const ch=120,Yt=[],Kt=new Set;let bi=!1;const hh=()=>{bi||Kt.size===0||(bi=!0,queueMicrotask(()=>{bi=!1;for(const e of Kt)e.afterRefresh()}))},zr=()=>{for(const e of Kt)e.beforeRefresh();for(const e of Yt)e.refresh();for(const e of Kt)e.afterRefresh()};let qt={width:0,height:0};const jr=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===qt.width&&t!==qt.height,i=Math.abs(t-qt.height)<qt.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(qt={width:e,height:t},zr())};class fe{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(t){this.timeline=t.timeline,this.options=t,this.snapper=new Vr(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const t=this.options.pin===!0?this.options.trigger:this.options.pin||null;t&&!this.options.container&&(this.pin=new Yr(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Ur(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Yt.length===0&&typeof window<"u"&&(qt={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",jr,{passive:!0})),Yt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Yt.splice(Yt.indexOf(this),1),Yt.length===0&&typeof window<"u"&&window.removeEventListener("resize",jr),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){zr()}static onRefresh(t){return Kt.add(t),()=>Kt.delete(t)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const t=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const i=this.viewportHeight();if(this.startPx=t+Wt(n,i,de(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,t),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-t),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,t),this.lastScroll=null,this.updateFrom(t,!this.measured),this.measured=!0,hh()}sample(){this.refresh()}update(t){this.running&&this.updateFrom(t??this.scrollPosition(),!1)}updateFrom(t,n){this.trackVelocity(t),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,t);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?gi((t-this.startPx)/i):t>=this.startPx?1:0,this.zone=i>0?t<=this.startPx?"before":t>=this.endPx?"after":"active":t>=this.startPx?"after":"before",this.fireBoundaryCallbacks(s,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const t=this.options.scrub;return typeof t=="number"?Math.max(0,t):0}resolveEnd(t,n,i){const s=de(this.options.end)??"bottom top",r=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return i+Wt(t,n,s)}applyProgress(){const t=this.timeline?.duration??0;this.timeline&&t>0&&this.timeline.seek(this.displayProgress*t),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const t=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===t[0]&&this.lastEmitted[1]===t[1]||(this.lastEmitted=t,this.options.onUpdate(t[0],t[1]))}trackVelocity(t){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&t!==this.lastScroll&&(this.velocityPxPerSecond=(t-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||t!==this.lastScroll)&&(this.lastScroll=t,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},ch))}fireBoundaryCallbacks(t,n){if(t===n)return;const{onEnter:i,onLeave:s,onEnterBack:r,onLeaveBack:o}=this.options;t==="before"?(i?.(),n==="after"&&s?.()):t==="after"?(r?.(),n==="before"&&o?.()):n==="after"?s?.():o?.()}scheduleSnap(){const t=this.options.snap;if(t===void 0||this.snapper.active)return;const n=Kr(t),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||s<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/s,a=this.startPx+qr(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,Xr(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(t){const n=this.options.scroller,i=this.options.horizontal?{left:t}:{top:t};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=t:n.scrollTop=t:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(t){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=i.left-s-t.shiftAt(t.progress()),{start:a,end:l}=t.range(),c=p=>a+p*(l-a),h=yi(o,i.width,r,de(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const f=de(this.options.end)??"right left",u=typeof f=="string"?f.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=u?this.startPx+Number.parseFloat(u[1]):c(yi(o,i.width,r,f,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=de(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=mi(a);return t*l.viewportFraction-l.offsetPx},i=n(this.options.start,"top bottom")??0,s=n(this.options.end,"bottom top")??i;return{startViewport:i,endViewport:s,startPage:this.startPx+i,endPage:this.endPx+s}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const t=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=Nr(this.displayProgress,this.targetProgress,this.smoothing(),i);const s=Math.abs(this.targetProgress-this.displayProgress)<1e-4;s&&(this.displayProgress=this.targetProgress),this.applyProgress(),s?this.lastFrameTime=null:this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const t=this.options.scroller,n=this.options.horizontal;return t?(n?t.scrollLeft:t.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const t=this.options.trigger;return typeof t?.getBoundingClientRect!="function"?null:this.relativeRect(t.getBoundingClientRect())}relativeRect(t){const n=this.options.horizontal,i=n?t.left??0:t.top,s=n?t.right??0:t.bottom,r=n?t.width??0:t.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:r}}return{top:i,bottom:s,height:r}}viewportHeight(){const t=this.options.scroller,n=this.options.horizontal;return t?n?t.clientWidth:t.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function de(e){return typeof e=="function"?e():e}function uh(e){const t=new fe(e);return t.start(),t}const wi=new Set,fh=16,Gr=.5,dh=2;class vi{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=t=>this.wheel(t);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(t={}){this.options=t,this.frames=t.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const t=this.options.scroller??window;return t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),wi.add(this),this.stopListening=fe.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of wi)t.refresh()}stop(){if(!this.running)return this;this.running=!1;const t=this.options.scroller??window;return t.removeEventListener("wheel",this.onWheel),t.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),wi.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)ki(t.element,t.saved);this.effects=[]}kill(){this.destroy()}get state(){const t=this.limit();return{scroll:this.current,target:this.target,progress:t>0?this.current/t:0,velocity:this.velocityPxPerSecond}}paused(t){return t!==void 0&&(this.pausedState=t,t&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(t,n={}){if(!this.running)return;const i=this.clamp(this.resolve(t)+(n.offset??0)),s=Math.abs(i-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(r<=0){this.journey=null,this.current=this.target=i,this.write(i),this.applyEffects(0);return}this.target=i,this.journey={from:this.current,to:i,ms:r*1e3,ease:n.ease??te,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const t=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(t&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(t)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+i;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-s/2,lagged:i,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const t of this.effects)ki(t.element,t.saved)}wheel(t){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||this.nestedScrollerTakes(t))return;const n=t.deltaMode===1?fh:t.deltaMode===2?this.viewportHeight():1,i=t.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(t.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const t=this.position();this.written!==null&&Math.abs(t-this.written)<=dh||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=t,this.requestFrame())}nestedScrollerTakes(t){const n=this.options.scroller??document.documentElement;for(let i=t.target;i&&i!==n&&i!==document.body;i=i.parentElement){if(i.hasAttribute?.("data-smooth-ignore"))return!0;const s=getComputedStyle(i);if(!/(auto|scroll)/.test(s.overflowY)||i.scrollHeight<=i.clientHeight)continue;if(t.deltaY<0?i.scrollTop>0:i.scrollTop+i.clientHeight<i.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(t=>this.frame(t)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(t){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,t-this.lastTime);this.lastTime=t;const i=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<Gr&&(this.current=this.target)}this.current!==i&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-i)*1e3/n:0;const s=this.applyEffects(n);this.current!==i&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||s?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(t){let n=!1;const i=this.current;for(const s of this.effects){let r=0;if(s.speed!==void 0&&(r+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const o=s.lag*1e3/3;s.lagged=t===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-t/o)),Math.abs(i-s.lagged)<Gr?s.lagged=i:n=!0,r+=i-s.lagged}ki(s.element,r===0?s.saved:`0 ${ph(r)}px`),s.shift=r}return n}write(t){const n=Math.round(t);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const t=this.options.scroller;return t?t.scrollTop:window.scrollY}viewportHeight(){const t=this.options.scroller;return t?t.clientHeight:window.innerHeight}limit(){const t=this.options.scroller??document.documentElement;return Math.max(0,t.scrollHeight-this.viewportHeight())}clamp(t){return Math.max(0,Math.min(this.limit(),t))}resolve(t){if(typeof t=="number")return t;const n=this.options.scroller??document,i=typeof t=="string"?n.querySelector(t):t;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-r}}function ki(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function ph(e){return Math.round(e*100)/100}function mh(e,t){switch(t){case"play":if(e.progress()>=1)break;e.reversed()?e.reverse():e.play();break;case"reverse":if(e.progress()<=0)break;e.reversed()?e.play():e.reverse();break;case"pause":e.pause();break;case"resume":e.resume();break;case"restart":e.restart();break;case"reset":e.pause(),e.progress(0);break;case"complete":e.pause(),e.progress(1);break}}function Si(e,t,n,i,s=()=>{}){const r=p=>typeof p=="string"?e.query(p)??void 0:p,o=r(t.trigger)??i;if(!o){s(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger=="string"?` for "${t.trigger}"`:""}`);return}const a=t.scrub===void 0||t.scrub===!1?!1:t.scrub,l=(t.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const f=(p,m)=>()=>{m?.(),n&&!a&&mh(n,l[p]??"none"),t.once&&p===0&&queueMicrotask(()=>h.destroy())},u=t.containerAnimation?bh(e,t.containerAnimation,o,s):void 0;return h=new fe({trigger:o,start:t.start,end:t.end,scrub:a===!1?void 0:a,pin:t.pin===!0?!0:r(t.pin),scroller:r(t.scroller),horizontal:t.horizontal,pinSpacing:t.pinSpacing,onRefresh:t.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:t.snap===void 0?void 0:gh(t.snap,n),markers:t.markers,container:u,onUpdate:(p,m)=>{if(n&&a!==!1&&n.progress(p),t.onUpdate){const d=p<c||m<0?-1:1;t.onUpdate({progress:p,velocity:m,direction:d})}c=p},onEnter:f(0,t.onEnter),onLeave:f(1,t.onLeave),onEnterBack:f(2,t.onEnterBack),onLeaveBack:f(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function gh(e,t){const n=s=>s==="labels"?r=>yh(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?ce(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??V(i.easing):void 0}}function yh(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function bh(e,t,n,i){const s=()=>t.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=e.elementFor(r);return!!o&&o!==n&&o.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=t.scrollTrigger;return r||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>t.progress(),shiftAt:r=>{const o=t.timeline.getStateAtTime(r*t.timeline.duration);let a=0;for(const l of s()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Jr{conditions={};scope;host;items=[];snapshots=new Map;constructor(t,n){this.host=t,this.scope=n}add(t){const n=this.host.collector;this.host.setCollector(this);try{const i=t();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(t){this.items.push(t)}touch(t,n){this.snapshots.has(t)||this.snapshots.set(t,{name:n,style:t.getAttribute("style"),d:t.getAttribute("d")})}revert(){for(const t of this.items.splice(0).reverse())t.revert?t.revert():t.kill?t.kill():t.destroy?.();for(const[t,{name:n,style:i,d:s}]of this.snapshots)i===null?t.removeAttribute("style"):t.setAttribute("style",i),s!==null&&t.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class wh{host;scope;entries=[];listeners=[];scheduled=!1;constructor(t,n){this.host=t,this.scope=n}add(t,n){const i={conditions:t,setup:n,queries:new Map},s=typeof t=="string"?{matches:t}:t;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(s)){const a=window.matchMedia(o);i.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(i),this.update(i),this}revert(){for(const t of this.listeners.splice(0))t();for(const t of this.entries.splice(0))t.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const t of this.entries)this.update(t)}))}update(t){const n={};for(const[o,a]of t.queries)n[o]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===t.key||(t.context?.revert(),t.context=void 0,t.key=s,!i))return;const r=new Jr(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class vh{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(t,n){this.canvas=t,this.context=t.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(t){this.current=Math.max(0,Math.min(this.frames-1,t)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const t of this.images)t&&(t.src="")}resize(){const t=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*t),i=Math.round(this.canvas.clientHeight*t);n>0&&i>0&&(this.canvas.width!==n||this.canvas.height!==i)&&(this.canvas.width=n,this.canvas.height=i),this.drawn=-1,this.draw()}draw(){const t=Math.round(this.current),n=this.nearestReady(t);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,r/i.naturalHeight):Math.min(s/i.naturalWidth,r/i.naturalHeight),a=i.naturalWidth*o,l=i.naturalHeight*o;this.context.clearRect(0,0,s,r),this.context.drawImage(i,(s-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(t){for(let n=0;n<this.frames;n++){if(t-n>=0&&this.ready[t-n])return t-n;if(t+n<this.frames&&this.ready[t+n])return t+n}return-1}pump(){const t=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<t;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=t||this.load(s)}load(t){const n=new Image;n.decoding="async",this.images[t]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[t]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(t-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(t)}}const kh={opacity:0,y:-16},Sh={opacity:0,y:16};async function Th(e,t,n,i){const s=t.collector?.scope??t.root,r=s.ownerDocument??s,o=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof r.startViewTransition=="function")return Mh(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),f=h.length?ui(t,h):void 0,u=i.from!==void 0?Zr(t,i.from,i.shared):[];if(u.length&&i.leave!==!1){const g=i.leave??kh;await c(y=>e.to(u,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const p=[],m=typeof i.to=="function"?i.to():i.to,d=m!==void 0?Zr(t,m,i.shared):[];if(d.length&&i.enter!==!1){const g=i.enter??Sh;p.push(c(y=>e.fromTo(d,g,{...Br(g),duration:a,ease:l,onComplete:y})))}if(f){const g=o().filter(y=>!h.includes(y));g.length&&p.push(c(y=>di(t,n,f,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(p)}function Zr(e,t,n){const i=e.resolveTargets(t).map(s=>e.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):i}async function Mh(e,t,n){const i=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},s=n();s.forEach(a=>i(a,!0));let r=[];await e.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await t.update(),r=n(),r.forEach(a=>i(a,!0))}).finished,r.forEach(a=>i(a,!1))}const Qr={create:(e,t)=>ni(e,ir(t))},to={create:(e,t)=>ni(e,{fn:sr(t)})},eo={create:(e,t)=>ni(e,{fn:rr(t)})},Eh=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),no=.5,Ah="power1.inOut";function xh(e){return e.keyframes!==void 0&&e.keyframes!==null}function Ph(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))Eh.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??no}));const i=Object.entries(t),s=e.duration??no,r=t.easeEach??e.easeEach??Ah;if(i.length>0&&i.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=i.filter(([u])=>u!=="easeEach").map(([u,p])=>({at:Number.parseFloat(u)/100,step:p})).sort((u,p)=>u.at-p.at),h=[];let f=0;for(const{at:u,step:p}of c){const m=Math.max(0,u-f);h.push({...n,ease:r,...p,duration:m*s}),f=u}return h}const o=i.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:s/a};for(const[f,u]of o)c<u.length&&(h[f]=u[c]);l.push(h)}return l}function io(e,t,n,i={}){const s=t.collector?.scope??t.root,r=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(v,w)=>{if(w===void 0)return o[v];if(typeof w=="number")return w;if(w==="max")return a[v];const T=typeof w=="string"?s.querySelector(w):w;if(!T)return o[v];const k=T.getBoundingClientRect(),S=r?.getBoundingClientRect(),E=(v==="x"?i.offsetX:i.offsetY)??i.offset??0;return v==="x"?k.left-(S?.left??0)+o.x-E:k.top-(S?.top??0)+o.y-E},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},f={...o},u=()=>{r?(r.scrollLeft=f.x,r.scrollTop=f.y):window.scrollTo({left:f.x,top:f.y,behavior:"instant"})},p=["wheel","touchstart","keydown"],m=r??window,d=()=>{y.kill(),g()},g=()=>{for(const v of p)m.removeEventListener(v,d)},y=e.to(f,{x:h.x,y:h.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{u(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const v of p)m.addEventListener(v,d,{passive:!0});return y}function _h(e,t,n){const i=e.collector?.scope??e.root,s=typeof t=="string"?[...i.querySelectorAll(t)]:"nodeType"in t?[t]:Array.from(t),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...f}=n,u={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},p={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},d=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const v=p[y].splice(0);v.length>0&&u[y]?.(v)},g=(y,v)=>{if(u[y]){if(p[y].push(v),o!==void 0&&p[y].length>=o)return d(y);m[y]===void 0&&(m[y]=setTimeout(()=>d(y),r*1e3))}};return s.map(y=>Si(e,{...f,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class lt{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(t,n={}){this.stage=t;const i={...n,onWarning:n.onWarning??t.onWarning};if(this.options=i,this.compat=new Et({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return Hh(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return Pr(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=lo(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>ao(s.map(r=>t.elementFor(r))),random:()=>t.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},t.collector?.track(this),t.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=Si(t,s,this,this.firstElement,r=>i.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(t,n,i){return xh(n)?this.record(()=>this.keyframed(t,n,i)):this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.to(r,s,o)))}from(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.from(r,s,o)))}fromTo(t,n,i,s){return this.record(()=>this.tween(t,[n,i],s,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.set(r,s,o)))}addLabel(t,n){return this.record(()=>this.compat.addLabel(t,n))}add(t,n){return this.record(()=>{t.autoplayPending=!1,t.timeline.stop(),t.stage.deactivate(t.timeline),this.compat.add(t.compat,n)})}invalidate(){const t=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(t),this.stage.render(this.timeline),this}call(t,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>t(...n)})})}addPause(t,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(t);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(t,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,t,n)}tweenFromTo(t,n,i={}){this.pause(),this.seek(t);const s=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:s},a=i.duration??Math.abs(r-s)/1e3/(this.timeScale()||1),l=new lt(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(o,{time:r,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(o.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const t=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!t){const i=this.timeline,s=i.direction==="forward"?i.currentTime===0:i.currentTime===i.duration;this.playhead={...this.readPlayhead(),fresh:s&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const t=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),t&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const t=this.timeline.duration;return t>0?this.compat.labelTimes().map(n=>n/t):[]}reversed(){return this.timeline.direction==="reverse"}seek(t){return this.autoplayPending=!1,this.compat.seek(t),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(t){return t===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,t))*this.timeline.duration),this.compat.progress())}timeScale(t){return this.compat.timeScale(t)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(t,n){for(const i of t)for(const s of n??[void 0])this.timeline.removeTracks({target:i,...s!==void 0&&{property:s}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(t){return this.recipe.push(t),t(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const t=Math.max(...this.events.map(n=>n.time));t>this.timeline.duration&&this.timeline.setDuration(t)}readPlayhead(){const t=this.timeline;return{time:t.currentTime,iteration:t.loopIteration,direction:t.direction}}moveTo(t){const n=this.playhead;this.timeline.seek(t),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:t>=n.time?"forward":"reverse"},s={...n,iteration:i.iteration,direction:i.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(s,i,!1),this.options.onUpdate?.()}refreshForRepeat(){const t=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(t,this.timeline.duration))}afterFrame(){const t=this.timeline,n=t.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const r=this.options.yoyo===!0;n&&!r&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=t.currentTime===0&&t.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(t,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:r,passes:o}=jn(s.map(a=>a.time),t,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=s[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(t,n,i,s){const r=this.resolve(t);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const f=(u,p,m)=>{s(u,p,m),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,f),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,i,s)}keyframed(t,n,i){const s=this.resolve(t);if(!s)return;const r=Ph(n);if(r.length===0)return;const o=s.length>1?ri(n.stagger,this.staggerContext(s)):void 0,a=s.map(g=>this.targetFor(g)).filter(g=>g!==void 0),l=o?a.map(g=>[g]):[a],c=o?Ee(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+Xe(n.delay,0)/1e3;let f=1/0,u=-1/0;if(l.forEach((g,y)=>{r.forEach((v,w)=>{const T=w===0?h+c[y]:">";this.tween(g,[v],T,([k],S,E)=>this.compat.to(S,k,E)),f=Math.min(f,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),f===1/0)return;const{onStart:p,onUpdate:m,onComplete:d}=n;p&&this.events.push({time:f,direction:"forward",run:p}),m&&this.ranges.push({start:f,end:u,run:m}),d&&this.events.push({time:u,direction:"forward",run:d})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>ao(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(u=>this.targetFor(u));if(!(t.length>1&&(n.some(Ih)||t.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(t[0]);s(n.map(p=>this.prepare(oo(p,0,u,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=ri(l,this.staggerContext(t)),f=h?Ee(t.length,h).map(u=>u/1e3):t.map(()=>0);t.forEach((u,p)=>{const m=p===0?Xe(c.delay,0)/1e3+f[0]:0,d=p===0?0:f[p]-f[p-1],g=p===0?i:`<${d<0?"-":"+"}${Math.abs(d).toFixed(6)}`,v=n.map((w,T)=>T===a?{...c,delay:m}:w).map(w=>this.prepare(oo(w,p,this.targetFor(u),this.stage.utils,r),[u]));s(v,[u],g)})}targetFor(t){return this.stage.elementFor(t)??this.stage.objectFor(t)}prepare(t,n){const i=o=>this.options.onWarning?.(o),s=o=>this.stage.query(o);let r=t;if(t.motionPath!==void 0){const o=Kc(t.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});r={...r,motionPath:o}}if(t.morphSVG!==void 0){const o=qc(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=lo(this.stage.elementFor(n[0]));if(o===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=gc(r,o)}return r}resolve(t){const n=this.stage.resolveTargets(t);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${$h(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function so(e=new Mr){const t=r=>{const{config:o}=qe(r);return new lt(e,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:f,...u}=r;return u},i=r=>(r&&e.collector?.track(r),r),s={stage:e,ticker:e.ticker,utils:e.utils,getProperty:(r,o)=>{const[a]=e.resolveTargets(r);if(a===void 0)return;const l=e.objectFor(a);return l?l[o]:e.appliedValue(a,o)??wr(o)},scrollTrigger:r=>i(Si(e,r)),scrollBatch:(r,o)=>_h(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>io(s,e,r,o),refreshScroll:()=>{fe.refreshAll(),vi.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new vi({...r,scroller:o}).start())},context:(r,o)=>{const a=new Jr(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new wh(e,r),customEase:Qr.create,customBounce:to.create,customWiggle:eo.create,pageTransition:r=>Th(s,e,o=>new lt(e,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(e.collector?.scope??e.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return i(new vh(a,o))},quickTo:(r,o,a={})=>{const l=new lt(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(f=>{if(!c)return;const u=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:f,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:Ch(a.spring,o,u)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new lt(e,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return io(s,e,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return t(o).to(r,n(o))},from:(r,o)=>t(o).from(r,n(o)),fromTo:(r,o,a)=>t(a).fromTo(r,o,n(a)),set:(r,o)=>t(o).set(r,n(o)),delayedCall:(r,o,a)=>new lt(e).call(o,a,r),killTweensOf:(r,o)=>{const a=e.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...e.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>Vc(r,e.root),splitText:(r,o)=>{const a=e.collector?.scope??e.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return i(th(l,o))},draggable:(r,o)=>i(Gc(s,e,r,o)),getFlipState:r=>ui(e,r),flipFrom:(r,o)=>di(e,a=>new lt(e,a),r,o),flip:(r,o,a)=>{const l=ui(e,r);return o(),di(e,c=>new lt(e,c),l,{targets:r,...a})}};return s}const z=so();function Ch(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Ih(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||ro(e)}function ro(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||yr(n))&&!si.has(t))}function oo(e,t,n,i,s){if(!ro(e))return e;const r={};for(const[o,a]of Object.entries(e))si.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):yr(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function ao(e){const t=e.map(i=>i?.getBoundingClientRect().top);if(t[0]===void 0)return e.length;let n=0;for(const i of t){if(i===void 0||Math.abs(i-t[0])>1)break;n++}return Math.max(1,n)}function lo(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Hh(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function $h(e){return typeof e=="string"?`"${e}"`:String(e)}class Ti{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function co(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class ze{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new At}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=Dt({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(a=>a.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||s?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(o=>o.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=o=>o?.[s]?.[i.id]??o?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new Ti(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)co(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const o=new At;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Dt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Ti(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=jn(s.map(o=>o.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=s[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function Rh(e,t,n={}){const i=new ze(e,{...n,autoplay:!0});return await i.load(t),i}function Fh(e,t={}){return new ze(e,t)}const ho={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},uo="tinyfly-controls-style",Oh=`
|
|
3
3
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
4
4
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
5
5
|
.tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
.tf-fullscreen > svg, .tf-fullscreen > canvas { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - 24px) !important; height: calc(100dvh - 24px) !important; }
|
|
48
48
|
.tf-fullscreen > :not(svg):not(canvas) { grid-column: 2; }
|
|
49
49
|
}
|
|
50
|
-
`;let
|
|
50
|
+
`;let Lh=0;function Bh(e){if(e.getElementById(uo))return;const t=e.createElement("style");t.id=uo,t.textContent=Oh,e.head.appendChild(t)}function fo(e,t,n={}){const i=t.ownerDocument;Bh(i);const s={...ho,...n.labels},r=n.speeds??[.5,1,2],o=()=>e.markers.length>0,a=()=>e.markers.some(H=>H.label!==void 0||e.caption(H.id)!==void 0),l=i.createElement("div");l.className="tf-ctl";const c=i.createElement("div");c.className="tf-ctl-bar",c.setAttribute("role","group");const h=(H,$,F,L="")=>{const O=i.createElement("button");return O.type="button",O.className=`tf-ctl-btn ${L}`.trim(),O.setAttribute("aria-label",H),O.title=H,O.textContent=$,O.addEventListener("click",F),O},f=h(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),u=h(s.prev,"|◀",()=>e.prev()),p=h(s.play,"▶",()=>e.isPlaying?e.pause():d(),"tf-ctl-primary"),m=h(s.next,"▶|",()=>e.next()),d=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},g=i.createElement("input");g.type="range",g.className="tf-ctl-scrub",g.min="0",g.max="1000",g.step="1",g.setAttribute("aria-label",s.scrub),g.addEventListener("input",()=>{e.pause(),e.seek(Number(g.value)/1e3*e.duration)});const y=i.createElement("span");y.className="tf-ctl-step";const v=i.createElement("select");v.className="tf-ctl-speed",v.setAttribute("aria-label",s.speed);for(const H of r){const $=i.createElement("option");$.value=String(H),$.textContent=`${H}×`,H===1&&($.selected=!0),v.appendChild($)}v.addEventListener("change",()=>e.setSpeed(Number(v.value))),c.append(f,u,p,m,g,y),r.length>0&&c.append(v),l.append(c);const w=n.fullscreen?Yh(t,i,s):void 0;w&&c.append(w.button);const T=i.createElement("p");T.className="tf-ctl-caption",T.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(T);const k=i.createElement("div");k.className="tf-ctl-question",k.hidden=!0;const S=i.createElement("span"),E=h(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");k.append(S,E),l.append(k);const _=Dh(e,i,s.scenario,n.scenarioControl??"buttons");_&&l.append(_.element);const M=n.mount;M?M.appendChild(l):t.insertAdjacentElement("afterend",l);const x=()=>{const H=e.isPlaying;p.textContent=H?"❚❚":"▶",p.setAttribute("aria-label",H?s.pause:s.play),p.title=H?s.pause:s.play;const $=e.duration;i.activeElement!==g&&(g.value=String($>0?Math.round(e.currentTime/$*1e3):0));const F=e.markers;if(u.hidden=m.hidden=y.hidden=F.length===0,F.length>0){const L=e.currentMarker,O=L?F.indexOf(L)+1:0;y.textContent=s.stepFormat.replace("{index}",String(O)).replace("{total}",String(F.length)),y.setAttribute("aria-label",`${s.step} ${O} ${s.of} ${F.length}`),u.disabled=e.currentTime<=.5,m.disabled=e.currentTime>=$-.5;const R=e.caption()??"";T.textContent!==R&&(T.textContent=R),T.hidden=!a();const B=!H&&L?.question!==void 0&&Math.abs(e.currentTime-L.time)<1;k.hidden=!B,B&&S.textContent!==L.question&&(S.textContent=L.question)}else k.hidden=!0,T.hidden=!0;_?.update()},A=e.subscribe(x);x();const P=n.keyboardScope??t;!P.hasAttribute("tabindex")&&P.tabIndex<0&&(P.tabIndex=0);const C=new WeakSet,I=H=>{if(C.has(H)||(C.add(H),H.defaultPrevented||H.altKey||H.ctrlKey||H.metaKey))return;const $=H.target;if(!($.tagName==="INPUT"||$.tagName==="SELECT")&&!(H.key===" "&&$.tagName==="BUTTON"))switch(H.key){case" ":H.preventDefault(),e.isPlaying?e.pause():d();break;case"ArrowRight":if(!o())return;H.preventDefault(),e.next();break;case"ArrowLeft":if(!o())return;H.preventDefault(),e.prev();break;case"Home":H.preventDefault(),e.pause(),e.seek(0);break;case"f":case"F":if(!w)return;H.preventDefault(),w.active?w.exit():w.enter();break}};return P.addEventListener("keydown",I),l.addEventListener("keydown",I),{element:l,fullscreen:w&&{get active(){return w.active},enter:w.enter,exit:w.exit},destroy(){w?.destroy(),A(),P.removeEventListener("keydown",I),l.removeEventListener("keydown",I),l.remove()}}}function Dh(e,t,n,i){const s=e.scenarios;if(s.length<2)return;if(i==="slider"){const h=t.createElement("div");h.className="tf-ctl-choice-slider";const f=t.createElement("span");f.textContent=n,f.setAttribute("aria-hidden","true");const u=t.createElement("input");u.type="range",u.min="0",u.max=String(s.length-1),u.step="1",u.setAttribute("aria-label",n);const p=t.createElement("output");return p.setAttribute("aria-hidden","true"),u.addEventListener("input",()=>{const d=s[Number(u.value)];d&&e.setScenario(d.id)}),h.append(f,u,p),{element:h,update:()=>{const d=Math.max(0,s.findIndex(y=>y.id===e.scenario));t.activeElement!==u&&(u.value=String(d));const g=s[d].label;p.textContent!==g&&(p.textContent=g),u.setAttribute("aria-valuetext",g)}}}const r=t.createElement("fieldset");r.className="tf-ctl-choices";const o=t.createElement("legend");o.textContent=n,r.append(o);const a=`tf-ctl-scenario-${++Lh}`,l=s.map(h=>{const f=t.createElement("label");f.className="tf-ctl-choice";const u=t.createElement("input");u.type="radio",u.name=a,u.value=h.id,u.addEventListener("change",()=>{u.checked&&e.setScenario(h.id)});const p=t.createElement("span");return p.textContent=h.label,f.append(u,p),r.append(f),u});return{element:r,update:()=>{for(const h of l){const f=h.value===e.scenario;h.checked!==f&&(h.checked=f)}}}}const Nh='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Wh='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function Yh(e,t,n){const i=t,s=e,r=t.createElement("button");r.type="button",r.className="tf-ctl-btn tf-ctl-fullscreen";let o,a="";const l=()=>{const d=o!==void 0;r.innerHTML=d?Wh:Nh;const g=d?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(d)),e.classList.toggle("tf-fullscreen",d),e.classList.toggle("tf-fullscreen-overlay",o==="overlay")},c=()=>i.fullscreenElement??i.webkitFullscreenElement??null,h=()=>{c()===e?o="native":o==="native"&&(o=void 0),l()},f=d=>{d.key==="Escape"&&m()},u=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",f),l()};async function p(){if(o)return;const d=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(d&&g)try{if(await d(),c()===e){o="native",l();return}}catch{}u()}async function m(){if(o==="overlay")t.removeEventListener("keydown",f),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const d=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===e&&d&&await d()}}return r.addEventListener("click",()=>{o?m():p()}),t.addEventListener("fullscreenchange",h),t.addEventListener("webkitfullscreenchange",h),l(),{button:r,get active(){return o!==void 0},enter:p,exit:m,destroy(){m(),t.removeEventListener("fullscreenchange",h),t.removeEventListener("webkitfullscreenchange",h),r.remove()}}}const po="tinyfly-choices-style",Kh=`
|
|
51
51
|
[data-tinyfly-choose] { cursor: pointer; }
|
|
52
52
|
[data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
|
|
53
|
-
`;function Wh(e){if(e.getElementById(Lr))return;const t=e.createElement("style");t.id=Lr,t.textContent=Nh,e.head.appendChild(t)}function Or(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Wh(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",h=[],c=(m,p)=>{a.hasAttribute(m)||(a.setAttribute(m,p),h.push(m))};c("role","button"),c("tabindex","0");const f=e.scenarios.find(m=>m.id===l)?.label;f!==void 0&&c("aria-label",f),a.setAttribute("aria-pressed","false"),h.push("aria-pressed"),i.push({element:a,attributes:h});const u=()=>e.setScenario(l),d=m=>{const p=m.key;p!=="Enter"&&p!==" "||(m.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",d),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",d)})}const r=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===e.scenario))},o=e.subscribe(r);return r(),()=>{o();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const h of l)a.removeAttribute(h)}}const De=new WeakMap,ai=new WeakMap;let Kh=0;function ae(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function Br(e,t={}){const n=De.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),o=qh(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Yh(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?ae(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const d=await fetch(r);d.ok&&(l=await d.json())}if(l&&o&&(l=Dr(l,o)),!l&&!r&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const h=ae(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),c={playWhenVisible:!0,...t.player,...h&&{captions:h},...ae(e.getAttribute("data-options"),"data-options",e)};Uh(e);const f=new Be(e,c),u={element:e,player:f};if(De.set(e,u),e.setAttribute("data-tinyfly-mounted",""),a){const d=e.getAttribute("data-scenario")??void 0;await f.loadScenarios(a,{initial:a.some(m=>m.id===d)?d:void 0}),ai.set(e,Or(f,e))}else await f.load(l??r);if(e.getAttribute("data-controls")!=="false"){const d=ae(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),p=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");u.controls=Fr(f,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...d,...p?{scenario:p}:{}},mount:void 0}),m?e.insertBefore(u.controls.element,m):e.appendChild(u.controls.element)}return u}function Yh(e,t,n){const i=[];return e.forEach((s,r)=>{const o=ae(s.textContent,"timeline",n);if(!o)return;const a=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(h=>h.id===a)){console.warn(`tinyfly: scenario id "${a}" is used more than once; the later one is skipped`,n);return}const l=s.getAttribute("data-scenario-label")??void 0;i.push({id:a,label:l,timeline:t?Dr(o,t):o})}),i}function Dr(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function qh(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function Nr(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>Br(s,t)))).filter(s=>s!==void 0)}function Xh(e){const t=De.get(e);t&&(ai.get(e)?.(),ai.delete(e),t.controls?.destroy(),t.player.destroy(),De.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Uh(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++Kh}`,t.setAttribute("aria-labelledby",i.id))}function Vh(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{Nr()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class Wr{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new Mt,this.adapterB=new Mt}async load(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=t;this.sequence=n,this.symbolDefs.clear();for(const i of n.symbols??[])i.timeline?.tracks?.length&&this.symbolDefs.set(i.id,i.timeline);this.container.style.width=`${n.canvas.width}px`,this.container.style.height=`${n.canvas.height}px`,n.scenes.length>0&&(this.renderScene(n.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(n.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const n=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=n?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const i=this.sequence.scenes[t];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(t),n)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const s=this.timelineA.getStateAtTime(0);this.adapterA.applyState(s),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const n of t)n.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,n,i){n.innerHTML="",i.clearTargets();const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;transform-origin:center center",s.setAttribute("data-tinyfly","Camera"),n.appendChild(s),i.registerTarget("Camera",s);for(const r of t.elements){if(!r.html)continue;const o=document.createElement("div");o.innerHTML=r.html.trim();const a=o.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(t,n){const i=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const r=s.getAttribute("data-tinyfly-symbol");if(!r)return;const o=this.symbolDefs.get(r);if(!o)return;const a=new Mt;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const h=l.getAttribute("data-tinyfly");h&&a.registerTarget(h,l)}),i.push({adapter:a,timeline:Ft(o)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(t,n){const i=this.nestedByAdapter.get(t);if(i)for(const s of i){const r=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(r>0?n%r:n))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?Ft(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const n=this.options.loop??this.sequence.loop??0;n===-1||n>0&&this.loopIteration<n-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[t],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(n,this.containerB,this.adapterB),this.timelineB=this.createTimeline(n),this.timelineB&&this.timelineB.play(),this.applyTransition(i.type,i.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},i.duration)}applyTransition(t,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,this.containerB.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.containerA;this.containerA=this.containerB,this.containerB=n;const i=this.adapterA;this.adapterA=this.adapterB,this.adapterB=i,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[t];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this._isDestroyed||!this._isPlaying)return;const i=n-(this.lastTime??n);if(this.lastTime=n,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(i);const s=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(s),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(i);const s=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(s),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function zh(e,t,n={}){const i=new Wr(e,{...n,autoplay:!0});return await i.load(t),i}const jh={type:"none",duration:0};function Kr(e){let t=0;for(let n=1;n<e.length;n++)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Wt(e,t){const n=Math.min(1,Math.max(0,t));if(e.length<2||n===1)return e.slice();if(n===0)return e.slice(0,1);let i=Kr(e)*n;const s=[e[0]];for(let r=1;r<e.length;r++){const o=e[r-1],a=e[r],l=Math.hypot(a.x-o.x,a.y-o.y);if(l>=i){const h=l===0?0:i/l;return s.push({x:o.x+(a.x-o.x)*h,y:o.y+(a.y-o.y)*h}),s}s.push(a),i-=l}return s}function Ne(e,t){const n=Wt(e,t);return n[n.length-1]}function li(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function We(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=li(n,t.boil??8);let o=0;const a=()=>{const u=o++;return d=>_e(Fn(`${t.seed??1}:${r}:${u}:${d}`))},l=(u,d)=>(u.next()*2-1)*d,h=u=>{const d=a(),m=e.lineWidth,p=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?p:p*.6,u(d(g));e.lineWidth=m,e.globalAlpha=p},c=(u,d=1)=>{if(u.length<2)return;const m=u.slice(1).map((g,y)=>Math.hypot(g.x-u[y].x,g.y-u[y].y)),p=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,d));h(g=>{const y=[],v=[];if(u.forEach((T,k)=>{y.push({x:T.x+l(g,i*.5),y:T.y+l(g,i*.5)}),k>0&&v.push([g.next()*2-1,g.next()*2-1])}),p<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let w=0;for(let T=1;T<y.length;T++){const k=Gh(y[T-1],y[T],i,v[T-1]),S=m[T-1];if(w+S<=p){e.bezierCurveTo(k[1].x,k[1].y,k[2].x,k[2].y,k[3].x,k[3].y),w+=S;continue}const M=Jh(k,S===0?1:(p-w)/S);e.bezierCurveTo(M[1].x,M[1].y,M[2].x,M[2].y,M[3].x,M[3].y);break}e.stroke()})},f=(u,d,m,p,g=1)=>{h(y=>{const w=y.next()*Math.PI*2,T=Math.PI*2+.15+y.next()*.3,k=[];for(let M=0;M<=14;M++){const C=w+T*M/14,x=l(y,i*.6);k.push({x:u+Math.cos(C)*(m+x),y:d+Math.sin(C)*(p+x)})}const S=Wt(k,g);S.length<2||(Yr(e,S),e.stroke())})};return{line:c,curve(u,d=1){if(u.length<2)return;const m=u[0],p=u[u.length-1],g=Math.hypot(p.x-m.x,p.y-m.y)||1,y=-(p.y-m.y)/g,v=(p.x-m.x)/g;h(w=>{const T={x:l(w,i*.5),y:l(w,i*.5)},k={x:l(w,i*.5),y:l(w,i*.5)},S=l(w,i*Math.min(1.5,Math.max(.3,g/80))),M=u.map((x,_)=>{const P=_/(u.length-1),A=Math.sin(Math.PI*P)*S;return{x:x.x+T.x+(k.x-T.x)*P+y*A,y:x.y+T.y+(k.y-T.y)*P+v*A}}),C=Wt(M,d);C.length<2||(Yr(e,C),e.stroke())})},circle(u,d,m,p=1){f(u,d,m,m,p)},ellipse:f,nudge(u=.5){const d=a()(0);return{x:l(d,i*u),y:l(d,i*u)}}}}function Gh(e,t,n,i){const s=t.x-e.x,r=t.y-e.y,o=Math.hypot(s,r)||1,a=n*Math.min(1.5,Math.max(.3,o/80)),l=-r/o,h=s/o;return[e,{x:e.x+s/3+l*i[0]*a,y:e.y+r/3+h*i[0]*a},{x:e.x+2*s/3+l*i[1]*a,y:e.y+2*r/3+h*i[1]*a},t]}function Jh([e,t,n,i],s){const r=(f,u)=>({x:f.x+(u.x-f.x)*s,y:f.y+(u.y-f.y)*s}),o=r(e,t),a=r(t,n),l=r(n,i),h=r(o,a),c=r(a,l);return[e,o,h,r(h,c)]}function Yr(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length-1;i++){const s={x:(t[i].x+t[i+1].x)/2,y:(t[i].y+t[i+1].y)/2};e.quadraticCurveTo(t[i].x,t[i].y,s.x,s.y)}const n=t[t.length-1];e.lineTo(n.x,n.y)}function le(e,t,n){const i=e.length;if(i<2)return[];const s=[],r=[],o=a=>t+(n-t)*a/(i-1);return e.forEach((a,l)=>{const h=e[Math.max(0,l-1)],c=e[Math.min(i-1,l+1)],f=Math.hypot(c.x-h.x,c.y-h.y)||1,u=o(l)/2,d=-(c.y-h.y)/f*u,m=(c.x-h.x)/f*u;s.push({x:a.x+d,y:a.y+m}),r.push({x:a.x-d,y:a.y-m})}),[...s,...r.reverse()]}function Ke(e,t,n,i){const s=t.length;if(s<2)return;const r=le(t,n,i),o=a=>n+(i-n)*a/(s-1);e.beginPath(),e.moveTo(r[0].x,r[0].y);for(const a of r.slice(1))e.lineTo(a.x,a.y);e.closePath(),e.fill(),t.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(e.beginPath(),e.arc(a.x,a.y,o(l)/2,0,Math.PI*2),e.fill())})}function Et(e,t,n,i,s=16){const r={x:2*t.x-(e.x+n.x)/2,y:2*t.y-(e.y+n.y)/2},o=[];for(let a=0;a<=s;a++){const l=a/s,h=l<.5?{x:e.x+(t.x-e.x)*2*l,y:e.y+(t.y-e.y)*2*l}:{x:t.x+(n.x-t.x)*(2*l-1),y:t.y+(n.y-t.y)*(2*l-1)},c=1-l,f={x:c*c*e.x+2*c*l*r.x+l*l*n.x,y:c*c*e.y+2*c*l*r.y+l*l*n.y};o.push({x:h.x+(f.x-h.x)*i,y:h.y+(f.y-h.y)*i})}return o}function hi(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),h=Math.sin(s);return Array.from({length:a+1},(c,f)=>{const u=r+Math.PI*2*o*f/a,d=Math.cos(u)*n,m=Math.sin(u)*i;return{x:e+d*l-m*h,y:t+d*h+m*l}})}function ci(e,t){return t.look==="pencil"?ec(e,t):Zh(e,t.ink,t.look)}function Ye(e,t,n=!1){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);n&&e.closePath()}function Zh(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,Ke(e,r,o*s,a*s)},line(r,o){r.length<2||(e.strokeStyle=t,e.lineWidth=o*s,e.lineCap="round",e.lineJoin="round",Ye(e,r),e.stroke())},shape(r,o,a){Ye(e,r,!0),(o!==null||i)&&(e.fillStyle=i?t:o,e.fill()),!(a<=0)&&(e.strokeStyle=t,e.lineWidth=a*s,e.lineJoin="round",e.stroke())},ellipse(r,o,a,l,h,c,f){e.beginPath(),e.ellipse(r,o,a,l,h,0,Math.PI*2),(c!==null||i)&&(e.fillStyle=i?t:c,e.fill()),!(f<=0)&&(e.strokeStyle=t,e.lineWidth=f*s,e.stroke())},dot(r,o,a){e.fillStyle=t,e.beginPath(),e.arc(r,o,a*s,0,Math.PI*2),e.fill()},guide(){},guideEllipse(){}}}function Qh(e,t){const n=[e[0]];let i=0;for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o],h=Math.hypot(l.x-a.x,l.y-a.y);let c=t-i;for(;c<h;){const f=c/h;n.push({x:a.x+(l.x-a.x)*f,y:a.y+(l.y-a.y)*f}),c+=t}i=h-(c-t)}const s=e[e.length-1],r=n[n.length-1];return Math.hypot(s.x-r.x,s.y-r.y)>t*.25?n.push(s):n[n.length-1]=s,n}function tc(e,t){const n=e.length;return e.map((i,s)=>{const r=e[Math.max(0,s-1)],o=e[Math.min(n-1,s+1)],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=t(n===1?0:s/(n-1));return{x:i.x-(o.y-r.y)/a*l,y:i.y+(o.x-r.x)/a*l}})}function qr(e){const t=[.6,1.4,2.9].map(i=>({frequency:i*(.8+e.next()*.4),phase:e.next()*Math.PI*2,amount:.5+e.next()*.5})),n=t.reduce((i,s)=>i+s.amount,0);return i=>t.reduce((s,r)=>s+r.amount*Math.sin(Math.PI*2*r.frequency*i+r.phase),0)/n}function ec(e,t){const n=t.pencil??{},i=t.ink,s=n.roughness??Math.max(1,t.lineWidth*.12),r=Math.max(1,Math.round(n.passes??2)),o=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=li(t.time,n.boil??8);let h=0;const c=(m,p,g=!1)=>_e(Fn(`${t.seed}:${g?"paper":l}:${m}:${p}`)),f=(m,p,g,y,v,w=0)=>{if(m.length<2)return;const T=m.slice(1).reduce((P,A,E)=>P+Math.hypot(A.x-m[E].x,A.y-m[E].y),0);let k=Qh(m,Math.max(1.5,Math.min(t.lineWidth*.8,T/24)));if(w>0&&k.length>=2){const[P,A]=[k[k.length-2],k[k.length-1]],E=Math.hypot(A.x-P.x,A.y-P.y)||1;k=[...k,{x:A.x+(A.x-P.x)/E*w,y:A.y+(A.y-P.y)/E*w}]}const S=qr(g),M=qr(g),C=k.length,x=[],_=[];k.forEach((P,A)=>{const E=C===1?0:A/(C-1),H=k[Math.max(0,A-1)],I=k[Math.min(C-1,A+1)],R=Math.hypot(I.x-H.x,I.y-H.y)||1,$=-(I.y-H.y)/R,O=(I.x-H.x)/R,L=S(E)*v,F=Math.min(1,E/.08,(1-E)/.08),B=(.55+.45*Math.sqrt(Math.max(0,F)))*(1+o*M(E)),D=Math.max(.3,p(E)*B/2),X=P.x+$*L,nt=P.y+O*L;x.push({x:X+$*D,y:nt+O*D}),_.push({x:X-$*D,y:nt-O*D})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,Ye(e,[...x,..._.reverse()],!0),e.fill(),e.restore()},u=(m,p)=>{const g=h++,y=c(g,99,!0);if(y.next()<a){const k=(y.next()*2-1)*t.lineWidth*1.4,S=(y.next()*2-1)*t.lineWidth*1.4,M=m.map(C=>({x:C.x+k,y:C.y+S}));f(M,C=>p(C)*1.8,c(g,98,!0),.035,s),f(M,C=>p(C)*.45,c(g,97,!0),.12,s*1.5)}const v=m.slice(1).reduce((k,S,M)=>k+Math.hypot(S.x-m[M].x,S.y-m[M].y),0),w=p(.5)>4&&v>p(.5)*6,T=w?[-.3,.3,0]:[0];for(let k=0;k<r;k++){const S=k===0;T.forEach((M,C)=>{const x=c(g,k*10+C),_=M===0?m:tc(m,A=>p(A)*M*Math.sqrt(Math.sin(Math.PI*A))),P=!S&&M===0?t.lineWidth*(.3+x.next()*.8):0;f(_,A=>p(A)*(w?.5:1)*(S?1:.6),x,S?.85:.45,s*(S?.6:1),P)})}},d=(m,p,g,y,v,w)=>{const k=c(h,50).next()*Math.PI*2;u(hi(m,p,g,y,v,k,1.08,48),()=>w)};return{look:"pencil",ink:i,limb(m,p,g){u(m,y=>p+(g-p)*y)},line(m,p){u(m,()=>p)},shape(m,p,g){p!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=p,Ye(e,m,!0),e.fill(),e.restore()),g>0&&u([...m,m[0]],()=>g)},ellipse(m,p,g,y,v,w,T){w!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=w,e.beginPath(),e.ellipse(m,p,g,y,v,0,Math.PI*2),e.fill(),e.restore()),d(m,p,g,y,v,T)},dot(m,p,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,p,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const p=h++;f(m,()=>Math.max(.6,t.lineWidth*.18),c(p,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,p,g,y,v){if(n.construction===!1)return;const w=h++,T=c(w,0),k=hi(m,p,g,y,v,T.next()*Math.PI*2,1.12,48);f(k,()=>Math.max(.6,t.lineWidth*.18),T,.28,s*1.5)}}}const Xr=["thumb","index","middle","ring","pinky"],N={"thumb.curl":.15,"thumb.across":.15,"index.curl":.12,"middle.curl":.16,"ring.curl":.2,"pinky.curl":.25,spread:.25,turn:0,bend:0,tilt:0,roll:0};function W(e={}){return{...N,...e}}const G=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),Y={relaxed:N,open:W({...G(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:W({...G(0,0,0,0,0),"thumb.across":0,spread:1}),flat:W({...G(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:W({...G(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:W({...G(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:W({...G(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:W({...G(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:W({...G(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:W({...G(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:W({...G(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:W({...G(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:W({...G(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:W({...G(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function Kt(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}const nc={index:{knuckle:[-.16,.47,-.02],bones:[.2,.125,.1],width:.125,fan:-1},middle:{knuckle:[-.055,.49,-.02],bones:[.22,.135,.1],width:.13,fan:-.2},ring:{knuckle:[.05,.475,-.02],bones:[.2,.125,.1],width:.122,fan:.55},pinky:{knuckle:[.15,.43,-.02],bones:[.16,.1,.085],width:.108,fan:1.25}},ic={index:{knuckle:[-.14,.47,-.02],bones:[.2,.125,.1],width:.15,fan:-1},middle:{knuckle:[0,.49,-.02],bones:[.22,.135,.1],width:.155,fan:0},pinky:{knuckle:[.14,.45,-.02],bones:[.19,.115,.095],width:.145,fan:1}},ct={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},sc=[82,100,62],rc=[48,72],oc=3,ac=13,lc=.035,hc=-.075,cc=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],yt=e=>e*Math.PI/180,ui=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],qe=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],fi=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],he=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function bt(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=fi(t,e),o=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];return[e[0]*i+r[0]*s+t[0]*o*(1-i),e[1]*i+r[1]*s+t[1]*o*(1-i),e[2]*i+r[2]*s+t[2]*o*(1-i)]}const Ur=[1,0,0],Vr=[0,1,0],ce=[0,0,1];function uc(e,t,n){const i=yt(e.fan*(oc+ac*n)),s=[Math.sin(i),Math.cos(i),0],r=[Math.cos(i),-Math.sin(i),0],o=[e.knuckle];let a=0;e.bones.forEach((c,f)=>{a+=yt(sc[f]*t),o.push(ui(o[f],qe(bt(s,r,-a),c)))});const l=bt(ce,r,-a),h=o.map((c,f)=>e.width*(1-.14*(f/(o.length-1))));return{joints:o,back:l,widths:h}}function fc(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=he(ui(qe(he(ct.out),1-s),qe(he(ct.across),s))),o=he(fi(ce,r)),a=he(fi(r,o)),l=[[ct.base[0]*i,ct.base[1],ct.base[2]]];let h=0;ct.bones.forEach((u,d)=>{d>0&&(h+=yt(rc[d-1]*e)),l.push(ui(l[d],qe(bt(r,o,h),u)))});const c=bt(a,o,h),f=[...ct.widths,ct.widths[ct.widths.length-1]*.92].map(u=>u*n);return{joints:l,back:c,widths:f}}function Xe(e,t={}){const n={...N,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=yt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),h=1+(l-1)*.7,c=A=>({...A,knuckle:[A.knuckle[0]*h,A.knuckle[1],A.knuckle[2]],width:A.width*l}),f=yt(n.bend??0),u=yt(n.tilt??0),d=yt(90*(n.turn??0)),m=A=>bt(bt(bt(A,Ur,-f),ce,-u),Vr,d),p=Math.cos(o),g=Math.sin(o),y=yt(n.roll??0),v=Math.cos(y),w=Math.sin(y),T=A=>{const E=A[0]*i,H=-A[1]*i,I=(E*v-H*w)*r,R=E*w+H*v;return{x:I*p-R*g,y:I*g+R*p}},k=A=>{const E=T(A),H=Math.hypot(E.x,E.y);return H>1e-6*i?{x:E.x/H,y:E.y/H}:{x:0,y:0}},S={thumb:fc(n["thumb.curl"]??0,n["thumb.across"]??0,l,h)},M=a?ic:nc;for(const A of Xr){const E=M[A];E&&(S[A]=uc(c(E),n[`${A}.curl`]??0,n.spread??0))}const C={};for(const[A,E]of Object.entries(S)){const H=E.joints.map(m),I=m(E.back);C[A]={points:H.map(T),depths:H.map(R=>R[2]*i),widths:E.widths.map(R=>R*i),nail:I[2],back:k(I)}}const x=cc.flatMap(([A,E])=>[m([A*h,E,lc]),m([A*h,E,hc])]),_=dc(x.map(T)),P=x.reduce((A,E)=>A+E[2],0)/x.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:_,palmDepth:P,palmFacing:-m(ce)[2],fingers:C,axes:{up:k(m(Vr)),across:k(m(Ur)),out:k(m(ce))},curls:Object.fromEntries(Object.keys(C).map(A=>[A,n[`${A}.curl`]??0]))}}function zr(e,t){const n=s=>({x:s.x+t.x-e.wrist.x,y:s.y+t.y-e.wrist.y}),i={};for(const[s,r]of Object.entries(e.fingers))i[s]={...r,points:r.points.map(n)};return{...e,wrist:n(e.wrist),palm:e.palm.map(n),fingers:i}}function dc(e){const t=[...e].sort((r,o)=>r.x-o.x||r.y-o.y);if(t.length<3)return t;const n=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x),i=[];for(const r of t){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}const s=[];for(const r of[...t].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],r)<=0;)s.pop();s.push(r)}return[...i.slice(0,-1),...s.slice(0,-1)]}const pc="#f1c9a5",mc="#2f2f33";function Ue(e,t,n,i={},s=0){const r=zr(Xe(n,i),t),o=i.ink??mc,a=i.lineWidth??r.size*.035,l=i.pen??ci(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),h=i.skin??pc,c=i.nails??!0,f=[{depth:r.palmDepth,draw:()=>gc(l,r,h,a)}];for(const u of Object.values(r.fingers)){const d=u.depths.reduce((m,p)=>m+p,0)/u.depths.length;f.push({depth:d,draw:()=>yc(e,l,u,h,a,c)})}if(i.prop){const u=i.prop;f.push({depth:u.depth,draw:()=>u.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const u of[...f].sort((d,m)=>d.depth-m.depth))u.draw();return e.restore(),r}function gc(e,t,n,i){if(e.shape(t.palm,n,i),t.palmFacing<-.3&&e.look!=="silhouette"){const{up:s}=t.axes;for(const[r,o]of Object.entries(t.fingers)){const a=t.curls[r]??0;if(r==="thumb"||a<.5)continue;const l=o.points[0],h=o.widths[0]*.42,c={x:l.x-s.x*h*.2,y:l.y-s.y*h*.2},f=Math.atan2(s.y,s.x),u=Array.from({length:7},(d,m)=>{const p=f-Math.PI/2+Math.PI*m/6;return{x:c.x+Math.cos(p)*h,y:c.y+Math.sin(p)*h}});e.line(u,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(c,f)=>({x:a.x+(r.x*c+s.x*f)*o,y:a.y+(r.y*c+s.y*f)*o}),h=t.side==="left"?-1:1;e.line([l(-.15*h,.36),l(-.04*h,.3),l(.1*h,.33)],i*.5)}}function yc(e,t,n,i,s,r){const{widths:o}=n,a=bc(n.points,2),l=n.points[0],h=a[a.length-1],c=o[0],f=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const p=c/2+s*1.6;e.moveTo(l.x+p,l.y),e.arc(l.x,l.y,p,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,c+2*s,f+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,Ke(e,a,c,f)),t.look==="silhouette"||!r||n.nail<.25)return;const u=a[a.length-2],d=wc({x:h.x-u.x,y:h.y-u.y})??{x:0,y:-1},m={x:h.x-d.x*f*.22+n.back.x*f*.1,y:h.y-d.y*f*.22+n.back.y*f*.1};t.ellipse(m.x,m.y,f*.24*Math.max(.35,n.nail),f*.19,Math.atan2(d.y,d.x),"#f8e3d3",s*.45)}function bc(e,t){let n=e;for(let i=0;i<t;i++){if(n.length<3)return n;const s=[n[0]];for(let r=0;r<n.length-1;r++){const o=n[r],a=n[r+1];r>0&&s.push({x:o.x*.75+a.x*.25,y:o.y*.75+a.y*.25}),r<n.length-2&&s.push({x:o.x*.25+a.x*.75,y:o.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const wc=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},J={lean:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee:0,leftWrist:0,rightWrist:0,leftAnkle:0,rightAnkle:0,leftFootOut:0,rightFootOut:0,mouth:0,smile:.6,mouthWidth:1,blink:0,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0,stretch:1,turn:0,sit:0,spin:0,rise:0};function U(e){return{...J,...e}}const jr={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},q=e=>({...jr,...e}),Q={neutral:jr,happy:q({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:q({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:q({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:q({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:q({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:q({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:q({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:q({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:q({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:q({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:q({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:q({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:q({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:q({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:q({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:q({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:q({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function di(e,t){return{...e,...typeof t=="string"?Q[t]:t}}const Gr={rest:J,wave:U({rightShoulder:135,rightElbow:30,headTilt:6,...Q.happy}),cheer:U({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...Q.joyful}),shrug:U({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...Q.confused,lookX:0,lookY:0}),point:U({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:U({rightShoulder:60,rightElbow:150,headTilt:10,...Q.thinking}),handsOnHips:U({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:U({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...Q.sad}),surprised:U({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...Q.surprised}),crouch:U({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:U({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:U({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...Q.joyful}),sideSplit:U({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...Q.happy}),frontSplit:U({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...Q.happy})},Jr=Object.keys(J);function Yt(e,t,n){const i={...e};for(const s of Jr)i[s]=e[s]+(t[s]-e[s])*n;return i}const pi=24,Zr=4,Qr=28,vc=40;function to(e,t=J,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=h=>h<=vc,o=h=>r(h)?22*i:h,a=r(t.leftShoulder)?t.leftElbow-Qr*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+Qr*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+Zr*n,headTilt:t.headTilt-Zr*.5*n,leftElbow:a,rightElbow:l,leftHip:-pi*i,rightHip:-pi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function kc(e,t=1){return 4*((mi+Ve)*e)*Math.sin(pi*t*Math.PI/180)}function eo(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const no=.12,io=.46,Sc=1-2*no,Tc=.1,Mc=.21,Ec=.19,mi=.24,Ve=.22,so=.12,Ac=.14,ro=.33,oo=.7,ao=.3,xc=.35,Pc=[1.7,1.05],_c=[1.3,.75],lo=[1.45,.85],Cc=[1.15,.75],ho=.06,Hc=.7,Ic=.65,co=.075,Rc=.3,$c=.02,Fc=.012,Lc=12,Oc=.25,ze=90,Bc=.25,Dc=.04,uo=.01,At=e=>Math.min(1,Math.max(0,e??0));function Nc(e,t=1){return Ve*e*t}const gi=-.12,fo=.4,it=e=>e*Math.PI/180,Wc=(e,t)=>({x:t*Math.sin(it(e)),y:Math.cos(it(e))}),po=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),mo=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function Kc(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Ac*n)),a=At(t.turn),l=(so+ro*a)*n,h=i+gi*n,c=l+t.lookX*.08*n,f=t.lookY*.07*n,u=[{x:-.34*n*(1-oo*a),squeeze:1-oo*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-ao*a),squeeze:1-ao*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of u){const v=po(y.open,t.blink);if(v<.2){const S=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,h),e.quadraticCurveTo(y.x+l,h+S,y.x+l+.12*n,h),e.stroke()}else{if(v>1.2){const M=.13*n*v;e.beginPath(),e.ellipse(y.x+l,h,M*.85,M,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const S=v>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+c,h+f,S,S*1.1*Math.min(v,1),0,0,Math.PI*2),e.fill()}const w=mo(h,n,y.brow,v),T=y.x+l-y.side*.13*n*y.squeeze,k=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(k,w),e.lineTo(T,w-t.browTilt*.1*n),e.stroke()}const d=i+fo*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-xc*a),p=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),p<=.05){e.moveTo(l-m,d),e.quadraticCurveTo(l,d+t.smile*.25*n,l+m,d),e.stroke();return}const g=.3*n*p;t.smile>.3?(e.moveTo(l-m,d-.05*n),e.lineTo(l+m,d-.05*n),e.quadraticCurveTo(l,d+g*2,l-m,d-.05*n)):t.smile<-.3?(e.moveTo(l-m,d+g*.6),e.lineTo(l+m,d+g*.6),e.quadraticCurveTo(l,d-g*1.4,l-m,d+g*.6)):e.ellipse(l,d,m*.8,g,0,0,Math.PI*2),e.fill()}function go(e,t){const n=t.height??300,i=Math.min(3,Math.max(.3,e.stretch??1)),s=Math.sqrt(i),r=(t.headSize??2*no)/2,o=t.headSize===void 0?Sc:1-2*r,a=r*n,l=At(e.sit),h=e.leftHip+(-ze-e.leftHip)*l,c=e.leftKnee+(-ze-e.leftKnee)*l,f=e.rightHip+(ze-e.rightHip)*l,u=e.rightKnee+(ze-e.rightKnee)*l,d=t.classic===!0,m=At(e.turn),p=(R,$,O,L,F)=>{const B=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(it($-O)/2)+it(L))),D=Math.max(-1,Math.min(1,Hc+F)),X=m+(1-m)*R*D;return d?{x:0,y:0}:{x:Math.cos(B)*ho*X,y:Math.sin(B)*ho}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let v=0;if(l>0||!d){const R=(F,B,D,X,nt)=>mi*Math.cos(it(B))+Ve*Math.cos(it(B-D))+Math.max(0,p(F,B,D,X,nt).y),$=Math.max(R(-1,h,c,g.left,y.left),R(1,f,u,g.right,y.right)),O=1-At((e.rise??0)/Dc),L=(d?Math.min(1,l/Bc):1)*O;v=(io-$)*L*n*i}const w=-io*n*i+v,T=-o*n*i+v,k=d?0:($c*At(e.turn)+Fc*l)*n*i,S=k===0?[{x:0,y:w},{x:0,y:T}]:Et({x:0,y:w},{x:-k,y:(w+T)/2},{x:0,y:T},1,8),M=T+Tc*n*i,C=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),x=(R,$,O,L,F)=>{const B=Wc(O,L);return{x:R+B.x*F*n,y:$+B.y*F*n}},_=(R,$,O)=>{const L=x(0,w,$,R,mi*i);return{root:{x:0,y:w},joint:L,end:x(L.x,L.y,$-O,R,Ve*i)}},P=(R,$,O)=>{const L={x:R*C,y:M},F=x(L.x,L.y,$,R,Mc*s);return{root:L,joint:F,end:x(F.x,F.y,$+O,R,Ec*s)}},A={left:_(-1,h,c),right:_(1,f,u)},E=(R,$,O,L,F,B)=>{const D=p(R,O,L,F,B);return{x:$.end.x+D.x*n*i,y:$.end.y+D.y*n*i}},H=(R,$,O,L,F)=>x($.end.x,$.end.y,O+L+F,R,co*s),I={left:P(-1,e.leftShoulder,e.leftElbow),right:P(1,e.rightShoulder,e.rightElbow)};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(d?0:Rc,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:w,neckY:T,drop:v,lean:d?e.lean:e.lean+Lc*Math.sin(Math.PI*l),classic:d,legs:A,toes:{left:E(-1,A.left,h,c,g.left,y.left),right:E(1,A.right,f,u,g.right,y.right)},spine:S,arms:I,handTips:{left:H(-1,I.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:H(1,I.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const ue=(e,t)=>t===0?[e.root,e.joint,e.end]:Et(e.root,e.joint,e.end,t);function je(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=e.x-t.x,o=e.y-t.y;return{x:t.x+r*i-o*s,y:t.y+r*s+o*i}}function yo(e,t,n=!0){const i=qc(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?Yc(i,e,s,r):i}function bo(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*it(t),lift:n*e.height}}function Yc(e,t,n,i){const{pivot:s,angle:r,lift:o}=bo(t,n,i),a=u=>{const d=je(u,s,r);return{x:d.x,y:d.y-o}},l=u=>({left:a(u.left),right:a(u.right)}),h={left:Math.max(a(e.feet.left).y,a(e.toes.left).y),right:Math.max(a(e.feet.right).y,a(e.toes.right).y)},c=Math.max(h.left,h.right),f=uo*t.height;return{...e,hip:a(e.hip),neck:a(e.neck),shoulders:l(e.shoulders),elbows:l(e.elbows),hands:l(e.hands),fingertips:l(e.fingertips),knees:l(e.knees),feet:l(e.feet),toes:l(e.toes),feetY:c,grounded:{left:h.left>=c-f,right:h.right>=c-f},handAngle:{left:e.handAngle.left+r,right:e.handAngle.right+r},limbs:{leftArm:e.limbs.leftArm.map(a),rightArm:e.limbs.rightArm.map(a),leftLeg:e.limbs.leftLeg.map(a),rightLeg:e.limbs.rightLeg.map(a),spine:e.limbs.spine.map(a)},head:{...e.head,center:a(e.head.center),angle:e.head.angle+r}}}function qc(e,t){const n=it(e.lean),i=it(t.headTilt),s={x:0,y:e.hipY},r=w=>({x:e.facing*w.x,y:w.y}),o=w=>r(je(w,s,n)),a=w=>o(je({x:w.x,y:w.y+e.neckY},{x:0,y:e.neckY},i)),l=ue(e.arms.left,e.rubber).map(o),h=ue(e.arms.right,e.rubber).map(o),c=(w,T)=>Math.atan2(T.y-w.y,T.x-w.x),f={left:o(e.handTips.left),right:o(e.handTips.right)},u=(w,T)=>{const[k,S]=w.slice(-2),M=e.arms[T],C=c(o(M.end),f[T])-c(o(M.joint),o(M.end));return c(k,S)+C};let d=1/0;for(const[w,T]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const k=mo(gi,1,w,po(T,t.blink));d=Math.min(d,k,k-t.browTilt*.1)}const m={left:r(e.legs.left.end),right:r(e.legs.right.end)},p={left:r(e.toes.left),right:r(e.toes.right)},g={left:Math.max(m.left.y,p.left.y),right:Math.max(m.right.y,p.right.y)},y=Math.max(g.left,g.right),v=uo*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:o({x:0,y:e.neckY}),shoulders:{left:o(e.arms.left.root),right:o(e.arms.right.root)},elbows:{left:o(e.arms.left.joint),right:o(e.arms.right.joint)},hands:{left:o(e.arms.left.end),right:o(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:m,toes:p,feetY:y,grounded:{left:g.left>=y-v,right:g.right>=y-v},fingertips:f,handAngle:{left:u(l,"left"),right:u(h,"right")},limbs:{leftArm:l,rightArm:h,leftLeg:ue(e.legs.left,e.rubber).map(r),rightLeg:ue(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:a({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+i),eyeY:gi,browTopY:d,mouthY:fo,faceX:e.facing*(so+ro*At(t.turn))}}}function wo(e,t={}){return yo(go(e,t),e)}function Xc(e,t,n){return je({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function vo(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>({left:i(r.left),right:i(r.right)});return{...e,hip:i(e.hip),neck:i(e.neck),shoulders:s(e.shoulders),elbows:s(e.elbows),hands:s(e.hands),knees:s(e.knees),feet:s(e.feet),toes:s(e.toes),feetY:e.feetY+n,grounded:{...e.grounded},handAngle:{...e.handAngle},limbs:{leftArm:e.limbs.leftArm.map(i),rightArm:e.limbs.rightArm.map(i),leftLeg:e.limbs.leftLeg.map(i),rightLeg:e.limbs.rightLeg.map(i),spine:e.limbs.spine.map(i)},head:{...e.head,center:i(e.head.center)}}}function ko(e,t,n={},i=0){const s=go(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?yo(s,t,!1):void 0,l=n.sketch?We(e,n.sketch,i):void 0,h=n.sketch&&n.layers?We(e,n.sketch,i):void 0,c=S=>{e.save(),S(),e.restore()},f=S=>{S&&a&&c(()=>S(e,a,i,h))},u=()=>e.scale(s.facing,1),d=()=>{u(),e.translate(0,s.hipY),e.rotate(it(s.lean)),e.translate(0,-s.hipY)},m=(S,M,C)=>{if(l)return M?l.curve(S):l.line(S);if(s.classic){e.beginPath(),e.moveTo(S[0].x,S[0].y);for(const x of S.slice(1))e.lineTo(x.x,x.y);e.stroke();return}Ke(e,S,C[0]*s.lineWidth,C[1]*s.lineWidth)},p=(S,M)=>m(ue(S,s.rubber),s.rubber>0,M),g=S=>{s.classic||m([s.legs[S].end,s.toes[S]],!1,Cc)},y=S=>{if(n.hands&&!s.classic)return w(S);if(s.classic||l)return;const M=s.arms[S].end;e.beginPath(),e.arc(M.x,M.y,Ic*s.lineWidth,0,Math.PI*2),e.fill()};e.save(),e.strokeStyle=r,e.fillStyle=r,e.lineWidth=s.lineWidth,e.lineCap="round",e.lineJoin="round";const v=bo(s,t.spin??0,t.rise??0);(v.angle!==0||v.lift!==0)&&(e.translate(0,-v.lift),e.translate(v.pivot.x,v.pivot.y),e.rotate(v.angle),e.translate(-v.pivot.x,-v.pivot.y));function w(S){const M=n.hands??{},C=s.arms[S].end,x=s.handTips[S],_=n.headFill??"#ffffff";Ue(e,C,M[S]??N,{side:S,angle:Math.atan2(x.x-C.x,C.y-x.y)*180/Math.PI,size:(M.size??co)*s.height*Math.sqrt(s.stretch),skin:M.skin??(_==="none"?void 0:_),ink:r,lineWidth:s.lineWidth*.45,fingers:M.fingers,plump:M.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const T=S=>{c(()=>{d(),p(s.arms[S],_c),y(S)});const M=o.sleeve;M&&a&&c(()=>M(e,a,S,i,h))},k=At(t.turn)>Oc;f(o.behind),c(()=>{u(),p(s.legs.left,lo),g("left"),p(s.legs.right,lo),g("right")}),k&&T("left"),c(()=>{d(),m(s.spine,s.spine.length>2,Pc);const{left:S,right:M}={left:s.arms.left.root,right:s.arms.right.root};if(S.x!==M.x)if(s.classic)m([S,M],!1,[1,1]);else{const C={x:(S.x+M.x)/2,y:S.y-.3*Math.abs(M.x-S.x)};m(Et(S,C,M,1,8),!0,[1.1,1.1])}}),f(o.body),k||T("left"),T("right"),f(o.behindHead),c(()=>{d(),e.translate(0,s.neckY),e.rotate(it(t.headTilt));const S=-s.headRy;e.beginPath(),e.ellipse(0,S,s.headRx,s.headRy,0,0,Math.PI*2);const M=n.headFill??"#ffffff";if(M!=="none"&&(e.fillStyle=M,e.fill()),l){l.ellipse(0,S,s.headRx,s.headRy);const C=l.nudge();e.translate(C.x,C.y)}else e.stroke();e.translate(0,S),e.scale(s.headRx/s.r,s.headRy/s.r),Kc(e,t,s.r,0,r,s.lineWidth)}),f(o.overHead),f(o.front),e.restore(),n.label&&(e.save(),e.fillStyle=r,e.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),e.restore())}function yi(e,t,n){const i={...e};let s=e.walking>0?Yt(i,to(e.walk,i),e.walking):i,r=Uc(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=Yt(s,a.pose,o),a.hands){const l=(h,c)=>c?Kt(h??N,c,o):h;r={left:l(r?.left,a.hands.left),right:l(r?.right,a.hands.right)}}}return e.talk>0&&(s={...s,mouth:Math.max(s.mouth,e.talk*eo(t))}),{pose:s,hands:r}}function So(e,t,n){return yi(e,t,n).pose}const fe=(e,t)=>`hand.${e}.${t}`;function Uc(e){const t=s=>{if(typeof e[fe(s,"spread")]=="number")return Object.fromEntries(Object.keys(N).map(r=>[r,e[fe(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function Vc(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function zc(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...U(e.pose??{}),walk:0,walking:0,talk:0,rubber:t.rubber??0,beat:0,dancing:0},r={};if(t.hands)for(const o of["left","right"]){const a=t.hands[o]??N;for(const l of Object.keys(N))r[fe(o,l)]=a[l]??N[l]}return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s,...r},figureStyle:t,figureDance:e.dance,draw(o,a,l){const h=a.props,c=yi(h,l,e.dance);o.translate(i/2,n),ko(o,c.pose,Vc({...t,rubber:h.rubber},c.hands),l)}}}function jc(e,t,n){const i=e.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...e.props};let r=0,o=0;for(const[h,c]of t.state?.values.get(n)??[])typeof c=="number"&&(h==="x"||h==="motionPathX"?r=c:h==="y"||h==="motionPathY"?o=c:h in s&&(s[h]=c));const a=So(s,t.time,e.figureDance),l=wo(a,{...i,rubber:s.rubber});return{pose:a,joints:vo(l,e.x+r+e.width/2,e.y+o+e.height)}}function Gc(e,t){const n=[];return t.forEach((i,s)=>{const r=s===0?J:n[s-1],o=typeof i.pose=="string"?Gr[i.pose]:{...r,...i.pose};n.push(i.expression?di(o,i.expression):o)}),Jr.filter(i=>n.some(s=>s[i]!==J[i])).map(i=>({id:`${e}-${i}`,target:e,property:i,keyframes:t.map((s,r)=>({time:s.time,value:n[r][i],...s.easing?{easing:s.easing}:{}}))}))}const bi=.5,wi={pataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:W({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:Y.fist,shikhara:Y.thumbsUp,hamsasya:W({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:W({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function Ge(e){return typeof e!="string"?e:e in wi?wi[e]:Y[e]}function To(e,t,n){const i=[];for(const s of e.keys){const r=i[i.length-1],o=!r||s.reset?{pose:t,...n}:r;i.push({beat:s.beat,pose:{...o.pose,...s.pose},left:s.hands?.left?Ge(s.hands.left):o.left,right:s.hands?.right?Ge(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const vi=(e,t)=>(e%t+t)%t;function Jc(e,t,n,i){const s=To(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=vi(t,e.beats);let o=s.length-1;for(let d=0;d<s.length;d++)s[d].beat<=r&&(o=d);const a=s[o],l=s[(o+1)%s.length],h=a.beat<=r?a.beat:a.beat-e.beats,c=l.beat>h?l.beat:l.beat+e.beats,f=c>h?(r-h)/(c-h):0,u=V(l.easing??"ease-in-out")(Math.min(1,Math.max(0,f)));return{pose:Yt(a.pose,l.pose,u),hands:{left:Kt(a.left,l.left,u),right:Kt(a.right,l.right,u)}}}const Zc=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],Qc=["lean","headTilt","lookX","spin"],tu=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Mo(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of Zc){const r=n&&tu.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of Qc)t[i]=-e[i];return t}const eu=e=>Math.min(1,Math.max(-1,(.5-e)*4));function Eo(e,t,n){const i=vi(n,1),s=(1+Math.cos(2*Math.PI*i))/2,r=t.bounce*(t.accent==="up"?1-s:s),o=Math.min(1,Math.max(0,e.turn??0)),a=eu(o);return{...e,leftHip:e.leftHip+a*r/2,rightHip:e.rightHip+r/2,leftKnee:e.leftKnee+a*r,rightKnee:e.rightKnee+r,lean:e.lean+(t.sway??0)*(1-o)*Math.sin(Math.PI*n)}}function Je(e){const t={...J,...e.stance};return e.expression?di(t,e.expression):t}function Ao(e){return{left:e.hands?.left?Ge(e.hands.left):N,right:e.hands?.right?Ge(e.hands.right):N}}function ki(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=Jc(i,n,Je(e),Ao(e));return t.mirror?{pose:Mo(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function Ze(e,t,n={}){const i=typeof e=="string"?xt[e]:e;let s;if(n.move)s=ki(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((f,u)=>f+u.beats,0),a=vi(t,o);let l=0,h=0;for(;h<r.length-1&&a>=l+r[h].beats;)l+=r[h++].beats;const c=a-l;if(s=ki(i,r[h],c),c<bi&&r.length>1&&t>=bi){const f=r[(h-1+r.length)%r.length],u=ki(i,f,f.beats+c),d=V("ease-in-out")(c/bi);s={pose:Yt(u.pose,s.pose,d),hands:{left:Kt(u.hands.left,s.hands.left,d),right:Kt(u.hands.right,s.hands.right,d)}}}}return{...s,pose:Eo(s.pose,i.groove,t)}}function nu(e,t,n={}){return Ze(e,t,n).pose}function Qe(e){return(typeof e=="string"?xt[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const iu={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function xo(e,t,n,i,s,r,o){for(let a=0;a*e.beats<n;a++)for(const l of e.keys){const h=a*e.beats+l.beat,c=t+h;if(!(h>=n||c<r||c>=o))for(const f of l.taps??[])s.push({beat:c,tap:i?iu[f]:f})}}function su(e,t,n,i={}){const s=typeof e=="string"?xt[e]:e,r=[];if(n<=t)return r;if(i.move){const o=s.moves[i.move],a=Math.floor(t/o.beats)*o.beats;xo(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=Qe(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const h of s.routine)xo(s.moves[h.move],l,h.beats,h.mirror,r,t,n),l+=h.beats}}return r.sort((o,a)=>o.beat-a.beat)}function Po(e,t){const n=e.moves[t.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return t.mirror?(To(n,Je(e),Ao(e))[0]?.pose.turn??Je(e).turn??0)>=.5?i:-i:i}function _o(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function tn(e,t,n={}){const i=typeof e=="string"?xt[e]:e,s=_o(i,n),r=s.reduce((c,f)=>c+f.beats,0),o=s.reduce((c,f)=>c+Po(i,f)*f.beats,0),a=Math.floor(t/r);let l=a*o,h=t-a*r;for(const c of s){const f=Math.min(c.beats,h);if(l+=Po(i,c)*f,h-=f,h<=0)break}return l}function ru(e,t,n){const i=_o(e,n),s=[0];let r=0;for(let o=0;r<t;o=(o+1)%i.length)r+=i[o].beats,s.push(Math.min(r,t));return s}const ou=8;function Co(e,t,n){const i=typeof t=="string"?xt[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Qe(i)),o=ru(i,r,n);if(o.every(y=>tn(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=V("ease-in-out"),h=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(r-y)/a))),c=Math.ceil(a*ou),f=a<=0?[]:Array.from({length:c+1},(y,v)=>[v/c*a,r-v/c*a]).flat(),u=[...new Set([...o,...f])].sort((y,v)=>y-v);let d=0;const m=u.map((y,v)=>{if(v>0){const w=u[v-1],T=Math.max(1,Math.ceil((y-w)*16));for(let k=0;k<T;k++){const S=w+(y-w)*k/T,M=w+(y-w)*(k+1)/T;d+=(tn(i,M,n)-tn(i,S,n))*h((S+M)/2)}}return{beat:y,travel:d}}),p=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:p+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function au(e,t,n=0){return(e-n)*t/6e4}function lu(e,t={}){return n=>Ze(e,n,t)}function hu(e,t){const n=t.start??0,i=6e4/t.bpm,s=n+t.beats*i,r=Math.min((t.fade??1)*i,(s-n)/2);return[{id:`${e}-beat`,target:e,property:"beat",keyframes:[{time:n,value:0},{time:s,value:t.beats,easing:"linear"}]},{id:`${e}-dancing`,target:e,property:"dancing",keyframes:[{time:n,value:0},{time:n+r,value:1,easing:"ease-in-out"},{time:s-r,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function cu(e,t,n={}){const i=typeof t=="string"?xt[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Qe(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),h=Array.from({length:l+1},(p,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:Ze(i,y,n)}}),c=(p,g)=>({id:`${e}-${p}`,target:e,property:p,keyframes:h.map(y=>({time:y.time,value:g(y.frame)}))}),u=Object.keys(J).filter(p=>h.some(g=>g.frame.pose[p]!==h[0].frame.pose[p])||h[0].frame.pose[p]!==J[p]).map(p=>c(p,g=>g.pose[p])),d=n.height===void 0?void 0:Co(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(d&&u.push(d),n.hands===!1)return u;const m=[];for(const p of["left","right"])for(const g of Object.keys(N)){const y=v=>v.hands?.[p]?.[g]??N[g];h.some(v=>y(v.frame)!==N[g])&&m.push(c(fe(p,g),y))}return[...u,...m]}const de={type:"back",mode:"out",overshoot:1.1},z="ease-out-cubic",uu={label:"Disco",bpm:120,stance:{leftHip:10,rightHip:10,leftKnee:6,rightKnee:6},expression:{smile:.9,mouth:.15,leftBrow:.3,rightBrow:.3},groove:{bounce:10,accent:"down",sway:2},moves:{point:{label:"The point",beats:2,easing:z,keys:[{beat:0,pose:{rightShoulder:150,rightElbow:0,rightWrist:0,leftShoulder:40,leftElbow:-105,leftWrist:-20,lean:-5,headTilt:8,rightHip:18,leftHip:6,lookX:.6,lookY:-.7},hands:{right:"point",left:"fist"}},{beat:1,pose:{rightShoulder:-30,rightWrist:10,lean:5,headTilt:-6,rightHip:6,leftHip:18,lookX:-.4,lookY:.6}}]},roll:{label:"Roll the arms",beats:2,easing:"linear",keys:[{beat:0,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:18,leftHip:6,lean:-3},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}},{beat:1,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:6,leftHip:18,lean:3}},{beat:1.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}}]},bump:{label:"Bump and clap",beats:4,keys:[{beat:0,pose:{lean:-10,rightHip:22,leftHip:4,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:z},{beat:1,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}},{beat:2,pose:{lean:10,rightHip:4,leftHip:22,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:z},{beat:3,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}}]}},routine:[{move:"point",beats:8},{move:"roll",beats:4},{move:"point",beats:8,mirror:!0},{move:"bump",beats:8}]},fu={label:"Hip hop",bpm:95,stance:{leftHip:14,rightHip:14,leftKnee:20,rightKnee:20,leftShoulder:22,rightShoulder:22,leftElbow:-30,rightElbow:-30,leftFootOut:.15,rightFootOut:.15},expression:"smug",hands:{left:"relaxed",right:"relaxed"},groove:{bounce:18,accent:"down"},moves:{bounce:{label:"Bounce",beats:2,keys:[{beat:0,pose:{leftShoulder:30,rightShoulder:30,leftElbow:-50,rightElbow:-50,lean:-3,headTilt:-5,leftWrist:-20,rightWrist:-20}},{beat:1,pose:{leftShoulder:14,rightShoulder:14,leftElbow:-18,rightElbow:-18,lean:3,headTilt:5,leftWrist:0,rightWrist:0}}]},runningMan:{label:"Running man",beats:2,keys:[{beat:0,reset:!0,pose:{turn:.85,leftHip:-84,leftKnee:-112,leftAnkle:25,rightHip:-26,rightKnee:8,leftShoulder:35,leftElbow:-50,rightShoulder:45,rightElbow:75,lean:6},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftHip:-4,leftKnee:-18,leftAnkle:0,rightHip:4,rightKnee:18,leftShoulder:5,leftElbow:-40,rightShoulder:5,rightElbow:40}},{beat:1,pose:{rightHip:84,rightKnee:112,rightAnkle:25,leftHip:26,leftKnee:-8,rightShoulder:-35,rightElbow:50,leftShoulder:-45,leftElbow:-75}},{beat:1.5,pose:{rightHip:4,rightKnee:18,rightAnkle:0,leftHip:-4,leftKnee:-18,rightShoulder:-5,rightElbow:40,leftShoulder:-5,leftElbow:-40}}]},armWave:{label:"Arm wave",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0},hands:{left:"flat",right:"flat"}},{beat:.5,pose:{leftWrist:45,leftElbow:-15}},{beat:1,pose:{leftWrist:-35,leftElbow:40,leftShoulder:84}},{beat:1.5,pose:{leftWrist:0,leftElbow:-10,leftShoulder:102,headTilt:-8}},{beat:2,pose:{leftElbow:0,leftShoulder:90,rightShoulder:102,headTilt:8}},{beat:2.5,pose:{rightShoulder:84,rightElbow:40,headTilt:0}},{beat:3,pose:{rightElbow:-15,rightWrist:45}},{beat:3.5,pose:{rightElbow:0,rightWrist:-35}}]}},routine:[{move:"bounce",beats:8},{move:"runningMan",beats:8},{move:"armWave",beats:8},{move:"bounce",beats:4}]},du={label:"Breaking (toprock)",bpm:110,stance:{leftHip:14,rightHip:14,leftKnee:14,rightKnee:14,leftShoulder:35,rightShoulder:35,leftElbow:-90,rightElbow:-90},expression:{smile:.3,leftBrow:-.3,rightBrow:-.3,browTilt:-.3},hands:{left:"fist",right:"fist"},groove:{bounce:8,accent:"down"},moves:{toprock:{label:"Toprock (Indian step)",beats:4,keys:[{beat:0,pose:{rightHip:-24,rightKnee:10,leftHip:10,leftShoulder:80,leftElbow:40,rightShoulder:55,rightElbow:-50,lean:6,headTilt:-6},easing:z},{beat:1,reset:!0,pose:{leftHip:18,rightHip:18}},{beat:2,pose:{leftHip:-24,leftKnee:10,rightHip:10,rightShoulder:80,rightElbow:40,leftShoulder:55,leftElbow:-50,lean:-6,headTilt:6},easing:z},{beat:3,reset:!0,pose:{leftHip:18,rightHip:18}}]},kick:{label:"Kick out",beats:2,keys:[{beat:0,pose:{rightHip:72,rightKnee:4,rightAnkle:-20,leftHip:4,lean:-12,leftShoulder:100,leftElbow:20},easing:z},{beat:1,reset:!0}]},freeze:{label:"B-boy stance",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:26,leftElbow:-122,rightShoulder:22,rightElbow:-118,leftHip:18,rightHip:18,leftKnee:6,rightKnee:6,lean:-4,headTilt:10,smile:.6,leftEye:.6,rightEye:.6},easing:de},{beat:2,pose:{headTilt:14,lean:-6}}]}},routine:[{move:"toprock",beats:8},{move:"kick",beats:4},{move:"toprock",beats:8},{move:"kick",beats:4,mirror:!0},{move:"freeze",beats:4}]},pu={label:"Jazz",bpm:130,stance:{leftHip:10,rightHip:10},expression:{mouth:.55,smile:1,mouthWidth:1.2,leftBrow:.6,rightBrow:.6},hands:{left:"spread",right:"spread"},groove:{bounce:6,accent:"up"},moves:{jazzHands:{label:"Jazz hands",beats:2,easing:"linear",keys:[0,.25,.5,.75,1,1.25,1.5,1.75].map((e,t)=>({beat:e,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:t%2?4:26,rightWrist:t%2?26:4,leftHip:16,rightHip:16,leftKnee:e<1?26:8,rightKnee:e<1?26:8},hands:t===0?{left:{...Y.spread,turn:2},right:{...Y.spread,turn:2}}:void 0}))},kickBallChange:{label:"Kick ball change",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:88,rightKnee:0,rightAnkle:55,leftHip:4,lean:-12,leftShoulder:112,rightShoulder:112,leftWrist:15,rightWrist:15},hands:{left:"flat",right:"flat"},easing:z},{beat:1,reset:!0,pose:{rightHip:10,rightKnee:24,rightAnkle:45,leftShoulder:60,rightShoulder:60,leftElbow:-20,rightElbow:-20}},{beat:1.5,pose:{rightAnkle:0,rightKnee:6,leftAnkle:45,leftKnee:20}}]},splitDrop:{label:"Drop into the splits",beats:8,keys:[{beat:0,reset:!0},{beat:2,reset:!0,pose:{leftHip:90,rightHip:90,leftKnee:0,rightKnee:0,leftAnkle:-45,rightAnkle:-45,leftShoulder:125,rightShoulder:125,leftElbow:10,rightElbow:10},easing:"ease-in-out-cubic"},{beat:4,pose:{leftShoulder:95,rightShoulder:95,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8}},{beat:6,reset:!0,pose:{leftHip:30,rightHip:30,leftKnee:60,rightKnee:60,leftShoulder:40,rightShoulder:40},easing:"ease-in-out-cubic"},{beat:7.5,reset:!0}]},jazzSquare:{label:"Jazz square",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:-18,leftHip:8,leftShoulder:38,rightShoulder:46,leftElbow:100,rightElbow:96,lean:4},hands:{left:"pinch",right:"pinch"}},{beat:1,pose:{leftHip:18,rightHip:6,leftShoulder:46,rightShoulder:38,lean:-4}},{beat:2,pose:{rightHip:22,leftHip:6,leftShoulder:38,rightShoulder:46,lean:4}},{beat:3,pose:{leftHip:10,rightHip:10,leftShoulder:46,rightShoulder:38,lean:0}}]}},routine:[{move:"jazzHands",beats:4},{move:"kickBallChange",beats:4},{move:"kickBallChange",beats:4,mirror:!0},{move:"jazzSquare",beats:8},{move:"jazzHands",beats:4},{move:"splitDrop",beats:8}]},mu={label:"K-pop",bpm:125,stance:{leftHip:9,rightHip:9,leftKnee:4,rightKnee:4},expression:"happy",groove:{bounce:5,accent:"down"},moves:{pointCombo:{label:"Point combo",beats:4,easing:de,keys:[{beat:0,reset:!0,pose:{rightShoulder:142,rightElbow:0,leftShoulder:25,leftElbow:-125,headTilt:6,lean:-3,lookX:.6,lookY:-.6},hands:{right:"point",left:"flat"}},{beat:1,pose:{rightShoulder:-38,headTilt:-6,lean:3,lookX:-.3,lookY:.5,rightHip:18}},{beat:2,reset:!0,pose:{leftShoulder:36,leftElbow:-96,rightShoulder:36,rightElbow:-96,leftWrist:20,rightWrist:20},hands:{left:"fist",right:"fist"}},{beat:3,reset:!0,pose:{leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8,leftHip:18,rightHip:18},hands:{left:"flat",right:"flat"}}]},heart:{label:"Big heart, finger heart",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:165,rightShoulder:165,leftElbow:46,rightElbow:46,headTilt:-8,lean:-4},hands:{left:"cupped",right:"cupped"},easing:de},{beat:1,pose:{headTilt:8,lean:4}},{beat:2,reset:!0,pose:{rightShoulder:32,rightElbow:112,rightWrist:10,leftShoulder:20,leftElbow:-30,headTilt:10,leftEye:0,smile:1},hands:{right:"pinch",left:"relaxed"},easing:de},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:z,keys:[{beat:0,reset:!0,pose:{lean:-9,headTilt:11,leftShoulder:55,leftElbow:-112,rightShoulder:55,rightElbow:-112,rightHip:18},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{lean:0,headTilt:0,rightHip:9}},{beat:1,pose:{lean:9,headTilt:-11,leftHip:18}},{beat:1.5,pose:{lean:0,headTilt:0,leftHip:9}}]}},routine:[{move:"pointCombo",beats:8},{move:"isolations",beats:4},{move:"heart",beats:8},{move:"pointCombo",beats:8,mirror:!0},{move:"isolations",beats:4}]},gu={label:"Bollywood",bpm:120,stance:{leftHip:10,rightHip:10},expression:{smile:1,mouth:.3,leftBrow:.4,rightBrow:.4},groove:{bounce:8,accent:"down",sway:3},moves:{lightBulb:{label:"Screw the bulb, pat the dog",beats:2,keys:[{beat:0,reset:!0,pose:{rightShoulder:160,rightElbow:12,rightWrist:-15,leftShoulder:40,leftElbow:-12,leftWrist:-45,lean:-4,rightHip:16,lookX:.5,lookY:-.6},hands:{right:{...Y.cupped,roll:-30},left:{...Y.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...Y.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...Y.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...Y.cupped,roll:30}}}]},thumka:{label:"Thumka",beats:2,keys:[{beat:0,reset:!0,pose:{lean:-11,rightHip:22,leftHip:2,leftKnee:14,rightShoulder:45,rightElbow:-105,leftShoulder:128,leftElbow:18,leftWrist:35,headTilt:10,lookX:-.5},hands:{right:"fist",left:{...Y.open,turn:2}},easing:z},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:z},{beat:1.5,pose:{lean:-4,rightHip:12,headTilt:6}}]},flick:{label:"Cross and flick",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26},hands:{left:"fist",right:"fist"}},{beat:1,pose:{leftShoulder:132,rightShoulder:132,leftElbow:0,rightElbow:0,leftWrist:30,rightWrist:30,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10,stretch:1.03},hands:{left:"spread",right:"spread"},easing:z},{beat:2,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftWrist:0,rightWrist:0,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26,stretch:1},hands:{left:"fist",right:"fist"}},{beat:3,pose:{leftShoulder:62,rightShoulder:62,leftElbow:0,rightElbow:0,leftWrist:35,rightWrist:35,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10},hands:{left:"spread",right:"spread"},easing:z}]}},routine:[{move:"thumka",beats:4},{move:"lightBulb",beats:8},{move:"flick",beats:8},{move:"thumka",beats:4,mirror:!0},{move:"lightBulb",beats:8,mirror:!0}]},yu={label:"Bhangra",bpm:100,stance:{leftShoulder:150,rightShoulder:150,leftElbow:18,rightElbow:18,leftHip:10,rightHip:10},expression:{mouth:.6,smile:1,mouthWidth:1.2,leftBrow:.5,rightBrow:.5},hands:{left:"open",right:"open"},groove:{bounce:12,accent:"down"},moves:{basic:{label:"Bhangra step",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:58,rightKnee:104,rightAnkle:30,leftShoulder:162,rightShoulder:140,headTilt:7}},{beat:.5,reset:!0,pose:{stretch:.98}},{beat:1,reset:!0,pose:{leftHip:58,leftKnee:104,leftAnkle:30,rightShoulder:162,leftShoulder:140,headTilt:-7}},{beat:1.5,reset:!0,pose:{stretch:.98}}]},dhamaal:{label:"Dhamaal (jump, arms up)",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94}},{beat:.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"},{beat:1,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94},hands:{left:"open",right:"open"},easing:"ease-in-quad"},{beat:1.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"}]}},routine:[{move:"basic",beats:8},{move:"dhamaal",beats:4},{move:"basic",beats:8},{move:"dhamaal",beats:4}]},bu={label:"Bharatanatyam",bpm:80,stance:{...{leftHip:42,rightHip:42,leftKnee:82,rightKnee:82,leftFootOut:.3,rightFootOut:.3},leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0,leftWrist:75,rightWrist:75},expression:{smile:.5,leftEye:1.2,rightEye:1.2,leftBrow:.3,rightBrow:.3},hands:{left:"pataka",right:"pataka"},groove:{bounce:0},moves:{tatta:{label:"Tatta adavu (stamps)",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:104,rightAnkle:-18}},{beat:.3,reset:!0,easing:"ease-in-quad",taps:["rightToe","rightHeel"]},{beat:1,reset:!0,pose:{leftHip:48,leftKnee:104,leftAnkle:-18}},{beat:1.3,reset:!0,easing:"ease-in-quad",taps:["leftToe","leftHeel"]}]},natta:{label:"Natta adavu (stretch and look)",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:52,rightKnee:0,rightAnkle:-40,rightShoulder:125,rightWrist:60,leftShoulder:25,leftElbow:-125,leftWrist:0,headTilt:8,lookX:.9,lookY:-.4,lean:-6}},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:52,leftKnee:0,leftAnkle:-40,leftShoulder:125,leftWrist:60,rightShoulder:25,rightElbow:-125,rightWrist:0,headTilt:-8,lookX:-.9,lookY:-.4,lean:6}},{beat:3,reset:!0}]},alapadma:{label:"Alapadma (lotus) to the sky",beats:4,keys:[{beat:0,reset:!0,pose:{rightShoulder:145,rightElbow:20,rightWrist:30,leftShoulder:28,leftElbow:-125,leftWrist:0,lookX:.7,lookY:-.9,headTilt:6},hands:{right:"alapadma",left:"pataka"}},{beat:1,pose:{rightWrist:55,headTilt:9}},{beat:2,reset:!0,pose:{leftShoulder:145,leftElbow:20,leftWrist:30,rightShoulder:28,rightElbow:-125,rightWrist:0,lookX:-.7,lookY:-.9,headTilt:-6},hands:{left:"alapadma",right:"pataka"}},{beat:3,pose:{leftWrist:55,headTilt:-9}}]}},routine:[{move:"tatta",beats:8},{move:"natta",beats:8},{move:"alapadma",beats:8},{move:"tatta",beats:4}]},wu={label:"Charleston",bpm:150,stance:{leftHip:10,rightHip:10,leftKnee:10,rightKnee:10,leftShoulder:30,rightShoulder:30,leftElbow:20,rightElbow:20},expression:{mouth:.4,smile:1,leftBrow:.5,rightBrow:.5},hands:{left:{...Y.spread,turn:2},right:{...Y.spread,turn:2}},groove:{bounce:8,accent:"down"},moves:{basic:{label:"Kick forward, kick back",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:8,rightAnkle:45,leftShoulder:75,rightShoulder:15,leftElbow:30,rightElbow:-10,lean:-7,headTilt:-5},easing:z},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:18,leftKnee:85,leftAnkle:35,rightShoulder:75,leftShoulder:15,rightElbow:30,leftElbow:-10,lean:7,headTilt:5},easing:z},{beat:3,reset:!0}]},twist:{label:"Swivel (heels in, heels out)",beats:2,keys:[{beat:0,reset:!0,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}},{beat:1,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:1.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}}]},kneeCross:{label:"Crossing knees",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,leftElbow:0,rightElbow:0,lean:0,lookY:.6}},{beat:.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}},{beat:1,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,lookY:.6}},{beat:1.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}}]}},routine:[{move:"basic",beats:8},{move:"twist",beats:8},{move:"kneeCross",beats:8},{move:"basic",beats:8,mirror:!0},{move:"twist",beats:4}]},vu={label:"Tap",bpm:120,stance:{turn:.8,leftHip:-3,rightHip:3,leftKnee:-10,rightKnee:10,leftShoulder:12,rightShoulder:12,leftElbow:-40,rightElbow:40,leftWrist:-15,rightWrist:15,lean:4},expression:{smile:.9,mouth:.2,leftBrow:.3,rightBrow:.3,lookY:.3},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:6,accent:"down"},moves:{shuffleBallChange:{label:"Shuffle ball change",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:34,rightKnee:8,rightAnkle:30,leftShoulder:30,rightShoulder:-10},taps:["rightToe"]},{beat:.25,pose:{rightHip:24,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:.5,pose:{rightHip:-8,rightKnee:14,rightAnkle:50,leftAnkle:15,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:.75,pose:{rightHip:3,rightKnee:10,rightAnkle:0,leftAnkle:0},taps:["leftHeel"]},{beat:1,reset:!0,pose:{leftHip:-34,leftKnee:-8,leftAnkle:30,rightShoulder:-30,leftShoulder:10},taps:["leftToe"]},{beat:1.25,pose:{leftHip:-24,leftKnee:-62,leftAnkle:40},taps:["leftToe"]},{beat:1.5,pose:{leftHip:8,leftKnee:-14,leftAnkle:50,rightAnkle:15,leftShoulder:12,rightShoulder:12},taps:["leftToe"]},{beat:1.75,pose:{leftHip:-3,leftKnee:-10,leftAnkle:0,rightAnkle:0},taps:["rightHeel"]}]},timeStep:{label:"Single time step",beats:4,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:8,rightKnee:4,rightAnkle:0,leftShoulder:25,rightShoulder:-20},taps:["rightToe","rightHeel"]},{beat:.5,pose:{rightHip:34,rightKnee:8,rightAnkle:30},taps:["rightToe"]},{beat:.75,pose:{rightHip:22,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:1,pose:{rise:.05,leftAnkle:45,leftKnee:-4,leftHip:-2,rightHip:26,rightKnee:70,stretch:1.03}},{beat:1.25,pose:{rise:0,leftAnkle:0,leftKnee:-14,stretch:1},taps:["leftToe"]},{beat:1.5,pose:{rightHip:4,rightKnee:12,rightAnkle:0,rightShoulder:25,leftShoulder:-20},taps:["rightToe"]},{beat:2,pose:{leftHip:-30,leftKnee:-6,leftAnkle:35},taps:["leftToe"]},{beat:2.25,pose:{leftHip:-4,leftKnee:-12,leftAnkle:0},taps:["leftToe"]},{beat:3,pose:{rightHip:10,rightAnkle:35,rightKnee:18,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:3.5,pose:{rightHip:3,rightKnee:10,rightAnkle:0}}]},heelToe:{label:"Heel toe",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:26,rightKnee:0,rightAnkle:-35,leftShoulder:30,rightShoulder:-20},taps:["rightHeel"]},{beat:.5,pose:{rightHip:-16,rightKnee:24,rightAnkle:55,leftShoulder:-15,rightShoulder:25},taps:["rightToe"]},{beat:1,reset:!0,pose:{leftHip:-26,leftKnee:0,leftAnkle:-35,rightShoulder:-30,leftShoulder:20},taps:["leftHeel"]},{beat:1.5,pose:{leftHip:16,leftKnee:-24,leftAnkle:55,rightShoulder:15,leftShoulder:-25},taps:["leftToe"]}]},crampRoll:{label:"Cramp roll",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:12,rightKnee:26,leftHip:-12,leftKnee:-26}},{beat:.5,pose:{rightAnkle:40,rise:.02},taps:["rightToe"]},{beat:.625,pose:{leftAnkle:40},taps:["leftToe"]},{beat:.75,pose:{rightAnkle:0,rise:0},taps:["rightHeel"]},{beat:.875,pose:{leftAnkle:0},taps:["leftHeel"]},{beat:1,pose:{rightShoulder:135,leftShoulder:125,leftElbow:0,rightElbow:0,leftWrist:0,rightWrist:30,rightKnee:8,leftKnee:-8,rightHip:4,leftHip:-4},hands:{left:{...Y.spread,turn:2},right:{...Y.spread,turn:2}}},{beat:1.75,reset:!0}]}},routine:[{move:"shuffleBallChange",beats:8},{move:"timeStep",beats:4},{move:"timeStep",beats:4,mirror:!0},{move:"heelToe",beats:8},{move:"crampRoll",beats:4}]},xt={disco:uu,hipHop:fu,breaking:du,jazz:pu,kpop:mu,bollywood:gu,bhangra:yu,bharatanatyam:bu,charleston:wu,tap:vu,popping:{label:"Popping (glides, moonwalk)",bpm:100,stance:{leftHip:9,rightHip:9,leftShoulder:16,rightShoulder:16,leftElbow:-24,rightElbow:-24},expression:{smile:.35,leftEye:.85,rightEye:.85,leftBrow:-.2,rightBrow:-.2},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:0},moves:{sideGlide:{label:"Side glide",beats:2,easing:"linear",travel:.2,keys:[{beat:0,reset:!0,pose:{leftHip:11,leftKnee:0,leftAnkle:0,rightHip:36,rightKnee:45,rightAnkle:45,rightShoulder:80,rightElbow:-10,rightWrist:10,leftShoulder:28,leftElbow:18,lean:-2,headTilt:4,lookX:.7},hands:{right:"flat",left:"relaxed"}},{beat:1,pose:{leftHip:27,leftKnee:54,leftAnkle:45,rightHip:-1,rightKnee:0,rightAnkle:0,rightShoulder:74,rightWrist:-10,lean:2}}]},moonwalk:{label:"Moonwalk",beats:2,easing:"linear",travel:-.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:4,headTilt:-4,leftHip:-12,leftKnee:0,leftAnkle:0,rightHip:23,rightKnee:57,rightAnkle:45,leftShoulder:-10,leftElbow:-45,rightShoulder:14,rightElbow:50}},{beat:1,pose:{leftHip:-23,leftKnee:-57,leftAnkle:45,rightHip:12,rightKnee:0,rightAnkle:0,leftShoulder:-14,leftElbow:-50,rightShoulder:10,rightElbow:45}}]},forwardGlide:{label:"Forward glide",beats:2,easing:"linear",travel:.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:2,leftHip:16,leftKnee:0,leftAnkle:0,rightHip:33,rightKnee:59,rightAnkle:45,leftShoulder:12,leftElbow:-40,rightShoulder:-12,rightElbow:40}},{beat:1,pose:{leftHip:-33,leftKnee:-59,leftAnkle:45,rightHip:-16,rightKnee:0,rightAnkle:0,leftShoulder:-12,leftElbow:-40,rightShoulder:12,rightElbow:40}}]},toeStand:{label:"Toe stand",beats:4,keys:[{beat:0,reset:!0,pose:{leftHip:6,rightHip:6,leftKnee:0,rightKnee:0,leftAnkle:65,rightAnkle:65,rightShoulder:150,rightElbow:75,leftShoulder:30,leftElbow:20,headTilt:-10,lookY:.4},hands:{right:"fist",left:"fist"},easing:de},{beat:2,pose:{headTilt:-14,lean:-2}}]}},routine:[{move:"sideGlide",beats:4},{move:"sideGlide",beats:4,mirror:!0},{move:"moonwalk",beats:8},{move:"forwardGlide",beats:8},{move:"toeStand",beats:4}]}},en=e=>Math.min(1,Math.max(0,e));function ku(e){const t={...J,turn:e.view},n=[];for(const i of e.keys){const s=n[n.length-1],r=!s||i.reset?t:s.pose;n.push({at:i.at,pose:{...r,...i.pose},easing:i.easing})}return n}function Su(e){return e-Tu*Math.sin(2*Math.PI*e)/(2*Math.PI)}const Tu=.5;function Mu(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function Ho(e,t){const n=typeof e=="string"?sn[e]:e,i=ku(n),s=en(t);let r=0;for(let f=0;f<i.length;f++)i[f].at<=s&&(r=f);const o=i[r],a=i[Math.min(r+1,i.length-1)],l=a.at>o.at?(s-o.at)/(a.at-o.at):0,h=Yt(o.pose,a.pose,V(a.easing??"ease-in-out")(en(l))),c=Mu(n,s);return c===void 0?{...h,spin:0,rise:0}:{...h,spin:n.spin*Su(c),rise:4*n.height*c*(1-c)}}function Io(e,t,n){const i=typeof e=="string"?sn[e]:e,s=en(t),r=en((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Eu(e,t,n={}){const i=typeof t=="string"?sn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(c,f)=>{const u=f/o;return{time:s+u*r,progress:u,pose:Ho(i,u)}}),h=Object.keys(J).filter(c=>a.some(f=>f.pose[c]!==J[c])).map(c=>({id:`${e}-${c}`,target:e,property:c,keyframes:a.map(f=>({time:f.time,value:f.pose[c]}))}));if(n.height!==void 0&&i.travel!==0){const c=(n.facing??1)<0?-1:1;h.push({id:`${e}-x`,target:e,property:"x",keyframes:a.map(f=>({time:f.time,value:(n.x??0)+c*Io(i,f.progress,n.height)}))})}return h}const Au={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},xu={leftHip:0,leftKnee:0,rightHip:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-172,rightShoulder:172,leftElbow:0,rightElbow:0,lean:0,stretch:1.08,headTilt:0},nn={leftHip:-128,leftKnee:-152,rightHip:128,rightKnee:152,leftAnkle:30,rightAnkle:30,leftShoulder:-78,rightShoulder:78,leftElbow:-48,rightElbow:48,lean:26,stretch:1,headTilt:14},Pu={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},_u={leftHip:-58,leftKnee:-100,rightHip:58,rightKnee:100,leftAnkle:0,rightAnkle:0,leftShoulder:-80,rightShoulder:80,leftElbow:-10,rightElbow:10,lean:20,stretch:.93};function qt(e,t,n,i,s,r=1300){return{label:e,view:1,spin:t,height:n,travel:i,takeoff:.27,landing:.8,duration:r,keys:[{at:0,reset:!0},{at:.16,pose:Au},{at:.27,pose:xu,easing:"ease-out-quad"},...s,{at:.76,pose:Pu},{at:.86,pose:_u,easing:"ease-out-quad"},{at:1,reset:!0}]}}const sn={frontFlip:qt("Front flip (tuck)",360,.56,.35,[{at:.38,pose:nn,easing:"ease-out-cubic"},{at:.64,pose:nn}]),backFlip:qt("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...nn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...nn,lean:18}}]),layout:qt("Back layout (straight body)",-360,.66,-.2,[{at:.4,pose:{leftHip:8,rightHip:-8,leftKnee:0,rightKnee:0,leftAnkle:60,rightAnkle:60,leftShoulder:-178,rightShoulder:178,lean:-18,headTilt:-14}},{at:.64,pose:{leftHip:-4,rightHip:4,lean:-6,headTilt:-4,leftShoulder:-150,rightShoulder:150}}],1400),scissorFlip:qt("Scissor flip",360,.6,.45,[{at:.36,pose:{leftHip:-105,leftKnee:0,rightHip:-40,rightKnee:-20,leftAnkle:50,rightAnkle:50,leftShoulder:-150,rightShoulder:150,leftElbow:0,rightElbow:0,lean:12},easing:"ease-out-cubic"},{at:.52,pose:{leftHip:40,leftKnee:20,rightHip:105,rightKnee:0,leftShoulder:-140,rightShoulder:140}},{at:.66,pose:{leftHip:-30,leftKnee:-20,rightHip:30,rightKnee:20,leftShoulder:-110,rightShoulder:110,lean:6}}]),sideFlip:{label:"Side flip (tuck)",view:0,spin:360,height:.55,travel:.4,takeoff:.27,landing:.8,duration:1300,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:20,rightShoulder:20,lean:-10,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:165,rightShoulder:165,lean:6,stretch:1.08},easing:"ease-out-quad"},{at:.38,pose:{leftHip:105,rightHip:105,leftKnee:135,rightKnee:135,leftShoulder:40,rightShoulder:40,leftElbow:-95,rightElbow:-95,lean:0,stretch:1,headTilt:10},easing:"ease-out-cubic"},{at:.64,pose:{}},{at:.76,pose:{leftHip:20,rightHip:20,leftKnee:20,rightKnee:20,leftAnkle:10,rightAnkle:10,leftShoulder:100,rightShoulder:100,leftElbow:0,rightElbow:0,headTilt:0}},{at:.86,pose:{leftHip:24,rightHip:24,leftKnee:48,rightKnee:48,leftAnkle:0,rightAnkle:0,leftShoulder:70,rightShoulder:70,stretch:.93},easing:"ease-out-quad"},{at:1,reset:!0}]},cartwheel:{label:"Cartwheel",view:0,spin:360,height:.155,travel:.9,takeoff:.2,landing:.86,duration:1600,keys:[{at:0,reset:!0},{at:.12,pose:{leftShoulder:165,rightShoulder:165,rightHip:30,rightKnee:0,lean:-6}},{at:.24,pose:{leftShoulder:172,rightShoulder:172,leftHip:55,rightHip:55,leftKnee:0,rightKnee:0,leftAnkle:40,rightAnkle:40,lean:0}},{at:.75,pose:{}},{at:.9,pose:{leftHip:30,rightHip:12,leftAnkle:0,rightAnkle:0,leftShoulder:150,rightShoulder:150}},{at:1,reset:!0}]},splitLeap:qt("Split leap (grand jeté)",0,.36,.9,[{at:.4,pose:{leftHip:-96,rightHip:-84,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-130,rightShoulder:-105,leftElbow:0,rightElbow:0,lean:4,headTilt:-6},easing:"ease-out-cubic"},{at:.64,pose:{lean:2}}]),toeTouch:{label:"Toe touch (straddle jump)",view:0,spin:0,height:.36,travel:0,takeoff:.27,landing:.8,duration:1200,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:-20,rightShoulder:-20,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:170,rightShoulder:170,stretch:1.06},easing:"ease-out-quad"},{at:.42,pose:{leftHip:104,rightHip:104,leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,stretch:1,headTilt:0},easing:"ease-out-cubic"},{at:.62,pose:{}},{at:.76,pose:{leftHip:12,rightHip:12,leftAnkle:10,rightAnkle:10,leftShoulder:120,rightShoulder:120}},{at:.86,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftAnkle:0,rightAnkle:0,leftShoulder:60,rightShoulder:60,stretch:.94},easing:"ease-out-quad"},{at:1,reset:!0}]},backHandspring:qt("Back handspring",-360,.16,-.7,[{at:.38,pose:{leftHip:10,rightHip:-10,leftKnee:0,rightKnee:0,leftShoulder:-178,rightShoulder:178,lean:-26,headTilt:-20}},{at:.6,pose:{leftHip:-40,rightHip:40,leftKnee:-20,rightKnee:20,lean:6,headTilt:0}}],1200)},Si=.215,Ti=.205,Cu=.065,Ro=.035,Hu=.165,Iu=.155,Ru=12,$u=e=>e*Math.PI/180,lt={turn:0,lean:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function tt(e={}){return{...lt,...e}}const Fu=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Lu(e){const t={};for(const[n,i]of Object.entries(e)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(r,o,a,l)=>`${o}${a==="left"?"right":"left"}${l}`);t[s]=Fu.has(n)?-i:i}return t}function et(e,t){const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n}const $o={rest:lt,wave:tt({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:tt({...et("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:tt({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:tt({...et("arm",{spread:50,bend:-105,elbow:0}),...et("leg",{spread:9}),smile:.8}),think:tt({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:tt({...et("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:tt({...et("leg",{swing:90,knee:90,spread:4}),...et("arm",{swing:25,elbow:45,spread:8})}),kneel:tt({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...et("arm",{swing:20,elbow:30})}),crouch:tt({...et("leg",{swing:75,knee:140,spread:6}),lean:25,...et("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:tt({lean:82,"head.nod":-35,...et("arm",{swing:80,elbow:0,spread:4}),...et("leg",{knee:92,ankle:-88})}),lieDown:tt({roll:90,...et("arm",{spread:8}),"head.nod":0})};function Fo(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-Ro-(Si+Ti)),r=l=>({id:`arm.${l}`,parent:"spine",offset:[(l==="left"?1:-1)*n,-.035,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Hu,width:[1.25,.9]},{length:Iu,width:[.9,.75]}]}),o=l=>({id:`leg.${l}`,parent:null,offset:[(l==="left"?1:-1)*i,0,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Si,width:[1.45,1.05]},{length:Ti,width:[1.05,.85]},{length:Cu,width:[.95,.7]}]}),a=(l,h)=>l[h]??lt[h]??0;return{id:"human",hipHeight:Si+Ti,chains:[o("left"),o("right"),{id:"spine",parent:null,rest:[0,1,0],bones:[{length:s/2,width:[1.7,1.4]},{length:s/2,width:[1.4,1.1]}]},{id:"neck",parent:"spine",rest:[0,1,0],bones:[{length:Ro,width:[1,.9]}]},r("left"),r("right")],head:{on:"neck",size:t},contacts:[...["left","right"].flatMap(l=>[{chain:`leg.${l}`,joint:1},{chain:`leg.${l}`,joint:2},{chain:`leg.${l}`,joint:3},{chain:`arm.${l}`,joint:1},{chain:`arm.${l}`,joint:2}]),{chain:"spine",joint:0},{chain:"spine",joint:1},{chain:"spine",joint:2},{head:"top"}],angles(l,h){if(h.id==="spine"){const p=-a(l,"lean")/2,g=a(l,"side")/2;return[{swing:p,spread:g},{swing:p,spread:g}]}if(h.id==="neck")return[{swing:0,spread:0}];const[c,f]=h.id.split("."),u=p=>a(l,`${c}.${f}.${p}`);if(c==="arm")return[{swing:u("swing"),spread:u("spread")},{swing:u("elbow"),spread:u("bend")}];const d=(h.side??1)*u("rotate"),m=1-Math.cos($u(u("rotate")));return[{swing:u("swing"),spread:u("spread"),yaw:d},{swing:-u("knee"),spread:0,yaw:d},{swing:90+u("ankle")-m*(u("swing")-u("knee")),spread:0,yaw:(Ru+u("toeOut"))*(h.side??1)}]},withAngles(l,h,c){const[f,u]=h.id.split("."),d=m=>`${f}.${u}.${m}`;return f==="arm"?{...l,[d("swing")]:c[0].swing,[d("spread")]:c[0].spread,[d("elbow")]:c[1].swing,[d("bend")]:c[1].spread}:f==="leg"?{...l,[d("swing")]:c[0].swing,[d("spread")]:c[0].spread,[d("knee")]:-c[1].swing}:l},boneScale(l,h){const c=Math.min(3,Math.max(.3,a(l,"stretch")));return h?.id.startsWith("arm.")?Math.sqrt(c):c},headPose(l){const h=Math.min(3,Math.max(.3,a(l,"stretch")));return{yaw:a(l,"head.turn"),nod:a(l,"head.nod"),tilt:a(l,"head.tilt"),sx:1/Math.sqrt(h),sy:Math.sqrt(h)}},landmarks:{neck:["neck",0],"shoulder.left":["arm.left",0],"elbow.left":["arm.left",1],"hand.left":["arm.left",2],"shoulder.right":["arm.right",0],"elbow.right":["arm.right",1],"hand.right":["arm.right",2],"hip.left":["leg.left",0],"knee.left":["leg.left",1],"ankle.left":["leg.left",2],"toe.left":["leg.left",3],"hip.right":["leg.right",0],"knee.right":["leg.right",1],"ankle.right":["leg.right",2],"toe.right":["leg.right",3]}}}function Ou(e){const t=e.split(".");if(t[0]==="hand"&&t.length>=3){const i=`${t[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},r=t.slice(2).join(".");return`${i} · ${s[r]??r.replace(".curl"," curl").replace(".across"," across")}`}if(t.length===3){const[i,s,r]=t;return`${`${s==="left"?"Left":"Right"} ${i}`} · ${{swing:"forward / back",spread:"out / in",elbow:"elbow bend",bend:"forearm out / in",knee:"knee bend",ankle:"foot tilt",toeOut:"toes out / in",rotate:"turn out at the hip"}[r]??r}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[e]??e}const Bu={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Du=Object.fromEntries(Object.entries(Q).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[Bu[n]??n,i]))]));function Nu(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...lt,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:o,human:a,s:l}of r){const h=e[`${o}Shoulder`],c=e[`${o}Elbow`];s[`arm.${a}.spread`]=h*i,s[`arm.${a}.swing`]=l*h*n,s[`arm.${a}.bend`]=c*i,s[`arm.${a}.elbow`]=l*c*n;const f=e[`${o}Hip`],u=e[`${o}Knee`],d=i+l*n;s[`leg.${a}.rotate`]=90*i,s[`leg.${a}.spread`]=0,s[`leg.${a}.swing`]=f*d,s[`leg.${a}.knee`]=u*d,s[`leg.${a}.ankle`]=-(e[`${o}Ankle`]??0),s[`leg.${a}.toeOut`]=(e[`${o}FootOut`]??0)*Wu,s[`eye.${a}`]=e[`${o}Eye`],s[`brow.${a}`]=e[`${o}Brow`],t&&Object.assign(s,Ku(a,t[o]??N,e[`${o}Wrist`]??0,n))}s.lean=e.lean*n,s.side=e.lean*i,s["head.tilt"]=e.headTilt*i,s["head.nod"]=e.headTilt*n;for(const o of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[o]=e[o];return s.lift=e.rise??0,s.roll=e.spin??0,s}const Wu=70;function Ku(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(N))r[`hand.${e}.${o}`]=t[o]??N[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}function Lo(e,t,n={},i){const s=n.length??240,r=9,o=28,a=s-22;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-30)*Math.PI/180),e.fillStyle=n.color??"#f4c542",e.fillRect(o,-r,a-o,2*r),e.fillStyle="#e8b4a0",e.fillRect(a,-r,s-a,2*r),e.fillStyle="#f1dcbf",e.beginPath(),e.moveTo(0,0),e.lineTo(o,-r),e.lineTo(o,r),e.closePath(),e.fill(),e.fillStyle=n.outline??"#2f2f33",e.beginPath(),e.moveTo(0,0),e.lineTo(o*.35,-r*.35),e.lineTo(o*.35,r*.35),e.closePath(),e.fill(),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round",e.lineCap="round";const l=[[{x:0,y:0},{x:o,y:-r},{x:s,y:-r},{x:s,y:r},{x:o,y:r},{x:0,y:0}],[{x:o,y:-r},{x:o,y:r}],[{x:a,y:-r},{x:a,y:r}]];for(const h of l)Do(e,h,i);e.restore()}function Mi(e,t,n={},i){const s=n.length??90,r=n.thickness??34;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-35)*Math.PI/180);const o=-r/2;e.fillStyle=n.color??"#f4a7b9",e.fillRect(0,o,s,r),e.fillStyle="#e9edf2",e.fillRect(s*.45,o,s*.55,r),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round";const a=[{x:0,y:o},{x:s,y:o},{x:s,y:-o},{x:0,y:-o},{x:0,y:o}],l=[{x:s*.45,y:o},{x:s*.45,y:-o}];if(i)i.line(a),i.line(l);else for(const h of[a,l]){e.beginPath(),e.moveTo(h[0].x,h[0].y);for(const c of h.slice(1))e.lineTo(c.x,c.y);e.stroke()}e.restore()}const Oo=150,Yu={pencil:44,eraser:30};function Ei(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=n.scale??1,l=Math.min(1,Math.max(0,n.lift??0)),h=(n.angle??-30)*Math.PI/180,c=i?i.nudge(.6):{x:0,y:0},f=Oo*a*(1+.05*l);l>0&&(e.save(),e.fillStyle=o,e.globalAlpha=.15*l,e.beginPath(),e.ellipse(t.x,t.y,9*a,4*a,0,0,Math.PI*2),e.fill(),e.restore());const u={x:t.x+c.x+6*l*a,y:t.y+c.y-18*l*a},d=Y.pencilGrip,m=M=>{const C=M.fingers.thumb,x=M.fingers.index,_=M.fingers.middle,P=Bo([C.points[3],x.points[3],_.points[3]]),A=Bo([C.points[1],x.points[0]]),E=(C.depths[3]+x.depths[3]+_.depths[3])/3;return{pinch:P,direction:Math.atan2(A.y-P.y,A.x-P.x),depth:E}},p=Xe(d,{size:f}),g=h-m(p).direction,y=Xe(d,{size:f,angle:g*180/Math.PI}),v=m(y),w=Yu[s]*a,T={x:v.pinch.x-Math.cos(h)*w,y:v.pinch.y-Math.sin(h)*w},k={x:u.x-T.x,y:u.y-T.y},S=y.axes.up;qu(e,k,{x:-S.x,y:-S.y},f,n.arm??300*a,r,n.sleeve??"#5b7db1",o),Ue(e,k,d,{size:f,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:v.depth,draw:()=>{e.save(),e.translate(u.x,u.y),e.scale(a,a),s==="eraser"?Mi(e,{x:0,y:0},{angle:h*180/Math.PI,outline:o},i):Lo(e,{x:0,y:0},{angle:h*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const Bo=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function qu(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},h=i*.15,c=(p,g,y)=>({x:t.x+n.x*p+l.x*g*y,y:t.y+n.y*p+l.y*g*y}),f=c(s,0,0),u=p=>{const g=e.createLinearGradient(t.x,t.y,f.x,f.y);return g.addColorStop(0,p),g.addColorStop(.6,p),g.addColorStop(1,zu(p)),g},d=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/Oo),e.beginPath(),e.moveTo(c(-i*.1,-1,h).x,c(-i*.1,-1,h).y),e.lineTo(c(d+4,-1,h*1.1).x,c(d+4,-1,h*1.1).y),e.lineTo(c(d+4,1,h*1.1).x,c(d+4,1,h*1.1).y),e.lineTo(c(-i*.1,1,h).x,c(-i*.1,1,h).y),e.closePath(),e.fillStyle=r,e.fill(),e.strokeStyle=a,e.beginPath(),e.moveTo(c(0,-1,h).x,c(0,-1,h).y),e.lineTo(c(d,-1,h*1.1).x,c(d,-1,h*1.1).y),e.moveTo(c(0,1,h).x,c(0,1,h).y),e.lineTo(c(d,1,h*1.1).x,c(d,1,h*1.1).y),e.stroke();const m=[c(d,-1,h*1.3),c(s,-1,h*1.5),c(s,1,h*1.5),c(d,1,h*1.3)];e.beginPath(),m.forEach((p,g)=>g?e.lineTo(p.x,p.y):e.moveTo(p.x,p.y)),e.closePath(),e.fillStyle=u(o),e.fill(),e.strokeStyle=u(a),e.beginPath(),e.moveTo(m[1].x,m[1].y),e.lineTo(m[0].x,m[0].y),e.lineTo(m[3].x,m[3].y),e.lineTo(m[2].x,m[2].y),e.stroke(),e.restore()}function Xu(e,t,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,r=n.exit??450,o=n.linger??1500,a=[...e].filter(p=>p.path.length>0).sort((p,g)=>p.start-g.start),l=p=>p.tool??"pencil",h=p=>{const g=Math.min(1,Math.max(0,p));return g*g*(3-2*g)},c=(p,g,y)=>({x:p.x+(g.x-p.x)*y,y:p.y+(g.y-p.y)*y}),f=a.find(p=>t>=p.start&&t<=p.end);if(f){const p=f.end-f.start,g=p>0?(t-f.start)/p:1;return{at:Ne(f.path,g),tool:l(f),lift:0,drawing:!0}}const u=[...a].reverse().find(p=>p.end<t),d=a.find(p=>p.start>t),m=p=>p.path[p.path.length-1];if(u&&d&&d.start-u.end<=o){const p=(t-u.end)/(d.start-u.end),g=p<.5?l(u):l(d);return{at:c(m(u),d.path[0],h(p)),tool:g,lift:Math.sin(Math.PI*p),drawing:!1}}if(d&&d.start-t<=s){const p=1-(d.start-t)/s;return{at:c(i,d.path[0],h(p)),tool:l(d),lift:1-h(p),drawing:!1}}if(u&&t-u.end<=r){const p=(t-u.end)/r;return{at:c(m(u),i,h(p)),tool:l(u),lift:h(p),drawing:!1}}return null}function Uu(e,t,n,i=.08,s=32){const r=Math.PI*2*(1+i),o=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+r*a/s;o.push({x:e+Math.cos(l)*n,y:t+Math.sin(l)*n})}return o}function Vu(e){const{path:t}=e,n=t.map(a=>a.x),i=t.map(a=>a.y),s=Math.min(...n),r=Math.min(...i),o=e.hand===!1?void 0:e.hand===!0||e.hand===void 0?{}:e.hand;return{type:"custom",x:s,y:r,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-r),props:{draw:0},draw(a,l,h){const c=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-r),a.strokeStyle=e.color??"#2f2f33",a.lineWidth=e.lineWidth??5,a.lineCap="round",a.lineJoin="round";const f=e.sketch?We(a,e.sketch,h):void 0;c>0&&(f?e.smooth?f.curve(t,c):f.line(t,c):Do(a,Wt(t,c))),o&&c>0&&c<1&&Ei(a,Ne(t,c),o,f)}}}function zu(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return"rgba(0, 0, 0, 0)";const n=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,s,r]=[0,2,4].map(o=>parseInt(n.slice(o,o+2),16));return`rgba(${i}, ${s}, ${r}, 0)`}function Do(e,t,n){if(!(t.length<2)){if(n)return n.line(t);e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);e.stroke()}}const rn=1e5;function ju(e,t,n,i,s=6){const r=[],o=Math.max(1,Math.round(s));for(let a=0;a<=o;a++)r.push({x:a%2===0?e:e+n,y:t+i*a/o});return r}function Ai(e,t,n,i){if(i<=0||t.length===0)return;const s=Wt(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-rn,-rn,2*rn,2*rn),a(),e.clip("evenodd")};for(const a of s)o(()=>{e.moveTo(a.x+r,a.y),e.arc(a.x,a.y,r,0,Math.PI*2)});for(let a=1;a<s.length;a++){const l=s[a-1],h=s[a],c=Math.hypot(h.x-l.x,h.y-l.y);if(c===0)continue;const f=-(h.y-l.y)/c*r,u=(h.x-l.x)/c*r;o(()=>{e.moveTo(l.x+f,l.y+u),e.lineTo(h.x+f,h.y+u),e.lineTo(h.x-f,h.y-u),e.lineTo(l.x-f,l.y-u),e.closePath()})}}function Gu(e,t,n,i,s){e.save(),Ai(e,t,n,i),s(),e.restore()}function Ju(e,t){const n=t.width??40,i=t.hand===!0?{}:t.hand||void 0,s=t.eraser===!1?void 0:t.eraser===!0||t.eraser===void 0?{}:t.eraser;return{...e,props:{...e.props,erase:0},draw(r,o,a){const l=Number(o.props?.erase??0);if(r.save(),Ai(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const h=Ne(t.path,l);i?Ei(r,h,{...i,tool:"eraser"}):Mi(r,h,s)}}}const wt=e=>e*Math.PI/180;function No([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function Wo([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function pe([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const xi=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Ko=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],on=(e,t)=>Wo(No(e,t.swing),t.spread);function Pi(e,t){const n=pe(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function _i(e,t,n){const i=n.height,s=wt(90*(t.turn??0)),o=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],a={};for(const E of e.chains){const H=E.parent?a[E.parent]:void 0;if(E.parent&&!H)throw new Error(`body plan ${e.id}: chain ${E.id} comes before its parent ${E.parent}`);const I=E.at??(H?H.joints3.length-1:0),R=H?H.joints3[I]:o,$=H?H.frames[Math.max(0,I-1)]:{swing:0,spread:0},O=E.offset?xi(R,on(Ko(E.offset,i),$)):R,L=E.side??1,F=e.boneScale?.(t,E)??1,B=e.angles(t,E),D=[O],X=[];let nt=$.swing,kt=$.spread;E.bones.forEach((Pt,un)=>{const ge=B[un]??{swing:0,spread:0};nt+=wt(ge.swing),kt+=wt(ge.spread)*L,X.push({swing:nt,spread:kt});const Fi=pe(on(E.rest,{swing:nt,spread:kt}),wt(ge.yaw??0));D.push(xi(D[un],Ko(Fi,Pt.length*i*F)))}),a[E.id]={joints3:D,frames:X}}const l=a[e.head.on],h=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=l.frames[l.frames.length-1],f=e.head.size/2*i,u=f*h.sx,d=f*h.sy,m=E=>on(pe(No(Wo(E,-wt(h.tilt)),-wt(h.nod)),wt(h.yaw)),c),p=xi(l.joints3[l.joints3.length-1],m([0,d,0])),g={};for(const E of e.chains){const{joints3:H,frames:I}=a[E.id],R=H.map($=>Pi($,s));g[E.id]={id:E.id,joints3:H,frames:I,points:R.map($=>$.point),depths:R.map($=>$.depth)}}const y=Pi(p,s),v=[[1,0,0],[0,1,0],[0,0,1]].map(E=>pe(m(E),s)),w=Pi(o,s).point,T=wt(t.roll??0),k=E=>{const H=E.x-w.x,I=E.y-w.y;return{x:w.x+H*Math.cos(T)-I*Math.sin(T),y:w.y+H*Math.sin(T)+I*Math.cos(T)}},S=([E,H,I])=>[E*Math.cos(T)+H*Math.sin(T),-E*Math.sin(T)+H*Math.cos(T),I];for(const E of Object.values(g))E.points=E.points.map(k);const M={center:k(y.point),depth:y.depth,rx:u,ry:d,angle:0,axes:v.map(S)},C=M.axes[1];M.angle=Math.atan2(C[0],C[1]);const x=E=>{if("head"in E)return{x:M.center.x+C[0]*d,y:M.center.y-C[1]*d};const H=g[E.chain];return H.points[Math.min(E.joint,H.points.length-1)]};let _=0;(n.contact??"ground")==="ground"&&(_=-Math.max(...e.contacts.map(E=>x(E).y))),_-=(t.lift??0)*i;const P=E=>({x:E.x,y:E.y+_});for(const E of Object.values(g))E.points=E.points.map(P);M.center=P(M.center);const A=e.contacts.map(E=>({spec:E,point:x(E)}));return{height:i,view:s,chains:g,head:M,hip:P(k(w)),contacts:A,groundY:Math.max(...A.map(E=>E.point.y))}}function Yo(e,[t,n,i]){const[s,r,o]=e.axes,a=[s[0]*t*e.rx+r[0]*n*e.ry+o[0]*i*e.rx,s[1]*t*e.rx+r[1]*n*e.ry+o[1]*i*e.rx,s[2]*t*e.rx+r[2]*n*e.ry+o[2]*i*e.rx],l=Math.hypot(t,n,i)||1,h=(s[2]*t+r[2]*n+o[2]*i)/l;return{point:{x:e.center.x+a[0],y:e.center.y-a[1]},depth:e.depth+a[2],facing:h}}const an=e=>e*180/Math.PI,Xt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Ci=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],me=e=>Math.hypot(e[0],e[1],e[2]),Hi=e=>{const t=me(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},ln=e=>Math.atan2(Math.sin(e),Math.cos(e));function qo(e){const[t,n,i]=Hi(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function Zu(e,t,n,i,s){const r=e.chains.find(_=>_.id===n);if(!r)throw new Error(`reach: no chain ${n} in ${e.id}`);if(r.bones.length<2||r.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!e.withAngles)throw new Error(`reach: the ${e.id} plan cannot set angles`);const o=_i(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],h=me(Xt(a.joints3[1],a.joints3[0])),c=me(Xt(a.joints3[2],a.joints3[1])),f=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},u=Xt(i,l),d=Math.min(h+c-1e-6,Math.max(Math.abs(h-c)+1e-6,me(u))),m=Hi(u),p=r.parent!==null,g=on(r.pole??(p?[0,-.35,-1]:[0,0,1]),f);let y=Xt(g,[m[0]*Ci(g,m),m[1]*Ci(g,m),m[2]*Ci(g,m)]);me(y)<1e-6&&(y=pe([1,0,0],0)),y=Hi(y);const v=(h*h+d*d-c*c)/(2*h*d),w=Math.sqrt(Math.max(0,1-v*v)),T=[l[0]+h*(v*m[0]+w*y[0]),l[1]+h*(v*m[1]+w*y[1]),l[2]+h*(v*m[2]+w*y[2])],k=[l[0]+m[0]*d,l[1]+m[1]*d,l[2]+m[2]*d],S=r.side??1,M=qo(Xt(T,l)),C=qo(Xt(k,T)),x=[{swing:an(ln(M.swing-f.swing)),spread:an(ln(M.spread-f.spread))*S},{swing:an(ln(C.swing-M.swing)),spread:an(ln(C.spread-M.spread))*S}];return e.withAngles(t,r,x)}const Qu=.34,vt=.12,ht=-.4,ut=(e,t,n)=>e[t]??n,tf=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),ef=.45,nf=.35,sf=.7;function hn(e,t,n){const i=d=>Math.sqrt(Math.max(0,1-d.x*d.x-d.y*d.y)),s=Yo(e,[n.x,n.y,i(n)]).facing,r=e.axes[2],o=Math.atan2(r[0],r[2]),a=Math.cos(o),l=a>=0?1:-1,h=l*Math.max(nf,Math.abs(a)),c=l*Math.max(sf,Math.abs(a)),f=Math.cos(e.angle),u=Math.sin(e.angle);return{facing:s,points:t.map(d=>{const m=ef*Math.sin(o)+n.x*h+(d.x-n.x)*c,p=d.y+r[1]*i(d),g=m*e.rx,y=p*e.ry;return{x:e.center.x+g*f+y*u,y:e.center.y+g*u-y*f}})}}const cn=(e,t,n,i=12)=>Array.from({length:i+1},(s,r)=>{const o=r/i,a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}}),Ii=(e,t,n,i,s=16)=>Array.from({length:s},(r,o)=>{const a=Math.PI*2*o/s;return{x:e+Math.cos(a)*n,y:t+Math.sin(a)*i}}),Xo=.05;function rf(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,v)=>hn(t,y,v).points,o=(y,v)=>hn(t,[],{x:y,y:v}).facing,a=ut(n,"smile",0),l=ut(n,"blink",0),h=ut(n,"lookX",0),c=ut(n,"lookY",0),f=ut(n,"browTilt",0);for(const y of[1,-1]){const v=y===1?"left":"right",w=Qu*y;if(o(w,vt)<Xo)continue;const T={x:w,y:vt},k=tf(ut(n,`eye.${v}`,1),l);if(k<.2){const x=a>.5?.12:-.06;e.line(r(cn({x:w-.12,y:vt},{x:w,y:vt+x},{x:w+.12,y:vt}),T),s)}else{if(k>1.2){const A=.13*k;e.shape(r(Ii(w,vt,A*.85,A),T),"#ffffff",s)}const x=k>1.2?.075:.1,_=w+h*.08,P=vt-c*.07;e.shape(r(Ii(_,P,x,x*1.1*Math.min(k,1)),T),e.ink,0)}const S=vt+.3+ut(n,`brow.${v}`,0)*.14+Math.max(0,k-1)*.12,M={x:w+y*.13,y:S},C={x:w-y*.13,y:S+f*.1};e.line(r([M,{x:(M.x+C.x)/2,y:(M.y+C.y)/2},C],{x:w,y:S}),s)}const u={x:0,y:ht};if(o(0,ht)<-Xo)return;const d=.25*Math.max(.3,ut(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,ut(n,"mouth",0)));if(m<=.05){e.line(r(cn({x:-d,y:ht},{x:0,y:ht-a*.25},{x:d,y:ht}),u),s);return}const p=.3*m;let g;if(a>.3){const y=ht+.05;g=[...cn({x:d,y},{x:0,y:ht-p*2},{x:-d,y})]}else if(a<-.3){const y=ht-p*.6;g=[...cn({x:d,y},{x:0,y:ht+p*1.4},{x:-d,y})]}else g=Ii(0,ht,d*.8,p);e.shape(r(g,u),e.ink,0)}function of(e={}){const t=(e.proportions??"bold")==="bold",n=e.figure??"fluid",i=e.look??"clean",s=e.height??300,r=n==="stick";return{plan:e.plan??Fo({headSize:e.headSize??(t?.3:.24),shoulderWidth:r?0:e.shoulderWidth??.06,hipWidth:r?0:e.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:e.lineWidth??s*(t?.045:.022),ink:e.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:e.skin??(i==="pencil"?"none":"#ffffff"),seed:e.seed??1,pencil:e.pencil??{},layers:e.layers??{},contact:e.contact??"ground",hands:e.hands??"dot",handStyle:e.handStyle??"glove",handSize:e.handSize??(e.handStyle==="natural"?.14:.17)}}function af(e,t,n,i){const{point:s,facing:r}=Yo(e,[t,n,i]);return{point:s,facing:r}}const Ri=e=>e.rest[1]<-.5,lf=.3;function hf(e,t,n){return e.figure==="stick"?Ri(t)?n.slice(0,3):n:Ri(t)&&n.length>=3?Et(n[0],n[1],n[2],lf):n.length===3?Et(n[0],n[1],n[2],1):n}function $i(e,t){const n=e.plan.id==="human"?{...lt,...t}:t,i=_i(e.plan,n,{height:e.height,contact:e.contact}),s={},r={},o={},a=.01*e.height;e.plan.chains.forEach(d=>{const m=i.chains[d.id];s[d.id]=m.points;const p=m.depths.reduce((w,T)=>w+T,0)/m.depths.length,g=d.parent?i.chains[d.parent]:void 0,y=g?g.depths[d.at??g.depths.length-1]:0,v=p-y;o[d.id]=Math.abs(v)<a?0:v,r[d.id]={points:hf(e,d,m.points),depth:p}}),r.head={points:[i.head.center],depth:i.head.depth},o.head=0;const l=[...e.plan.chains.map(d=>d.id),"head"],h=[...l].sort((d,m)=>o[d]-o[m]||l.indexOf(d)-l.indexOf(m)),c={hip:i.hip};for(const[d,[m,p]]of Object.entries(e.plan.landmarks??{})){const g=i.chains[m]?.points;g&&(c[d]=g[Math.min(p,g.length-1)])}const f={};for(const[d,m]of Object.entries(c))f[d]=m.y>=i.groundY-.01*e.height;const u={height:e.height,lineWidth:e.lineWidth,turn:n.turn??0,points:c,chains:s,parts:r,head:i.head,groundY:i.groundY,grounded:f};return{skeleton:i,joints:u,order:h}}function Uo(e,t){return $i(e,t).joints}function cf(e,t,n){const{head:i}=n;e.guideEllipse(i.center.x,i.center.y,i.rx*1.03,i.ry*1.03,i.angle);const s=Array.from({length:13},(l,h)=>({x:0,y:-.95+1.9*h/12})),r=Array.from({length:13},(l,h)=>({x:-.95+1.9*h/12,y:.12})),o=hn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(hn(i,r,{x:0,y:.12}).points),e.guide(n.chains.spine??[]);const a=t.lineWidth*.9;for(const l of["shoulder.left","shoulder.right","elbow.left","elbow.right","hip.left","hip.right","knee.left","knee.right"]){const h=n.points[l];h&&e.guideEllipse(h.x,h.y,a,a,0)}}function uf(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:d}=i,m=n.skin==="none"?null:n.skin;t.ellipse(d.center.x,d.center.y,d.rx,d.ry,d.angle,m,o),t.look!=="silhouette"&&rf(t,d,r,o);return}const a=n.plan.chains.find(d=>d.id===s),l=i.chains[s],h=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const d=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:h;t.line(d,o);return}const c=(d,m)=>[a.bones[d].width[0]*o,a.bones[m].width[1]*o];if(Ri(a)){const[d,m]=c(0,1);if(t.limb(h,d,m),a.bones.length>=3)t.limb([l[2],l[3]],a.bones[2].width[0]*o,a.bones[2].width[1]*o);else if(n.hands==="cartoon"&&s.startsWith("arm."))ff(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const p=l[l.length-1];t.dot(p.x,p.y,o*.62)}return}if(s==="spine"){const d=i.points["hip.left"],m=i.points["hip.right"];d&&m&&Math.hypot(d.x-m.x,d.y-m.y)>.5&&t.limb([d,m],o*1.3,o*1.3);const[p,g]=c(0,a.bones.length-1);t.limb(h,p,g);const y=i.points["shoulder.left"],v=i.points["shoulder.right"];y&&v&&Math.hypot(y.x-v.x,y.y-v.y)>.5&&t.limb(Et(y,l[l.length-1],v,1,10),o*1.15,o*1.15);return}const[f,u]=c(0,a.bones.length-1);t.limb(h,f,u)}function Vo(e,t){const n=`hand.${t}.`,i={};for(const[o,a]of Object.entries(e))o.startsWith(n)&&(i[o.slice(n.length)]=a);const s=e.turn??0,r=t==="right"?1-s:1+s;return{...N,...i,turn:r+(i.turn??0)}}function ff(e,t,n,i,s,r){const o=i[i.length-1],a=i[i.length-2],l=Math.atan2(o.x-a.x,-(o.y-a.y))*180/Math.PI;Ue(e,o,Vo(r,s),{size:n.handSize*n.height,side:s,angle:l,pen:t,skin:n.skin==="none"?"#ffffff":n.skin,fingers:n.handStyle==="natural"?5:4,plump:n.handStyle==="natural"?1.15:1.6,lineWidth:n.lineWidth*.3})}function zo(e,t,n,i=0){const s=t.plan.id==="human"?{...lt,...n}:n,{joints:r,order:o}=$i(t,s),a=ci(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:i,pencil:t.pencil}),l=h=>{h&&(e.save(),h(e,r,a,i),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&cf(a,t,r),l(t.layers.behind);for(const h of o){const c=t.layers.parts?.[h];l(c?.under),uf(e,a,t,r,h,s),l(c?.over)}l(t.layers.front),e.restore()}function df(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}function pf(e,t,n,i){const s=e.plan.id==="human"?{...lt,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=$i(e,s),a=_i(e.plan,{...s,roll:0},{height:e.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,h=i.x-o.hip.x,c=i.y-o.hip.y,f=a.hip.x+h*Math.cos(-l)-c*Math.sin(-l),u=a.hip.y+h*Math.sin(-l)+c*Math.cos(-l),d=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],p=Math.cos(d),g=Math.sin(d);r=[f*p-m*g,-u,f*g+m*p]}return Zu(e.plan,s,n,r,{height:e.height})}function mf(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?lt:{};return{type:"custom",x:e.x-n/2,y:e.y-i,width:n,height:i,props:{...s,...e.pose},character:t,draw(r,o,a){r.translate(n/2,i),zo(r,t,o.props,a)}}}function jo(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>Object.fromEntries(Object.entries(r).map(([o,a])=>[o,a.map(i)]));return{...e,points:Object.fromEntries(Object.entries(e.points).map(([r,o])=>[r,i(o)])),chains:s(e.chains),parts:Object.fromEntries(Object.entries(e.parts).map(([r,o])=>[r,{...o,points:o.points.map(i)}])),head:{...e.head,center:i(e.head.center)},groundY:e.groundY+n}}function gf(e,t,n){const i=e.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...e.props};let r=0,o=0;for(const[l,h]of t.state?.values.get(n)??[])typeof h=="number"&&(l==="x"||l==="motionPathX"?r=h:l==="y"||l==="motionPathY"?o=h:l in s&&(s[l]=h));const a=Uo(i,s);return{pose:s,joints:jo(a,e.x+r+e.width/2,e.y+o+e.height)}}function yf(e,t,n=lt){const i=[];return t.forEach((r,o)=>{const a=o===0?n:i[o-1],l=typeof r.pose=="string"?$o[r.pose]:void 0;i.push(l?{...l,turn:a.turn??0}:{...a,...r.pose})}),Object.keys(n).filter(r=>i.some(o=>(o[r]??n[r])!==n[r])).map(r=>({id:`${e}-${r}`,target:e,property:r,keyframes:t.map((o,a)=>({time:o.time,value:i[a][r]??n[r],...o.easing?{easing:o.easing}:{}}))}))}const bf=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function wf(e={}){const t=e.shirt??"#e2493b",n=e.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,h)=>{const c=a.parts[`leg.${h}`].points;l.shape(le(c,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const h=a.chains.spine,c=h[0],f=h[h.length-1],u={x:c.x-(f.x-c.x)*.25,y:c.y-(f.y-c.y)*.25};l.shape(le([u,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,h)=>{const c=a.parts[`arm.${h}`].points,f=c[0],u=a.chains.spine[a.chains.spine.length-1],m=[{x:f.x+(u.x-f.x)*.45,y:f.y+(u.y-f.y)*.45},...bf(c,0,.45)],p=le(m,a.height*.085,a.height*.06),g=m.length,y=p.slice(0,g),v=p.slice(g).reverse();l.shape(p,t,0);const w=S=>Math.hypot(S[1].x-u.x,S[1].y-u.y),[T,k]=w(y)>w(v)?[y,v]:[v,y];l.line(T.slice(1),i(a)),l.line(k.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],v[g-1]],i(a))};return{parts:{"leg.left":{over:(a,l,h)=>s(l,h,"left")},"leg.right":{over:(a,l,h)=>s(l,h,"right")},spine:{over:(a,l,h)=>r(l,h)},"arm.left":{over:(a,l,h)=>o(l,h,"left")},"arm.right":{over:(a,l,h)=>o(l,h,"right")}}}}function vf(e){const{timeline:t}=e,n=new Mt;for(const[h,c]of Object.entries(e.targets)){const f=typeof c=="string"?document.querySelector(c):c;if(!f)throw new Error(`quickPlay: no element found for target "${h}" (${String(c)})`);n.registerTarget(h,f)}t.onUpdate=h=>{n.applyState(h),e.onUpdate?.(h)},e.onComplete&&(t.onComplete=e.onComplete);let i=null,s=null,r=!1;const o=h=>{if(r)return;const c=s===null?0:h-s;s=h,c>0&&t.tick(c),i=requestAnimationFrame(o)},a=()=>{i!==null||r||(s=null,i=requestAnimationFrame(o))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(t.getStateAtTime(t.currentTime)),e.autoplay!==!1&&(t.play(),a()),{timeline:t,adapter:n,play(){t.play(),a()},pause(){t.pause(),l()},restart(){t.stop(),t.play(),a()},seek(h){t.seek(h*1e3),n.applyState(t.getStateAtTime(t.currentTime))},destroy(){r=!0,l(),t.stop(),n.clearTargets()}}}const kf={timeline:Tl,to(e,t,n){const i=new Tt(n);return i.to(e,t),i},from(e,t,n){const i=new Tt(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new Tt(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new Tt(n);return i.set(e,t),i}},Sf=j.to,Tf=j.from,Mf=j.fromTo,Ef=j.set,Af=j.timeline,xf=j.ticker,Pf=j.splitText,_f=j.context,Cf=j.matchMedia,Hf=j.quickTo,If=j.imageSequence,Rf=j.pageTransition;Vh(),b.Clock=Zo,b.CompatTimeline=Tt,b.CustomBounce=Tr,b.CustomEase=Sr,b.CustomWiggle=Mr,b.DANCE_STYLES=xt,b.DEFAULT_BAKE_INTERVAL_MS=An,b.DEFAULT_INERTIA_FRICTION=gn,b.DEFAULT_LABELS=Rr,b.DEFAULT_SPRING=Z,b.DEFAULT_TRANSITION=jh,b.Draggable=Un,b.EXPRESSIONS=Q,b.FINGERS=Xr,b.FLIPS=sn,b.FORMAT_VERSION=Vt,b.HAND_REST=N,b.HAND_SHAPES=Y,b.HUMAN_EXPRESSIONS=Du,b.HUMAN_POSES=$o,b.HUMAN_REST=lt,b.INERTIA_MAX_DURATION_MS=Di,b.InertiaTrackPlayer=ks,b.LiveTimeline=at,b.MORPH_SAMPLES=va,b.MUDRAS=wi,b.ManualClock=Jo,b.MediaSync=oi,b.Observer=Qs,b.POSES=Gr,b.REST_POSE=J,b.SPRING_MAX_DURATION_MS=mn,b.SPRING_PRESETS=ke,b.SPRING_STEP_MS=_t,b.ScrollAnimator=mr,b.ScrollDriver=re,b.ScrollMarkers=gr,b.ScrollPin=ur,b.SmoothScroll=ii,b.SpringSampler=jt,b.SpringTrackPlayer=vs,b.Stage=Vs,b.Timeline=In,b.TinyflyPlayer=Be,b.TinyflySequencer=Wr,b.TrackPlayer=Pe,b.ValueResolver=Ka,b.VisibilityDriver=cr,b.applyGroove=Eo,b.backOut=ji,b.bakeDanceTracks=cu,b.bakeEasing=_n,b.bakeInertiaTrack=Pn,b.bakeSpringTrack=xn,b.basicOutfit=wf,b.beatAt=au,b.beatAtTime=He,b.beatLength=Bn,b.beatTime=Ce,b.beatsBetween=tl,b.bindChoiceHotspots=Or,b.blendPose=Yt,b.boilFrame=li,b.bounceOut=zi,b.character=of,b.characterAt=gf,b.characterHandPose=Vo,b.characterJoints=Uo,b.characterPoseTracks=yf,b.characterTarget=mf,b.charactersFor=Ss,b.circlePath=Uu,b.clamp01=Qn,b.clearMorphCache=_a,b.clearPathCache=ma,b.clipErased=Ai,b.containerProgressAt=ti,b.context=_f,b.create=Ih,b.createControls=Fr,b.createCubicBezier=Ui,b.createLive=xr,b.createPen=ci,b.createRandom=_e,b.createTrack=xe,b.criticalDamping=ea,b.customBounce=Rs,b.customEase=Is,b.customWiggle=$s,b.danceFrame=Ze,b.dancePose=nu,b.danceStance=Je,b.danceTaps=su,b.danceTracks=hu,b.danceTravel=tn,b.danceTravelTrack=Co,b.dancer=lu,b.deserializeTimeline=Ft,b.deserializeTrack=As,b.detectTempo=el,b.draggable=Xl,b.drawCartoonHand=Ue,b.drawCharacter=zo,b.drawEraser=Mi,b.drawHand=Ei,b.drawPencil=Lo,b.drawStickFigure=ko,b.drawnPathTarget=Vu,b.easeIn=Yi,b.easeInCubic=yn,b.easeInOut=Xi,b.easeInOutCubic=Jt,b.easeInOutQuad=Ki,b.easeInQuad=Ni,b.easeOut=qi,b.easeOutCubic=bn,b.easeOutQuad=Wi,b.elasticOut=Vi,b.ellipsePoints=hi,b.erasable=Ju,b.expandParametricEasings=bs,b.flipPose=Ho,b.flipTracks=Eu,b.flipTravel=Io,b.from=Tf,b.fromJSON=Da,b.fromTo=Mf,b.getEasingFunction=V,b.getInterpolator=ee,b.getMotionPathPoint=Cn,b.getPathLength=ga,b.getPointAtProgress=ts,b.gridLinesFor=nr,b.handAt=Xu,b.handJoints=Xe,b.handJointsAt=zr,b.handPose=W,b.handProp=fe,b.hasKeyframes=Oi,b.hashSeed=Fn,b.headPoint=Xc,b.humanFieldLabel=Ou,b.humanPlan=Fo,b.humanPose=tt,b.imageSequence=If,b.inertiaDuration=Ht,b.inertiaRest=Ct,b.inertiaValueAt=Te,b.inertiaVelocityAt=ra,b.interpolateArray=ms,b.interpolateColor=ps,b.interpolateMotionPath=$a,b.interpolateNumber=st,b.interpolatePathString=gs,b.interpolateString=En,b.isCubicBezierEasing=Li,b.isInertiaTrack=ft,b.isMotionPathPoint=Go,b.isMotionPathTrack=fn,b.isParametricEasing=Ut,b.isPathData=Rt,b.isSpringTrack=dt,b.isTextTrack=ye,b.isUnderdamped=ta,b.isUnresolved=Wa,b.jointsInScene=jo,b.jointsToScene=vo,b.linear=Me,b.live=j,b.mapEase=ne,b.matchMedia=Cf,b.maxStaggerDistance=pn,b.mirrorHumanPose=Lu,b.mirrorPose=Mo,b.mixHandPoses=Kt,b.mixPoses=df,b.morphPath=as,b.mount=Br,b.mountAll=Nr,b.narrationMarkers=Ga,b.narrationSceneAt=Ja,b.naturalRest=Gt,b.nearestBeat=Za,b.nextBeat=Qa,b.pageTransition=Rf,b.parametricEasing=Ji,b.parseEdge=Jn,b.parsePath=St,b.parseTrigger=Zn,b.partialPath=Wt,b.pathLength=Kr,b.planNarration=ja,b.play=Hh,b.playSequence=zh,b.playWhenVisible=sh,b.playheadCrossings=Rn,b.pointAlong=Ne,b.pointAtDistance=vn,b.pointOnHead=af,b.pointsToPath=Ls,b.pose=U,b.poseTracks=Gc,b.quickPlay=vf,b.quickTo=Hf,b.randomBetween=Ln,b.randomChoice=Na,b.randomSnapped=Ps,b.reachCharacter=pf,b.resolveSequence=Hs,b.resolveStickFrame=yi,b.resolveStickPose=So,b.resolveValue=On,b.rotateAbout=bt,b.routineBeats=Qe,b.rubberLimb=Et,b.scrollProgress=ih,b.scrubOnScroll=lh,b.scrubPath=ju,b.seatHeight=Nc,b.serializeTimeline=xs,b.serializeTrack=Ms,b.set=Ef,b.shapeToPathData=Ie,b.simplifyKeyframes=ws,b.sketchPen=We,b.smoothToward=hr,b.snapAxis=er,b.snapConfig=fr,b.snapDuration=pr,b.snapProgress=dr,b.splitText=Pf,b.springDuration=Bi,b.springValueAt=Qo,b.staggerDistance=dn,b.staggerOffset=be,b.staggerOffsets=we,b.staggerSpan=zt,b.stepsEasing=Gi,b.stickFigureAt=jc,b.stickFigureJoints=wo,b.stickFigureTarget=zc,b.stickToHuman=Nu,b.strideLength=kc,b.syncMediaElement=Ir,b.talkingMouth=eo,b.taperedLine=Ke,b.taperedOutline=le,b.textAt=Ts,b.tf=kf,b.ticker=xf,b.timeline=Af,b.to=Sf,b.toJSON=Ba,b.toKeyframedTrack=Ia,b.toKeyframedTracks=Ra,b.trackTargets=gt,b.triggerDistance=Ot,b.unmount=Xh,b.walkPose=to,b.withErased=Gu,b.withExpression=di,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
53
|
+
`;function qh(e){if(e.getElementById(po))return;const t=e.createElement("style");t.id=po,t.textContent=Kh,e.head.appendChild(t)}function mo(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};qh(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(m,d)=>{a.hasAttribute(m)||(a.setAttribute(m,d),c.push(m))};h("role","button"),h("tabindex","0");const f=e.scenarios.find(m=>m.id===l)?.label;f!==void 0&&h("aria-label",f),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const u=()=>e.setScenario(l),p=m=>{const d=m.key;d!=="Enter"&&d!==" "||(m.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",p),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",p)})}const r=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===e.scenario))},o=e.subscribe(r);return r(),()=>{o();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const c of l)a.removeAttribute(c)}}const je=new WeakMap,Mi=new WeakMap;let Xh=0;function pe(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function go(e,t={}){const n=je.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),o=Uh(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Vh(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?pe(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const p=await fetch(r);p.ok&&(l=await p.json())}if(l&&o&&(l=yo(l,o)),!l&&!r&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const c=pe(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...pe(e.getAttribute("data-options"),"data-options",e)};jh(e);const f=new ze(e,h),u={element:e,player:f};if(je.set(e,u),e.setAttribute("data-tinyfly-mounted",""),a){const p=e.getAttribute("data-scenario")??void 0;await f.loadScenarios(a,{initial:a.some(m=>m.id===p)?p:void 0}),Mi.set(e,mo(f,e))}else await f.load(l??r);if(e.getAttribute("data-controls")!=="false"){const p=pe(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),d=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");u.controls=fo(f,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...p,...d?{scenario:d}:{}},mount:void 0}),m?e.insertBefore(u.controls.element,m):e.appendChild(u.controls.element)}return u}function Vh(e,t,n){const i=[];return e.forEach((s,r)=>{const o=pe(s.textContent,"timeline",n);if(!o)return;const a=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(c=>c.id===a)){console.warn(`tinyfly: scenario id "${a}" is used more than once; the later one is skipped`,n);return}const l=s.getAttribute("data-scenario-label")??void 0;i.push({id:a,label:l,timeline:t?yo(o,t):o})}),i}function yo(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function Uh(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function bo(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>go(s,t)))).filter(s=>s!==void 0)}function zh(e){const t=je.get(e);t&&(Mi.get(e)?.(),Mi.delete(e),t.controls?.destroy(),t.player.destroy(),je.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function jh(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++Xh}`,t.setAttribute("aria-labelledby",i.id))}function Gh(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{bo()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class wo{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new At,this.adapterB=new At}async load(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=t;this.sequence=n,this.symbolDefs.clear();for(const i of n.symbols??[])i.timeline?.tracks?.length&&this.symbolDefs.set(i.id,i.timeline);this.container.style.width=`${n.canvas.width}px`,this.container.style.height=`${n.canvas.height}px`,n.scenes.length>0&&(this.renderScene(n.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(n.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const n=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=n?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const i=this.sequence.scenes[t];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(t),n)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const s=this.timelineA.getStateAtTime(0);this.adapterA.applyState(s),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const n of t)n.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,n,i){n.innerHTML="",i.clearTargets();const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;transform-origin:center center",s.setAttribute("data-tinyfly","Camera"),n.appendChild(s),i.registerTarget("Camera",s);for(const r of t.elements){if(!r.html)continue;const o=document.createElement("div");o.innerHTML=r.html.trim();const a=o.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(t,n){const i=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const r=s.getAttribute("data-tinyfly-symbol");if(!r)return;const o=this.symbolDefs.get(r);if(!o)return;const a=new At;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:Dt(o)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(t,n){const i=this.nestedByAdapter.get(t);if(i)for(const s of i){const r=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(r>0?n%r:n))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?Dt(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const n=this.options.loop??this.sequence.loop??0;n===-1||n>0&&this.loopIteration<n-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[t],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(n,this.containerB,this.adapterB),this.timelineB=this.createTimeline(n),this.timelineB&&this.timelineB.play(),this.applyTransition(i.type,i.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},i.duration)}applyTransition(t,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,this.containerB.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.containerA;this.containerA=this.containerB,this.containerB=n;const i=this.adapterA;this.adapterA=this.adapterB,this.adapterB=i,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[t];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this._isDestroyed||!this._isPlaying)return;const i=n-(this.lastTime??n);if(this.lastTime=n,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(i);const s=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(s),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(i);const s=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(s),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function Jh(e,t,n={}){const i=new wo(e,{...n,autoplay:!0});return await i.load(t),i}const Zh={type:"none",duration:0};function vo(e){let t=0;for(let n=1;n<e.length;n++)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Xt(e,t){const n=Math.min(1,Math.max(0,t));if(e.length<2||n===1)return e.slice();if(n===0)return e.slice(0,1);let i=vo(e)*n;const s=[e[0]];for(let r=1;r<e.length;r++){const o=e[r-1],a=e[r],l=Math.hypot(a.x-o.x,a.y-o.y);if(l>=i){const c=l===0?0:i/l;return s.push({x:o.x+(a.x-o.x)*c,y:o.y+(a.y-o.y)*c}),s}s.push(a),i-=l}return s}function Ge(e,t){const n=Xt(e,t);return n[n.length-1]}function Ei(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function Je(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Ei(n,t.boil??8);let o=0;const a=()=>{const u=o++;return p=>Fe(Jn(`${t.seed??1}:${r}:${u}:${p}`))},l=(u,p)=>(u.next()*2-1)*p,c=u=>{const p=a(),m=e.lineWidth,d=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?d:d*.6,u(p(g));e.lineWidth=m,e.globalAlpha=d},h=(u,p=1)=>{if(u.length<2)return;const m=u.slice(1).map((g,y)=>Math.hypot(g.x-u[y].x,g.y-u[y].y)),d=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,p));c(g=>{const y=[],v=[];if(u.forEach((T,k)=>{y.push({x:T.x+l(g,i*.5),y:T.y+l(g,i*.5)}),k>0&&v.push([g.next()*2-1,g.next()*2-1])}),d<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let w=0;for(let T=1;T<y.length;T++){const k=Qh(y[T-1],y[T],i,v[T-1]),S=m[T-1];if(w+S<=d){e.bezierCurveTo(k[1].x,k[1].y,k[2].x,k[2].y,k[3].x,k[3].y),w+=S;continue}const E=tu(k,S===0?1:(d-w)/S);e.bezierCurveTo(E[1].x,E[1].y,E[2].x,E[2].y,E[3].x,E[3].y);break}e.stroke()})},f=(u,p,m,d,g=1)=>{c(y=>{const w=y.next()*Math.PI*2,T=Math.PI*2+.15+y.next()*.3,k=[];for(let E=0;E<=14;E++){const _=w+T*E/14,M=l(y,i*.6);k.push({x:u+Math.cos(_)*(m+M),y:p+Math.sin(_)*(d+M)})}const S=Xt(k,g);S.length<2||(ko(e,S),e.stroke())})};return{line:h,curve(u,p=1){if(u.length<2)return;const m=u[0],d=u[u.length-1],g=Math.hypot(d.x-m.x,d.y-m.y)||1,y=-(d.y-m.y)/g,v=(d.x-m.x)/g;c(w=>{const T={x:l(w,i*.5),y:l(w,i*.5)},k={x:l(w,i*.5),y:l(w,i*.5)},S=l(w,i*Math.min(1.5,Math.max(.3,g/80))),E=u.map((M,x)=>{const A=x/(u.length-1),P=Math.sin(Math.PI*A)*S;return{x:M.x+T.x+(k.x-T.x)*A+y*P,y:M.y+T.y+(k.y-T.y)*A+v*P}}),_=Xt(E,p);_.length<2||(ko(e,_),e.stroke())})},circle(u,p,m,d=1){f(u,p,m,m,d)},ellipse:f,nudge(u=.5){const p=a()(0);return{x:l(p,i*u),y:l(p,i*u)}}}}function Qh(e,t,n,i){const s=t.x-e.x,r=t.y-e.y,o=Math.hypot(s,r)||1,a=n*Math.min(1.5,Math.max(.3,o/80)),l=-r/o,c=s/o;return[e,{x:e.x+s/3+l*i[0]*a,y:e.y+r/3+c*i[0]*a},{x:e.x+2*s/3+l*i[1]*a,y:e.y+2*r/3+c*i[1]*a},t]}function tu([e,t,n,i],s){const r=(f,u)=>({x:f.x+(u.x-f.x)*s,y:f.y+(u.y-f.y)*s}),o=r(e,t),a=r(t,n),l=r(n,i),c=r(o,a),h=r(a,l);return[e,o,c,r(c,h)]}function ko(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length-1;i++){const s={x:(t[i].x+t[i+1].x)/2,y:(t[i].y+t[i+1].y)/2};e.quadraticCurveTo(t[i].x,t[i].y,s.x,s.y)}const n=t[t.length-1];e.lineTo(n.x,n.y)}function me(e,t,n){const i=e.length;if(i<2)return[];const s=[],r=[],o=a=>t+(n-t)*a/(i-1);return e.forEach((a,l)=>{const c=e[Math.max(0,l-1)],h=e[Math.min(i-1,l+1)],f=Math.hypot(h.x-c.x,h.y-c.y)||1,u=o(l)/2,p=-(h.y-c.y)/f*u,m=(h.x-c.x)/f*u;s.push({x:a.x+p,y:a.y+m}),r.push({x:a.x-p,y:a.y-m})}),[...s,...r.reverse()]}function Ze(e,t,n,i){const s=t.length;if(s<2)return;const r=me(t,n,i),o=a=>n+(i-n)*a/(s-1);e.beginPath(),e.moveTo(r[0].x,r[0].y);for(const a of r.slice(1))e.lineTo(a.x,a.y);e.closePath(),e.fill(),t.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(e.beginPath(),e.arc(a.x,a.y,o(l)/2,0,Math.PI*2),e.fill())})}function xt(e,t,n,i,s=16){const r={x:2*t.x-(e.x+n.x)/2,y:2*t.y-(e.y+n.y)/2},o=[];for(let a=0;a<=s;a++){const l=a/s,c=l<.5?{x:e.x+(t.x-e.x)*2*l,y:e.y+(t.y-e.y)*2*l}:{x:t.x+(n.x-t.x)*(2*l-1),y:t.y+(n.y-t.y)*(2*l-1)},h=1-l,f={x:h*h*e.x+2*h*l*r.x+l*l*n.x,y:h*h*e.y+2*h*l*r.y+l*l*n.y};o.push({x:c.x+(f.x-c.x)*i,y:c.y+(f.y-c.y)*i})}return o}function Ai(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,f)=>{const u=r+Math.PI*2*o*f/a,p=Math.cos(u)*n,m=Math.sin(u)*i;return{x:e+p*l-m*c,y:t+p*c+m*l}})}function xi(e,t){return t.look==="pencil"?su(e,t):eu(e,t.ink,t.look)}function Qe(e,t,n=!1){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);n&&e.closePath()}function eu(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,Ze(e,r,o*s,a*s)},line(r,o){r.length<2||(e.strokeStyle=t,e.lineWidth=o*s,e.lineCap="round",e.lineJoin="round",Qe(e,r),e.stroke())},shape(r,o,a){Qe(e,r,!0),(o!==null||i)&&(e.fillStyle=i?t:o,e.fill()),!(a<=0)&&(e.strokeStyle=t,e.lineWidth=a*s,e.lineJoin="round",e.stroke())},ellipse(r,o,a,l,c,h,f){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(f<=0)&&(e.strokeStyle=t,e.lineWidth=f*s,e.stroke())},dot(r,o,a){e.fillStyle=t,e.beginPath(),e.arc(r,o,a*s,0,Math.PI*2),e.fill()},guide(){},guideEllipse(){}}}function nu(e,t){const n=[e[0]];let i=0;for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o],c=Math.hypot(l.x-a.x,l.y-a.y);let h=t-i;for(;h<c;){const f=h/c;n.push({x:a.x+(l.x-a.x)*f,y:a.y+(l.y-a.y)*f}),h+=t}i=c-(h-t)}const s=e[e.length-1],r=n[n.length-1];return Math.hypot(s.x-r.x,s.y-r.y)>t*.25?n.push(s):n[n.length-1]=s,n}function iu(e,t){const n=e.length;return e.map((i,s)=>{const r=e[Math.max(0,s-1)],o=e[Math.min(n-1,s+1)],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=t(n===1?0:s/(n-1));return{x:i.x-(o.y-r.y)/a*l,y:i.y+(o.x-r.x)/a*l}})}function So(e){const t=[.6,1.4,2.9].map(i=>({frequency:i*(.8+e.next()*.4),phase:e.next()*Math.PI*2,amount:.5+e.next()*.5})),n=t.reduce((i,s)=>i+s.amount,0);return i=>t.reduce((s,r)=>s+r.amount*Math.sin(Math.PI*2*r.frequency*i+r.phase),0)/n}function su(e,t){const n=t.pencil??{},i=t.ink,s=n.roughness??Math.max(1,t.lineWidth*.12),r=Math.max(1,Math.round(n.passes??2)),o=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=Ei(t.time,n.boil??8);let c=0;const h=(m,d,g=!1)=>Fe(Jn(`${t.seed}:${g?"paper":l}:${m}:${d}`)),f=(m,d,g,y,v,w=0)=>{if(m.length<2)return;const T=m.slice(1).reduce((A,P,C)=>A+Math.hypot(P.x-m[C].x,P.y-m[C].y),0);let k=nu(m,Math.max(1.5,Math.min(t.lineWidth*.8,T/24)));if(w>0&&k.length>=2){const[A,P]=[k[k.length-2],k[k.length-1]],C=Math.hypot(P.x-A.x,P.y-A.y)||1;k=[...k,{x:P.x+(P.x-A.x)/C*w,y:P.y+(P.y-A.y)/C*w}]}const S=So(g),E=So(g),_=k.length,M=[],x=[];k.forEach((A,P)=>{const C=_===1?0:P/(_-1),I=k[Math.max(0,P-1)],H=k[Math.min(_-1,P+1)],$=Math.hypot(H.x-I.x,H.y-I.y)||1,F=-(H.y-I.y)/$,L=(H.x-I.x)/$,O=S(C)*v,R=Math.min(1,C/.08,(1-C)/.08),B=(.55+.45*Math.sqrt(Math.max(0,R)))*(1+o*E(C)),D=Math.max(.3,d(C)*B/2),Z=A.x+F*O,St=A.y+L*O;M.push({x:Z+F*D,y:St+L*D}),x.push({x:Z-F*D,y:St-L*D})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,Qe(e,[...M,...x.reverse()],!0),e.fill(),e.restore()},u=(m,d)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const k=(y.next()*2-1)*t.lineWidth*1.4,S=(y.next()*2-1)*t.lineWidth*1.4,E=m.map(_=>({x:_.x+k,y:_.y+S}));f(E,_=>d(_)*1.8,h(g,98,!0),.035,s),f(E,_=>d(_)*.45,h(g,97,!0),.12,s*1.5)}const v=m.slice(1).reduce((k,S,E)=>k+Math.hypot(S.x-m[E].x,S.y-m[E].y),0),w=d(.5)>4&&v>d(.5)*6,T=w?[-.3,.3,0]:[0];for(let k=0;k<r;k++){const S=k===0;T.forEach((E,_)=>{const M=h(g,k*10+_),x=E===0?m:iu(m,P=>d(P)*E*Math.sqrt(Math.sin(Math.PI*P))),A=!S&&E===0?t.lineWidth*(.3+M.next()*.8):0;f(x,P=>d(P)*(w?.5:1)*(S?1:.6),M,S?.85:.45,s*(S?.6:1),A)})}},p=(m,d,g,y,v,w)=>{const k=h(c,50).next()*Math.PI*2;u(Ai(m,d,g,y,v,k,1.08,48),()=>w)};return{look:"pencil",ink:i,limb(m,d,g){u(m,y=>d+(g-d)*y)},line(m,d){u(m,()=>d)},shape(m,d,g){d!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=d,Qe(e,m,!0),e.fill(),e.restore()),g>0&&u([...m,m[0]],()=>g)},ellipse(m,d,g,y,v,w,T){w!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=w,e.beginPath(),e.ellipse(m,d,g,y,v,0,Math.PI*2),e.fill(),e.restore()),p(m,d,g,y,v,T)},dot(m,d,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,d,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const d=c++;f(m,()=>Math.max(.6,t.lineWidth*.18),h(d,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,d,g,y,v){if(n.construction===!1)return;const w=c++,T=h(w,0),k=Ai(m,d,g,y,v,T.next()*Math.PI*2,1.12,48);f(k,()=>Math.max(.6,t.lineWidth*.18),T,.28,s*1.5)}}}const To=["thumb","index","middle","ring","pinky"],N={"thumb.curl":.15,"thumb.across":.15,"index.curl":.12,"middle.curl":.16,"ring.curl":.2,"pinky.curl":.25,spread:.25,turn:0,bend:0,tilt:0,roll:0};function W(e={}){return{...N,...e}}const j=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),K={relaxed:N,open:W({...j(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:W({...j(0,0,0,0,0),"thumb.across":0,spread:1}),flat:W({...j(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:W({...j(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:W({...j(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:W({...j(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:W({...j(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:W({...j(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:W({...j(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:W({...j(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:W({...j(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:W({...j(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:W({...j(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function Vt(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}const ru={index:{knuckle:[-.16,.47,-.02],bones:[.2,.125,.1],width:.125,fan:-1},middle:{knuckle:[-.055,.49,-.02],bones:[.22,.135,.1],width:.13,fan:-.2},ring:{knuckle:[.05,.475,-.02],bones:[.2,.125,.1],width:.122,fan:.55},pinky:{knuckle:[.15,.43,-.02],bones:[.16,.1,.085],width:.108,fan:1.25}},ou={index:{knuckle:[-.14,.47,-.02],bones:[.2,.125,.1],width:.15,fan:-1},middle:{knuckle:[0,.49,-.02],bones:[.22,.135,.1],width:.155,fan:0},pinky:{knuckle:[.14,.45,-.02],bones:[.19,.115,.095],width:.145,fan:1}},ht={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},au=[82,100,62],lu=[48,72],cu=3,hu=13,uu=.035,fu=-.075,du=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],bt=e=>e*Math.PI/180,Pi=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],tn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],_i=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],ge=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function wt(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=_i(t,e),o=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];return[e[0]*i+r[0]*s+t[0]*o*(1-i),e[1]*i+r[1]*s+t[1]*o*(1-i),e[2]*i+r[2]*s+t[2]*o*(1-i)]}const Mo=[1,0,0],Eo=[0,1,0],ye=[0,0,1];function pu(e,t,n){const i=bt(e.fan*(cu+hu*n)),s=[Math.sin(i),Math.cos(i),0],r=[Math.cos(i),-Math.sin(i),0],o=[e.knuckle];let a=0;e.bones.forEach((h,f)=>{a+=bt(au[f]*t),o.push(Pi(o[f],tn(wt(s,r,-a),h)))});const l=wt(ye,r,-a),c=o.map((h,f)=>e.width*(1-.14*(f/(o.length-1))));return{joints:o,back:l,widths:c}}function mu(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=ge(Pi(tn(ge(ht.out),1-s),tn(ge(ht.across),s))),o=ge(_i(ye,r)),a=ge(_i(r,o)),l=[[ht.base[0]*i,ht.base[1],ht.base[2]]];let c=0;ht.bones.forEach((u,p)=>{p>0&&(c+=bt(lu[p-1]*e)),l.push(Pi(l[p],tn(wt(r,o,c),u)))});const h=wt(a,o,c),f=[...ht.widths,ht.widths[ht.widths.length-1]*.92].map(u=>u*n);return{joints:l,back:h,widths:f}}function en(e,t={}){const n={...N,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=bt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),c=1+(l-1)*.7,h=P=>({...P,knuckle:[P.knuckle[0]*c,P.knuckle[1],P.knuckle[2]],width:P.width*l}),f=bt(n.bend??0),u=bt(n.tilt??0),p=bt(90*(n.turn??0)),m=P=>wt(wt(wt(P,Mo,-f),ye,-u),Eo,p),d=Math.cos(o),g=Math.sin(o),y=bt(n.roll??0),v=Math.cos(y),w=Math.sin(y),T=P=>{const C=P[0]*i,I=-P[1]*i,H=(C*v-I*w)*r,$=C*w+I*v;return{x:H*d-$*g,y:H*g+$*d}},k=P=>{const C=T(P),I=Math.hypot(C.x,C.y);return I>1e-6*i?{x:C.x/I,y:C.y/I}:{x:0,y:0}},S={thumb:mu(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},E=a?ou:ru;for(const P of To){const C=E[P];C&&(S[P]=pu(h(C),n[`${P}.curl`]??0,n.spread??0))}const _={};for(const[P,C]of Object.entries(S)){const I=C.joints.map(m),H=m(C.back);_[P]={points:I.map(T),depths:I.map($=>$[2]*i),widths:C.widths.map($=>$*i),nail:H[2],back:k(H)}}const M=du.flatMap(([P,C])=>[m([P*c,C,uu]),m([P*c,C,fu])]),x=gu(M.map(T)),A=M.reduce((P,C)=>P+C[2],0)/M.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:x,palmDepth:A,palmFacing:-m(ye)[2],fingers:_,axes:{up:k(m(Eo)),across:k(m(Mo)),out:k(m(ye))},curls:Object.fromEntries(Object.keys(_).map(P=>[P,n[`${P}.curl`]??0]))}}function Ao(e,t){const n=s=>({x:s.x+t.x-e.wrist.x,y:s.y+t.y-e.wrist.y}),i={};for(const[s,r]of Object.entries(e.fingers))i[s]={...r,points:r.points.map(n)};return{...e,wrist:n(e.wrist),palm:e.palm.map(n),fingers:i}}function gu(e){const t=[...e].sort((r,o)=>r.x-o.x||r.y-o.y);if(t.length<3)return t;const n=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x),i=[];for(const r of t){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}const s=[];for(const r of[...t].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],r)<=0;)s.pop();s.push(r)}return[...i.slice(0,-1),...s.slice(0,-1)]}const yu="#f1c9a5",bu="#2f2f33";function nn(e,t,n,i={},s=0){const r=Ao(en(n,i),t),o=i.ink??bu,a=i.lineWidth??r.size*.035,l=i.pen??xi(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??yu,h=i.nails??!0,f=[{depth:r.palmDepth,draw:()=>wu(l,r,c,a)}];for(const u of Object.values(r.fingers)){const p=u.depths.reduce((m,d)=>m+d,0)/u.depths.length;f.push({depth:p,draw:()=>vu(e,l,u,c,a,h)})}if(i.prop){const u=i.prop;f.push({depth:u.depth,draw:()=>u.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const u of[...f].sort((p,m)=>p.depth-m.depth))u.draw();return e.restore(),r}function wu(e,t,n,i){if(e.shape(t.palm,n,i),t.palmFacing<-.3&&e.look!=="silhouette"){const{up:s}=t.axes;for(const[r,o]of Object.entries(t.fingers)){const a=t.curls[r]??0;if(r==="thumb"||a<.5)continue;const l=o.points[0],c=o.widths[0]*.42,h={x:l.x-s.x*c*.2,y:l.y-s.y*c*.2},f=Math.atan2(s.y,s.x),u=Array.from({length:7},(p,m)=>{const d=f-Math.PI/2+Math.PI*m/6;return{x:h.x+Math.cos(d)*c,y:h.y+Math.sin(d)*c}});e.line(u,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(h,f)=>({x:a.x+(r.x*h+s.x*f)*o,y:a.y+(r.y*h+s.y*f)*o}),c=t.side==="left"?-1:1;e.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function vu(e,t,n,i,s,r){const{widths:o}=n,a=ku(n.points,2),l=n.points[0],c=a[a.length-1],h=o[0],f=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const d=h/2+s*1.6;e.moveTo(l.x+d,l.y),e.arc(l.x,l.y,d,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,h+2*s,f+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,Ze(e,a,h,f)),t.look==="silhouette"||!r||n.nail<.25)return;const u=a[a.length-2],p=Su({x:c.x-u.x,y:c.y-u.y})??{x:0,y:-1},m={x:c.x-p.x*f*.22+n.back.x*f*.1,y:c.y-p.y*f*.22+n.back.y*f*.1};t.ellipse(m.x,m.y,f*.24*Math.max(.35,n.nail),f*.19,Math.atan2(p.y,p.x),"#f8e3d3",s*.45)}function ku(e,t){let n=e;for(let i=0;i<t;i++){if(n.length<3)return n;const s=[n[0]];for(let r=0;r<n.length-1;r++){const o=n[r],a=n[r+1];r>0&&s.push({x:o.x*.75+a.x*.25,y:o.y*.75+a.y*.25}),r<n.length-2&&s.push({x:o.x*.25+a.x*.75,y:o.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const Su=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},G={lean:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee:0,leftWrist:0,rightWrist:0,leftAnkle:0,rightAnkle:0,leftFootOut:0,rightFootOut:0,mouth:0,smile:.6,mouthWidth:1,blink:0,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0,stretch:1,turn:0,sit:0,spin:0,rise:0};function X(e){return{...G,...e}}const xo={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},q=e=>({...xo,...e}),tt={neutral:xo,happy:q({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:q({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:q({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:q({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:q({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:q({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:q({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:q({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:q({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:q({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:q({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:q({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:q({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:q({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:q({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:q({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:q({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function Ci(e,t){return{...e,...typeof t=="string"?tt[t]:t}}const Po={rest:G,wave:X({rightShoulder:135,rightElbow:30,headTilt:6,...tt.happy}),cheer:X({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...tt.joyful}),shrug:X({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...tt.confused,lookX:0,lookY:0}),point:X({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:X({rightShoulder:60,rightElbow:150,headTilt:10,...tt.thinking}),handsOnHips:X({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:X({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...tt.sad}),surprised:X({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...tt.surprised}),crouch:X({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:X({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:X({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...tt.joyful}),sideSplit:X({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...tt.happy}),frontSplit:X({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...tt.happy})},_o=Object.keys(G);function Ut(e,t,n){const i={...e};for(const s of _o)i[s]=e[s]+(t[s]-e[s])*n;return i}const Ii=24,Co=4,Io=28,Tu=40;function Ho(e,t=G,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=Tu,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-Io*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+Io*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+Co*n,headTilt:t.headTilt-Co*.5*n,leftElbow:a,rightElbow:l,leftHip:-Ii*i,rightHip:-Ii*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function Mu(e,t=1){return 4*((Hi+sn)*e)*Math.sin(Ii*t*Math.PI/180)}function $o(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const Ro=.12,Fo=.46,Eu=1-2*Ro,Au=.1,xu=.21,Pu=.19,Hi=.24,sn=.22,Oo=.12,_u=.14,Lo=.33,Bo=.7,Do=.3,Cu=.35,Iu=[1.7,1.05],Hu=[1.3,.75],No=[1.45,.85],$u=[1.15,.75],Wo=.06,Ru=.7,Fu=.65,Yo=.075,Ou=.3,Lu=.02,Bu=.012,Du=12,Nu=.25,rn=90,Wu=.25,Yu=.04,Ko=.01,Pt=e=>Math.min(1,Math.max(0,e??0));function Ku(e,t=1){return sn*e*t}const $i=-.12,qo=.4,it=e=>e*Math.PI/180,qu=(e,t)=>({x:t*Math.sin(it(e)),y:Math.cos(it(e))}),Xo=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Vo=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function Xu(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,_u*n)),a=Pt(t.turn),l=(Oo+Lo*a)*n,c=i+$i*n,h=l+t.lookX*.08*n,f=t.lookY*.07*n,u=[{x:-.34*n*(1-Bo*a),squeeze:1-Bo*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-Do*a),squeeze:1-Do*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of u){const v=Xo(y.open,t.blink);if(v<.2){const S=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+S,y.x+l+.12*n,c),e.stroke()}else{if(v>1.2){const E=.13*n*v;e.beginPath(),e.ellipse(y.x+l,c,E*.85,E,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const S=v>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+f,S,S*1.1*Math.min(v,1),0,0,Math.PI*2),e.fill()}const w=Vo(c,n,y.brow,v),T=y.x+l-y.side*.13*n*y.squeeze,k=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(k,w),e.lineTo(T,w-t.browTilt*.1*n),e.stroke()}const p=i+qo*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-Cu*a),d=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),d<=.05){e.moveTo(l-m,p),e.quadraticCurveTo(l,p+t.smile*.25*n,l+m,p),e.stroke();return}const g=.3*n*d;t.smile>.3?(e.moveTo(l-m,p-.05*n),e.lineTo(l+m,p-.05*n),e.quadraticCurveTo(l,p+g*2,l-m,p-.05*n)):t.smile<-.3?(e.moveTo(l-m,p+g*.6),e.lineTo(l+m,p+g*.6),e.quadraticCurveTo(l,p-g*1.4,l-m,p+g*.6)):e.ellipse(l,p,m*.8,g,0,0,Math.PI*2),e.fill()}function Uo(e,t){const n=t.height??300,i=Math.min(3,Math.max(.3,e.stretch??1)),s=Math.sqrt(i),r=(t.headSize??2*Ro)/2,o=t.headSize===void 0?Eu:1-2*r,a=r*n,l=Pt(e.sit),c=e.leftHip+(-rn-e.leftHip)*l,h=e.leftKnee+(-rn-e.leftKnee)*l,f=e.rightHip+(rn-e.rightHip)*l,u=e.rightKnee+(rn-e.rightKnee)*l,p=t.classic===!0,m=Pt(e.turn),d=($,F,L,O,R)=>{const B=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(it(F-L)/2)+it(O))),D=Math.max(-1,Math.min(1,Ru+R)),Z=m+(1-m)*$*D;return p?{x:0,y:0}:{x:Math.cos(B)*Wo*Z,y:Math.sin(B)*Wo}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let v=0;if(l>0||!p){const $=(R,B,D,Z,St)=>Hi*Math.cos(it(B))+sn*Math.cos(it(B-D))+Math.max(0,d(R,B,D,Z,St).y),F=Math.max($(-1,c,h,g.left,y.left),$(1,f,u,g.right,y.right)),L=1-Pt((e.rise??0)/Yu),O=(p?Math.min(1,l/Wu):1)*L;v=(Fo-F)*O*n*i}const w=-Fo*n*i+v,T=-o*n*i+v,k=p?0:(Lu*Pt(e.turn)+Bu*l)*n*i,S=k===0?[{x:0,y:w},{x:0,y:T}]:xt({x:0,y:w},{x:-k,y:(w+T)/2},{x:0,y:T},1,8),E=T+Au*n*i,_=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),M=($,F,L,O,R)=>{const B=qu(L,O);return{x:$+B.x*R*n,y:F+B.y*R*n}},x=($,F,L)=>{const O=M(0,w,F,$,Hi*i);return{root:{x:0,y:w},joint:O,end:M(O.x,O.y,F-L,$,sn*i)}},A=($,F,L)=>{const O={x:$*_,y:E},R=M(O.x,O.y,F,$,xu*s);return{root:O,joint:R,end:M(R.x,R.y,F+L,$,Pu*s)}},P={left:x(-1,c,h),right:x(1,f,u)},C=($,F,L,O,R,B)=>{const D=d($,L,O,R,B);return{x:F.end.x+D.x*n*i,y:F.end.y+D.y*n*i}},I=($,F,L,O,R)=>M(F.end.x,F.end.y,L+O+R,$,Yo*s),H={left:A(-1,e.leftShoulder,e.leftElbow),right:A(1,e.rightShoulder,e.rightElbow)};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(p?0:Ou,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:w,neckY:T,drop:v,lean:p?e.lean:e.lean+Du*Math.sin(Math.PI*l),classic:p,legs:P,toes:{left:C(-1,P.left,c,h,g.left,y.left),right:C(1,P.right,f,u,g.right,y.right)},spine:S,arms:H,handTips:{left:I(-1,H.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:I(1,H.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const be=(e,t)=>t===0?[e.root,e.joint,e.end]:xt(e.root,e.joint,e.end,t);function on(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=e.x-t.x,o=e.y-t.y;return{x:t.x+r*i-o*s,y:t.y+r*s+o*i}}function zo(e,t,n=!0){const i=Uu(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?Vu(i,e,s,r):i}function jo(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*it(t),lift:n*e.height}}function Vu(e,t,n,i){const{pivot:s,angle:r,lift:o}=jo(t,n,i),a=u=>{const p=on(u,s,r);return{x:p.x,y:p.y-o}},l=u=>({left:a(u.left),right:a(u.right)}),c={left:Math.max(a(e.feet.left).y,a(e.toes.left).y),right:Math.max(a(e.feet.right).y,a(e.toes.right).y)},h=Math.max(c.left,c.right),f=Ko*t.height;return{...e,hip:a(e.hip),neck:a(e.neck),shoulders:l(e.shoulders),elbows:l(e.elbows),hands:l(e.hands),fingertips:l(e.fingertips),knees:l(e.knees),feet:l(e.feet),toes:l(e.toes),feetY:h,grounded:{left:c.left>=h-f,right:c.right>=h-f},handAngle:{left:e.handAngle.left+r,right:e.handAngle.right+r},limbs:{leftArm:e.limbs.leftArm.map(a),rightArm:e.limbs.rightArm.map(a),leftLeg:e.limbs.leftLeg.map(a),rightLeg:e.limbs.rightLeg.map(a),spine:e.limbs.spine.map(a)},head:{...e.head,center:a(e.head.center),angle:e.head.angle+r}}}function Uu(e,t){const n=it(e.lean),i=it(t.headTilt),s={x:0,y:e.hipY},r=w=>({x:e.facing*w.x,y:w.y}),o=w=>r(on(w,s,n)),a=w=>o(on({x:w.x,y:w.y+e.neckY},{x:0,y:e.neckY},i)),l=be(e.arms.left,e.rubber).map(o),c=be(e.arms.right,e.rubber).map(o),h=(w,T)=>Math.atan2(T.y-w.y,T.x-w.x),f={left:o(e.handTips.left),right:o(e.handTips.right)},u=(w,T)=>{const[k,S]=w.slice(-2),E=e.arms[T],_=h(o(E.end),f[T])-h(o(E.joint),o(E.end));return h(k,S)+_};let p=1/0;for(const[w,T]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const k=Vo($i,1,w,Xo(T,t.blink));p=Math.min(p,k,k-t.browTilt*.1)}const m={left:r(e.legs.left.end),right:r(e.legs.right.end)},d={left:r(e.toes.left),right:r(e.toes.right)},g={left:Math.max(m.left.y,d.left.y),right:Math.max(m.right.y,d.right.y)},y=Math.max(g.left,g.right),v=Ko*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:o({x:0,y:e.neckY}),shoulders:{left:o(e.arms.left.root),right:o(e.arms.right.root)},elbows:{left:o(e.arms.left.joint),right:o(e.arms.right.joint)},hands:{left:o(e.arms.left.end),right:o(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:m,toes:d,feetY:y,grounded:{left:g.left>=y-v,right:g.right>=y-v},fingertips:f,handAngle:{left:u(l,"left"),right:u(c,"right")},limbs:{leftArm:l,rightArm:c,leftLeg:be(e.legs.left,e.rubber).map(r),rightLeg:be(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:a({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+i),eyeY:$i,browTopY:p,mouthY:qo,faceX:e.facing*(Oo+Lo*Pt(t.turn))}}}function Go(e,t={}){return zo(Uo(e,t),e)}function zu(e,t,n){return on({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function Jo(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>({left:i(r.left),right:i(r.right)});return{...e,hip:i(e.hip),neck:i(e.neck),shoulders:s(e.shoulders),elbows:s(e.elbows),hands:s(e.hands),knees:s(e.knees),feet:s(e.feet),toes:s(e.toes),feetY:e.feetY+n,grounded:{...e.grounded},handAngle:{...e.handAngle},limbs:{leftArm:e.limbs.leftArm.map(i),rightArm:e.limbs.rightArm.map(i),leftLeg:e.limbs.leftLeg.map(i),rightLeg:e.limbs.rightLeg.map(i),spine:e.limbs.spine.map(i)},head:{...e.head,center:i(e.head.center)}}}function Zo(e,t,n={},i=0){const s=Uo(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?zo(s,t,!1):void 0,l=n.sketch?Je(e,n.sketch,i):void 0,c=n.sketch&&n.layers?Je(e,n.sketch,i):void 0,h=S=>{e.save(),S(),e.restore()},f=S=>{S&&a&&h(()=>S(e,a,i,c))},u=()=>e.scale(s.facing,1),p=()=>{u(),e.translate(0,s.hipY),e.rotate(it(s.lean)),e.translate(0,-s.hipY)},m=(S,E,_)=>{if(l)return E?l.curve(S):l.line(S);if(s.classic){e.beginPath(),e.moveTo(S[0].x,S[0].y);for(const M of S.slice(1))e.lineTo(M.x,M.y);e.stroke();return}Ze(e,S,_[0]*s.lineWidth,_[1]*s.lineWidth)},d=(S,E)=>m(be(S,s.rubber),s.rubber>0,E),g=S=>{s.classic||m([s.legs[S].end,s.toes[S]],!1,$u)},y=S=>{if(n.hands&&!s.classic)return w(S);if(s.classic||l)return;const E=s.arms[S].end;e.beginPath(),e.arc(E.x,E.y,Fu*s.lineWidth,0,Math.PI*2),e.fill()};e.save(),e.strokeStyle=r,e.fillStyle=r,e.lineWidth=s.lineWidth,e.lineCap="round",e.lineJoin="round";const v=jo(s,t.spin??0,t.rise??0);(v.angle!==0||v.lift!==0)&&(e.translate(0,-v.lift),e.translate(v.pivot.x,v.pivot.y),e.rotate(v.angle),e.translate(-v.pivot.x,-v.pivot.y));function w(S){const E=n.hands??{},_=s.arms[S].end,M=s.handTips[S],x=n.headFill??"#ffffff";nn(e,_,E[S]??N,{side:S,angle:Math.atan2(M.x-_.x,_.y-M.y)*180/Math.PI,size:(E.size??Yo)*s.height*Math.sqrt(s.stretch),skin:E.skin??(x==="none"?void 0:x),ink:r,lineWidth:s.lineWidth*.45,fingers:E.fingers,plump:E.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const T=S=>{h(()=>{p(),d(s.arms[S],Hu),y(S)});const E=o.sleeve;E&&a&&h(()=>E(e,a,S,i,c))},k=Pt(t.turn)>Nu;f(o.behind),h(()=>{u(),d(s.legs.left,No),g("left"),d(s.legs.right,No),g("right")}),k&&T("left"),h(()=>{p(),m(s.spine,s.spine.length>2,Iu);const{left:S,right:E}={left:s.arms.left.root,right:s.arms.right.root};if(S.x!==E.x)if(s.classic)m([S,E],!1,[1,1]);else{const _={x:(S.x+E.x)/2,y:S.y-.3*Math.abs(E.x-S.x)};m(xt(S,_,E,1,8),!0,[1.1,1.1])}}),f(o.body),k||T("left"),T("right"),f(o.behindHead),h(()=>{p(),e.translate(0,s.neckY),e.rotate(it(t.headTilt));const S=-s.headRy;e.beginPath(),e.ellipse(0,S,s.headRx,s.headRy,0,0,Math.PI*2);const E=n.headFill??"#ffffff";if(E!=="none"&&(e.fillStyle=E,e.fill()),l){l.ellipse(0,S,s.headRx,s.headRy);const _=l.nudge();e.translate(_.x,_.y)}else e.stroke();e.translate(0,S),e.scale(s.headRx/s.r,s.headRy/s.r),Xu(e,t,s.r,0,r,s.lineWidth)}),f(o.overHead),f(o.front),e.restore(),n.label&&(e.save(),e.fillStyle=r,e.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),e.restore())}function Ri(e,t,n){const i={...e};let s=e.walking>0?Ut(i,Ho(e.walk,i),e.walking):i,r=ju(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=Ut(s,a.pose,o),a.hands){const l=(c,h)=>h?Vt(c??N,h,o):c;r={left:l(r?.left,a.hands.left),right:l(r?.right,a.hands.right)}}}return e.talk>0&&(s={...s,mouth:Math.max(s.mouth,e.talk*$o(t))}),{pose:s,hands:r}}function Qo(e,t,n){return Ri(e,t,n).pose}const we=(e,t)=>`hand.${e}.${t}`;function ju(e){const t=s=>{if(typeof e[we(s,"spread")]=="number")return Object.fromEntries(Object.keys(N).map(r=>[r,e[we(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function Gu(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function Ju(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...X(e.pose??{}),walk:0,walking:0,talk:0,rubber:t.rubber??0,beat:0,dancing:0},r={};if(t.hands)for(const o of["left","right"]){const a=t.hands[o]??N;for(const l of Object.keys(N))r[we(o,l)]=a[l]??N[l]}return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s,...r},figureStyle:t,figureDance:e.dance,draw(o,a,l){const c=a.props,h=Ri(c,l,e.dance);o.translate(i/2,n),Zo(o,h.pose,Gu({...t,rubber:c.rubber},h.hands),l)}}}function Zu(e,t,n){const i=e.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...e.props};let r=0,o=0;for(const[c,h]of t.state?.values.get(n)??[])typeof h=="number"&&(c==="x"||c==="motionPathX"?r=h:c==="y"||c==="motionPathY"?o=h:c in s&&(s[c]=h));const a=Qo(s,t.time,e.figureDance),l=Go(a,{...i,rubber:s.rubber});return{pose:a,joints:Jo(l,e.x+r+e.width/2,e.y+o+e.height)}}function Qu(e,t){const n=[];return t.forEach((i,s)=>{const r=s===0?G:n[s-1],o=typeof i.pose=="string"?Po[i.pose]:{...r,...i.pose};n.push(i.expression?Ci(o,i.expression):o)}),_o.filter(i=>n.some(s=>s[i]!==G[i])).map(i=>({id:`${e}-${i}`,target:e,property:i,keyframes:t.map((s,r)=>({time:s.time,value:n[r][i],...s.easing?{easing:s.easing}:{}}))}))}const Fi=.5,Oi={pataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:W({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:K.fist,shikhara:K.thumbsUp,hamsasya:W({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:W({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function an(e){return typeof e!="string"?e:e in Oi?Oi[e]:K[e]}function ta(e,t,n){const i=[];for(const s of e.keys){const r=i[i.length-1],o=!r||s.reset?{pose:t,...n}:r;i.push({beat:s.beat,pose:{...o.pose,...s.pose},left:s.hands?.left?an(s.hands.left):o.left,right:s.hands?.right?an(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const Li=(e,t)=>(e%t+t)%t;function tf(e,t,n,i){const s=ta(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=Li(t,e.beats);let o=s.length-1;for(let p=0;p<s.length;p++)s[p].beat<=r&&(o=p);const a=s[o],l=s[(o+1)%s.length],c=a.beat<=r?a.beat:a.beat-e.beats,h=l.beat>c?l.beat:l.beat+e.beats,f=h>c?(r-c)/(h-c):0,u=V(l.easing??"ease-in-out")(Math.min(1,Math.max(0,f)));return{pose:Ut(a.pose,l.pose,u),hands:{left:Vt(a.left,l.left,u),right:Vt(a.right,l.right,u)}}}const ef=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],nf=["lean","headTilt","lookX","spin"],sf=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function ea(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of ef){const r=n&&sf.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of nf)t[i]=-e[i];return t}const rf=e=>Math.min(1,Math.max(-1,(.5-e)*4));function na(e,t,n){const i=Li(n,1),s=(1+Math.cos(2*Math.PI*i))/2,r=t.bounce*(t.accent==="up"?1-s:s),o=Math.min(1,Math.max(0,e.turn??0)),a=rf(o);return{...e,leftHip:e.leftHip+a*r/2,rightHip:e.rightHip+r/2,leftKnee:e.leftKnee+a*r,rightKnee:e.rightKnee+r,lean:e.lean+(t.sway??0)*(1-o)*Math.sin(Math.PI*n)}}function ln(e){const t={...G,...e.stance};return e.expression?Ci(t,e.expression):t}function ia(e){return{left:e.hands?.left?an(e.hands.left):N,right:e.hands?.right?an(e.hands.right):N}}function Bi(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=tf(i,n,ln(e),ia(e));return t.mirror?{pose:ea(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function cn(e,t,n={}){const i=typeof e=="string"?_t[e]:e;let s;if(n.move)s=Bi(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((f,u)=>f+u.beats,0),a=Li(t,o);let l=0,c=0;for(;c<r.length-1&&a>=l+r[c].beats;)l+=r[c++].beats;const h=a-l;if(s=Bi(i,r[c],h),h<Fi&&r.length>1&&t>=Fi){const f=r[(c-1+r.length)%r.length],u=Bi(i,f,f.beats+h),p=V("ease-in-out")(h/Fi);s={pose:Ut(u.pose,s.pose,p),hands:{left:Vt(u.hands.left,s.hands.left,p),right:Vt(u.hands.right,s.hands.right,p)}}}}return{...s,pose:na(s.pose,i.groove,t)}}function of(e,t,n={}){return cn(e,t,n).pose}function hn(e){return(typeof e=="string"?_t[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const af={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function sa(e,t,n,i,s,r,o){for(let a=0;a*e.beats<n;a++)for(const l of e.keys){const c=a*e.beats+l.beat,h=t+c;if(!(c>=n||h<r||h>=o))for(const f of l.taps??[])s.push({beat:h,tap:i?af[f]:f})}}function lf(e,t,n,i={}){const s=typeof e=="string"?_t[e]:e,r=[];if(n<=t)return r;if(i.move){const o=s.moves[i.move],a=Math.floor(t/o.beats)*o.beats;sa(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=hn(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const c of s.routine)sa(s.moves[c.move],l,c.beats,c.mirror,r,t,n),l+=c.beats}}return r.sort((o,a)=>o.beat-a.beat)}function ra(e,t){const n=e.moves[t.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return t.mirror?(ta(n,ln(e),ia(e))[0]?.pose.turn??ln(e).turn??0)>=.5?i:-i:i}function oa(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function un(e,t,n={}){const i=typeof e=="string"?_t[e]:e,s=oa(i,n),r=s.reduce((h,f)=>h+f.beats,0),o=s.reduce((h,f)=>h+ra(i,f)*f.beats,0),a=Math.floor(t/r);let l=a*o,c=t-a*r;for(const h of s){const f=Math.min(h.beats,c);if(l+=ra(i,h)*f,c-=f,c<=0)break}return l}function cf(e,t,n){const i=oa(e,n),s=[0];let r=0;for(let o=0;r<t;o=(o+1)%i.length)r+=i[o].beats,s.push(Math.min(r,t));return s}const hf=8;function aa(e,t,n){const i=typeof t=="string"?_t[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:hn(i)),o=cf(i,r,n);if(o.every(y=>un(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=V("ease-in-out"),c=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(r-y)/a))),h=Math.ceil(a*hf),f=a<=0?[]:Array.from({length:h+1},(y,v)=>[v/h*a,r-v/h*a]).flat(),u=[...new Set([...o,...f])].sort((y,v)=>y-v);let p=0;const m=u.map((y,v)=>{if(v>0){const w=u[v-1],T=Math.max(1,Math.ceil((y-w)*16));for(let k=0;k<T;k++){const S=w+(y-w)*k/T,E=w+(y-w)*(k+1)/T;p+=(un(i,E,n)-un(i,S,n))*c((S+E)/2)}}return{beat:y,travel:p}}),d=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:d+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function uf(e,t,n=0){return(e-n)*t/6e4}function ff(e,t={}){return n=>cn(e,n,t)}function df(e,t){const n=t.start??0,i=6e4/t.bpm,s=n+t.beats*i,r=Math.min((t.fade??1)*i,(s-n)/2);return[{id:`${e}-beat`,target:e,property:"beat",keyframes:[{time:n,value:0},{time:s,value:t.beats,easing:"linear"}]},{id:`${e}-dancing`,target:e,property:"dancing",keyframes:[{time:n,value:0},{time:n+r,value:1,easing:"ease-in-out"},{time:s-r,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function pf(e,t,n={}){const i=typeof t=="string"?_t[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:hn(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),c=Array.from({length:l+1},(d,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:cn(i,y,n)}}),h=(d,g)=>({id:`${e}-${d}`,target:e,property:d,keyframes:c.map(y=>({time:y.time,value:g(y.frame)}))}),u=Object.keys(G).filter(d=>c.some(g=>g.frame.pose[d]!==c[0].frame.pose[d])||c[0].frame.pose[d]!==G[d]).map(d=>h(d,g=>g.pose[d])),p=n.height===void 0?void 0:aa(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(p&&u.push(p),n.hands===!1)return u;const m=[];for(const d of["left","right"])for(const g of Object.keys(N)){const y=v=>v.hands?.[d]?.[g]??N[g];c.some(v=>y(v.frame)!==N[g])&&m.push(h(we(d,g),y))}return[...u,...m]}const ve={type:"back",mode:"out",overshoot:1.1},U="ease-out-cubic",mf={label:"Disco",bpm:120,stance:{leftHip:10,rightHip:10,leftKnee:6,rightKnee:6},expression:{smile:.9,mouth:.15,leftBrow:.3,rightBrow:.3},groove:{bounce:10,accent:"down",sway:2},moves:{point:{label:"The point",beats:2,easing:U,keys:[{beat:0,pose:{rightShoulder:150,rightElbow:0,rightWrist:0,leftShoulder:40,leftElbow:-105,leftWrist:-20,lean:-5,headTilt:8,rightHip:18,leftHip:6,lookX:.6,lookY:-.7},hands:{right:"point",left:"fist"}},{beat:1,pose:{rightShoulder:-30,rightWrist:10,lean:5,headTilt:-6,rightHip:6,leftHip:18,lookX:-.4,lookY:.6}}]},roll:{label:"Roll the arms",beats:2,easing:"linear",keys:[{beat:0,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:18,leftHip:6,lean:-3},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}},{beat:1,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:6,leftHip:18,lean:3}},{beat:1.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}}]},bump:{label:"Bump and clap",beats:4,keys:[{beat:0,pose:{lean:-10,rightHip:22,leftHip:4,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:U},{beat:1,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}},{beat:2,pose:{lean:10,rightHip:4,leftHip:22,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:U},{beat:3,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}}]}},routine:[{move:"point",beats:8},{move:"roll",beats:4},{move:"point",beats:8,mirror:!0},{move:"bump",beats:8}]},gf={label:"Hip hop",bpm:95,stance:{leftHip:14,rightHip:14,leftKnee:20,rightKnee:20,leftShoulder:22,rightShoulder:22,leftElbow:-30,rightElbow:-30,leftFootOut:.15,rightFootOut:.15},expression:"smug",hands:{left:"relaxed",right:"relaxed"},groove:{bounce:18,accent:"down"},moves:{bounce:{label:"Bounce",beats:2,keys:[{beat:0,pose:{leftShoulder:30,rightShoulder:30,leftElbow:-50,rightElbow:-50,lean:-3,headTilt:-5,leftWrist:-20,rightWrist:-20}},{beat:1,pose:{leftShoulder:14,rightShoulder:14,leftElbow:-18,rightElbow:-18,lean:3,headTilt:5,leftWrist:0,rightWrist:0}}]},runningMan:{label:"Running man",beats:2,keys:[{beat:0,reset:!0,pose:{turn:.85,leftHip:-84,leftKnee:-112,leftAnkle:25,rightHip:-26,rightKnee:8,leftShoulder:35,leftElbow:-50,rightShoulder:45,rightElbow:75,lean:6},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftHip:-4,leftKnee:-18,leftAnkle:0,rightHip:4,rightKnee:18,leftShoulder:5,leftElbow:-40,rightShoulder:5,rightElbow:40}},{beat:1,pose:{rightHip:84,rightKnee:112,rightAnkle:25,leftHip:26,leftKnee:-8,rightShoulder:-35,rightElbow:50,leftShoulder:-45,leftElbow:-75}},{beat:1.5,pose:{rightHip:4,rightKnee:18,rightAnkle:0,leftHip:-4,leftKnee:-18,rightShoulder:-5,rightElbow:40,leftShoulder:-5,leftElbow:-40}}]},armWave:{label:"Arm wave",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0},hands:{left:"flat",right:"flat"}},{beat:.5,pose:{leftWrist:45,leftElbow:-15}},{beat:1,pose:{leftWrist:-35,leftElbow:40,leftShoulder:84}},{beat:1.5,pose:{leftWrist:0,leftElbow:-10,leftShoulder:102,headTilt:-8}},{beat:2,pose:{leftElbow:0,leftShoulder:90,rightShoulder:102,headTilt:8}},{beat:2.5,pose:{rightShoulder:84,rightElbow:40,headTilt:0}},{beat:3,pose:{rightElbow:-15,rightWrist:45}},{beat:3.5,pose:{rightElbow:0,rightWrist:-35}}]}},routine:[{move:"bounce",beats:8},{move:"runningMan",beats:8},{move:"armWave",beats:8},{move:"bounce",beats:4}]},yf={label:"Breaking (toprock)",bpm:110,stance:{leftHip:14,rightHip:14,leftKnee:14,rightKnee:14,leftShoulder:35,rightShoulder:35,leftElbow:-90,rightElbow:-90},expression:{smile:.3,leftBrow:-.3,rightBrow:-.3,browTilt:-.3},hands:{left:"fist",right:"fist"},groove:{bounce:8,accent:"down"},moves:{toprock:{label:"Toprock (Indian step)",beats:4,keys:[{beat:0,pose:{rightHip:-24,rightKnee:10,leftHip:10,leftShoulder:80,leftElbow:40,rightShoulder:55,rightElbow:-50,lean:6,headTilt:-6},easing:U},{beat:1,reset:!0,pose:{leftHip:18,rightHip:18}},{beat:2,pose:{leftHip:-24,leftKnee:10,rightHip:10,rightShoulder:80,rightElbow:40,leftShoulder:55,leftElbow:-50,lean:-6,headTilt:6},easing:U},{beat:3,reset:!0,pose:{leftHip:18,rightHip:18}}]},kick:{label:"Kick out",beats:2,keys:[{beat:0,pose:{rightHip:72,rightKnee:4,rightAnkle:-20,leftHip:4,lean:-12,leftShoulder:100,leftElbow:20},easing:U},{beat:1,reset:!0}]},freeze:{label:"B-boy stance",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:26,leftElbow:-122,rightShoulder:22,rightElbow:-118,leftHip:18,rightHip:18,leftKnee:6,rightKnee:6,lean:-4,headTilt:10,smile:.6,leftEye:.6,rightEye:.6},easing:ve},{beat:2,pose:{headTilt:14,lean:-6}}]}},routine:[{move:"toprock",beats:8},{move:"kick",beats:4},{move:"toprock",beats:8},{move:"kick",beats:4,mirror:!0},{move:"freeze",beats:4}]},bf={label:"Jazz",bpm:130,stance:{leftHip:10,rightHip:10},expression:{mouth:.55,smile:1,mouthWidth:1.2,leftBrow:.6,rightBrow:.6},hands:{left:"spread",right:"spread"},groove:{bounce:6,accent:"up"},moves:{jazzHands:{label:"Jazz hands",beats:2,easing:"linear",keys:[0,.25,.5,.75,1,1.25,1.5,1.75].map((e,t)=>({beat:e,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:t%2?4:26,rightWrist:t%2?26:4,leftHip:16,rightHip:16,leftKnee:e<1?26:8,rightKnee:e<1?26:8},hands:t===0?{left:{...K.spread,turn:2},right:{...K.spread,turn:2}}:void 0}))},kickBallChange:{label:"Kick ball change",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:88,rightKnee:0,rightAnkle:55,leftHip:4,lean:-12,leftShoulder:112,rightShoulder:112,leftWrist:15,rightWrist:15},hands:{left:"flat",right:"flat"},easing:U},{beat:1,reset:!0,pose:{rightHip:10,rightKnee:24,rightAnkle:45,leftShoulder:60,rightShoulder:60,leftElbow:-20,rightElbow:-20}},{beat:1.5,pose:{rightAnkle:0,rightKnee:6,leftAnkle:45,leftKnee:20}}]},splitDrop:{label:"Drop into the splits",beats:8,keys:[{beat:0,reset:!0},{beat:2,reset:!0,pose:{leftHip:90,rightHip:90,leftKnee:0,rightKnee:0,leftAnkle:-45,rightAnkle:-45,leftShoulder:125,rightShoulder:125,leftElbow:10,rightElbow:10},easing:"ease-in-out-cubic"},{beat:4,pose:{leftShoulder:95,rightShoulder:95,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8}},{beat:6,reset:!0,pose:{leftHip:30,rightHip:30,leftKnee:60,rightKnee:60,leftShoulder:40,rightShoulder:40},easing:"ease-in-out-cubic"},{beat:7.5,reset:!0}]},jazzSquare:{label:"Jazz square",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:-18,leftHip:8,leftShoulder:38,rightShoulder:46,leftElbow:100,rightElbow:96,lean:4},hands:{left:"pinch",right:"pinch"}},{beat:1,pose:{leftHip:18,rightHip:6,leftShoulder:46,rightShoulder:38,lean:-4}},{beat:2,pose:{rightHip:22,leftHip:6,leftShoulder:38,rightShoulder:46,lean:4}},{beat:3,pose:{leftHip:10,rightHip:10,leftShoulder:46,rightShoulder:38,lean:0}}]}},routine:[{move:"jazzHands",beats:4},{move:"kickBallChange",beats:4},{move:"kickBallChange",beats:4,mirror:!0},{move:"jazzSquare",beats:8},{move:"jazzHands",beats:4},{move:"splitDrop",beats:8}]},wf={label:"K-pop",bpm:125,stance:{leftHip:9,rightHip:9,leftKnee:4,rightKnee:4},expression:"happy",groove:{bounce:5,accent:"down"},moves:{pointCombo:{label:"Point combo",beats:4,easing:ve,keys:[{beat:0,reset:!0,pose:{rightShoulder:142,rightElbow:0,leftShoulder:25,leftElbow:-125,headTilt:6,lean:-3,lookX:.6,lookY:-.6},hands:{right:"point",left:"flat"}},{beat:1,pose:{rightShoulder:-38,headTilt:-6,lean:3,lookX:-.3,lookY:.5,rightHip:18}},{beat:2,reset:!0,pose:{leftShoulder:36,leftElbow:-96,rightShoulder:36,rightElbow:-96,leftWrist:20,rightWrist:20},hands:{left:"fist",right:"fist"}},{beat:3,reset:!0,pose:{leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8,leftHip:18,rightHip:18},hands:{left:"flat",right:"flat"}}]},heart:{label:"Big heart, finger heart",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:165,rightShoulder:165,leftElbow:46,rightElbow:46,headTilt:-8,lean:-4},hands:{left:"cupped",right:"cupped"},easing:ve},{beat:1,pose:{headTilt:8,lean:4}},{beat:2,reset:!0,pose:{rightShoulder:32,rightElbow:112,rightWrist:10,leftShoulder:20,leftElbow:-30,headTilt:10,leftEye:0,smile:1},hands:{right:"pinch",left:"relaxed"},easing:ve},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:U,keys:[{beat:0,reset:!0,pose:{lean:-9,headTilt:11,leftShoulder:55,leftElbow:-112,rightShoulder:55,rightElbow:-112,rightHip:18},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{lean:0,headTilt:0,rightHip:9}},{beat:1,pose:{lean:9,headTilt:-11,leftHip:18}},{beat:1.5,pose:{lean:0,headTilt:0,leftHip:9}}]}},routine:[{move:"pointCombo",beats:8},{move:"isolations",beats:4},{move:"heart",beats:8},{move:"pointCombo",beats:8,mirror:!0},{move:"isolations",beats:4}]},vf={label:"Bollywood",bpm:120,stance:{leftHip:10,rightHip:10},expression:{smile:1,mouth:.3,leftBrow:.4,rightBrow:.4},groove:{bounce:8,accent:"down",sway:3},moves:{lightBulb:{label:"Screw the bulb, pat the dog",beats:2,keys:[{beat:0,reset:!0,pose:{rightShoulder:160,rightElbow:12,rightWrist:-15,leftShoulder:40,leftElbow:-12,leftWrist:-45,lean:-4,rightHip:16,lookX:.5,lookY:-.6},hands:{right:{...K.cupped,roll:-30},left:{...K.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...K.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...K.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...K.cupped,roll:30}}}]},thumka:{label:"Thumka",beats:2,keys:[{beat:0,reset:!0,pose:{lean:-11,rightHip:22,leftHip:2,leftKnee:14,rightShoulder:45,rightElbow:-105,leftShoulder:128,leftElbow:18,leftWrist:35,headTilt:10,lookX:-.5},hands:{right:"fist",left:{...K.open,turn:2}},easing:U},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:U},{beat:1.5,pose:{lean:-4,rightHip:12,headTilt:6}}]},flick:{label:"Cross and flick",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26},hands:{left:"fist",right:"fist"}},{beat:1,pose:{leftShoulder:132,rightShoulder:132,leftElbow:0,rightElbow:0,leftWrist:30,rightWrist:30,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10,stretch:1.03},hands:{left:"spread",right:"spread"},easing:U},{beat:2,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftWrist:0,rightWrist:0,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26,stretch:1},hands:{left:"fist",right:"fist"}},{beat:3,pose:{leftShoulder:62,rightShoulder:62,leftElbow:0,rightElbow:0,leftWrist:35,rightWrist:35,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10},hands:{left:"spread",right:"spread"},easing:U}]}},routine:[{move:"thumka",beats:4},{move:"lightBulb",beats:8},{move:"flick",beats:8},{move:"thumka",beats:4,mirror:!0},{move:"lightBulb",beats:8,mirror:!0}]},kf={label:"Bhangra",bpm:100,stance:{leftShoulder:150,rightShoulder:150,leftElbow:18,rightElbow:18,leftHip:10,rightHip:10},expression:{mouth:.6,smile:1,mouthWidth:1.2,leftBrow:.5,rightBrow:.5},hands:{left:"open",right:"open"},groove:{bounce:12,accent:"down"},moves:{basic:{label:"Bhangra step",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:58,rightKnee:104,rightAnkle:30,leftShoulder:162,rightShoulder:140,headTilt:7}},{beat:.5,reset:!0,pose:{stretch:.98}},{beat:1,reset:!0,pose:{leftHip:58,leftKnee:104,leftAnkle:30,rightShoulder:162,leftShoulder:140,headTilt:-7}},{beat:1.5,reset:!0,pose:{stretch:.98}}]},dhamaal:{label:"Dhamaal (jump, arms up)",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94}},{beat:.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"},{beat:1,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94},hands:{left:"open",right:"open"},easing:"ease-in-quad"},{beat:1.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"}]}},routine:[{move:"basic",beats:8},{move:"dhamaal",beats:4},{move:"basic",beats:8},{move:"dhamaal",beats:4}]},Sf={label:"Bharatanatyam",bpm:80,stance:{...{leftHip:42,rightHip:42,leftKnee:82,rightKnee:82,leftFootOut:.3,rightFootOut:.3},leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0,leftWrist:75,rightWrist:75},expression:{smile:.5,leftEye:1.2,rightEye:1.2,leftBrow:.3,rightBrow:.3},hands:{left:"pataka",right:"pataka"},groove:{bounce:0},moves:{tatta:{label:"Tatta adavu (stamps)",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:104,rightAnkle:-18}},{beat:.3,reset:!0,easing:"ease-in-quad",taps:["rightToe","rightHeel"]},{beat:1,reset:!0,pose:{leftHip:48,leftKnee:104,leftAnkle:-18}},{beat:1.3,reset:!0,easing:"ease-in-quad",taps:["leftToe","leftHeel"]}]},natta:{label:"Natta adavu (stretch and look)",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:52,rightKnee:0,rightAnkle:-40,rightShoulder:125,rightWrist:60,leftShoulder:25,leftElbow:-125,leftWrist:0,headTilt:8,lookX:.9,lookY:-.4,lean:-6}},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:52,leftKnee:0,leftAnkle:-40,leftShoulder:125,leftWrist:60,rightShoulder:25,rightElbow:-125,rightWrist:0,headTilt:-8,lookX:-.9,lookY:-.4,lean:6}},{beat:3,reset:!0}]},alapadma:{label:"Alapadma (lotus) to the sky",beats:4,keys:[{beat:0,reset:!0,pose:{rightShoulder:145,rightElbow:20,rightWrist:30,leftShoulder:28,leftElbow:-125,leftWrist:0,lookX:.7,lookY:-.9,headTilt:6},hands:{right:"alapadma",left:"pataka"}},{beat:1,pose:{rightWrist:55,headTilt:9}},{beat:2,reset:!0,pose:{leftShoulder:145,leftElbow:20,leftWrist:30,rightShoulder:28,rightElbow:-125,rightWrist:0,lookX:-.7,lookY:-.9,headTilt:-6},hands:{left:"alapadma",right:"pataka"}},{beat:3,pose:{leftWrist:55,headTilt:-9}}]}},routine:[{move:"tatta",beats:8},{move:"natta",beats:8},{move:"alapadma",beats:8},{move:"tatta",beats:4}]},Tf={label:"Charleston",bpm:150,stance:{leftHip:10,rightHip:10,leftKnee:10,rightKnee:10,leftShoulder:30,rightShoulder:30,leftElbow:20,rightElbow:20},expression:{mouth:.4,smile:1,leftBrow:.5,rightBrow:.5},hands:{left:{...K.spread,turn:2},right:{...K.spread,turn:2}},groove:{bounce:8,accent:"down"},moves:{basic:{label:"Kick forward, kick back",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:8,rightAnkle:45,leftShoulder:75,rightShoulder:15,leftElbow:30,rightElbow:-10,lean:-7,headTilt:-5},easing:U},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:18,leftKnee:85,leftAnkle:35,rightShoulder:75,leftShoulder:15,rightElbow:30,leftElbow:-10,lean:7,headTilt:5},easing:U},{beat:3,reset:!0}]},twist:{label:"Swivel (heels in, heels out)",beats:2,keys:[{beat:0,reset:!0,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}},{beat:1,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:1.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}}]},kneeCross:{label:"Crossing knees",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,leftElbow:0,rightElbow:0,lean:0,lookY:.6}},{beat:.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}},{beat:1,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,lookY:.6}},{beat:1.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}}]}},routine:[{move:"basic",beats:8},{move:"twist",beats:8},{move:"kneeCross",beats:8},{move:"basic",beats:8,mirror:!0},{move:"twist",beats:4}]},Mf={label:"Tap",bpm:120,stance:{turn:.8,leftHip:-3,rightHip:3,leftKnee:-10,rightKnee:10,leftShoulder:12,rightShoulder:12,leftElbow:-40,rightElbow:40,leftWrist:-15,rightWrist:15,lean:4},expression:{smile:.9,mouth:.2,leftBrow:.3,rightBrow:.3,lookY:.3},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:6,accent:"down"},moves:{shuffleBallChange:{label:"Shuffle ball change",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:34,rightKnee:8,rightAnkle:30,leftShoulder:30,rightShoulder:-10},taps:["rightToe"]},{beat:.25,pose:{rightHip:24,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:.5,pose:{rightHip:-8,rightKnee:14,rightAnkle:50,leftAnkle:15,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:.75,pose:{rightHip:3,rightKnee:10,rightAnkle:0,leftAnkle:0},taps:["leftHeel"]},{beat:1,reset:!0,pose:{leftHip:-34,leftKnee:-8,leftAnkle:30,rightShoulder:-30,leftShoulder:10},taps:["leftToe"]},{beat:1.25,pose:{leftHip:-24,leftKnee:-62,leftAnkle:40},taps:["leftToe"]},{beat:1.5,pose:{leftHip:8,leftKnee:-14,leftAnkle:50,rightAnkle:15,leftShoulder:12,rightShoulder:12},taps:["leftToe"]},{beat:1.75,pose:{leftHip:-3,leftKnee:-10,leftAnkle:0,rightAnkle:0},taps:["rightHeel"]}]},timeStep:{label:"Single time step",beats:4,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:8,rightKnee:4,rightAnkle:0,leftShoulder:25,rightShoulder:-20},taps:["rightToe","rightHeel"]},{beat:.5,pose:{rightHip:34,rightKnee:8,rightAnkle:30},taps:["rightToe"]},{beat:.75,pose:{rightHip:22,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:1,pose:{rise:.05,leftAnkle:45,leftKnee:-4,leftHip:-2,rightHip:26,rightKnee:70,stretch:1.03}},{beat:1.25,pose:{rise:0,leftAnkle:0,leftKnee:-14,stretch:1},taps:["leftToe"]},{beat:1.5,pose:{rightHip:4,rightKnee:12,rightAnkle:0,rightShoulder:25,leftShoulder:-20},taps:["rightToe"]},{beat:2,pose:{leftHip:-30,leftKnee:-6,leftAnkle:35},taps:["leftToe"]},{beat:2.25,pose:{leftHip:-4,leftKnee:-12,leftAnkle:0},taps:["leftToe"]},{beat:3,pose:{rightHip:10,rightAnkle:35,rightKnee:18,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:3.5,pose:{rightHip:3,rightKnee:10,rightAnkle:0}}]},heelToe:{label:"Heel toe",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:26,rightKnee:0,rightAnkle:-35,leftShoulder:30,rightShoulder:-20},taps:["rightHeel"]},{beat:.5,pose:{rightHip:-16,rightKnee:24,rightAnkle:55,leftShoulder:-15,rightShoulder:25},taps:["rightToe"]},{beat:1,reset:!0,pose:{leftHip:-26,leftKnee:0,leftAnkle:-35,rightShoulder:-30,leftShoulder:20},taps:["leftHeel"]},{beat:1.5,pose:{leftHip:16,leftKnee:-24,leftAnkle:55,rightShoulder:15,leftShoulder:-25},taps:["leftToe"]}]},crampRoll:{label:"Cramp roll",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:12,rightKnee:26,leftHip:-12,leftKnee:-26}},{beat:.5,pose:{rightAnkle:40,rise:.02},taps:["rightToe"]},{beat:.625,pose:{leftAnkle:40},taps:["leftToe"]},{beat:.75,pose:{rightAnkle:0,rise:0},taps:["rightHeel"]},{beat:.875,pose:{leftAnkle:0},taps:["leftHeel"]},{beat:1,pose:{rightShoulder:135,leftShoulder:125,leftElbow:0,rightElbow:0,leftWrist:0,rightWrist:30,rightKnee:8,leftKnee:-8,rightHip:4,leftHip:-4},hands:{left:{...K.spread,turn:2},right:{...K.spread,turn:2}}},{beat:1.75,reset:!0}]}},routine:[{move:"shuffleBallChange",beats:8},{move:"timeStep",beats:4},{move:"timeStep",beats:4,mirror:!0},{move:"heelToe",beats:8},{move:"crampRoll",beats:4}]},_t={disco:mf,hipHop:gf,breaking:yf,jazz:bf,kpop:wf,bollywood:vf,bhangra:kf,bharatanatyam:Sf,charleston:Tf,tap:Mf,popping:{label:"Popping (glides, moonwalk)",bpm:100,stance:{leftHip:9,rightHip:9,leftShoulder:16,rightShoulder:16,leftElbow:-24,rightElbow:-24},expression:{smile:.35,leftEye:.85,rightEye:.85,leftBrow:-.2,rightBrow:-.2},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:0},moves:{sideGlide:{label:"Side glide",beats:2,easing:"linear",travel:.2,keys:[{beat:0,reset:!0,pose:{leftHip:11,leftKnee:0,leftAnkle:0,rightHip:36,rightKnee:45,rightAnkle:45,rightShoulder:80,rightElbow:-10,rightWrist:10,leftShoulder:28,leftElbow:18,lean:-2,headTilt:4,lookX:.7},hands:{right:"flat",left:"relaxed"}},{beat:1,pose:{leftHip:27,leftKnee:54,leftAnkle:45,rightHip:-1,rightKnee:0,rightAnkle:0,rightShoulder:74,rightWrist:-10,lean:2}}]},moonwalk:{label:"Moonwalk",beats:2,easing:"linear",travel:-.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:4,headTilt:-4,leftHip:-12,leftKnee:0,leftAnkle:0,rightHip:23,rightKnee:57,rightAnkle:45,leftShoulder:-10,leftElbow:-45,rightShoulder:14,rightElbow:50}},{beat:1,pose:{leftHip:-23,leftKnee:-57,leftAnkle:45,rightHip:12,rightKnee:0,rightAnkle:0,leftShoulder:-14,leftElbow:-50,rightShoulder:10,rightElbow:45}}]},forwardGlide:{label:"Forward glide",beats:2,easing:"linear",travel:.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:2,leftHip:16,leftKnee:0,leftAnkle:0,rightHip:33,rightKnee:59,rightAnkle:45,leftShoulder:12,leftElbow:-40,rightShoulder:-12,rightElbow:40}},{beat:1,pose:{leftHip:-33,leftKnee:-59,leftAnkle:45,rightHip:-16,rightKnee:0,rightAnkle:0,leftShoulder:-12,leftElbow:-40,rightShoulder:12,rightElbow:40}}]},toeStand:{label:"Toe stand",beats:4,keys:[{beat:0,reset:!0,pose:{leftHip:6,rightHip:6,leftKnee:0,rightKnee:0,leftAnkle:65,rightAnkle:65,rightShoulder:150,rightElbow:75,leftShoulder:30,leftElbow:20,headTilt:-10,lookY:.4},hands:{right:"fist",left:"fist"},easing:ve},{beat:2,pose:{headTilt:-14,lean:-2}}]}},routine:[{move:"sideGlide",beats:4},{move:"sideGlide",beats:4,mirror:!0},{move:"moonwalk",beats:8},{move:"forwardGlide",beats:8},{move:"toeStand",beats:4}]}},fn=e=>Math.min(1,Math.max(0,e));function Ef(e){const t={...G,turn:e.view},n=[];for(const i of e.keys){const s=n[n.length-1],r=!s||i.reset?t:s.pose;n.push({at:i.at,pose:{...r,...i.pose},easing:i.easing})}return n}function Af(e){return e-xf*Math.sin(2*Math.PI*e)/(2*Math.PI)}const xf=.5;function Pf(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function la(e,t){const n=typeof e=="string"?pn[e]:e,i=Ef(n),s=fn(t);let r=0;for(let f=0;f<i.length;f++)i[f].at<=s&&(r=f);const o=i[r],a=i[Math.min(r+1,i.length-1)],l=a.at>o.at?(s-o.at)/(a.at-o.at):0,c=Ut(o.pose,a.pose,V(a.easing??"ease-in-out")(fn(l))),h=Pf(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*Af(h),rise:4*n.height*h*(1-h)}}function ca(e,t,n){const i=typeof e=="string"?pn[e]:e,s=fn(t),r=fn((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function _f(e,t,n={}){const i=typeof t=="string"?pn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(h,f)=>{const u=f/o;return{time:s+u*r,progress:u,pose:la(i,u)}}),c=Object.keys(G).filter(h=>a.some(f=>f.pose[h]!==G[h])).map(h=>({id:`${e}-${h}`,target:e,property:h,keyframes:a.map(f=>({time:f.time,value:f.pose[h]}))}));if(n.height!==void 0&&i.travel!==0){const h=(n.facing??1)<0?-1:1;c.push({id:`${e}-x`,target:e,property:"x",keyframes:a.map(f=>({time:f.time,value:(n.x??0)+h*ca(i,f.progress,n.height)}))})}return c}const Cf={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},If={leftHip:0,leftKnee:0,rightHip:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-172,rightShoulder:172,leftElbow:0,rightElbow:0,lean:0,stretch:1.08,headTilt:0},dn={leftHip:-128,leftKnee:-152,rightHip:128,rightKnee:152,leftAnkle:30,rightAnkle:30,leftShoulder:-78,rightShoulder:78,leftElbow:-48,rightElbow:48,lean:26,stretch:1,headTilt:14},Hf={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},$f={leftHip:-58,leftKnee:-100,rightHip:58,rightKnee:100,leftAnkle:0,rightAnkle:0,leftShoulder:-80,rightShoulder:80,leftElbow:-10,rightElbow:10,lean:20,stretch:.93};function zt(e,t,n,i,s,r=1300){return{label:e,view:1,spin:t,height:n,travel:i,takeoff:.27,landing:.8,duration:r,keys:[{at:0,reset:!0},{at:.16,pose:Cf},{at:.27,pose:If,easing:"ease-out-quad"},...s,{at:.76,pose:Hf},{at:.86,pose:$f,easing:"ease-out-quad"},{at:1,reset:!0}]}}const pn={frontFlip:zt("Front flip (tuck)",360,.56,.35,[{at:.38,pose:dn,easing:"ease-out-cubic"},{at:.64,pose:dn}]),backFlip:zt("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...dn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...dn,lean:18}}]),layout:zt("Back layout (straight body)",-360,.66,-.2,[{at:.4,pose:{leftHip:8,rightHip:-8,leftKnee:0,rightKnee:0,leftAnkle:60,rightAnkle:60,leftShoulder:-178,rightShoulder:178,lean:-18,headTilt:-14}},{at:.64,pose:{leftHip:-4,rightHip:4,lean:-6,headTilt:-4,leftShoulder:-150,rightShoulder:150}}],1400),scissorFlip:zt("Scissor flip",360,.6,.45,[{at:.36,pose:{leftHip:-105,leftKnee:0,rightHip:-40,rightKnee:-20,leftAnkle:50,rightAnkle:50,leftShoulder:-150,rightShoulder:150,leftElbow:0,rightElbow:0,lean:12},easing:"ease-out-cubic"},{at:.52,pose:{leftHip:40,leftKnee:20,rightHip:105,rightKnee:0,leftShoulder:-140,rightShoulder:140}},{at:.66,pose:{leftHip:-30,leftKnee:-20,rightHip:30,rightKnee:20,leftShoulder:-110,rightShoulder:110,lean:6}}]),sideFlip:{label:"Side flip (tuck)",view:0,spin:360,height:.55,travel:.4,takeoff:.27,landing:.8,duration:1300,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:20,rightShoulder:20,lean:-10,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:165,rightShoulder:165,lean:6,stretch:1.08},easing:"ease-out-quad"},{at:.38,pose:{leftHip:105,rightHip:105,leftKnee:135,rightKnee:135,leftShoulder:40,rightShoulder:40,leftElbow:-95,rightElbow:-95,lean:0,stretch:1,headTilt:10},easing:"ease-out-cubic"},{at:.64,pose:{}},{at:.76,pose:{leftHip:20,rightHip:20,leftKnee:20,rightKnee:20,leftAnkle:10,rightAnkle:10,leftShoulder:100,rightShoulder:100,leftElbow:0,rightElbow:0,headTilt:0}},{at:.86,pose:{leftHip:24,rightHip:24,leftKnee:48,rightKnee:48,leftAnkle:0,rightAnkle:0,leftShoulder:70,rightShoulder:70,stretch:.93},easing:"ease-out-quad"},{at:1,reset:!0}]},cartwheel:{label:"Cartwheel",view:0,spin:360,height:.155,travel:.9,takeoff:.2,landing:.86,duration:1600,keys:[{at:0,reset:!0},{at:.12,pose:{leftShoulder:165,rightShoulder:165,rightHip:30,rightKnee:0,lean:-6}},{at:.24,pose:{leftShoulder:172,rightShoulder:172,leftHip:55,rightHip:55,leftKnee:0,rightKnee:0,leftAnkle:40,rightAnkle:40,lean:0}},{at:.75,pose:{}},{at:.9,pose:{leftHip:30,rightHip:12,leftAnkle:0,rightAnkle:0,leftShoulder:150,rightShoulder:150}},{at:1,reset:!0}]},splitLeap:zt("Split leap (grand jeté)",0,.36,.9,[{at:.4,pose:{leftHip:-96,rightHip:-84,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-130,rightShoulder:-105,leftElbow:0,rightElbow:0,lean:4,headTilt:-6},easing:"ease-out-cubic"},{at:.64,pose:{lean:2}}]),toeTouch:{label:"Toe touch (straddle jump)",view:0,spin:0,height:.36,travel:0,takeoff:.27,landing:.8,duration:1200,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:-20,rightShoulder:-20,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:170,rightShoulder:170,stretch:1.06},easing:"ease-out-quad"},{at:.42,pose:{leftHip:104,rightHip:104,leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,stretch:1,headTilt:0},easing:"ease-out-cubic"},{at:.62,pose:{}},{at:.76,pose:{leftHip:12,rightHip:12,leftAnkle:10,rightAnkle:10,leftShoulder:120,rightShoulder:120}},{at:.86,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftAnkle:0,rightAnkle:0,leftShoulder:60,rightShoulder:60,stretch:.94},easing:"ease-out-quad"},{at:1,reset:!0}]},backHandspring:zt("Back handspring",-360,.16,-.7,[{at:.38,pose:{leftHip:10,rightHip:-10,leftKnee:0,rightKnee:0,leftShoulder:-178,rightShoulder:178,lean:-26,headTilt:-20}},{at:.6,pose:{leftHip:-40,rightHip:40,leftKnee:-20,rightKnee:20,lean:6,headTilt:0}}],1200)},Di=.215,Ni=.205,Rf=.065,ha=.035,Ff=.165,Of=.155,Lf=12,Bf=e=>e*Math.PI/180,J={turn:0,lean:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function et(e={}){return{...J,...e}}const Df=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Nf(e){const t={};for(const[n,i]of Object.entries(e)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(r,o,a,l)=>`${o}${a==="left"?"right":"left"}${l}`);t[s]=Df.has(n)?-i:i}return t}function nt(e,t){const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n}const ua={rest:J,wave:et({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:et({...nt("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:et({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:et({...nt("arm",{spread:50,bend:-105,elbow:0}),...nt("leg",{spread:9}),smile:.8}),think:et({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:et({...nt("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:et({...nt("leg",{swing:90,knee:90,spread:4}),...nt("arm",{swing:25,elbow:45,spread:8})}),kneel:et({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...nt("arm",{swing:20,elbow:30})}),crouch:et({...nt("leg",{swing:75,knee:140,spread:6}),lean:25,...nt("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:et({lean:82,"head.nod":-35,...nt("arm",{swing:80,elbow:0,spread:4}),...nt("leg",{knee:92,ankle:-88})}),lieDown:et({roll:90,...nt("arm",{spread:8}),"head.nod":0})};function fa(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-ha-(Di+Ni)),r=l=>({id:`arm.${l}`,parent:"spine",offset:[(l==="left"?1:-1)*n,-.035,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Ff,width:[1.25,.9]},{length:Of,width:[.9,.75]}]}),o=l=>({id:`leg.${l}`,parent:null,offset:[(l==="left"?1:-1)*i,0,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Di,width:[1.45,1.05]},{length:Ni,width:[1.05,.85]},{length:Rf,width:[.95,.7]}]}),a=(l,c)=>l[c]??J[c]??0;return{id:"human",hipHeight:Di+Ni,chains:[o("left"),o("right"),{id:"spine",parent:null,rest:[0,1,0],bones:[{length:s/2,width:[1.7,1.4]},{length:s/2,width:[1.4,1.1]}]},{id:"neck",parent:"spine",rest:[0,1,0],bones:[{length:ha,width:[1,.9]}]},r("left"),r("right")],head:{on:"neck",size:t},contacts:[...["left","right"].flatMap(l=>[{chain:`leg.${l}`,joint:1},{chain:`leg.${l}`,joint:2},{chain:`leg.${l}`,joint:3},{chain:`arm.${l}`,joint:1},{chain:`arm.${l}`,joint:2}]),{chain:"spine",joint:0},{chain:"spine",joint:1},{chain:"spine",joint:2},{head:"top"}],angles(l,c){if(c.id==="spine"){const d=-a(l,"lean")/2,g=a(l,"side")/2;return[{swing:d,spread:g},{swing:d,spread:g}]}if(c.id==="neck")return[{swing:0,spread:0}];const[h,f]=c.id.split("."),u=d=>a(l,`${h}.${f}.${d}`);if(h==="arm")return[{swing:u("swing"),spread:u("spread")},{swing:u("elbow"),spread:u("bend")}];const p=(c.side??1)*u("rotate"),m=1-Math.cos(Bf(u("rotate")));return[{swing:u("swing"),spread:u("spread"),yaw:p},{swing:-u("knee"),spread:0,yaw:p},{swing:90+u("ankle")-m*(u("swing")-u("knee")),spread:0,yaw:(Lf+u("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[f,u]=c.id.split("."),p=m=>`${f}.${u}.${m}`;return f==="arm"?{...l,[p("swing")]:h[0].swing,[p("spread")]:h[0].spread,[p("elbow")]:h[1].swing,[p("bend")]:h[1].spread}:f==="leg"?{...l,[p("swing")]:h[0].swing,[p("spread")]:h[0].spread,[p("knee")]:-h[1].swing}:l},boneScale(l,c){const h=Math.min(3,Math.max(.3,a(l,"stretch")));return c?.id.startsWith("arm.")?Math.sqrt(h):h},headPose(l){const c=Math.min(3,Math.max(.3,a(l,"stretch")));return{yaw:a(l,"head.turn"),nod:a(l,"head.nod"),tilt:a(l,"head.tilt"),sx:1/Math.sqrt(c),sy:Math.sqrt(c)}},landmarks:{neck:["neck",0],"shoulder.left":["arm.left",0],"elbow.left":["arm.left",1],"hand.left":["arm.left",2],"shoulder.right":["arm.right",0],"elbow.right":["arm.right",1],"hand.right":["arm.right",2],"hip.left":["leg.left",0],"knee.left":["leg.left",1],"ankle.left":["leg.left",2],"toe.left":["leg.left",3],"hip.right":["leg.right",0],"knee.right":["leg.right",1],"ankle.right":["leg.right",2],"toe.right":["leg.right",3]}}}function Wf(e){const t=e.split(".");if(t[0]==="hand"&&t.length>=3){const i=`${t[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},r=t.slice(2).join(".");return`${i} · ${s[r]??r.replace(".curl"," curl").replace(".across"," across")}`}if(t.length===3){const[i,s,r]=t;return`${`${s==="left"?"Left":"Right"} ${i}`} · ${{swing:"forward / back",spread:"out / in",elbow:"elbow bend",bend:"forearm out / in",knee:"knee bend",ankle:"foot tilt",toeOut:"toes out / in",rotate:"turn out at the hip"}[r]??r}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[e]??e}const Yf={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Kf=Object.fromEntries(Object.entries(tt).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[Yf[n]??n,i]))]));function qf(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...J,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:o,human:a,s:l}of r){const c=e[`${o}Shoulder`],h=e[`${o}Elbow`];s[`arm.${a}.spread`]=c*i,s[`arm.${a}.swing`]=l*c*n,s[`arm.${a}.bend`]=h*i,s[`arm.${a}.elbow`]=l*h*n;const f=e[`${o}Hip`],u=e[`${o}Knee`],p=i+l*n;s[`leg.${a}.rotate`]=90*i,s[`leg.${a}.spread`]=0,s[`leg.${a}.swing`]=f*p,s[`leg.${a}.knee`]=u*p,s[`leg.${a}.ankle`]=-(e[`${o}Ankle`]??0),s[`leg.${a}.toeOut`]=(e[`${o}FootOut`]??0)*Xf,s[`eye.${a}`]=e[`${o}Eye`],s[`brow.${a}`]=e[`${o}Brow`],t&&Object.assign(s,Vf(a,t[o]??N,e[`${o}Wrist`]??0,n))}s.lean=e.lean*n,s.side=e.lean*i,s["head.tilt"]=e.headTilt*i,s["head.nod"]=e.headTilt*n;for(const o of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[o]=e[o];return s.lift=e.rise??0,s.roll=e.spin??0,s}const Xf=70;function Vf(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(N))r[`hand.${e}.${o}`]=t[o]??N[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}const st=e=>e*Math.PI/180;function da([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function Wi([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Ct([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const vt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],mn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],gn=(e,t)=>Wi(da(e,t.swing),t.spread);function Yi(e,t){const n=Ct(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function yn(e,t,n){const i=n,r=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],o={};for(const d of e.chains){const g=d.parent?o[d.parent]:void 0;if(d.parent&&!g)throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);const y=d.at??(g?g.joints3.length-1:0),v=g?g.joints3[y]:r,w=g?g.frames[Math.max(0,y-1)]:{swing:0,spread:0},T=d.offset?vt(v,gn(mn(d.offset,i),w)):v,k=d.side??1,S=e.boneScale?.(t,d)??1,E=e.angles(t,d),_=[T],M=[];let x=w.swing,A=w.spread;d.bones.forEach((P,C)=>{const I=E[C]??{swing:0,spread:0};x+=st(I.swing),A+=st(I.spread)*k,M.push({swing:x,spread:A});const H=Ct(gn(d.rest,{swing:x,spread:A}),st(I.yaw??0));_.push(vt(_[C],mn(H,P.length*i*S)))}),o[d.id]={joints3:_,frames:M}}const a=o[e.head.on],l=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=a.frames[a.frames.length-1],h=e.head.size/2*i,f=h*l.sx,u=h*l.sy,p=d=>gn(Ct(da(Wi(d,-st(l.tilt)),-st(l.nod)),st(l.yaw)),c),m=vt(a.joints3[a.joints3.length-1],p([0,u,0]));return{height:i,root:r,chains:o,head:{center:m,rx:f,ry:u,toBody:p}}}function Ki(e,t,n){const i=n.height,s=st(90*(t.turn??0)),r=yn(e,t,i),{root:o}=r,a=r.chains,{rx:l,ry:c}=r.head,h=r.head.toBody,f=r.head.center,u={};for(const M of e.chains){const{joints3:x,frames:A}=a[M.id],P=x.map(C=>Yi(C,s));u[M.id]={id:M.id,joints3:x,frames:A,points:P.map(C=>C.point),depths:P.map(C=>C.depth)}}const p=Yi(f,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(M=>Ct(h(M),s)),d=Yi(o,s).point,g=st(t.roll??0),y=M=>{const x=M.x-d.x,A=M.y-d.y;return{x:d.x+x*Math.cos(g)-A*Math.sin(g),y:d.y+x*Math.sin(g)+A*Math.cos(g)}},v=([M,x,A])=>[M*Math.cos(g)+x*Math.sin(g),-M*Math.sin(g)+x*Math.cos(g),A];for(const M of Object.values(u))M.points=M.points.map(y);const w={center:y(p.point),depth:p.depth,rx:l,ry:c,angle:0,axes:m.map(v)},T=w.axes[1];w.angle=Math.atan2(T[0],T[1]);const k=M=>{if("head"in M)return{x:w.center.x+T[0]*c,y:w.center.y-T[1]*c};const x=u[M.chain];return x.points[Math.min(M.joint,x.points.length-1)]};let S=0;(n.contact??"ground")==="ground"&&(S=-Math.max(...e.contacts.map(M=>k(M).y))),S-=(t.lift??0)*i;const E=M=>({x:M.x,y:M.y+S});for(const M of Object.values(u))M.points=M.points.map(E);w.center=E(w.center);const _=e.contacts.map(M=>({spec:M,point:k(M)}));return{height:i,view:s,chains:u,head:w,hip:E(y(d)),contacts:_,groundY:Math.max(..._.map(M=>M.point.y))}}const qi=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],pa=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function Xi(e,t,n){const i=n.height,s=st(90*(t.turn??0)),r=st(t.roll??0),o=yn(e,t,i),a=Ct(o.root,s),l=g=>vt(Wi(qi(Ct(g,s),a),-r),a),c={};for(const g of e.chains)c[g.id]=o.chains[g.id].joints3.map(l);const h=l(o.head.center),f=g=>pa(qi(l(vt(o.head.center,o.head.toBody(g))),h)),u=[f([1,0,0]),f([0,1,0]),f([0,0,1])],p=g=>{if("head"in g)return vt(h,mn(u[1],o.head.ry));const y=c[g.chain];return y[Math.min(g.joint,y.length-1)]};let m=0;(n.contact??"ground")==="ground"&&(m=-Math.min(...e.contacts.map(g=>p(g)[1]))),m+=(t.lift??0)*i;const d=g=>[g[0],g[1]+m,g[2]];return{height:i,hip:d(a),chains:Object.fromEntries(Object.entries(c).map(([g,y])=>[g,y.map(d)])),head:{center:d(h),rx:o.head.rx,ry:o.head.ry,axes:u}}}function Vi(e,t,n,i){const s=n.height,r=st(90*(t.turn??0)),o=yn(e,t,s),a=Xi(e,t,n),l=a.hip,c=a.chains,h=a.head.center,f=M=>{if("head"in M)return vt(h,mn(a.head.axes[1],a.head.ry));const x=c[M.chain];return x[Math.min(M.joint,x.length-1)]},u=i.toView(l),p=i.toScreen(u),m=i.toScreen([u[0]+1,u[1],u[2]]),d=Math.hypot(m.x-p.x,m.y-p.y),g=M=>{const x=i.toView(M);return{point:i.toScreen(x),depth:x[2]*d}},y={};for(const M of e.chains){const x=c[M.id].map(g);y[M.id]={id:M.id,joints3:o.chains[M.id].joints3,frames:o.chains[M.id].frames,points:x.map(A=>A.point),depths:x.map(A=>A.depth)}}const v=i.toView(h),w=i.toScreen(v),T=i.toScreen([v[0]+1,v[1],v[2]]),k=Math.hypot(T.x-w.x,T.y-w.y),S=a.head.axes.map(M=>pa(qi(i.toView(vt(h,M)),v))),E={center:w,depth:v[2]*d,rx:o.head.rx*k,ry:o.head.ry*k,angle:Math.atan2(S[1][0],S[1][1]),axes:S},_=e.contacts.map(M=>({spec:M,point:g(f(M)).point}));return{height:s*d,view:r,chains:y,head:E,hip:p,contacts:_,groundY:Math.max(..._.map(M=>M.point.y))}}function ma(e,[t,n,i]){const[s,r,o]=e.axes,a=[s[0]*t*e.rx+r[0]*n*e.ry+o[0]*i*e.rx,s[1]*t*e.rx+r[1]*n*e.ry+o[1]*i*e.rx,s[2]*t*e.rx+r[2]*n*e.ry+o[2]*i*e.rx],l=Math.hypot(t,n,i)||1,c=(s[2]*t+r[2]*n+o[2]*i)/l;return{point:{x:e.center.x+a[0],y:e.center.y-a[1]},depth:e.depth+a[2],facing:c}}class ga{positions=[];normals=[];indices=[];vertex(t,n,i,s,r,o){const a=Math.hypot(s,r,o)||1;return this.positions.push(t,n,i),this.normals.push(s/a,r/a,o/a),this.positions.length/3-1}triangle(t,n,i){this.indices.push(t,n,i)}quad(t,n,i,s){this.indices.push(t,n,i,t,i,s)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function Uf(e){const t=new Map,n=[];for(let s=0;s<e.positions.length/3;s++){const r=[0,1,2].map(o=>Math.round(e.positions[s*3+o]*1e6)).join(",");t.has(r)||t.set(r,s),n.push(t.get(r))}const i=new Map;for(let s=0;s<e.indices.length/3;s++)for(let r=0;r<3;r++){const o=n[e.indices[s*3+r]],a=n[e.indices[s*3+(r+1)%3]];if(o===a)continue;const l=o<a?`${o}-${a}`:`${a}-${o}`,c=i.get(l);c?c.faces.push(s):i.set(l,{a:Math.min(o,a),b:Math.max(o,a),faces:[s]})}return[...i.values()]}const Ui=Math.PI*2;function zf(e,t=16){const n=new ga,i=Math.max(6,Math.round(t)),s=Math.max(3,Math.round(i/2)),r=[];for(let o=0;o<=s;o++){const a=o/s*Math.PI,l=[];for(let c=0;c<=i;c++){const h=c/i*Ui,f=Math.sin(a)*Math.sin(h),u=Math.cos(a),p=Math.sin(a)*Math.cos(h);l.push(n.vertex(f*e,u*e,p*e,f,u,p))}r.push(l)}for(let o=0;o<s;o++)for(let a=0;a<i;a++){const l=r[o][a],c=r[o+1][a],h=r[o+1][a+1],f=r[o][a+1];o>0&&n.triangle(l,c,f),o<s-1&&n.triangle(c,h,f)}return n.build()}function ya(e,t,n,i,s){const r=e.vertex(0,n,0,0,i,0),o=Array.from({length:s},(a,l)=>{const c=l/s*Ui;return e.vertex(Math.sin(c)*t,n,Math.cos(c)*t,0,i,0)});for(let a=0;a<s;a++){const l=o[a],c=o[(a+1)%s];i===1?e.triangle(r,l,c):e.triangle(r,c,l)}}function jf(e,t,n=24){const i=new ga,s=Math.max(6,Math.round(n)),r=t/2,o=-t/2,a=h=>Array.from({length:s+1},(f,u)=>{const p=u/s*Ui;return i.vertex(Math.sin(p)*e,h,Math.cos(p)*e,Math.sin(p),0,Math.cos(p))}),l=a(o),c=a(r);for(let h=0;h<s;h++)i.quad(l[h],l[h+1],c[h+1],c[h]);return ya(i,e,r,1,s),ya(i,e,o,-1,s),i.build()}function ba(e){const t=Array.from({length:e.indices.length/3},()=>[]);for(const n of Uf(e))for(const i of n.faces){const s=n.faces.find(r=>r!==i)??-1;t[i].push({a:n.a,b:n.b,across:s})}return{...e,faceEdges:t}}const bn=e=>e*180/Math.PI,jt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],zi=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],ke=e=>Math.hypot(e[0],e[1],e[2]),ji=e=>{const t=ke(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},wn=e=>Math.atan2(Math.sin(e),Math.cos(e));function wa(e){const[t,n,i]=ji(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function Gf(e,t,n,i,s){const r=e.chains.find(x=>x.id===n);if(!r)throw new Error(`reach: no chain ${n} in ${e.id}`);if(r.bones.length<2||r.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!e.withAngles)throw new Error(`reach: the ${e.id} plan cannot set angles`);const o=Ki(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=ke(jt(a.joints3[1],a.joints3[0])),h=ke(jt(a.joints3[2],a.joints3[1])),f=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},u=jt(i,l),p=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,ke(u))),m=ji(u),d=r.parent!==null,g=gn(r.pole??(d?[0,-.35,-1]:[0,0,1]),f);let y=jt(g,[m[0]*zi(g,m),m[1]*zi(g,m),m[2]*zi(g,m)]);ke(y)<1e-6&&(y=Ct([1,0,0],0)),y=ji(y);const v=(c*c+p*p-h*h)/(2*c*p),w=Math.sqrt(Math.max(0,1-v*v)),T=[l[0]+c*(v*m[0]+w*y[0]),l[1]+c*(v*m[1]+w*y[1]),l[2]+c*(v*m[2]+w*y[2])],k=[l[0]+m[0]*p,l[1]+m[1]*p,l[2]+m[2]*p],S=r.side??1,E=wa(jt(T,l)),_=wa(jt(k,T)),M=[{swing:bn(wn(E.swing-f.swing)),spread:bn(wn(E.spread-f.spread))*S},{swing:bn(wn(_.swing-E.swing)),spread:bn(wn(_.spread-E.spread))*S}];return e.withAngles(t,r,M)}const Jf=.34,kt=.12,ct=-.4,ut=(e,t,n)=>e[t]??n,Zf=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Qf=.45,td=.35,ed=.7;function vn(e,t,n){const i=p=>Math.sqrt(Math.max(0,1-p.x*p.x-p.y*p.y)),s=ma(e,[n.x,n.y,i(n)]).facing,r=e.axes[2],o=Math.atan2(r[0],r[2]),a=Math.cos(o),l=a>=0?1:-1,c=l*Math.max(td,Math.abs(a)),h=l*Math.max(ed,Math.abs(a)),f=Math.cos(e.angle),u=Math.sin(e.angle);return{facing:s,points:t.map(p=>{const m=Qf*Math.sin(o)+n.x*c+(p.x-n.x)*h,d=p.y+r[1]*i(p),g=m*e.rx,y=d*e.ry;return{x:e.center.x+g*f+y*u,y:e.center.y+g*u-y*f}})}}const kn=(e,t,n,i=12)=>Array.from({length:i+1},(s,r)=>{const o=r/i,a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}}),Gi=(e,t,n,i,s=16)=>Array.from({length:s},(r,o)=>{const a=Math.PI*2*o/s;return{x:e+Math.cos(a)*n,y:t+Math.sin(a)*i}}),va=.05;function nd(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,v)=>vn(t,y,v).points,o=(y,v)=>vn(t,[],{x:y,y:v}).facing,a=ut(n,"smile",0),l=ut(n,"blink",0),c=ut(n,"lookX",0),h=ut(n,"lookY",0),f=ut(n,"browTilt",0);for(const y of[1,-1]){const v=y===1?"left":"right",w=Jf*y;if(o(w,kt)<va)continue;const T={x:w,y:kt},k=Zf(ut(n,`eye.${v}`,1),l);if(k<.2){const M=a>.5?.12:-.06;e.line(r(kn({x:w-.12,y:kt},{x:w,y:kt+M},{x:w+.12,y:kt}),T),s)}else{if(k>1.2){const P=.13*k;e.shape(r(Gi(w,kt,P*.85,P),T),"#ffffff",s)}const M=k>1.2?.075:.1,x=w+c*.08,A=kt-h*.07;e.shape(r(Gi(x,A,M,M*1.1*Math.min(k,1)),T),e.ink,0)}const S=kt+.3+ut(n,`brow.${v}`,0)*.14+Math.max(0,k-1)*.12,E={x:w+y*.13,y:S},_={x:w-y*.13,y:S+f*.1};e.line(r([E,{x:(E.x+_.x)/2,y:(E.y+_.y)/2},_],{x:w,y:S}),s)}const u={x:0,y:ct};if(o(0,ct)<-va)return;const p=.25*Math.max(.3,ut(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,ut(n,"mouth",0)));if(m<=.05){e.line(r(kn({x:-p,y:ct},{x:0,y:ct-a*.25},{x:p,y:ct}),u),s);return}const d=.3*m;let g;if(a>.3){const y=ct+.05;g=[...kn({x:p,y},{x:0,y:ct-d*2},{x:-p,y})]}else if(a<-.3){const y=ct-d*.6;g=[...kn({x:p,y},{x:0,y:ct+d*1.4},{x:-p,y})]}else g=Gi(0,ct,p*.8,d);e.shape(r(g,u),e.ink,0)}function ka(e={}){const t=(e.proportions??"bold")==="bold",n=e.figure??"fluid",i=e.look??"clean",s=e.height??300,r=n==="stick";return{plan:e.plan??fa({headSize:e.headSize??(t?.3:.24),shoulderWidth:r?0:e.shoulderWidth??.06,hipWidth:r?0:e.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:e.lineWidth??s*(t?.045:.022),ink:e.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:e.skin??(i==="pencil"?"none":"#ffffff"),seed:e.seed??1,pencil:e.pencil??{},layers:e.layers??{},contact:e.contact??"ground",hands:e.hands??"dot",handStyle:e.handStyle??"glove",handSize:e.handSize??(e.handStyle==="natural"?.14:.17)}}function id(e,t,n,i){const{point:s,facing:r}=ma(e,[t,n,i]);return{point:s,facing:r}}const Ji=e=>e.rest[1]<-.5,sd=.3;function rd(e,t,n){return e.figure==="stick"?Ji(t)?n.slice(0,3):n:Ji(t)&&n.length>=3?xt(n[0],n[1],n[2],sd):n.length===3?xt(n[0],n[1],n[2],1):n}function Zi(e,t){const n=e.plan.id==="human"?{...J,...t}:t;return Qi(e,n,Ki(e.plan,n,{height:e.height,contact:e.contact}))}function Qi(e,t,n){const i={},s={},r={},o=.01*e.height;e.plan.chains.forEach(u=>{const p=n.chains[u.id];i[u.id]=p.points;const m=p.depths.reduce((v,w)=>v+w,0)/p.depths.length,d=u.parent?n.chains[u.parent]:void 0,g=d?d.depths[u.at??d.depths.length-1]:0,y=m-g;r[u.id]=Math.abs(y)<o?0:y,s[u.id]={points:rd(e,u,p.points),depth:m}}),s.head={points:[n.head.center],depth:n.head.depth},r.head=0;const a=[...e.plan.chains.map(u=>u.id),"head"],l=[...a].sort((u,p)=>r[u]-r[p]||a.indexOf(u)-a.indexOf(p)),c={hip:n.hip};for(const[u,[p,m]]of Object.entries(e.plan.landmarks??{})){const d=n.chains[p]?.points;d&&(c[u]=d[Math.min(m,d.length-1)])}const h={};for(const[u,p]of Object.entries(c))h[u]=p.y>=n.groundY-.01*e.height;const f={height:e.height,lineWidth:e.lineWidth,turn:t.turn??0,points:c,chains:i,parts:s,head:n.head,groundY:n.groundY,grounded:h};return{skeleton:n,joints:f,order:l}}function Sa(e,t){return Zi(e,t).joints}function od(e,t,n){const{head:i}=n;e.guideEllipse(i.center.x,i.center.y,i.rx*1.03,i.ry*1.03,i.angle);const s=Array.from({length:13},(l,c)=>({x:0,y:-.95+1.9*c/12})),r=Array.from({length:13},(l,c)=>({x:-.95+1.9*c/12,y:.12})),o=vn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(vn(i,r,{x:0,y:.12}).points),e.guide(n.chains.spine??[]);const a=t.lineWidth*.9;for(const l of["shoulder.left","shoulder.right","elbow.left","elbow.right","hip.left","hip.right","knee.left","knee.right"]){const c=n.points[l];c&&e.guideEllipse(c.x,c.y,a,a,0)}}function ad(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:p}=i,m=n.skin==="none"?null:n.skin;t.ellipse(p.center.x,p.center.y,p.rx,p.ry,p.angle,m,o),t.look!=="silhouette"&&nd(t,p,r,o);return}const a=n.plan.chains.find(p=>p.id===s),l=i.chains[s],c=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const p=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:c;t.line(p,o);return}const h=(p,m)=>[a.bones[p].width[0]*o,a.bones[m].width[1]*o];if(Ji(a)){const[p,m]=h(0,1);if(t.limb(c,p,m),a.bones.length>=3)t.limb([l[2],l[3]],a.bones[2].width[0]*o,a.bones[2].width[1]*o);else if(n.hands==="cartoon"&&s.startsWith("arm."))ld(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const d=l[l.length-1];t.dot(d.x,d.y,o*.62)}return}if(s==="spine"){const p=i.points["hip.left"],m=i.points["hip.right"];p&&m&&Math.hypot(p.x-m.x,p.y-m.y)>.5&&t.limb([p,m],o*1.3,o*1.3);const[d,g]=h(0,a.bones.length-1);t.limb(c,d,g);const y=i.points["shoulder.left"],v=i.points["shoulder.right"];y&&v&&Math.hypot(y.x-v.x,y.y-v.y)>.5&&t.limb(xt(y,l[l.length-1],v,1,10),o*1.15,o*1.15);return}const[f,u]=h(0,a.bones.length-1);t.limb(c,f,u)}function Ta(e,t){const n=`hand.${t}.`,i={};for(const[o,a]of Object.entries(e))o.startsWith(n)&&(i[o.slice(n.length)]=a);const s=e.turn??0,r=t==="right"?1-s:1+s;return{...N,...i,turn:r+(i.turn??0)}}function ld(e,t,n,i,s,r){const o=i[i.length-1],a=i[i.length-2],l=Math.atan2(o.x-a.x,-(o.y-a.y))*180/Math.PI;nn(e,o,Ta(r,s),{size:n.handSize*n.height,side:s,angle:l,pen:t,skin:n.skin==="none"?"#ffffff":n.skin,fingers:n.handStyle==="natural"?5:4,plump:n.handStyle==="natural"?1.15:1.6,lineWidth:n.lineWidth*.3})}function Ma(e,t,n,i=0){const s=t.plan.id==="human"?{...J,...n}:n;xa(e,t,s,Zi(t,s),i)}function Ea(e,t){const n=t/e.height;return{...e,height:t,lineWidth:e.lineWidth*n}}function cd(e,t,n,i){const s=e.plan.id==="human"?{...J,...t}:t,r=Vi(e.plan,s,{height:i.height,contact:e.contact},n);return Qi(Ea(e,r.height),s,r).joints}function Aa(e,t,n,i,s){const r=t.plan.id==="human"?{...J,...n}:n,o=Vi(t.plan,r,{height:s.height,contact:t.contact},i),a=Ea(t,o.height);xa(e,a,r,Qi(a,r,o),s.time??0)}function xa(e,t,n,i,s){const{joints:r,order:o}=i,a=xi(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:s,pencil:t.pencil}),l=c=>{c&&(e.save(),c(e,r,a,s),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&od(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),ad(e,a,t,r,c,n),l(h?.over)}l(t.layers.front),e.restore()}function hd(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}function ud(e,t,n,i){const s=e.plan.id==="human"?{...J,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=Zi(e,s),a=Ki(e.plan,{...s,roll:0},{height:e.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,c=i.x-o.hip.x,h=i.y-o.hip.y,f=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),u=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),p=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],d=Math.cos(p),g=Math.sin(p);r=[f*d-m*g,-u,f*g+m*d]}return Gf(e.plan,s,n,r,{height:e.height})}function fd(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?J:{};return{type:"custom",x:e.x-n/2,y:e.y-i,width:n,height:i,props:{...s,...e.pose},character:t,draw(r,o,a){r.translate(n/2,i),Ma(r,t,o.props,a)}}}function Pa(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>Object.fromEntries(Object.entries(r).map(([o,a])=>[o,a.map(i)]));return{...e,points:Object.fromEntries(Object.entries(e.points).map(([r,o])=>[r,i(o)])),chains:s(e.chains),parts:Object.fromEntries(Object.entries(e.parts).map(([r,o])=>[r,{...o,points:o.points.map(i)}])),head:{...e.head,center:i(e.head.center)},groundY:e.groundY+n}}function dd(e,t,n){const i=e.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...e.props};let r=0,o=0;for(const[l,c]of t.state?.values.get(n)??[])typeof c=="number"&&(l==="x"||l==="motionPathX"?r=c:l==="y"||l==="motionPathY"?o=c:l in s&&(s[l]=c));const a=Sa(i,s);return{pose:s,joints:Pa(a,e.x+r+e.width/2,e.y+o+e.height)}}function pd(e,t,n=J){const i=[];return t.forEach((r,o)=>{const a=o===0?n:i[o-1],l=typeof r.pose=="string"?ua[r.pose]:void 0;i.push(l?{...l,turn:a.turn??0}:{...a,...r.pose})}),Object.keys(n).filter(r=>i.some(o=>(o[r]??n[r])!==n[r])).map(r=>({id:`${e}-${r}`,target:e,property:r,keyframes:t.map((o,a)=>({time:o.time,value:i[a][r]??n[r],...o.easing?{easing:o.easing}:{}}))}))}const md=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),gd=1.7;function yd(e,t,n){const i=Array.from({length:24},(s,r)=>{const o=r/24*Math.PI*2,a=t.toView([Math.cos(o)*n,0,Math.sin(o)*n*.8]);return a[2]<-.001?t.toScreen(a):null});i.some(s=>s===null)||(e.beginPath(),i.forEach((s,r)=>r===0?e.moveTo(s.x,s.y):e.lineTo(s.x,s.y)),e.closePath(),e.fillStyle="rgba(0, 0, 0, 0.22)",e.fill())}function bd(e){const t=oe([0,1,0],e);if(t>.999999)return hr();if(t<-.999999)return le(Lt([1,0,0],180));const n=We([0,1,0],e);return le(Lt(n,Math.acos(t)*180/Math.PI))}function wd(e,t,n,i,s){const r=e.solid??{},o=r.outline===!1?void 0:r.outline??{width:2,color:"#0f172a"},a={color:r.color??"#475569",shading:r.shading??"toon",outline:o},l={color:r.skin??"#f2c49b",shading:r.shading??"toon",outline:o},c={color:"#0f172a",shading:"unlit"},h=i.height*.034,f=[],u=(w,T,k)=>f.push({mesh:w,world:Mt(s,T),material:k}),p=(w,T,k)=>u(t.sphere,fr(w,[0,0,0,1],[T,T,T]),k);for(const w of n.chains){const T=i.chains[w.id],k=w.id==="spine"?1.9:1;w.bones.forEach((S,E)=>{const _=T[E],M=T[E+1],x=lr(_,M),[A,P]=S.width??[1,1],C=h*k*(A+P)/2;if(x>1e-6){const I=cr(_,M,.5),H=bd(ae(Ne(M,_)));u(t.cylinder,Mt(ur(I),Mt(H,Ye([C,x,C]))),a)}p(_,h*k*A,a),p(M,h*k*P,a)}),w.id.startsWith("arm.")&&p(T[T.length-1],h*1.5,l)}const{center:m,rx:d,ry:g,axes:y}=i.head,v=[...y[0],0,...y[1],0,...y[2],0,...m,1];u(t.sphere,Mt(v,Ye([d,g,d])),l);for(const w of[-1,1]){const T=ae([w*.36,.15,.92]),k=De(m,De(De(re(y[0],T[0]*d*1.04),re(y[1],T[1]*g*1.04)),re(y[2],T[2]*d*1.04))),S=[...y[0],0,...y[1],0,...y[2],0,...k,1];u(t.sphere,Mt(S,Ye([d*.11,g*.14,d*.03])),c)}return f}const vd={kind:"character",validate(e){const t=e;return t.height!==void 0&&!(t.height>0)?["a character's height must be positive"]:[]},prepare(e){return{who:ka({...e.character,height:1}),cylinder:ba(jf(1,1,16)),sphere:ba(zf(1,20))}},resolve({object:e,prepared:t,values:n,world:i,camera:s,toScreen:r}){const o=e,a=t,l=a.who,c={...J,...o.pose};for(const[g,y]of n)typeof y=="number"&&!md.has(g)&&(c[g]=y);const h=o.height??gd,f=Mt(s.view,i),u={toView:g=>dr(f,g),toScreen:g=>r(g)},m=-u.toView([0,h/2,0])[2];if(m<=s.near)return null;const d=o.shadow===!1?[]:[{depth:m+h,draw:g=>yd(g,u,h*.18)}];if(o.look==="solid"){const g=Xi(l.plan,c,{height:h,contact:l.contact});return{meshes:wd(o,a,l.plan,g,i),drawables:d}}return{drawables:[...d,{depth:m,draw(g,y){g.lineCap="round",g.lineJoin="round",Aa(g,l,c,u,{height:h,time:y.time})}}]}}};function _a(e,t,n={},i){const s=n.length??240,r=9,o=28,a=s-22;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-30)*Math.PI/180),e.fillStyle=n.color??"#f4c542",e.fillRect(o,-r,a-o,2*r),e.fillStyle="#e8b4a0",e.fillRect(a,-r,s-a,2*r),e.fillStyle="#f1dcbf",e.beginPath(),e.moveTo(0,0),e.lineTo(o,-r),e.lineTo(o,r),e.closePath(),e.fill(),e.fillStyle=n.outline??"#2f2f33",e.beginPath(),e.moveTo(0,0),e.lineTo(o*.35,-r*.35),e.lineTo(o*.35,r*.35),e.closePath(),e.fill(),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round",e.lineCap="round";const l=[[{x:0,y:0},{x:o,y:-r},{x:s,y:-r},{x:s,y:r},{x:o,y:r},{x:0,y:0}],[{x:o,y:-r},{x:o,y:r}],[{x:a,y:-r},{x:a,y:r}]];for(const c of l)Ha(e,c,i);e.restore()}function ts(e,t,n={},i){const s=n.length??90,r=n.thickness??34;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-35)*Math.PI/180);const o=-r/2;e.fillStyle=n.color??"#f4a7b9",e.fillRect(0,o,s,r),e.fillStyle="#e9edf2",e.fillRect(s*.45,o,s*.55,r),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round";const a=[{x:0,y:o},{x:s,y:o},{x:s,y:-o},{x:0,y:-o},{x:0,y:o}],l=[{x:s*.45,y:o},{x:s*.45,y:-o}];if(i)i.line(a),i.line(l);else for(const c of[a,l]){e.beginPath(),e.moveTo(c[0].x,c[0].y);for(const h of c.slice(1))e.lineTo(h.x,h.y);e.stroke()}e.restore()}const Ca=150,kd={pencil:44,eraser:30};function es(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=n.scale??1,l=Math.min(1,Math.max(0,n.lift??0)),c=(n.angle??-30)*Math.PI/180,h=i?i.nudge(.6):{x:0,y:0},f=Ca*a*(1+.05*l);l>0&&(e.save(),e.fillStyle=o,e.globalAlpha=.15*l,e.beginPath(),e.ellipse(t.x,t.y,9*a,4*a,0,0,Math.PI*2),e.fill(),e.restore());const u={x:t.x+h.x+6*l*a,y:t.y+h.y-18*l*a},p=K.pencilGrip,m=E=>{const _=E.fingers.thumb,M=E.fingers.index,x=E.fingers.middle,A=Ia([_.points[3],M.points[3],x.points[3]]),P=Ia([_.points[1],M.points[0]]),C=(_.depths[3]+M.depths[3]+x.depths[3])/3;return{pinch:A,direction:Math.atan2(P.y-A.y,P.x-A.x),depth:C}},d=en(p,{size:f}),g=c-m(d).direction,y=en(p,{size:f,angle:g*180/Math.PI}),v=m(y),w=kd[s]*a,T={x:v.pinch.x-Math.cos(c)*w,y:v.pinch.y-Math.sin(c)*w},k={x:u.x-T.x,y:u.y-T.y},S=y.axes.up;Sd(e,k,{x:-S.x,y:-S.y},f,n.arm??300*a,r,n.sleeve??"#5b7db1",o),nn(e,k,p,{size:f,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:v.depth,draw:()=>{e.save(),e.translate(u.x,u.y),e.scale(a,a),s==="eraser"?ts(e,{x:0,y:0},{angle:c*180/Math.PI,outline:o},i):_a(e,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const Ia=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function Sd(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},c=i*.15,h=(d,g,y)=>({x:t.x+n.x*d+l.x*g*y,y:t.y+n.y*d+l.y*g*y}),f=h(s,0,0),u=d=>{const g=e.createLinearGradient(t.x,t.y,f.x,f.y);return g.addColorStop(0,d),g.addColorStop(.6,d),g.addColorStop(1,Ad(d)),g},p=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/Ca),e.beginPath(),e.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),e.lineTo(h(p+4,-1,c*1.1).x,h(p+4,-1,c*1.1).y),e.lineTo(h(p+4,1,c*1.1).x,h(p+4,1,c*1.1).y),e.lineTo(h(-i*.1,1,c).x,h(-i*.1,1,c).y),e.closePath(),e.fillStyle=r,e.fill(),e.strokeStyle=a,e.beginPath(),e.moveTo(h(0,-1,c).x,h(0,-1,c).y),e.lineTo(h(p,-1,c*1.1).x,h(p,-1,c*1.1).y),e.moveTo(h(0,1,c).x,h(0,1,c).y),e.lineTo(h(p,1,c*1.1).x,h(p,1,c*1.1).y),e.stroke();const m=[h(p,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(p,1,c*1.3)];e.beginPath(),m.forEach((d,g)=>g?e.lineTo(d.x,d.y):e.moveTo(d.x,d.y)),e.closePath(),e.fillStyle=u(o),e.fill(),e.strokeStyle=u(a),e.beginPath(),e.moveTo(m[1].x,m[1].y),e.lineTo(m[0].x,m[0].y),e.lineTo(m[3].x,m[3].y),e.lineTo(m[2].x,m[2].y),e.stroke(),e.restore()}function Td(e,t,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,r=n.exit??450,o=n.linger??1500,a=[...e].filter(d=>d.path.length>0).sort((d,g)=>d.start-g.start),l=d=>d.tool??"pencil",c=d=>{const g=Math.min(1,Math.max(0,d));return g*g*(3-2*g)},h=(d,g,y)=>({x:d.x+(g.x-d.x)*y,y:d.y+(g.y-d.y)*y}),f=a.find(d=>t>=d.start&&t<=d.end);if(f){const d=f.end-f.start,g=d>0?(t-f.start)/d:1;return{at:Ge(f.path,g),tool:l(f),lift:0,drawing:!0}}const u=[...a].reverse().find(d=>d.end<t),p=a.find(d=>d.start>t),m=d=>d.path[d.path.length-1];if(u&&p&&p.start-u.end<=o){const d=(t-u.end)/(p.start-u.end),g=d<.5?l(u):l(p);return{at:h(m(u),p.path[0],c(d)),tool:g,lift:Math.sin(Math.PI*d),drawing:!1}}if(p&&p.start-t<=s){const d=1-(p.start-t)/s;return{at:h(i,p.path[0],c(d)),tool:l(p),lift:1-c(d),drawing:!1}}if(u&&t-u.end<=r){const d=(t-u.end)/r;return{at:h(m(u),i,c(d)),tool:l(u),lift:c(d),drawing:!1}}return null}function Md(e,t,n,i=.08,s=32){const r=Math.PI*2*(1+i),o=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+r*a/s;o.push({x:e+Math.cos(l)*n,y:t+Math.sin(l)*n})}return o}function Ed(e){const{path:t}=e,n=t.map(a=>a.x),i=t.map(a=>a.y),s=Math.min(...n),r=Math.min(...i),o=e.hand===!1?void 0:e.hand===!0||e.hand===void 0?{}:e.hand;return{type:"custom",x:s,y:r,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-r),props:{draw:0},draw(a,l,c){const h=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-r),a.strokeStyle=e.color??"#2f2f33",a.lineWidth=e.lineWidth??5,a.lineCap="round",a.lineJoin="round";const f=e.sketch?Je(a,e.sketch,c):void 0;h>0&&(f?e.smooth?f.curve(t,h):f.line(t,h):Ha(a,Xt(t,h))),o&&h>0&&h<1&&es(a,Ge(t,h),o,f)}}}function Ad(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return"rgba(0, 0, 0, 0)";const n=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,s,r]=[0,2,4].map(o=>parseInt(n.slice(o,o+2),16));return`rgba(${i}, ${s}, ${r}, 0)`}function Ha(e,t,n){if(!(t.length<2)){if(n)return n.line(t);e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);e.stroke()}}const Sn=1e5;function xd(e,t,n,i,s=6){const r=[],o=Math.max(1,Math.round(s));for(let a=0;a<=o;a++)r.push({x:a%2===0?e:e+n,y:t+i*a/o});return r}function ns(e,t,n,i){if(i<=0||t.length===0)return;const s=Xt(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Sn,-Sn,2*Sn,2*Sn),a(),e.clip("evenodd")};for(const a of s)o(()=>{e.moveTo(a.x+r,a.y),e.arc(a.x,a.y,r,0,Math.PI*2)});for(let a=1;a<s.length;a++){const l=s[a-1],c=s[a],h=Math.hypot(c.x-l.x,c.y-l.y);if(h===0)continue;const f=-(c.y-l.y)/h*r,u=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+f,l.y+u),e.lineTo(c.x+f,c.y+u),e.lineTo(c.x-f,c.y-u),e.lineTo(l.x-f,l.y-u),e.closePath()})}}function Pd(e,t,n,i,s){e.save(),ns(e,t,n,i),s(),e.restore()}function _d(e,t){const n=t.width??40,i=t.hand===!0?{}:t.hand||void 0,s=t.eraser===!1?void 0:t.eraser===!0||t.eraser===void 0?{}:t.eraser;return{...e,props:{...e.props,erase:0},draw(r,o,a){const l=Number(o.props?.erase??0);if(r.save(),ns(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=Ge(t.path,l);i?es(r,c,{...i,tool:"eraser"}):ts(r,c,s)}}}const Cd=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function Id(e={}){const t=e.shirt??"#e2493b",n=e.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,c)=>{const h=a.parts[`leg.${c}`].points;l.shape(me(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],f=c[c.length-1],u={x:h.x-(f.x-h.x)*.25,y:h.y-(f.y-h.y)*.25};l.shape(me([u,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,f=h[0],u=a.chains.spine[a.chains.spine.length-1],m=[{x:f.x+(u.x-f.x)*.45,y:f.y+(u.y-f.y)*.45},...Cd(h,0,.45)],d=me(m,a.height*.085,a.height*.06),g=m.length,y=d.slice(0,g),v=d.slice(g).reverse();l.shape(d,t,0);const w=S=>Math.hypot(S[1].x-u.x,S[1].y-u.y),[T,k]=w(y)>w(v)?[y,v]:[v,y];l.line(T.slice(1),i(a)),l.line(k.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],v[g-1]],i(a))};return{parts:{"leg.left":{over:(a,l,c)=>s(l,c,"left")},"leg.right":{over:(a,l,c)=>s(l,c,"right")},spine:{over:(a,l,c)=>r(l,c)},"arm.left":{over:(a,l,c)=>o(l,c,"left")},"arm.right":{over:(a,l,c)=>o(l,c,"right")}}}}function Hd(e){const{timeline:t}=e,n=new At;for(const[c,h]of Object.entries(e.targets)){const f=typeof h=="string"?document.querySelector(h):h;if(!f)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,f)}t.onUpdate=c=>{n.applyState(c),e.onUpdate?.(c)},e.onComplete&&(t.onComplete=e.onComplete);let i=null,s=null,r=!1;const o=c=>{if(r)return;const h=s===null?0:c-s;s=c,h>0&&t.tick(h),i=requestAnimationFrame(o)},a=()=>{i!==null||r||(s=null,i=requestAnimationFrame(o))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(t.getStateAtTime(t.currentTime)),e.autoplay!==!1&&(t.play(),a()),{timeline:t,adapter:n,play(){t.play(),a()},pause(){t.pause(),l()},restart(){t.stop(),t.play(),a()},seek(c){t.seek(c*1e3),n.applyState(t.getStateAtTime(t.currentTime))},destroy(){r=!0,l(),t.stop(),n.clearTargets()}}}const $d={timeline:Tc,to(e,t,n){const i=new Et(n);return i.to(e,t),i},from(e,t,n){const i=new Et(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new Et(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new Et(n);return i.set(e,t),i}};function Rd(e,t,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,n);const i=e.canvas;if(i?.ownerDocument){const s=i.ownerDocument.createElement("canvas");return s.width=t,s.height=n,s}try{return i?.constructor?new i.constructor(t,n):null}catch{return null}}function Fd(e,t){const n=e.length/4,i=new Float32Array(n*3),s=Math.min(.999,Math.max(0,t));for(let r=0;r<n;r++){const o=e[r*4]/255,a=e[r*4+1]/255,l=e[r*4+2]/255,c=e[r*4+3]/255,h=Math.max(o,a,l);if(h<=s)continue;const f=(h-s)/(1-s)*c/h;i[r*3]=o*f,i[r*3+1]=a*f,i[r*3+2]=l*f}return i}function $a(e,t,n,i,s){const r=new Float32Array(e.length),o=s?n:t,a=s?t:n,l=(h,f)=>(s?h*t+f:f*t+h)*3,c=i*2+1;for(let h=0;h<o;h++)for(let f=0;f<3;f++){let u=0;for(let p=-i;p<=i;p++)u+=e[l(h,Math.min(a-1,Math.max(0,p)))+f];for(let p=0;p<a;p++){r[l(h,p)+f]=u/c;const m=e[l(h,Math.max(0,p-i))+f],d=e[l(h,Math.min(a-1,p+i+1))+f];u+=d-m}}return r}function Ra(e,t,n,i){const s=Math.max(1,Math.round(i/Math.sqrt(3)));let r=e;for(let o=0;o<3;o++)r=$a(r,t,n,s,!0),r=$a(r,t,n,s,!1);return r}function Od(e,t={}){const n=e.canvas,i=n.width,s=n.height;if(!(i>0&&s>0))return;const r=Math.max(1,Math.round(t.downsample??4)),o=Math.max(1,Math.ceil(i/r)),a=Math.max(1,Math.ceil(s/r)),l=Rd(e,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(e.canvas,0,0,o,a);const h=Fd(c.getImageData(0,0,o,a).data,t.threshold??.55),f=(t.radius??Math.max(i,s)*.02)/r,u=Ra(h,o,a,f),p=Ra(h,o,a,f*3),m=t.halo??.6,d=c.createImageData(o,a);for(let g=0;g<o*a;g++){for(let y=0;y<3;y++)d.data[g*4+y]=Math.round(Math.min(1,u[g*3+y]+p[g*3+y]*m)*255);d.data[g*4+3]=255}c.putImageData(d,0,0),e.save(),e.setTransform(1,0,0,1,0,0),e.globalCompositeOperation="lighter",e.globalAlpha=Math.max(0,t.strength??.9),e.imageSmoothingEnabled=!0,e.drawImage(l,0,0,i,s),e.restore()}const Ld=z.to,Bd=z.from,Dd=z.fromTo,Nd=z.set,Wd=z.timeline,Yd=z.ticker,Kd=z.splitText,qd=z.context,Xd=z.matchMedia,Vd=z.quickTo,Ud=z.imageSequence,zd=z.pageTransition;Gh(),b.Clock=La,b.CompatTimeline=Et,b.CustomBounce=to,b.CustomEase=Qr,b.CustomWiggle=eo,b.DANCE_STYLES=_t,b.DEFAULT_BAKE_INTERVAL_MS=Yn,b.DEFAULT_INERTIA_FRICTION=Cn,b.DEFAULT_LABELS=ho,b.DEFAULT_SPRING=Q,b.DEFAULT_TRANSITION=Zh,b.Draggable=ci,b.EXPRESSIONS=tt,b.FINGERS=To,b.FLIPS=pn,b.FORMAT_VERSION=Mn,b.HAND_REST=N,b.HAND_SHAPES=K,b.HUMAN_EXPRESSIONS=Kf,b.HUMAN_POSES=ua,b.HUMAN_REST=J,b.INERTIA_MAX_DURATION_MS=os,b.InertiaTrackPlayer=Vs,b.LiveTimeline=lt,b.MORPH_SAMPLES=rl,b.MUDRAS=Oi,b.ManualClock=Oa,b.MediaSync=Ti,b.Observer=Cr,b.POSES=Po,b.REST_POSE=G,b.SPRING_MAX_DURATION_MS=_n,b.SPRING_PRESETS=xe,b.SPRING_STEP_MS=It,b.ScrollAnimator=Vr,b.ScrollDriver=fe,b.ScrollMarkers=Ur,b.ScrollPin=Yr,b.SmoothScroll=vi,b.SpringSampler=Zt,b.SpringTrackPlayer=Xs,b.Stage=Mr,b.Timeline=zn,b.TinyflyPlayer=ze,b.TinyflySequencer=wo,b.TrackPlayer=Re,b.ValueResolver=$l,b.VisibilityDriver=Wr,b.applyBloom=Od,b.applyGroove=na,b.backOut=gs,b.bakeDanceTracks=pf,b.bakeEasing=Xn,b.bakeInertiaTrack=qn,b.bakeSpringTrack=Kn,b.basicOutfit=Id,b.beatAt=uf,b.beatAtTime=Le,b.beatLength=ti,b.beatTime=Oe,b.beatsBetween=Xl,b.bindChoiceHotspots=mo,b.blendPose=Ut,b.boilFrame=Ei,b.bounceOut=ms,b.character=ka,b.characterAt=dd,b.characterHandPose=Ta,b.characterJoints=Sa,b.characterJointsInView=cd,b.characterObjects=vd,b.characterPoseTracks=pd,b.characterTarget=fd,b.charactersFor=Us,b.circlePath=Md,b.clamp01=gi,b.clearMorphCache=pl,b.clearPathCache=tl,b.clipErased=ns,b.containerProgressAt=yi,b.context=qd,b.create=Fh,b.createControls=fo,b.createCubicBezier=ds,b.createLive=so,b.createPen=xi,b.createRandom=Fe,b.createTrack=$e,b.criticalDamping=Na,b.customBounce=sr,b.customEase=ir,b.customWiggle=rr,b.danceFrame=cn,b.dancePose=of,b.danceStance=ln,b.danceTaps=lf,b.danceTracks=df,b.danceTravel=un,b.danceTravelTrack=aa,b.dancer=ff,b.deserializeTimeline=Dt,b.deserializeTrack=Js,b.detectTempo=Vl,b.draggable=zc,b.drawCartoonHand=nn,b.drawCharacter=Ma,b.drawCharacterInView=Aa,b.drawEraser=ts,b.drawHand=es,b.drawPencil=_a,b.drawStickFigure=Zo,b.drawnPathTarget=Ed,b.easeIn=hs,b.easeInCubic=In,b.easeInOut=fs,b.easeInOutCubic=te,b.easeInOutQuad=cs,b.easeInQuad=as,b.easeOut=us,b.easeOutCubic=Hn,b.easeOutQuad=ls,b.elasticOut=ps,b.ellipsePoints=Ai,b.erasable=_d,b.expandParametricEasings=Ks,b.flipPose=la,b.flipTracks=_f,b.flipTravel=ca,b.formatVersionFor=En,b.from=Bd,b.fromJSON=Cl,b.fromTo=Dd,b.getEasingFunction=V,b.getInterpolator=se,b.getMotionPathPoint=Vn,b.getPathLength=el,b.getPointAtProgress=ks,b.gridLinesFor=$r,b.handAt=Td,b.handJoints=en,b.handJointsAt=Ao,b.handPose=W,b.handProp=we,b.hasKeyframes=ss,b.hashSeed=Jn,b.headPoint=zu,b.humanFieldLabel=Wf,b.humanPlan=fa,b.humanPose=et,b.imageSequence=Ud,b.inertiaDuration=$t,b.inertiaRest=Ht,b.inertiaValueAt=_e,b.inertiaVelocityAt=qa,b.interpolateArray=Ds,b.interpolateColor=Bs,b.interpolateMotionPath=El,b.interpolateNumber=rt,b.interpolatePathString=Ws,b.interpolateQuaternion=Ns,b.interpolateString=Wn,b.isCubicBezierEasing=is,b.isInertiaTrack=ft,b.isMotionPathPoint=Fa,b.isMotionPathTrack=An,b.isParametricEasing=Gt,b.isPathData=Ft,b.isSpringTrack=dt,b.isTextTrack=Te,b.isUnderdamped=Da,b.isUnresolved=Hl,b.jointsInScene=Pa,b.jointsToScene=Jo,b.linear=Ce,b.live=z,b.mapEase=ce,b.mat4=ec,b.matchMedia=Xd,b.maxStaggerDistance=Pn,b.mirrorHumanPose=Nf,b.mirrorPose=ea,b.mixHandPoses=Vt,b.mixPoses=hd,b.morphPath=Ps,b.mount=go,b.mountAll=bo,b.narrationMarkers=Wl,b.narrationSceneAt=Yl,b.naturalRest=Qt,b.nearestBeat=Kl,b.nextBeat=ql,b.pageTransition=zd,b.parametricEasing=bs,b.parseEdge=pi,b.parsePath=Tt,b.parseTrigger=mi,b.partialPath=Xt,b.pathLength=vo,b.planNarration=Nl,b.play=Rh,b.playSequence=Jh,b.playWhenVisible=ah,b.playheadCrossings=jn,b.pointAlong=Ge,b.pointAtDistance=Rn,b.pointOnHead=id,b.pointsToPath=ar,b.pose=X,b.poseTracks=Qu,b.quat=vl,b.quickPlay=Hd,b.quickTo=Vd,b.randomBetween=Zn,b.randomChoice=Il,b.randomSnapped=Qs,b.reachCharacter=ud,b.resolveSequence=nr,b.resolveStickFrame=Ri,b.resolveStickPose=Qo,b.resolveValue=Qn,b.rotateAbout=wt,b.routineBeats=hn,b.rubberLimb=xt,b.scrollProgress=oh,b.scrubOnScroll=uh,b.scrubPath=xd,b.seatHeight=Ku,b.serializeTimeline=Zs,b.serializeTrack=js,b.set=Nd,b.shapeToPathData=Be,b.simplifyKeyframes=qs,b.skeletonInView=Vi,b.sketchPen=Je,b.smoothToward=Nr,b.snapAxis=Hr,b.snapConfig=Kr,b.snapDuration=Xr,b.snapProgress=qr,b.solvePlanSpace=yn,b.splitText=Kd,b.springDuration=rs,b.springValueAt=Ba,b.stagePlanSpace=Xi,b.staggerDistance=xn,b.staggerOffset=Me,b.staggerOffsets=Ee,b.staggerSpan=Jt,b.stepsEasing=ys,b.stickFigureAt=Zu,b.stickFigureJoints=Go,b.stickFigureTarget=Ju,b.stickToHuman=qf,b.strideLength=Mu,b.syncMediaElement=co,b.talkingMouth=$o,b.taperedLine=Ze,b.taperedOutline=me,b.textAt=zs,b.tf=$d,b.ticker=Yd,b.timeline=Wd,b.to=Ld,b.toJSON=_l,b.toKeyframedTrack=Tl,b.toKeyframedTracks=Ml,b.trackTargets=yt,b.triggerDistance=Wt,b.unmount=zh,b.vec3=zl,b.walkPose=Ho,b.withErased=Pd,b.withExpression=Ci,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|