@penner/responsive-easing 0.0.4 → 0.1.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.
@@ -0,0 +1,2 @@
1
+ var mylib=(function(x,L,k){"use strict";const tt=e=>2.70158*e*e*e-1.70158*e*e,et=e=>8.10474*e*e-3.40316*e,nt={id:"bounce",label:"Bounce (hard-surface)",build({joinTime:e,bounces:t,decayPct:a,L:n=tt,Ld:o=et}){if(e<it)return{p:O=>L.clampNormalized(O),v:O=>1,meta:{r:0,finalPct:0}};if(e>gt)return{p:O=>O>=1?1:n(O),v:O=>O>=1?0:o(O),meta:{r:0,finalPct:0}};const r=Math.ceil(t),s=t-Math.floor(t);let i;if(t<=1)i=L.clampNormalized(1-a/100);else{const h=L.clampNormalized(1-a/100);h===0?i=0:i=Math.pow(h,1/(2*(t-1)))}const u=h=>n(h/e),d=h=>o(h/e)/e,l=d(e),c=Math.abs(-i*l);if(i===0||c===0)return{p:O=>O<=e?u(O):1,v:O=>O<=e?d(O):0,meta:{r:0,finalPct:0,g:0,edges:[e,1]}};const M=1-e,b=Math.floor(t),E=Math.abs(1-i)<1e-6?t:(1-Math.pow(i,b))/(1-i)+s*Math.pow(i,b);let m=2*c/M*E,f=0;const P=50;for(let h=0;h<=P;h++){const F=h/P*e,O=u(F);O<f&&(f=O)}const I=1-f,p=c*c/(2*m);let S=c,w=!1,_=1;if(p>I){S=Math.sqrt(2*m*I),w=!0;const h=Math.abs(1-i)<1e-6?t:(1-Math.pow(i,b))/(1-i)+s*Math.pow(i,b),F=2*S*h/m;_=e+F,_>1&&(_=1)}const B=S,T=Array.from({length:r},(h,F)=>2*B*Math.pow(i,F)/m),v=[e];T.forEach(h=>v.push(v[v.length-1]+h)),w?v[v.length-1]=_:v[v.length-1]=1;const N=h=>-B*Math.pow(i,h),H=h=>{if(h>=_)return 1;let F=v.findIndex((V,z)=>z<v.length-1&&h<=v[z+1]);F<0&&(F=r-1);const O=v[F],U=h-O;return 1+(N(F)*U+.5*m*U*U)},D=h=>{if(h>=_)return 0;let F=v.findIndex((K,V)=>V<v.length-1&&h<=v[V+1]);F<0&&(F=r-1);const O=v[F],U=h-O;return N(F)+m*U},A=h=>h<=e?u(h):H(h),g=h=>h<=e?d(h):D(h),y=r<=1?100:100*(1-a/100);return{p:A,v:g,meta:{r:i,finalPct:y,g:m,edges:v,clamped:w,settleTime:_}}}},Mt=12;function bt({joinTime:e,L:t=tt,Ld:a=et,bridge:n}){const o=Mt;n&&n.joinHeight;const r=n?e+n.duration:e,s=1-r;let i;if(n)i=n.joinHeight;else{const S=a(1)*(1-e)+o*e;Math.abs(S)<1e-9?i=.5:i=o*e/S,i=Math.max(.01,Math.min(.999,i))}const u=n?1:i,d=u-1,l=n?n.velocity*s:i*a(1)*(1-e)/e,c=l+o*d,M=p=>{if(p<=0)return u;if(p>=1)return 1;const S=Math.exp(-o*p);return 1+(d+c*p)*S},b=p=>{if(p<=0)return l;if(p>=1)return 0;const S=Math.exp(-o*p);return(c-o*(d+c*p))*S},E=n?n.joinHeight:i,m=p=>E*t(p/e),f=p=>E/e*a(p/e);return{p:p=>{if(p<=0)return 0;if(p>=1)return 1;if(p<=e)return m(p);if(n&&p<=r)return n.joinHeight+n.velocity*(p-e);const S=(p-r)/s;return M(S)},v:p=>{if(p<=0||p>=1)return 0;if(p<=e)return f(p);if(n&&p<=r)return n.velocity;const S=(p-r)/s;return b(S)/s},meta:{r:0,finalPct:0,k:o,B:0,P:i,guard:"critically-damped",useBridge:!!n}}}function _t(e,t,a,n){const o=L.clampNormalized(a/100),r=t+.5,s=k.amplitudeRatio(o,r),i=r,u=Math.PI*i,d=k.dampingRate(i,s),l=1-e,c=e<=it*10,M=l>0?u/l:u,b=l>0?d/l:d,E=n(1);let m;if(c)m=0;else{const I=E/e,p=u,S=I*(1-e)+p*e;m=Math.abs(S)<1e-9?.5:p*e/S,m=Math.max(.01,Math.min(.999,m))}const f=c?0:m*E/e,P=t<=1?100:100*(1-a/100);return{P:m,v0:f,r:s,N:i,w:M,g:b,alpha:l,finalPct:P}}function Et({joinTime:e,bounces:t,decayPct:a,L:n=tt,Ld:o=et}){const r=_t(e,t,a,o),{r:s,g:i,alpha:u,finalPct:d}=r,l=o(1);let c;if(l>1e-6){const y=Math.min(u/(8*Math.max(t,1)),u*.1),h=e/(e+l*y),O=t>0?.5*e*t*Math.PI/(l*u):.5;c=Math.min(h,O),c=Math.max(.01,Math.min(.999,c))}else c=r.P;const M=c*l/e,b=t>0?u/(2*t+1):u,E=t>0?u*.5:u,m=1e-6;let f;if(M>1e-6){const y=(1-c)/M;f=Math.max(m,Math.min(E,y))}else f=Math.max(m,Math.min(E,b));const P=f>0?2*(1-c-M*f)/(f*f):0,I=y=>.5*P*y*y+M*y+c,p=y=>P*y+M,S=P*f+M,w=u-f,_=w>0?t*Math.PI/w:0,B=_>0?S/_:0,T=y=>1+B*Math.exp(-i*y)*Math.sin(_*y),v=y=>B*Math.exp(-i*y)*(_*Math.cos(_*y)-i*Math.sin(_*y)),N=y=>c*n(y/e),H=y=>c/e*o(y/e),D=e+f;return{p:y=>{if(y<=0)return 0;if(y>=1)return 1;if(y<=e)return N(y);if(y<=D){const F=y-e;return I(F)}const h=y-D;return T(h)},v:y=>{if(y<=0||y>=1)return 0;if(y<=e)return H(y);if(y<=D){const F=y-e;return p(F)}const h=y-D;return v(h)},meta:{r:s,finalPct:d,k:i,B:_,P:c,guard:"quadratic-sine"}}}const Pt=Et,Q={id:"spring",label:"Spring (phase-locked; bounce = half-cycle)",getNaturalStartVelocity({bounces:e,decayPct:t},a,n){const o=e;if(o<=0)return a(1);let r;if(o<=1)r=L.clampNormalized(1-t/100);else{const M=L.clampNormalized(1-t/100);M===0?r=0:r=Math.pow(M,1/(o-1))}if(r===0)return 0;const s=a(1),i=n?.headWeight??1,u=n?.freqWeight??1,d=n?.freqExponent??1,l=n?.baseMultiplier??1,c=Math.pow(o,d);return s*i+l*c*u},build({joinTime:e,bounces:t,decayPct:a,L:n=tt,Ld:o=et,bridge:r}){if(e<it)return{p:h=>L.clampNormalized(h),v:h=>1,meta:{r:0,finalPct:0,k:0,B:0,P:0}};if(e>gt)return{p:h=>h>=1?1:n(h),v:h=>h>=1?0:o(h),meta:{r:0,finalPct:0,k:0,B:0,P:1}};if(t<=0)return bt({joinTime:e,L:n,Ld:o,bridge:r});if(!r)return Pt({joinTime:e,bounces:t,decayPct:a,L:n,Ld:o});let s;if(t<=1)s=L.clampNormalized(1-a/100);else{const g=L.clampNormalized(1-a/100);g===0?s=0:s=Math.pow(g,1/(t-1))}const i=r?r.joinHeight:1,u=r?e+r.duration:e;if(s===0){const g=O=>i*n(O/e),y=O=>i/e*o(O/e);return{p:O=>O<=e?g(O):r&&O<=u?r.joinHeight+r.velocity*(O-e):1,v:O=>O<=e?y(O):r&&O<=u?r.velocity:0,meta:{r:0,finalPct:0,k:1/0,B:0,P:i,guard:"no-oscillation",useBridge:!!r}}}const d=1-u,l=t<=0||d<=0?0:t*Math.PI/d,c=s<=0?50:l/Math.PI*-Math.log(s),M=g=>Math.exp(-c*g)*Math.sin(l*g),b=g=>Math.exp(-c*g)*(l*Math.cos(l*g)-c*Math.sin(l*g));let E="";const m=Math.PI/(2*l),f=Math.exp(-c*m),P=f>1e-9?f:1;f<=1e-9&&(E="high-decay-fallback");const I=g=>M(d*g)/P,p=g=>d*b(d*g)/P,S=()=>!r||l===0?0:r.joinHeight/e*o(1)*P/l,w=g=>v+(1-v)*g,_=g=>r?1+S()*I(g):w(g)+(1-v)*I(g),B=g=>r?S()/(1-u)*p(g):(1-v)*(1+p(g))/(1-u),T=()=>{if(r){const g=p(0),y=1-u;return Math.abs(g)<1e-9?i:1-r.velocity*y/g}else{const g=o(1),h=1+p(0);return Math.abs(g*(1-e)+h*e)<1e-9?.5:h*e/(g*(1-e)+h*e)}},v=T(),N=globalThis;typeof N.__SPRING_TEST_HELPERS__=="object"&&(N.__SPRING_TEST_HELPERS__.calculateBridgeAmplitude=S,N.__SPRING_TEST_HELPERS__.calculateNonBridgeBaseline=w,N.__SPRING_TEST_HELPERS__.calculatePulsePosition=_,N.__SPRING_TEST_HELPERS__.calculatePulseVelocity=B,N.__SPRING_TEST_HELPERS__.calculateScalingFactor=T);const H=g=>{if(g<=e)return(r?r.joinHeight:v)*n(g/e);if(r&&g<=u)return r.joinHeight+r.velocity*(g-e);const y=(g-u)/(1-u);return _(y)},D=g=>{if(g<=e)return(r?r.joinHeight:v)/e*o(g/e);if(r&&g<=u)return r.velocity;const y=(g-u)/(1-u);return B(y)},A=t<=1?100:100*(1-a/100);return{p:H,v:D,meta:{r:s,finalPct:A,k:c,B:l,P:v,guard:E||"ok",useBridge:!!r}}}},ct=Q;function It(e,t,a,n){const o=Math.PI/2,r=K=>Math.abs(K)<222e-17,s=K=>{const V=Math.sign(K),z=K*V;return((((-.021641405*z+.077981383)*z+-.213301322)*z+o)*Math.sqrt(1-z)-o)*V+o},i=K=>{if(Math.abs(K)<1){const V=K*K,z=V*K,Me=z*V;return K+z/6+Me/120}return Math.sinh(K)},u=e-a,d=t-n,l=3*e,c=3*t,M=3*u+1,b=-l-3*u,E=l,m=3*d+1,f=-c-3*d,P=c,I=1/M,p=b*I,S=E*I,w=p/-3*p+S,_=p/3,B=(2*_*_-S)*_,T=Math.sign(w),v=Math.sign(b);let N=1,H=1,D=1,A,g,y;if(r(M)&&r(b))A=1,N=1/E,H=0,g=1,y=0;else if(r(M))A=2,N=v,H=-(E/(2*b)),g=1/b,y=H*H;else if(r(w))A=3,H=-_,g=I,y=-B;else{if(M<0)A=4;else if(w>0)A=5;else if(w<0)A=6,D=v;else throw new Error("Invalid curve type");N=-2*T*D*Math.sqrt(Math.abs(w)/3),H=-_,g=3*T*I/(w*N),y=3*T*(-B/w/N)}const h=m*N*N*N,F=(3*m*H+f)*N*N,O=((3*m*H+2*f)*H+P)*N,U=((m*H+f)*H+P)*H;return K=>{if(K<=0)return 0;if(K>=1)return 1;let V=g*K+y;switch(A){case 1:break;case 2:V=Math.sqrt(Math.max(0,V));break;case 3:V=Math.cbrt(V);break;case 4:V=Math.cos(s(Math.max(-1,Math.min(1,V)))/3-2.094395102393195);break;case 5:V=i(Math.log(V+Math.sqrt(V*V+1))/3);break;case 6:V=V>=1?Math.cosh(Math.log(V+Math.sqrt(V*V-1))/3):Math.cos(s(Math.max(-1,V))/3);break;default:throw new Error("Invalid curve type")}return((h*V+F)*V+O)*V+U}}function at(e,t,a,n){if(e<0||e>1||a<0||a>1)throw new Error("x1 & x2 must be in [0, 1]");return e===t&&a===n?o=>o:It(e,t,a,n)}function Ot(e,t){if(e<=0)return 0;if(e>=1)return Number.POSITIVE_INFINITY;if(t<=1)return 0;if(t-1<1e-10){const n=e/(1-e);return Math.max(0,n*Math.pow(t-1,2))}const a=Math.pow((t-1)/t,t-1)/t;return Math.pow(e,t)/(1-e)*a}function j(e,t){if(e<=0||t<=1)return 0;const a=e;let n=0,o=1-1e-9;for(let s=0;s<60;s++){const i=.5*(n+o);Ot(i,t)<a?n=i:o=i}const r=.5*(n+o);return r/(1-r)}function lt(e,t,a){const n=t;if(a===0||n<=1)return Math.pow(e,Math.max(n,0));if(n-1<1e-10)return(a+1)*e-a;const r=Math.pow(e,n-1)*((a+1)*e-a);return r===0?0:r}function ut(e,t,a){const n=t;return a===0||n<=1?n*Math.pow(e,n-1):n-1<1e-10?a+1:Math.abs(n-2)<1e-10?2*(a+1)*e-a:e===0&&n>2?0:e===0&&n<=2?n*(a+1)*Math.pow(1e-10,n-1):n*(a+1)*Math.pow(e,n-1)-a*(n-1)*Math.pow(e,n-2)}function St(e,t){if(t<=0||e<=1)return 0;const a=e,n=j(t,a);return n<=0?0:(a-1)*n/(a*(n+1))}function kt(e){const t=e;if(t<=1)return{u:.5,p:Math.pow(.5,Math.max(t,0))};const a=Math.pow(t,-1/(t-1));return{u:a,p:Math.pow(a,t)}}function vt(e,t,a=1.01,n=10){if(e<=0||t<=0||t>=1)return null;const o=d=>{const l=j(e,d);return l<=0?0:(d-1)*l/(d*(l+1))},r=o(a),s=o(n);if(t<=r&&r>0)return a;if(t>=s)return n;let i=a,u=n;for(let d=0;d<50;d++){const l=.5*(i+u),c=o(l);if(Math.abs(c-t)<1e-9)return l;c<t?i=l:u=l}return .5*(i+u)}function Bt(e=.1){const t=k.solveBackStrength(e),a=o=>{const r=1-o;return 1-((t+1)*r*r*r-t*r*r)},n=o=>{const r=1-o;return(t+1)*3*r*r-t*2*r};return{id:"back-out",label:`Back Out (${(e*100).toFixed(0)}%)`,easingFn:a,velocityFn:n,config:{overshoot:e}}}function st(e=2){const t=Math.max(.1,e);return{id:"power-out",label:`Power Out (t^${t})`,easingFn:a=>{const n=1-a;return 1-Math.pow(n,t)},velocityFn:a=>{const n=1-a;return t*Math.pow(n,t-1)},config:{exponent:t}}}function Vt(e=2,t=.1){const a=Math.max(.1,e);if(t<=0||a<=1)return st(e);const n=j(t,a),o=s=>{const i=1-s;return n===0||a<=1?1-Math.pow(i,a):a-1<1e-10?1-((n+1)*i-n):1-Math.pow(i,a-1)*((n+1)*i-n)},r=s=>{const i=1-s;return ut(i,a,n)};return{id:"power-back-out",label:`Power Back Out (${(t*100).toFixed(0)}%, n=${a.toFixed(2)})`,easingFn:o,velocityFn:r,config:{exponent:a,overshoot:t,strength:n}}}function wt(e=.5,t=0,a=1,n=.5){const o=at(e,t,a,n),r=k.createVelocityFn(o,{step:1e-8,boundarySample:.001});return{id:"bezier-out",label:`Bezier (${e.toFixed(2)}, ${t.toFixed(2)}, ${a.toFixed(2)}, ${n.toFixed(2)})`,easingFn:o,velocityFn:r,config:{x1:e,y1:t,x2:a,y2:n}}}function Ft(e=.95){const t=Math.max(0,Math.min(1,e));if(t===0)return{id:"expo-out",label:"Expo Out (linear)",easingFn:s=>s<=0?0:s>=1?1:s,velocityFn:()=>1,config:{decay:t}};if(t===1)return{id:"expo-out",label:"Expo Out (step)",easingFn:s=>s>0?1:0,velocityFn:()=>0,config:{decay:t}};const a=Math.log1p(-t),n=1/Math.expm1(a),o=k.makeExpoEaseOut(t),r=s=>a*Math.exp(a*s)*n;return{id:"expo-out",label:`Expo Out (${(t*100).toFixed(0)}%)`,easingFn:o,velocityFn:r,config:{decay:t}}}const Nt={back:Bt,power:st,"power-back":Vt,bezier:wt,expo:Ft};function xt(e,t){const a=Nt[e];return e==="back"?a(t?.overshoot??.1):e==="power"?a(t?.exponent??2):e==="power-back"?a(t?.exponent??2,t?.overshoot??.1):e==="expo"?a(t?.decay??.95):a(t?.x1??.5,t?.y1??0,t?.x2??1,t?.y2??.5)}function rt(e,t,a){let n;Object.defineProperty(e,t,{get:()=>n??=a(),configurable:!0,enumerable:!0})}class J{params;constructor(t){this.params=Object.freeze({...t}),rt(this,"easeInVelocity",()=>k.createVelocityFn(this.easeIn)),rt(this,"easeOutVelocity",()=>k.createVelocityFn(this.easeOut))}easeOut=t=>1-this.easeIn(1-t);get easeOutBoundary(){return{start:this.easeInBoundary.end,end:this.easeInBoundary.start}}}class Y extends J{static STROKES_KNOB={key:"strokes",label:"Strokes",type:"number",default:2,min:1,max:10,step:.05,isPrimary:!0};static EFFORT_KNOB={key:"effort",label:"Effort",type:"percent",default:.4,min:.05,max:.95,step:.01};static DRAG_KNOB={key:"drag",label:"Drag",type:"number",default:6,min:.5,max:30,step:.1};kind="swim";metadata={variants:{easeIn:!0,easeOut:!0},modes:{transition:!0,pulse:!1}};knobSpecs=[Y.STROKES_KNOB,Y.EFFORT_KNOB,Y.DRAG_KNOB];easeInBoundary={start:"zero",end:"nonzero"};constructor(t){super(t);const a=k.swim(t);this.easeIn=n=>a(n)}with(t){return new Y({...this.params,...t})}static create(t={}){return new Y({strokes:t.strokes??2,effort:t.effort??.2,drag:t.drag??6})}}function Ht(e=.1){const t=k.solveBackStrength(e),a=t+1;return{id:"back",label:`Back (${(e*100).toFixed(0)}% overshoot)`,easingFn:n=>n*n*(a*n-t),velocityFn:n=>n*(3*a*n-2*t),config:{overshoot:e,strength:t}}}Ht(.1);function Tt(e,t,a){const n=Math.max(.001,Math.min(.999,a));return o=>{if(o<=0||o>=1)return 0;if(o<=n){const r=o/n;return e(r)}else{const r=(o-n)/(1-n);return 1-t(r)}}}function At(e={}){const{bounces:t=4,decay:a=90}=e,n=Math.max(.5,t),o=Math.max(0,1-a/100),r=n<=1?o:o===0?0:Math.pow(o,1/(n-1)),s=n*Math.PI,i=r<=0?50:s/Math.PI*-Math.log(r),u=i/s,d=Math.exp(-i)*(Math.cos(s)+u*Math.sin(s));return l=>l<=0?1:l>=1?0:Math.exp(-i*l)*(Math.cos(s*l)+u*Math.sin(s*l))-d*l}function Kt(e={}){const{bounces:t=4,decay:a=90}=e,n=Math.max(1,Math.round(t)),o=Math.max(0,1-a/100),r=n<=1?Math.sqrt(o):o===0?0:Math.pow(o,1/(2*(n-1)));if(r===0)return c=>c<=0?1:c>=1?0:1-c*c;const s=Math.abs(1-r)<1e-6?1+2*n:1+2*r*(1-Math.pow(r,n))/(1-r),i=2*s*s,u=1/s,d=i*u,l=[0,u];for(let c=1;c<=n;c++){const M=2*Math.pow(r,c)*d/i;l.push(l[l.length-1]+M)}return l[l.length-1]=1,c=>{if(c<=0)return 1;if(c>=1)return 0;if(c<=u)return 1-.5*i*c*c;let M=0;for(let f=1;f<l.length-1;f++)if(c<=l[f+1]){M=f;break}M===0&&(M=l.length-2);const E=Math.pow(r,M)*d,m=c-l[M];return E*m-.5*i*m*m}}function dt(e,t,a){const n=Math.max(.001,Math.min(.999,a));return o=>{if(o<=0||o>=1)return 0;if(o<=n){const r=o/n;return e(r)}else{const r=(o-n)/(1-n);return t(r)}}}function Dt(e,t){return{isValid:!0,point:{x:1-e.x,y:1-e.y}}}function zt(e,t){return{isValid:!0,point:{x:1-e.x,y:1-e.y}}}class $ extends J{static EXPONENT_KNOB={key:"exponent",label:"Exponent",type:"number",default:2,min:.1,max:10,step:.01,isPrimary:!0};kind="power";metadata={variants:{easeIn:!0,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[$.EXPONENT_KNOB];constructor(t){super(t)}get easeInBoundary(){return{start:this.params.exponent>1?"zero":"nonzero",end:"nonzero"}}easeIn=t=>Math.pow(t,this.params.exponent);easeInVelocity=t=>{const a=this.params.exponent;return a*Math.pow(t,a-1)};easeOutVelocity=t=>this.easeInVelocity(1-t);with(t){return new $({...this.params,...t,exponent:Math.max(.1,t.exponent??this.params.exponent)})}static create(t={}){const a=Math.max(.1,t.exponent??2);return new $({exponent:a})}}const Lt=1e-4,Ct=.9999,Gt=0,Jt=1;function Yt(e){if(Number.isNaN(e))return{atStart:!1,atEnd:!1};const t=Math.max(Gt,Math.min(Jt,e));return{atStart:t<=Lt,atEnd:t>=Ct}}function ht(e){const{joinTime:t,headVelocityAtEnd:a,tailVelocityAtStart:n}=e;if(t<=0||t>=1)return{joinHeight:0,isValid:!1,warning:`Invalid joinTime: ${t}. Must be in range (0, 1).`};if(a===0)return{joinHeight:0,isValid:!1,warning:`Invalid headVelocityAtEnd: ${a}. Must be non-zero.`};if(n<=0)return{joinHeight:0,isValid:!1,warning:`Invalid tailVelocityAtStart: ${n}. Must be positive.`};const o=a*(1-t)+t*n;if(Math.abs(o)<1e-10)return{joinHeight:0,isValid:!1,warning:"Denominator too close to zero. Cannot calculate join height."};const r=t*n/o;let s;return r<0?s=`Join height is negative (${r.toFixed(4)}). This may indicate incompatible velocities.`:r>1?a<0?s=`Join height exceeds 1 (${r.toFixed(4)}) due to negative head slope. This creates a natural reflection/dip effect.`:s=`Join height exceeds 1 (${r.toFixed(4)}). This may cause overshoot beyond target.`:a<0&&r<=1&&(s=`Head ends with negative slope (${a.toFixed(4)}). Curve will dip below join height before tail recovers.`),{joinHeight:r,isValid:!0,warning:s}}function ft(e){const{joinTime:t,headVelocityAtEnd:a,pulseNaturalStartVelocity:n,isBounceStrategy:o}=e;if(o)return{isValid:!1,failureReason:"bounce_tail_unsupported"};if(n<=0)return{isValid:!1,failureReason:"invalid_pulse_velocity"};const r=n;let s=r*t/a;s<0&&(s=1),s>=1&&(s=.9999);const u=(1-s)/r;return u<=0?{isValid:!1,failureReason:"invalid_bridge_duration"}:t+u>=1?{isValid:!1,failureReason:"bridge_exceeds_timeline"}:{isValid:!0,bridgeParams:{joinHeight:s,duration:u,velocity:r}}}function $t(e,t,a){return e!==void 0&&Number.isFinite(e)&&e>0&&t>0&&a>0}function Xt(e,t,a,n){return t?e*a/n:0}function qt(e,t,a){const n=e;return 1/(1/n+(a-a/n)+(1-a)/t)}function Rt(e){const{joinTime:t,headVelocityAtEnd:a,tailVelocityAtStart:n,maxSpeed:o,naturalJoinHeight:r,naturalJoinHeightIsValid:s}=e;if(Xt(r,s,a,t)<=o)return null;const u=a,d=qt(u,n,t),l=Math.max(o,Math.max(d,1));let c;if(Math.abs(1/u-1)<1e-9)c=0;else{const I=1/u-1,p=1-1/n,S=1/l-1/n,w=t*I/(1-t),_=p-w;let B;Math.abs(_)<1e-9?B=t:B=(S-w)/_,B=Math.max(t,Math.min(.99,B)),c=t*(1-B)/(1-t),c=Math.max(0,Math.min(t,c))}const M=c>0?l*c/u:0,b=c>0?t+(t-c)*(1-t)/t:t+(1-t)*(1-1/(l*(1/n))),E=Math.max(t,Math.min(1-.01,b)),f=M+l*(t-c)+l*(E-t),P=1-E;return f<=0||f>=1||P<=.01?null:{cruiseSpeed:l,tStar:c,tC:E,headHeight:M,tailStartPos:f}}function Ut(e,t,a){const{cruiseSpeed:n,tStar:o,tC:r,headHeight:s,tailStartPos:i}=e,u=1-r;return d=>{if(d<=0)return 0;if(d>=1)return 1;if(o>0&&d<=o){const l=d/o;return s*t(l)}else{if(d<=r)return(o>0?s:0)+n*(d-o);{const l=(d-r)/u;return i+(1-i)*a(l)}}}}function Wt(e){const{joinTime:t,headBounces:a,headDecay:n,tailBounces:o,tailDecay:r,springTailBuilder:s}=e,i=s.build({joinTime:.5,bounces:a,decayPct:n,bridge:void 0}),u=k.reverseEasingFn(i.p),d=m=>u(m*.5),l=m=>i.v(1-m*.5)*.5,c=t,M=m=>m<=0?0:m>=t?t:c*d(m/t),b=m=>m<=0||m>=t?0:c/t*l(m/t);return s.build({joinTime:t,bounces:o,decayPct:r,L:M,Ld:b,bridge:void 0}).p}const Zt=10;function Qt(e){const{joinTime:t,headBounces:a,headDecay:n,tailBounces:o,tailDecay:r}=e;if(t<=0||t>=1)return{easingFn:null};if(a<1||o<1)return{easingFn:null};const s=ct.build({joinTime:.5,bounces:a,decayPct:n,bridge:void 0}),i=ct.build({joinTime:.5,bounces:o,decayPct:r,bridge:void 0}),u=k.reverseEasingFn(s.p),d=_=>u(_*.5),l=Zt,c=t,M=c/l,b=(1-c)/l,E=t-M,m=t+b,f=1-m;if(E<=0||M<=0||b<=0||f<=0)return{easingFn:null};const P=2*E,I=2*f,p=d(1),S=i.p(.5);return{easingFn:_=>{if(_<=0)return 0;if(_>=1)return 1;if(_<=E){const B=_/E;return P*d(B)}else if(_<=t){const B=P*p,T=(_-E)/M;return B+(c-B)*T}else if(_<=m){const B=1-I*(1-S),T=(_-t)/b;return c+(B-c)*T}else{const B=(_-m)/f,T=i.p(.5+B*.5);return 1-I*(1-T)}},diagnostics:{joinPosition:c,headBridgeDuration:M,tailBridgeDuration:b,headPulseDuration:E,tailPulseDuration:f,bridgeVelocity:l}}}function jt(){return{easingFn:e=>e,velocityFn:()=>1}}function te(e,t){const{joinTime:a,pulseTail:n,useBridge:o=!0,bridgeTuning:r}=e;if(a<=0||a>=1)throw new Error(`Invalid joinTime: ${a}. Must be in range (0, 1).`);if(n.bounces<1)throw new Error(`Invalid pulse tail bounces: ${n.bounces}. Must be >= 1.`);const s=jt(),i=1-a,u=t(n.strategy,{head:s.easingFn,headVelocityFn:s.velocityFn,join:i,bounces:n.bounces,decay:n.decay,useBridge:o,bridgeTuning:r});return k.reverseEasingFn(u)}function C(e){return e.params}function ee(e,t,a={}){const{joinTime:n=.5,movement:o="transition",mirror:r=!1,useBridge:s=!0,bridgeTuning:i,allowGeneralizedBackTail:u=!1,maxSpeed:d}=a,l={movement:o,headKind:e.kind,tailKind:t.kind,joinTime:n,mirror:r};return o==="pulse"?ne(e,t,n,l):ae(e,t,{joinTime:n,mirror:r,useBridge:s,bridgeTuning:i,allowGeneralizedBackTail:u,maxSpeed:d,meta:l})}function ne(e,t,a,n){const r=(e.kind==="spring"?$.create({exponent:C(e).bounces??2}):e).easeOut;let s;if(t.kind==="spring"){const{bounces:i,decay:u}=C(t);s=dt(r,At({bounces:i,decay:u*100}),a)}else if(t.kind==="bounce"){const{bounces:i,decay:u}=C(t);s=dt(r,Kt({bounces:i,decay:u*100}),a)}else s=Tt(r,t.easeIn,a);return k.easingKit(s,n)}function ae(e,t,a){const{joinTime:n,mirror:o}=a,r=Yt(n);return r.atStart&&!(t.kind==="spring"||t.kind==="bounce")?k.easingKit(s=>Math.max(0,Math.min(1,s)),a.meta):r.atEnd?k.easingKit(e.easeIn,a.meta):e.kind==="spring"?re(e,t,a):t.kind==="spring"||t.kind==="bounce"?se(e,t,a):e.kind==="bezier"&&t.kind==="bezier"?oe(e,t,a):ie(e,t,a)}function re(e,t,a){const{joinTime:n,useBridge:o,bridgeTuning:r}=a,s=C(e),i=s.bounces??4,u=(s.decay??.95)*100;if(t.kind==="spring"){const f=C(t),P=Qt({joinTime:n,headBounces:i,headDecay:u,tailBounces:f.bounces,tailDecay:f.decay*100});if(P.easingFn)return k.easingKit(P.easingFn,a.meta);const I=Wt({joinTime:n,headBounces:i,headDecay:u,tailBounces:f.bounces,tailDecay:f.decay*100,springTailBuilder:Q});return k.easingKit(I,a.meta)}if(t.kind==="bounce"){const f=C(t),P=te({joinTime:n,springHead:{decay:f.decay*100},pulseTail:{strategy:nt,bounces:f.bounces,decay:f.decay*100},useBridge:o,bridgeTuning:r},(I,p)=>pt(I,p));return k.easingKit(P,a.meta)}const d=a.mirror?k.reverseEasingFn(e.easeIn):t.easeOut,l=a.mirror?f=>e.easeInVelocity(1-f):t.easeOutVelocity,c=k.reverseEasingFn(d),M=f=>l(1-f),b=1-n,E=pt(Q,{head:c,headVelocityFn:M,joinTime:b,bounces:i,decay:u,useBridge:!0,bridgeTuning:r}),m=k.reverseEasingFn(E);return k.easingKit(m,a.meta)}function se(e,t,a){const{joinTime:n,useBridge:o,bridgeTuning:r}=a,s=C(t),i=s.bounces,u=s.decay*100,d=(t.kind==="spring",t.constructor.tailStrategy),l=e.easeIn,c=e.easeInVelocity;let M;const b=t.kind==="spring";if(o&&!b&&d.getNaturalStartVelocity){const m=d.getNaturalStartVelocity({bounces:i,decayPct:u},c,r),f=ft({joinTime:n,headVelocityAtEnd:c(1),pulseNaturalStartVelocity:m,isBounceStrategy:t.kind==="bounce"});f.isValid&&(M=f.bridgeParams)}const E=d.build({joinTime:n,bounces:i,decayPct:u,L:l,Ld:c,bridge:M});return k.easingKit(E.p,a.meta)}function oe(e,t,a){const{joinTime:n}=a,o=C(e),r=C(t),s=n,i=o.x1*n,u=o.y1*s,d=o.x2*n,l=o.y2*s,c=n,M=s;let b;Math.abs(c-d)<1e-8?b=1e8:b=(M-l)/(c-d);const E=n+r.x1*(1-n),m=s+b*(E-n),f=n+r.x2*(1-n),P=s+r.y2*(1-s),I=i/n,p=u/s,S=d/n,w=l/s,_=at(I,p,S,w),B=(E-n)/(1-n),T=(m-s)/(1-s),v=(f-n)/(1-n),N=(P-s)/(1-s),H=at(B,T,v,N),D=A=>{if(A<=0)return 0;if(A>=1)return 1;if(A<=n){const g=A/n;return s*_(g)}else{const g=(A-n)/(1-n);return s+(1-s)*H(g)}};return k.easingKit(D,a.meta)}function ie(e,t,a){const{joinTime:n,mirror:o,allowGeneralizedBackTail:r,maxSpeed:s}=a,i=e.easeIn,u=e.easeInVelocity;let d,l;o?(d=k.reverseEasingFn(i),l=P=>u(1-P)):(d=t.easeOut,l=t.easeOutVelocity);const c=u(1),M=l(0);if($t(s,c,M)){const P=ht({joinTime:n,headVelocityAtEnd:c,tailVelocityAtStart:M}),I=Rt({joinTime:n,headVelocityAtEnd:c,tailVelocityAtStart:M,maxSpeed:s,naturalJoinHeight:P.joinHeight,naturalJoinHeightIsValid:P.isValid});if(I){const p=Ut(I,i,d);return k.easingKit(p,a.meta)}}let b,E=!1,m=c;if(c<0&&(t.kind==="power"||t.kind==="back"))b=1,E=!0,m=c*(b/n);else{const P=ht({joinTime:n,headVelocityAtEnd:c,tailVelocityAtStart:M});if(!P.isValid)return k.easingKit(p=>Math.max(0,Math.min(1,p)),a.meta);const I=P.joinHeight;b=Math.max(0,Math.min(1,I)),r&&b>=.9999&&(t.kind==="power-back"||t.kind==="back"||t.kind==="power")&&(E=!0,b=1,m=c*(b/n))}const f=P=>{if(P<=0)return 0;if(P>=1)return 1;if(P<=n){const I=P/n;return b*i(I)}else{const I=(P-n)/(1-n);if(E){const p=m*(1-n),S=b,w=p,_=(3*(1-S)-2*w)/(w-(1-S));return(1-w-S)*((_+1)*I*I*I-_*I*I)+w*I+S}else return b+(1-b)*d(I)}};return k.easingKit(f,a.meta)}function pt(e,t){const{head:a=c=>c,headVelocityFn:n=()=>1,joinTime:o=.5,bounces:r=4,decay:s=95,useBridge:i=!0,bridgeTuning:u}=t;let d;if(i&&e.getNaturalStartVelocity){const c=e.getNaturalStartVelocity({bounces:r,decayPct:s},n,u),M=ft({joinTime:o,headVelocityAtEnd:n(1),pulseNaturalStartVelocity:c,isBounceStrategy:e===nt});M.isValid&&(d=M.bridgeParams)}return e.build({joinTime:o,bounces:r,decayPct:s,L:a,Ld:n,bridge:d}).p}class W extends J{static OVERSHOOT_KNOB={key:"overshoot",label:"Overshoot",type:"percent",default:.1,min:0,max:1,step:.01,isPrimary:!0};kind="back";metadata={variants:{easeIn:!0,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[W.OVERSHOOT_KNOB];easeInBoundary={start:"zero",end:"nonzero"};strength;constructor(t){super(t),this.strength=k.solveBackStrength(t.overshoot)}easeIn=t=>k.backEaseIn(t,this.strength);easeInVelocity=t=>k.backEaseInVelocity(t,this.strength);easeOutVelocity=t=>k.backEaseInVelocity(1-t,this.strength);with(t){return new W({...this.params,...t})}static create(t={}){const a=t.overshoot??.1;return new W({overshoot:a})}}class X extends J{static EXPONENT_KNOB={key:"exponent",label:"Exponent",type:"number",default:3,min:.1,max:10,step:.01,isPrimary:!0};static OVERSHOOT_KNOB={key:"overshoot",label:"Overshoot",type:"percent",default:0,min:0,max:1,step:.01};kind="power-back";metadata={variants:{easeIn:!0,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[X.EXPONENT_KNOB,X.OVERSHOOT_KNOB];strength;constructor(t){super(t),this.strength=j(t.overshoot,t.exponent)}get easeInBoundary(){return{start:this.params.exponent>2||this.params.overshoot<=0?"zero":"nonzero",end:"nonzero"}}easeIn=t=>lt(t,this.params.exponent,this.strength);easeInVelocity=t=>ut(t,this.params.exponent,this.strength);easeOutVelocity=t=>this.easeInVelocity(1-t);with(t){return new X({...this.params,...t,exponent:Math.max(.1,t.exponent??this.params.exponent)})}static create(t={}){const a=Math.max(.1,t.exponent??3),n=t.overshoot??.3;return new X({exponent:a,overshoot:n})}}class G extends J{static X1_KNOB={key:"x1",label:"X1",type:"number",default:.42,min:0,max:1,step:.01};static Y1_KNOB={key:"y1",label:"Y1",type:"number",default:0,min:-.5,max:1.5,step:.01};static X2_KNOB={key:"x2",label:"X2",type:"number",default:1,min:0,max:1,step:.01};static Y2_KNOB={key:"y2",label:"Y2",type:"number",default:1,min:-.5,max:1.5,step:.01};kind="bezier";metadata={variants:{easeIn:!0,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[G.X1_KNOB,G.Y1_KNOB,G.X2_KNOB,G.Y2_KNOB];easeInBoundary={start:"nonzero",end:"nonzero"};bezier=at(this.params.x1,this.params.y1,this.params.x2,this.params.y2);easeIn=t=>this.bezier(t);easeOut=t=>this.bezier(t);constructor(t){super(t);const a=()=>k.createVelocityFn(this.bezier,{boundarySample:.001});rt(this,"easeInVelocity",a),rt(this,"easeOutVelocity",a)}with(t){return new G({...this.params,...t})}static create(t={}){return new G({x1:t.x1??.42,y1:t.y1??0,x2:t.x2??1,y2:t.y2??1})}}class Z extends J{static DECAY_KNOB={key:"decay",label:"Decay",type:"percent",default:.95,min:.8,max:.999,step:.001,isPrimary:!0};kind="expo";metadata={variants:{easeIn:!1,easeOut:!0},modes:{transition:!0,pulse:!1}};knobSpecs=[Z.DECAY_KNOB];easeInBoundary={start:"nonzero",end:"nonzero"};easeOutFn;negK;scale;d;constructor(t){super(t),this.d=Math.max(0,Math.min(1,t.decay)),this.d===0?(this.easeOutFn=a=>Math.max(0,Math.min(1,a)),this.negK=0,this.scale=1):this.d===1?(this.easeOutFn=a=>a>0?1:0,this.negK=-1/0,this.scale=0):(this.negK=Math.log1p(-this.d),this.scale=1/Math.expm1(this.negK),this.easeOutFn=k.makeExpoEaseOut(this.d))}easeIn=t=>1-this.easeOutFn(1-t);easeInVelocity=t=>this.easeOutVelocityImpl(1-t);easeOut=t=>this.easeOutFn(t);easeOutVelocity=t=>this.easeOutVelocityImpl(t);easeOutVelocityImpl(t){return this.d===0?1:this.d===1?0:this.negK*Math.exp(this.negK*t)*this.scale}with(t){return new Z({...this.params,...t})}static create(t={}){return new Z({decay:t.decay??.95})}}const ce=e=>e,le=e=>1,ue=1e-4;class q extends J{static BOUNCES_KNOB={key:"bounces",label:"Bounces",type:"number",default:4,min:0,max:10,step:1,isPrimary:!0};static DECAY_KNOB={key:"decay",label:"Decay",type:"percent",default:.95,min:0,max:.99,step:.01};kind="spring";metadata={variants:{easeIn:!1,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[q.BOUNCES_KNOB,q.DECAY_KNOB];easeInBoundary={start:"nonzero",end:"nonzero"};builtP;builtV;constructor(t){super(t);const a=Q.build({joinTime:ue,bounces:t.bounces,decayPct:t.decay*100,L:ce,Ld:le});this.builtP=a.p,this.builtV=a.v}easeIn=t=>1-this.builtP(1-t);easeInVelocity=t=>this.builtV(1-t);easeOut=t=>this.builtP(t);easeOutVelocity=t=>this.builtV(t);static get tailStrategy(){return Q}with(t){return new q({...this.params,...t})}static create(t={}){return new q({bounces:t.bounces??4,decay:t.decay??.95})}}const de=e=>e,he=e=>1,fe=1e-4;class R extends J{static BOUNCES_KNOB={key:"bounces",label:"Bounces",type:"number",default:4,min:1,max:10,step:1,isPrimary:!0};static DECAY_KNOB={key:"decay",label:"Decay",type:"percent",default:.95,min:0,max:.99,step:.01};kind="bounce";metadata={variants:{easeIn:!1,easeOut:!0},modes:{transition:!0,pulse:!0}};knobSpecs=[R.BOUNCES_KNOB,R.DECAY_KNOB];easeInBoundary={start:"nonzero",end:"nonzero"};builtP;builtV;constructor(t){super(t);const a=nt.build({joinTime:fe,bounces:t.bounces,decayPct:t.decay*100,L:de,Ld:he});this.builtP=a.p,this.builtV=a.v}easeIn=t=>1-this.builtP(1-t);easeInVelocity=t=>this.builtV(1-t);easeOut=t=>this.builtP(t);easeOutVelocity=t=>this.builtV(t);static get tailStrategy(){return nt}with(t){return new R({...this.params,...t})}static create(t={}){return new R({bounces:t.bounces??4,decay:t.decay??.95})}}const pe={power:$,back:W,"power-back":X,bezier:G,expo:Z,spring:q,bounce:R,swim:Y};function ot(e,t){return pe[e].create(t)}function yt(e){const{kind:t,...a}=e;return a}function ye(e){const{movement:t="transition",head:a,tail:n,joinTime:o=.5,mirror:r=!1,useBridge:s,bridgeTuning:i,allowGeneralizedBackTail:u,maxSpeed:d}=e,l=ot(a.kind,yt(a)),c=ot(n.kind,yt(n));return ee(l,c,{movement:t,joinTime:o,mirror:r,useBridge:s,bridgeTuning:i,allowGeneralizedBackTail:u,maxSpeed:d})}const mt=1e-6,it=mt,gt=1-mt;function me(e,t,a=!1){return!a&&(t==="power-back"||t==="back"||t==="power")?Math.min(1,e):e}function ge(e,t,a=!1){return!a&&t==="power-back"?Math.max(0,e):e}return x.BackRem=W,x.BezierRem=G,x.BounceRem=R,x.ExpoRem=Z,x.PowerBackRem=X,x.PowerRem=$,x.SpringRem=q,x.SwimRem=Y,x.calculateHeadP2FromTailP1=zt,x.calculateTailP1FromHeadP2=Dt,x.clampBezierY1ForHead=ge,x.clampBezierY2ForTail=me,x.evalPowerBackIn=lt,x.findExponentForMinimumPosition=vt,x.fuse=ye,x.getEasingRem=ot,x.getLocalMinimumPosition=St,x.getPowerCurveCanonicalPoint=kt,x.getTailStrategy=xt,x.solvePowerBackStrength=j,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"}),x})({},SmartPrimitive,PennerEasing);
2
+ //# sourceMappingURL=index.iife.js.map