@algorisys/tinyfly 0.79.0 → 0.82.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,2 +1,2 @@
1
- (function(l,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(l=typeof globalThis<"u"?globalThis:l||self,q(l.tinyfly={}))})(this,(function(l){"use strict";function q(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function st(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const G=1;function it(t){return t.property==="text"&&"textConfig"in t}function X(t){return t.kind==="inertia"&&"inertia"in t}function x(t){return t.kind==="spring"&&"spring"in t}function yt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function Qe(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function Ht(t){return"keyframes"in t}class Ze{_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(e){this._currentTime+=e,this.onTick?.(e,this._currentTime)}reset(){this._currentTime=0}seek(e){this._currentTime=e}}class Je{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(e={}){this._speed=e.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(e){this._speed=e}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(e){this._currentTime=e}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(e){if(this._isRunning){if(this._lastFrameTime!==null){const r=(e-this._lastFrameTime)*this._speed;this._currentTime+=r,this.onTick?.(r,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function _t(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const r=Math.max(0,Math.min(e-1,n));return Math.abs(t-r)}switch(n){case"end":return e-1-t;case"center":return Math.abs(t-(e-1)/2);case"edges":return(e-1)/2-Math.abs(t-(e-1)/2);default:return t}}function qt(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,_t(r,t,e));return n}function Mt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=_t(t,e,r);if(n.amount!==void 0){const i=qt(e,r);return i===0?0:n.amount*s/i}return n.each!==void 0?n.each*s:0}function Kt(t,e){return Array.from({length:t},(n,r)=>Mt(r,t,e))}function at(t,e){return t<=1?0:Math.max(...Kt(t,e))}const K=1,Tt=6e4,ot=Tt/K,$={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},tn={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 Q{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(e){this.from=e.from,this.to=e.to,this.stiffness=e.stiffness??$.stiffness,this.damping=e.damping??$.damping,this.mass=e.mass??$.mass,this.restDelta=e.restDelta??$.restDelta,this.restSpeed=e.restSpeed??$.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??$.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(e){return Math.abs(e-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(e){if(e<=0)return this.from;const n=Math.floor(e/K);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const r=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],i=e/K-n;return r+(s-r)*i}settleTime(){return this.simulateTo(ot+1),this.settledStep!==null?this.settledStep*K:Tt}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,ot+1),r=K/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],i=s-this.to,a=-this.stiffness*i,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*r;const u=s+this.velocity*r;if(this.samples.push(u),this.isAtRest(u)){this.settledStep=this.samples.length-1;return}}this.samples.length>ot&&(this.settledStep=ot)}}function en(t,e){return new Q(t).valueAt(e)}function nn(t){return new Q(t).settleTime()}function rn(t){const e=t.stiffness??$.stiffness,n=t.damping??$.damping,r=t.mass??$.mass;return n<2*Math.sqrt(e*r)}function sn(t){const e=t.stiffness??$.stiffness,n=t.mass??$.mass;return 2*Math.sqrt(e*n)}const bt=4,an=.002,on=1e-4,Wt=6e4;function ct(t){const e=t.friction??bt;return e>0?e:bt}function jt(t){return t.from+t.velocity/ct(t)}function cn(t,e){if(e===void 0)return t;if(typeof e=="number")return e>0?Math.round(t/e)*e:t;if(e.length===0)return t;let n=e[0];for(const r of e)Math.abs(r-t)<Math.abs(n-t)&&(n=r);return n}function Z(t){let e=cn(jt(t),t.end);return t.min!==void 0&&(e=Math.max(t.min,e)),t.max!==void 0&&(e=Math.min(t.max,e)),e}function J(t){const e=Math.abs(Z(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(on,e*an);if(n>=e)return 0;const r=Math.log(e/n)/ct(t);return Math.min(Wt,r*1e3)}function ut(t,e){if(e<=0)return t.from;const n=Z(t);if(e>=J(t))return n;const r=ct(t);return t.from+(n-t.from)*(1-Math.exp(-r*e/1e3))}function un(t,e){const n=ct(t),r=Z(t);return e>=J(t)?0:(r-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const lt=t=>t,Bt=t=>t*t,Gt=t=>1-(1-t)*(1-t),Qt=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,kt=t=>t*t*t,St=t=>1-Math.pow(1-t,3),Pt=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,Zt=kt,Jt=St,te=Pt,ln={linear:lt,"ease-in":Zt,"ease-out":Jt,"ease-in-out":te,"ease-in-quad":Bt,"ease-out-quad":Gt,"ease-in-out-quad":Qt,"ease-in-cubic":kt,"ease-out-cubic":St,"ease-in-out-cubic":Pt};function ee(t){const[e,n,r,s]=t,i=3*e,a=3*(r-e)-i,o=1-i-a,c=3*n,u=3*(s-n)-c,h=1-c-u,f=p=>((o*p+a)*p+i)*p,g=p=>((h*p+u)*p+c)*p,d=p=>(3*o*p+2*a)*p+i,T=p=>{let m=p;for(let b=0;b<8;b++){const S=f(m)-p;if(Math.abs(S)<1e-7)return m;const y=d(m);if(Math.abs(y)<1e-7)break;m-=S/y}let _=0,M=1;for(m=p;_<M;){const b=f(m);if(Math.abs(b-p)<1e-7)return m;p>b?_=m:M=m,m=(_+M)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=T(p);return g(m)}}function At(t,e="out"){if(e==="out")return t;const n=r=>1-t(1-r);return e==="in"?n:r=>r<.5?n(r*2)/2:t(r*2-1)/2+.5}function ne(t=1,e=.3){const n=Math.max(1,t),r=e/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-r)*(2*Math.PI)/e)+1}const re=t=>{if(t<=0)return 0;if(t>=1)return 1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const s=t-.5454545454545454;return 7.5625*s*s+.75}if(t<2.5/2.75){const s=t-.8181818181818182;return 7.5625*s*s+.9375}const r=t-2.625/2.75;return 7.5625*r*r+.984375};function se(t=1.70158){return e=>{if(e<=0)return 0;if(e>=1)return 1;const n=e-1;return n*n*((t+1)*n+t)+1}}function ie(t,e="end"){const n=Math.max(1,Math.floor(t));return r=>{if(r>=1)return 1;if(r<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const s=Math.floor(r*n);switch(e){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 ae(t){switch(t.type){case"steps":return ie(t.count,t.position);case"elastic":return At(ne(t.amplitude,t.period),t.mode);case"bounce":return At(re,t.mode);case"back":return At(se(t.overshoot),t.mode)}}function vt(t){return t===void 0?lt:q(t)?ee(t.points):st(t)?ae(t):ln[t]??lt}const oe=32,hn=256,W=new Map,fn=/[MmLlHhVvCcSsQqTtAaZz]/,dn=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,gn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function pn(t){const e=[];let n=0,r=null;const s=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(s(),!(n>=t.length));){const i=t[n];if(fn.test(i)){r={type:i,args:[]},e.push(r),n++;continue}if(!r)break;const a=r.type==="A"||r.type==="a",o=r.args.length%7;if(a&&(o===3||o===4)){if(i!=="0"&&i!=="1")break;r.args.push(i==="1"?1:0),n++;continue}const c=dn.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function mn(t,e,n,r,s,i,a,o,c){if(t===o&&e===c)return[];let u=Math.abs(n),h=Math.abs(r);if(u===0||h===0)return[[t,e,o,c,o,c]];const f=s*Math.PI/180,g=Math.cos(f),d=Math.sin(f),T=(t-o)/2,p=(e-c)/2,m=g*T+d*p,_=-d*T+g*p,M=m*m/(u*u)+_*_/(h*h);if(M>1){const v=Math.sqrt(M);u*=v,h*=v}const b=i===a?-1:1,S=u*u*h*h-u*u*_*_-h*h*m*m,y=u*u*_*_+h*h*m*m,P=b*Math.sqrt(Math.max(0,S/y)),k=P*u*_/h,F=-P*h*m/u,gt=g*k-d*F+(t+o)/2,A=d*k+g*F+(e+c)/2,C=(v,D,E,B)=>{const zt=v*E+D*B,mt=Math.sqrt((v*v+D*D)*(E*E+B*B)),rt=Math.acos(Math.max(-1,Math.min(1,zt/mt)));return v*B-D*E<0?-rt:rt},R=C(1,0,(m-k)/u,(_-F)/h);let I=C((m-k)/u,(_-F)/h,(-m-k)/u,(-_-F)/h);!a&&I>0&&(I-=2*Math.PI),a&&I<0&&(I+=2*Math.PI);const H=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),Yt=I/H,pt=4/3*Math.tan(Yt/4),je=v=>{const D=u*Math.cos(v),E=h*Math.sin(v);return[g*D-d*E+gt,d*D+g*E+A]},Be=v=>{const D=-u*Math.sin(v),E=h*Math.cos(v);return[g*D-d*E,d*D+g*E]},Ge=[];for(let v=0;v<H;v++){const D=R+v*Yt,E=D+Yt,[B,zt]=je(D),[mt,rt]=v===H-1?[o,c]:je(E),[lr,hr]=Be(D),[fr,dr]=Be(E);Ge.push([B+pt*lr,zt+pt*hr,mt-pt*fr,rt-pt*dr,mt,rt])}return Ge}function U(t,e,n,r,s){const i=1-s;return i*i*i*t+3*i*i*s*e+3*i*s*s*n+s*s*s*r}function ce(t,e,n,r,s){const i=1-s;return 3*i*i*(e-t)+6*i*s*(n-e)+3*s*s*(r-n)}function tt(t,e,n,r){return{subpath:0,type:"L",points:[n,r],startX:t,startY:e,endX:n,endY:r,length:Math.hypot(n-t,r-e)}}function ht(t,e,n){const[r,s,i,a,o,c]=n,u=[0];let h=t,f=e,g=0;for(let d=1;d<=oe;d++){const T=d/oe,p=U(t,r,i,o,T),m=U(e,s,a,c,T);g+=Math.hypot(p-h,m-f),u.push(g),h=p,f=m}return{subpath:0,type:"C",points:[r,s,i,a,o,c],startX:t,startY:e,endX:o,endY:c,length:g,lengths:u}}function z(t){const e=W.get(t);if(e)return e;const n=[];let r=0,s=0,i=0,a=0,o=null,c=null,u=-1;const h=new Set,f=p=>{u<0&&(u=0),p.subpath=u,n.push(p)};for(const{type:p,args:m}of pn(t)){const _=p.toUpperCase(),M=p!==_,b=gn[_];if(_==="Z"){(r!==i||s!==a)&&f(tt(r,s,i,a)),u>=0&&h.add(u),r=i,s=a,o=c=null;continue}for(let S=0;S+b<=m.length;S+=b){const y=m.slice(S,S+b),P=M?r:0,k=M?s:0;let F=null,gt=null;switch(_){case"M":S===0?(r=y[0]+P,s=y[1]+k,i=r,a=s,(u<0||n[n.length-1]?.subpath===u)&&u++):(f(tt(r,s,y[0]+P,y[1]+k)),r=y[0]+P,s=y[1]+k);break;case"L":f(tt(r,s,y[0]+P,y[1]+k)),r=y[0]+P,s=y[1]+k;break;case"H":f(tt(r,s,y[0]+P,s)),r=y[0]+P;break;case"V":f(tt(r,s,r,y[0]+k)),s=y[0]+k;break;case"C":{const A=[y[0]+P,y[1]+k,y[2]+P,y[3]+k,y[4]+P,y[5]+k];f(ht(r,s,A)),F=[A[2],A[3]],r=A[4],s=A[5];break}case"S":{const[A,C]=o?[2*r-o[0],2*s-o[1]]:[r,s],R=[A,C,y[0]+P,y[1]+k,y[2]+P,y[3]+k];f(ht(r,s,R)),F=[R[2],R[3]],r=R[4],s=R[5];break}case"Q":case"T":{let A=r,C=s;_==="Q"?(A=y[0]+P,C=y[1]+k):c&&(A=2*r-c[0],C=2*s-c[1]);const R=_==="Q"?y[2]+P:y[0]+P,I=_==="Q"?y[3]+k:y[1]+k;f(ht(r,s,[r+2/3*(A-r),s+2/3*(C-s),R+2/3*(A-R),I+2/3*(C-I),R,I])),gt=[A,C],r=R,s=I;break}case"A":{const A=y[5]+P,C=y[6]+k;let R=r,I=s;for(const H of mn(r,s,y[0],y[1],y[2],y[3],y[4],A,C))f(ht(R,I,H)),R=H[4],I=H[5];r=A,s=C;break}}o=F,c=gt}}const g=n.reduce((p,m)=>p+m.length,0),d=[];for(let p=0;p<n.length;){const m=n[p].subpath;let _=p,M=0;for(;_<n.length&&n[_].subpath===m;)M+=n[_++].length;const b=n[p],S=n[_-1],y=h.has(m)||Math.abs(S.endX-b.startX)<1e-9&&Math.abs(S.endY-b.startY)<1e-9;d.push({start:p,end:_,length:M,closed:y}),p=_}const T={segments:n,totalLength:g,subpaths:d};return W.size>=hn&&W.delete(W.keys().next().value),W.set(t,T),T}function yn(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let r=0,s=n.length-1;for(;r<s-1;){const o=r+s>>1;n[o]<e?r=o:s=o}const i=n[s]-n[r],a=i>0?(e-n[r])/i:0;return(r+a)/(n.length-1)}function _n(t,e){if(t.type==="L"){const f=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*f,y:t.startY+(t.endY-t.startY)*f,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,r,s,i,a,o]=t.points,c=yn(t,e);let u=ce(t.startX,n,s,a,c),h=ce(t.startY,r,i,o,c);if(Math.hypot(u,h)<1e-9){const f=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),g=U(t.startX,n,s,a,f),d=U(t.startY,r,i,o,f),T=U(t.startX,n,s,a,c),p=U(t.startY,r,i,o,c);u=c<.5?g-T:T-g,h=c<.5?d-p:p-d}return{x:U(t.startX,n,s,a,c),y:U(t.startY,r,i,o,c),angle:Math.atan2(h,u)*180/Math.PI}}function wt(t,e,n=0,r=t.length){if(r<=n)return{x:0,y:0,angle:0};let s=0;for(let i=n;i<r;i++){const a=t[i];if(s+a.length>=e||i===r-1)return _n(a,e-s);s+=a.length}return{x:0,y:0,angle:0}}function ue(t,e){const{segments:n,totalLength:r}=z(t);return wt(n,Math.max(0,Math.min(1,e))*r)}function Mn(){W.clear()}function Tn(t){return z(t).totalLength}const bn=24,kn=320,Sn=2.5,et=72,Pn=64,An=.2,vn=128,nt=new Map;let ft=0,V;const le=t=>Math.round(t*100)/100;function he(t,e){const{segments:n,subpaths:r,totalLength:s}=z(t);if(n.length===0)return[];if(e){const i=r.every(a=>a.closed);return[{segments:n,start:0,end:n.length,length:s,closed:i}]}return r.filter(i=>i.length>0).map(i=>({segments:n,start:i.start,end:i.end,length:i.length,closed:i.closed}))}function Rt(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),r=wt(t.segments,n*t.length,t.start,t.end);return[r.x,r.y]}function fe(t){const e=[];let n=0;for(let r=t.start;r<t.end;r++)n+=t.segments[r].length,t.length>0&&e.push(n/t.length);return e}function de(t,e){const n=[];for(let r=0;r<e;r++)n.push(Rt(t,t.closed?r/e:r/(e-1)));return n}function ge(t){let e=0,n=0;for(const[r,s]of t)e+=r,n+=s;return e/=t.length,n/=t.length,t.map(([r,s])=>[r-e,s-n])}function wn(t,e,n){const r=t.closed&&e.closed;if(n!==void 0)return{offset:r?Math.abs(n)%et/et:0,reversed:n<0};const s=ge(de(t,et)),i=ge(de(e,et)),a=et;let o={offset:0,reversed:!1},c=1/0;for(const u of[!1,!0]){const h=r?a:1;for(let f=0;f<h;f++){let g=0;for(let d=0;d<a&&g<c;d++){const T=r?u?(f-d+a)%a:(d+f)%a:u?a-1-d:d,p=s[d][0]-i[T][0],m=s[d][1]-i[T][1];g+=p*p+m*m}g<c&&(c=g,o={offset:r?f/a:0,reversed:u})}}return o}function Rn(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function In(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function Dn(t,e,n){const r=t.closed&&e.closed,s=wn(t,e,n.shapeIndex),i=Math.max(bn,Math.min(kn,Math.ceil(Math.max(t.length,e.length)/Sn))),a=new Set,o=f=>a.add(Math.round(f*1e7)/1e7);for(let f=0;f<=i;f++)o(f/i);for(const f of fe(t))o(f);for(const f of fe(e))o(In(f,s,r));let c=[...a].sort((f,g)=>f-g);r&&(c=c.filter(f=>f<1));const u=[],h=[];for(const f of c)u.push(...Rt(t,f)),h.push(...Rt(e,Rn(f,s,r)));return Cn({from:u,to:h,closed:r})}function Cn(t){const e=t.from.length/2;if(e<=3)return t;const n=new Uint8Array(e);n[0]=1,n[e-1]=1;const r=[[0,e-1]];for(;r.length>0;){const[a,o]=r.pop();let c=-1,u=An;for(let h=a+1;h<o;h++){const f=Math.max(pe(t.from,a,o,h),pe(t.to,a,o,h));f>u&&(u=f,c=h)}c!==-1&&(n[c]=1,r.push([a,c],[c,o]))}const s=[],i=[];for(let a=0;a<e;a++)n[a]&&(s.push(t.from[a*2],t.from[a*2+1]),i.push(t.to[a*2],t.to[a*2+1]));return{from:s,to:i,closed:t.closed}}function pe(t,e,n,r){const s=t[e*2],i=t[e*2+1],a=t[n*2]-s,o=t[n*2+1]-i,c=t[r*2]-s,u=t[r*2+1]-i,h=a*a+o*o,f=h===0?0:Math.max(0,Math.min(1,(c*a+u*o)/h));return Math.hypot(c-f*a,u-f*o)}function En(t,e,n){const r=n.shapeIndex;if(V&&V.from===t&&V.to===e&&V.shapeIndex===r)return V.plan;const i=nt.get(String(r??"auto"))?.get(t)?.get(e);if(i)return V={from:t,to:e,shapeIndex:r,plan:i},i;const a=z(t).subpaths.filter(d=>d.length>0).length===z(e).subpaths.filter(d=>d.length>0).length,o=he(t,!a),c=he(e,!a),u={pairs:o.map((d,T)=>Dn(d,c[T],n))};ft>=vn&&(nt.clear(),ft=0);const h=String(r??"auto"),f=nt.get(h)??new Map;nt.set(h,f);const g=f.get(t)??new Map;return f.set(t,g),g.set(e,u),ft++,V={from:t,to:e,shapeIndex:r,plan:u},u}function me(t,e,n,r={}){if(!t)return e;if(!e)return t;const s=Math.max(0,Math.min(1,n));if(s===0)return t;if(s===1)return e;const i=En(t,e,r);if(i.pairs.length===0)return s<.5?t:e;let a="";for(const o of i.pairs){for(let c=0;c<o.from.length;c+=2){const u=le(o.from[c]+(o.to[c]-o.from[c])*s),h=le(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);a+=`${c===0?a?" M":"M":" L"}${u} ${h}`}o.closed&&(a+=" Z")}return a}function $n(){nt.clear(),ft=0,V=void 0}function ye(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const O=(t,e,n)=>t+(e-t)*n,_e=512,It=new Map,Dt=new Map;function Me(t){const e=It.get(t);if(e)return e;const n=t.replace("#",""),r=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return It.size<_e&&It.set(t,r),r}const Te=t=>t.charCodeAt(0)===35,be=t=>t.startsWith("rgb"),ke=t=>t.startsWith("rgba"),On=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Ct=t=>Math.round(t).toString(16).padStart(2,"0");function Ln(t,e,n){return`#${Ct(t)}${Ct(e)}${Ct(n)}`}function Se(t){const e=Dt.get(t);if(e)return e;const n=t.match(On);if(!n)throw new Error(`Invalid rgb color: ${t}`);const r=parseInt(n[1],10),s=parseInt(n[2],10),i=parseInt(n[3],10),a=n[4]!==void 0?[r,s,i,parseFloat(n[4])]:[r,s,i];return Dt.size<_e&&Dt.set(t,a),a}const Pe=(t,e,n)=>{if(Te(t)&&Te(e)){const[r,s,i]=Me(t),[a,o,c]=Me(e),u=O(r,a,n),h=O(s,o,n),f=O(i,c,n);return Ln(u,h,f)}if((be(t)||ke(t))&&(be(e)||ke(e))){const r=Se(t),s=Se(e),i=Math.round(O(r[0],s[0],n)),a=Math.round(O(r[1],s[1],n)),o=Math.round(O(r[2],s[2],n));if(r.length===4||s.length===4){const c=r[3]??1,u=s[3]??1,h=O(c,u,n);return`rgba(${i}, ${a}, ${o}, ${h})`}return`rgb(${i}, ${a}, ${o})`}return n<1?t:e},Ae=(t,e,n)=>{const r=Math.min(t.length,e.length),s=[];for(let i=0;i<r;i++)s.push(O(t[i],e[i],n));return s},Et=(t,e,n)=>n<1?t:e,ve=(t,e,n)=>me(t,e,n);function $t(t){return typeof t=="number"?O:Array.isArray(t)?Ae:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?Pe:ye(t)?ve:Et:Et}const Ot=1e3/60;function Lt(t,e={}){if(!x(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new Q(t.spring);return we(t,r=>n.valueAt(r),n.settleTime(),t.spring.from,t.spring.to,e)}function Nt(t,e={}){if(!X(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return we(t,r=>ut(n,r),J(n),n.from,Z(n),e)}function we(t,e,n,r,s,i){const a=i.intervalMs??Ot,o=i.tolerance??.01,c=t.delay??0,u=[];for(let f=0;f<=n;f+=a)u.push({time:f+c,value:e(f),easing:"linear"});const h=u[u.length-1];return!h||h.time<n+c?u.push({time:n+c,value:s,easing:"linear"}):h.value=s,c>0&&u.unshift({time:0,value:r,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:o>0?De(u,o):u,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Re(t,e,n,r={}){const s=r.intervalMs??Ot,i=typeof n=="function"?n:vt(n),a=$t(t.value),o=e.time-t.time;if(o<=0)return[e];const c=[];for(let h=s;h<o;h+=s){const f=h/o;c.push({time:t.time+h,value:a(t.value,e.value,i(f)),easing:"linear"})}const u=i(1);return c.push({...e,...u!==1&&{value:a(t.value,e.value,u)},easing:"linear"}),c}function Nn(t,e){return x(t)?Lt(t,e):X(t)?Nt(t,e):t}function Ie(t,e={}){const n=t.keyframes;if(!n.some(s=>st(s.easing)))return t;const r=n.length>0?[n[0]]:[];for(let s=1;s<n.length;s++){const i=n[s];st(i.easing)?r.push(...Re(n[s-1],i,i.easing,e)):r.push(i)}return{...t,keyframes:r}}function Fn(t,e){return t.filter(Ht).map(n=>Ie(n,e)).concat(t.filter(x).map(n=>Lt(n,e)),t.filter(X).map(n=>Nt(n,e)))}function De(t,e){if(t.length<=2)return t;const n=[t[0]];for(let r=1;r<t.length-1;r++){const s=n[n.length-1],i=t[r],a=t[r+1],o=a.time-s.time;if(o<=0)continue;const c=(i.time-s.time)/o,u=s.value+(a.value-s.value)*c;Math.abs(i.value-u)>e&&n.push(i)}return n.push(t[t.length-1]),n}function Ce(t){const e=[...t.keyframes].sort((n,r)=>n.time-r.time);return{...t,keyframes:e}}function Y(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function j(t,e,n,r){const s=n??0;return!r||e<=1?s:s+Mt(t,e,r)}class dt{track;targets;constructor(e){this.track=e,this.targets=Y(e)}getValueAtTime(e){return this.valueForOffset(e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=j(s,n,this.track.delay,this.track.stagger),a=this.valueForOffset(e-i);a!==void 0&&r.push({target:this.targets[s],value:a,start:i+this.track.keyframes[0].time})}return r}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,r=this.track.stagger?at(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+r+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(e){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||e<=n[0].time)return n[0].value;if(e>=n[n.length-1].time)return n[n.length-1].value;const{from:r,to:s}=this.findSurroundingKeyframes(e);if(!r||!s)return;if(r.time===e)return r.value;const i=s.time-r.time,a=(e-r.time)/i,c=vt(s.easing)(a);return $t(r.value)(r.value,s.value,c)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let r=0;r<n.length-1;r++)if(e>=n[r].time&&e<=n[r+1].time)return{from:n[r],to:n[r+1]};return{from:null,to:null}}}class Ee{track;targets;sampler;constructor(e){this.track=e,this.targets=Y(e),this.sampler=new Q(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=j(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:this.sampler.valueAt(e-i),start:i})}return r}getDuration(){const e=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class $e{track;targets;duration;constructor(e){this.track=e,this.targets=Y(e),this.duration=J(e.inertia)}getValueAtTime(e){return ut(this.track.inertia,e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=j(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:ut(this.track.inertia,e-i),start:i})}return r}getDuration(){const e=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Ft(t,e){const n={...ue(t.pathData,e)};if(t.matrix){const[r,s,i,a,o,c]=t.matrix,{x:u,y:h}=n;n.x=r*u+i*h+o,n.y=s*u+a*h+c;const f=n.angle*Math.PI/180,g=Math.cos(f),d=Math.sin(f);n.angle=Math.atan2(s*g+a*d,r*g+i*d)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function Xn(t,e,n,r){const s=e+(n-e)*r;return Ft(t,s)}const Xt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},xn=20;function Oe(t){const e=Xt[t??"upperCase"]??t??Xt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Xt.upperCase)}function Un(t,e,n){let r=(t|0)^Math.imul(e+1,2654435761)^Math.imul(n+1,2246822507);return r=Math.imul(r^r>>>16,2146121005),r=Math.imul(r^r>>>15,2221713035),(r^r>>>16)>>>0}function Le(t,e,n=0){const r=t.from??"",s=t.to,i=Math.max(0,Math.min(1,e));if(i<=0)return r;if(i>=1)return s;const a=Array.from(r),o=Array.from(s),c=t.rightToLeft??!1;if(t.mode==="type"){const M=Math.round(i*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-M)).join("")+o.slice(Math.max(0,o.length-M)).join(""):o.slice(0,M).join("")+a.slice(M).join("")}const u=Math.max(0,Math.min(.999,t.revealDelay??0)),h=Math.max(0,(i-u)/(1-u)),f=Math.floor(h*o.length),g=t.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*i),d=Oe(t.chars),T=t.refreshRate??xn,p=T>0?Math.floor(n*T/1e3):0,m=t.seed??1;let _="";for(let M=0;M<g;M++){const b=c?M>=g-f:M<f,S=c?o[o.length-(g-M)]:o[M];b&&S!==void 0||S===" "||S===`
2
- `?_+=S:_+=d[Un(m,M,p)%d.length]}return _}class Ne{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(e){if(this.id=e.id,this.name=e.name,this._captions=e.captions,this._config=e.config??{},this._explicitDuration=e.config?.duration,e.tracks)for(const n of e.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(e){if(this._explicitDuration=e,e!==void 0)this._config={...this._config,duration:e};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(e){this._config.speed=e}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,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(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=e*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=o,s-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const i=1e3;for(let o=0;o<i&&s>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(s>=c){if(s-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const c=this._currentTime;if(s>=c){if(s-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(e){const n=new Map;if(this._hasSharedWrites())this._resolveShared(e,n);else for(const[r,s]of this._trackPlayers){const i=s.getTrack().property;for(const{target:a,value:o,start:c}of s.getTargetValues(e))this._write(n,r,a,i,o,e-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const r=new Map;for(const[s,i]of this._trackPlayers){const a=i.getTrack().property;for(const{target:o,value:c,start:u}of i.getTargetValues(e)){const h=`${o}\0${a}`,f=u<=e,g=r.get(h);(!g||(f!==g.started?f:f?u>=g.start:u<=g.start))&&r.set(h,{trackId:s,target:o,property:a,value:c,start:u,started:f})}}for(const{trackId:s,target:i,property:a,value:o,start:c}of r.values())this._write(n,s,i,a,o,e-c)}_write(e,n,r,s,i,a){if(i===void 0)return;let o=e.get(r);o||(o=new Map,e.set(r,o));const c=this._textTracks.get(n);if(c&&typeof i=="number"){o.set("text",Le(c.textConfig,i,Math.max(0,a)));return}const u=this._motionPathTracks.get(n);if(u&&typeof i=="number"){const h=Ft(u.motionPathConfig,i);o.set("motionPathX",h.x),o.set("motionPathY",h.y),u.motionPathConfig.autoRotate&&o.set("motionPathRotate",h.angle)}else o.set(s,i)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const r of Y(n)){const s=`${r}\0${n.property}`;if(e.has(s)){this._sharedWrites=!0;break t}e.add(s)}}return this._sharedWrites}addTrack(e){if(this._tracks.push(e),this._sharedWrites=null,X(e)){this._trackPlayers.set(e.id,new $e(e));return}if(x(e)){this._trackPlayers.set(e.id,new Ee(e)),this._springTracks.set(e.id,e);return}if(it(e))this._trackPlayers.set(e.id,new dt(e)),this._textTracks.set(e.id,e);else if(yt(e)){const n={id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,delay:e.delay,endDelay:e.endDelay,targets:e.targets,stagger:e.stagger};this._trackPlayers.set(e.id,new dt(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new dt(e))}replaceTrack(e,n){const r=this._tracks.findIndex(i=>i.id===e);if(r<0)return;const s=this._tracks.slice(r+1);this.removeTrack(e);for(const i of s)this.removeTrack(i.id);this.addTrack(n);for(const i of s)this.addTrack(i)}removeTrack(e){this._tracks=this._tracks.filter(n=>n.id!==e),this._sharedWrites=null,this._trackPlayers.delete(e),this._motionPathTracks.delete(e),this._springTracks.delete(e),this._textTracks.delete(e)}getTracks(e={}){return this._tracks.filter(n=>this._matches(n,e))}removeTracks(e={}){const n=this.getTracks(e).map(r=>r.id);for(const r of n)this.removeTrack(r);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const r=n.getTrack(),s=r.delay??0;if(x(r)||X(r))return{from:s,to:n.getDuration()};const i=r.keyframes;if(!(!i||i.length===0))return{from:i[0].time+s,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const r=this._tracks[n],s=this.getTrackSpan(r.id);if(s)for(let i=0;i<n;i++){const a=this._tracks[i];if(a.property!==r.property)continue;const o=Y(a).filter(f=>Y(r).includes(f));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=s.to&&s.from<=c.to))continue;const h=s.from>=c.from;for(const f of o)e.push({target:f,property:r.property,losingTrackId:h?a.id:r.id,winningTrackId:h?r.id:a.id})}}return e}_matches(e,n){if(n.id!==void 0&&e.id!==n.id||n.property!==void 0&&e.property!==n.property||n.target!==void 0&&!Y(e).includes(n.target))return!1;if(n.timeRange){const r=this.getTrackSpan(e.id);if(!r||r.to<n.timeRange.from||r.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:G,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((e,n)=>e.time-n.time)}setMarkers(e){const n=e&&e.length>0?[...e].sort((s,i)=>s.time-i.time).map(s=>({...s})):void 0,r={...this._config};n?r.markers=n:delete r.markers,this._config=r}get captions(){return this._captions}setCaptions(e){const n={};for(const[r,s]of Object.entries(e??{}))n[r]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let e=0;for(const[,n]of this._trackPlayers)e=Math.max(e,n.getDuration());return e}_handleEndReached(){const e=this._config.loop??0;return e===-1||this._loopIteration<e?(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 e=this._config.loop??0;return this._config.alternate&&(e===-1||this._loopIteration<e)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Vn=100;function Yn(t,e,n,r){const s=[],i=[],{duration:a,alternate:o}=r,c=(d,T,p,m)=>{i.push([d,T]);const _=[];t.forEach((M,b)=>{(p==="forward"?(m?M>=d:M>d)&&M<=T:(m?M<=d:M<d)&&M>=T)&&_.push(b)}),_.sort((M,b)=>(p==="forward"?t[M]-t[b]:t[b]-t[M])||M-b);for(const M of _)s.push({kind:"event",index:M,direction:p})};let u=e.time,h=e.direction,f=e.fresh===!0;const g=Math.min(Vn,Math.max(0,n.iteration-e.iteration));for(let d=0;d<g;d++){const T=h==="forward"?a:0;c(u,T,h,f),s.push({kind:"repeat"}),o?(h=h==="forward"?"reverse":"forward",u=T,f=!1):(u=h==="forward"?0:a,f=!0)}return g>0&&r.holding&&!o?{crossings:s,passes:i}:(c(u,n.time,h,f),{crossings:s,passes:i})}function Fe(t){return X(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Xe(t.inertia),...L(t)}:x(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...L(t)}:it(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(xt),...L(t)}:yt(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(xt),...L(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(xt),...L(t)}}function Xe(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function xt(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function L(t){const e=t.endDelay;return{...t.delay!==void 0&&{delay:t.delay},...e!==void 0&&{endDelay:e},...t.targets!==void 0&&{targets:[...t.targets]},...t.stagger!==void 0&&{stagger:{...t.stagger}}}}function xe(t){if(X(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Xe(e.inertia),...L(e)}}if(x(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...L(e)}}if(it(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,r)=>n.time-r.time),...L(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((r,s)=>r.time-s.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...L(e)}}return Ce({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...L(t)})}function Ue(t){const e=t._config.markers;return{formatVersion:G,id:t.id,name:t.name,config:{duration:t.duration>0?t.duration:void 0,loop:t._config.loop,speed:t._config.speed,alternate:t._config.alternate,repeatDelay:t._config.repeatDelay,...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(Fe),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function Ve(t){const e=t.formatVersion??1;if(e>G)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${G}. Update tinyfly to play it.`);return new Ne({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(xe),captions:t.captions})}function zn(t){return JSON.stringify(Ue(t))}function Hn(t){const e=JSON.parse(t);return Ve(e)}function qn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Ye(t){let e=t>>>0||2654435769;return{seed:t>>>0,next(){return e^=e<<13,e>>>=0,e^=e>>17,e^=e<<5,e>>>=0,e/4294967296}}}function Ut(t,e,n){return e+t.next()*(n-e)}function ze(t,e,n,r){if(r<=0)return Ut(t,e,n);const s=Math.floor((n-e)/r),i=Math.round(t.next()*s);return e+i*r}function Kn(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const He=/^([+\-*/])=\s*(-?[\d.]+)$/,qe=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Wn(t){return typeof t!="string"?!1:He.test(t.trim())||qe.test(t.trim())}function Vt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=He.exec(n);if(r){const[,i,a]=r,o=e.base??0,c=Number.parseFloat(a);switch(i){case"+":return o+c;case"-":return o-c;case"*":return o*c;case"/":return c===0?o:o/c}}const s=qe.exec(n);if(s){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const i=Number.parseFloat(s[1]),a=Number.parseFloat(s[2]),o=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return o!==void 0?ze(e.random,i,a,o):Ut(e.random,i,a)}return t}function Ke(t,e=0,n){const r=[];let s=e;for(const i of t){const a=Vt(i,{base:s,random:n});r.push(a),typeof a=="number"&&(s=a)}return r}class jn{random;constructor(e){this.random=Ye(e)}get seed(){return this.random.seed}resolve(e,n=0){return Vt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return Ke(e,n,this.random)}}const Bn=600;function Gn(t){if(Array.isArray(t)){const[g,d,T,p]=t;return{fn:We(g,d,T,p),bezier:[g,d,T,p]}}const{segments:e}=z(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,r=e[0].startY,s=e[e.length-1],i=s.endX-n,a=s.endY-r;if(i===0||a===0)throw new Error(`customEase: "${t}" must move along both axes`);const o=g=>(g-n)/i,c=g=>(g-r)/a;if(e.length===1&&s.type==="C"){const[g,d,T,p]=s.points,m=[o(g),c(d),o(T),c(p)];return{fn:We(...m),bezier:m}}const u=[],h=[],f=Math.max(8,Math.ceil(Bn/e.length));for(const g of e)for(let d=u.length===0?0:1;d<=f;d++){const[T,p]=Jn(g,d/f);u.push(o(T)),h.push(c(p))}return{fn:tr(u,h)}}function Qn(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,r=[1];for(let i=n;i>.002;i*=n)r.push(2*Math.sqrt(i));const s=r.reduce((i,a)=>i+a,0);return i=>{if(i<=0)return 0;if(i>=1)return 1;let a=i*s;for(let o=0;o<r.length;o++){if(a<=r[o]){if(o===0)return(a/r[0])**2;const c=r[o]/2,u=c*c,h=a-c;return 1-(u-h*h)}a-=r[o]}return 1}}function Zn(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",r=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*e*Math.PI*2)*r(s)}function Jn(t,e){if(t.type==="L"){const[u,h]=t.points;return[t.startX+(u-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,r,s,i,a,o]=t.points,c=1-e;return[c*c*c*t.startX+3*c*c*e*n+3*c*e*e*s+e*e*e*a,c*c*c*t.startY+3*c*c*e*r+3*c*e*e*i+e*e*e*o]}function tr(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let r=0,s=t.length-1;for(;s-r>1;){const a=r+s>>1;t[a]<=n?r=a:s=a}const i=t[s]-t[r];return i===0?e[s]:e[r]+(n-t[r])/i*(e[s]-e[r])}}function We(t,e,n,r){const s=(a,o,c)=>3*(1-a)*(1-a)*a*o+3*(1-a)*a*a*c+a*a*a,i=(a,o,c)=>3*(1-a)*(1-a)*o+6*(1-a)*a*(c-o)+3*a*a*(1-c);return a=>{if(a<=0)return 0;if(a>=1)return 1;let o=a;for(let h=0;h<8;h++){const f=s(o,t,n)-a,g=i(o,t,n);if(Math.abs(f)<1e-6)return s(o,e,r);if(Math.abs(g)<1e-6)break;o-=f/g}let c=0,u=1;o=a;for(let h=0;h<40;h++)s(o,t,n)<a?c=o:u=o,o=(c+u)/2;return s(o,e,r)}}const er=350,nr=300,rr=550;function sr(t,e={}){const n=e.lead??er,r=e.gap??nr,s=e.tail??rr,i=[];let a=0;return t.forEach((o,c)=>{const u=[];let h=a+n;o.lines.forEach((g,d)=>{if(!(g.duration>=0))throw new Error(`narration: scene ${c} line ${d} has an invalid duration (${g.duration})`);d>0&&(h+=r),u.push({id:g.id??`s${c}-l${d}`,scene:c,line:d,start:h,end:h+g.duration,text:g.text}),h+=g.duration});const f=h+s+(o.tail??0);i.push({id:o.id??`s${c}`,start:a,duration:f-a,cues:u}),a=f}),{duration:a,scenes:i,cues:i.flatMap(o=>o.cues)}}function ir(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function ar(t,e){let n=t.scenes[0];for(const r of t.scenes)if(e>=r.start)n=r;else break;return n}const N=t=>Math.round(t*1e3)/1e3;function or(t,e={}){if(t.length===0)return"";const n=e.curviness??1,r=e.closed??!1,s=t.length;let i=`M${N(t[0].x)} ${N(t[0].y)}`;if(s===1)return i;const a=c=>r?t[(c%s+s)%s]:t[Math.max(0,Math.min(s-1,c))],o=r?s:s-1;for(let c=0;c<o;c++){const u=a(c-1),h=a(c),f=a(c+1),g=a(c+2);if(n===0){i+=` L${N(f.x)} ${N(f.y)}`;continue}const d=n/6,T=h.x+(f.x-u.x)*d,p=h.y+(f.y-u.y)*d,m=f.x-(g.x-h.x)*d,_=f.y-(g.y-h.y)*d;i+=` C${N(T)} ${N(p)} ${N(m)} ${N(_)} ${N(f.x)} ${N(f.y)}`}return r?`${i} Z`:i}const w=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function cr(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let r=0;r+1<e.length;r+=2)n.push({x:e[r],y:e[r+1]});return n}function ur(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=w(e.cx),r=w(e.cy),s=t.tag.toLowerCase()==="circle"?w(e.r):w(e.rx),i=t.tag.toLowerCase()==="circle"?w(e.r):w(e.ry);return`M${n+s} ${r} A${s} ${i} 0 1 1 ${n-s} ${r} A${s} ${i} 0 1 1 ${n+s} ${r} Z`}case"rect":{const n=w(e.x),r=w(e.y),s=w(e.width),i=w(e.height);let a=e.rx!=null?w(e.rx):e.ry!=null?w(e.ry):0,o=e.ry!=null?w(e.ry):a;return a=Math.min(a,s/2),o=Math.min(o,i/2),a===0||o===0?`M${n} ${r} H${n+s} V${r+i} H${n} Z`:`M${n+a} ${r} H${n+s-a} A${a} ${o} 0 0 1 ${n+s} ${r+o} V${r+i-o} A${a} ${o} 0 0 1 ${n+s-a} ${r+i} H${n+a} A${a} ${o} 0 0 1 ${n} ${r+i-o} V${r+o} A${a} ${o} 0 0 1 ${n+a} ${r} Z`}case"line":return`M${w(e.x1)} ${w(e.y1)} L${w(e.x2)} ${w(e.y2)}`;case"polyline":case"polygon":{const n=cr(e.points);if(n.length===0)return null;const r=n.map((s,i)=>`${i===0?"M":"L"}${s.x} ${s.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${r} Z`:r}default:return null}}l.Clock=Je,l.DEFAULT_BAKE_INTERVAL_MS=Ot,l.DEFAULT_INERTIA_FRICTION=bt,l.DEFAULT_SPRING=$,l.FORMAT_VERSION=G,l.INERTIA_MAX_DURATION_MS=Wt,l.InertiaTrackPlayer=$e,l.MORPH_SAMPLES=Pn,l.ManualClock=Ze,l.SPRING_MAX_DURATION_MS=Tt,l.SPRING_PRESETS=tn,l.SPRING_STEP_MS=K,l.SpringSampler=Q,l.SpringTrackPlayer=Ee,l.Timeline=Ne,l.TrackPlayer=dt,l.ValueResolver=jn,l.backOut=se,l.bakeEasing=Re,l.bakeInertiaTrack=Nt,l.bakeSpringTrack=Lt,l.bounceOut=re,l.charactersFor=Oe,l.clearMorphCache=$n,l.clearPathCache=Mn,l.createCubicBezier=ee,l.createRandom=Ye,l.createTrack=Ce,l.criticalDamping=sn,l.customBounce=Qn,l.customEase=Gn,l.customWiggle=Zn,l.deserializeTimeline=Ve,l.deserializeTrack=xe,l.easeIn=Zt,l.easeInCubic=kt,l.easeInOut=te,l.easeInOutCubic=Pt,l.easeInOutQuad=Qt,l.easeInQuad=Bt,l.easeOut=Jt,l.easeOutCubic=St,l.easeOutQuad=Gt,l.elasticOut=ne,l.expandParametricEasings=Ie,l.fromJSON=Hn,l.getEasingFunction=vt,l.getInterpolator=$t,l.getMotionPathPoint=Ft,l.getPathLength=Tn,l.getPointAtProgress=ue,l.hasKeyframes=Ht,l.hashSeed=qn,l.inertiaDuration=J,l.inertiaRest=Z,l.inertiaValueAt=ut,l.inertiaVelocityAt=un,l.interpolateArray=Ae,l.interpolateColor=Pe,l.interpolateMotionPath=Xn,l.interpolateNumber=O,l.interpolatePathString=ve,l.interpolateString=Et,l.isCubicBezierEasing=q,l.isInertiaTrack=X,l.isMotionPathPoint=Qe,l.isMotionPathTrack=yt,l.isParametricEasing=st,l.isPathData=ye,l.isSpringTrack=x,l.isTextTrack=it,l.isUnderdamped=rn,l.isUnresolved=Wn,l.linear=lt,l.maxStaggerDistance=qt,l.morphPath=me,l.narrationMarkers=ir,l.narrationSceneAt=ar,l.naturalRest=jt,l.parametricEasing=ae,l.parsePath=z,l.planNarration=sr,l.playheadCrossings=Yn,l.pointAtDistance=wt,l.pointsToPath=or,l.randomBetween=Ut,l.randomChoice=Kn,l.randomSnapped=ze,l.resolveSequence=Ke,l.resolveValue=Vt,l.serializeTimeline=Ue,l.serializeTrack=Fe,l.shapeToPathData=ur,l.simplifyKeyframes=De,l.springDuration=nn,l.springValueAt=en,l.staggerDistance=_t,l.staggerOffset=Mt,l.staggerOffsets=Kt,l.staggerSpan=at,l.stepsEasing=ie,l.textAt=Le,l.toJSON=zn,l.toKeyframedTrack=Nn,l.toKeyframedTracks=Fn,l.trackTargets=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(l,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(l=typeof globalThis<"u"?globalThis:l||self,q(l.tinyfly={}))})(this,(function(l){"use strict";function q(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function it(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const Z=1;function ot(t){return t.property==="text"&&"textConfig"in t}function x(t){return t.kind==="inertia"&&"inertia"in t}function U(t){return t.kind==="spring"&&"spring"in t}function Tt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function en(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function Wt(t){return"keyframes"in t}class nn{_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(e){this._currentTime+=e,this.onTick?.(e,this._currentTime)}reset(){this._currentTime=0}seek(e){this._currentTime=e}}class rn{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(e={}){this._speed=e.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(e){this._speed=e}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(e){this._currentTime=e}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(e){if(this._isRunning){if(this._lastFrameTime!==null){const r=(e-this._lastFrameTime)*this._speed;this._currentTime+=r,this.onTick?.(r,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function bt(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const r=Math.max(0,Math.min(e-1,n));return Math.abs(t-r)}switch(n){case"end":return e-1-t;case"center":return Math.abs(t-(e-1)/2);case"edges":return(e-1)/2-Math.abs(t-(e-1)/2);default:return t}}function jt(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,bt(r,t,e));return n}function kt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=bt(t,e,r);if(n.amount!==void 0){const a=jt(e,r);return a===0?0:n.amount*s/a}return n.each!==void 0?n.each*s:0}function Gt(t,e){return Array.from({length:t},(n,r)=>kt(r,t,e))}function ct(t,e){return t<=1?0:Math.max(...Gt(t,e))}const K=1,St=6e4,ut=St/K,O={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},sn={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 J{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(e){this.from=e.from,this.to=e.to,this.stiffness=e.stiffness??O.stiffness,this.damping=e.damping??O.damping,this.mass=e.mass??O.mass,this.restDelta=e.restDelta??O.restDelta,this.restSpeed=e.restSpeed??O.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??O.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(e){return Math.abs(e-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(e){if(e<=0)return this.from;const n=Math.floor(e/K);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const r=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],a=e/K-n;return r+(s-r)*a}settleTime(){return this.simulateTo(ut+1),this.settledStep!==null?this.settledStep*K:St}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,ut+1),r=K/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],a=s-this.to,i=-this.stiffness*a,o=-this.damping*this.velocity,c=(i+o)/this.mass;this.velocity+=c*r;const u=s+this.velocity*r;if(this.samples.push(u),this.isAtRest(u)){this.settledStep=this.samples.length-1;return}}this.samples.length>ut&&(this.settledStep=ut)}}function an(t,e){return new J(t).valueAt(e)}function on(t){return new J(t).settleTime()}function cn(t){const e=t.stiffness??O.stiffness,n=t.damping??O.damping,r=t.mass??O.mass;return n<2*Math.sqrt(e*r)}function un(t){const e=t.stiffness??O.stiffness,n=t.mass??O.mass;return 2*Math.sqrt(e*n)}const At=4,ln=.002,hn=1e-4,Qt=6e4;function lt(t){const e=t.friction??At;return e>0?e:At}function Zt(t){return t.from+t.velocity/lt(t)}function fn(t,e){if(e===void 0)return t;if(typeof e=="number")return e>0?Math.round(t/e)*e:t;if(e.length===0)return t;let n=e[0];for(const r of e)Math.abs(r-t)<Math.abs(n-t)&&(n=r);return n}function tt(t){let e=fn(Zt(t),t.end);return t.min!==void 0&&(e=Math.max(t.min,e)),t.max!==void 0&&(e=Math.min(t.max,e)),e}function et(t){const e=Math.abs(tt(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(hn,e*ln);if(n>=e)return 0;const r=Math.log(e/n)/lt(t);return Math.min(Qt,r*1e3)}function ht(t,e){if(e<=0)return t.from;const n=tt(t);if(e>=et(t))return n;const r=lt(t);return t.from+(n-t.from)*(1-Math.exp(-r*e/1e3))}function dn(t,e){const n=lt(t),r=tt(t);return e>=et(t)?0:(r-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const ft=t=>t,Jt=t=>t*t,te=t=>1-(1-t)*(1-t),ee=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Pt=t=>t*t*t,vt=t=>1-Math.pow(1-t,3),wt=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,ne=Pt,re=vt,se=wt,gn={linear:ft,"ease-in":ne,"ease-out":re,"ease-in-out":se,"ease-in-quad":Jt,"ease-out-quad":te,"ease-in-out-quad":ee,"ease-in-cubic":Pt,"ease-out-cubic":vt,"ease-in-out-cubic":wt};function ae(t){const[e,n,r,s]=t,a=3*e,i=3*(r-e)-a,o=1-a-i,c=3*n,u=3*(s-n)-c,h=1-c-u,f=m=>((o*m+i)*m+a)*m,g=m=>((h*m+u)*m+c)*m,d=m=>(3*o*m+2*i)*m+a,M=m=>{let p=m;for(let A=0;A<8;A++){const w=f(p)-m;if(Math.abs(w)<1e-7)return p;const _=d(p);if(Math.abs(_)<1e-7)break;p-=w/_}let T=0,b=1;for(p=m;T<b;){const A=f(p);if(Math.abs(A-m)<1e-7)return p;m>A?T=p:b=p,p=(T+b)/2}return p};return m=>{if(m<=0)return 0;if(m>=1)return 1;const p=M(m);return g(p)}}function Rt(t,e="out"){if(e==="out")return t;const n=r=>1-t(1-r);return e==="in"?n:r=>r<.5?n(r*2)/2:t(r*2-1)/2+.5}function ie(t=1,e=.3){const n=Math.max(1,t),r=e/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-r)*(2*Math.PI)/e)+1}const oe=t=>{if(t<=0)return 0;if(t>=1)return 1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const s=t-.5454545454545454;return 7.5625*s*s+.75}if(t<2.5/2.75){const s=t-.8181818181818182;return 7.5625*s*s+.9375}const r=t-2.625/2.75;return 7.5625*r*r+.984375};function ce(t=1.70158){return e=>{if(e<=0)return 0;if(e>=1)return 1;const n=e-1;return n*n*((t+1)*n+t)+1}}function ue(t,e="end"){const n=Math.max(1,Math.floor(t));return r=>{if(r>=1)return 1;if(r<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const s=Math.floor(r*n);switch(e){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 le(t){switch(t.type){case"steps":return ue(t.count,t.position);case"elastic":return Rt(ie(t.amplitude,t.period),t.mode);case"bounce":return Rt(oe,t.mode);case"back":return Rt(ce(t.overshoot),t.mode)}}function It(t){return t===void 0?ft:q(t)?ae(t.points):it(t)?le(t):gn[t]??ft}const he=32,mn=256,W=new Map,pn=/[MmLlHhVvCcSsQqTtAaZz]/,yn=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,_n={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Mn(t){const e=[];let n=0,r=null;const s=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(s(),!(n>=t.length));){const a=t[n];if(pn.test(a)){r={type:a,args:[]},e.push(r),n++;continue}if(!r)break;const i=r.type==="A"||r.type==="a",o=r.args.length%7;if(i&&(o===3||o===4)){if(a!=="0"&&a!=="1")break;r.args.push(a==="1"?1:0),n++;continue}const c=yn.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function Tn(t,e,n,r,s,a,i,o,c){if(t===o&&e===c)return[];let u=Math.abs(n),h=Math.abs(r);if(u===0||h===0)return[[t,e,o,c,o,c]];const f=s*Math.PI/180,g=Math.cos(f),d=Math.sin(f),M=(t-o)/2,m=(e-c)/2,p=g*M+d*m,T=-d*M+g*m,b=p*p/(u*u)+T*T/(h*h);if(b>1){const I=Math.sqrt(b);u*=I,h*=I}const A=a===i?-1:1,w=u*u*h*h-u*u*T*T-h*h*p*p,_=u*u*T*T+h*h*p*p,R=A*Math.sqrt(Math.max(0,w/_)),v=R*u*T/h,L=-R*h*p/u,y=g*v-d*L+(t+o)/2,k=d*v+g*L+(e+c)/2,S=(I,E,$,Q)=>{const Kt=I*$+E*Q,Mt=Math.sqrt((I*I+E*E)*($*$+Q*Q)),at=Math.acos(Math.max(-1,Math.min(1,Kt/Mt)));return I*Q-E*$<0?-at:at},P=S(1,0,(p-v)/u,(T-L)/h);let C=S((p-v)/u,(T-L)/h,(-p-v)/u,(-T-L)/h);!i&&C>0&&(C-=2*Math.PI),i&&C<0&&(C+=2*Math.PI);const H=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),qt=C/H,_t=4/3*Math.tan(qt/4),Ze=I=>{const E=u*Math.cos(I),$=h*Math.sin(I);return[g*E-d*$+y,d*E+g*$+k]},Je=I=>{const E=-u*Math.sin(I),$=h*Math.cos(I);return[g*E-d*$,d*E+g*$]},tn=[];for(let I=0;I<H;I++){const E=P+I*qt,$=E+qt,[Q,Kt]=Ze(E),[Mt,at]=I===H-1?[o,c]:Ze($),[_r,Mr]=Je(E),[Tr,br]=Je($);tn.push([Q+_t*_r,Kt+_t*Mr,Mt-_t*Tr,at-_t*br,Mt,at])}return tn}function V(t,e,n,r,s){const a=1-s;return a*a*a*t+3*a*a*s*e+3*a*s*s*n+s*s*s*r}function fe(t,e,n,r,s){const a=1-s;return 3*a*a*(e-t)+6*a*s*(n-e)+3*s*s*(r-n)}function nt(t,e,n,r){return{subpath:0,type:"L",points:[n,r],startX:t,startY:e,endX:n,endY:r,length:Math.hypot(n-t,r-e)}}function dt(t,e,n){const[r,s,a,i,o,c]=n,u=[0];let h=t,f=e,g=0;for(let d=1;d<=he;d++){const M=d/he,m=V(t,r,a,o,M),p=V(e,s,i,c,M);g+=Math.hypot(m-h,p-f),u.push(g),h=m,f=p}return{subpath:0,type:"C",points:[r,s,a,i,o,c],startX:t,startY:e,endX:o,endY:c,length:g,lengths:u}}function z(t){const e=W.get(t);if(e)return e;const n=[];let r=0,s=0,a=0,i=0,o=null,c=null,u=-1;const h=new Set,f=m=>{u<0&&(u=0),m.subpath=u,n.push(m)};for(const{type:m,args:p}of Mn(t)){const T=m.toUpperCase(),b=m!==T,A=_n[T];if(T==="Z"){(r!==a||s!==i)&&f(nt(r,s,a,i)),u>=0&&h.add(u),r=a,s=i,o=c=null;continue}for(let w=0;w+A<=p.length;w+=A){const _=p.slice(w,w+A),R=b?r:0,v=b?s:0;let L=null,y=null;switch(T){case"M":w===0?(r=_[0]+R,s=_[1]+v,a=r,i=s,(u<0||n[n.length-1]?.subpath===u)&&u++):(f(nt(r,s,_[0]+R,_[1]+v)),r=_[0]+R,s=_[1]+v);break;case"L":f(nt(r,s,_[0]+R,_[1]+v)),r=_[0]+R,s=_[1]+v;break;case"H":f(nt(r,s,_[0]+R,s)),r=_[0]+R;break;case"V":f(nt(r,s,r,_[0]+v)),s=_[0]+v;break;case"C":{const k=[_[0]+R,_[1]+v,_[2]+R,_[3]+v,_[4]+R,_[5]+v];f(dt(r,s,k)),L=[k[2],k[3]],r=k[4],s=k[5];break}case"S":{const[k,S]=o?[2*r-o[0],2*s-o[1]]:[r,s],P=[k,S,_[0]+R,_[1]+v,_[2]+R,_[3]+v];f(dt(r,s,P)),L=[P[2],P[3]],r=P[4],s=P[5];break}case"Q":case"T":{let k=r,S=s;T==="Q"?(k=_[0]+R,S=_[1]+v):c&&(k=2*r-c[0],S=2*s-c[1]);const P=T==="Q"?_[2]+R:_[0]+R,C=T==="Q"?_[3]+v:_[1]+v;f(dt(r,s,[r+2/3*(k-r),s+2/3*(S-s),P+2/3*(k-P),C+2/3*(S-C),P,C])),y=[k,S],r=P,s=C;break}case"A":{const k=_[5]+R,S=_[6]+v;let P=r,C=s;for(const H of Tn(r,s,_[0],_[1],_[2],_[3],_[4],k,S))f(dt(P,C,H)),P=H[4],C=H[5];r=k,s=S;break}}o=L,c=y}}const g=n.reduce((m,p)=>m+p.length,0),d=[];for(let m=0;m<n.length;){const p=n[m].subpath;let T=m,b=0;for(;T<n.length&&n[T].subpath===p;)b+=n[T++].length;const A=n[m],w=n[T-1],_=h.has(p)||Math.abs(w.endX-A.startX)<1e-9&&Math.abs(w.endY-A.startY)<1e-9;d.push({start:m,end:T,length:b,closed:_}),m=T}const M={segments:n,totalLength:g,subpaths:d};return W.size>=mn&&W.delete(W.keys().next().value),W.set(t,M),M}function bn(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let r=0,s=n.length-1;for(;r<s-1;){const o=r+s>>1;n[o]<e?r=o:s=o}const a=n[s]-n[r],i=a>0?(e-n[r])/a:0;return(r+i)/(n.length-1)}function kn(t,e){if(t.type==="L"){const f=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*f,y:t.startY+(t.endY-t.startY)*f,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,r,s,a,i,o]=t.points,c=bn(t,e);let u=fe(t.startX,n,s,i,c),h=fe(t.startY,r,a,o,c);if(Math.hypot(u,h)<1e-9){const f=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),g=V(t.startX,n,s,i,f),d=V(t.startY,r,a,o,f),M=V(t.startX,n,s,i,c),m=V(t.startY,r,a,o,c);u=c<.5?g-M:M-g,h=c<.5?d-m:m-d}return{x:V(t.startX,n,s,i,c),y:V(t.startY,r,a,o,c),angle:Math.atan2(h,u)*180/Math.PI}}function Dt(t,e,n=0,r=t.length){if(r<=n)return{x:0,y:0,angle:0};let s=0;for(let a=n;a<r;a++){const i=t[a];if(s+i.length>=e||a===r-1)return kn(i,e-s);s+=i.length}return{x:0,y:0,angle:0}}function de(t,e){const{segments:n,totalLength:r}=z(t);return Dt(n,Math.max(0,Math.min(1,e))*r)}function Sn(){W.clear()}function An(t){return z(t).totalLength}const Pn=24,vn=320,wn=2.5,rt=72,Rn=64,In=.2,Dn=128,st=new Map;let gt=0,Y;const ge=t=>Math.round(t*100)/100;function me(t,e){const{segments:n,subpaths:r,totalLength:s}=z(t);if(n.length===0)return[];if(e){const a=r.every(i=>i.closed);return[{segments:n,start:0,end:n.length,length:s,closed:a}]}return r.filter(a=>a.length>0).map(a=>({segments:n,start:a.start,end:a.end,length:a.length,closed:a.closed}))}function Ct(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),r=Dt(t.segments,n*t.length,t.start,t.end);return[r.x,r.y]}function pe(t){const e=[];let n=0;for(let r=t.start;r<t.end;r++)n+=t.segments[r].length,t.length>0&&e.push(n/t.length);return e}function ye(t,e){const n=[];for(let r=0;r<e;r++)n.push(Ct(t,t.closed?r/e:r/(e-1)));return n}function _e(t){let e=0,n=0;for(const[r,s]of t)e+=r,n+=s;return e/=t.length,n/=t.length,t.map(([r,s])=>[r-e,s-n])}function Cn(t,e,n){const r=t.closed&&e.closed;if(n!==void 0)return{offset:r?Math.abs(n)%rt/rt:0,reversed:n<0};const s=_e(ye(t,rt)),a=_e(ye(e,rt)),i=rt;let o={offset:0,reversed:!1},c=1/0;for(const u of[!1,!0]){const h=r?i:1;for(let f=0;f<h;f++){let g=0;for(let d=0;d<i&&g<c;d++){const M=r?u?(f-d+i)%i:(d+f)%i:u?i-1-d:d,m=s[d][0]-a[M][0],p=s[d][1]-a[M][1];g+=m*m+p*p}g<c&&(c=g,o={offset:r?f/i:0,reversed:u})}}return o}function En(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function $n(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function On(t,e,n){const r=t.closed&&e.closed,s=Cn(t,e,n.shapeIndex),a=Math.max(Pn,Math.min(vn,Math.ceil(Math.max(t.length,e.length)/wn))),i=new Set,o=f=>i.add(Math.round(f*1e7)/1e7);for(let f=0;f<=a;f++)o(f/a);for(const f of pe(t))o(f);for(const f of pe(e))o($n(f,s,r));let c=[...i].sort((f,g)=>f-g);r&&(c=c.filter(f=>f<1));const u=[],h=[];for(const f of c)u.push(...Ct(t,f)),h.push(...Ct(e,En(f,s,r)));return Ln({from:u,to:h,closed:r})}function Ln(t){const e=t.from.length/2;if(e<=3)return t;const n=new Uint8Array(e);n[0]=1,n[e-1]=1;const r=[[0,e-1]];for(;r.length>0;){const[i,o]=r.pop();let c=-1,u=In;for(let h=i+1;h<o;h++){const f=Math.max(Me(t.from,i,o,h),Me(t.to,i,o,h));f>u&&(u=f,c=h)}c!==-1&&(n[c]=1,r.push([i,c],[c,o]))}const s=[],a=[];for(let i=0;i<e;i++)n[i]&&(s.push(t.from[i*2],t.from[i*2+1]),a.push(t.to[i*2],t.to[i*2+1]));return{from:s,to:a,closed:t.closed}}function Me(t,e,n,r){const s=t[e*2],a=t[e*2+1],i=t[n*2]-s,o=t[n*2+1]-a,c=t[r*2]-s,u=t[r*2+1]-a,h=i*i+o*o,f=h===0?0:Math.max(0,Math.min(1,(c*i+u*o)/h));return Math.hypot(c-f*i,u-f*o)}function Fn(t,e,n){const r=n.shapeIndex;if(Y&&Y.from===t&&Y.to===e&&Y.shapeIndex===r)return Y.plan;const a=st.get(String(r??"auto"))?.get(t)?.get(e);if(a)return Y={from:t,to:e,shapeIndex:r,plan:a},a;const i=z(t).subpaths.filter(d=>d.length>0).length===z(e).subpaths.filter(d=>d.length>0).length,o=me(t,!i),c=me(e,!i),u={pairs:o.map((d,M)=>On(d,c[M],n))};gt>=Dn&&(st.clear(),gt=0);const h=String(r??"auto"),f=st.get(h)??new Map;st.set(h,f);const g=f.get(t)??new Map;return f.set(t,g),g.set(e,u),gt++,Y={from:t,to:e,shapeIndex:r,plan:u},u}function Te(t,e,n,r={}){if(!t)return e;if(!e)return t;const s=Math.max(0,Math.min(1,n));if(s===0)return t;if(s===1)return e;const a=Fn(t,e,r);if(a.pairs.length===0)return s<.5?t:e;let i="";for(const o of a.pairs){for(let c=0;c<o.from.length;c+=2){const u=ge(o.from[c]+(o.to[c]-o.from[c])*s),h=ge(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);i+=`${c===0?i?" M":"M":" L"}${u} ${h}`}o.closed&&(i+=" Z")}return i}function Nn(){st.clear(),gt=0,Y=void 0}function be(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const F=(t,e,n)=>t+(e-t)*n,ke=512,Et=new Map,$t=new Map;function Se(t){const e=Et.get(t);if(e)return e;const n=t.replace("#",""),r=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return Et.size<ke&&Et.set(t,r),r}const Ae=t=>t.charCodeAt(0)===35,Pe=t=>t.startsWith("rgb"),ve=t=>t.startsWith("rgba"),Xn=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Ot=t=>Math.round(t).toString(16).padStart(2,"0");function xn(t,e,n){return`#${Ot(t)}${Ot(e)}${Ot(n)}`}function we(t){const e=$t.get(t);if(e)return e;const n=t.match(Xn);if(!n)throw new Error(`Invalid rgb color: ${t}`);const r=parseInt(n[1],10),s=parseInt(n[2],10),a=parseInt(n[3],10),i=n[4]!==void 0?[r,s,a,parseFloat(n[4])]:[r,s,a];return $t.size<ke&&$t.set(t,i),i}const Re=(t,e,n)=>{if(Ae(t)&&Ae(e)){const[r,s,a]=Se(t),[i,o,c]=Se(e),u=F(r,i,n),h=F(s,o,n),f=F(a,c,n);return xn(u,h,f)}if((Pe(t)||ve(t))&&(Pe(e)||ve(e))){const r=we(t),s=we(e),a=Math.round(F(r[0],s[0],n)),i=Math.round(F(r[1],s[1],n)),o=Math.round(F(r[2],s[2],n));if(r.length===4||s.length===4){const c=r[3]??1,u=s[3]??1,h=F(c,u,n);return`rgba(${a}, ${i}, ${o}, ${h})`}return`rgb(${a}, ${i}, ${o})`}return n<1?t:e},Ie=(t,e,n)=>{const r=Math.min(t.length,e.length),s=[];for(let a=0;a<r;a++)s.push(F(t[a],e[a],n));return s},Lt=(t,e,n)=>n<1?t:e,De=(t,e,n)=>Te(t,e,n);function Ft(t){return typeof t=="number"?F:Array.isArray(t)?Ie:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?Re:be(t)?De:Lt:Lt}const Nt=1e3/60;function Xt(t,e={}){if(!U(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new J(t.spring);return Ce(t,r=>n.valueAt(r),n.settleTime(),t.spring.from,t.spring.to,e)}function xt(t,e={}){if(!x(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return Ce(t,r=>ht(n,r),et(n),n.from,tt(n),e)}function Ce(t,e,n,r,s,a){const i=a.intervalMs??Nt,o=a.tolerance??.01,c=t.delay??0,u=[];for(let f=0;f<=n;f+=i)u.push({time:f+c,value:e(f),easing:"linear"});const h=u[u.length-1];return!h||h.time<n+c?u.push({time:n+c,value:s,easing:"linear"}):h.value=s,c>0&&u.unshift({time:0,value:r,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:o>0?Oe(u,o):u,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Ee(t,e,n,r={}){const s=r.intervalMs??Nt,a=typeof n=="function"?n:It(n),i=Ft(t.value),o=e.time-t.time;if(o<=0)return[e];const c=[];for(let h=s;h<o;h+=s){const f=h/o;c.push({time:t.time+h,value:i(t.value,e.value,a(f)),easing:"linear"})}const u=a(1);return c.push({...e,...u!==1&&{value:i(t.value,e.value,u)},easing:"linear"}),c}function Un(t,e){return U(t)?Xt(t,e):x(t)?xt(t,e):t}function $e(t,e={}){const n=t.keyframes;if(!n.some(s=>it(s.easing)))return t;const r=n.length>0?[n[0]]:[];for(let s=1;s<n.length;s++){const a=n[s];it(a.easing)?r.push(...Ee(n[s-1],a,a.easing,e)):r.push(a)}return{...t,keyframes:r}}function Vn(t,e){return t.filter(Wt).map(n=>$e(n,e)).concat(t.filter(U).map(n=>Xt(n,e)),t.filter(x).map(n=>xt(n,e)))}function Oe(t,e){if(t.length<=2)return t;const n=[t[0]];for(let r=1;r<t.length-1;r++){const s=n[n.length-1],a=t[r],i=t[r+1],o=i.time-s.time;if(o<=0)continue;const c=(a.time-s.time)/o,u=s.value+(i.value-s.value)*c;Math.abs(a.value-u)>e&&n.push(a)}return n.push(t[t.length-1]),n}function Le(t){const e=[...t.keyframes].sort((n,r)=>n.time-r.time);return{...t,keyframes:e}}function B(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function j(t,e,n,r){const s=n??0;return!r||e<=1?s:s+kt(t,e,r)}class mt{track;targets;constructor(e){this.track=e,this.targets=B(e)}getValueAtTime(e){return this.valueForOffset(e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=j(s,n,this.track.delay,this.track.stagger),i=this.valueForOffset(e-a);i!==void 0&&r.push({target:this.targets[s],value:i,start:a+this.track.keyframes[0].time})}return r}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,r=this.track.stagger?ct(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+r+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(e){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||e<=n[0].time)return n[0].value;if(e>=n[n.length-1].time)return n[n.length-1].value;const{from:r,to:s}=this.findSurroundingKeyframes(e);if(!r||!s)return;if(r.time===e)return r.value;const a=s.time-r.time,i=(e-r.time)/a,c=It(s.easing)(i);return Ft(r.value)(r.value,s.value,c)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let r=0;r<n.length-1;r++)if(e>=n[r].time&&e<=n[r+1].time)return{from:n[r],to:n[r+1]};return{from:null,to:null}}}class Fe{track;targets;sampler;constructor(e){this.track=e,this.targets=B(e),this.sampler=new J(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=j(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:this.sampler.valueAt(e-a),start:a})}return r}getDuration(){const e=this.track.stagger?ct(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class Ne{track;targets;duration;constructor(e){this.track=e,this.targets=B(e),this.duration=et(e.inertia)}getValueAtTime(e){return ht(this.track.inertia,e-j(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=j(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:ht(this.track.inertia,e-a),start:a})}return r}getDuration(){const e=this.track.stagger?ct(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Ut(t,e){const n={...de(t.pathData,e)};if(t.matrix){const[r,s,a,i,o,c]=t.matrix,{x:u,y:h}=n;n.x=r*u+a*h+o,n.y=s*u+i*h+c;const f=n.angle*Math.PI/180,g=Math.cos(f),d=Math.sin(f);n.angle=Math.atan2(s*g+i*d,r*g+a*d)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function Yn(t,e,n,r){const s=e+(n-e)*r;return Ut(t,s)}const Vt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Bn=20;function Xe(t){const e=Vt[t??"upperCase"]??t??Vt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Vt.upperCase)}function zn(t,e,n){let r=(t|0)^Math.imul(e+1,2654435761)^Math.imul(n+1,2246822507);return r=Math.imul(r^r>>>16,2146121005),r=Math.imul(r^r>>>15,2221713035),(r^r>>>16)>>>0}function xe(t,e,n=0){const r=t.from??"",s=t.to,a=Math.max(0,Math.min(1,e));if(a<=0)return r;if(a>=1)return s;const i=Array.from(r),o=Array.from(s),c=t.rightToLeft??!1;if(t.mode==="type"){const b=Math.round(a*Math.max(i.length,o.length));return c?i.slice(0,Math.max(0,i.length-b)).join("")+o.slice(Math.max(0,o.length-b)).join(""):o.slice(0,b).join("")+i.slice(b).join("")}const u=Math.max(0,Math.min(.999,t.revealDelay??0)),h=Math.max(0,(a-u)/(1-u)),f=Math.floor(h*o.length),g=t.tweenLength===!1?o.length:Math.round(i.length+(o.length-i.length)*a),d=Xe(t.chars),M=t.refreshRate??Bn,m=M>0?Math.floor(n*M/1e3):0,p=t.seed??1;let T="";for(let b=0;b<g;b++){const A=c?b>=g-f:b<f,w=c?o[o.length-(g-b)]:o[b];A&&w!==void 0||w===" "||w===`
2
+ `?T+=w:T+=d[zn(p,b,m)%d.length]}return T}class Ue{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(e){if(this.id=e.id,this.name=e.name,this._captions=e.captions,this._config=e.config??{},this._explicitDuration=e.config?.duration,e.tracks)for(const n of e.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(e){if(this._explicitDuration=e,e!==void 0)this._config={...this._config,duration:e};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(e){this._config.speed=e}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,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(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=e*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=o,s-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const a=1e3;for(let o=0;o<a&&s>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(s>=c){if(s-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const c=this._currentTime;if(s>=c){if(s-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const i=this.getStateAtTime(this._currentTime);this.onUpdate?.(i)}getStateAtTime(e){const n=new Map;if(this._hasSharedWrites())this._resolveShared(e,n);else for(const[r,s]of this._trackPlayers){const a=s.getTrack().property;for(const{target:i,value:o,start:c}of s.getTargetValues(e))this._write(n,r,i,a,o,e-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const r=new Map;for(const[s,a]of this._trackPlayers){const i=a.getTrack().property;for(const{target:o,value:c,start:u}of a.getTargetValues(e)){const h=`${o}\0${i}`,f=u<=e,g=r.get(h);(!g||(f!==g.started?f:f?u>=g.start:u<=g.start))&&r.set(h,{trackId:s,target:o,property:i,value:c,start:u,started:f})}}for(const{trackId:s,target:a,property:i,value:o,start:c}of r.values())this._write(n,s,a,i,o,e-c)}_write(e,n,r,s,a,i){if(a===void 0)return;let o=e.get(r);o||(o=new Map,e.set(r,o));const c=this._textTracks.get(n);if(c&&typeof a=="number"){o.set("text",xe(c.textConfig,a,Math.max(0,i)));return}const u=this._motionPathTracks.get(n);if(u&&typeof a=="number"){const h=Ut(u.motionPathConfig,a);o.set("motionPathX",h.x),o.set("motionPathY",h.y),u.motionPathConfig.autoRotate&&o.set("motionPathRotate",h.angle)}else o.set(s,a)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const r of B(n)){const s=`${r}\0${n.property}`;if(e.has(s)){this._sharedWrites=!0;break t}e.add(s)}}return this._sharedWrites}addTrack(e){if(this._tracks.push(e),this._sharedWrites=null,x(e)){this._trackPlayers.set(e.id,new Ne(e));return}if(U(e)){this._trackPlayers.set(e.id,new Fe(e)),this._springTracks.set(e.id,e);return}if(ot(e))this._trackPlayers.set(e.id,new mt(e)),this._textTracks.set(e.id,e);else if(Tt(e)){const n={id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,delay:e.delay,endDelay:e.endDelay,targets:e.targets,stagger:e.stagger};this._trackPlayers.set(e.id,new mt(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new mt(e))}replaceTrack(e,n){const r=this._tracks.findIndex(a=>a.id===e);if(r<0)return;const s=this._tracks.slice(r+1);this.removeTrack(e);for(const a of s)this.removeTrack(a.id);this.addTrack(n);for(const a of s)this.addTrack(a)}removeTrack(e){this._tracks=this._tracks.filter(n=>n.id!==e),this._sharedWrites=null,this._trackPlayers.delete(e),this._motionPathTracks.delete(e),this._springTracks.delete(e),this._textTracks.delete(e)}getTracks(e={}){return this._tracks.filter(n=>this._matches(n,e))}removeTracks(e={}){const n=this.getTracks(e).map(r=>r.id);for(const r of n)this.removeTrack(r);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const r=n.getTrack(),s=r.delay??0;if(U(r)||x(r))return{from:s,to:n.getDuration()};const a=r.keyframes;if(!(!a||a.length===0))return{from:a[0].time+s,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const r=this._tracks[n],s=this.getTrackSpan(r.id);if(s)for(let a=0;a<n;a++){const i=this._tracks[a];if(i.property!==r.property)continue;const o=B(i).filter(f=>B(r).includes(f));if(o.length===0)continue;const c=this.getTrackSpan(i.id);if(!c||!(c.from<=s.to&&s.from<=c.to))continue;const h=s.from>=c.from;for(const f of o)e.push({target:f,property:r.property,losingTrackId:h?i.id:r.id,winningTrackId:h?r.id:i.id})}}return e}_matches(e,n){if(n.id!==void 0&&e.id!==n.id||n.property!==void 0&&e.property!==n.property||n.target!==void 0&&!B(e).includes(n.target))return!1;if(n.timeRange){const r=this.getTrackSpan(e.id);if(!r||r.to<n.timeRange.from||r.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Z,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((e,n)=>e.time-n.time)}setMarkers(e){const n=e&&e.length>0?[...e].sort((s,a)=>s.time-a.time).map(s=>({...s})):void 0,r={...this._config};n?r.markers=n:delete r.markers,this._config=r}get captions(){return this._captions}setCaptions(e){const n={};for(const[r,s]of Object.entries(e??{}))n[r]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let e=0;for(const[,n]of this._trackPlayers)e=Math.max(e,n.getDuration());return e}_handleEndReached(){const e=this._config.loop??0;return e===-1||this._loopIteration<e?(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 e=this._config.loop??0;return this._config.alternate&&(e===-1||this._loopIteration<e)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Hn=100;function qn(t,e,n,r){const s=[],a=[],{duration:i,alternate:o}=r,c=(d,M,m,p)=>{a.push([d,M]);const T=[];t.forEach((b,A)=>{(m==="forward"?(p?b>=d:b>d)&&b<=M:(p?b<=d:b<d)&&b>=M)&&T.push(A)}),T.sort((b,A)=>(m==="forward"?t[b]-t[A]:t[A]-t[b])||b-A);for(const b of T)s.push({kind:"event",index:b,direction:m})};let u=e.time,h=e.direction,f=e.fresh===!0;const g=Math.min(Hn,Math.max(0,n.iteration-e.iteration));for(let d=0;d<g;d++){const M=h==="forward"?i:0;c(u,M,h,f),s.push({kind:"repeat"}),o?(h=h==="forward"?"reverse":"forward",u=M,f=!1):(u=h==="forward"?0:i,f=!0)}return g>0&&r.holding&&!o?{crossings:s,passes:a}:(c(u,n.time,h,f),{crossings:s,passes:a})}function Ve(t){return x(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Ye(t.inertia),...N(t)}:U(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...N(t)}:ot(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(Yt),...N(t)}:Tt(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(Yt),...N(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(Yt),...N(t)}}function Ye(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function Yt(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function N(t){const e=t.endDelay;return{...t.delay!==void 0&&{delay:t.delay},...e!==void 0&&{endDelay:e},...t.targets!==void 0&&{targets:[...t.targets]},...t.stagger!==void 0&&{stagger:{...t.stagger}}}}function Be(t){if(x(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Ye(e.inertia),...N(e)}}if(U(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...N(e)}}if(ot(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,r)=>n.time-r.time),...N(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((r,s)=>r.time-s.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...N(e)}}return Le({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...N(t)})}function ze(t){const e=t._config.markers;return{formatVersion:Z,id:t.id,name:t.name,config:{duration:t.duration>0?t.duration:void 0,loop:t._config.loop,speed:t._config.speed,alternate:t._config.alternate,repeatDelay:t._config.repeatDelay,...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(Ve),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function He(t){const e=t.formatVersion??1;if(e>Z)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${Z}. Update tinyfly to play it.`);return new Ue({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(Be),captions:t.captions})}function Kn(t){return JSON.stringify(ze(t))}function Wn(t){const e=JSON.parse(t);return He(e)}function jn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function qe(t){let e=t>>>0||2654435769;return{seed:t>>>0,next(){return e^=e<<13,e>>>=0,e^=e>>17,e^=e<<5,e>>>=0,e/4294967296}}}function Bt(t,e,n){return e+t.next()*(n-e)}function Ke(t,e,n,r){if(r<=0)return Bt(t,e,n);const s=Math.floor((n-e)/r),a=Math.round(t.next()*s);return e+a*r}function Gn(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const We=/^([+\-*/])=\s*(-?[\d.]+)$/,je=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Qn(t){return typeof t!="string"?!1:We.test(t.trim())||je.test(t.trim())}function zt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=We.exec(n);if(r){const[,a,i]=r,o=e.base??0,c=Number.parseFloat(i);switch(a){case"+":return o+c;case"-":return o-c;case"*":return o*c;case"/":return c===0?o:o/c}}const s=je.exec(n);if(s){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const a=Number.parseFloat(s[1]),i=Number.parseFloat(s[2]),o=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return o!==void 0?Ke(e.random,a,i,o):Bt(e.random,a,i)}return t}function Ge(t,e=0,n){const r=[];let s=e;for(const a of t){const i=zt(a,{base:s,random:n});r.push(i),typeof i=="number"&&(s=i)}return r}class Zn{random;constructor(e){this.random=qe(e)}get seed(){return this.random.seed}resolve(e,n=0){return zt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return Ge(e,n,this.random)}}const Jn=600;function tr(t){if(Array.isArray(t)){const[g,d,M,m]=t;return{fn:Qe(g,d,M,m),bezier:[g,d,M,m]}}const{segments:e}=z(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,r=e[0].startY,s=e[e.length-1],a=s.endX-n,i=s.endY-r;if(a===0||i===0)throw new Error(`customEase: "${t}" must move along both axes`);const o=g=>(g-n)/a,c=g=>(g-r)/i;if(e.length===1&&s.type==="C"){const[g,d,M,m]=s.points,p=[o(g),c(d),o(M),c(m)];return{fn:Qe(...p),bezier:p}}const u=[],h=[],f=Math.max(8,Math.ceil(Jn/e.length));for(const g of e)for(let d=u.length===0?0:1;d<=f;d++){const[M,m]=rr(g,d/f);u.push(o(M)),h.push(c(m))}return{fn:sr(u,h)}}function er(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,r=[1];for(let a=n;a>.002;a*=n)r.push(2*Math.sqrt(a));const s=r.reduce((a,i)=>a+i,0);return a=>{if(a<=0)return 0;if(a>=1)return 1;let i=a*s;for(let o=0;o<r.length;o++){if(i<=r[o]){if(o===0)return(i/r[0])**2;const c=r[o]/2,u=c*c,h=i-c;return 1-(u-h*h)}i-=r[o]}return 1}}function nr(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",r=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*e*Math.PI*2)*r(s)}function rr(t,e){if(t.type==="L"){const[u,h]=t.points;return[t.startX+(u-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,r,s,a,i,o]=t.points,c=1-e;return[c*c*c*t.startX+3*c*c*e*n+3*c*e*e*s+e*e*e*i,c*c*c*t.startY+3*c*c*e*r+3*c*e*e*a+e*e*e*o]}function sr(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let r=0,s=t.length-1;for(;s-r>1;){const i=r+s>>1;t[i]<=n?r=i:s=i}const a=t[s]-t[r];return a===0?e[s]:e[r]+(n-t[r])/a*(e[s]-e[r])}}function Qe(t,e,n,r){const s=(i,o,c)=>3*(1-i)*(1-i)*i*o+3*(1-i)*i*i*c+i*i*i,a=(i,o,c)=>3*(1-i)*(1-i)*o+6*(1-i)*i*(c-o)+3*i*i*(1-c);return i=>{if(i<=0)return 0;if(i>=1)return 1;let o=i;for(let h=0;h<8;h++){const f=s(o,t,n)-i,g=a(o,t,n);if(Math.abs(f)<1e-6)return s(o,e,r);if(Math.abs(g)<1e-6)break;o-=f/g}let c=0,u=1;o=i;for(let h=0;h<40;h++)s(o,t,n)<i?c=o:u=o,o=(c+u)/2;return s(o,e,r)}}const ar=350,ir=300,or=550;function cr(t,e={}){const n=e.lead??ar,r=e.gap??ir,s=e.tail??or,a=[];let i=0;return t.forEach((o,c)=>{const u=[];let h=i+n;o.lines.forEach((g,d)=>{if(!(g.duration>=0))throw new Error(`narration: scene ${c} line ${d} has an invalid duration (${g.duration})`);d>0&&(h+=r),u.push({id:g.id??`s${c}-l${d}`,scene:c,line:d,start:h,end:h+g.duration,text:g.text}),h+=g.duration});const f=h+s+(o.tail??0);a.push({id:o.id??`s${c}`,start:i,duration:f-i,cues:u}),i=f}),{duration:i,scenes:a,cues:a.flatMap(o=>o.cues)}}function ur(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function lr(t,e){let n=t.scenes[0];for(const r of t.scenes)if(e>=r.start)n=r;else break;return n}const Ht=t=>6e4/t.bpm;function pt(t,e){return t.offset+e*Ht(t)}function yt(t,e){return(e-t.offset)/Ht(t)}function hr(t,e){return pt(t,Math.round(yt(t,e)))}function fr(t,e){return pt(t,Math.ceil(yt(t,e)-1e-9))}function dr(t,e,n){const r=Math.max(1,Math.round(t.beatsPerBar??4)),s=[];if(!(t.bpm>0)||n<e)return s;for(let a=Math.ceil(yt(t,e)-1e-9);;a++){const i=pt(t,a);if(i>n+1e-9)break;s.push({time:i,bar:(a%r+r)%r===0,n:a})}return s}const G=100;function gr(t,e,n={}){const r=n.minBpm??70,s=n.maxBpm??180,a=Math.max(1,Math.round(e/G)),i=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),o=Math.floor(i/a);if(o<4)return{bpm:120,offset:0,confidence:0};const c=new Float64Array(o);for(let y=0;y<o;y++){let k=0;for(let S=y*a;S<(y+1)*a;S++)k+=t[S]*t[S];c[y]=Math.log(1e-6+k/a)}const u=new Float64Array(o);for(let y=1;y<o;y++)u[y]=Math.max(0,c[y]-c[y-1]);const h=u.reduce((y,k)=>y+k,0)/o;for(let y=0;y<o;y++)u[y]=Math.max(0,u[y]-h);const f=Math.max(1,Math.floor(60*G/s)),g=Math.min(o-1,Math.ceil(60*G/r)),d=y=>{let k=0;for(let S=y;S<o;S++)k+=u[S]*u[S-y];return k/(o-y)};let M=0;for(let y=0;y<o;y++)M+=u[y]*u[y];M/=o;let m=f,p=-1/0;for(let y=f;y<=g;y++){const k=60*G/y,S=Math.exp(-.5*(Math.log2(k/120)/.9)**2),P=d(y)*S;P>p&&(p=P,m=y)}const T=y=>{const k=Math.floor(y);return k<0||k+1>=o?0:u[k]+(u[k+1]-u[k])*(y-k)},b=(y,k)=>{let S=0;for(let P=k;P<o;P+=y)S+=T(P);return S};let A=m,w=0,_=-1/0;for(let y=m-.6;y<=m+.6+1e-9;y+=.02){if(y<1)continue;const k=Math.max(1,Math.round(y*4));for(let S=0;S<k;S++){const P=S/k*y,C=b(y,P);C>_&&(_=C,w=P,A=y)}}const R=60*G/A,v=M>0?Math.max(0,Math.min(1,d(m)/M)):0,L=(w+.5)*1e3/G;return{bpm:Math.round(R*100)/100,offset:Math.round(L%(6e4/R)),confidence:v}}const X=t=>Math.round(t*1e3)/1e3;function mr(t,e={}){if(t.length===0)return"";const n=e.curviness??1,r=e.closed??!1,s=t.length;let a=`M${X(t[0].x)} ${X(t[0].y)}`;if(s===1)return a;const i=c=>r?t[(c%s+s)%s]:t[Math.max(0,Math.min(s-1,c))],o=r?s:s-1;for(let c=0;c<o;c++){const u=i(c-1),h=i(c),f=i(c+1),g=i(c+2);if(n===0){a+=` L${X(f.x)} ${X(f.y)}`;continue}const d=n/6,M=h.x+(f.x-u.x)*d,m=h.y+(f.y-u.y)*d,p=f.x-(g.x-h.x)*d,T=f.y-(g.y-h.y)*d;a+=` C${X(M)} ${X(m)} ${X(p)} ${X(T)} ${X(f.x)} ${X(f.y)}`}return r?`${a} Z`:a}const D=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function pr(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let r=0;r+1<e.length;r+=2)n.push({x:e[r],y:e[r+1]});return n}function yr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=D(e.cx),r=D(e.cy),s=t.tag.toLowerCase()==="circle"?D(e.r):D(e.rx),a=t.tag.toLowerCase()==="circle"?D(e.r):D(e.ry);return`M${n+s} ${r} A${s} ${a} 0 1 1 ${n-s} ${r} A${s} ${a} 0 1 1 ${n+s} ${r} Z`}case"rect":{const n=D(e.x),r=D(e.y),s=D(e.width),a=D(e.height);let i=e.rx!=null?D(e.rx):e.ry!=null?D(e.ry):0,o=e.ry!=null?D(e.ry):i;return i=Math.min(i,s/2),o=Math.min(o,a/2),i===0||o===0?`M${n} ${r} H${n+s} V${r+a} H${n} Z`:`M${n+i} ${r} H${n+s-i} A${i} ${o} 0 0 1 ${n+s} ${r+o} V${r+a-o} A${i} ${o} 0 0 1 ${n+s-i} ${r+a} H${n+i} A${i} ${o} 0 0 1 ${n} ${r+a-o} V${r+o} A${i} ${o} 0 0 1 ${n+i} ${r} Z`}case"line":return`M${D(e.x1)} ${D(e.y1)} L${D(e.x2)} ${D(e.y2)}`;case"polyline":case"polygon":{const n=pr(e.points);if(n.length===0)return null;const r=n.map((s,a)=>`${a===0?"M":"L"}${s.x} ${s.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${r} Z`:r}default:return null}}l.Clock=rn,l.DEFAULT_BAKE_INTERVAL_MS=Nt,l.DEFAULT_INERTIA_FRICTION=At,l.DEFAULT_SPRING=O,l.FORMAT_VERSION=Z,l.INERTIA_MAX_DURATION_MS=Qt,l.InertiaTrackPlayer=Ne,l.MORPH_SAMPLES=Rn,l.ManualClock=nn,l.SPRING_MAX_DURATION_MS=St,l.SPRING_PRESETS=sn,l.SPRING_STEP_MS=K,l.SpringSampler=J,l.SpringTrackPlayer=Fe,l.Timeline=Ue,l.TrackPlayer=mt,l.ValueResolver=Zn,l.backOut=ce,l.bakeEasing=Ee,l.bakeInertiaTrack=xt,l.bakeSpringTrack=Xt,l.beatAtTime=yt,l.beatLength=Ht,l.beatTime=pt,l.beatsBetween=dr,l.bounceOut=oe,l.charactersFor=Xe,l.clearMorphCache=Nn,l.clearPathCache=Sn,l.createCubicBezier=ae,l.createRandom=qe,l.createTrack=Le,l.criticalDamping=un,l.customBounce=er,l.customEase=tr,l.customWiggle=nr,l.deserializeTimeline=He,l.deserializeTrack=Be,l.detectTempo=gr,l.easeIn=ne,l.easeInCubic=Pt,l.easeInOut=se,l.easeInOutCubic=wt,l.easeInOutQuad=ee,l.easeInQuad=Jt,l.easeOut=re,l.easeOutCubic=vt,l.easeOutQuad=te,l.elasticOut=ie,l.expandParametricEasings=$e,l.fromJSON=Wn,l.getEasingFunction=It,l.getInterpolator=Ft,l.getMotionPathPoint=Ut,l.getPathLength=An,l.getPointAtProgress=de,l.hasKeyframes=Wt,l.hashSeed=jn,l.inertiaDuration=et,l.inertiaRest=tt,l.inertiaValueAt=ht,l.inertiaVelocityAt=dn,l.interpolateArray=Ie,l.interpolateColor=Re,l.interpolateMotionPath=Yn,l.interpolateNumber=F,l.interpolatePathString=De,l.interpolateString=Lt,l.isCubicBezierEasing=q,l.isInertiaTrack=x,l.isMotionPathPoint=en,l.isMotionPathTrack=Tt,l.isParametricEasing=it,l.isPathData=be,l.isSpringTrack=U,l.isTextTrack=ot,l.isUnderdamped=cn,l.isUnresolved=Qn,l.linear=ft,l.maxStaggerDistance=jt,l.morphPath=Te,l.narrationMarkers=ur,l.narrationSceneAt=lr,l.naturalRest=Zt,l.nearestBeat=hr,l.nextBeat=fr,l.parametricEasing=le,l.parsePath=z,l.planNarration=cr,l.playheadCrossings=qn,l.pointAtDistance=Dt,l.pointsToPath=mr,l.randomBetween=Bt,l.randomChoice=Gn,l.randomSnapped=Ke,l.resolveSequence=Ge,l.resolveValue=zt,l.serializeTimeline=ze,l.serializeTrack=Ve,l.shapeToPathData=yr,l.simplifyKeyframes=Oe,l.springDuration=on,l.springValueAt=an,l.staggerDistance=bt,l.staggerOffset=kt,l.staggerOffsets=Gt,l.staggerSpan=ct,l.stepsEasing=ue,l.textAt=xe,l.toJSON=Kn,l.toKeyframedTrack=Un,l.toKeyframedTracks=Vn,l.trackTargets=B,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,398 @@
1
+ import type { EasingType, Track } from '../engine/types';
2
+ import { type StickPose } from './stick-figure';
3
+ /**
4
+ * Flips and other acrobatics for the stick figure, as plain data.
5
+ *
6
+ * A flip is one continuous motion through its phases: wind up (crouch, arms
7
+ * back), take off (arms swing up, toes push), the air (tuck or layout while
8
+ * the body turns), and land (absorb in a crouch, stand). `progress` runs 0 → 1
9
+ * through all of it.
10
+ *
11
+ * The body's pose is keyed like any pose. The turn and the height are not
12
+ * keyed: between take-off and landing the hips follow a parabola (as anything
13
+ * thrown does) and the turn eases in and out, quickest at the top, where a
14
+ * real tuck spins fastest. After landing the turn is a whole number of turns,
15
+ * drawn as none, so the figure can blend on into any other pose.
16
+ */
17
+ export interface FlipKey {
18
+ /** When, 0..1 of the whole move */
19
+ at: number;
20
+ /** Joints that change from the previous key (the first key builds on the view's stance) */
21
+ pose?: Partial<StickPose>;
22
+ /** Start again from the stance before applying `pose` */
23
+ reset?: boolean;
24
+ /** Easing into this key (default ease-in-out) */
25
+ easing?: EasingType;
26
+ }
27
+ export interface Flip {
28
+ label: string;
29
+ /** How the figure is seen: 0 front-on (side flips, cartwheels), 1 in profile (front and back flips) */
30
+ view: number;
31
+ /** Total turn in the air, degrees: positive rolls forward, negative backward */
32
+ spin: number;
33
+ /** Height of the hips' arc above standing, as a fraction of the height */
34
+ height: number;
35
+ /** Ground covered, as a fraction of the height (positive the way the figure faces) */
36
+ travel: number;
37
+ /** Feet leave the ground, 0..1 */
38
+ takeoff: number;
39
+ /** Feet touch down again, 0..1 */
40
+ landing: number;
41
+ /** How long the whole move takes at its natural speed, ms */
42
+ duration: number;
43
+ keys: FlipKey[];
44
+ }
45
+ /**
46
+ * The figure `progress` (0..1) of the way through a flip. The pose is in the
47
+ * figure's own place: add {@link flipTravel} to its x to move it across.
48
+ */
49
+ export declare function flipPose(flip: Flip | FlipName, progress: number): StickPose;
50
+ /**
51
+ * Ground covered `progress` of the way through a flip, px for a figure
52
+ * `height` px tall: none while winding up, steady through the air, none after.
53
+ */
54
+ export declare function flipTravel(flip: Flip | FlipName, progress: number, height: number): number;
55
+ export interface FlipTrackOptions {
56
+ /** When the flip starts, ms (default 0) */
57
+ start?: number;
58
+ /** How long it takes, ms (default the flip's own duration) */
59
+ duration?: number;
60
+ /** Keyframes over the whole flip (default 48) */
61
+ samples?: number;
62
+ /**
63
+ * The figure's height in px, to move it across by the flip's `travel` (an
64
+ * `x` offset track). Omit to flip on the spot.
65
+ */
66
+ height?: number;
67
+ /** Facing: -1 travels to the left (default 1) */
68
+ facing?: number;
69
+ /** An x offset the travel starts from (default 0) */
70
+ x?: number;
71
+ }
72
+ /**
73
+ * The flip as keyframe tracks for a stick-figure target: every joint that
74
+ * moves, plus `spin` and `rise` (and `x` when `height` is given). Plain JSON,
75
+ * so a flip saves, scrubs and renders like any other animation.
76
+ */
77
+ export declare function flipTracks(target: string, flip: Flip | FlipName, options?: FlipTrackOptions): Track[];
78
+ /**
79
+ * Ready-made flips and leaps. Each is plain data: copy one and change it to
80
+ * make your own. Side flips, cartwheels and toe touches are seen front-on,
81
+ * the rest in profile.
82
+ */
83
+ export declare const FLIPS: {
84
+ frontFlip: Flip;
85
+ backFlip: Flip;
86
+ layout: Flip;
87
+ scissorFlip: Flip;
88
+ sideFlip: {
89
+ label: string;
90
+ view: number;
91
+ spin: number;
92
+ height: number;
93
+ travel: number;
94
+ takeoff: number;
95
+ landing: number;
96
+ duration: number;
97
+ keys: ({
98
+ at: number;
99
+ reset: true;
100
+ pose?: undefined;
101
+ easing?: undefined;
102
+ } | {
103
+ at: number;
104
+ pose: {
105
+ leftHip: number;
106
+ rightHip: number;
107
+ leftKnee: number;
108
+ rightKnee: number;
109
+ leftShoulder: number;
110
+ rightShoulder: number;
111
+ lean: number;
112
+ stretch: number;
113
+ leftAnkle?: undefined;
114
+ rightAnkle?: undefined;
115
+ leftElbow?: undefined;
116
+ rightElbow?: undefined;
117
+ headTilt?: undefined;
118
+ };
119
+ reset?: undefined;
120
+ easing?: undefined;
121
+ } | {
122
+ at: number;
123
+ pose: {
124
+ leftHip: number;
125
+ rightHip: number;
126
+ leftKnee: number;
127
+ rightKnee: number;
128
+ leftAnkle: number;
129
+ rightAnkle: number;
130
+ leftShoulder: number;
131
+ rightShoulder: number;
132
+ lean: number;
133
+ stretch: number;
134
+ leftElbow?: undefined;
135
+ rightElbow?: undefined;
136
+ headTilt?: undefined;
137
+ };
138
+ easing: "ease-out-quad";
139
+ reset?: undefined;
140
+ } | {
141
+ at: number;
142
+ pose: {
143
+ leftHip: number;
144
+ rightHip: number;
145
+ leftKnee: number;
146
+ rightKnee: number;
147
+ leftShoulder: number;
148
+ rightShoulder: number;
149
+ leftElbow: number;
150
+ rightElbow: number;
151
+ lean: number;
152
+ stretch: number;
153
+ headTilt: number;
154
+ leftAnkle?: undefined;
155
+ rightAnkle?: undefined;
156
+ };
157
+ easing: "ease-out-cubic";
158
+ reset?: undefined;
159
+ } | {
160
+ at: number;
161
+ pose: {
162
+ leftHip?: undefined;
163
+ rightHip?: undefined;
164
+ leftKnee?: undefined;
165
+ rightKnee?: undefined;
166
+ leftShoulder?: undefined;
167
+ rightShoulder?: undefined;
168
+ lean?: undefined;
169
+ stretch?: undefined;
170
+ leftAnkle?: undefined;
171
+ rightAnkle?: undefined;
172
+ leftElbow?: undefined;
173
+ rightElbow?: undefined;
174
+ headTilt?: undefined;
175
+ };
176
+ reset?: undefined;
177
+ easing?: undefined;
178
+ } | {
179
+ at: number;
180
+ pose: {
181
+ leftHip: number;
182
+ rightHip: number;
183
+ leftKnee: number;
184
+ rightKnee: number;
185
+ leftAnkle: number;
186
+ rightAnkle: number;
187
+ leftShoulder: number;
188
+ rightShoulder: number;
189
+ leftElbow: number;
190
+ rightElbow: number;
191
+ headTilt: number;
192
+ lean?: undefined;
193
+ stretch?: undefined;
194
+ };
195
+ reset?: undefined;
196
+ easing?: undefined;
197
+ } | {
198
+ at: number;
199
+ pose: {
200
+ leftHip: number;
201
+ rightHip: number;
202
+ leftKnee: number;
203
+ rightKnee: number;
204
+ leftAnkle: number;
205
+ rightAnkle: number;
206
+ leftShoulder: number;
207
+ rightShoulder: number;
208
+ stretch: number;
209
+ lean?: undefined;
210
+ leftElbow?: undefined;
211
+ rightElbow?: undefined;
212
+ headTilt?: undefined;
213
+ };
214
+ easing: "ease-out-quad";
215
+ reset?: undefined;
216
+ })[];
217
+ };
218
+ cartwheel: {
219
+ label: string;
220
+ view: number;
221
+ spin: number;
222
+ height: number;
223
+ travel: number;
224
+ takeoff: number;
225
+ landing: number;
226
+ duration: number;
227
+ keys: ({
228
+ at: number;
229
+ reset: true;
230
+ pose?: undefined;
231
+ } | {
232
+ at: number;
233
+ pose: {
234
+ leftShoulder: number;
235
+ rightShoulder: number;
236
+ rightHip: number;
237
+ rightKnee: number;
238
+ lean: number;
239
+ leftHip?: undefined;
240
+ leftKnee?: undefined;
241
+ leftAnkle?: undefined;
242
+ rightAnkle?: undefined;
243
+ };
244
+ reset?: undefined;
245
+ } | {
246
+ at: number;
247
+ pose: {
248
+ leftShoulder: number;
249
+ rightShoulder: number;
250
+ leftHip: number;
251
+ rightHip: number;
252
+ leftKnee: number;
253
+ rightKnee: number;
254
+ leftAnkle: number;
255
+ rightAnkle: number;
256
+ lean: number;
257
+ };
258
+ reset?: undefined;
259
+ } | {
260
+ at: number;
261
+ pose: {
262
+ leftShoulder?: undefined;
263
+ rightShoulder?: undefined;
264
+ rightHip?: undefined;
265
+ rightKnee?: undefined;
266
+ lean?: undefined;
267
+ leftHip?: undefined;
268
+ leftKnee?: undefined;
269
+ leftAnkle?: undefined;
270
+ rightAnkle?: undefined;
271
+ };
272
+ reset?: undefined;
273
+ } | {
274
+ at: number;
275
+ pose: {
276
+ leftHip: number;
277
+ rightHip: number;
278
+ leftAnkle: number;
279
+ rightAnkle: number;
280
+ leftShoulder: number;
281
+ rightShoulder: number;
282
+ rightKnee?: undefined;
283
+ lean?: undefined;
284
+ leftKnee?: undefined;
285
+ };
286
+ reset?: undefined;
287
+ })[];
288
+ };
289
+ splitLeap: Flip;
290
+ toeTouch: {
291
+ label: string;
292
+ view: number;
293
+ spin: number;
294
+ height: number;
295
+ travel: number;
296
+ takeoff: number;
297
+ landing: number;
298
+ duration: number;
299
+ keys: ({
300
+ at: number;
301
+ reset: true;
302
+ pose?: undefined;
303
+ easing?: undefined;
304
+ } | {
305
+ at: number;
306
+ pose: {
307
+ leftHip: number;
308
+ rightHip: number;
309
+ leftKnee: number;
310
+ rightKnee: number;
311
+ leftShoulder: number;
312
+ rightShoulder: number;
313
+ stretch: number;
314
+ leftAnkle?: undefined;
315
+ rightAnkle?: undefined;
316
+ leftElbow?: undefined;
317
+ rightElbow?: undefined;
318
+ headTilt?: undefined;
319
+ };
320
+ reset?: undefined;
321
+ easing?: undefined;
322
+ } | {
323
+ at: number;
324
+ pose: {
325
+ leftHip: number;
326
+ rightHip: number;
327
+ leftKnee: number;
328
+ rightKnee: number;
329
+ leftAnkle: number;
330
+ rightAnkle: number;
331
+ leftShoulder: number;
332
+ rightShoulder: number;
333
+ stretch: number;
334
+ leftElbow?: undefined;
335
+ rightElbow?: undefined;
336
+ headTilt?: undefined;
337
+ };
338
+ easing: "ease-out-quad";
339
+ reset?: undefined;
340
+ } | {
341
+ at: number;
342
+ pose: {
343
+ leftHip: number;
344
+ rightHip: number;
345
+ leftShoulder: number;
346
+ rightShoulder: number;
347
+ leftElbow: number;
348
+ rightElbow: number;
349
+ stretch: number;
350
+ headTilt: number;
351
+ leftKnee?: undefined;
352
+ rightKnee?: undefined;
353
+ leftAnkle?: undefined;
354
+ rightAnkle?: undefined;
355
+ };
356
+ easing: "ease-out-cubic";
357
+ reset?: undefined;
358
+ } | {
359
+ at: number;
360
+ pose: {
361
+ leftHip?: undefined;
362
+ rightHip?: undefined;
363
+ leftKnee?: undefined;
364
+ rightKnee?: undefined;
365
+ leftShoulder?: undefined;
366
+ rightShoulder?: undefined;
367
+ stretch?: undefined;
368
+ leftAnkle?: undefined;
369
+ rightAnkle?: undefined;
370
+ leftElbow?: undefined;
371
+ rightElbow?: undefined;
372
+ headTilt?: undefined;
373
+ };
374
+ reset?: undefined;
375
+ easing?: undefined;
376
+ } | {
377
+ at: number;
378
+ pose: {
379
+ leftHip: number;
380
+ rightHip: number;
381
+ leftAnkle: number;
382
+ rightAnkle: number;
383
+ leftShoulder: number;
384
+ rightShoulder: number;
385
+ leftKnee?: undefined;
386
+ rightKnee?: undefined;
387
+ stretch?: undefined;
388
+ leftElbow?: undefined;
389
+ rightElbow?: undefined;
390
+ headTilt?: undefined;
391
+ };
392
+ reset?: undefined;
393
+ easing?: undefined;
394
+ })[];
395
+ };
396
+ backHandspring: Flip;
397
+ };
398
+ export type FlipName = keyof typeof FLIPS;
@@ -67,7 +67,13 @@ export interface CharacterOptions {
67
67
  * `hand.right.index.curl`; see {@link characterHandPose})
68
68
  */
69
69
  hands?: 'dot' | 'cartoon';
70
- /** Cartoon hand length, wrist to fingertip, fraction of the height (default 0.17: a cartoon glove) */
70
+ /**
71
+ * Cartoon hands as `glove` (default: a thumb and three plump fingers, the
72
+ * classic cartoon glove) or `natural` (five slimmer fingers, so shapes like
73
+ * mudras read finger by finger)
74
+ */
75
+ handStyle?: 'glove' | 'natural';
76
+ /** Cartoon hand length, wrist to fingertip, fraction of the height (default 0.17 for gloves, 0.14 natural) */
71
77
  handSize?: number;
72
78
  }
73
79
  /** A character, with every option resolved. Plain data plus its plan. */
@@ -84,6 +90,7 @@ export interface Character {
84
90
  layers: CharacterLayers;
85
91
  contact: 'ground' | 'none';
86
92
  hands: 'dot' | 'cartoon';
93
+ handStyle: 'glove' | 'natural';
87
94
  handSize: number;
88
95
  }
89
96
  export declare function character(options?: CharacterOptions): Character;