UNPKG

@okikio/animate

Version:

An animation library for the modern web which utilizes the Web Animation API (WAAPI) to create butter smooth animation.

2 lines (1 loc) 32.5 kB
var it=Object.defineProperty;var At=e=>it(e,"__esModule",{value:!0});var kt=(e,t)=>{At(e);for(var i in t)it(e,i,{get:t[i],enumerable:!0})};kt(exports,{ALL_TIMING_KEYS:()=>ge,Animate:()=>K,ApplyCustomEasing:()=>Be,Back:()=>se,Bezier:()=>He,Bounce:()=>ae,CSSArrValue:()=>V,CSSPXDataType:()=>Ke,CSSValue:()=>Z,Circ:()=>re,ComplexEasingSyntax:()=>pe,ComplexStrtoArr:()=>ft,Cubic:()=>J,CustomEasing:()=>Ye,CustomEasingOptions:()=>$e,DefaultAnimationOptions:()=>Je,DestroyableAnimate:()=>tt,EASINGS:()=>Xe,EFFECTS:()=>Ot,EaseInOut:()=>A,EaseOut:()=>C,EaseOutIn:()=>k,EasingDurationCache:()=>Ae,EasingFunctionKeys:()=>R,EasingFunctions:()=>z,EasingKeys:()=>we,EasingPts:()=>gt,Elastic:()=>oe,Expo:()=>ie,FUNCTION_SUPPORTED_TIMING_KEYS:()=>et,GetEase:()=>ye,GetEasingFunction:()=>ue,INTINITE_LOOP_LIMIT:()=>lt,KeyframeParse:()=>Le,NOT_FUNCTION_SUPPORTED_TIMING_KEYS:()=>Et,ParseCSSProperties:()=>Ne,ParseTransformableCSSKeyframes:()=>ze,ParseTransformableCSSProperties:()=>je,Quad:()=>X,Quart:()=>ee,Quint:()=>te,Sine:()=>ne,Spring:()=>H,SpringEasing:()=>qt,Steps:()=>ke,TransformFunctionNames:()=>Te,TransformFunctions:()=>ve,TweenCache:()=>Pe,UIDCount:()=>Tt,UnitDEG:()=>Ee,UnitDEGCSSValue:()=>T,UnitLess:()=>B,UnitLessCSSValue:()=>P,UnitPX:()=>Se,UnitPXCSSValue:()=>x,addCSSUnit:()=>de,animate:()=>Ut,camelCase:()=>be,computeOption:()=>St,convertToDash:()=>W,createEmptyEl:()=>xt,createTransformProperty:()=>Ve,easein:()=>le,flatten:()=>Me,getEasingDuration:()=>pt,getElements:()=>dt,getTargets:()=>D,interpolateColor:()=>yt,interpolateComplex:()=>me,interpolateNumber:()=>Oe,interpolateString:()=>ct,interpolateUsingIndex:()=>mt,isNumberLike:()=>Ge,isValid:()=>h,limit:()=>w,mapAnimationOptions:()=>Qe,mapObject:()=>O,omit:()=>I,parseEasingParameters:()=>Re,parseOffset:()=>Y,parseOptions:()=>fe,pick:()=>Fe,registerEasingFunction:()=>zt,registerEasingFunctions:()=>Dt,scale:()=>ut,toArr:()=>$,toFixed:()=>_e,toStr:()=>v,transpose:()=>U,trim:()=>Ie,tween:()=>Ct,tweenAttr:()=>Ht});var Me=e=>[].concat(...e),O=(e,t)=>{let i=Object.keys(e),n,r,s={};for(let a=0,o=i.length;a<o;a++)n=i[a],r=e[n],s[n]=t(r,n,e);return s},v=e=>""+e,$=e=>Array.isArray(e)||typeof e=="string"?(typeof e=="string"&&(e=e.split(",")),e):[e],h=e=>Array.isArray(e)||typeof e=="string"?Boolean(e.length):e!=null&&e!=null&&!Number.isNaN(e),W=e=>(e=e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`),e.charAt(0)=="-"?e.substr(1):e),be=e=>e.includes("--")?e:`${e}`.replace(/-([a-z])/g,(i,n)=>n.toUpperCase()),I=(e,t)=>{let i=[...e],n={...t};for(;i.length;){let{[i.pop()]:r,...s}=n;n=s}return n},Fe=(e,t)=>{let i=[...e],n={};for(let r of i)h(t[r])&&(n[r]=t[r]);return n},U=(...e)=>{let t=0;e=e.map(r=>{let s=$(r),a=s.length;return a>t&&(t=a),s});let i=[],n=e.length;for(let r=0;r<t;r++){i[r]=[];for(let s=0;s<n;s++){let a=e[s][r];h(a)&&(i[r][s]=a)}}return i};var Y=e=>typeof e=="string"?e.includes("%")?parseFloat(e)/100:e=="from"?0:e=="to"?1:parseFloat(e):e,Le=e=>{let t=new Set,i=Object.keys(e),n=i.length;for(let r=0;r<n;r++){let s=""+i[r],a=e[s],o=s.split(","),l=o.length;for(let p=0;p<l;p++){let y=Y(o[p]);t.add({...a,offset:y})}}return[...t].sort((r,s)=>r.offset-s.offset)},Ot={};var de=(e="")=>t=>typeof t=="string"?t:`${t}${e}`,B=de(),Se=de("px"),Ee=de("deg"),Z=e=>t=>h(t)?$(t).map(i=>{if(typeof i!="number"&&typeof i!="string")return i;let n=Number(i),r=Number.isNaN(n)?typeof i=="string"?i.trim():i:n;return e(r)}):[],V=(e,t)=>$(e).map(Z(t)),P=Z(B),x=Z(Se),T=Z(Ee),Ne=e=>{let t=Object.keys(e),i,n,r={};for(let s=0,a=t.length;s<a;s++)i=be(t[s]),n=e[t[s]],r[i]=n;return r},ve={translate:e=>V(e,Se),translate3d:e=>V(e,Se),translateX:e=>x(e),translateY:e=>x(e),translateZ:e=>x(e),rotate:e=>V(e,Ee),rotate3d:e=>V(e,B),rotateX:e=>T(e),rotateY:e=>T(e),rotateZ:e=>T(e),scale:e=>V(e,B),scale3d:e=>V(e,B),scaleX:e=>P(e),scaleY:e=>P(e),scaleZ:e=>P(e),skew:e=>V(e,Ee),skewX:e=>T(e),skewY:e=>T(e),perspective:e=>x(e)},Te=Object.keys(ve),Ve=(e,t)=>{let i="",n=e.length;for(let r=0;r<n;r++){let s=e[r],a=t[r];h(a)&&(i+=`${s}(${Array.isArray(a)?a.join(", "):a}) `)}return i.trim()},Ke=["margin","padding","size","width","height","left","right","top","bottom","radius","gap","basis","inset","outline-offset","perspective","thickness","position","distance","spacing"].map(be).join("|"),je=e=>{let t=Ne(e),i=I(Te,t),n=Object.keys(t).filter(a=>Te.includes(a)),r=n.map(a=>ve[a](t[a])),s=U(...r).filter(h).map(a=>Ve(n,a));return i=O(i,(a,o)=>{let l;if(!/color/i.test(o)){let p=/rotate/i.test(o),y=new RegExp(Ke,"i").test(o);if(p||y)return p?l=T:y&&(l=x),l(a).map(c=>{let u=c.trim().split(" ");return l(u).join(" ")})}return[].concat(a).map(v)}),Object.assign({},h(s)?{transform:s}:null,i)},ze=e=>e.map(t=>{let{translate:i,translate3d:n,translateX:r,translateY:s,translateZ:a,rotate:o,rotate3d:l,rotateX:p,rotateY:y,rotateZ:c,scale:u,scale3d:f,scaleX:g,scaleY:m,scaleZ:E,skew:S,skewX:b,skewY:M,perspective:G,easing:F,iterations:L,offset:q,...N}=Ne(t);return i=x(i),n=x(n),r=x(r)[0],s=x(s)[0],a=x(a)[0],o=T(o),l=P(l),p=T(p)[0],y=T(y)[0],c=T(c)[0],u=P(u),f=P(f),g=P(g)[0],m=P(m)[0],E=P(E)[0],S=T(S),b=T(b)[0],M=T(M)[0],G=x(G)[0],[N,i,n,r,s,a,o,l,p,y,c,u,f,g,m,E,S,b,M,G]}).map(([t,...i])=>{let n=Ve(Te,i);return t=O(t,(r,s)=>{let a;if(!/color/i.test(s)){let o=/rotate/i.test(s),l=new RegExp(Ke,"i").test(s);if(o||l){o?a=T:l&&(a=x);let p=v(r).trim().split(" ");return a(p).join(" ")}}return v(r)}),Object.assign({},h(n)?{transform:n}:null,t)});var It=4,Pt=.001,wt=1e-7,Mt=10,Q=11,xe=1/(Q-1),Ft=typeof Float32Array=="function",nt=(e,t)=>1-3*t+3*e,rt=(e,t)=>3*t-6*e,st=e=>3*e,Ce=(e,t,i)=>((nt(t,i)*e+rt(t,i))*e+st(t))*e,at=(e,t,i)=>3*nt(t,i)*e*e+2*rt(t,i)*e+st(t),Lt=(e,t,i,n,r)=>{let s,a,o=0;do a=t+(i-t)/2,s=Ce(a,n,r)-e,s>0?i=a:t=a;while(Math.abs(s)>wt&&++o<Mt);return a},Nt=(e,t,i,n)=>{for(var r=0;r<It;++r){let s=at(t,i,n);if(s===0)return t;t-=(Ce(t,i,n)-e)/s}return t},vt=(e,t,i,n)=>{if(!(0<=e&&e<=1&&0<=i&&i<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&i===n)return o=>o;for(var r=Ft?new Float32Array(Q):new Array(Q),s=0;s<Q;++s)r[s]=Ce(s*xe,e,i);let a=o=>{let l=0,p=1,y=Q-1;for(;p!==y&&r[p]<=o;++p)l+=xe;--p;let c=(o-r[p])/(r[p+1]-r[p]),u=l+c*xe,f=at(u,e,i);return f>=Pt?Nt(o,u,e,i):f===0?u:Lt(o,l,l+xe,e,i)};return o=>o===0||o===1?o:Ce(a(o),t,n)},De=vt;var qe={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var Vt={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(e){var t=e[0]/360,i=e[1]/100,n=e[2]/100,r,s,a,o,l;if(i===0)return l=n*255,[l,l,l];n<.5?s=n*(1+i):s=n+i-n*i,r=2*n-s,o=[0,0,0];for(var p=0;p<3;p++)a=t+1/3*-(p-1),a<0?a++:a>1&&a--,6*a<1?l=r+(s-r)*6*a:2*a<1?l=s:3*a<2?l=r+(s-r)*(2/3-a)*6:l=r,o[p]=l*255;return o}},ot={red:0,orange:60,yellow:120,green:180,blue:240,purple:300},Kt=e=>{var t,i=[],n=1,r;if(typeof e=="string")if(qe[e])i=qe[e].slice(),r="rgb";else if(e==="transparent")n=0,r="rgb",i=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var s=e.slice(1),a=s.length,o=a<=4;n=1,o?(i=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],a===4&&(n=parseInt(s[3]+s[3],16)/255)):(i=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],a===8&&(n=parseInt(s[6]+s[7],16)/255)),i[0]||(i[0]=0),i[1]||(i[1]=0),i[2]||(i[2]=0),r="rgb"}else if(t=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(e)){var l=t[1],p=l==="rgb",s=l.replace(/a$/,"");r=s;var a=s==="cmyk"?4:s==="gray"?1:3;i=t[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(u,f){if(/%$/.test(u))return f===a?parseFloat(u)/100:s==="rgb"?parseFloat(u)*255/100:parseFloat(u);if(s[f]==="h"){if(/deg$/.test(u))return parseFloat(u);if(ot[u]!==void 0)return ot[u]}return parseFloat(u)}),l===s&&i.push(1),n=p||i[a]===void 0?1:i[a],i=i.slice(0,a)}else e.length>10&&/[0-9](?:\s|\/)/.test(e)&&(i=e.match(/([0-9]+)/g).map(function(y){return parseFloat(y)}),r=e.match(/([a-z])/ig).join("").toLowerCase());else Number.isNaN(e)?Array.isArray(e)||e.length?(i=[e[0],e[1],e[2]],r="rgb",n=e.length===4?e[3]:1):e instanceof Object&&(e.r!=null||e.red!=null||e.R!=null?(r="rgb",i=[e.r||e.red||e.R||0,e.g||e.green||e.G||0,e.b||e.blue||e.B||0]):(r="hsl",i=[e.h||e.hue||e.H||0,e.s||e.saturation||e.S||0,e.l||e.lightness||e.L||e.b||e.brightness]),n=e.a||e.alpha||e.opacity||1,e.opacity!=null&&(n/=100)):(r="rgb",i=[e>>>16,(e&65280)>>>8,e&255]);return{space:r,values:i,alpha:n}},jt=e=>{Array.isArray(e)&&e.raw&&(e=String.raw(...arguments));var t,i,n,r=Kt(e);return r.space?(t=Array(3),t[0]=Math.min(Math.max(r.values[0],0),255),t[1]=Math.min(Math.max(r.values[1],0),255),t[2]=Math.min(Math.max(r.values[2],0),255),r.space[0]==="h"&&(t=Vt.rgb(t)),t.push(Math.min(Math.max(r.alpha,0),1)),t):[]},Ue=jt;var w=(e,t,i)=>Math.min(Math.max(e,t),i),X=e=>Math.pow(e,2),J=e=>Math.pow(e,3),ee=e=>Math.pow(e,4),te=e=>Math.pow(e,5),ie=e=>Math.pow(e,6),ne=e=>1-Math.cos(e*Math.PI/2),re=e=>1-Math.sqrt(1-e*e),se=e=>e*e*(3*e-2),ae=e=>{let t,i=4;for(;e<((t=Math.pow(2,--i))-1)/11;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((t*3-2)/22-e,2)},oe=(e,t=[])=>{let[i=1,n=.5]=t,r=w(i,1,10),s=w(n,.1,2);return e===0||e===1?e:-r*Math.pow(2,10*(e-1))*Math.sin((e-1-s/(Math.PI*2)*Math.asin(1/r))*(Math.PI*2)/s)},H=(e,t=[],i)=>{let[n=1,r=100,s=10,a=0]=t;n=w(n,.1,1e3),r=w(r,.1,1e3),s=w(s,.1,1e3),a=w(a,.1,1e3);let o=Math.sqrt(r/n),l=s/(2*Math.sqrt(r*n)),p=l<1?o*Math.sqrt(1-l*l):0,y=1,c=l<1?(l*o+-a)/p:-a+o,u=i?i*e/1e3:e;return l<1?u=Math.exp(-u*l*o)*(y*Math.cos(p*u)+c*Math.sin(p*u)):u=(y+c*u)*Math.exp(-u*o),e===0||e===1?e:1-u},Ae=new Map,lt=1e4,pt=(e="spring")=>{if(Ae.has(e))return Ae.get(e);let t=typeof e=="function"?e:ue(e),i=typeof e=="function"?[]:Re(e),n=1/6,r=0,s=0,a=0;for(;++a<lt;)if(r+=n,t(r,i,null)===1){if(s++,s>=16)break}else s=0;let o=r*n*1e3;return Ae.set(e,o),o},ke=(e,t=[])=>{let[i=10,n]=t;return(n=="start"?Math.ceil:Math.floor)(w(e,0,1)*i)/i},He=(e,t=[])=>{let[i,n,r,s]=t;return De(i,n,r,s)(e)},le=De(.42,0,1,1),C=e=>(t,i=[],n)=>1-e(1-t,i,n),A=e=>(t,i=[],n)=>t<.5?e(t*2,i,n)/2:1-e(t*-2+2,i,n)/2,k=e=>(t,i=[],n)=>t<.5?(1-e(1-t*2,i,n))/2:(e(t*2-1,i,n)+1)/2,z={steps:ke,"step-start":e=>ke(e,[1,"start"]),"step-end":e=>ke(e,[1,"end"]),linear:e=>e,"cubic-bezier":He,ease:e=>He(e,[.25,.1,.25,1]),in:le,out:C(le),"in-out":A(le),"out-in":k(le),"in-quad":X,"out-quad":C(X),"in-out-quad":A(X),"out-in-quad":k(X),"in-cubic":J,"out-cubic":C(J),"in-out-cubic":A(J),"out-in-cubic":k(J),"in-quart":ee,"out-quart":C(ee),"in-out-quart":A(ee),"out-in-quart":k(ee),"in-quint":te,"out-quint":C(te),"in-out-quint":A(te),"out-in-quint":k(te),"in-expo":ie,"out-expo":C(ie),"in-out-expo":A(ie),"out-in-expo":k(ie),"in-sine":ne,"out-sine":C(ne),"in-out-sine":A(ne),"out-in-sine":k(ne),"in-circ":re,"out-circ":C(re),"in-out-circ":A(re),"out-in-circ":k(re),"in-back":se,"out-back":C(se),"in-out-back":A(se),"out-in-back":k(se),"in-bounce":ae,"out-bounce":C(ae),"in-out-bounce":A(ae),"out-in-bounce":k(ae),"in-elastic":oe,"out-elastic":C(oe),"in-out-elastic":A(oe),"out-in-elastic":k(oe),spring:H,"spring-in":H,"spring-out":C(H),"spring-in-out":A(H),"spring-out-in":k(H)},R=Object.keys(z),zt=(e,t)=>{Object.assign(z,{[e]:t}),R=Object.keys(z)},Dt=(...e)=>{Object.assign(z,...e),R=Object.keys(z)},pe=e=>W(e).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim(),ue=e=>{let t=pe(e);return R.includes(t)?z[t]:null},Re=e=>{let t=/(\(|\s)([^)]+)\)?/.exec(e);return t?t[2].split(",").map(i=>{let n=parseFloat(i);return Number.isNaN(n)?i.trim():n}):[]},ut=(e,t,i)=>t+(i-t)*e,_e=(e,t)=>Math.round(e*10**t)/10**t,Oe=(e,t,i=3)=>{let n=t.length-1,r=w(Math.floor(e*n),0,n-1),s=t[r],a=t[r+1],o=(e-r/n)*n;return _e(ut(o,s,a),i)},Ge=e=>{let t=parseFloat(e);return typeof t=="number"&&!Number.isNaN(t)},mt=(e,t)=>{e=w(e,0,1);let i=t.length-1,n=Math.round(e*i);return t[n]},ct=(e,t,i=3)=>{let n="";return Ge(t[0])&&(n=v(t[0]).replace(/^\d+/,"")),Oe(e,t.map(parseFloat),i)+n},yt=(e,t,i=3)=>U(...t.map(Ue)).map((n,r)=>{let s=Oe(e,n);return r<3?Math.round(s):_e(s,i)}),Ie=e=>v(e).trim(),ft=e=>Ie(e).replace(/(\d|\)|\w)\s/g,t=>t[0]+"__").split("__").map(Ie).filter(h),me=(e,t,i=3)=>{if(t.every(a=>typeof a=="number"))return Oe(e,t,i);if(t.every(a=>h(Ue(a??null))))return`rgba(${yt(e,t,i)})`;if(t.some(a=>typeof a=="string"))return t.some(l=>/(\d|\)|\w)\s/.test(Ie(l)))?U(...t.map(ft)).map(l=>me(e,l,i)).join(" "):t.every(l=>Ge(l))?ct(e,t,i):mt(e,t)},$e=(e={})=>{let t=typeof e=="string"||typeof e=="function",{easing:i="spring(1, 100, 10, 0)",numPoints:n=100,decimal:r=3,duration:s}=t?{easing:e}:e;return{easing:i,numPoints:n,decimal:r,duration:s}},Pe=new Map,gt=({easing:e,numPoints:t,duration:i}={})=>{let n=[],r=`${e}${t}`;if(Pe.has(r))return Pe.get(r);let s=typeof e=="function"?e:ue(e),a=typeof e=="function"?[]:Re(e);for(let o=0;o<t;o++)n[o]=s(o/(t-1),a,i);return Pe.set(r,n),n},We=(e={})=>{if(typeof e.easing=="string"){let t=pe(e.easing);/(spring|spring-in)$/i.test(t)&&(e.duration=pt(e.easing))}},Ye=(e,t={})=>{let i=$e(t);return We(i),gt(i).map(n=>me(n,e,i.decimal))},qt=(e,t={})=>{let i=$e(t),{duration:n}=i;return We(i),[Ye(e,i),h(n)?n:i.duration]},Be=(e={})=>{let{easing:t,numPoints:i,decimal:n,duration:r,...s}=e,a={easing:t,numPoints:i,decimal:n,duration:r};We(a);let o=O(s,p=>Ye(p,a)),l={};return h(r)?l={duration:r}:h(a.duration)&&(l={duration:a.duration}),Object.assign({},o,l)};var _=class{constructor(t){this.map=new Map(t)}getMap(){return this.map}get(t){return this.map.get(t)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(t,i){return this.map.set(t,i),this}add(t){let n=this.size;return this.set(n,t),this}get size(){return this.map.size}get length(){return this.map.size}last(t=1){let i=this.keys()[this.size-t];return this.get(i)}delete(t){return this.map.delete(t)}remove(t){return this.map.delete(t),this}clear(){return this.map.clear(),this}has(t){return this.map.has(t)}entries(){return this.map.entries()}forEach(t,i){return this.map.forEach(t,i),this}[Symbol.iterator](){return this.entries()}},ht=(e,t,...i)=>{e.forEach(n=>{n[t](...i)})};var bt=({callback:e=()=>{},scope:t=null,name:i="event"})=>({callback:e,scope:t,name:i}),ce=class extends _{constructor(t="event"){super();this.name=t}},Ze=class extends _{constructor(){super()}getEvent(t){let i=this.get(t);return i instanceof ce?i:(this.set(t,new ce(t)),this.get(t))}newListener(t,i,n){let r=this.getEvent(t);return r.add(bt({name:t,callback:i,scope:n})),r}on(t,i,n){if(typeof t=="undefined"||t==null)return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let r,s,a=typeof t=="object"&&!Array.isArray(t),o=a?i:n;return a||(s=i),Object.keys(t).forEach(l=>{r=a?l:t[l],a&&(s=t[l]),this.newListener(r,s,o)},this),this}removeListener(t,i,n){let r=this.get(t);if(r instanceof ce&&i){let s=bt({name:t,callback:i,scope:n});r.forEach((a,o)=>{if(a.callback===s.callback&&a.scope===s.scope)return r.remove(o)})}return r}off(t,i,n){if(typeof t=="undefined"||t==null)return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let r,s,a=typeof t=="object"&&!Array.isArray(t),o=a?i:n;return a||(s=i),Object.keys(t).forEach(l=>{r=a?l:t[l],a&&(s=t[l]),typeof s=="function"?this.removeListener(r,s,o):this.remove(r)},this),this}once(t,i,n){if(typeof t=="undefined"||t==null)return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let r=typeof t=="object"&&!Array.isArray(t);return Object.keys(t).forEach(s=>{let a=r?s:t[s],o=r?t[s]:i,l=r?i:n,p=(...y)=>{o.apply(l,y),this.removeListener(a,p,l)};this.newListener(a,p,l)},this),this}emit(t,...i){return typeof t=="undefined"||t==null?this:(typeof t=="string"&&(t=t.trim().split(/\s/g)),t.forEach(n=>{let r=this.get(n);r instanceof ce&&r.forEach(s=>{let{callback:a,scope:o}=s;a.apply(o,i)})},this),this)}clear(){return ht(this,"clear"),super.clear(),this}};var dt=e=>typeof e=="string"?Array.from(document.querySelectorAll(e)):[e],D=e=>Array.isArray(e)?Me(e.map(D)):typeof e=="string"||e instanceof Node?dt(e):e instanceof NodeList||e instanceof HTMLCollection?Array.from(e):[],St=(e,t,i)=>typeof e=="function"?e.apply(i,t):e,Qe=(e,t,i)=>O(e,n=>St(n,t,i)),Xe={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},we=Object.keys(Xe),ye=(e="ease")=>{let t=W(e).replace(/^ease-/,"");return we.includes(t)?Xe[t]:e},Je={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,timeline:document.timeline,extend:{}},fe=e=>{let{options:t,...i}=e,n=t instanceof K?t.options:Array.isArray(t)?t?.[0]?.options:t;return Object.assign({},n,i)},et=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],Et=["keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets","timeline"],ge=[...et,...Et],d=class{constructor(t){this.options={};this.properties={};this.totalDuration=-1/0;this.minDelay=1/0;this.maxSpeed=1/0;this.emitter=new Ze;this.targets=new _;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",console.error),this.updateOptions(t),this.mainAnimation&&(this.visibilityPlayState=this.getPlayState(),d.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1)),this.newPromise()}static requestFrame(){d.cancelFrame(),d.RUNNING.forEach(t=>{t.emitter.getEvent("update").length<=0?t.stopLoop():t.loop()}),d.RUNNING.size>0?d.animationFrame=window.requestAnimationFrame(d.requestFrame):d.cancelFrame()}static cancelFrame(){window.cancelAnimationFrame(d.animationFrame),d.animationFrame=null}loop(){this.emit("update",this.getProgress(),this)}stopLoop(){d.RUNNING.delete(this)}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((t,i)=>{this.emitter?.once?.("finish",()=>t([this])),this.emitter?.once?.("error",n=>i(n))}),this.promise}then(t,i){return t=t?.bind(this),i=i?.bind(this),this.promise?.then?.(t,i),this}catch(t){return t=t?.bind(this),this.promise?.catch?.(t),this}finally(t){return t=t?.bind(this),this.promise?.finally?.(t),this}allAnimations(t){return this.targets.forEach(i=>{let n=this.keyframeEffects.get(i),r=this.animations.get(n);return t(r,i)}),this}all(t){return this.mainAnimation&&t(this.mainAnimation,this.mainElement),this.allAnimations(t),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let t=this.getPlayState();return this.beginEvent(),this.all(i=>i.play()),this.emit("play",t,this),this.is(t)||this.emit("playstate-change",t,this),this.loop(),d.RUNNING.add(this),d.requestFrame(),this}pause(){let t=this.getPlayState();return this.all(i=>i.pause()),this.emit("pause",t,this),this.is(t)||this.emit("playstate-change",t,this),this.stopLoop(),this}reverse(){return this.all(t=>t.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(t=>t.cancel()),this}finish(){return this.all(t=>t.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(t=>this.removeTarget(t)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement?.remove?.(),this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(t){let i=this.keyframeEffects.get(t);return this.animations.get(i)}getTiming(t){let i=this.computedOptions.get(t)??{},n=this.keyframeEffects.get(t).getTiming?.()??{};return{...i,...n}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(t){return this.getPlayState()==t}setCurrentTime(t){return this.all(i=>i.currentTime=t),this.emit("update",this.getProgress()),this}setProgress(t){let i=t/100*this.totalDuration;return this.setCurrentTime(i),this}setSpeed(t=1){return this.maxSpeed=t,this.all(i=>{i.updatePlaybackRate?i.updatePlaybackRate(t):i.playbackRate=t}),this}createArrayOfComputedOptions(t,i){let n=[];return this.targets.forEach((r,s)=>{let a=this.computedOptions.get(r)??{},o=b=>{let M=b;return b=="loop"&&(M="iterations"),b=="fillMode"&&(M="fill"),t[b]??a[M]??this.options[b]??Je[b]},l=Object.assign({easing:o("easing"),iterations:o("loop"),direction:o("direction"),endDelay:o("endDelay"),duration:o("duration"),speed:o("speed"),delay:o("delay"),timelineOffset:o("timelineOffset"),keyframes:o("keyframes")},o("extend")??{}),p=Qe(l,[s,i,r],this);typeof p.easing=="string"&&(p.easing=ye(p.easing)),p.iterations===!0&&(p.iterations=1/0),p.fill=o("fillMode");let{timelineOffset:y,speed:c,endDelay:u,delay:f,duration:g,iterations:m,...E}=p;m=Number(m),g=Number(g),u=Number(u),c=Number(c),f=Number(f)+Number(y);let S=f+g*m+u;this.totalDuration<S&&(this.totalDuration=S),n[s]={...E,speed:c,tempDurations:S,endDelay:u,delay:f,duration:g,iterations:m},this.minDelay>f&&(this.minDelay=f),this.maxSpeed>c&&(this.maxSpeed=c)}),n}createAnimations(t,i){let{arrOfComputedOptions:n,padEndDelay:r,oldCSSProperties:s,onfinish:a,oncancel:o,timeline:l}=t;this.targets.forEach((p,y)=>{let{speed:c,keyframes:u,tempDurations:f,...g}=n[y];r&&g.endDelay==0&&Math.abs(g.iterations)!=Math.abs(1/0)&&(g.endDelay=this.totalDuration-f);let m,E,S=u;typeof S=="object"&&(S=Le(S));let b=this.computedKeyframes.get(p)??{},M=Object.assign({},s,b),G=O(M,(q,N)=>this.properties[N]??q);if(E=h(S)?S:G,Array.isArray(E))m=E.map(q=>{let{easing:N,offset:j,...he}=I(["speed","loop"],q);return Object.assign({},he,typeof N=="string"?{easing:ye(N)}:null,typeof j=="string"||typeof j=="number"?{offset:Y(j)}:null)}),m=ze(m);else{let q=I(["keyframes"],E),{offset:N,...j}=Qe(q,[y,i,p],this);j=je(j);let he=N;m=Object.assign({},j,h(he)?{offset:he.map(Y)}:null)}let F,L;this.keyframeEffects.has(p)?(L=this.keyframeEffects.get(p),F=this.animations.get(L),L?.setKeyframes?.(m),L?.updateTiming?.(g)):(L=new KeyframeEffect(p,m,g),F=new Animation(L,l),this.keyframeEffects.set(p,L),this.animations.set(L,F)),F.playbackRate=c,F.onfinish=()=>{typeof a=="function"&&a.call(this,p,y,i,F)},F.oncancel=()=>{typeof o=="function"&&o.call(this,p,y,i,F)},this.computedOptions.set(p,g),this.computedKeyframes.set(p,m)})}updateOptions(t={}){try{let i=fe(t);this.options=Object.assign({},Je,this.options,i);let{padEndDelay:n,autoplay:r,target:s,targets:a,timeline:o,onfinish:l,oncancel:p,...y}=I(et,this.options);this.properties=I(ge,i);let c=this.targets.values(),u=[...new Set([...c,...D(a),...D(s)])];this.targets.clear(),u.forEach((m,E)=>{this.targets.set(E,m),this.targetIndexes.set(m,E)});let f=this.targets.size,g=this.createArrayOfComputedOptions(i,f);if(this.createAnimations({arrOfComputedOptions:g,padEndDelay:n,oldCSSProperties:y,onfinish:l,oncancel:p,timeline:o},f),f<=0&&(this.maxSpeed==1/0&&(this.maxSpeed=Number(this.options.speed)),this.minDelay==1/0&&(this.minDelay=Number(this.options.delay)+Number(this.options.timelineOffset)),this.totalDuration==-1/0&&(this.totalDuration=Number(this.options.duration))),this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,null,{duration:this.totalDuration}),this.mainAnimation=new Animation(this.mainkeyframeEffect,o)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.mainAnimation){let m=this.getPlayState();this.is(m)||this.emit("playstate-change",m,this),this.loop(),this.stopLoop()}this.emit("finish",this)},this.mainAnimation.oncancel=()=>{if(this.mainAnimation){let m=this.getPlayState();this.is(m)||this.emit("playstate-change",m,this),this.loop(),this.stopLoop()}this.emit("cancel",this)},r){let m=window.setTimeout(()=>{this.emit("begin",this),m=window.clearTimeout(m)},0);this.play()}else this.pause()}catch(i){this.emit("error",i)}}add(t){let i=this.getProgress(),n=this.is("running"),r=this.is("paused");this.updateOptions({target:t}),this.setProgress(i),n?this.play():r&&this.pause()}removeTarget(t){let i=this.keyframeEffects.get(t);this.animations.delete(i),i=null,this.computedKeyframes.delete(t),this.computedOptions.delete(t),this.keyframeEffects.delete(t);let n=this.targetIndexes.get(t);this.targets.delete(n),this.targetIndexes.delete(t)}remove(t){this.removeTarget(t);let i=new Set([].concat(this.targets.values()));this.options.target=[...i],this.options.targets=[],i.clear(),i=null;let n=this.getProgress(),r=this.is("running"),s=this.is("paused");this.updateOptions(),r?this.play():s&&this.pause(),this.setProgress(n)}on(t,i,n){return this.emitter?.on?.(t,i,n??this),this.emitter.getEvent("update").length>0&&(d.RUNNING.add(this),d.animationFrame==null&&d.requestFrame()),this}off(t,i,n){return this.emitter?.off?.(t,i,n??this),this}emit(t,...i){return this.emitter?.emit?.(t,...i),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},K=d;K.pauseOnPageHidden=!0,K.RUNNING=new Set;var Ut=(e={})=>new K(e);var Tt=0,xt=()=>{let e=document.createElement("div");return e.id=`empty-animate-el-${Tt++}`,e.style.setProperty("display","none"),document.body.appendChild(e),e},tt=class extends K{constructor(t={}){super(t)}stop(){this.targets.forEach(t=>t?.remove?.()),super.stop()}},Ct=(e={})=>{let t=xt(),{target:i,easing:n,decimal:r,numPoints:s,...a}=fe(e),o=Fe(ge,a),l=n;if(typeof n=="string"){let c=pe(n);we.includes(c)||["linear","steps","step-start","step-end"].includes(c)?l=ye(n):R.includes(c)?l=ue(n):l=n}let p=typeof l=="function"?Be({opacity:[0,1],easing:n,decimal:r,numPoints:s}):{opacity:[0,1],easing:n};return new tt({target:t,...p,...o})},Ht=(e={},t="attribute")=>{let i=fe(e),n=I([...ge,"opacity","decimal","numPoints"],i),r=Ct(i),{target:s,targets:a}=i,o=[...new Set([...D(a),...D(s)])];try{let l=o.length,p=r.targets.get(0),y=getComputedStyle(p);o.forEach((c,u)=>{let f=/style/i.test(t)?getComputedStyle(c):null;O(n,(g,m)=>{let E=/style/i.test(t)?f?.getPropertyValue(m):c.getAttribute(m);r.on("update",()=>{let S=Number(y.getPropertyValue("opacity")),b;typeof g=="function"?b=g(S,u,l,c):b=me(S,Array.isArray(g)?g:[E,g],e.decimal),/style/i.test(t)?c.style.setProperty(m,""+b):c.setAttribute(m,""+b)})})})}catch(l){r?.stopLoop(),console.error(l)}return r};0&&(module.exports={ALL_TIMING_KEYS,Animate,ApplyCustomEasing,Back,Bezier,Bounce,CSSArrValue,CSSPXDataType,CSSValue,Circ,ComplexEasingSyntax,ComplexStrtoArr,Cubic,CustomEasing,CustomEasingOptions,DefaultAnimationOptions,DestroyableAnimate,EASINGS,EFFECTS,EaseInOut,EaseOut,EaseOutIn,EasingDurationCache,EasingFunctionKeys,EasingFunctions,EasingKeys,EasingPts,Elastic,Expo,FUNCTION_SUPPORTED_TIMING_KEYS,GetEase,GetEasingFunction,INTINITE_LOOP_LIMIT,KeyframeParse,NOT_FUNCTION_SUPPORTED_TIMING_KEYS,ParseCSSProperties,ParseTransformableCSSKeyframes,ParseTransformableCSSProperties,Quad,Quart,Quint,Sine,Spring,SpringEasing,Steps,TransformFunctionNames,TransformFunctions,TweenCache,UIDCount,UnitDEG,UnitDEGCSSValue,UnitLess,UnitLessCSSValue,UnitPX,UnitPXCSSValue,addCSSUnit,animate,camelCase,computeOption,convertToDash,createEmptyEl,createTransformProperty,easein,flatten,getEasingDuration,getElements,getTargets,interpolateColor,interpolateComplex,interpolateNumber,interpolateString,interpolateUsingIndex,isNumberLike,isValid,limit,mapAnimationOptions,mapObject,omit,parseEasingParameters,parseOffset,parseOptions,pick,registerEasingFunction,registerEasingFunctions,scale,toArr,toFixed,toStr,transpose,trim,tween,tweenAttr});