!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).MotionUtils={})}(this,function(n){"use strict";function t(n,t){-1===n.indexOf(t)&&n.push(t)}function e(n,t){const e=n.indexOf(t);e>-1&&n.splice(e,1)}const i=(n,t,e)=>e>t?t:e<n?n:e;function s(n,t){return t?`${n}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:n}n.warning=()=>{},n.invariant=()=>{},"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&(n.warning=(n,t,e)=>{n||"undefined"==typeof console||console.warn(s(t,e))},n.invariant=(n,t,e)=>{if(!n)throw new Error(s(t,e))});const o=n=>n;const r=new Set;const c=(n,t,e)=>{const i=t-n;return((e-n)%i+i)%i+n},a=(n,t,e)=>(((1-3*e+3*t)*n+(3*e-6*t))*n+3*t)*n;function u(n,t,e,i){if(n===t&&e===i)return o;const s=t=>function(n,t,e,i,s){let o,r,c=0;do{r=t+(e-t)/2,o=a(r,i,s)-n,o>0?e=r:t=r}while(Math.abs(o)>1e-7&&++c<12);return r}(t,0,1,n,e);return n=>0===n||1===n?n:a(s(n),t,i)}const l=n=>t=>t<=.5?n(2*t)/2:(2-n(2*(1-t)))/2,f=n=>t=>1-n(1-t),p=u(.33,1.53,.69,.99),d=f(p),h=l(d),g=n=>n>=1?1:(n*=2)<1?.5*d(n):.5*(2-Math.pow(2,-10*(n-1))),b=n=>1-Math.sin(Math.acos(n)),m=f(b),y=l(b),v=u(.42,0,1,1),O=u(0,0,.58,1),I=u(.42,0,.58,1);const M=n=>Array.isArray(n)&&"number"!=typeof n[0];const w=n=>Array.isArray(n)&&"number"==typeof n[0],S={linear:o,easeIn:v,easeInOut:I,easeOut:O,circIn:b,circInOut:y,circOut:m,backIn:d,backInOut:h,backOut:p,anticipate:g};n.MotionGlobalConfig={},n.SubscriptionManager=class{constructor(){this.subscriptions=[]}add(n){return t(this.subscriptions,n),()=>e(this.subscriptions,n)}notify(n,t,e){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](n,t,e);else for(let s=0;s<i;s++){const i=this.subscriptions[s];i&&i(n,t,e)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},n.addUniqueItem=t,n.anticipate=g,n.backIn=d,n.backInOut=h,n.backOut=p,n.circIn=b,n.circInOut=y,n.circOut=m,n.clamp=i,n.cubicBezier=u,n.easeIn=v,n.easeInOut=I,n.easeOut=O,n.easingDefinitionToFunction=t=>{if(w(t)){n.invariant(4===t.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,i,s,o]=t;return u(e,i,s,o)}return"string"==typeof t?(n.invariant(void 0!==S[t],`Invalid easing type '${t}'`,"invalid-easing-type"),S[t]):t},n.getEasingForSegment=function(n,t){return M(n)?n[c(0,n.length,t)]:n},n.hasWarned=function(n){return r.has(n)},n.isBezierDefinition=w,n.isEasingArray=M,n.isNumericalString=n=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),n.isObject=n=>"object"==typeof n&&null!==n,n.isZeroValueString=n=>/^0[^.\s]+$/u.test(n),n.memo=function(n){let t;return()=>(void 0===t&&(t=n()),t)},n.millisecondsToSeconds=n=>n/1e3,n.mirrorEasing=l,n.moveItem=function([...n],t,e){const i=t<0?n.length+t:t;if(i>=0&&i<n.length){const i=e<0?n.length+e:e,[s]=n.splice(t,1);n.splice(i,0,s)}return n},n.noop=o,n.pipe=(...n)=>n.reduce((n,t)=>e=>t(n(e))),n.progress=(n,t,e)=>{const i=t-n;return i?(e-n)/i:1},n.removeItem=e,n.reverseEasing=f,n.secondsToMilliseconds=n=>1e3*n,n.steps=function(n,t="end"){return e=>{const s=(e="end"===t?Math.min(e,.999):Math.max(e,.001))*n,o="end"===t?Math.floor(s):Math.ceil(s);return i(0,1,o/n)}},n.velocityPerSecond=(n,t)=>t?n*(1e3/t):0,n.warnOnce=function(n,t,e){n||r.has(t)||(console.warn(s(t,e)),r.add(t))},n.wrap=c});
