!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).EmblaCarouselFade=t()}(this,(function(){"use strict";function n(n,t,e){return Math.min(Math.max(n,t),e)}function t(n){return"number"==typeof n&&!isNaN(n)}function e(e={}){const o=1,i=0,r=.68;let s,l,c,a,f=[],d=0,u=0,p=0,g=!1;function y(){b(s.selectedScrollSnap(),o)}function E(){g=!1}function S(){g=!1,d=0,u=0}function h(){const n=s.internalEngine().scrollBody.duration();u=n?0:o,g=!0,n||y()}function m(n){const{scrollSnaps:e,location:o,target:i}=s.internalEngine();!t(n)||f[n]<.5||(o.set(e[n]),i.set(o))}function b(t,e){s.scrollSnapList().forEach(((r,l)=>{const c=Math.abs(e),a=f[l],u=l===t,y=n(u?a+c:a-c,i,o);f[l]=y;const E=u&&g,S=s.previousScrollSnap();E&&(f[S]=1-y),u&&function(n,t){const{index:e,dragHandler:o,scrollSnaps:i}=s.internalEngine(),r=o.pointerDown(),l=1/(i.length-1);let c=n,a=r?s.selectedScrollSnap():s.previousScrollSnap();if(r&&c===a){const n=-1*Math.sign(d);c=a,a=e.clone().set(a).add(n).get()}const f=a*l,u=(c-a)*l;p=f+u*t}(t,y),function(n){const t=s.internalEngine().slideRegistry[n],{scrollSnaps:e,containerRect:o}=s.internalEngine(),r=f[n];t.forEach((t=>{const l=s.slideNodes()[t].style,c=parseFloat(r.toFixed(2)),a=c>i,f=function(n){const{axis:t}=s.internalEngine();return`translate${t.scroll.toUpperCase()}(${t.direction(n)}px)`}(a?e[n]:o.width+2);a&&(l.transform=f),l.opacity=c.toString(),l.pointerEvents=r>.5?"auto":"none",a||(l.transform=f)}))}(l)}))}function v(){const{dragHandler:n,index:t,scrollBody:e}=s.internalEngine(),o=s.selectedScrollSnap();if(!n.pointerDown())return o;const i=Math.sign(e.velocity()),r=Math.sign(d),l=t.clone().set(o).add(-1*i).get();return i&&r?r===i?l:o:null}function x(){const{target:n,location:e}=s.internalEngine(),i=n.get()-e.get(),c=Math.abs(i)>=1,a=v(),p=!t(a);return function(n){const{dragHandler:e,scrollBody:i}=n.internalEngine(),s=e.pointerDown(),c=i.velocity(),a=i.duration(),p=v(),g=!t(p);if(s){if(!c)return;d+=c,u=Math.abs(c/l),m(p)}if(!s){if(!a||g)return;u+=(o-f[p])/a,u*=r}g||b(p,u)}(s),!p&&!c&&f[a]>.999}function M(){return p}return{name:"fade",options:e,init:function(t){s=t;const e=s.selectedScrollSnap(),{scrollBody:r,containerRect:d,axis:u}=s.internalEngine(),p=u.measureSize(d);l=n(.75*p,200,500),g=!1,f=s.scrollSnapList().map(((n,t)=>t===e?o:i)),c=r.settled,a=s.scrollProgress,r.settled=x,s.scrollProgress=M,s.on("select",h).on("slideFocus",y).on("pointerDown",S).on("pointerUp",E),function(){const{translate:n,slideLooper:t}=s.internalEngine();n.clear(),n.toggleActive(!1),t.loopPoints.forEach((({translate:n})=>{n.clear(),n.toggleActive(!1)}))}(),y()},destroy:function(){const{scrollBody:n}=s.internalEngine();n.settled=c,s.scrollProgress=a,s.off("select",h).off("slideFocus",y).off("pointerDown",S).off("pointerUp",E),s.slideNodes().forEach((n=>{const t=n.style;t.opacity="",t.transform="",t.pointerEvents="",n.getAttribute("style")||n.removeAttribute("style")}))}}}return e.globalOptions=void 0,e}));