@algorisys/tinyfly 0.78.0 → 0.81.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.
@@ -1,5 +1,5 @@
1
- (function(b,wt){typeof exports=="object"&&typeof module<"u"?wt(exports):typeof define=="function"&&define.amd?define(["exports"],wt):(b=typeof globalThis<"u"?globalThis:b||self,wt(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function wt(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function $t(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const Ft=1;function ee(e){return e.property==="text"&&"textConfig"in e}function rt(e){return e.kind==="inertia"&&"inertia"in e}function ot(e){return e.kind==="spring"&&"spring"in e}function Le(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Ur(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function Qn(e){return"keyframes"in e}class jr{_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 zr{_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 $e(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 Fe(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,$e(i,e,t));return n}function ne(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=$e(e,t,i);if(n.amount!==void 0){const r=Fe(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function ie(e,t){return Array.from({length:e},(n,i)=>ne(i,e,t))}function Ot(e,t){return e<=1?0:Math.max(...ie(e,t))}const vt=1,Oe=6e4,se=Oe/vt,H={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},re={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 Dt{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??H.stiffness,this.damping=t.damping??H.damping,this.mass=t.mass??H.mass,this.restDelta=t.restDelta??H.restDelta,this.restSpeed=t.restSpeed??H.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??H.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/vt);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/vt-n;return i+(s-i)*r}settleTime(){return this.simulateTo(se+1),this.settledStep!==null?this.settledStep*vt:Oe}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,se+1),i=vt/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>se&&(this.settledStep=se)}}function Gr(e,t){return new Dt(e).valueAt(t)}function Zn(e){return new Dt(e).settleTime()}function Kr(e){const t=e.stiffness??H.stiffness,n=e.damping??H.damping,i=e.mass??H.mass;return n<2*Math.sqrt(t*i)}function Jr(e){const t=e.stiffness??H.stiffness,n=e.mass??H.mass;return 2*Math.sqrt(t*n)}const De=4,Qr=.002,Zr=1e-4,ti=6e4;function oe(e){const t=e.friction??De;return t>0?t:De}function Bt(e){return e.from+e.velocity/oe(e)}function to(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 Tt(e){let t=to(Bt(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 kt(e){const t=Math.abs(Tt(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Zr,t*Qr);if(n>=t)return 0;const i=Math.log(t/n)/oe(e);return Math.min(ti,i*1e3)}function ae(e,t){if(t<=0)return e.from;const n=Tt(e);if(t>=kt(e))return n;const i=oe(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function eo(e,t){const n=oe(e),i=Tt(e);return t>=kt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const le=e=>e,ei=e=>e*e,ni=e=>1-(1-e)*(1-e),ii=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Be=e=>e*e*e,Ne=e=>1-Math.pow(1-e,3),Nt=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,si=Be,ri=Ne,oi=Nt,no={linear:le,"ease-in":si,"ease-out":ri,"ease-in-out":oi,"ease-in-quad":ei,"ease-out-quad":ni,"ease-in-out-quad":ii,"ease-in-cubic":Be,"ease-out-cubic":Ne,"ease-in-out-cubic":Nt};function ai(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,d=m=>((a*m+o)*m+r)*m,u=m=>((h*m+c)*m+l)*m,f=m=>(3*a*m+2*o)*m+r,p=m=>{let g=m;for(let w=0;w<8;w++){const k=d(g)-m;if(Math.abs(k)<1e-7)return g;const T=f(g);if(Math.abs(T)<1e-7)break;g-=k/T}let y=0,v=1;for(g=m;y<v;){const w=d(g);if(Math.abs(w-m)<1e-7)return g;m>w?y=g:v=g,g=(y+v)/2}return g};return m=>{if(m<=0)return 0;if(m>=1)return 1;const g=p(m);return u(g)}}function Ye(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 li(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 ci=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 hi(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 ui(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 fi(e){switch(e.type){case"steps":return ui(e.count,e.position);case"elastic":return Ye(li(e.amplitude,e.period),e.mode);case"bounce":return Ye(ci,e.mode);case"back":return Ye(hi(e.overshoot),e.mode)}}function z(e){return e===void 0?le:wt(e)?ai(e.points):$t(e)?fi(e):no[e]??le}const di=32,io=256,Mt=new Map,so=/[MmLlHhVvCcSsQqTtAaZz]/,ro=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,oo={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function ao(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(so.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=ro.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function lo(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 d=s*Math.PI/180,u=Math.cos(d),f=Math.sin(d),p=(e-a)/2,m=(t-l)/2,g=u*p+f*m,y=-f*p+u*m,v=g*g/(c*c)+y*y/(h*h);if(v>1){const F=Math.sqrt(v);c*=F,h*=F}const w=r===o?-1:1,k=c*c*h*h-c*c*y*y-h*h*g*g,T=c*c*y*y+h*h*g*g,M=w*Math.sqrt(Math.max(0,k/T)),x=M*c*y/h,C=-M*h*g/c,L=u*x-f*C+(e+a)/2,I=f*x+u*C+(t+l)/2,A=(F,D,O,j)=>{const et=F*O+D*j,ft=Math.sqrt((F*F+D*D)*(O*O+j*j)),bt=Math.acos(Math.max(-1,Math.min(1,et/ft)));return F*j-D*O<0?-bt:bt},E=A(1,0,(g-x)/c,(y-C)/h);let S=A((g-x)/c,(y-C)/h,(-g-x)/c,(-y-C)/h);!o&&S>0&&(S-=2*Math.PI),o&&S<0&&(S+=2*Math.PI);const _=Math.max(1,Math.ceil(Math.abs(S)/(Math.PI/2))),P=S/_,R=4/3*Math.tan(P/4),$=F=>{const D=c*Math.cos(F),O=h*Math.sin(F);return[u*D-f*O+L,f*D+u*O+I]},B=F=>{const D=-c*Math.sin(F),O=h*Math.cos(F);return[u*D-f*O,f*D+u*O]},N=[];for(let F=0;F<_;F++){const D=E+F*P,O=D+P,[j,et]=$(D),[ft,bt]=F===_-1?[a,l]:$(O),[Re,te]=B(D),[Jn,ph]=B(O);N.push([j+R*Re,et+R*te,ft-R*Jn,bt-R*ph,ft,bt])}return N}function at(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 pi(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 Yt(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 ce(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,d=t,u=0;for(let f=1;f<=di;f++){const p=f/di,m=at(e,i,r,a,p),g=at(t,s,o,l,p);u+=Math.hypot(m-h,g-d),c.push(u),h=m,d=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 dt(e){const t=Mt.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,d=m=>{c<0&&(c=0),m.subpath=c,n.push(m)};for(const{type:m,args:g}of ao(e)){const y=m.toUpperCase(),v=m!==y,w=oo[y];if(y==="Z"){(i!==r||s!==o)&&d(Yt(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let k=0;k+w<=g.length;k+=w){const T=g.slice(k,k+w),M=v?i:0,x=v?s:0;let C=null,L=null;switch(y){case"M":k===0?(i=T[0]+M,s=T[1]+x,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(d(Yt(i,s,T[0]+M,T[1]+x)),i=T[0]+M,s=T[1]+x);break;case"L":d(Yt(i,s,T[0]+M,T[1]+x)),i=T[0]+M,s=T[1]+x;break;case"H":d(Yt(i,s,T[0]+M,s)),i=T[0]+M;break;case"V":d(Yt(i,s,i,T[0]+x)),s=T[0]+x;break;case"C":{const I=[T[0]+M,T[1]+x,T[2]+M,T[3]+x,T[4]+M,T[5]+x];d(ce(i,s,I)),C=[I[2],I[3]],i=I[4],s=I[5];break}case"S":{const[I,A]=a?[2*i-a[0],2*s-a[1]]:[i,s],E=[I,A,T[0]+M,T[1]+x,T[2]+M,T[3]+x];d(ce(i,s,E)),C=[E[2],E[3]],i=E[4],s=E[5];break}case"Q":case"T":{let I=i,A=s;y==="Q"?(I=T[0]+M,A=T[1]+x):l&&(I=2*i-l[0],A=2*s-l[1]);const E=y==="Q"?T[2]+M:T[0]+M,S=y==="Q"?T[3]+x:T[1]+x;d(ce(i,s,[i+2/3*(I-i),s+2/3*(A-s),E+2/3*(I-E),S+2/3*(A-S),E,S])),L=[I,A],i=E,s=S;break}case"A":{const I=T[5]+M,A=T[6]+x;let E=i,S=s;for(const _ of lo(i,s,T[0],T[1],T[2],T[3],T[4],I,A))d(ce(E,S,_)),E=_[4],S=_[5];i=I,s=A;break}}a=C,l=L}}const u=n.reduce((m,g)=>m+g.length,0),f=[];for(let m=0;m<n.length;){const g=n[m].subpath;let y=m,v=0;for(;y<n.length&&n[y].subpath===g;)v+=n[y++].length;const w=n[m],k=n[y-1],T=h.has(g)||Math.abs(k.endX-w.startX)<1e-9&&Math.abs(k.endY-w.startY)<1e-9;f.push({start:m,end:y,length:v,closed:T}),m=y}const p={segments:n,totalLength:u,subpaths:f};return Mt.size>=io&&Mt.delete(Mt.keys().next().value),Mt.set(e,p),p}function co(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 ho(e,t){if(e.type==="L"){const d=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*d,y:e.startY+(e.endY-e.startY)*d,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=co(e,t);let c=pi(e.startX,n,s,o,l),h=pi(e.startY,i,r,a,l);if(Math.hypot(c,h)<1e-9){const d=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=at(e.startX,n,s,o,d),f=at(e.startY,i,r,a,d),p=at(e.startX,n,s,o,l),m=at(e.startY,i,r,a,l);c=l<.5?u-p:p-u,h=l<.5?f-m:m-f}return{x:at(e.startX,n,s,o,l),y:at(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function We(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 ho(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function mi(e,t){const{segments:n,totalLength:i}=dt(e);return We(n,Math.max(0,Math.min(1,t))*i)}function uo(){Mt.clear()}function fo(e){return dt(e).totalLength}const po=24,mo=320,go=2.5,Wt=72,yo=64,bo=.2,wo=128,qt=new Map;let he=0,lt;const gi=e=>Math.round(e*100)/100;function yi(e,t){const{segments:n,subpaths:i,totalLength:s}=dt(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 qe(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=We(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function bi(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 wi(e,t){const n=[];for(let i=0;i<t;i++)n.push(qe(e,e.closed?i/t:i/(t-1)));return n}function vi(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 vo(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%Wt/Wt:0,reversed:n<0};const s=vi(wi(e,Wt)),r=vi(wi(t,Wt)),o=Wt;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let d=0;d<h;d++){let u=0;for(let f=0;f<o&&u<l;f++){const p=i?c?(d-f+o)%o:(f+d)%o:c?o-1-f:f,m=s[f][0]-r[p][0],g=s[f][1]-r[p][1];u+=m*m+g*g}u<l&&(l=u,a={offset:i?d/o:0,reversed:c})}}return a}function To(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function ko(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function Mo(e,t,n){const i=e.closed&&t.closed,s=vo(e,t,n.shapeIndex),r=Math.max(po,Math.min(mo,Math.ceil(Math.max(e.length,t.length)/go))),o=new Set,a=d=>o.add(Math.round(d*1e7)/1e7);for(let d=0;d<=r;d++)a(d/r);for(const d of bi(e))a(d);for(const d of bi(t))a(ko(d,s,i));let l=[...o].sort((d,u)=>d-u);i&&(l=l.filter(d=>d<1));const c=[],h=[];for(const d of l)c.push(...qe(e,d)),h.push(...qe(t,To(d,s,i)));return So({from:c,to:h,closed:i})}function So(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=bo;for(let h=o+1;h<a;h++){const d=Math.max(Ti(e.from,o,a,h),Ti(e.to,o,a,h));d>c&&(c=d,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 Ti(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,d=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-d*o,c-d*a)}function xo(e,t,n){const i=n.shapeIndex;if(lt&&lt.from===e&&lt.to===t&&lt.shapeIndex===i)return lt.plan;const r=qt.get(String(i??"auto"))?.get(e)?.get(t);if(r)return lt={from:e,to:t,shapeIndex:i,plan:r},r;const o=dt(e).subpaths.filter(f=>f.length>0).length===dt(t).subpaths.filter(f=>f.length>0).length,a=yi(e,!o),l=yi(t,!o),c={pairs:a.map((f,p)=>Mo(f,l[p],n))};he>=wo&&(qt.clear(),he=0);const h=String(i??"auto"),d=qt.get(h)??new Map;qt.set(h,d);const u=d.get(e)??new Map;return d.set(e,u),u.set(t,c),he++,lt={from:e,to:t,shapeIndex:i,plan:c},c}function ki(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=xo(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=gi(a.from[l]+(a.to[l]-a.from[l])*s),h=gi(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 Ao(){qt.clear(),he=0,lt=void 0}function St(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const G=(e,t,n)=>e+(t-e)*n,Mi=512,Xe=new Map,He=new Map;function Si(e){const t=Xe.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 Xe.size<Mi&&Xe.set(e,i),i}const xi=e=>e.charCodeAt(0)===35,Ai=e=>e.startsWith("rgb"),Ei=e=>e.startsWith("rgba"),Eo=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Ve=e=>Math.round(e).toString(16).padStart(2,"0");function Po(e,t,n){return`#${Ve(e)}${Ve(t)}${Ve(n)}`}function Pi(e){const t=He.get(e);if(t)return t;const n=e.match(Eo);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 He.size<Mi&&He.set(e,o),o}const _i=(e,t,n)=>{if(xi(e)&&xi(t)){const[i,s,r]=Si(e),[o,a,l]=Si(t),c=G(i,o,n),h=G(s,a,n),d=G(r,l,n);return Po(c,h,d)}if((Ai(e)||Ei(e))&&(Ai(t)||Ei(t))){const i=Pi(e),s=Pi(t),r=Math.round(G(i[0],s[0],n)),o=Math.round(G(i[1],s[1],n)),a=Math.round(G(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=G(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},Ci=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(G(e[r],t[r],n));return s},Ue=(e,t,n)=>n<1?e:t,Ii=(e,t,n)=>ki(e,t,n);function Xt(e){return typeof e=="number"?G:Array.isArray(e)?Ci:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?_i:St(e)?Ii:Ue:Ue}const je=1e3/60;function ze(e,t={}){if(!ot(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new Dt(e.spring);return Ri(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function Ge(e,t={}){if(!rt(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return Ri(e,i=>ae(n,i),kt(n),n.from,Tt(n),t)}function Ri(e,t,n,i,s,r){const o=r.intervalMs??je,a=r.tolerance??.01,l=e.delay??0,c=[];for(let d=0;d<=n;d+=o)c.push({time:d+l,value:t(d),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?$i(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function Ke(e,t,n,i={}){const s=i.intervalMs??je,r=typeof n=="function"?n:z(n),o=Xt(e.value),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let h=s;h<a;h+=s){const d=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(d)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function _o(e,t){return ot(e)?ze(e,t):rt(e)?Ge(e,t):e}function Li(e,t={}){const n=e.keyframes;if(!n.some(s=>$t(s.easing)))return e;const i=n.length>0?[n[0]]:[];for(let s=1;s<n.length;s++){const r=n[s];$t(r.easing)?i.push(...Ke(n[s-1],r,r.easing,t)):i.push(r)}return{...e,keyframes:i}}function Co(e,t){return e.filter(Qn).map(n=>Li(n,t)).concat(e.filter(ot).map(n=>ze(n,t)),e.filter(rt).map(n=>Ge(n,t)))}function $i(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 ue(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function ct(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function xt(e,t,n,i){const s=n??0;return!i||t<=1?s:s+ne(e,t,i)}class fe{track;targets;constructor(t){this.track=t,this.targets=ct(t)}getValueAtTime(t){return this.valueForOffset(t-xt(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=xt(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?Ot(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=z(s.easing)(o);return Xt(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 Fi{track;targets;sampler;constructor(t){this.track=t,this.targets=ct(t),this.sampler=new Dt(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-xt(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=xt(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?Ot(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Oi{track;targets;duration;constructor(t){this.track=t,this.targets=ct(t),this.duration=kt(t.inertia)}getValueAtTime(t){return ae(this.track.inertia,t-xt(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=xt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:ae(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?Ot(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Je(e,t){const n={...mi(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 d=n.angle*Math.PI/180,u=Math.cos(d),f=Math.sin(d);n.angle=Math.atan2(s*u+o*f,i*u+r*f)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function Io(e,t,n,i){const s=t+(n-t)*i;return Je(e,s)}const Qe={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Ro=20;function Di(e){const t=Qe[e??"upperCase"]??e??Qe.upperCase,n=Array.from(t);return n.length>0?n:Array.from(Qe.upperCase)}function Lo(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 Bi(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)),d=Math.floor(h*a.length),u=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),f=Di(e.chars),p=e.refreshRate??Ro,m=p>0?Math.floor(n*p/1e3):0,g=e.seed??1;let y="";for(let v=0;v<u;v++){const w=l?v>=u-d:v<d,k=l?a[a.length-(u-v)]:a[v];w&&k!==void 0||k===" "||k===`
2
- `?y+=k:y+=f[Lo(g,v,m)%f.length]}return y}class Ze{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}`,d=c<=t,u=i.get(h);(!u||(d!==u.started?d:d?c>=u.start:c<=u.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:d})}}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",Bi(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=Je(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 ct(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,rt(t)){this._trackPlayers.set(t.id,new Oi(t));return}if(ot(t)){this._trackPlayers.set(t.id,new Fi(t)),this._springTracks.set(t.id,t);return}if(ee(t))this._trackPlayers.set(t.id,new fe(t)),this._textTracks.set(t.id,t);else if(Le(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 fe(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new fe(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(ot(i)||rt(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=ct(o).filter(d=>ct(i).includes(d));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 d of a)t.push({target:d,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&&!ct(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:Ft,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 $o=100;function tn(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(f,p,m,g)=>{r.push([f,p]);const y=[];e.forEach((v,w)=>{(m==="forward"?(g?v>=f:v>f)&&v<=p:(g?v<=f:v<f)&&v>=p)&&y.push(w)}),y.sort((v,w)=>(m==="forward"?e[v]-e[w]:e[w]-e[v])||v-w);for(const v of y)s.push({kind:"event",index:v,direction:m})};let c=t.time,h=t.direction,d=t.fresh===!0;const u=Math.min($o,Math.max(0,n.iteration-t.iteration));for(let f=0;f<u;f++){const p=h==="forward"?o:0;l(c,p,h,d),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=p,d=!1):(c=h==="forward"?0:o,d=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,d),{crossings:s,passes:r})}function Ni(e){return rt(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Yi(e.inertia),...K(e)}:ot(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...K(e)}:ee(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(en),...K(e)}:Le(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(en),...K(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(en),...K(e)}}function Yi(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function en(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function K(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 Wi(e){if(rt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Yi(t.inertia),...K(t)}}if(ot(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...K(t)}}if(ee(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),...K(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,...K(t)}}return ue({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...K(e)})}function qi(e){const t=e._config.markers;return{formatVersion:Ft,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(Ni),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function At(e){const t=e.formatVersion??1;if(t>Ft)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Ft}. Update tinyfly to play it.`);return new Ze({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Wi),captions:e.captions})}function Fo(e){return JSON.stringify(qi(e))}function Oo(e){const t=JSON.parse(e);return At(t)}function nn(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 de(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 sn(e,t,n){return t+e.next()*(n-t)}function Xi(e,t,n,i){if(i<=0)return sn(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Do(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const Hi=/^([+\-*/])=\s*(-?[\d.]+)$/,Vi=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Bo(e){return typeof e!="string"?!1:Hi.test(e.trim())||Vi.test(e.trim())}function rn(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=Hi.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=Vi.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?Xi(t.random,r,o,a):sn(t.random,r,o)}return e}function Ui(e,t=0,n){const i=[];let s=t;for(const r of e){const o=rn(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class No{random;constructor(t){this.random=de(t)}get seed(){return this.random.seed}resolve(t,n=0){return rn(t,{base:n,random:this.random})}resolveSequence(t,n=0){return Ui(t,n,this.random)}}const Yo=600;function ji(e){if(Array.isArray(e)){const[u,f,p,m]=e;return{fn:Ki(u,f,p,m),bezier:[u,f,p,m]}}const{segments:t}=dt(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,f,p,m]=s.points,g=[a(u),l(f),a(p),l(m)];return{fn:Ki(...g),bezier:g}}const c=[],h=[],d=Math.max(8,Math.ceil(Yo/t.length));for(const u of t)for(let f=c.length===0?0:1;f<=d;f++){const[p,m]=Wo(u,f/d);c.push(a(p)),h.push(l(m))}return{fn:qo(c,h)}}function zi(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 Gi(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 Wo(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 qo(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 Ki(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 d=s(a,e,n)-o,u=r(a,e,n);if(Math.abs(d)<1e-6)return s(a,t,i);if(Math.abs(u)<1e-6)break;a-=d/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 Xo=350,Ho=300,Vo=550;function Uo(e,t={}){const n=t.lead??Xo,i=t.gap??Ho,s=t.tail??Vo,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((u,f)=>{if(!(u.duration>=0))throw new Error(`narration: scene ${l} line ${f} has an invalid duration (${u.duration})`);f>0&&(h+=i),c.push({id:u.id??`s${l}-l${f}`,scene:l,line:f,start:h,end:h+u.duration,text:u.text}),h+=u.duration});const d=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:d-o,cues:c}),o=d}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function jo(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function zo(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const J=e=>Math.round(e*1e3)/1e3;function Ji(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${J(e[0].x)} ${J(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),d=o(l+1),u=o(l+2);if(n===0){r+=` L${J(d.x)} ${J(d.y)}`;continue}const f=n/6,p=h.x+(d.x-c.x)*f,m=h.y+(d.y-c.y)*f,g=d.x-(u.x-h.x)*f,y=d.y-(u.y-h.y)*f;r+=` C${J(p)} ${J(m)} ${J(g)} ${J(y)} ${J(d.x)} ${J(d.y)}`}return i?`${r} Z`:r}const Y=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function Go(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 pe(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=Go(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 me={"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]},Qi={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 Ko(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}z({type:"bounce",mode:"in"}),z({type:"bounce",mode:"in-out"});function Ht(e){const t=Zi.get(e.trim().toLowerCase());if(t)return t;const n=Ko(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:z(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(d=>Number.parseFloat(d)).filter(d=>Number.isFinite(d)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in me)return{easing:{type:"cubic-bezier",points:me[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:z(h)}}return n in Qi?{easing:Qi[n]}:n in me?{easing:{type:"cubic-bezier",points:me[n]}}:{easing:"ease-out"}}const Zi=new Map;function on(e,t){return Zi.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function an(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 ts=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function es(e){return typeof e=="string"&&ts.test(e)}function Jo(e=1){let t=an(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):d=>c(...h,d)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,d,u)=>c===l?h:h+(u-l)/(c-l)*(d-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return ns(l,c,1/0);if("values"in l)return ns(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 d=l+t()*(c-l);return h?Math.round(d/h)*h:d};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 d={};for(const u of Object.keys(l))d[u]=Xt(l[u])(l[u],c[u],h);return d}return Xt(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const m=l,g=y=>m[(Math.round(y)%m.length+m.length)%m.length];return c===void 0?g:g(c)}const d=l,f=c-d,p=m=>f===0?d:((m-d)%f+f)%f+d;return h===void 0?p:p(h)}),wrapYoyo:n(3,(l,c,h)=>{const d=c-l;if(d===0)return l;const u=((h-l)%(d*2)+d*2)%(d*2);return l+(u>d?d*2-u:u)}),snap:n(2,r),random:((l,c,h,d)=>{if(Array.isArray(l)){const f=()=>l[Math.floor(t()*l.length)];return c===!0?f:f()}const u=()=>o(l,c,h);return d?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:d="start",ease:u})=>(f,p,m)=>{const g=m.length,v=ne(f,g,{...c!==void 0?{amount:c}:{each:h??1},from:d}),w=c!==void 0?c:(h??1)*Fe(g,d),k=u&&w>0?u(v/w)*w:v;return l+k},pipe:(...l)=>c=>l.reduce((h,d)=>d(h),c),splitColor:l=>Qo(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=an(l)},resolveRandomString:l=>{const c=ts.exec(l)?.[1]??"";if(c.startsWith("[")){const p=c.slice(1,-1).split(",").map(m=>m.trim()).filter(Boolean).map(m=>Number.isFinite(Number(m))?Number(m):m.replace(/^['"]|['"]$/g,""));return p[Math.floor(t()*p.length)]}const[h,d,u]=c.split(",").map(f=>Number.parseFloat(f));return o(h,d,Number.isFinite(u)?u:void 0)}}}function ns(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 Qo(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 Zo=/^([+-])=\s*(-?[\d.]+)$/,ta=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function Vt(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=Zo.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=ta.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 ea(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 na(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=p=>({x:p%i,y:Math.floor(p/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=p=>{const{x:m,y:g}=r(p),y=Math.abs(m-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},(p,m)=>l(m));const h=Math.max(...c);if(o==="edges"&&(c=c.map(p=>h-p)),o==="random"){const p=n.random??Math.random;c=c.map(()=>p()*h)}const d=t.amount!==void 0?t.amount:(t.each??0)*h,u=t.ease?Ht(t.ease):void 0,f=u?u.fn??z(u.easing):void 0;return c.map(p=>{const m=h===0?0:p/h;return(f?f(m):m)*d})}const ln=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 ge(e){const t={},n={};for(const[i,s]of Object.entries(e))ln.has(i)?t[i]=s:n[i]=s;return{config:t,properties:n}}function ye(e,t){return e===void 0?t:e*1e3}function cn(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:ea(e)?{offsets:na(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 ia={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 is(e){return ia[e]}function sa(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=Ji(t.path,{curviness:t.curviness});else if(St(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 ra(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function ss(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function oa(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=ss(t);if(typeof i!="string"||!St(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 aa(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,rs(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 rs(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 la(e,t){const[n,i]=aa(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function ca(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...la(n,t)}}function ha(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 rs(e,t){return Math.max(0,Math.min(t,e))}function ua(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function fa(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??ua(`${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 hn(e){return Math.max(.1,e/25)}function da(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?hn(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(Bt(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function pa(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in re))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(re).join(", ")}`);return{...t.preset?re[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 ma(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class pt{timeline;options;cursor=0;fallbackRandom=an(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new Ze({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,Ut(n),i)}from(t,n,i){const{config:s,properties:r}=ge(Ut(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],d={...s};for(const p of Object.keys(c))d[p]=this.resolveStart(h,p);o!==void 0&&(d.motionPath=ra(o));const u={},f=String(this.resolveStart(h,"text"));return a!==void 0&&(u.text=un(a),d.text=typeof a=="object"?{...a,value:f}:f),l!==void 0&&(u.text=un(l),d.scrambleText=typeof l=="object"?{...l,text:f}:f),this.build(t,{...c,...u},d,i)}fromTo(t,n,i,s){const{properties:r}=ge(Ut(n));return this.build(t,r,Ut(i),s)}set(t,n,i){return this.build(t,void 0,{...Ut(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,Vt(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return Vt(t,this.context())}addLabel(t,n){return this.labels.set(t,Vt(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=Vt(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=ue({...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}=ge(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...d}=o,u=this.targetsOf(t),f=Vt(s,this.context()),p=ye(r.delay,0),m=ye(r.duration,500),g=cn(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 k=0,T=!1;for(const[A,E]of Object.entries(d)){const S=E;let _=n?.[A]!==void 0?n[A]:this.resolveStart(u[0],A);if(typeof _!=typeof S&&(this.warn(`no usable start value for "${A}" on "${u[0]}" — it will snap to ${String(S)}. Use fromTo() to animate it.`),_=S),w!==void 0&&(typeof _!="number"||typeof S!="number")&&this.warn(`spring works on numbers, so "${A}" on "${u[0]}" eases instead`),w!==void 0&&typeof _=="number"&&typeof S=="number"){const $={...pa(w),from:_,to:S,velocity:ma(w,A)??this.options.startVelocity?.(u[0],A)??0},B=this.nextTrackId(`${u[0]}-${A}-spring`),N={id:B,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"spring",spring:$,delay:f+p};this.timeline.addTrack(N),v.push(B),k=Math.max(k,Zn($));for(const F of u)this.lastValues.set(`${F}|${A}`,S);continue}T=!0;const P=this.keyframesFor(_,S,m,y,r.ease),R=this.nextTrackId(`${u[0]}-${A}`);this.timeline.addTrack(ue({id:R,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,delay:f+p,keyframes:P})),v.push(R);for(const $ of u)this.lastValues.set(`${$}|${A}`,S)}const M=fa({text:l,scrambleText:c},u[0],m);if(M){const A=n?.text??n?.scrambleText,E=A!==void 0?un(A):this.resolveStart(u[0],"text"),S=this.nextTrackId(`${u[0]}-text`),_={id:S,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"text",textConfig:{from:typeof E=="string"?E:String(E??""),...M},delay:f+p,keyframes:this.keyframesFor(0,1,m,y,r.ease)};this.timeline.addTrack(_),v.push(S);for(const P of u)this.lastValues.set(`${P}|text`,M.to)}if(a!==void 0){const{config:A,start:E,end:S}=sa(a),_=this.nextTrackId(`${u[0]}-motionPath`),P={id:_,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"motionPath",motionPathConfig:A,delay:f+p,keyframes:this.keyframesFor(E,S,m,y,r.ease)};this.timeline.addTrack(P),v.push(_)}if(h!==void 0)for(const[A,E]of Object.entries(h)){const S=this.resolveStart(u[0],A);if(typeof S!="number"){this.warn(`inertia on "${A}" needs a numeric start value; skipped`);continue}const _=da(S,E),P=this.nextTrackId(`${u[0]}-${A}-inertia`),R={id:P,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"inertia",inertia:_,delay:f+p};this.timeline.addTrack(R),v.push(P),k=Math.max(k,kt(_));for(const $ of u)this.lastValues.set(`${$}|${A}`,Tt(_))}const L=((h!==void 0||w!==void 0)&&!T&&!M&&a===void 0?k:Math.max(m,k))+(g&&u.length>1?Ot(u.length,g):0),I=f+p+L;return this.previousStart=f+p,this.previousEnd=I,this.cursor=Math.max(this.cursor,I),{trackIds:v,start:f+p,end:I,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"?Ht(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&$t(s)){const c=a?.fn??z(s);return[o,...Ke(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==="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=is(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 Ht(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 un(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 ga(e){return new pt(e)}function Ut(e){return ha(oa(e))}const ya=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),ba="#ffffff",wa="rgba(0, 0, 0, 0.5)";function va(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??ba})`),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??wa})`)}return t.length>0?t.join(" "):null}function Ta(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 ka(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const os=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"]),Ma=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),Sa=new Set(["originX","originY"]),xa=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Aa=new Set(["drawOn"]),Ea={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},as={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Pa="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"),c=n.has("motionPathRotate");for(const[u,f]of n)if(!(u==="x"&&a)&&!(u==="y"&&l)&&!((u==="rotate"||u==="rotateZ")&&c)&&!Aa.has(u)){if(Ma.has(u)){const p=this.buildTransformPart(u,f);p&&i.push(p)}else if(Sa.has(u))typeof f=="number"&&((s??={})[u]=f);else if(xa.has(u))typeof f=="number"&&((r??={})[u]=f);else if(ya.has(u))(o??={})[u]=f;else if(u!=="perspective"){if(u!=="shine")if(u==="text"&&typeof f=="string")Ta(t,f);else if(u==="d"&&typeof f=="string"){const p=t;(p.tagName?.toLowerCase()==="path"?p:p.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,u,f)}}const h=n.get("shine");typeof h=="number"&&this.applyShine(t,h);const d=n.get("perspective");if(typeof d=="number"&&i.unshift(`perspective(${d}px)`),i.length>0&&(t.style.transform=i.join(" "),ka(t)),s){const u=s.originX??50,f=s.originY??50;t.style.transformOrigin=`${u}% ${f}%`}if(r){const u=r.clipTop??0,f=r.clipRight??0,p=r.clipBottom??0,m=r.clipLeft??0;t.style.clipPath=`inset(${u}% ${f}% ${p}% ${m}%)`}if(o){const u=va(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===Pa&&n in as){const a=Array.isArray(i)?i.join(", "):String(i);t.style[as[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Ea[n]??n;let o;typeof i=="number"?os.has(n)||os.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const _a={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class ls{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=Jo();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??_a,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);fn(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(fn(t))return[t];if(!Ca(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return fn(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 fn(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Ca(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function be(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 cs=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Ia(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Ra(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 La(e,t){const n=typeof e=="string"||Array.isArray(e)||cs(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=M=>{const x=cs(M)?M:t.query(M);return x||t.warn(`gsap-compat: motionPath could not find "${String(M)}"`),x};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&St(r))c=r;else{l=a(r);const M=l&&pe({tag:l.localName,attributes:Ia(l)});l&&!M&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=M??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const d=i===!0?l:a(i);if(!d)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[f,p,m,g,y,v]=Ra(d),w=be(u),[k,T]=s??[.5,.5];for(const M of t.targets.slice(1)){const x=be(M);if(Math.abs(x.left-w.left)>.5||Math.abs(x.top-w.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[f,p,m,g,y-w.left-k*w.width,v-w.top-T*w.height],h}const hs=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function us(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function fs(e){if(!e)return null;const t=pe({tag:e.localName,attributes:us(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function $a(e,t,n){const i=ss(e);if(typeof i=="string"&&St(i))return i;const s=hs(i)?i:typeof i=="string"?t(i):null,r=fs(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Fa=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Oa(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):hs(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=pe({tag:i.localName,attributes:us(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))Fa.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const ds=.3;class ps{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=ms(),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=ms(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*ds,this.velocityY+=(o-this.velocityY)*ds}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 ms(){return typeof performance<"u"?performance.now():Date.now()}function gs(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 ys(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class dn{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 ps({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=Da(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...ys([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=gs([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 Da(e){return e<0?0:e>1?1:e}function Ba(e){const t=new dn(e);return t.start(),t}const Na={x:"x",y:"y","x,y":"both"},pn=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function bs(e,t){const n=be(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 ws(e){return Array.isArray(e)?[...e]:e}function Ya(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 Wa(e,t,s,r,i);const o=Na[i.type??"x,y"],a=()=>{const m=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof m=="number"?m:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):pn(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!pn(i.bounds)?i.bounds:void 0)??(l?bs(r,l):void 0)};let d=null;const u=()=>{d?.kill(),d=null},f=m=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?hn(g.resistance):4),v=a(),w=h.bounds??{};let k,T;const M=g.end;if(Array.isArray(M)){const C=Bt({from:v.x,velocity:o==="y"?0:m.x,friction:y}),L=Bt({from:v.y,velocity:o==="x"?0:m.y,friction:y});let I=M[0];for(const A of M)Math.hypot(A.x-C,A.y-L)<Math.hypot(I.x-C,I.y-L)&&(I=A);I&&(k=[I.x],T=[I.y])}else typeof M=="number"?(k=M,T=M):M&&(k=ws(M.x),T=ws(M.y));const x={};o!=="y"&&(x.x={velocity:m.x,friction:y,min:w.minX,max:w.maxX,end:k}),o!=="x"&&(x.y={velocity:m.y,friction:y,min:w.minY,max:w.maxY,end:T}),d=e.to(r,{inertia:x,onComplete:()=>i.onThrowComplete?.()})},p=new dn({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{u(),l&&(h.bounds=bs(r,l)),i.onPress?.()},onDrag:m=>{t.apply(s,o==="x"?{x:m.x}:o==="y"?{y:m.y}:{x:m.x,y:m.y}),i.onDrag?.(m)},onRelease:()=>{const m=p.velocity;i.onRelease?.(m),i.inertia&&f(m)}});return p.start(),{draggable:p,get position(){return a()},get rotation(){const m=t.appliedValue(s,"rotate");return typeof m=="number"?m:0},destroy(){u(),p.destroy()}}}function Wa(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!pn(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,d={x:0,y:0},u=0,f=0,p=[];const m=w=>Math.atan2(w.clientY-d.y,w.clientX-d.x)*180/Math.PI,g=w=>{if(c)return;l?.kill(),l=null,c=!0,h=w.pointerId,i.setPointerCapture?.(w.pointerId);const k=i.getBoundingClientRect();d={x:k.left+k.width/2,y:k.top+k.height/2},u=m(w),f=o(),p=[{time:performance.now(),rotation:f}],s.onPress?.()},y=w=>{if(!c||w.pointerId!==h)return;const k=m(w);let T=k-u;T>180&&(T-=360),T<-180&&(T+=360),u=k,f+=T;let M=a(f);s.snap&&(M=a(Math.round(M/s.snap)*s.snap)),t.apply(n,{rotate:M});const x=performance.now();for(p.push({time:x,rotation:M});p.length>2&&x-p[0].time>100;)p.shift();const C={x:0,y:0};s.onDrag?.(C)},v=w=>{if(!c||w.pointerId!==h)return;c=!1;const k=p[0],T=p[p.length-1],M=k&&T?(T.time-k.time)/1e3:0,x=M>0?(T.rotation-k.rotation)/M:0;if(s.onRelease?.({x,y:0}),!s.inertia)return;const C=s.inertia===!0?{}:s.inertia,L=C.friction??(C.resistance!==void 0?hn(C.resistance):4),I=typeof C.end=="number"||Array.isArray(C.end)?C.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:x,friction:L,min:r.minRotation,max:r.maxRotation,end:Array.isArray(I)?I.filter(A=>typeof A=="number"):I}},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 qa={opacity:0,scale:.6};function Xa(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 vs(e){const t=be(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 mn(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=Xa(o);s.set(o,a);const l=Ts(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const gn=new WeakMap;function yn(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?qa:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const f of e.resolveTargets(i.targets)){const p=e.elementFor(f);p&&c.add(p)}const h=[...c].sort((f,p)=>f===p?0:f.compareDocumentPosition(p)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),d=t({onComplete:i.onComplete});let u=0;for(const f of h){const p=vs(f);if(!p)continue;let m=n.boxes.get(f)??null,g;const y=Ts(f),v=!m&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==f&&(m=v.box,g=v.element);const[w]=e.resolveTargets(f);gn.get(f)?.timeline.removeTracks({target:w});const k=u*o;if(!m){if(l===!1)continue;d.fromTo(f,{x:0,y:0,scaleX:1,scaleY:1,...l},{...ks(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:k},0),gn.set(f,d),u++;continue}const T=m.cx-p.cx,M=m.cy-p.cy,x=a?m.width/p.width:1,C=a?m.height/p.height:1;if(!(Math.abs(T)>.5||Math.abs(M)>.5||Math.abs(x-1)>.001||Math.abs(C-1)>.001)){const A=(E,S)=>{const _=e.appliedValue(w,E);return typeof _=="number"&&Math.abs(_-S)>1e-6};(A("x",0)||A("y",0)||A("scaleX",1)||A("scaleY",1))&&d.set(f,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const I=i.fade===!0&&g!==void 0;d.fromTo(f,{x:T,y:M,scaleX:x,scaleY:C,...I&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...I&&{opacity:1},duration:s,ease:r,delay:k},0),I&&g&&vs(g)&&d.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:k},0),gn.set(f,d),u++}return d}function Ts(e){return e.dataset?.flipId}function ks(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function Ha(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(m=>m.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(m=>({element:m,html:m.innerHTML,ariaLabel:m.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:m,html:g,ariaLabel:y}of r)m.innerHTML=g,y===null?m.removeAttribute("aria-label"):m.setAttribute("aria-label",y)},d=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},u=()=>{const m={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),v=Va(g,i.words),w=n.has("chars")?v.flatMap(M=>Ua(M,i.chars)):[],k=n.has("lines")?za(g,v,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const M of v)M.setAttribute("aria-hidden","true")}if(n.has("words"))m.words.push(...v);else for(const M of v)M.removeAttribute("class");m.chars.push(...w),m.lines.push(...k);const T=t.mask==="lines"?k:t.mask==="words"?v:t.mask==="chars"?w:[];for(const M of T)m.masks.push(Ga(M,`${i[t.mask]}-mask`))}o=m},f={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(d(),h(),u(),a=t.onSplit?.(f))},revert(){c=!0,l?.disconnect(),d(),h()}};u(),a=t.onSplit?.(f),t.autoSplit&&p();function p(){const m=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const w=()=>{g=!1,f.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(w):setTimeout(w,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(w=>{let k=!1;for(const T of w){const M=Math.round(T.contentRect.width),x=m.get(T.target);m.set(T.target,M),x!==void 0&&x!==M&&(k=!0)}k&&y()});for(const w of e)l.observe(w)}const v=e[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return f}function Va(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 Ua(e,t){const n=e.ownerDocument,i=ja(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 ja(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function za(e,t,n){const i=e.ownerDocument,s=new Map(t.map(p=>[p,p.getBoundingClientRect()])),r=[],o=p=>{for(const m of Array.from(p.childNodes))m.nodeType===3||s.has(m)||m.tagName==="BR"?r.push(m):o(m)};o(e);const a=[];let l=null,c=0,h=0,d=!1,u=[];const f=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),u=[]};for(const p of r){if(p.tagName==="BR"){d=!0;continue}const m=s.get(p);if(m&&(!l||d||m.top>c+h)&&(f(),c=m.top,h=m.height/2,d=!1),!l)continue;const g=[];for(let w=p.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 k=w.cloneNode(!1);v.appendChild(k),u.push({original:w,clone:k}),v=k}v.appendChild(p)}return e.replaceChildren(...a),a}function Ga(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 Ms={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function bn(e){const t=e.trim().toLowerCase();if(t in Ms)return Ms[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function wn(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?bn(i[0]):void 0,r=i[1]!==void 0?bn(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Et(e,t,n){const i=wn(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 Ka(e,t,n,i){const s=Et(e,t,n),o=Et(e,t,i)-s;return o<=0?s<=0?1:0:vn(-s/o)}function vn(e){return e<0?0:e>1?1:e===0?0:e}function Ss(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function Tn(e,t,n,i,s){const r=h=>Et({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 d=(l+c)/2;Math.sign(r(d))===Math.sign(o)?l=d:c=d}return(l+c)/2}class xs{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 Ja(e){const t=new xs(e);return t.start(),t}class As{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 Qa=.15;function Es(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function Ps(e,t,n){const i=we(e+t*Qa);if(typeof n=="function")return we(n(i));if(typeof n=="number")return n<=0?e:we(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 we(s)}function _s(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 Cs{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=Nt,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 we(e){return Math.max(0,Math.min(1,e))}class Is{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,d)=>{const u=t.createElement("div");return u.textContent=`${a}${c}`,u.setAttribute("aria-hidden","true"),u.className="scroll-marker",Object.assign(u.style,{position:d?"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 Za=120,Pt=[],_t=new Set;let kn=!1;const tl=()=>{kn||_t.size===0||(kn=!0,queueMicrotask(()=>{kn=!1;for(const e of _t)e.afterRefresh()}))},Rs=()=>{for(const e of _t)e.beforeRefresh();for(const e of Pt)e.refresh();for(const e of _t)e.afterRefresh()};let Ct={width:0,height:0};const Ls=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===Ct.width&&t!==Ct.height,i=Math.abs(t-Ct.height)<Ct.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(Ct={width:e,height:t},Rs())};class jt{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 Cs(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 As(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Is(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Pt.length===0&&typeof window<"u"&&(Ct={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Ls,{passive:!0})),Pt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Pt.splice(Pt.indexOf(this),1),Pt.length===0&&typeof window<"u"&&window.removeEventListener("resize",Ls),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(){Rs()}static onRefresh(t){return _t.add(t),()=>_t.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+Et(n,i,zt(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,tl()}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?vn((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=zt(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+Et(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()},Za))}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=Es(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+Ps(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,_s(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=f=>a+f*(l-a),h=Tn(o,i.width,r,zt(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const d=zt(this.options.end)??"right left",u=typeof d=="string"?d.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=u?this.startPx+Number.parseFloat(u[1]):c(Tn(o,i.width,r,d,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=zt(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=wn(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=Ss(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 zt(e){return typeof e=="function"?e():e}function el(e){const t=new jt(e);return t.start(),t}const Mn=new Set,nl=16,$s=.5,il=2;class Sn{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),Mn.add(this),this.stopListening=jt.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of Mn)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),Mn.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)xn(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??Nt,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)xn(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?nl: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)<=il||(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)<$s&&(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)<$s?s.lagged=i:n=!0,r+=i-s.lagged}xn(s.element,r===0?s.saved:`0 ${sl(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 xn(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function sl(e){return Math.round(e*100)/100}function rl(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 An(e,t,n,i,s=()=>{}){const r=f=>typeof f=="string"?e.query(f)??void 0:f,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 d=(f,p)=>()=>{p?.(),n&&!a&&rl(n,l[f]??"none"),t.once&&f===0&&queueMicrotask(()=>h.destroy())},u=t.containerAnimation?ll(e,t.containerAnimation,o,s):void 0;return h=new jt({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:ol(t.snap,n),markers:t.markers,container:u,onUpdate:(f,p)=>{if(n&&a!==!1&&n.progress(f),t.onUpdate){const m=f<c||p<0?-1:1;t.onUpdate({progress:f,velocity:p,direction:m})}c=f},onEnter:d(0,t.onEnter),onLeave:d(1,t.onLeave),onEnterBack:d(2,t.onEnterBack),onLeaveBack:d(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function ol(e,t){const n=s=>s==="labels"?r=>al(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?Ht(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??z(i.easing):void 0}}function al(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function ll(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 Fs{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 cl{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 Fs(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class hl{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 ul={opacity:0,y:-16},fl={opacity:0,y:16};async function dl(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 pl(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),d=h.length?mn(t,h):void 0,u=i.from!==void 0?Os(t,i.from,i.shared):[];if(u.length&&i.leave!==!1){const g=i.leave??ul;await c(y=>e.to(u,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const f=[],p=typeof i.to=="function"?i.to():i.to,m=p!==void 0?Os(t,p,i.shared):[];if(m.length&&i.enter!==!1){const g=i.enter??fl;f.push(c(y=>e.fromTo(m,g,{...ks(g),duration:a,ease:l,onComplete:y})))}if(d){const g=o().filter(y=>!h.includes(y));g.length&&f.push(c(y=>yn(t,n,d,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(f)}function Os(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 pl(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 Ds={create:(e,t)=>on(e,ji(t))},Bs={create:(e,t)=>on(e,{fn:zi(t)})},Ns={create:(e,t)=>on(e,{fn:Gi(t)})},ml=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Ys=.5,gl="power1.inOut";function yl(e){return e.keyframes!==void 0&&e.keyframes!==null}function bl(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))ml.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??Ys}));const i=Object.entries(t),s=e.duration??Ys,r=t.easeEach??e.easeEach??gl;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,f])=>({at:Number.parseFloat(u)/100,step:f})).sort((u,f)=>u.at-f.at),h=[];let d=0;for(const{at:u,step:f}of c){const p=Math.max(0,u-d);h.push({...n,ease:r,...f,duration:p*s}),d=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[d,u]of o)c<u.length&&(h[d]=u[c]);l.push(h)}return l}function Ws(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 k=typeof w=="string"?s.querySelector(w):w;if(!k)return o[v];const T=k.getBoundingClientRect(),M=r?.getBoundingClientRect(),x=(v==="x"?i.offsetX:i.offsetY)??i.offset??0;return v==="x"?T.left-(M?.left??0)+o.x-x:T.top-(M?.top??0)+o.y-x},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))},d={...o},u=()=>{r?(r.scrollLeft=d.x,r.scrollTop=d.y):window.scrollTo({left:d.x,top:d.y,behavior:"instant"})},f=["wheel","touchstart","keydown"],p=r??window,m=()=>{y.kill(),g()},g=()=>{for(const v of f)p.removeEventListener(v,m)},y=e.to(d,{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 f)p.addEventListener(v,m,{passive:!0});return y}function wl(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,...d}=n,u={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},f={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},p={},m=y=>{p[y]!==void 0&&clearTimeout(p[y]),p[y]=void 0;const v=f[y].splice(0);v.length>0&&u[y]?.(v)},g=(y,v)=>{if(u[y]){if(f[y].push(v),o!==void 0&&f[y].length>=o)return m(y);p[y]===void 0&&(p[y]=setTimeout(()=>m(y),r*1e3))}};return s.map(y=>An(e,{...d,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class Q{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 pt({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return kl(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return fs(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=Us(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>Vs(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=An(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 yl(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 Q(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}=tn(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 d=(u,f,p)=>{s(u,f,p),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,d),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=bl(n);if(r.length===0)return;const o=s.length>1?cn(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?ie(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+ye(n.delay,0)/1e3;let d=1/0,u=-1/0;if(l.forEach((g,y)=>{r.forEach((v,w)=>{const k=w===0?h+c[y]:">";this.tween(g,[v],k,([T],M,x)=>this.compat.to(M,T,x)),d=Math.min(d,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),d===1/0)return;const{onStart:f,onUpdate:p,onComplete:m}=n;f&&this.events.push({time:d,direction:"forward",run:f}),p&&this.ranges.push({start:d,end:u,run:p}),m&&this.events.push({time:u,direction:"forward",run:m})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>Vs(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(Tl)||t.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(t[0]);s(n.map(f=>this.prepare(Hs(f,0,u,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=cn(l,this.staggerContext(t)),d=h?ie(t.length,h).map(u=>u/1e3):t.map(()=>0);t.forEach((u,f)=>{const p=f===0?ye(c.delay,0)/1e3+d[0]:0,m=f===0?0:d[f]-d[f-1],g=f===0?i:`<${m<0?"-":"+"}${Math.abs(m).toFixed(6)}`,v=n.map((w,k)=>k===a?{...c,delay:p}:w).map(w=>this.prepare(Hs(w,f,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=La(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=$a(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=Us(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=ca(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 ${Ml(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function qs(e=new ls){const t=r=>{const{config:o}=ge(r);return new Q(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:d,...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)??is(o)},scrollTrigger:r=>i(An(e,r)),scrollBatch:(r,o)=>wl(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Ws(s,e,r,o),refreshScroll:()=>{jt.refreshAll(),Sn.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new Sn({...r,scroller:o}).start())},context:(r,o)=>{const a=new Fs(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new cl(e,r),customEase:Ds.create,customBounce:Bs.create,customWiggle:Ns.create,pageTransition:r=>dl(s,e,o=>new Q(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 hl(a,o))},quickTo:(r,o,a={})=>{const l=new Q(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(d=>{if(!c)return;const u=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:d,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:vl(a.spring,o,u)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new Q(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 Ws(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 Q(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=>Oa(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(Ha(l,o))},draggable:(r,o)=>i(Ya(s,e,r,o)),getFlipState:r=>mn(e,r),flipFrom:(r,o)=>yn(e,a=>new Q(e,a),r,o),flip:(r,o,a)=>{const l=mn(e,r);return o(),yn(e,c=>new Q(e,c),l,{targets:r,...a})}};return s}const q=qs();function vl(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Tl(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Xs(e)}function Xs(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||es(n))&&!ln.has(t))}function Hs(e,t,n,i,s){if(!Xs(e))return e;const r={};for(const[o,a]of Object.entries(e))ln.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):es(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function Vs(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 Us(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function kl(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Ml(e){return typeof e=="string"?`"${e}"`:String(e)}class En{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 js(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 ve{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=At({...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 En(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)js(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:At(r.timeline)})})}attachMedia(t,n){this.mediaSync=new En(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}=tn(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 Sl(e,t,n={}){const i=new ve(e,{...n,autoplay:!0});return await i.load(t),i}function xl(e,t={}){return new ve(e,t)}const zs={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"},Gs="tinyfly-controls-style",Al=`
1
+ (function(y,Pt){typeof exports=="object"&&typeof module<"u"?Pt(exports):typeof define=="function"&&define.amd?define(["exports"],Pt):(y=typeof globalThis<"u"?globalThis:y||self,Pt(y.tinyfly=y.tinyfly||{}))})(this,(function(y){"use strict";function Pt(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 cn(e){return e.property==="motionPath"&&"motionPathConfig"in e}function qo(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function Fi(e){return"keyframes"in e}class Xo{_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 Uo{_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 un(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 fn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,un(i,e,t));return n}function be(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=un(e,t,i);if(n.amount!==void 0){const r=fn(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,dn=6e4,ve=dn/_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:dn}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 Vo(e,t){return new jt(e).valueAt(t)}function Li(e){return new jt(e).settleTime()}function zo(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 jo(e){const t=e.stiffness??Z.stiffness,n=e.mass??Z.mass;return 2*Math.sqrt(t*n)}const pn=4,Go=.002,Jo=1e-4,Oi=6e4;function Se(e){const t=e.friction??pn;return t>0?t:pn}function Gt(e){return e.from+e.velocity/Se(e)}function Zo(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=Zo(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 It(e){const t=Math.abs(Ct(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Jo,t*Go);if(n>=t)return 0;const i=Math.log(t/n)/Se(e);return Math.min(Oi,i*1e3)}function Te(e,t){if(t<=0)return e.from;const n=Ct(e);if(t>=It(e))return n;const i=Se(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function Qo(e,t){const n=Se(e),i=Ct(e);return t>=It(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Me=e=>e,Bi=e=>e*e,Di=e=>1-(1-e)*(1-e),Ni=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,mn=e=>e*e*e,gn=e=>1-Math.pow(1-e,3),Jt=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Wi=mn,Yi=gn,Ki=Jt,ta={linear:Me,"ease-in":Wi,"ease-out":Yi,"ease-in-out":Ki,"ease-in-quad":Bi,"ease-out-quad":Di,"ease-in-out-quad":Ni,"ease-in-cubic":mn,"ease-out-cubic":gn,"ease-in-out-cubic":Jt};function qi(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,d=p=>((a*p+o)*p+r)*p,u=p=>((c*p+h)*p+l)*p,f=p=>(3*a*p+2*o)*p+r,m=p=>{let g=p;for(let w=0;w<8;w++){const T=d(g)-p;if(Math.abs(T)<1e-7)return g;const S=f(g);if(Math.abs(S)<1e-7)break;g-=T/S}let b=0,v=1;for(g=p;b<v;){const w=d(g);if(Math.abs(w-p)<1e-7)return g;p>w?b=g:v=g,g=(b+v)/2}return g};return p=>{if(p<=0)return 0;if(p>=1)return 1;const g=m(p);return u(g)}}function yn(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 Xi(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 Ui=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 Vi(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 zi(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 zi(e.count,e.position);case"elastic":return yn(Xi(e.amplitude,e.period),e.mode);case"bounce":return yn(Ui,e.mode);case"back":return yn(Vi(e.overshoot),e.mode)}}function z(e){return e===void 0?Me:Pt(e)?qi(e.points):Ut(e)?ji(e):ta[e]??Me}const Gi=32,ea=256,Ht=new Map,na=/[MmLlHhVvCcSsQqTtAaZz]/,ia=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,sa={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function ra(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(na.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=ia.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function oa(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 d=s*Math.PI/180,u=Math.cos(d),f=Math.sin(d),m=(e-a)/2,p=(t-l)/2,g=u*m+f*p,b=-f*m+u*p,v=g*g/(h*h)+b*b/(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*b*b-c*c*g*g,S=h*h*b*b+c*c*g*g,k=w*Math.sqrt(Math.max(0,T/S)),M=k*h*b/c,C=-k*c*g/h,x=u*M-f*C+(e+a)/2,_=f*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)),xt=Math.acos(Math.max(-1,Math.min(1,nt/kt)));return F*X-B*D<0?-xt:xt},A=P(1,0,(g-M)/h,(b-C)/c);let E=P((g-M)/h,(b-C)/c,(-g-M)/h,(-b-C)/c);!o&&E>0&&(E-=2*Math.PI),o&&E<0&&(E+=2*Math.PI);const I=Math.max(1,Math.ceil(Math.abs(E)/(Math.PI/2))),H=E/I,R=4/3*Math.tan(H/4),$=F=>{const B=h*Math.cos(F),D=c*Math.sin(F);return[u*B-f*D+x,f*B+u*D+_]},O=F=>{const B=-h*Math.sin(F),D=c*Math.cos(F);return[u*B-f*D,f*B+u*D]},L=[];for(let F=0;F<I;F++){const B=A+F*H,D=B+H,[X,nt]=$(B),[kt,xt]=F===I-1?[a,l]:$(D),[hn,ge]=O(B),[$i,Af]=O(D);L.push([X+R*hn,nt+R*ge,kt-R*$i,xt-R*Af,kt,xt])}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 Ji(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,d=t,u=0;for(let f=1;f<=Gi;f++){const m=f/Gi,p=pt(e,i,r,a,m),g=pt(t,s,o,l,m);u+=Math.hypot(p-c,g-d),h.push(u),c=p,d=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=Ht.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,d=p=>{h<0&&(h=0),p.subpath=h,n.push(p)};for(const{type:p,args:g}of ra(e)){const b=p.toUpperCase(),v=p!==b,w=sa[b];if(b==="Z"){(i!==r||s!==o)&&d(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 S=g.slice(T,T+w),k=v?i:0,M=v?s:0;let C=null,x=null;switch(b){case"M":T===0?(i=S[0]+k,s=S[1]+M,r=i,o=s,(h<0||n[n.length-1]?.subpath===h)&&h++):(d(Zt(i,s,S[0]+k,S[1]+M)),i=S[0]+k,s=S[1]+M);break;case"L":d(Zt(i,s,S[0]+k,S[1]+M)),i=S[0]+k,s=S[1]+M;break;case"H":d(Zt(i,s,S[0]+k,s)),i=S[0]+k;break;case"V":d(Zt(i,s,i,S[0]+M)),s=S[0]+M;break;case"C":{const _=[S[0]+k,S[1]+M,S[2]+k,S[3]+M,S[4]+k,S[5]+M];d(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,S[0]+k,S[1]+M,S[2]+k,S[3]+M];d(Ee(i,s,A)),C=[A[2],A[3]],i=A[4],s=A[5];break}case"Q":case"T":{let _=i,P=s;b==="Q"?(_=S[0]+k,P=S[1]+M):l&&(_=2*i-l[0],P=2*s-l[1]);const A=b==="Q"?S[2]+k:S[0]+k,E=b==="Q"?S[3]+M:S[1]+M;d(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 _=S[5]+k,P=S[6]+M;let A=i,E=s;for(const I of oa(i,s,S[0],S[1],S[2],S[3],S[4],_,P))d(Ee(A,E,I)),A=I[4],E=I[5];i=_,s=P;break}}a=C,l=x}}const u=n.reduce((p,g)=>p+g.length,0),f=[];for(let p=0;p<n.length;){const g=n[p].subpath;let b=p,v=0;for(;b<n.length&&n[b].subpath===g;)v+=n[b++].length;const w=n[p],T=n[b-1],S=c.has(g)||Math.abs(T.endX-w.startX)<1e-9&&Math.abs(T.endY-w.startY)<1e-9;f.push({start:p,end:b,length:v,closed:S}),p=b}const m={segments:n,totalLength:u,subpaths:f};return Ht.size>=ea&&Ht.delete(Ht.keys().next().value),Ht.set(e,m),m}function aa(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 la(e,t){if(e.type==="L"){const d=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*d,y:e.startY+(e.endY-e.startY)*d,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=aa(e,t);let h=Ji(e.startX,n,s,o,l),c=Ji(e.startY,i,r,a,l);if(Math.hypot(h,c)<1e-9){const d=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=pt(e.startX,n,s,o,d),f=pt(e.startY,i,r,a,d),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?f-p:p-f}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 bn(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 la(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function Zi(e,t){const{segments:n,totalLength:i}=St(e);return bn(n,Math.max(0,Math.min(1,t))*i)}function ha(){Ht.clear()}function ca(e){return St(e).totalLength}const ua=24,fa=320,da=2.5,Qt=72,pa=64,ma=.2,ga=128,te=new Map;let Ae=0,mt;const Qi=e=>Math.round(e*100)/100;function ts(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 wn(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=bn(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function es(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 ns(e,t){const n=[];for(let i=0;i<t;i++)n.push(wn(e,e.closed?i/t:i/(t-1)));return n}function is(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 ya(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=is(ns(e,Qt)),r=is(ns(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 d=0;d<c;d++){let u=0;for(let f=0;f<o&&u<l;f++){const m=i?h?(d-f+o)%o:(f+d)%o:h?o-1-f:f,p=s[f][0]-r[m][0],g=s[f][1]-r[m][1];u+=p*p+g*g}u<l&&(l=u,a={offset:i?d/o:0,reversed:h})}}return a}function ba(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function wa(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function va(e,t,n){const i=e.closed&&t.closed,s=ya(e,t,n.shapeIndex),r=Math.max(ua,Math.min(fa,Math.ceil(Math.max(e.length,t.length)/da))),o=new Set,a=d=>o.add(Math.round(d*1e7)/1e7);for(let d=0;d<=r;d++)a(d/r);for(const d of es(e))a(d);for(const d of es(t))a(wa(d,s,i));let l=[...o].sort((d,u)=>d-u);i&&(l=l.filter(d=>d<1));const h=[],c=[];for(const d of l)h.push(...wn(e,d)),c.push(...wn(t,ba(d,s,i)));return ka({from:h,to:c,closed:i})}function ka(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=ma;for(let c=o+1;c<a;c++){const d=Math.max(ss(e.from,o,a,c),ss(e.to,o,a,c));d>h&&(h=d,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 ss(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,d=c===0?0:Math.max(0,Math.min(1,(l*o+h*a)/c));return Math.hypot(l-d*o,h-d*a)}function Sa(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(f=>f.length>0).length===St(t).subpaths.filter(f=>f.length>0).length,a=ts(e,!o),l=ts(t,!o),h={pairs:a.map((f,m)=>va(f,l[m],n))};Ae>=ga&&(te.clear(),Ae=0);const c=String(i??"auto"),d=te.get(c)??new Map;te.set(c,d);const u=d.get(e)??new Map;return d.set(e,u),u.set(t,h),Ae++,mt={from:e,to:t,shapeIndex:i,plan:h},h}function rs(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=Sa(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=Qi(a.from[l]+(a.to[l]-a.from[l])*s),c=Qi(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 Ta(){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,os=512,vn=new Map,kn=new Map;function as(e){const t=vn.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 vn.size<os&&vn.set(e,i),i}const ls=e=>e.charCodeAt(0)===35,hs=e=>e.startsWith("rgb"),cs=e=>e.startsWith("rgba"),Ma=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Sn=e=>Math.round(e).toString(16).padStart(2,"0");function Ea(e,t,n){return`#${Sn(e)}${Sn(t)}${Sn(n)}`}function us(e){const t=kn.get(e);if(t)return t;const n=e.match(Ma);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 kn.size<os&&kn.set(e,o),o}const fs=(e,t,n)=>{if(ls(e)&&ls(t)){const[i,s,r]=as(e),[o,a,l]=as(t),h=st(i,o,n),c=st(s,a,n),d=st(r,l,n);return Ea(h,c,d)}if((hs(e)||cs(e))&&(hs(t)||cs(t))){const i=us(e),s=us(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},ds=(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},Tn=(e,t,n)=>n<1?e:t,ps=(e,t,n)=>rs(e,t,n);function ee(e){return typeof e=="number"?st:Array.isArray(e)?ds:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?fs:Rt(e)?ps:Tn:Tn}const Mn=1e3/60;function En(e,t={}){if(!dt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new jt(e.spring);return ms(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function An(e,t={}){if(!ft(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return ms(e,i=>Te(n,i),It(n),n.from,Ct(n),t)}function ms(e,t,n,i,s,r){const o=r.intervalMs??Mn,a=r.tolerance??.01,l=e.delay??0,h=[];for(let d=0;d<=n;d+=o)h.push({time:d+l,value:t(d),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?ys(h,a):h,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function xn(e,t,n,i={}){const s=i.intervalMs??Mn,r=typeof n=="function"?n:z(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 d=c/a;l.push({time:e.time+c,value:o(e.value,t.value,r(d)),easing:"linear"})}const h=r(1);return l.push({...t,...h!==1&&{value:o(e.value,t.value,h)},easing:"linear"}),l}function Aa(e,t){return dt(e)?En(e,t):ft(e)?An(e,t):e}function gs(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(...xn(n[s-1],r,r.easing,t)):i.push(r)}return{...e,keyframes:i}}function xa(e,t){return e.filter(Fi).map(n=>gs(n,t)).concat(e.filter(dt).map(n=>En(n,t)),e.filter(ft).map(n=>An(n,t)))}function ys(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=z(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 bs{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 ws{track;targets;duration;constructor(t){this.track=t,this.targets=gt(t),this.duration=It(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 Pn(e,t){const n={...Zi(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 d=n.angle*Math.PI/180,u=Math.cos(d),f=Math.sin(d);n.angle=Math.atan2(s*u+o*f,i*u+r*f)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function Pa(e,t,n,i){const s=t+(n-t)*i;return Pn(e,s)}const _n={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},_a=20;function vs(e){const t=_n[e??"upperCase"]??e??_n.upperCase,n=Array.from(t);return n.length>0?n:Array.from(_n.upperCase)}function Ca(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 ks(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)),d=Math.floor(c*a.length),u=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),f=vs(e.chars),m=e.refreshRate??_a,p=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let b="";for(let v=0;v<u;v++){const w=l?v>=u-d:v<d,T=l?a[a.length-(u-v)]:a[v];w&&T!==void 0||T===" "||T===`
2
+ `?b+=T:b+=f[Ca(g,v,p)%f.length]}return b}class Cn{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}`,d=h<=t,u=i.get(c);(!u||(d!==u.started?d:d?h>=u.start:h<=u.start))&&i.set(c,{trackId:s,target:a,property:o,value:l,start:h,started:d})}}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",ks(l.textConfig,r,Math.max(0,o)));return}const h=this._motionPathTracks.get(n);if(h&&typeof r=="number"){const c=Pn(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 ws(t));return}if(dt(t)){this._trackPlayers.set(t.id,new bs(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(cn(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(d=>gt(i).includes(d));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 d of a)t.push({target:d,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 Ia=100;function In(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(f,m,p,g)=>{r.push([f,m]);const b=[];e.forEach((v,w)=>{(p==="forward"?(g?v>=f:v>f)&&v<=m:(g?v<=f:v<f)&&v>=m)&&b.push(w)}),b.sort((v,w)=>(p==="forward"?e[v]-e[w]:e[w]-e[v])||v-w);for(const v of b)s.push({kind:"event",index:v,direction:p})};let h=t.time,c=t.direction,d=t.fresh===!0;const u=Math.min(Ia,Math.max(0,n.iteration-t.iteration));for(let f=0;f<u;f++){const m=c==="forward"?o:0;l(h,m,c,d),s.push({kind:"repeat"}),a?(c=c==="forward"?"reverse":"forward",h=m,d=!1):(h=c==="forward"?0:o,d=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:r}:(l(h,n.time,c,d),{crossings:s,passes:r})}function Ss(e){return ft(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Ts(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(Hn),...rt(e)}:cn(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(Hn),...rt(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(Hn),...rt(e)}}function Ts(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function Hn(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 Ms(e){if(ft(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Ts(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 Es(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(Ss),...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 Cn({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Ms),captions:e.captions})}function Ha(e){return JSON.stringify(Es(e))}function Ra(e){const t=JSON.parse(e);return Ft(t)}function Rn(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 $n(e,t,n){return t+e.next()*(n-t)}function As(e,t,n,i){if(i<=0)return $n(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function $a(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const xs=/^([+\-*/])=\s*(-?[\d.]+)$/,Ps=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Fa(e){return typeof e!="string"?!1:xs.test(e.trim())||Ps.test(e.trim())}function Fn(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=xs.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=Ps.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?As(t.random,r,o,a):$n(t.random,r,o)}return e}function _s(e,t=0,n){const i=[];let s=t;for(const r of e){const o=Fn(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class La{random;constructor(t){this.random=_e(t)}get seed(){return this.random.seed}resolve(t,n=0){return Fn(t,{base:n,random:this.random})}resolveSequence(t,n=0){return _s(t,n,this.random)}}const Oa=600;function Cs(e){if(Array.isArray(e)){const[u,f,m,p]=e;return{fn:Rs(u,f,m,p),bezier:[u,f,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,f,m,p]=s.points,g=[a(u),l(f),a(m),l(p)];return{fn:Rs(...g),bezier:g}}const h=[],c=[],d=Math.max(8,Math.ceil(Oa/t.length));for(const u of t)for(let f=h.length===0?0:1;f<=d;f++){const[m,p]=Ba(u,f/d);h.push(a(m)),c.push(l(p))}return{fn:Da(h,c)}}function Is(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 Hs(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 Ba(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 Da(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 Rs(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 d=s(a,e,n)-o,u=r(a,e,n);if(Math.abs(d)<1e-6)return s(a,t,i);if(Math.abs(u)<1e-6)break;a-=d/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 Na=350,Wa=300,Ya=550;function Ka(e,t={}){const n=t.lead??Na,i=t.gap??Wa,s=t.tail??Ya,r=[];let o=0;return e.forEach((a,l)=>{const h=[];let c=o+n;a.lines.forEach((u,f)=>{if(!(u.duration>=0))throw new Error(`narration: scene ${l} line ${f} has an invalid duration (${u.duration})`);f>0&&(c+=i),h.push({id:u.id??`s${l}-l${f}`,scene:l,line:f,start:c,end:c+u.duration,text:u.text}),c+=u.duration});const d=c+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:d-o,cues:h}),o=d}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function qa(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Xa(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const Ln=e=>6e4/e.bpm;function Ce(e,t){return e.offset+t*Ln(e)}function Ie(e,t){return(t-e.offset)/Ln(e)}function Ua(e,t){return Ce(e,Math.round(Ie(e,t)))}function Va(e,t){return Ce(e,Math.ceil(Ie(e,t)-1e-9))}function za(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(Ie(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 ja(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 d=Math.max(1,Math.floor(60*Lt/s)),u=Math.min(a-1,Math.ceil(60*Lt/i)),f=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=d,g=-1/0;for(let x=d;x<=u;x++){const _=60*Lt/x,P=Math.exp(-.5*(Math.log2(_/120)/.9)**2),A=f(x)*P;A>g&&(g=A,p=x)}const b=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+=b(A);return P};let w=p,T=0,S=-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>S&&(S=E,T=A,w=x)}}const k=60*Lt/w,M=m>0?Math.max(0,Math.min(1,f(p)/m)):0,C=(T+.5)*1e3/Lt;return{bpm:Math.round(k*100)/100,offset:Math.round(C%(6e4/k)),confidence:M}}const ot=e=>Math.round(e*1e3)/1e3;function $s(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),d=o(l+1),u=o(l+2);if(n===0){r+=` L${ot(d.x)} ${ot(d.y)}`;continue}const f=n/6,m=c.x+(d.x-h.x)*f,p=c.y+(d.y-h.y)*f,g=d.x-(u.x-c.x)*f,b=d.y-(u.y-c.y)*f;r+=` C${ot(m)} ${ot(p)} ${ot(g)} ${ot(b)} ${ot(d.x)} ${ot(d.y)}`}return i?`${r} Z`:r}const Y=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function Ga(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 He(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=Ga(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]},Fs={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 Ja(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}z({type:"bounce",mode:"in"}),z({type:"bounce",mode:"in-out"});function ne(e){const t=Ls.get(e.trim().toLowerCase());if(t)return t;const n=Ja(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:z(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(d=>Number.parseFloat(d)).filter(d=>Number.isFinite(d)),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:z(c)}}return n in Fs?{easing:Fs[n]}:n in Re?{easing:{type:"cubic-bezier",points:Re[n]}}:{easing:"ease-out"}}const Ls=new Map;function On(e,t){return Ls.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function Bn(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 Os=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function Bs(e){return typeof e=="string"&&Os.test(e)}function Za(e=1){let t=Bn(e);const n=(l,h)=>((...c)=>c.length>=l?h(...c):d=>h(...c,d)),i=(l,h,c)=>Math.min(Math.max(c,Math.min(l,h)),Math.max(l,h)),s=(l,h,c,d,u)=>h===l?c:c+(u-l)/(h-l)*(d-c),r=(l,h)=>{if(typeof l=="number")return l===0?h:Math.round(h/l)*l;if(Array.isArray(l))return Ds(l,h,1/0);if("values"in l)return Ds(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 d=l+t()*(h-l);return c?Math.round(d/c)*c:d};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 d={};for(const u of Object.keys(l))d[u]=ee(l[u])(l[u],h[u],c);return d}return ee(l)(l,h,c)}),wrap:((l,h,c)=>{if(Array.isArray(l)){const p=l,g=b=>p[(Math.round(b)%p.length+p.length)%p.length];return h===void 0?g:g(h)}const d=l,f=h-d,m=p=>f===0?d:((p-d)%f+f)%f+d;return c===void 0?m:m(c)}),wrapYoyo:n(3,(l,h,c)=>{const d=h-l;if(d===0)return l;const u=((c-l)%(d*2)+d*2)%(d*2);return l+(u>d?d*2-u:u)}),snap:n(2,r),random:((l,h,c,d)=>{if(Array.isArray(l)){const f=()=>l[Math.floor(t()*l.length)];return h===!0?f:f()}const u=()=>o(l,h,c);return d?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:d="start",ease:u})=>(f,m,p)=>{const g=p.length,v=be(f,g,{...h!==void 0?{amount:h}:{each:c??1},from:d}),w=h!==void 0?h:(c??1)*fn(g,d),T=u&&w>0?u(v/w)*w:v;return l+T},pipe:(...l)=>h=>l.reduce((c,d)=>d(c),h),splitColor:l=>Qa(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=Bn(l)},resolveRandomString:l=>{const h=Os.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,d,u]=h.split(",").map(f=>Number.parseFloat(f));return o(c,d,Number.isFinite(u)?u:void 0)}}}function Ds(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 Qa(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 tl=/^([+-])=\s*(-?[\d.]+)$/,el=/^([<>])\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=tl.exec(s);if(r){const h=i(r[2]);return t.cursor+(r[1]==="-"?-h:h)}const o=el.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 nl(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 il(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),b=Math.abs(p-a.x),v=Math.abs(g-a.y);return t.axis==="x"?b:t.axis==="y"?v:Math.hypot(b,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 d=t.amount!==void 0?t.amount:(t.each??0)*c,u=t.ease?ne(t.ease):void 0,f=u?u.fn??z(u.easing):void 0;return h.map(m=>{const p=c===0?0:m/c;return(f?f(p):p)*d})}const Dn=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))Dn.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 Nn(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:nl(e)?{offsets:il(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 sl={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 Ns(e){return sl[e]}function rl(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=$s(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 ol(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function Ws(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function al(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=Ws(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 ll(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,Ys(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 Ys(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 hl(e,t){const[n,i]=ll(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function cl(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...hl(n,t)}}function ul(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 Ys(e,t){return Math.max(0,Math.min(t,e))}function fl(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function dl(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??fl(`${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 Wn(e){return Math.max(.1,e/25)}function pl(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?Wn(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 ml(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 gl(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=Bn(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new Cn({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],d={...s};for(const m of Object.keys(h))d[m]=this.resolveStart(c,m);o!==void 0&&(d.motionPath=ol(o));const u={},f=String(this.resolveStart(c,"text"));return a!==void 0&&(u.text=Yn(a),d.text=typeof a=="object"?{...a,value:f}:f),l!==void 0&&(u.text=Yn(l),d.scrambleText=typeof l=="object"?{...l,text:f}:f),this.build(t,{...h,...u},d,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,...d}=o,u=this.targetsOf(t),f=ie(s,this.context()),m=Fe(r.delay,0),p=Fe(r.duration,500),g=Nn(r.stagger,{count:u.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(u):void 0,random:this.options.random??this.fallbackRandom}),b=this.easingFor(r.ease),v=[],w=r.spring;let T=0,S=!1;for(const[P,A]of Object.entries(d)){const E=A;let I=n?.[P]!==void 0?n[P]:this.resolveStart(u[0],P);if(typeof I!=typeof E&&(this.warn(`no usable start value for "${P}" on "${u[0]}" — it will snap to ${String(E)}. Use fromTo() to animate it.`),I=E),w!==void 0&&(typeof I!="number"||typeof E!="number")&&this.warn(`spring works on numbers, so "${P}" on "${u[0]}" eases instead`),w!==void 0&&typeof I=="number"&&typeof E=="number"){const $={...ml(w),from:I,to:E,velocity:gl(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:f+m};this.timeline.addTrack(L),v.push(O),T=Math.max(T,Li($));for(const F of u)this.lastValues.set(`${F}|${P}`,E);continue}S=!0;const H=this.keyframesFor(I,E,p,b,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:f+m,keyframes:H})),v.push(R);for(const $ of u)this.lastValues.set(`${$}|${P}`,E)}const k=dl({text:l,scrambleText:h},u[0],p);if(k){const P=n?.text??n?.scrambleText,A=P!==void 0?Yn(P):this.resolveStart(u[0],"text"),E=this.nextTrackId(`${u[0]}-text`),I={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??""),...k},delay:f+m,keyframes:this.keyframesFor(0,1,p,b,r.ease)};this.timeline.addTrack(I),v.push(E);for(const H of u)this.lastValues.set(`${H}|text`,k.to)}if(a!==void 0){const{config:P,start:A,end:E}=rl(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:P,delay:f+m,keyframes:this.keyframesFor(A,E,p,b,r.ease)};this.timeline.addTrack(H),v.push(I)}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 I=pl(E,A),H=this.nextTrackId(`${u[0]}-${P}-inertia`),R={id:H,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:P,kind:"inertia",inertia:I,delay:f+m};this.timeline.addTrack(R),v.push(H),T=Math.max(T,It(I));for(const $ of u)this.lastValues.set(`${$}|${P}`,Ct(I))}const x=((c!==void 0||w!==void 0)&&!S&&!k&&a===void 0?T:Math.max(p,T))+(g&&u.length>1?zt(u.length,g):0),_=f+m+x;return this.previousStart=f+m,this.previousEnd=_,this.cursor=Math.max(this.cursor,_),{trackIds:v,start:f+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??z(s);return[o,...xn(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=Ns(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 Yn(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 yl(e){return new Tt(e)}function se(e){return ul(al(e))}const bl=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),wl="#ffffff",vl="rgba(0, 0, 0, 0.5)";function kl(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??wl})`),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??vl})`)}return t.length>0?t.join(" "):null}function Sl(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 Tl(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Ks=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"]),Ml=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),El=new Set(["originX","originY"]),Al=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),xl=new Set(["drawOn"]),Pl={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},qs={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},_l="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,f]of n)if(!(u==="x"&&a)&&!(u==="y"&&l)&&!((u==="rotate"||u==="rotateZ")&&h)&&!xl.has(u)){if(Ml.has(u)){const m=this.buildTransformPart(u,f);m&&i.push(m)}else if(El.has(u))typeof f=="number"&&((s??={})[u]=f);else if(Al.has(u))typeof f=="number"&&((r??={})[u]=f);else if(bl.has(u))(o??={})[u]=f;else if(u!=="perspective"){if(u!=="shine")if(u==="text"&&typeof f=="string")Sl(t,f);else if(u==="d"&&typeof f=="string"){const m=t;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,u,f)}}const c=n.get("shine");typeof c=="number"&&this.applyShine(t,c);const d=n.get("perspective");if(typeof d=="number"&&i.unshift(`perspective(${d}px)`),i.length>0&&(t.style.transform=i.join(" "),Tl(t)),s){const u=s.originX??50,f=s.originY??50;t.style.transformOrigin=`${u}% ${f}%`}if(r){const u=r.clipTop??0,f=r.clipRight??0,m=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${u}% ${f}% ${m}% ${p}%)`}if(o){const u=kl(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===_l&&n in qs){const a=Array.isArray(i)?i.join(", "):String(i);t.style[qs[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Pl[n]??n;let o;typeof i=="number"?Ks.has(n)||Ks.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Cl={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class Xs{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=Za();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Cl,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);Kn(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(Kn(t))return[t];if(!Il(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return Kn(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 Kn(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Il(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 Us=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Hl(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Rl(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 $l(e,t){const n=typeof e=="string"||Array.isArray(e)||Us(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=k=>{const M=Us(k)?k:t.query(k);return M||t.warn(`gsap-compat: motionPath could not find "${String(k)}"`),M};let l=null,h="";if(Array.isArray(r)||typeof r=="string"&&Rt(r))h=r;else{l=a(r);const k=l&&He({tag:l.localName,attributes:Hl(l)});l&&!k&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),h=k??""}const c={...o,path:h};if(i===void 0||i===!1)return c;const d=i===!0?l:a(i);if(!d)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[f,m,p,g,b,v]=Rl(d),w=Le(u),[T,S]=s??[.5,.5];for(const k of t.targets.slice(1)){const M=Le(k);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=[f,m,p,g,b-w.left-T*w.width,v-w.top-S*w.height],c}const Vs=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function zs(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=He({tag:e.localName,attributes:zs(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function Fl(e,t,n){const i=Ws(e);if(typeof i=="string"&&Rt(i))return i;const s=Vs(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 Ll=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Ol(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):Vs(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=He({tag:i.localName,attributes:zs(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))Ll.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const Gs=.3;class Js{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=Zs(),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=Zs(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*Gs,this.velocityY+=(o-this.velocityY)*Gs}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 Zs(){return typeof performance<"u"?performance.now():Date.now()}function Qs(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 tr(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class qn{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 Js({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=Bl(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...tr([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=Qs([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 Bl(e){return e<0?0:e>1?1:e}function Dl(e){const t=new qn(e);return t.start(),t}const Nl={x:"x",y:"y","x,y":"both"},Xn=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function er(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 nr(e){return Array.isArray(e)?[...e]:e}function Wl(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 Yl(e,t,s,r,i);const o=Nl[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):Xn(i.bounds)?i.bounds:null,c={bounds:(!l&&i.bounds&&!Xn(i.bounds)?i.bounds:void 0)??(l?er(r,l):void 0)};let d=null;const u=()=>{d?.kill(),d=null},f=p=>{const g=i.inertia===!0?{}:i.inertia,b=g.friction??(g.resistance!==void 0?Wn(g.resistance):4),v=a(),w=c.bounds??{};let T,S;const k=g.end;if(Array.isArray(k)){const C=Gt({from:v.x,velocity:o==="y"?0:p.x,friction:b}),x=Gt({from:v.y,velocity:o==="x"?0:p.y,friction:b});let _=k[0];for(const P of k)Math.hypot(P.x-C,P.y-x)<Math.hypot(_.x-C,_.y-x)&&(_=P);_&&(T=[_.x],S=[_.y])}else typeof k=="number"?(T=k,S=k):k&&(T=nr(k.x),S=nr(k.y));const M={};o!=="y"&&(M.x={velocity:p.x,friction:b,min:w.minX,max:w.maxX,end:T}),o!=="x"&&(M.y={velocity:p.y,friction:b,min:w.minY,max:w.maxY,end:S}),d=e.to(r,{inertia:M,onComplete:()=>i.onThrowComplete?.()})},m=new qn({target:r,axis:o,snap:i.snap,get bounds(){return c.bounds},getPosition:a,onPress:()=>{u(),l&&(c.bounds=er(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&&f(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 Yl(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!Xn(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,d={x:0,y:0},u=0,f=0,m=[];const p=w=>Math.atan2(w.clientY-d.y,w.clientX-d.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();d={x:T.left+T.width/2,y:T.top+T.height/2},u=p(w),f=o(),m=[{time:performance.now(),rotation:f}],s.onPress?.()},b=w=>{if(!h||w.pointerId!==c)return;const T=p(w);let S=T-u;S>180&&(S-=360),S<-180&&(S+=360),u=T,f+=S;let k=a(f);s.snap&&(k=a(Math.round(k/s.snap)*s.snap)),t.apply(n,{rotate:k});const M=performance.now();for(m.push({time:M,rotation:k});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],S=m[m.length-1],k=T&&S?(S.time-T.time)/1e3:0,M=k>0?(S.rotation-T.rotation)/k: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?Wn(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",b),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",b),i.removeEventListener("pointerup",v),i.removeEventListener("pointercancel",v)}}}const Kl={opacity:0,scale:.6};function ql(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 ir(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 Un(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=ql(o);s.set(o,a);const l=sr(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const Vn=new WeakMap;function zn(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?Kl:i.enter,h=new Set(n.elements);if(i.targets!==void 0)for(const f of e.resolveTargets(i.targets)){const m=e.elementFor(f);m&&h.add(m)}const c=[...h].sort((f,m)=>f===m?0:f.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),d=t({onComplete:i.onComplete});let u=0;for(const f of c){const m=ir(f);if(!m)continue;let p=n.boxes.get(f)??null,g;const b=sr(f),v=!p&&b!==void 0?n.ids.get(b):void 0;v&&v.element!==f&&(p=v.box,g=v.element);const[w]=e.resolveTargets(f);Vn.get(f)?.timeline.removeTracks({target:w});const T=u*o;if(!p){if(l===!1)continue;d.fromTo(f,{x:0,y:0,scaleX:1,scaleY:1,...l},{...rr(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:T},0),Vn.set(f,d),u++;continue}const S=p.cx-m.cx,k=p.cy-m.cy,M=a?p.width/m.width:1,C=a?p.height/m.height:1;if(!(Math.abs(S)>.5||Math.abs(k)>.5||Math.abs(M-1)>.001||Math.abs(C-1)>.001)){const P=(A,E)=>{const I=e.appliedValue(w,A);return typeof I=="number"&&Math.abs(I-E)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&d.set(f,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const _=i.fade===!0&&g!==void 0;d.fromTo(f,{x:S,y:k,scaleX:M,scaleY:C,..._&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,..._&&{opacity:1},duration:s,ease:r,delay:T},0),_&&g&&ir(g)&&d.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:T},0),Vn.set(f,d),u++}return d}function sr(e){return e.dataset?.flipId}function rr(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function Xl(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:b}of r)p.innerHTML=g,b===null?p.removeAttribute("aria-label"):p.setAttribute("aria-label",b)},d=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},u=()=>{const p={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const b=(g.textContent??"").replace(/\s+/g," ").trim(),v=Ul(g,i.words),w=n.has("chars")?v.flatMap(k=>Vl(k,i.chars)):[],T=n.has("lines")?jl(g,v,i.lines):[];if(s){!g.hasAttribute("aria-label")&&b&&g.setAttribute("aria-label",b);for(const k of v)k.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...v);else for(const k of v)k.removeAttribute("class");p.chars.push(...w),p.lines.push(...T);const S=t.mask==="lines"?T:t.mask==="words"?v:t.mask==="chars"?w:[];for(const k of S)p.masks.push(Gl(k,`${i[t.mask]}-mask`))}o=p},f={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){h||(d(),c(),u(),a=t.onSplit?.(f))},revert(){h=!0,l?.disconnect(),d(),c()}};u(),a=t.onSplit?.(f),t.autoSplit&&m();function m(){const p=new Map;let g=!1;const b=()=>{if(g)return;g=!0;const w=()=>{g=!1,f.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(w):setTimeout(w,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(w=>{let T=!1;for(const S of w){const k=Math.round(S.contentRect.width),M=p.get(S.target);p.set(S.target,k),M!==void 0&&M!==k&&(T=!0)}T&&b()});for(const w of e)l.observe(w)}const v=e[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>b())}return f}function Ul(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 Vl(e,t){const n=e.ownerDocument,i=zl(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 zl(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function jl(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,d=!1,u=[];const f=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),u=[]};for(const m of r){if(m.tagName==="BR"){d=!0;continue}const p=s.get(m);if(p&&(!l||d||p.top>h+c)&&(f(),h=p.top,c=p.height/2,d=!1),!l)continue;const g=[];for(let w=m.parentNode;w&&w!==e;w=w.parentNode)g.unshift(w);let b=0;for(;b<u.length&&b<g.length&&u[b].original===g[b];)b++;u.length=b;let v=b===0?l:u[b-1].clone;for(const w of g.slice(b)){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 Gl(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 or={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 or)return or[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Gn(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=Gn(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 Jl(e,t,n,i){const s=Ot(e,t,n),o=Ot(e,t,i)-s;return o<=0?s<=0?1:0:Jn(-s/o)}function Jn(e){return e<0?0:e>1?1:e===0?0:e}function ar(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function Zn(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 d=(l+h)/2;Math.sign(r(d))===Math.sign(o)?l=d:h=d}return(l+h)/2}class lr{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 Zl(e){const t=new lr(e);return t.start(),t}class hr{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 Ql=.15;function cr(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function ur(e,t,n){const i=Oe(e+t*Ql);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 fr(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 dr{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 pr{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,d)=>{const u=t.createElement("div");return u.textContent=`${a}${h}`,u.setAttribute("aria-hidden","true"),u.className="scroll-marker",Object.assign(u.style,{position:d?"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 th=120,Bt=[],Dt=new Set;let Qn=!1;const eh=()=>{Qn||Dt.size===0||(Qn=!0,queueMicrotask(()=>{Qn=!1;for(const e of Dt)e.afterRefresh()}))},mr=()=>{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 gr=()=>{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},mr())};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 dr(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 hr(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new pr(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",gr,{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",gr),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(){mr()}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,eh()}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?Jn((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()},th))}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=cr(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+ur(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,fr(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=f=>a+f*(l-a),c=Zn(o,i.width,r,oe(this.options.start)??"left right",t.shiftAt);this.startPx=h(c);const d=oe(this.options.end)??"right left",u=typeof d=="string"?d.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=u?this.startPx+Number.parseFloat(u[1]):h(Zn(o,i.width,r,d,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=Gn(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=ar(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 nh(e){const t=new re(e);return t.start(),t}const ti=new Set,ih=16,yr=.5,sh=2;class ei{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),ti.add(this),this.stopListening=re.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of ti)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),ti.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)ni(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)ni(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?ih: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)<=sh||(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)<yr&&(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)<yr?s.lagged=i:n=!0,r+=i-s.lagged}ni(s.element,r===0?s.saved:`0 ${rh(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 ni(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function rh(e){return Math.round(e*100)/100}function oh(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 ii(e,t,n,i,s=()=>{}){const r=f=>typeof f=="string"?e.query(f)??void 0:f,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 d=(f,m)=>()=>{m?.(),n&&!a&&oh(n,l[f]??"none"),t.once&&f===0&&queueMicrotask(()=>c.destroy())},u=t.containerAnimation?hh(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:ah(t.snap,n),markers:t.markers,container:u,onUpdate:(f,m)=>{if(n&&a!==!1&&n.progress(f),t.onUpdate){const p=f<h||m<0?-1:1;t.onUpdate({progress:f,velocity:m,direction:p})}h=f},onEnter:d(0,t.onEnter),onLeave:d(1,t.onLeave),onEnterBack:d(2,t.onEnterBack),onLeaveBack:d(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),c.start(),e.own(c)}function ah(e,t){const n=s=>s==="labels"?r=>lh(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??z(i.easing):void 0}}function lh(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function hh(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 br{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 ch{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 br(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class uh{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 fh={opacity:0,y:-16},dh={opacity:0,y:16};async function ph(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",h=g=>new Promise(b=>{g(b)||b()}),c=o(),d=c.length?Un(t,c):void 0,u=i.from!==void 0?wr(t,i.from,i.shared):[];if(u.length&&i.leave!==!1){const g=i.leave??fh;await h(b=>e.to(u,{...g,duration:a,ease:l,onComplete:b}))}await i.update();const f=[],m=typeof i.to=="function"?i.to():i.to,p=m!==void 0?wr(t,m,i.shared):[];if(p.length&&i.enter!==!1){const g=i.enter??dh;f.push(h(b=>e.fromTo(p,g,{...rr(g),duration:a,ease:l,onComplete:b})))}if(d){const g=o().filter(b=>!c.includes(b));g.length&&f.push(h(b=>zn(t,n,d,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:b})))}await Promise.all(f)}function wr(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 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 vr={create:(e,t)=>On(e,Cs(t))},kr={create:(e,t)=>On(e,{fn:Is(t)})},Sr={create:(e,t)=>On(e,{fn:Hs(t)})},gh=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Tr=.5,yh="power1.inOut";function bh(e){return e.keyframes!==void 0&&e.keyframes!==null}function wh(e){const t=e.keyframes,n={};for(const[h,c]of Object.entries(e))gh.has(h)||(n[h]=c);if(Array.isArray(t))return t.map(h=>({...n,...h,duration:h.duration??e.duration??Tr}));const i=Object.entries(t),s=e.duration??Tr,r=t.easeEach??e.easeEach??yh;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,f])=>({at:Number.parseFloat(u)/100,step:f})).sort((u,f)=>u.at-f.at),c=[];let d=0;for(const{at:u,step:f}of h){const m=Math.max(0,u-d);c.push({...n,ease:r,...f,duration:m*s}),d=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[d,u]of o)h<u.length&&(c[d]=u[h]);l.push(c)}return l}function Mr(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 S=T.getBoundingClientRect(),k=r?.getBoundingClientRect(),M=(v==="x"?i.offsetX:i.offsetY)??i.offset??0;return v==="x"?S.left-(k?.left??0)+o.x-M:S.top-(k?.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))},d={...o},u=()=>{r?(r.scrollLeft=d.x,r.scrollTop=d.y):window.scrollTo({left:d.x,top:d.y,behavior:"instant"})},f=["wheel","touchstart","keydown"],m=r??window,p=()=>{b.kill(),g()},g=()=>{for(const v of f)m.removeEventListener(v,p)},b=e.to(d,{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 f)m.addEventListener(v,p,{passive:!0});return b}function vh(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,...d}=n,u={onEnter:a,onLeave:l,onEnterBack:h,onLeaveBack:c},f={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},p=b=>{m[b]!==void 0&&clearTimeout(m[b]),m[b]=void 0;const v=f[b].splice(0);v.length>0&&u[b]?.(v)},g=(b,v)=>{if(u[b]){if(f[b].push(v),o!==void 0&&f[b].length>=o)return p(b);m[b]===void 0&&(m[b]=setTimeout(()=>p(b),r*1e3))}};return s.map(b=>ii(e,{...d,trigger:b,onEnter:()=>g("onEnter",b),onLeave:()=>g("onLeave",b),onEnterBack:()=>g("onEnterBack",b),onLeaveBack:()=>g("onLeaveBack",b)})).filter(b=>b!==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 Th(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=_r(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>Pr(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=ii(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 bh(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}=In(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 d=(u,f,m)=>{s(u,f,m),h=Math.min(h,this.compat.lastStart),c=Math.max(c,this.compat.lastEnd)};if(this.buildTween(r,n,i,d),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=wh(n);if(r.length===0)return;const o=s.length>1?Nn(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 d=1/0,u=-1/0;if(l.forEach((g,b)=>{r.forEach((v,w)=>{const T=w===0?c+h[b]:">";this.tween(g,[v],T,([S],k,M)=>this.compat.to(k,S,M)),d=Math.min(d,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),d===1/0)return;const{onStart:f,onUpdate:m,onComplete:p}=n;f&&this.events.push({time:d,direction:"forward",run:f}),m&&this.ranges.push({start:d,end:u,run:m}),p&&this.events.push({time:u,direction:"forward",run:p})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>Pr(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(Sh)||t.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(t[0]);s(n.map(f=>this.prepare(xr(f,0,u,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...h}=n[a],c=Nn(l,this.staggerContext(t)),d=c?we(t.length,c).map(u=>u/1e3):t.map(()=>0);t.forEach((u,f)=>{const m=f===0?Fe(h.delay,0)/1e3+d[0]:0,p=f===0?0:d[f]-d[f-1],g=f===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,v=n.map((w,T)=>T===a?{...h,delay:m}:w).map(w=>this.prepare(xr(w,f,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=$l(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=Fl(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=_r(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=cl(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 ${Mh(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function Er(e=new Xs){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:d,...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)??Ns(o)},scrollTrigger:r=>i(ii(e,r)),scrollBatch:(r,o)=>vh(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Mr(s,e,r,o),refreshScroll:()=>{re.refreshAll(),ei.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new ei({...r,scroller:o}).start())},context:(r,o)=>{const a=new br(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new ch(e,r),customEase:vr.create,customBounce:kr.create,customWiggle:Sr.create,pageTransition:r=>ph(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 uh(a,o))},quickTo:(r,o,a={})=>{const l=new at(e,{paused:!0}),[h]=e.resolveTargets(r);return Object.assign(d=>{if(!h)return;const u=a.spring!==void 0?e.velocityOf(h,o)??0:0;l.compat.reset(),l.compat.to(h,{[o]:d,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:kh(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 Mr(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=>Ol(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(Xl(l,o))},draggable:(r,o)=>i(Wl(s,e,r,o)),getFlipState:r=>Un(e,r),flipFrom:(r,o)=>zn(e,a=>new at(e,a),r,o),flip:(r,o,a)=>{const l=Un(e,r);return o(),zn(e,h=>new at(e,h),l,{targets:r,...a})}};return s}const j=Er();function kh(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Sh(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Ar(e)}function Ar(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||Bs(n))&&!Dn.has(t))}function xr(e,t,n,i,s){if(!Ar(e))return e;const r={};for(const[o,a]of Object.entries(e))Dn.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):Bs(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function Pr(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 _r(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Th(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Mh(e){return typeof e=="string"?`"${e}"`:String(e)}class si{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 Cr(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 si(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Cr(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 si(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}=In(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 Eh(e,t,n={}){const i=new Be(e,{...n,autoplay:!0});return await i.load(t),i}function Ah(e,t={}){return new Be(e,t)}const Ir={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"},Hr="tinyfly-controls-style",xh=`
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 El=0;function Pl(e){if(e.getElementById(Gs))return;const t=e.createElement("style");t.id=Gs,t.textContent=Al,e.head.appendChild(t)}function Ks(e,t,n={}){const i=t.ownerDocument;Pl(i);const s={...zs,...n.labels},r=n.speeds??[.5,1,2],o=()=>e.markers.length>0,a=()=>e.markers.some(P=>P.label!==void 0||e.caption(P.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=(P,R,$,B="")=>{const N=i.createElement("button");return N.type="button",N.className=`tf-ctl-btn ${B}`.trim(),N.setAttribute("aria-label",P),N.title=P,N.textContent=R,N.addEventListener("click",$),N},d=h(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),u=h(s.prev,"|◀",()=>e.prev()),f=h(s.play,"▶",()=>e.isPlaying?e.pause():m(),"tf-ctl-primary"),p=h(s.next,"▶|",()=>e.next()),m=()=>{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 P of r){const R=i.createElement("option");R.value=String(P),R.textContent=`${P}×`,P===1&&(R.selected=!0),v.appendChild(R)}v.addEventListener("change",()=>e.setSpeed(Number(v.value))),c.append(d,u,f,p,g,y),r.length>0&&c.append(v),l.append(c);const w=n.fullscreen?Rl(t,i,s):void 0;w&&c.append(w.button);const k=i.createElement("p");k.className="tf-ctl-caption",k.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(k);const T=i.createElement("div");T.className="tf-ctl-question",T.hidden=!0;const M=i.createElement("span"),x=h(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");T.append(M,x),l.append(T);const C=_l(e,i,s.scenario,n.scenarioControl??"buttons");C&&l.append(C.element);const L=n.mount;L?L.appendChild(l):t.insertAdjacentElement("afterend",l);const I=()=>{const P=e.isPlaying;f.textContent=P?"❚❚":"▶",f.setAttribute("aria-label",P?s.pause:s.play),f.title=P?s.pause:s.play;const R=e.duration;i.activeElement!==g&&(g.value=String(R>0?Math.round(e.currentTime/R*1e3):0));const $=e.markers;if(u.hidden=p.hidden=y.hidden=$.length===0,$.length>0){const B=e.currentMarker,N=B?$.indexOf(B)+1:0;y.textContent=s.stepFormat.replace("{index}",String(N)).replace("{total}",String($.length)),y.setAttribute("aria-label",`${s.step} ${N} ${s.of} ${$.length}`),u.disabled=e.currentTime<=.5,p.disabled=e.currentTime>=R-.5;const F=e.caption()??"";k.textContent!==F&&(k.textContent=F),k.hidden=!a();const D=!P&&B?.question!==void 0&&Math.abs(e.currentTime-B.time)<1;T.hidden=!D,D&&M.textContent!==B.question&&(M.textContent=B.question)}else T.hidden=!0,k.hidden=!0;C?.update()},A=e.subscribe(I);I();const E=n.keyboardScope??t;!E.hasAttribute("tabindex")&&E.tabIndex<0&&(E.tabIndex=0);const S=new WeakSet,_=P=>{if(S.has(P)||(S.add(P),P.defaultPrevented||P.altKey||P.ctrlKey||P.metaKey))return;const R=P.target;if(!(R.tagName==="INPUT"||R.tagName==="SELECT")&&!(P.key===" "&&R.tagName==="BUTTON"))switch(P.key){case" ":P.preventDefault(),e.isPlaying?e.pause():m();break;case"ArrowRight":if(!o())return;P.preventDefault(),e.next();break;case"ArrowLeft":if(!o())return;P.preventDefault(),e.prev();break;case"Home":P.preventDefault(),e.pause(),e.seek(0);break;case"f":case"F":if(!w)return;P.preventDefault(),w.active?w.exit():w.enter();break}};return E.addEventListener("keydown",_),l.addEventListener("keydown",_),{element:l,fullscreen:w&&{get active(){return w.active},enter:w.enter,exit:w.exit},destroy(){w?.destroy(),A(),E.removeEventListener("keydown",_),l.removeEventListener("keydown",_),l.remove()}}}function _l(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 d=t.createElement("span");d.textContent=n,d.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 f=t.createElement("output");return f.setAttribute("aria-hidden","true"),u.addEventListener("input",()=>{const m=s[Number(u.value)];m&&e.setScenario(m.id)}),h.append(d,u,f),{element:h,update:()=>{const m=Math.max(0,s.findIndex(y=>y.id===e.scenario));t.activeElement!==u&&(u.value=String(m));const g=s[m].label;f.textContent!==g&&(f.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-${++El}`,l=s.map(h=>{const d=t.createElement("label");d.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 f=t.createElement("span");return f.textContent=h.label,d.append(u,f),r.append(d),u});return{element:r,update:()=>{for(const h of l){const d=h.value===e.scenario;h.checked!==d&&(h.checked=d)}}}}const Cl='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Il='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function Rl(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 m=o!==void 0;r.innerHTML=m?Il:Cl;const g=m?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(m)),e.classList.toggle("tf-fullscreen",m),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()},d=m=>{m.key==="Escape"&&p()},u=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",d),l()};async function f(){if(o)return;const m=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(m&&g)try{if(await m(),c()===e){o="native",l();return}}catch{}u()}async function p(){if(o==="overlay")t.removeEventListener("keydown",d),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const m=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===e&&m&&await m()}}return r.addEventListener("click",()=>{o?p():f()}),t.addEventListener("fullscreenchange",h),t.addEventListener("webkitfullscreenchange",h),l(),{button:r,get active(){return o!==void 0},enter:f,exit:p,destroy(){p(),t.removeEventListener("fullscreenchange",h),t.removeEventListener("webkitfullscreenchange",h),r.remove()}}}const Js="tinyfly-choices-style",Ll=`
50
+ `;let Ph=0;function _h(e){if(e.getElementById(Hr))return;const t=e.createElement("style");t.id=Hr,t.textContent=xh,e.head.appendChild(t)}function Rr(e,t,n={}){const i=t.ownerDocument;_h(i);const s={...Ir,...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 h=i.createElement("div");h.className="tf-ctl-bar",h.setAttribute("role","group");const c=(H,R,$,O="")=>{const L=i.createElement("button");return L.type="button",L.className=`tf-ctl-btn ${O}`.trim(),L.setAttribute("aria-label",H),L.title=H,L.textContent=R,L.addEventListener("click",$),L},d=c(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),u=c(s.prev,"|◀",()=>e.prev()),f=c(s.play,"▶",()=>e.isPlaying?e.pause():p(),"tf-ctl-primary"),m=c(s.next,"▶|",()=>e.next()),p=()=>{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 b=i.createElement("span");b.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 R=i.createElement("option");R.value=String(H),R.textContent=`${H}×`,H===1&&(R.selected=!0),v.appendChild(R)}v.addEventListener("change",()=>e.setSpeed(Number(v.value))),h.append(d,u,f,m,g,b),r.length>0&&h.append(v),l.append(h);const w=n.fullscreen?Rh(t,i,s):void 0;w&&h.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 S=i.createElement("div");S.className="tf-ctl-question",S.hidden=!0;const k=i.createElement("span"),M=c(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");S.append(k,M),l.append(S);const C=Ch(e,i,s.scenario,n.scenarioControl??"buttons");C&&l.append(C.element);const x=n.mount;x?x.appendChild(l):t.insertAdjacentElement("afterend",l);const _=()=>{const H=e.isPlaying;f.textContent=H?"❚❚":"▶",f.setAttribute("aria-label",H?s.pause:s.play),f.title=H?s.pause:s.play;const R=e.duration;i.activeElement!==g&&(g.value=String(R>0?Math.round(e.currentTime/R*1e3):0));const $=e.markers;if(u.hidden=m.hidden=b.hidden=$.length===0,$.length>0){const O=e.currentMarker,L=O?$.indexOf(O)+1:0;b.textContent=s.stepFormat.replace("{index}",String(L)).replace("{total}",String($.length)),b.setAttribute("aria-label",`${s.step} ${L} ${s.of} ${$.length}`),u.disabled=e.currentTime<=.5,m.disabled=e.currentTime>=R-.5;const F=e.caption()??"";T.textContent!==F&&(T.textContent=F),T.hidden=!a();const B=!H&&O?.question!==void 0&&Math.abs(e.currentTime-O.time)<1;S.hidden=!B,B&&k.textContent!==O.question&&(k.textContent=O.question)}else S.hidden=!0,T.hidden=!0;C?.update()},P=e.subscribe(_);_();const A=n.keyboardScope??t;!A.hasAttribute("tabindex")&&A.tabIndex<0&&(A.tabIndex=0);const E=new WeakSet,I=H=>{if(E.has(H)||(E.add(H),H.defaultPrevented||H.altKey||H.ctrlKey||H.metaKey))return;const R=H.target;if(!(R.tagName==="INPUT"||R.tagName==="SELECT")&&!(H.key===" "&&R.tagName==="BUTTON"))switch(H.key){case" ":H.preventDefault(),e.isPlaying?e.pause():p();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 A.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(),P(),A.removeEventListener("keydown",I),l.removeEventListener("keydown",I),l.remove()}}}function Ch(e,t,n,i){const s=e.scenarios;if(s.length<2)return;if(i==="slider"){const c=t.createElement("div");c.className="tf-ctl-choice-slider";const d=t.createElement("span");d.textContent=n,d.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 f=t.createElement("output");return f.setAttribute("aria-hidden","true"),u.addEventListener("input",()=>{const p=s[Number(u.value)];p&&e.setScenario(p.id)}),c.append(d,u,f),{element:c,update:()=>{const p=Math.max(0,s.findIndex(b=>b.id===e.scenario));t.activeElement!==u&&(u.value=String(p));const g=s[p].label;f.textContent!==g&&(f.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-${++Ph}`,l=s.map(c=>{const d=t.createElement("label");d.className="tf-ctl-choice";const u=t.createElement("input");u.type="radio",u.name=a,u.value=c.id,u.addEventListener("change",()=>{u.checked&&e.setScenario(c.id)});const f=t.createElement("span");return f.textContent=c.label,d.append(u,f),r.append(d),u});return{element:r,update:()=>{for(const c of l){const d=c.value===e.scenario;c.checked!==d&&(c.checked=d)}}}}const Ih='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Hh='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function Rh(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 p=o!==void 0;r.innerHTML=p?Hh:Ih;const g=p?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(p)),e.classList.toggle("tf-fullscreen",p),e.classList.toggle("tf-fullscreen-overlay",o==="overlay")},h=()=>i.fullscreenElement??i.webkitFullscreenElement??null,c=()=>{h()===e?o="native":o==="native"&&(o=void 0),l()},d=p=>{p.key==="Escape"&&m()},u=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",d),l()};async function f(){if(o)return;const p=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(p&&g)try{if(await p(),h()===e){o="native",l();return}}catch{}u()}async function m(){if(o==="overlay")t.removeEventListener("keydown",d),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const p=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);h()===e&&p&&await p()}}return r.addEventListener("click",()=>{o?m():f()}),t.addEventListener("fullscreenchange",c),t.addEventListener("webkitfullscreenchange",c),l(),{button:r,get active(){return o!==void 0},enter:f,exit:m,destroy(){m(),t.removeEventListener("fullscreenchange",c),t.removeEventListener("webkitfullscreenchange",c),r.remove()}}}const $r="tinyfly-choices-style",$h=`
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 $l(e){if(e.getElementById(Js))return;const t=e.createElement("style");t.id=Js,t.textContent=Ll,e.head.appendChild(t)}function Qs(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};$l(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(p,m)=>{a.hasAttribute(p)||(a.setAttribute(p,m),c.push(p))};h("role","button"),h("tabindex","0");const d=e.scenarios.find(p=>p.id===l)?.label;d!==void 0&&h("aria-label",d),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const u=()=>e.setScenario(l),f=p=>{const m=p.key;m!=="Enter"&&m!==" "||(p.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",f),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",f)})}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 Te=new WeakMap,Pn=new WeakMap;let Fl=0;function Gt(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function Zs(e,t={}){const n=Te.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=Dl(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Ol(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?Gt(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const f=await fetch(r);f.ok&&(l=await f.json())}if(l&&o&&(l=tr(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=Gt(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...Gt(e.getAttribute("data-options"),"data-options",e)};Nl(e);const d=new ve(e,h),u={element:e,player:d};if(Te.set(e,u),e.setAttribute("data-tinyfly-mounted",""),a){const f=e.getAttribute("data-scenario")??void 0;await d.loadScenarios(a,{initial:a.some(p=>p.id===f)?f:void 0}),Pn.set(e,Qs(d,e))}else await d.load(l??r);if(e.getAttribute("data-controls")!=="false"){const f=Gt(e.getAttribute("data-labels"),"data-labels",e),p=e.querySelector("figcaption"),m=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");u.controls=Ks(d,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...f,...m?{scenario:m}:{}},mount:void 0}),p?e.insertBefore(u.controls.element,p):e.appendChild(u.controls.element)}return u}function Ol(e,t,n){const i=[];return e.forEach((s,r)=>{const o=Gt(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?tr(o,t):o})}),i}function tr(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function Dl(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 er(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>Zs(s,t)))).filter(s=>s!==void 0)}function Bl(e){const t=Te.get(e);t&&(Pn.get(e)?.(),Pn.delete(e),t.controls?.destroy(),t.player.destroy(),Te.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Nl(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-${++Fl}`,t.setAttribute("aria-labelledby",i.id))}function Yl(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{er()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class nr{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 c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:At(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?At(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 Wl(e,t,n={}){const i=new nr(e,{...n,autoplay:!0});return await i.load(t),i}const ql={type:"none",duration:0};function ir(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 It(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=ir(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 _n(e,t){const n=It(e,t);return n[n.length-1]}function Cn(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function ke(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Cn(n,t.boil??8);let o=0;const a=()=>{const u=o++;return f=>de(nn(`${t.seed??1}:${r}:${u}:${f}`))},l=(u,f)=>(u.next()*2-1)*f,c=u=>{const f=a(),p=e.lineWidth,m=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?p:p*.55,e.globalAlpha=g===0?m:m*.6,u(f(g));e.lineWidth=p,e.globalAlpha=m},h=(u,f=1)=>{if(u.length<2)return;const p=u.slice(1).map((g,y)=>Math.hypot(g.x-u[y].x,g.y-u[y].y)),m=p.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,f));c(g=>{const y=[],v=[];if(u.forEach((k,T)=>{y.push({x:k.x+l(g,i*.5),y:k.y+l(g,i*.5)}),T>0&&v.push([g.next()*2-1,g.next()*2-1])}),m<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let w=0;for(let k=1;k<y.length;k++){const T=Xl(y[k-1],y[k],i,v[k-1]),M=p[k-1];if(w+M<=m){e.bezierCurveTo(T[1].x,T[1].y,T[2].x,T[2].y,T[3].x,T[3].y),w+=M;continue}const x=Hl(T,M===0?1:(m-w)/M);e.bezierCurveTo(x[1].x,x[1].y,x[2].x,x[2].y,x[3].x,x[3].y);break}e.stroke()})},d=(u,f,p,m,g=1)=>{c(y=>{const w=y.next()*Math.PI*2,k=Math.PI*2+.15+y.next()*.3,T=[];for(let x=0;x<=14;x++){const C=w+k*x/14,L=l(y,i*.6);T.push({x:u+Math.cos(C)*(p+L),y:f+Math.sin(C)*(m+L)})}const M=It(T,g);M.length<2||(sr(e,M),e.stroke())})};return{line:h,curve(u,f=1){if(u.length<2)return;const p=u[0],m=u[u.length-1],g=Math.hypot(m.x-p.x,m.y-p.y)||1,y=-(m.y-p.y)/g,v=(m.x-p.x)/g;c(w=>{const k={x:l(w,i*.5),y:l(w,i*.5)},T={x:l(w,i*.5),y:l(w,i*.5)},M=l(w,i*Math.min(1.5,Math.max(.3,g/80))),x=u.map((L,I)=>{const A=I/(u.length-1),E=Math.sin(Math.PI*A)*M;return{x:L.x+k.x+(T.x-k.x)*A+y*E,y:L.y+k.y+(T.y-k.y)*A+v*E}}),C=It(x,f);C.length<2||(sr(e,C),e.stroke())})},circle(u,f,p,m=1){d(u,f,p,p,m)},ellipse:d,nudge(u=.5){const f=a()(0);return{x:l(f,i*u),y:l(f,i*u)}}}}function Xl(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 Hl([e,t,n,i],s){const r=(d,u)=>({x:d.x+(u.x-d.x)*s,y:d.y+(u.y-d.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 sr(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 Kt(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)],d=Math.hypot(h.x-c.x,h.y-c.y)||1,u=o(l)/2,f=-(h.y-c.y)/d*u,p=(h.x-c.x)/d*u;s.push({x:a.x+f,y:a.y+p}),r.push({x:a.x-f,y:a.y-p})}),[...s,...r.reverse()]}function In(e,t,n,i){const s=t.length;if(s<2)return;const r=Kt(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 gt(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,d={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+(d.x-c.x)*i,y:c.y+(d.y-c.y)*i})}return o}const yt={lean:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee: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};function X(e){return{...yt,...e}}const rr={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},W=e=>({...rr,...e}),Z={neutral:rr,happy:W({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:W({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:W({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:W({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:W({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:W({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:W({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:W({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:W({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:W({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:W({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:W({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:W({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:W({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:W({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:W({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:W({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function or(e,t){return{...e,...typeof t=="string"?Z[t]:t}}const ar={rest:yt,wave:X({rightShoulder:135,rightElbow:30,headTilt:6,...Z.happy}),cheer:X({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...Z.joyful}),shrug:X({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...Z.confused,lookX:0,lookY:0}),point:X({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:X({rightShoulder:60,rightElbow:150,headTilt:10,...Z.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,...Z.sad}),surprised:X({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...Z.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,...Z.joyful})},lr=Object.keys(yt);function cr(e,t,n){const i={...e};for(const s of lr)i[s]=e[s]+(t[s]-e[s])*n;return i}const Rn=24,hr=4,ur=28,Vl=40;function fr(e,t=yt,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=Vl,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-ur*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+ur*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+hr*n,headTilt:t.headTilt-hr*.5*n,leftElbow:a,rightElbow:l,leftHip:-Rn*i,rightHip:-Rn*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function Ul(e,t=1){return 4*((Ln+Me)*e)*Math.sin(Rn*t*Math.PI/180)}function dr(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const pr=.12,mr=.46,jl=1-2*pr,zl=.1,Gl=.21,Kl=.19,Ln=.24,Me=.22,gr=.12,Jl=.14,yr=.33,br=.7,wr=.3,Ql=.35,Zl=[1.7,1.05],tc=[1.3,.75],vr=[1.45,.85],ec=[1.15,.75],Tr=.06,nc=.7,ic=.65,sc=.3,rc=.02,oc=.012,ac=12,lc=.25,Se=90,cc=.25,hc=.01,Rt=e=>Math.min(1,Math.max(0,e??0));function uc(e,t=1){return Me*e*t}const $n=-.12,kr=.4,nt=e=>e*Math.PI/180,fc=(e,t)=>({x:t*Math.sin(nt(e)),y:Math.cos(nt(e))}),Mr=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Sr=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function dc(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Jl*n)),a=Rt(t.turn),l=(gr+yr*a)*n,c=i+$n*n,h=l+t.lookX*.08*n,d=t.lookY*.07*n,u=[{x:-.34*n*(1-br*a),squeeze:1-br*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-wr*a),squeeze:1-wr*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=Mr(y.open,t.blink);if(v<.2){const M=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+M,y.x+l+.12*n,c),e.stroke()}else{if(v>1.2){const x=.13*n*v;e.beginPath(),e.ellipse(y.x+l,c,x*.85,x,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const M=v>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+d,M,M*1.1*Math.min(v,1),0,0,Math.PI*2),e.fill()}const w=Sr(c,n,y.brow,v),k=y.x+l-y.side*.13*n*y.squeeze,T=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(T,w),e.lineTo(k,w-t.browTilt*.1*n),e.stroke()}const f=i+kr*n,p=.25*n*Math.max(.3,t.mouthWidth)*(1-Ql*a),m=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),m<=.05){e.moveTo(l-p,f),e.quadraticCurveTo(l,f+t.smile*.25*n,l+p,f),e.stroke();return}const g=.3*n*m;t.smile>.3?(e.moveTo(l-p,f-.05*n),e.lineTo(l+p,f-.05*n),e.quadraticCurveTo(l,f+g*2,l-p,f-.05*n)):t.smile<-.3?(e.moveTo(l-p,f+g*.6),e.lineTo(l+p,f+g*.6),e.quadraticCurveTo(l,f-g*1.4,l-p,f+g*.6)):e.ellipse(l,f,p*.8,g,0,0,Math.PI*2),e.fill()}function xr(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*pr)/2,o=t.headSize===void 0?jl:1-2*r,a=r*n,l=Rt(e.sit),c=e.leftHip+(-Se-e.leftHip)*l,h=e.leftKnee+(-Se-e.leftKnee)*l,d=e.rightHip+(Se-e.rightHip)*l,u=e.rightKnee+(Se-e.rightKnee)*l,f=t.classic===!0,p=Rt(e.turn),m=(E,S,_)=>{const P=nt(S-_)/2,R=p+(1-p)*E*nc;return f?{x:0,y:0}:{x:Math.cos(P)*Tr*R,y:Math.abs(Math.sin(P))*Tr}};let g=0;if(l>0||!f){const E=(P,R,$)=>Ln*Math.cos(nt(R))+Me*Math.cos(nt(R-$))+m(P,R,$).y,S=Math.max(E(-1,c,h),E(1,d,u)),_=f?Math.min(1,l/cc):1;g=(mr-S)*_*n*i}const y=-mr*n*i+g,v=-o*n*i+g,w=f?0:(rc*Rt(e.turn)+oc*l)*n*i,k=w===0?[{x:0,y},{x:0,y:v}]:gt({x:0,y},{x:-w,y:(y+v)/2},{x:0,y:v},1,8),T=v+zl*n*i,M=(t.shoulderWidth??0)*n*Math.cos(p*Math.PI/2),x=(E,S,_,P,R)=>{const $=fc(_,P);return{x:E+$.x*R*n,y:S+$.y*R*n}},C=(E,S,_)=>{const P=x(0,y,S,E,Ln*i);return{root:{x:0,y},joint:P,end:x(P.x,P.y,S-_,E,Me*i)}},L=(E,S,_)=>{const P={x:E*M,y:T},R=x(P.x,P.y,S,E,Gl*s);return{root:P,joint:R,end:x(R.x,R.y,S+_,E,Kl*s)}},I={left:C(-1,c,h),right:C(1,d,u)},A=(E,S,_,P)=>{const R=m(E,_,P);return{x:S.end.x+R.x*n*i,y:S.end.y+R.y*n*i}};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(f?0:sc,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:y,neckY:v,drop:g,lean:f?e.lean:e.lean+ac*Math.sin(Math.PI*l),classic:f,legs:I,toes:{left:A(-1,I.left,c,h),right:A(1,I.right,d,u)},spine:k,arms:{left:L(-1,e.leftShoulder,e.leftElbow),right:L(1,e.rightShoulder,e.rightElbow)}}}const Jt=(e,t)=>t===0?[e.root,e.joint,e.end]:gt(e.root,e.joint,e.end,t);function Fn(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 Ar(e,t){const n=nt(e.lean),i=nt(t.headTilt),s={x:0,y:e.hipY},r=y=>({x:e.facing*y.x,y:y.y}),o=y=>r(Fn(y,s,n)),a=y=>o(Fn({x:y.x,y:y.y+e.neckY},{x:0,y:e.neckY},i)),l=Jt(e.arms.left,e.rubber).map(o),c=Jt(e.arms.right,e.rubber).map(o),h=y=>{const[v,w]=y.slice(-2);return Math.atan2(w.y-v.y,w.x-v.x)};let d=1/0;for(const[y,v]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const w=Sr($n,1,y,Mr(v,t.blink));d=Math.min(d,w,w-t.browTilt*.1)}const u={left:r(e.legs.left.end),right:r(e.legs.right.end)},f={left:r(e.toes.left),right:r(e.toes.right)},p={left:Math.max(u.left.y,f.left.y),right:Math.max(u.right.y,f.right.y)},m=Math.max(p.left,p.right),g=hc*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:u,toes:f,feetY:m,grounded:{left:p.left>=m-g,right:p.right>=m-g},handAngle:{left:h(l),right:h(c)},limbs:{leftArm:l,rightArm:c,leftLeg:Jt(e.legs.left,e.rubber).map(r),rightLeg:Jt(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:$n,browTopY:d,mouthY:kr,faceX:e.facing*(gr+yr*Rt(t.turn))}}}function Er(e,t={}){return Ar(xr(e,t),e)}function pc(e,t,n){return Fn({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function Pr(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 _r(e,t,n={},i=0){const s=xr(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?Ar(s,t):void 0,l=n.sketch?ke(e,n.sketch,i):void 0,c=n.sketch&&n.layers?ke(e,n.sketch,i):void 0,h=k=>{e.save(),k(),e.restore()},d=k=>{k&&a&&h(()=>k(e,a,i,c))},u=()=>e.scale(s.facing,1),f=()=>{u(),e.translate(0,s.hipY),e.rotate(nt(s.lean)),e.translate(0,-s.hipY)},p=(k,T,M)=>{if(l)return T?l.curve(k):l.line(k);if(s.classic){e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const x of k.slice(1))e.lineTo(x.x,x.y);e.stroke();return}In(e,k,M[0]*s.lineWidth,M[1]*s.lineWidth)},m=(k,T)=>p(Jt(k,s.rubber),s.rubber>0,T),g=k=>{s.classic||p([s.legs[k].end,s.toes[k]],!1,ec)},y=k=>{if(s.classic||l)return;const T=s.arms[k].end;e.beginPath(),e.arc(T.x,T.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=k=>{h(()=>{f(),m(s.arms[k],tc),y(k)});const T=o.sleeve;T&&a&&h(()=>T(e,a,k,i,c))},w=Rt(t.turn)>lc;d(o.behind),h(()=>{u(),m(s.legs.left,vr),g("left"),m(s.legs.right,vr),g("right")}),w&&v("left"),h(()=>{f(),p(s.spine,s.spine.length>2,Zl);const{left:k,right:T}={left:s.arms.left.root,right:s.arms.right.root};if(k.x!==T.x)if(s.classic)p([k,T],!1,[1,1]);else{const M={x:(k.x+T.x)/2,y:k.y-.3*Math.abs(T.x-k.x)};p(gt(k,M,T,1,8),!0,[1.1,1.1])}}),d(o.body),w||v("left"),v("right"),d(o.behindHead),h(()=>{f(),e.translate(0,s.neckY),e.rotate(nt(t.headTilt));const k=-s.headRy;e.beginPath(),e.ellipse(0,k,s.headRx,s.headRy,0,0,Math.PI*2);const T=n.headFill??"#ffffff";if(T!=="none"&&(e.fillStyle=T,e.fill()),l){l.ellipse(0,k,s.headRx,s.headRy);const M=l.nudge();e.translate(M.x,M.y)}else e.stroke();e.translate(0,k),e.scale(s.headRx/s.r,s.headRy/s.r),dc(e,t,s.r,0,r,s.lineWidth)}),d(o.overHead),d(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 On(e,t){const n={...e};let i=e.walking>0?cr(n,fr(e.walk,n),e.walking):n;return e.talk>0&&(i={...i,mouth:Math.max(i.mouth,e.talk*dr(t))}),i}function mc(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};return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s},figureStyle:t,draw(r,o,a){const l=o.props;r.translate(i/2,n),_r(r,On(l,a),{...t,rubber:l.rubber},a)}}}function gc(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=On(s,t.time),l=Er(a,{...i,rubber:s.rubber});return{pose:a,joints:Pr(l,e.x+r+e.width/2,e.y+o+e.height)}}function yc(e,t){const n=[];return t.forEach((i,s)=>{const r=s===0?yt:n[s-1],o=typeof i.pose=="string"?ar[i.pose]:{...r,...i.pose};n.push(i.expression?or(o,i.expression):o)}),lr.filter(i=>n.some(s=>s[i]!==yt[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}:{}}))}))}function Cr(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)Ir(e,c,i);e.restore()}function Dn(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()}function Bn(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=s==="eraser"?17:9,l=s==="eraser"?-40:0,c=i?i.nudge(.6):{x:0,y:0};e.save(),e.translate(t.x+c.x,t.y+c.y),e.rotate((n.angle??-30)*Math.PI/180),e.scale(n.scale??1,n.scale??1),e.lineCap="round",e.lineJoin="round";const h=(f,p,m,g)=>{for(const[y,v]of[[o,m+6],[g,m]])e.strokeStyle=y,e.lineWidth=v,e.beginPath(),e.moveTo(f.x,f.y),e.lineTo(p.x,p.y),e.stroke()};e.save(),e.translate(l,0);const d={x:165,y:-a-26},u=f=>({x:d.x+f*.8,y:d.y+f*.6});h(d,u(2e3),64,r),h(u(110),u(2e3),92,n.sleeve??"#5b7db1"),e.fillStyle=r,e.strokeStyle=o,e.lineWidth=3,e.beginPath(),e.ellipse(d.x,d.y,54,40,.25,0,Math.PI*2),e.fill(),e.stroke(),e.restore(),s==="eraser"?Dn(e,{x:0,y:0},{angle:0,outline:o},i):Cr(e,{x:0,y:0},{angle:0,outline:o},i),e.translate(l,0),h({x:150,y:a+8},{x:92,y:a+12},22,r),h({x:140,y:-a-18},{x:58,y:-a-6},20,r),h({x:150,y:-a-30},{x:112,y:-a+2},20,r),h({x:172,y:-a-30},{x:140,y:-a+4},20,r),e.restore()}function bc(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 wc(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 d=e.sketch?ke(a,e.sketch,c):void 0;h>0&&(d?e.smooth?d.curve(t,h):d.line(t,h):Ir(a,It(t,h))),o&&h>0&&h<1&&Bn(a,_n(t,h),o,d)}}}function Ir(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 xe=1e5;function vc(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 Nn(e,t,n,i){if(i<=0||t.length===0)return;const s=It(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-xe,-xe,2*xe,2*xe),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 d=-(c.y-l.y)/h*r,u=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+d,l.y+u),e.lineTo(c.x+d,c.y+u),e.lineTo(c.x-d,c.y-u),e.lineTo(l.x-d,l.y-u),e.closePath()})}}function Tc(e,t,n,i,s){e.save(),Nn(e,t,n,i),s(),e.restore()}function kc(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(),Nn(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=_n(t.path,l);i?Bn(r,c,{...i,tool:"eraser"}):Dn(r,c,s)}}}const ht=e=>e*Math.PI/180;function Rr([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function Lr([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Qt([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const Yn=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],$r=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Ae=(e,t)=>Lr(Rr(e,t.swing),t.spread);function Wn(e,t){const n=Qt(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function qn(e,t,n){const i=n.height,s=ht(90*(t.turn??0)),o=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],a={};for(const S of e.chains){const _=S.parent?a[S.parent]:void 0;if(S.parent&&!_)throw new Error(`body plan ${e.id}: chain ${S.id} comes before its parent ${S.parent}`);const P=S.at??(_?_.joints3.length-1:0),R=_?_.joints3[P]:o,$=_?_.frames[Math.max(0,P-1)]:{swing:0,spread:0},B=S.offset?Yn(R,Ae($r(S.offset,i),$)):R,N=S.side??1,F=e.boneScale?.(t,S)??1,D=e.angles(t,S),O=[B],j=[];let et=$.swing,ft=$.spread;S.bones.forEach((bt,Re)=>{const te=D[Re]??{swing:0,spread:0};et+=ht(te.swing),ft+=ht(te.spread)*N,j.push({swing:et,spread:ft});const Jn=Qt(Ae(S.rest,{swing:et,spread:ft}),ht(te.yaw??0));O.push(Yn(O[Re],$r(Jn,bt.length*i*F)))}),a[S.id]={joints3:O,frames:j}}const l=a[e.head.on],c=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},h=l.frames[l.frames.length-1],d=e.head.size/2*i,u=d*c.sx,f=d*c.sy,p=S=>Ae(Qt(Rr(Lr(S,-ht(c.tilt)),-ht(c.nod)),ht(c.yaw)),h),m=Yn(l.joints3[l.joints3.length-1],p([0,f,0])),g={};for(const S of e.chains){const{joints3:_,frames:P}=a[S.id],R=_.map($=>Wn($,s));g[S.id]={id:S.id,joints3:_,frames:P,points:R.map($=>$.point),depths:R.map($=>$.depth)}}const y=Wn(m,s),v=[[1,0,0],[0,1,0],[0,0,1]].map(S=>Qt(p(S),s)),w=Wn(o,s).point,k=ht(t.roll??0),T=S=>{const _=S.x-w.x,P=S.y-w.y;return{x:w.x+_*Math.cos(k)-P*Math.sin(k),y:w.y+_*Math.sin(k)+P*Math.cos(k)}},M=([S,_,P])=>[S*Math.cos(k)+_*Math.sin(k),-S*Math.sin(k)+_*Math.cos(k),P];for(const S of Object.values(g))S.points=S.points.map(T);const x={center:T(y.point),depth:y.depth,rx:u,ry:f,angle:0,axes:v.map(M)},C=x.axes[1];x.angle=Math.atan2(C[0],C[1]);const L=S=>{if("head"in S)return{x:x.center.x+C[0]*f,y:x.center.y-C[1]*f};const _=g[S.chain];return _.points[Math.min(S.joint,_.points.length-1)]};let I=0;(n.contact??"ground")==="ground"&&(I=-Math.max(...e.contacts.map(S=>L(S).y))),I-=(t.lift??0)*i;const A=S=>({x:S.x,y:S.y+I});for(const S of Object.values(g))S.points=S.points.map(A);x.center=A(x.center);const E=e.contacts.map(S=>({spec:S,point:L(S)}));return{height:i,view:s,chains:g,head:x,hip:A(T(w)),contacts:E,groundY:Math.max(...E.map(S=>S.point.y))}}function Fr(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}}const Ee=e=>e*180/Math.PI,Lt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Xn=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Zt=e=>Math.hypot(e[0],e[1],e[2]),Hn=e=>{const t=Zt(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Pe=e=>Math.atan2(Math.sin(e),Math.cos(e));function Or(e){const[t,n,i]=Hn(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function Mc(e,t,n,i,s){const r=e.chains.find(I=>I.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=qn(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=Zt(Lt(a.joints3[1],a.joints3[0])),h=Zt(Lt(a.joints3[2],a.joints3[1])),d=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=Lt(i,l),f=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,Zt(u))),p=Hn(u),m=r.parent!==null,g=Ae(r.pole??(m?[0,-.35,-1]:[0,0,1]),d);let y=Lt(g,[p[0]*Xn(g,p),p[1]*Xn(g,p),p[2]*Xn(g,p)]);Zt(y)<1e-6&&(y=Qt([1,0,0],0)),y=Hn(y);const v=(c*c+f*f-h*h)/(2*c*f),w=Math.sqrt(Math.max(0,1-v*v)),k=[l[0]+c*(v*p[0]+w*y[0]),l[1]+c*(v*p[1]+w*y[1]),l[2]+c*(v*p[2]+w*y[2])],T=[l[0]+p[0]*f,l[1]+p[1]*f,l[2]+p[2]*f],M=r.side??1,x=Or(Lt(k,l)),C=Or(Lt(T,k)),L=[{swing:Ee(Pe(x.swing-d.swing)),spread:Ee(Pe(x.spread-d.spread))*M},{swing:Ee(Pe(C.swing-x.swing)),spread:Ee(Pe(C.spread-x.spread))*M}];return e.withAngles(t,r,L)}function Vn(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,d)=>{const u=r+Math.PI*2*o*d/a,f=Math.cos(u)*n,p=Math.sin(u)*i;return{x:e+f*l-p*c,y:t+f*c+p*l}})}function Dr(e,t){return t.look==="pencil"?Ec(e,t):Sc(e,t.ink,t.look)}function _e(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 Sc(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,In(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",_e(e,r),e.stroke())},shape(r,o,a){_e(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,d){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(d<=0)&&(e.strokeStyle=t,e.lineWidth=d*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 xc(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 d=h/c;n.push({x:a.x+(l.x-a.x)*d,y:a.y+(l.y-a.y)*d}),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 Ac(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 Br(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=Cn(t.time,n.boil??8);let c=0;const h=(p,m,g=!1)=>de(nn(`${t.seed}:${g?"paper":l}:${p}:${m}`)),d=(p,m,g,y,v,w=0)=>{if(p.length<2)return;const k=p.slice(1).reduce((A,E,S)=>A+Math.hypot(E.x-p[S].x,E.y-p[S].y),0);let T=xc(p,Math.max(1.5,Math.min(t.lineWidth*.8,k/24)));if(w>0&&T.length>=2){const[A,E]=[T[T.length-2],T[T.length-1]],S=Math.hypot(E.x-A.x,E.y-A.y)||1;T=[...T,{x:E.x+(E.x-A.x)/S*w,y:E.y+(E.y-A.y)/S*w}]}const M=Br(g),x=Br(g),C=T.length,L=[],I=[];T.forEach((A,E)=>{const S=C===1?0:E/(C-1),_=T[Math.max(0,E-1)],P=T[Math.min(C-1,E+1)],R=Math.hypot(P.x-_.x,P.y-_.y)||1,$=-(P.y-_.y)/R,B=(P.x-_.x)/R,N=M(S)*v,F=Math.min(1,S/.08,(1-S)/.08),D=(.55+.45*Math.sqrt(Math.max(0,F)))*(1+o*x(S)),O=Math.max(.3,m(S)*D/2),j=A.x+$*N,et=A.y+B*N;L.push({x:j+$*O,y:et+B*O}),I.push({x:j-$*O,y:et-B*O})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,_e(e,[...L,...I.reverse()],!0),e.fill(),e.restore()},u=(p,m)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const T=(y.next()*2-1)*t.lineWidth*1.4,M=(y.next()*2-1)*t.lineWidth*1.4,x=p.map(C=>({x:C.x+T,y:C.y+M}));d(x,C=>m(C)*1.8,h(g,98,!0),.035,s),d(x,C=>m(C)*.45,h(g,97,!0),.12,s*1.5)}const v=p.slice(1).reduce((T,M,x)=>T+Math.hypot(M.x-p[x].x,M.y-p[x].y),0),w=m(.5)>4&&v>m(.5)*6,k=w?[-.3,.3,0]:[0];for(let T=0;T<r;T++){const M=T===0;k.forEach((x,C)=>{const L=h(g,T*10+C),I=x===0?p:Ac(p,E=>m(E)*x*Math.sqrt(Math.sin(Math.PI*E))),A=!M&&x===0?t.lineWidth*(.3+L.next()*.8):0;d(I,E=>m(E)*(w?.5:1)*(M?1:.6),L,M?.85:.45,s*(M?.6:1),A)})}},f=(p,m,g,y,v,w)=>{const T=h(c,50).next()*Math.PI*2;u(Vn(p,m,g,y,v,T,1.08,48),()=>w)};return{look:"pencil",ink:i,limb(p,m,g){u(p,y=>m+(g-m)*y)},line(p,m){u(p,()=>m)},shape(p,m,g){m!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=m,_e(e,p,!0),e.fill(),e.restore()),g>0&&u([...p,p[0]],()=>g)},ellipse(p,m,g,y,v,w,k){w!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=w,e.beginPath(),e.ellipse(p,m,g,y,v,0,Math.PI*2),e.fill(),e.restore()),f(p,m,g,y,v,k)},dot(p,m,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(p,m,g,0,Math.PI*2),e.fill(),e.restore()},guide(p){if(n.construction===!1||p.length<2)return;const m=c++;d(p,()=>Math.max(.6,t.lineWidth*.18),h(m,0),.28,s*1.2,t.lineWidth)},guideEllipse(p,m,g,y,v){if(n.construction===!1)return;const w=c++,k=h(w,0),T=Vn(p,m,g,y,v,k.next()*Math.PI*2,1.12,48);d(T,()=>Math.max(.6,t.lineWidth*.18),k,.28,s*1.5)}}}const Pc=.34,ut=.12,tt=-.4,it=(e,t,n)=>e[t]??n,_c=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Cc=.45,Ic=.35,Rc=.7;function Ce(e,t,n){const i=f=>Math.sqrt(Math.max(0,1-f.x*f.x-f.y*f.y)),s=Fr(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(Ic,Math.abs(a)),h=l*Math.max(Rc,Math.abs(a)),d=Math.cos(e.angle),u=Math.sin(e.angle);return{facing:s,points:t.map(f=>{const p=Cc*Math.sin(o)+n.x*c+(f.x-n.x)*h,m=f.y+r[1]*i(f),g=p*e.rx,y=m*e.ry;return{x:e.center.x+g*d+y*u,y:e.center.y+g*u-y*d}})}}const Ie=(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}}),Un=(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}}),Nr=.05;function Lc(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,v)=>Ce(t,y,v).points,o=(y,v)=>Ce(t,[],{x:y,y:v}).facing,a=it(n,"smile",0),l=it(n,"blink",0),c=it(n,"lookX",0),h=it(n,"lookY",0),d=it(n,"browTilt",0);for(const y of[1,-1]){const v=y===1?"left":"right",w=Pc*y;if(o(w,ut)<Nr)continue;const k={x:w,y:ut},T=_c(it(n,`eye.${v}`,1),l);if(T<.2){const L=a>.5?.12:-.06;e.line(r(Ie({x:w-.12,y:ut},{x:w,y:ut+L},{x:w+.12,y:ut}),k),s)}else{if(T>1.2){const E=.13*T;e.shape(r(Un(w,ut,E*.85,E),k),"#ffffff",s)}const L=T>1.2?.075:.1,I=w+c*.08,A=ut-h*.07;e.shape(r(Un(I,A,L,L*1.1*Math.min(T,1)),k),e.ink,0)}const M=ut+.3+it(n,`brow.${v}`,0)*.14+Math.max(0,T-1)*.12,x={x:w+y*.13,y:M},C={x:w-y*.13,y:M+d*.1};e.line(r([x,{x:(x.x+C.x)/2,y:(x.y+C.y)/2},C],{x:w,y:M}),s)}const u={x:0,y:tt};if(o(0,tt)<-Nr)return;const f=.25*Math.max(.3,it(n,"mouthWidth",1)),p=Math.min(1,Math.max(0,it(n,"mouth",0)));if(p<=.05){e.line(r(Ie({x:-f,y:tt},{x:0,y:tt-a*.25},{x:f,y:tt}),u),s);return}const m=.3*p;let g;if(a>.3){const y=tt+.05;g=[...Ie({x:f,y},{x:0,y:tt-m*2},{x:-f,y})]}else if(a<-.3){const y=tt-m*.6;g=[...Ie({x:f,y},{x:0,y:tt+m*1.4},{x:-f,y})]}else g=Un(0,tt,f*.8,m);e.shape(r(g,u),e.ink,0)}const jn=.215,zn=.205,$c=.065,Yr=.035,Fc=.165,Oc=.155,Dc=12,st={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.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":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 V(e={}){return{...st,...e}}function U(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 Wr={rest:st,wave:V({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:V({...U("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:V({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:V({...U("arm",{spread:50,bend:-105,elbow:0}),...U("leg",{spread:9}),smile:.8}),think:V({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:V({...U("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:V({...U("leg",{swing:90,knee:90,spread:4}),...U("arm",{swing:25,elbow:45,spread:8})}),kneel:V({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...U("arm",{swing:20,elbow:30})}),crouch:V({...U("leg",{swing:75,knee:140,spread:6}),lean:25,...U("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:V({lean:82,"head.nod":-35,...U("arm",{swing:80,elbow:0,spread:4}),...U("leg",{knee:92,ankle:-88})}),lieDown:V({roll:90,...U("arm",{spread:8}),"head.nod":0})};function qr(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-Yr-(jn+zn)),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:Fc,width:[1.25,.9]},{length:Oc,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:jn,width:[1.45,1.05]},{length:zn,width:[1.05,.85]},{length:$c,width:[.95,.7]}]}),a=(l,c)=>l[c]??st[c]??0;return{id:"human",hipHeight:jn+zn,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:Yr,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 f=-a(l,"lean")/2,p=a(l,"side")/2;return[{swing:f,spread:p},{swing:f,spread:p}]}if(c.id==="neck")return[{swing:0,spread:0}];const[h,d]=c.id.split("."),u=f=>a(l,`${h}.${d}.${f}`);return h==="arm"?[{swing:u("swing"),spread:u("spread")},{swing:u("elbow"),spread:u("bend")}]:[{swing:u("swing"),spread:u("spread")},{swing:-u("knee"),spread:0},{swing:90+u("ankle"),spread:0,yaw:Dc*(c.side??1)}]},withAngles(l,c,h){const[d,u]=c.id.split("."),f=p=>`${d}.${u}.${p}`;return d==="arm"?{...l,[f("swing")]:h[0].swing,[f("spread")]:h[0].spread,[f("elbow")]:h[1].swing,[f("bend")]:h[1].spread}:d==="leg"?{...l,[f("swing")]:h[0].swing,[f("spread")]:h[0].spread,[f("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 Bc(e){const t=e.split(".");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"}[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 Nc={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Yc=Object.fromEntries(Object.entries(Z).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[Nc[n]??n,i]))]));function Wc(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??qr({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"}}function qc(e,t,n,i){const{point:s,facing:r}=Fr(e,[t,n,i]);return{point:s,facing:r}}const Gn=e=>e.rest[1]<-.5,Xc=.3;function Hc(e,t,n){return e.figure==="stick"?Gn(t)?n.slice(0,3):n:Gn(t)&&n.length>=3?gt(n[0],n[1],n[2],Xc):n.length===3?gt(n[0],n[1],n[2],1):n}function Kn(e,t){const n=e.plan.id==="human"?{...st,...t}:t,i=qn(e.plan,n,{height:e.height,contact:e.contact}),s={},r={},o={},a=.01*e.height;e.plan.chains.forEach(f=>{const p=i.chains[f.id];s[f.id]=p.points;const m=p.depths.reduce((w,k)=>w+k,0)/p.depths.length,g=f.parent?i.chains[f.parent]:void 0,y=g?g.depths[f.at??g.depths.length-1]:0,v=m-y;o[f.id]=Math.abs(v)<a?0:v,r[f.id]={points:Hc(e,f,p.points),depth:m}}),r.head={points:[i.head.center],depth:i.head.depth},o.head=0;const l=[...e.plan.chains.map(f=>f.id),"head"],c=[...l].sort((f,p)=>o[f]-o[p]||l.indexOf(f)-l.indexOf(p)),h={hip:i.hip};for(const[f,[p,m]]of Object.entries(e.plan.landmarks??{})){const g=i.chains[p]?.points;g&&(h[f]=g[Math.min(m,g.length-1)])}const d={};for(const[f,p]of Object.entries(h))d[f]=p.y>=i.groundY-.01*e.height;const u={height:e.height,lineWidth:e.lineWidth,turn:n.turn??0,points:h,chains:s,parts:r,head:i.head,groundY:i.groundY,grounded:d};return{skeleton:i,joints:u,order:c}}function Xr(e,t){return Kn(e,t).joints}function Vc(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=Ce(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(Ce(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 Uc(e,t,n,i,s){const r=t.lineWidth;if(i==="head"){const{head:u}=n,f=t.skin==="none"?null:t.skin;e.ellipse(u.center.x,u.center.y,u.rx,u.ry,u.angle,f,r),e.look!=="silhouette"&&Lc(e,u,s,r);return}const o=t.plan.chains.find(u=>u.id===i),a=n.chains[i],l=n.parts[i].points;if(t.figure==="stick"){if(i==="neck")return;const u=i==="spine"?[...a,...n.chains.neck?.slice(1)??[]]:l;e.line(u,r);return}const c=(u,f)=>[o.bones[u].width[0]*r,o.bones[f].width[1]*r];if(Gn(o)){const[u,f]=c(0,1);if(e.limb(l,u,f),o.bones.length>=3)e.limb([a[2],a[3]],o.bones[2].width[0]*r,o.bones[2].width[1]*r);else{const p=a[a.length-1];e.dot(p.x,p.y,r*.62)}return}if(i==="spine"){const u=n.points["hip.left"],f=n.points["hip.right"];u&&f&&Math.hypot(u.x-f.x,u.y-f.y)>.5&&e.limb([u,f],r*1.3,r*1.3);const[p,m]=c(0,o.bones.length-1);e.limb(l,p,m);const g=n.points["shoulder.left"],y=n.points["shoulder.right"];g&&y&&Math.hypot(g.x-y.x,g.y-y.y)>.5&&e.limb(gt(g,a[a.length-1],y,1,10),r*1.15,r*1.15);return}const[h,d]=c(0,o.bones.length-1);e.limb(l,h,d)}function Hr(e,t,n,i=0){const s=t.plan.id==="human"?{...st,...n}:n,{joints:r,order:o}=Kn(t,s),a=Dr(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:i,pencil:t.pencil}),l=c=>{c&&(e.save(),c(e,r,a,i),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&Vc(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),Uc(a,t,r,c,s),l(h?.over)}l(t.layers.front),e.restore()}function jc(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 zc(e,t,n,i){const s=e.plan.id==="human"?{...st,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=Kn(e,s),a=qn(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,d=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),u=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),f=Math.PI/2*(s.turn??0),p=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],m=Math.cos(f),g=Math.sin(f);r=[d*m-p*g,-u,d*g+p*m]}return Mc(e.plan,s,n,r,{height:e.height})}function Gc(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?st:{};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),Hr(r,t,o.props,a)}}}function Vr(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 Kc(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=Xr(i,s);return{pose:s,joints:Vr(a,e.x+r+e.width/2,e.y+o+e.height)}}function Jc(e,t,n=st){const i=[];return t.forEach((r,o)=>{const a=o===0?n:i[o-1],l=typeof r.pose=="string"?Wr[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 Qc=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function Zc(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(Kt(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],d=c[c.length-1],u={x:h.x-(d.x-h.x)*.25,y:h.y-(d.y-h.y)*.25};l.shape(Kt([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,d=h[0],u=a.chains.spine[a.chains.spine.length-1],p=[{x:d.x+(u.x-d.x)*.45,y:d.y+(u.y-d.y)*.45},...Qc(h,0,.45)],m=Kt(p,a.height*.085,a.height*.06),g=p.length,y=m.slice(0,g),v=m.slice(g).reverse();l.shape(m,t,0);const w=M=>Math.hypot(M[1].x-u.x,M[1].y-u.y),[k,T]=w(y)>w(v)?[y,v]:[v,y];l.line(k.slice(1),i(a)),l.line(T.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 th(e){const{timeline:t}=e,n=new mt;for(const[c,h]of Object.entries(e.targets)){const d=typeof h=="string"?document.querySelector(h):h;if(!d)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,d)}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 eh={timeline:ga,to(e,t,n){const i=new pt(n);return i.to(e,t),i},from(e,t,n){const i=new pt(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new pt(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new pt(n);return i.set(e,t),i}},nh=q.to,ih=q.from,sh=q.fromTo,rh=q.set,oh=q.timeline,ah=q.ticker,lh=q.splitText,ch=q.context,hh=q.matchMedia,uh=q.quickTo,fh=q.imageSequence,dh=q.pageTransition;Yl(),b.Clock=zr,b.CompatTimeline=pt,b.CustomBounce=Bs,b.CustomEase=Ds,b.CustomWiggle=Ns,b.DEFAULT_BAKE_INTERVAL_MS=je,b.DEFAULT_INERTIA_FRICTION=De,b.DEFAULT_LABELS=zs,b.DEFAULT_SPRING=H,b.DEFAULT_TRANSITION=ql,b.Draggable=dn,b.EXPRESSIONS=Z,b.FORMAT_VERSION=Ft,b.HUMAN_EXPRESSIONS=Yc,b.HUMAN_POSES=Wr,b.HUMAN_REST=st,b.INERTIA_MAX_DURATION_MS=ti,b.InertiaTrackPlayer=Oi,b.LiveTimeline=Q,b.MORPH_SAMPLES=yo,b.ManualClock=jr,b.MediaSync=En,b.Observer=ps,b.POSES=ar,b.REST_POSE=yt,b.SPRING_MAX_DURATION_MS=Oe,b.SPRING_PRESETS=re,b.SPRING_STEP_MS=vt,b.ScrollAnimator=Cs,b.ScrollDriver=jt,b.ScrollMarkers=Is,b.ScrollPin=As,b.SmoothScroll=Sn,b.SpringSampler=Dt,b.SpringTrackPlayer=Fi,b.Stage=ls,b.Timeline=Ze,b.TinyflyPlayer=ve,b.TinyflySequencer=nr,b.TrackPlayer=fe,b.ValueResolver=No,b.VisibilityDriver=xs,b.backOut=hi,b.bakeEasing=Ke,b.bakeInertiaTrack=Ge,b.bakeSpringTrack=ze,b.basicOutfit=Zc,b.bindChoiceHotspots=Qs,b.blendPose=cr,b.boilFrame=Cn,b.bounceOut=ci,b.character=Wc,b.characterAt=Kc,b.characterJoints=Xr,b.characterPoseTracks=Jc,b.characterTarget=Gc,b.charactersFor=Di,b.circlePath=bc,b.clamp01=vn,b.clearMorphCache=Ao,b.clearPathCache=uo,b.clipErased=Nn,b.containerProgressAt=Tn,b.context=ch,b.create=xl,b.createControls=Ks,b.createCubicBezier=ai,b.createLive=qs,b.createPen=Dr,b.createRandom=de,b.createTrack=ue,b.criticalDamping=Jr,b.customBounce=zi,b.customEase=ji,b.customWiggle=Gi,b.deserializeTimeline=At,b.deserializeTrack=Wi,b.draggable=Ba,b.drawCharacter=Hr,b.drawEraser=Dn,b.drawHand=Bn,b.drawPencil=Cr,b.drawStickFigure=_r,b.drawnPathTarget=wc,b.easeIn=si,b.easeInCubic=Be,b.easeInOut=oi,b.easeInOutCubic=Nt,b.easeInOutQuad=ii,b.easeInQuad=ei,b.easeOut=ri,b.easeOutCubic=Ne,b.easeOutQuad=ni,b.elasticOut=li,b.ellipsePoints=Vn,b.erasable=kc,b.expandParametricEasings=Li,b.from=ih,b.fromJSON=Oo,b.fromTo=sh,b.getEasingFunction=z,b.getInterpolator=Xt,b.getMotionPathPoint=Je,b.getPathLength=fo,b.getPointAtProgress=mi,b.gridLinesFor=ys,b.hasKeyframes=Qn,b.hashSeed=nn,b.headPoint=pc,b.humanFieldLabel=Bc,b.humanPlan=qr,b.humanPose=V,b.imageSequence=fh,b.inertiaDuration=kt,b.inertiaRest=Tt,b.inertiaValueAt=ae,b.inertiaVelocityAt=eo,b.interpolateArray=Ci,b.interpolateColor=_i,b.interpolateMotionPath=Io,b.interpolateNumber=G,b.interpolatePathString=Ii,b.interpolateString=Ue,b.isCubicBezierEasing=wt,b.isInertiaTrack=rt,b.isMotionPathPoint=Ur,b.isMotionPathTrack=Le,b.isParametricEasing=$t,b.isPathData=St,b.isSpringTrack=ot,b.isTextTrack=ee,b.isUnderdamped=Kr,b.isUnresolved=Bo,b.jointsInScene=Vr,b.jointsToScene=Pr,b.linear=le,b.live=q,b.mapEase=Ht,b.matchMedia=hh,b.maxStaggerDistance=Fe,b.mixPoses=jc,b.morphPath=ki,b.mount=Zs,b.mountAll=er,b.narrationMarkers=jo,b.narrationSceneAt=zo,b.naturalRest=Bt,b.pageTransition=dh,b.parametricEasing=fi,b.parseEdge=bn,b.parsePath=dt,b.parseTrigger=wn,b.partialPath=It,b.pathLength=ir,b.planNarration=Uo,b.play=Sl,b.playSequence=Wl,b.playWhenVisible=Ja,b.playheadCrossings=tn,b.pointAlong=_n,b.pointAtDistance=We,b.pointOnHead=qc,b.pointsToPath=Ji,b.pose=X,b.poseTracks=yc,b.quickPlay=th,b.quickTo=uh,b.randomBetween=sn,b.randomChoice=Do,b.randomSnapped=Xi,b.reachCharacter=zc,b.resolveSequence=Ui,b.resolveStickPose=On,b.resolveValue=rn,b.rubberLimb=gt,b.scrollProgress=Ka,b.scrubOnScroll=el,b.scrubPath=vc,b.seatHeight=uc,b.serializeTimeline=qi,b.serializeTrack=Ni,b.set=rh,b.shapeToPathData=pe,b.simplifyKeyframes=$i,b.sketchPen=ke,b.smoothToward=Ss,b.snapAxis=gs,b.snapConfig=Es,b.snapDuration=_s,b.snapProgress=Ps,b.splitText=lh,b.springDuration=Zn,b.springValueAt=Gr,b.staggerDistance=$e,b.staggerOffset=ne,b.staggerOffsets=ie,b.staggerSpan=Ot,b.stepsEasing=ui,b.stickFigureAt=gc,b.stickFigureJoints=Er,b.stickFigureTarget=mc,b.strideLength=Ul,b.syncMediaElement=js,b.talkingMouth=dr,b.taperedLine=In,b.taperedOutline=Kt,b.textAt=Bi,b.tf=eh,b.ticker=ah,b.timeline=oh,b.to=nh,b.toJSON=Fo,b.toKeyframedTrack=_o,b.toKeyframedTracks=Co,b.trackTargets=ct,b.triggerDistance=Et,b.unmount=Bl,b.walkPose=fr,b.withErased=Tc,b.withExpression=or,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
53
+ `;function Fh(e){if(e.getElementById($r))return;const t=e.createElement("style");t.id=$r,t.textContent=$h,e.head.appendChild(t)}function Fr(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Fh(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 d=e.scenarios.find(m=>m.id===l)?.label;d!==void 0&&c("aria-label",d),a.setAttribute("aria-pressed","false"),h.push("aria-pressed"),i.push({element:a,attributes:h});const u=()=>e.setScenario(l),f=m=>{const p=m.key;p!=="Enter"&&p!==" "||(m.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",f),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",f)})}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,ri=new WeakMap;let Lh=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 Lr(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=Bh(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Oh(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 f=await fetch(r);f.ok&&(l=await f.json())}if(l&&o&&(l=Or(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)};Nh(e);const d=new Be(e,c),u={element:e,player:d};if(De.set(e,u),e.setAttribute("data-tinyfly-mounted",""),a){const f=e.getAttribute("data-scenario")??void 0;await d.loadScenarios(a,{initial:a.some(m=>m.id===f)?f:void 0}),ri.set(e,Fr(d,e))}else await d.load(l??r);if(e.getAttribute("data-controls")!=="false"){const f=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=Rr(d,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...f,...p?{scenario:p}:{}},mount:void 0}),m?e.insertBefore(u.controls.element,m):e.appendChild(u.controls.element)}return u}function Oh(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?Or(o,t):o})}),i}function Or(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function Bh(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 Br(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>Lr(s,t)))).filter(s=>s!==void 0)}function Dh(e){const t=De.get(e);t&&(ri.get(e)?.(),ri.delete(e),t.controls?.destroy(),t.player.destroy(),De.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Nh(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-${++Lh}`,t.setAttribute("aria-labelledby",i.id))}function Wh(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{Br()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class Dr{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 Yh(e,t,n={}){const i=new Dr(e,{...n,autoplay:!0});return await i.load(t),i}const Kh={type:"none",duration:0};function Nr(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=Nr(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 oi(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=oi(n,t.boil??8);let o=0;const a=()=>{const u=o++;return f=>_e(Rn(`${t.seed??1}:${r}:${u}:${f}`))},l=(u,f)=>(u.next()*2-1)*f,h=u=>{const f=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(f(g));e.lineWidth=m,e.globalAlpha=p},c=(u,f=1)=>{if(u.length<2)return;const m=u.slice(1).map((g,b)=>Math.hypot(g.x-u[b].x,g.y-u[b].y)),p=m.reduce((g,b)=>g+b,0)*Math.min(1,Math.max(0,f));h(g=>{const b=[],v=[];if(u.forEach((T,S)=>{b.push({x:T.x+l(g,i*.5),y:T.y+l(g,i*.5)}),S>0&&v.push([g.next()*2-1,g.next()*2-1])}),p<=0)return;e.beginPath(),e.moveTo(b[0].x,b[0].y);let w=0;for(let T=1;T<b.length;T++){const S=qh(b[T-1],b[T],i,v[T-1]),k=m[T-1];if(w+k<=p){e.bezierCurveTo(S[1].x,S[1].y,S[2].x,S[2].y,S[3].x,S[3].y),w+=k;continue}const M=Xh(S,k===0?1:(p-w)/k);e.bezierCurveTo(M[1].x,M[1].y,M[2].x,M[2].y,M[3].x,M[3].y);break}e.stroke()})},d=(u,f,m,p,g=1)=>{h(b=>{const w=b.next()*Math.PI*2,T=Math.PI*2+.15+b.next()*.3,S=[];for(let M=0;M<=14;M++){const C=w+T*M/14,x=l(b,i*.6);S.push({x:u+Math.cos(C)*(m+x),y:f+Math.sin(C)*(p+x)})}const k=Wt(S,g);k.length<2||(Wr(e,k),e.stroke())})};return{line:c,curve(u,f=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,b=-(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)},S={x:l(w,i*.5),y:l(w,i*.5)},k=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)*k;return{x:x.x+T.x+(S.x-T.x)*P+b*A,y:x.y+T.y+(S.y-T.y)*P+v*A}}),C=Wt(M,f);C.length<2||(Wr(e,C),e.stroke())})},circle(u,f,m,p=1){d(u,f,m,m,p)},ellipse:d,nudge(u=.5){const f=a()(0);return{x:l(f,i*u),y:l(f,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,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 Xh([e,t,n,i],s){const r=(d,u)=>({x:d.x+(u.x-d.x)*s,y:d.y+(u.y-d.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 Wr(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)],d=Math.hypot(c.x-h.x,c.y-h.y)||1,u=o(l)/2,f=-(c.y-h.y)/d*u,m=(c.x-h.x)/d*u;s.push({x:a.x+f,y:a.y+m}),r.push({x:a.x-f,y:a.y-m})}),[...s,...r.reverse()]}function Ye(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,d={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+(d.x-h.x)*i,y:h.y+(d.y-h.y)*i})}return o}function ai(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,d)=>{const u=r+Math.PI*2*o*d/a,f=Math.cos(u)*n,m=Math.sin(u)*i;return{x:e+f*l-m*h,y:t+f*h+m*l}})}function li(e,t){return t.look==="pencil"?jh(e,t):Uh(e,t.ink,t.look)}function Ke(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 Uh(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,Ye(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",Ke(e,r),e.stroke())},shape(r,o,a){Ke(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,d){e.beginPath(),e.ellipse(r,o,a,l,h,0,Math.PI*2),(c!==null||i)&&(e.fillStyle=i?t:c,e.fill()),!(d<=0)&&(e.strokeStyle=t,e.lineWidth=d*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 Vh(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 d=c/h;n.push({x:a.x+(l.x-a.x)*d,y:a.y+(l.y-a.y)*d}),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 zh(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 Yr(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 jh(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=oi(t.time,n.boil??8);let h=0;const c=(m,p,g=!1)=>_e(Rn(`${t.seed}:${g?"paper":l}:${m}:${p}`)),d=(m,p,g,b,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 S=Vh(m,Math.max(1.5,Math.min(t.lineWidth*.8,T/24)));if(w>0&&S.length>=2){const[P,A]=[S[S.length-2],S[S.length-1]],E=Math.hypot(A.x-P.x,A.y-P.y)||1;S=[...S,{x:A.x+(A.x-P.x)/E*w,y:A.y+(A.y-P.y)/E*w}]}const k=Yr(g),M=Yr(g),C=S.length,x=[],_=[];S.forEach((P,A)=>{const E=C===1?0:A/(C-1),I=S[Math.max(0,A-1)],H=S[Math.min(C-1,A+1)],R=Math.hypot(H.x-I.x,H.y-I.y)||1,$=-(H.y-I.y)/R,O=(H.x-I.x)/R,L=k(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*=b,e.fillStyle=i,Ke(e,[...x,..._.reverse()],!0),e.fill(),e.restore()},u=(m,p)=>{const g=h++,b=c(g,99,!0);if(b.next()<a){const S=(b.next()*2-1)*t.lineWidth*1.4,k=(b.next()*2-1)*t.lineWidth*1.4,M=m.map(C=>({x:C.x+S,y:C.y+k}));d(M,C=>p(C)*1.8,c(g,98,!0),.035,s),d(M,C=>p(C)*.45,c(g,97,!0),.12,s*1.5)}const v=m.slice(1).reduce((S,k,M)=>S+Math.hypot(k.x-m[M].x,k.y-m[M].y),0),w=p(.5)>4&&v>p(.5)*6,T=w?[-.3,.3,0]:[0];for(let S=0;S<r;S++){const k=S===0;T.forEach((M,C)=>{const x=c(g,S*10+C),_=M===0?m:zh(m,A=>p(A)*M*Math.sqrt(Math.sin(Math.PI*A))),P=!k&&M===0?t.lineWidth*(.3+x.next()*.8):0;d(_,A=>p(A)*(w?.5:1)*(k?1:.6),x,k?.85:.45,s*(k?.6:1),P)})}},f=(m,p,g,b,v,w)=>{const S=c(h,50).next()*Math.PI*2;u(ai(m,p,g,b,v,S,1.08,48),()=>w)};return{look:"pencil",ink:i,limb(m,p,g){u(m,b=>p+(g-p)*b)},line(m,p){u(m,()=>p)},shape(m,p,g){p!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=p,Ke(e,m,!0),e.fill(),e.restore()),g>0&&u([...m,m[0]],()=>g)},ellipse(m,p,g,b,v,w,T){w!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=w,e.beginPath(),e.ellipse(m,p,g,b,v,0,Math.PI*2),e.fill(),e.restore()),f(m,p,g,b,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++;d(m,()=>Math.max(.6,t.lineWidth*.18),c(p,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,p,g,b,v){if(n.construction===!1)return;const w=h++,T=c(w,0),S=ai(m,p,g,b,v,T.next()*Math.PI*2,1.12,48);d(S,()=>Math.max(.6,t.lineWidth*.18),T,.28,s*1.5)}}}const Kr=["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}),K={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 Yt(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 Gh={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}},Jh={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]},Zh=[82,100,62],Qh=[48,72],tc=3,ec=13,nc=.035,ic=-.075,sc=[[-.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,hi=(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],ci=(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=ci(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 qr=[1,0,0],Xr=[0,1,0],ce=[0,0,1];function rc(e,t,n){const i=yt(e.fan*(tc+ec*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,d)=>{a+=yt(Zh[d]*t),o.push(hi(o[d],qe(bt(s,r,-a),c)))});const l=bt(ce,r,-a),h=o.map((c,d)=>e.width*(1-.14*(d/(o.length-1))));return{joints:o,back:l,widths:h}}function oc(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=he(hi(qe(he(ct.out),1-s),qe(he(ct.across),s))),o=he(ci(ce,r)),a=he(ci(r,o)),l=[[ct.base[0]*i,ct.base[1],ct.base[2]]];let h=0;ct.bones.forEach((u,f)=>{f>0&&(h+=yt(Qh[f-1]*e)),l.push(hi(l[f],qe(bt(r,o,h),u)))});const c=bt(a,o,h),d=[...ct.widths,ct.widths[ct.widths.length-1]*.92].map(u=>u*n);return{joints:l,back:c,widths:d}}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}),d=yt(n.bend??0),u=yt(n.tilt??0),f=yt(90*(n.turn??0)),m=A=>bt(bt(bt(A,qr,-d),ce,-u),Xr,f),p=Math.cos(o),g=Math.sin(o),b=yt(n.roll??0),v=Math.cos(b),w=Math.sin(b),T=A=>{const E=A[0]*i,I=-A[1]*i,H=(E*v-I*w)*r,R=E*w+I*v;return{x:H*p-R*g,y:H*g+R*p}},S=A=>{const E=T(A),I=Math.hypot(E.x,E.y);return I>1e-6*i?{x:E.x/I,y:E.y/I}:{x:0,y:0}},k={thumb:oc(n["thumb.curl"]??0,n["thumb.across"]??0,l,h)},M=a?Jh:Gh;for(const A of Kr){const E=M[A];E&&(k[A]=rc(c(E),n[`${A}.curl`]??0,n.spread??0))}const C={};for(const[A,E]of Object.entries(k)){const I=E.joints.map(m),H=m(E.back);C[A]={points:I.map(T),depths:I.map(R=>R[2]*i),widths:E.widths.map(R=>R*i),nail:H[2],back:S(H)}}const x=sc.flatMap(([A,E])=>[m([A*h,E,nc]),m([A*h,E,ic])]),_=ac(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:S(m(Xr)),across:S(m(qr)),out:S(m(ce))},curls:Object.fromEntries(Object.keys(C).map(A=>[A,n[`${A}.curl`]??0]))}}function Ur(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 ac(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 lc="#f1c9a5",hc="#2f2f33";function Ue(e,t,n,i={},s=0){const r=Ur(Xe(n,i),t),o=i.ink??hc,a=i.lineWidth??r.size*.035,l=i.pen??li(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),h=i.skin??lc,c=i.nails??!0,d=[{depth:r.palmDepth,draw:()=>cc(l,r,h,a)}];for(const u of Object.values(r.fingers)){const f=u.depths.reduce((m,p)=>m+p,0)/u.depths.length;d.push({depth:f,draw:()=>uc(e,l,u,h,a,c)})}if(i.prop){const u=i.prop;d.push({depth:u.depth,draw:()=>u.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const u of[...d].sort((f,m)=>f.depth-m.depth))u.draw();return e.restore(),r}function cc(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},d=Math.atan2(s.y,s.x),u=Array.from({length:7},(f,m)=>{const p=d-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,d)=>({x:a.x+(r.x*c+s.x*d)*o,y:a.y+(r.y*c+s.y*d)*o}),h=t.side==="left"?-1:1;e.line([l(-.15*h,.36),l(-.04*h,.3),l(.1*h,.33)],i*.5)}}function uc(e,t,n,i,s,r){const{widths:o}=n,a=fc(n.points,2),l=n.points[0],h=a[a.length-1],c=o[0],d=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,d+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,Ye(e,a,c,d)),t.look==="silhouette"||!r||n.nail<.25)return;const u=a[a.length-2],f=dc({x:h.x-u.x,y:h.y-u.y})??{x:0,y:-1},m={x:h.x-f.x*d*.22+n.back.x*d*.1,y:h.y-f.y*d*.22+n.back.y*d*.1};t.ellipse(m.x,m.y,d*.24*Math.max(.35,n.nail),d*.19,Math.atan2(f.y,f.x),"#f8e3d3",s*.45)}function fc(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 dc=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 Vr={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},q=e=>({...Vr,...e}),Q={neutral:Vr,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 ui(e,t){return{...e,...typeof t=="string"?Q[t]:t}}const zr={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 Kt(e,t,n){const i={...e};for(const s of jr)i[s]=e[s]+(t[s]-e[s])*n;return i}const fi=24,Gr=4,Jr=28,pc=40;function Zr(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<=pc,o=h=>r(h)?22*i:h,a=r(t.leftShoulder)?t.leftElbow-Jr*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+Jr*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+Gr*n,headTilt:t.headTilt-Gr*.5*n,leftElbow:a,rightElbow:l,leftHip:-fi*i,rightHip:-fi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function mc(e,t=1){return 4*((di+Ve)*e)*Math.sin(fi*t*Math.PI/180)}function Qr(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const to=.12,eo=.46,gc=1-2*to,yc=.1,bc=.21,wc=.19,di=.24,Ve=.22,no=.12,vc=.14,io=.33,so=.7,ro=.3,kc=.35,Sc=[1.7,1.05],Tc=[1.3,.75],oo=[1.45,.85],Mc=[1.15,.75],ao=.06,Ec=.7,Ac=.65,lo=.075,xc=.3,Pc=.02,_c=.012,Cc=12,Ic=.25,ze=90,Hc=.25,Rc=.04,ho=.01,At=e=>Math.min(1,Math.max(0,e??0));function $c(e,t=1){return Ve*e*t}const pi=-.12,co=.4,it=e=>e*Math.PI/180,Fc=(e,t)=>({x:t*Math.sin(it(e)),y:Math.cos(it(e))}),uo=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),fo=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function Lc(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,vc*n)),a=At(t.turn),l=(no+io*a)*n,h=i+pi*n,c=l+t.lookX*.08*n,d=t.lookY*.07*n,u=[{x:-.34*n*(1-so*a),squeeze:1-so*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-ro*a),squeeze:1-ro*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const b of u){const v=uo(b.open,t.blink);if(v<.2){const k=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(b.x+l-.12*n,h),e.quadraticCurveTo(b.x+l,h+k,b.x+l+.12*n,h),e.stroke()}else{if(v>1.2){const M=.13*n*v;e.beginPath(),e.ellipse(b.x+l,h,M*.85,M,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const k=v>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(b.x+c,h+d,k,k*1.1*Math.min(v,1),0,0,Math.PI*2),e.fill()}const w=fo(h,n,b.brow,v),T=b.x+l-b.side*.13*n*b.squeeze,S=b.x+l+b.side*.13*n*b.squeeze;e.beginPath(),e.moveTo(S,w),e.lineTo(T,w-t.browTilt*.1*n),e.stroke()}const f=i+co*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-kc*a),p=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),p<=.05){e.moveTo(l-m,f),e.quadraticCurveTo(l,f+t.smile*.25*n,l+m,f),e.stroke();return}const g=.3*n*p;t.smile>.3?(e.moveTo(l-m,f-.05*n),e.lineTo(l+m,f-.05*n),e.quadraticCurveTo(l,f+g*2,l-m,f-.05*n)):t.smile<-.3?(e.moveTo(l-m,f+g*.6),e.lineTo(l+m,f+g*.6),e.quadraticCurveTo(l,f-g*1.4,l-m,f+g*.6)):e.ellipse(l,f,m*.8,g,0,0,Math.PI*2),e.fill()}function po(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*to)/2,o=t.headSize===void 0?gc:1-2*r,a=r*n,l=At(e.sit),h=e.leftHip+(-ze-e.leftHip)*l,c=e.leftKnee+(-ze-e.leftKnee)*l,d=e.rightHip+(ze-e.rightHip)*l,u=e.rightKnee+(ze-e.rightKnee)*l,f=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,Ec+F)),X=m+(1-m)*R*D;return f?{x:0,y:0}:{x:Math.cos(B)*ao*X,y:Math.sin(B)*ao}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},b={left:e.leftFootOut??0,right:e.rightFootOut??0};let v=0;if(l>0||!f){const R=(F,B,D,X,nt)=>di*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,b.left),R(1,d,u,g.right,b.right)),O=1-At((e.rise??0)/Rc),L=(f?Math.min(1,l/Hc):1)*O;v=(eo-$)*L*n*i}const w=-eo*n*i+v,T=-o*n*i+v,S=f?0:(Pc*At(e.turn)+_c*l)*n*i,k=S===0?[{x:0,y:w},{x:0,y:T}]:Et({x:0,y:w},{x:-S,y:(w+T)/2},{x:0,y:T},1,8),M=T+yc*n*i,C=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),x=(R,$,O,L,F)=>{const B=Fc(O,L);return{x:R+B.x*F*n,y:$+B.y*F*n}},_=(R,$,O)=>{const L=x(0,w,$,R,di*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,bc*s);return{root:L,joint:F,end:x(F.x,F.y,$+O,R,wc*s)}},A={left:_(-1,h,c),right:_(1,d,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}},I=(R,$,O,L,F)=>x($.end.x,$.end.y,O+L+F,R,lo*s),H={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(f?0:xc,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:w,neckY:T,drop:v,lean:f?e.lean:e.lean+Cc*Math.sin(Math.PI*l),classic:f,legs:A,toes:{left:E(-1,A.left,h,c,g.left,b.left),right:E(1,A.right,d,u,g.right,b.right)},spine:k,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 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 mo(e,t,n=!0){const i=Bc(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?Oc(i,e,s,r):i}function go(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*it(t),lift:n*e.height}}function Oc(e,t,n,i){const{pivot:s,angle:r,lift:o}=go(t,n,i),a=u=>{const f=je(u,s,r);return{x:f.x,y:f.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),d=ho*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-d,right:h.right>=c-d},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 Bc(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),d={left:o(e.handTips.left),right:o(e.handTips.right)},u=(w,T)=>{const[S,k]=w.slice(-2),M=e.arms[T],C=c(o(M.end),d[T])-c(o(M.joint),o(M.end));return c(S,k)+C};let f=1/0;for(const[w,T]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const S=fo(pi,1,w,uo(T,t.blink));f=Math.min(f,S,S-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)},b=Math.max(g.left,g.right),v=ho*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:b,grounded:{left:g.left>=b-v,right:g.right>=b-v},fingertips:d,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:pi,browTopY:f,mouthY:co,faceX:e.facing*(no+io*At(t.turn))}}}function yo(e,t={}){return mo(po(e,t),e)}function Dc(e,t,n){return je({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function bo(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 wo(e,t,n={},i=0){const s=po(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?mo(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=k=>{e.save(),k(),e.restore()},d=k=>{k&&a&&c(()=>k(e,a,i,h))},u=()=>e.scale(s.facing,1),f=()=>{u(),e.translate(0,s.hipY),e.rotate(it(s.lean)),e.translate(0,-s.hipY)},m=(k,M,C)=>{if(l)return M?l.curve(k):l.line(k);if(s.classic){e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const x of k.slice(1))e.lineTo(x.x,x.y);e.stroke();return}Ye(e,k,C[0]*s.lineWidth,C[1]*s.lineWidth)},p=(k,M)=>m(ue(k,s.rubber),s.rubber>0,M),g=k=>{s.classic||m([s.legs[k].end,s.toes[k]],!1,Mc)},b=k=>{if(n.hands&&!s.classic)return w(k);if(s.classic||l)return;const M=s.arms[k].end;e.beginPath(),e.arc(M.x,M.y,Ac*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=go(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(k){const M=n.hands??{},C=s.arms[k].end,x=s.handTips[k],_=n.headFill??"#ffffff";Ue(e,C,M[k]??N,{side:k,angle:Math.atan2(x.x-C.x,C.y-x.y)*180/Math.PI,size:(M.size??lo)*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=k=>{c(()=>{f(),p(s.arms[k],Tc),b(k)});const M=o.sleeve;M&&a&&c(()=>M(e,a,k,i,h))},S=At(t.turn)>Ic;d(o.behind),c(()=>{u(),p(s.legs.left,oo),g("left"),p(s.legs.right,oo),g("right")}),S&&T("left"),c(()=>{f(),m(s.spine,s.spine.length>2,Sc);const{left:k,right:M}={left:s.arms.left.root,right:s.arms.right.root};if(k.x!==M.x)if(s.classic)m([k,M],!1,[1,1]);else{const C={x:(k.x+M.x)/2,y:k.y-.3*Math.abs(M.x-k.x)};m(Et(k,C,M,1,8),!0,[1.1,1.1])}}),d(o.body),S||T("left"),T("right"),d(o.behindHead),c(()=>{f(),e.translate(0,s.neckY),e.rotate(it(t.headTilt));const k=-s.headRy;e.beginPath(),e.ellipse(0,k,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,k,s.headRx,s.headRy);const C=l.nudge();e.translate(C.x,C.y)}else e.stroke();e.translate(0,k),e.scale(s.headRx/s.r,s.headRy/s.r),Lc(e,t,s.r,0,r,s.lineWidth)}),d(o.overHead),d(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 mi(e,t,n){const i={...e};let s=e.walking>0?Kt(i,Zr(e.walk,i),e.walking):i,r=Nc(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=Kt(s,a.pose,o),a.hands){const l=(h,c)=>c?Yt(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*Qr(t))}),{pose:s,hands:r}}function vo(e,t,n){return mi(e,t,n).pose}const fe=(e,t)=>`hand.${e}.${t}`;function Nc(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 Wc(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function Yc(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=mi(h,l,e.dance);o.translate(i/2,n),wo(o,c.pose,Wc({...t,rubber:h.rubber},c.hands),l)}}}function Kc(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=vo(s,t.time,e.figureDance),l=yo(a,{...i,rubber:s.rubber});return{pose:a,joints:bo(l,e.x+r+e.width/2,e.y+o+e.height)}}function qc(e,t){const n=[];return t.forEach((i,s)=>{const r=s===0?J:n[s-1],o=typeof i.pose=="string"?zr[i.pose]:{...r,...i.pose};n.push(i.expression?ui(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 gi=.5,yi={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 Ge(e){return typeof e!="string"?e:e in yi?yi[e]:K[e]}function Xc(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 bi=(e,t)=>(e%t+t)%t;function Uc(e,t,n,i){const s=Xc(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=bi(t,e.beats);let o=s.length-1;for(let f=0;f<s.length;f++)s[f].beat<=r&&(o=f);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,d=c>h?(r-h)/(c-h):0,u=z(l.easing??"ease-in-out")(Math.min(1,Math.max(0,d)));return{pose:Kt(a.pose,l.pose,u),hands:{left:Yt(a.left,l.left,u),right:Yt(a.right,l.right,u)}}}const Vc=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],zc=["lean","headTilt","lookX","spin"],jc=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function ko(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of Vc){const r=n&&jc.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of zc)t[i]=-e[i];return t}const Gc=e=>Math.min(1,Math.max(-1,(.5-e)*4));function So(e,t,n){const i=bi(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=Gc(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 To(e){const t={...J,...e.stance};return e.expression?ui(t,e.expression):t}function Jc(e){return{left:e.hands?.left?Ge(e.hands.left):N,right:e.hands?.right?Ge(e.hands.right):N}}function wi(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=Uc(i,n,To(e),Jc(e));return t.mirror?{pose:ko(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function Je(e,t,n={}){const i=typeof e=="string"?de[e]:e;let s;if(n.move)s=wi(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((d,u)=>d+u.beats,0),a=bi(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=wi(i,r[h],c),c<gi&&r.length>1&&t>=gi){const d=r[(h-1+r.length)%r.length],u=wi(i,d,d.beats+c),f=z("ease-in-out")(c/gi);s={pose:Kt(u.pose,s.pose,f),hands:{left:Yt(u.hands.left,s.hands.left,f),right:Yt(u.hands.right,s.hands.right,f)}}}}return{...s,pose:So(s.pose,i.groove,t)}}function Zc(e,t,n={}){return Je(e,t,n).pose}function vi(e){return(typeof e=="string"?de[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const Qc={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function Mo(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 d of l.taps??[])s.push({beat:c,tap:i?Qc[d]:d})}}function tu(e,t,n,i={}){const s=typeof e=="string"?de[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;Mo(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=vi(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const h of s.routine)Mo(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 eu(e,t,n=0){return(e-n)*t/6e4}function nu(e,t={}){return n=>Je(e,n,t)}function iu(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 su(e,t,n={}){const i=typeof t=="string"?de[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:vi(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),h=Array.from({length:l+1},(m,p)=>{const g=p/o;return{time:a+g*6e4/s,frame:Je(i,g,n)}}),c=(m,p)=>({id:`${e}-${m}`,target:e,property:m,keyframes:h.map(g=>({time:g.time,value:p(g.frame)}))}),u=Object.keys(J).filter(m=>h.some(p=>p.frame.pose[m]!==h[0].frame.pose[m])||h[0].frame.pose[m]!==J[m]).map(m=>c(m,p=>p.pose[m]));if(n.hands===!1)return u;const f=[];for(const m of["left","right"])for(const p of Object.keys(N)){const g=b=>b.hands?.[m]?.[p]??N[p];h.some(b=>g(b.frame)!==N[p])&&f.push(c(fe(m,p),g))}return[...u,...f]}const Ze={type:"back",mode:"out",overshoot:1.1},V="ease-out-cubic",ru={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:V,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:V},{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:V},{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}]},ou={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}]},au={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:V},{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:V},{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:V},{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:Ze},{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}]},lu={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:V},{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}]},hu={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:Ze,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:Ze},{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:Ze},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:V,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}]},cu={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:V},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:V},{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:V},{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:V}]}},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}]},uu={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}]},fu={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}]},du={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:V},{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:V},{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}]},pu={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}]},de={disco:ru,hipHop:ou,breaking:au,jazz:lu,kpop:hu,bollywood:cu,bhangra:uu,bharatanatyam:fu,charleston:du,tap:pu},Qe=e=>Math.min(1,Math.max(0,e));function mu(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 gu(e){return e-yu*Math.sin(2*Math.PI*e)/(2*Math.PI)}const yu=.5;function bu(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function Eo(e,t){const n=typeof e=="string"?en[e]:e,i=mu(n),s=Qe(t);let r=0;for(let d=0;d<i.length;d++)i[d].at<=s&&(r=d);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=Kt(o.pose,a.pose,z(a.easing??"ease-in-out")(Qe(l))),c=bu(n,s);return c===void 0?{...h,spin:0,rise:0}:{...h,spin:n.spin*gu(c),rise:4*n.height*c*(1-c)}}function Ao(e,t,n){const i=typeof e=="string"?en[e]:e,s=Qe(t),r=Qe((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function wu(e,t,n={}){const i=typeof t=="string"?en[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(c,d)=>{const u=d/o;return{time:s+u*r,progress:u,pose:Eo(i,u)}}),h=Object.keys(J).filter(c=>a.some(d=>d.pose[c]!==J[c])).map(c=>({id:`${e}-${c}`,target:e,property:c,keyframes:a.map(d=>({time:d.time,value:d.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(d=>({time:d.time,value:(n.x??0)+c*Ao(i,d.progress,n.height)}))})}return h}const vu={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},ku={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},tn={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},Su={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Tu={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:vu},{at:.27,pose:ku,easing:"ease-out-quad"},...s,{at:.76,pose:Su},{at:.86,pose:Tu,easing:"ease-out-quad"},{at:1,reset:!0}]}}const en={frontFlip:qt("Front flip (tuck)",360,.56,.35,[{at:.38,pose:tn,easing:"ease-out-cubic"},{at:.64,pose:tn}]),backFlip:qt("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...tn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...tn,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)},ki=.215,Si=.205,Mu=.065,xo=.035,Eu=.165,Au=.155,xu=12,Pu=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}}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 Po={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 _o(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-xo-(ki+Si)),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:Eu,width:[1.25,.9]},{length:Au,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:ki,width:[1.45,1.05]},{length:Si,width:[1.05,.85]},{length:Mu,width:[.95,.7]}]}),a=(l,h)=>l[h]??lt[h]??0;return{id:"human",hipHeight:ki+Si,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:xo,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,d]=h.id.split("."),u=p=>a(l,`${c}.${d}.${p}`);if(c==="arm")return[{swing:u("swing"),spread:u("spread")},{swing:u("elbow"),spread:u("bend")}];const f=(h.side??1)*u("rotate"),m=1-Math.cos(Pu(u("rotate")));return[{swing:u("swing"),spread:u("spread"),yaw:f},{swing:-u("knee"),spread:0,yaw:f},{swing:90+u("ankle")-m*(u("swing")-u("knee")),spread:0,yaw:(xu+u("toeOut"))*(h.side??1)}]},withAngles(l,h,c){const[d,u]=h.id.split("."),f=m=>`${d}.${u}.${m}`;return d==="arm"?{...l,[f("swing")]:c[0].swing,[f("spread")]:c[0].spread,[f("elbow")]:c[1].swing,[f("bend")]:c[1].spread}:d==="leg"?{...l,[f("swing")]:c[0].swing,[f("spread")]:c[0].spread,[f("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 _u(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 Cu={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Iu=Object.fromEntries(Object.entries(Q).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[Cu[n]??n,i]))]));function Hu(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 d=e[`${o}Hip`],u=e[`${o}Knee`],f=i+l*n;s[`leg.${a}.rotate`]=90*i,s[`leg.${a}.spread`]=0,s[`leg.${a}.swing`]=d*f,s[`leg.${a}.knee`]=u*f,s[`leg.${a}.ankle`]=-(e[`${o}Ankle`]??0),s[`leg.${a}.toeOut`]=(e[`${o}FootOut`]??0)*Ru,s[`eye.${a}`]=e[`${o}Eye`],s[`brow.${a}`]=e[`${o}Brow`],t&&Object.assign(s,$u(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 Ru=70;function $u(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 Co(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)Ro(e,h,i);e.restore()}function Ti(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 Io=150,Fu={pencil:44,eraser:30};function Mi(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},d=Io*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},f=K.pencilGrip,m=M=>{const C=M.fingers.thumb,x=M.fingers.index,_=M.fingers.middle,P=Ho([C.points[3],x.points[3],_.points[3]]),A=Ho([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(f,{size:d}),g=h-m(p).direction,b=Xe(f,{size:d,angle:g*180/Math.PI}),v=m(b),w=Fu[s]*a,T={x:v.pinch.x-Math.cos(h)*w,y:v.pinch.y-Math.sin(h)*w},S={x:u.x-T.x,y:u.y-T.y},k=b.axes.up;Lu(e,S,{x:-k.x,y:-k.y},d,n.arm??300*a,r,n.sleeve??"#5b7db1",o),Ue(e,S,f,{size:d,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"?Ti(e,{x:0,y:0},{angle:h*180/Math.PI,outline:o},i):Co(e,{x:0,y:0},{angle:h*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const Ho=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function Lu(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},h=i*.15,c=(p,g,b)=>({x:t.x+n.x*p+l.x*g*b,y:t.y+n.y*p+l.y*g*b}),d=c(s,0,0),u=p=>{const g=e.createLinearGradient(t.x,t.y,d.x,d.y);return g.addColorStop(0,p),g.addColorStop(.6,p),g.addColorStop(1,Nu(p)),g},f=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/Io),e.beginPath(),e.moveTo(c(-i*.1,-1,h).x,c(-i*.1,-1,h).y),e.lineTo(c(f+4,-1,h*1.1).x,c(f+4,-1,h*1.1).y),e.lineTo(c(f+4,1,h*1.1).x,c(f+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(f,-1,h*1.1).x,c(f,-1,h*1.1).y),e.moveTo(c(0,1,h).x,c(0,1,h).y),e.lineTo(c(f,1,h*1.1).x,c(f,1,h*1.1).y),e.stroke();const m=[c(f,-1,h*1.3),c(s,-1,h*1.5),c(s,1,h*1.5),c(f,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 Ou(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,b)=>({x:p.x+(g.x-p.x)*b,y:p.y+(g.y-p.y)*b}),d=a.find(p=>t>=p.start&&t<=p.end);if(d){const p=d.end-d.start,g=p>0?(t-d.start)/p:1;return{at:Ne(d.path,g),tool:l(d),lift:0,drawing:!0}}const u=[...a].reverse().find(p=>p.end<t),f=a.find(p=>p.start>t),m=p=>p.path[p.path.length-1];if(u&&f&&f.start-u.end<=o){const p=(t-u.end)/(f.start-u.end),g=p<.5?l(u):l(f);return{at:c(m(u),f.path[0],h(p)),tool:g,lift:Math.sin(Math.PI*p),drawing:!1}}if(f&&f.start-t<=s){const p=1-(f.start-t)/s;return{at:c(i,f.path[0],h(p)),tool:l(f),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 Bu(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 Du(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 d=e.sketch?We(a,e.sketch,h):void 0;c>0&&(d?e.smooth?d.curve(t,c):d.line(t,c):Ro(a,Wt(t,c))),o&&c>0&&c<1&&Mi(a,Ne(t,c),o,d)}}}function Nu(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 Ro(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 nn=1e5;function Wu(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 Ei(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(-nn,-nn,2*nn,2*nn),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 d=-(h.y-l.y)/c*r,u=(h.x-l.x)/c*r;o(()=>{e.moveTo(l.x+d,l.y+u),e.lineTo(h.x+d,h.y+u),e.lineTo(h.x-d,h.y-u),e.lineTo(l.x-d,l.y-u),e.closePath()})}}function Yu(e,t,n,i,s){e.save(),Ei(e,t,n,i),s(),e.restore()}function Ku(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(),Ei(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?Mi(r,h,{...i,tool:"eraser"}):Ti(r,h,s)}}}const wt=e=>e*Math.PI/180;function $o([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function Fo([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 Ai=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Lo=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],sn=(e,t)=>Fo($o(e,t.swing),t.spread);function xi(e,t){const n=pe(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function Pi(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 I=E.parent?a[E.parent]:void 0;if(E.parent&&!I)throw new Error(`body plan ${e.id}: chain ${E.id} comes before its parent ${E.parent}`);const H=E.at??(I?I.joints3.length-1:0),R=I?I.joints3[H]:o,$=I?I.frames[Math.max(0,H-1)]:{swing:0,spread:0},O=E.offset?Ai(R,sn(Lo(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((xt,hn)=>{const ge=B[hn]??{swing:0,spread:0};nt+=wt(ge.swing),kt+=wt(ge.spread)*L,X.push({swing:nt,spread:kt});const $i=pe(sn(E.rest,{swing:nt,spread:kt}),wt(ge.yaw??0));D.push(Ai(D[hn],Lo($i,xt.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],d=e.head.size/2*i,u=d*h.sx,f=d*h.sy,m=E=>sn(pe($o(Fo(E,-wt(h.tilt)),-wt(h.nod)),wt(h.yaw)),c),p=Ai(l.joints3[l.joints3.length-1],m([0,f,0])),g={};for(const E of e.chains){const{joints3:I,frames:H}=a[E.id],R=I.map($=>xi($,s));g[E.id]={id:E.id,joints3:I,frames:H,points:R.map($=>$.point),depths:R.map($=>$.depth)}}const b=xi(p,s),v=[[1,0,0],[0,1,0],[0,0,1]].map(E=>pe(m(E),s)),w=xi(o,s).point,T=wt(t.roll??0),S=E=>{const I=E.x-w.x,H=E.y-w.y;return{x:w.x+I*Math.cos(T)-H*Math.sin(T),y:w.y+I*Math.sin(T)+H*Math.cos(T)}},k=([E,I,H])=>[E*Math.cos(T)+I*Math.sin(T),-E*Math.sin(T)+I*Math.cos(T),H];for(const E of Object.values(g))E.points=E.points.map(S);const M={center:S(b.point),depth:b.depth,rx:u,ry:f,angle:0,axes:v.map(k)},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]*f,y:M.center.y-C[1]*f};const I=g[E.chain];return I.points[Math.min(E.joint,I.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(S(w)),contacts:A,groundY:Math.max(...A.map(E=>E.point.y))}}function Oo(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 rn=e=>e*180/Math.PI,Xt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],_i=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],me=e=>Math.hypot(e[0],e[1],e[2]),Ci=e=>{const t=me(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},on=e=>Math.atan2(Math.sin(e),Math.cos(e));function Bo(e){const[t,n,i]=Ci(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function qu(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=Pi(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])),d=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),f=Math.min(h+c-1e-6,Math.max(Math.abs(h-c)+1e-6,me(u))),m=Ci(u),p=r.parent!==null,g=sn(r.pole??(p?[0,-.35,-1]:[0,0,1]),d);let b=Xt(g,[m[0]*_i(g,m),m[1]*_i(g,m),m[2]*_i(g,m)]);me(b)<1e-6&&(b=pe([1,0,0],0)),b=Ci(b);const v=(h*h+f*f-c*c)/(2*h*f),w=Math.sqrt(Math.max(0,1-v*v)),T=[l[0]+h*(v*m[0]+w*b[0]),l[1]+h*(v*m[1]+w*b[1]),l[2]+h*(v*m[2]+w*b[2])],S=[l[0]+m[0]*f,l[1]+m[1]*f,l[2]+m[2]*f],k=r.side??1,M=Bo(Xt(T,l)),C=Bo(Xt(S,T)),x=[{swing:rn(on(M.swing-d.swing)),spread:rn(on(M.spread-d.spread))*k},{swing:rn(on(C.swing-M.swing)),spread:rn(on(C.spread-M.spread))*k}];return e.withAngles(t,r,x)}const Xu=.34,vt=.12,ht=-.4,ut=(e,t,n)=>e[t]??n,Uu=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Vu=.45,zu=.35,ju=.7;function an(e,t,n){const i=f=>Math.sqrt(Math.max(0,1-f.x*f.x-f.y*f.y)),s=Oo(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(zu,Math.abs(a)),c=l*Math.max(ju,Math.abs(a)),d=Math.cos(e.angle),u=Math.sin(e.angle);return{facing:s,points:t.map(f=>{const m=Vu*Math.sin(o)+n.x*h+(f.x-n.x)*c,p=f.y+r[1]*i(f),g=m*e.rx,b=p*e.ry;return{x:e.center.x+g*d+b*u,y:e.center.y+g*u-b*d}})}}const ln=(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}}),Do=.05;function Gu(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(b,v)=>an(t,b,v).points,o=(b,v)=>an(t,[],{x:b,y:v}).facing,a=ut(n,"smile",0),l=ut(n,"blink",0),h=ut(n,"lookX",0),c=ut(n,"lookY",0),d=ut(n,"browTilt",0);for(const b of[1,-1]){const v=b===1?"left":"right",w=Xu*b;if(o(w,vt)<Do)continue;const T={x:w,y:vt},S=Uu(ut(n,`eye.${v}`,1),l);if(S<.2){const x=a>.5?.12:-.06;e.line(r(ln({x:w-.12,y:vt},{x:w,y:vt+x},{x:w+.12,y:vt}),T),s)}else{if(S>1.2){const A=.13*S;e.shape(r(Ii(w,vt,A*.85,A),T),"#ffffff",s)}const x=S>1.2?.075:.1,_=w+h*.08,P=vt-c*.07;e.shape(r(Ii(_,P,x,x*1.1*Math.min(S,1)),T),e.ink,0)}const k=vt+.3+ut(n,`brow.${v}`,0)*.14+Math.max(0,S-1)*.12,M={x:w+b*.13,y:k},C={x:w-b*.13,y:k+d*.1};e.line(r([M,{x:(M.x+C.x)/2,y:(M.y+C.y)/2},C],{x:w,y:k}),s)}const u={x:0,y:ht};if(o(0,ht)<-Do)return;const f=.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(ln({x:-f,y:ht},{x:0,y:ht-a*.25},{x:f,y:ht}),u),s);return}const p=.3*m;let g;if(a>.3){const b=ht+.05;g=[...ln({x:f,y:b},{x:0,y:ht-p*2},{x:-f,y:b})]}else if(a<-.3){const b=ht-p*.6;g=[...ln({x:f,y:b},{x:0,y:ht+p*1.4},{x:-f,y:b})]}else g=Ii(0,ht,f*.8,p);e.shape(r(g,u),e.ink,0)}function Ju(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??_o({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 Zu(e,t,n,i){const{point:s,facing:r}=Oo(e,[t,n,i]);return{point:s,facing:r}}const Hi=e=>e.rest[1]<-.5,Qu=.3;function tf(e,t,n){return e.figure==="stick"?Hi(t)?n.slice(0,3):n:Hi(t)&&n.length>=3?Et(n[0],n[1],n[2],Qu):n.length===3?Et(n[0],n[1],n[2],1):n}function Ri(e,t){const n=e.plan.id==="human"?{...lt,...t}:t,i=Pi(e.plan,n,{height:e.height,contact:e.contact}),s={},r={},o={},a=.01*e.height;e.plan.chains.forEach(f=>{const m=i.chains[f.id];s[f.id]=m.points;const p=m.depths.reduce((w,T)=>w+T,0)/m.depths.length,g=f.parent?i.chains[f.parent]:void 0,b=g?g.depths[f.at??g.depths.length-1]:0,v=p-b;o[f.id]=Math.abs(v)<a?0:v,r[f.id]={points:tf(e,f,m.points),depth:p}}),r.head={points:[i.head.center],depth:i.head.depth},o.head=0;const l=[...e.plan.chains.map(f=>f.id),"head"],h=[...l].sort((f,m)=>o[f]-o[m]||l.indexOf(f)-l.indexOf(m)),c={hip:i.hip};for(const[f,[m,p]]of Object.entries(e.plan.landmarks??{})){const g=i.chains[m]?.points;g&&(c[f]=g[Math.min(p,g.length-1)])}const d={};for(const[f,m]of Object.entries(c))d[f]=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:d};return{skeleton:i,joints:u,order:h}}function No(e,t){return Ri(e,t).joints}function ef(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=an(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(an(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 nf(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:f}=i,m=n.skin==="none"?null:n.skin;t.ellipse(f.center.x,f.center.y,f.rx,f.ry,f.angle,m,o),t.look!=="silhouette"&&Gu(t,f,r,o);return}const a=n.plan.chains.find(f=>f.id===s),l=i.chains[s],h=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const f=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:h;t.line(f,o);return}const c=(f,m)=>[a.bones[f].width[0]*o,a.bones[m].width[1]*o];if(Hi(a)){const[f,m]=c(0,1);if(t.limb(h,f,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."))sf(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 f=i.points["hip.left"],m=i.points["hip.right"];f&&m&&Math.hypot(f.x-m.x,f.y-m.y)>.5&&t.limb([f,m],o*1.3,o*1.3);const[p,g]=c(0,a.bones.length-1);t.limb(h,p,g);const b=i.points["shoulder.left"],v=i.points["shoulder.right"];b&&v&&Math.hypot(b.x-v.x,b.y-v.y)>.5&&t.limb(Et(b,l[l.length-1],v,1,10),o*1.15,o*1.15);return}const[d,u]=c(0,a.bones.length-1);t.limb(h,d,u)}function Wo(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 sf(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,Wo(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 Yo(e,t,n,i=0){const s=t.plan.id==="human"?{...lt,...n}:n,{joints:r,order:o}=Ri(t,s),a=li(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&&ef(a,t,r),l(t.layers.behind);for(const h of o){const c=t.layers.parts?.[h];l(c?.under),nf(e,a,t,r,h,s),l(c?.over)}l(t.layers.front),e.restore()}function rf(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 of(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}=Ri(e,s),a=Pi(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,d=a.hip.x+h*Math.cos(-l)-c*Math.sin(-l),u=a.hip.y+h*Math.sin(-l)+c*Math.cos(-l),f=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],p=Math.cos(f),g=Math.sin(f);r=[d*p-m*g,-u,d*g+m*p]}return qu(e.plan,s,n,r,{height:e.height})}function af(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),Yo(r,t,o.props,a)}}}function Ko(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 lf(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=No(i,s);return{pose:s,joints:Ko(a,e.x+r+e.width/2,e.y+o+e.height)}}function hf(e,t,n=lt){const i=[];return t.forEach((r,o)=>{const a=o===0?n:i[o-1],l=typeof r.pose=="string"?Po[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 cf=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function uf(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],d=h[h.length-1],u={x:c.x-(d.x-c.x)*.25,y:c.y-(d.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,d=c[0],u=a.chains.spine[a.chains.spine.length-1],m=[{x:d.x+(u.x-d.x)*.45,y:d.y+(u.y-d.y)*.45},...cf(c,0,.45)],p=le(m,a.height*.085,a.height*.06),g=m.length,b=p.slice(0,g),v=p.slice(g).reverse();l.shape(p,t,0);const w=k=>Math.hypot(k[1].x-u.x,k[1].y-u.y),[T,S]=w(b)>w(v)?[b,v]:[v,b];l.line(T.slice(1),i(a)),l.line(S.slice(Math.ceil(g*.45)),i(a)),l.line([b[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 ff(e){const{timeline:t}=e,n=new Mt;for(const[h,c]of Object.entries(e.targets)){const d=typeof c=="string"?document.querySelector(c):c;if(!d)throw new Error(`quickPlay: no element found for target "${h}" (${String(c)})`);n.registerTarget(h,d)}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 df={timeline:yl,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}},pf=j.to,mf=j.from,gf=j.fromTo,yf=j.set,bf=j.timeline,wf=j.ticker,vf=j.splitText,kf=j.context,Sf=j.matchMedia,Tf=j.quickTo,Mf=j.imageSequence,Ef=j.pageTransition;Wh(),y.Clock=Uo,y.CompatTimeline=Tt,y.CustomBounce=kr,y.CustomEase=vr,y.CustomWiggle=Sr,y.DANCE_STYLES=de,y.DEFAULT_BAKE_INTERVAL_MS=Mn,y.DEFAULT_INERTIA_FRICTION=pn,y.DEFAULT_LABELS=Ir,y.DEFAULT_SPRING=Z,y.DEFAULT_TRANSITION=Kh,y.Draggable=qn,y.EXPRESSIONS=Q,y.FINGERS=Kr,y.FLIPS=en,y.FORMAT_VERSION=Vt,y.HAND_REST=N,y.HAND_SHAPES=K,y.HUMAN_EXPRESSIONS=Iu,y.HUMAN_POSES=Po,y.HUMAN_REST=lt,y.INERTIA_MAX_DURATION_MS=Oi,y.InertiaTrackPlayer=ws,y.LiveTimeline=at,y.MORPH_SAMPLES=pa,y.MUDRAS=yi,y.ManualClock=Xo,y.MediaSync=si,y.Observer=Js,y.POSES=zr,y.REST_POSE=J,y.SPRING_MAX_DURATION_MS=dn,y.SPRING_PRESETS=ke,y.SPRING_STEP_MS=_t,y.ScrollAnimator=dr,y.ScrollDriver=re,y.ScrollMarkers=pr,y.ScrollPin=hr,y.SmoothScroll=ei,y.SpringSampler=jt,y.SpringTrackPlayer=bs,y.Stage=Xs,y.Timeline=Cn,y.TinyflyPlayer=Be,y.TinyflySequencer=Dr,y.TrackPlayer=Pe,y.ValueResolver=La,y.VisibilityDriver=lr,y.applyGroove=So,y.backOut=Vi,y.bakeDanceTracks=su,y.bakeEasing=xn,y.bakeInertiaTrack=An,y.bakeSpringTrack=En,y.basicOutfit=uf,y.beatAt=eu,y.beatAtTime=Ie,y.beatLength=Ln,y.beatTime=Ce,y.beatsBetween=za,y.bindChoiceHotspots=Fr,y.blendPose=Kt,y.boilFrame=oi,y.bounceOut=Ui,y.character=Ju,y.characterAt=lf,y.characterHandPose=Wo,y.characterJoints=No,y.characterPoseTracks=hf,y.characterTarget=af,y.charactersFor=vs,y.circlePath=Bu,y.clamp01=Jn,y.clearMorphCache=Ta,y.clearPathCache=ha,y.clipErased=Ei,y.containerProgressAt=Zn,y.context=kf,y.create=Ah,y.createControls=Rr,y.createCubicBezier=qi,y.createLive=Er,y.createPen=li,y.createRandom=_e,y.createTrack=xe,y.criticalDamping=jo,y.customBounce=Is,y.customEase=Cs,y.customWiggle=Hs,y.danceFrame=Je,y.dancePose=Zc,y.danceStance=To,y.danceTaps=tu,y.danceTracks=iu,y.dancer=nu,y.deserializeTimeline=Ft,y.deserializeTrack=Ms,y.detectTempo=ja,y.draggable=Dl,y.drawCartoonHand=Ue,y.drawCharacter=Yo,y.drawEraser=Ti,y.drawHand=Mi,y.drawPencil=Co,y.drawStickFigure=wo,y.drawnPathTarget=Du,y.easeIn=Wi,y.easeInCubic=mn,y.easeInOut=Ki,y.easeInOutCubic=Jt,y.easeInOutQuad=Ni,y.easeInQuad=Bi,y.easeOut=Yi,y.easeOutCubic=gn,y.easeOutQuad=Di,y.elasticOut=Xi,y.ellipsePoints=ai,y.erasable=Ku,y.expandParametricEasings=gs,y.flipPose=Eo,y.flipTracks=wu,y.flipTravel=Ao,y.from=mf,y.fromJSON=Ra,y.fromTo=gf,y.getEasingFunction=z,y.getInterpolator=ee,y.getMotionPathPoint=Pn,y.getPathLength=ca,y.getPointAtProgress=Zi,y.gridLinesFor=tr,y.handAt=Ou,y.handJoints=Xe,y.handJointsAt=Ur,y.handPose=W,y.handProp=fe,y.hasKeyframes=Fi,y.hashSeed=Rn,y.headPoint=Dc,y.humanFieldLabel=_u,y.humanPlan=_o,y.humanPose=tt,y.imageSequence=Mf,y.inertiaDuration=It,y.inertiaRest=Ct,y.inertiaValueAt=Te,y.inertiaVelocityAt=Qo,y.interpolateArray=ds,y.interpolateColor=fs,y.interpolateMotionPath=Pa,y.interpolateNumber=st,y.interpolatePathString=ps,y.interpolateString=Tn,y.isCubicBezierEasing=Pt,y.isInertiaTrack=ft,y.isMotionPathPoint=qo,y.isMotionPathTrack=cn,y.isParametricEasing=Ut,y.isPathData=Rt,y.isSpringTrack=dt,y.isTextTrack=ye,y.isUnderdamped=zo,y.isUnresolved=Fa,y.jointsInScene=Ko,y.jointsToScene=bo,y.linear=Me,y.live=j,y.mapEase=ne,y.matchMedia=Sf,y.maxStaggerDistance=fn,y.mirrorPose=ko,y.mixHandPoses=Yt,y.mixPoses=rf,y.morphPath=rs,y.mount=Lr,y.mountAll=Br,y.narrationMarkers=qa,y.narrationSceneAt=Xa,y.naturalRest=Gt,y.nearestBeat=Ua,y.nextBeat=Va,y.pageTransition=Ef,y.parametricEasing=ji,y.parseEdge=jn,y.parsePath=St,y.parseTrigger=Gn,y.partialPath=Wt,y.pathLength=Nr,y.planNarration=Ka,y.play=Eh,y.playSequence=Yh,y.playWhenVisible=Zl,y.playheadCrossings=In,y.pointAlong=Ne,y.pointAtDistance=bn,y.pointOnHead=Zu,y.pointsToPath=$s,y.pose=U,y.poseTracks=qc,y.quickPlay=ff,y.quickTo=Tf,y.randomBetween=$n,y.randomChoice=$a,y.randomSnapped=As,y.reachCharacter=of,y.resolveSequence=_s,y.resolveStickFrame=mi,y.resolveStickPose=vo,y.resolveValue=Fn,y.rotateAbout=bt,y.routineBeats=vi,y.rubberLimb=Et,y.scrollProgress=Jl,y.scrubOnScroll=nh,y.scrubPath=Wu,y.seatHeight=$c,y.serializeTimeline=Es,y.serializeTrack=Ss,y.set=yf,y.shapeToPathData=He,y.simplifyKeyframes=ys,y.sketchPen=We,y.smoothToward=ar,y.snapAxis=Qs,y.snapConfig=cr,y.snapDuration=fr,y.snapProgress=ur,y.splitText=vf,y.springDuration=Li,y.springValueAt=Vo,y.staggerDistance=un,y.staggerOffset=be,y.staggerOffsets=we,y.staggerSpan=zt,y.stepsEasing=zi,y.stickFigureAt=Kc,y.stickFigureJoints=yo,y.stickFigureTarget=Yc,y.stickToHuman=Hu,y.strideLength=mc,y.syncMediaElement=Cr,y.talkingMouth=Qr,y.taperedLine=Ye,y.taperedOutline=le,y.textAt=ks,y.tf=df,y.ticker=wf,y.timeline=bf,y.to=pf,y.toJSON=Ha,y.toKeyframedTrack=Aa,y.toKeyframedTracks=xa,y.trackTargets=gt,y.triggerDistance=Ot,y.unmount=Dh,y.walkPose=Zr,y.withErased=Yu,y.withExpression=ui,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));