!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).EmblaCarouselWheelGestures=t()}(this,(function(){"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t=e;case"y":return Math.abs(o)>=e;case"z":return Math.abs(r)>=e;default:return!1}}(m,c)&&i.preventDefault(),p.isStarted?p.isMomentum&&m>Math.max(2,2*p.lastAbsDelta)&&(L(!0),O()):O(),0===m&&Object.is&&Object.is(i.deltaX,-0)?M=!0:(u=i,p.axisMovement=t(p.axisMovement,c),p.lastAbsDelta=m,p.scrollPointsToMerge.push({axisDelta:c,timeStamp:l}),w(),b({axisDelta:c,isStart:!p.isStartPublished}),p.isStartPublished=!0,j())},w=function(){var e;2===p.scrollPointsToMerge.length?(p.scrollPoints.unshift({axisDeltaSum:p.scrollPointsToMerge.map((function(e){return e.axisDelta})).reduce(t),timeStamp:(e=p.scrollPointsToMerge.map((function(e){return e.timeStamp})),e.reduce((function(e,t){return e+t}))/e.length)}),D(),p.scrollPointsToMerge.length=0,p.scrollPoints.length=1,p.isMomentum||T()):p.isStartPublished||y()},y=function(){var e;p.axisVelocity=(e=p.scrollPointsToMerge,e[e.length-1]).axisDelta.map((function(e){return e/p.willEndTimeout}))},D=function(){var e=p.scrollPoints,t=e[0],n=e[1];if(n&&t){var i=t.timeStamp-n.timeStamp;if(!(i<=0)){var o=t.axisDeltaSum.map((function(e){return e/i})),r=o.map((function(e,t){return e/(p.axisVelocity[t]||1)}));p.axisVelocity=o,p.accelerationFactors.push(r),S(i)}}},S=function(e){var t=10*Math.ceil(e/10)*1.2;p.isMomentum||(t=Math.max(100,2*t)),p.willEndTimeout=Math.min(1e3,Math.round(t))},P=function(e){return 0===e||e<=.96&&e>=.6},T=function(){if(p.accelerationFactors.length>=5){if(M&&(M=!1,n(p.axisVelocity)>=.2))return void A();var e=p.accelerationFactors.slice(-5);e.every((function(e){var t=!!e.reduce((function(e,t){return e&&e<1&&e===t?1:0})),n=e.filter(P).length===e.length;return t||n}))&&A(),p.accelerationFactors=e}},A=function(){p.isMomentum=!0},O=function(){(p={isStarted:!1,isStartPublished:!1,isMomentum:!1,startTime:0,lastAbsDelta:Infinity,axisMovement:[0,0,0],axisVelocity:[0,0,0],accelerationFactors:[],scrollPoints:[],scrollPointsToMerge:[],willEndTimeout:400}).isStarted=!0,p.startTime=Date.now(),c=void 0,M=!1},j=function(){clearTimeout(l),l=setTimeout(L,p.willEndTimeout)},L=function(e){void 0===e&&(e=!1),p.isStarted&&(b(p.isMomentum&&e?{isEnding:!0,isMomentumCancel:!0}:{isEnding:!0}),p.isMomentum=!1,p.isStarted=!1)},V=function(e){var t=[],n=function(n){n.removeEventListener("wheel",e),t=t.filter((function(e){return e!==n}))};return i({observe:function(i){return i.addEventListener("wheel",e,{passive:!1}),t.push(i),function(){return n(i)}},unobserve:n,disconnect:function(){t.forEach(n)}})}(g),C=V.observe,F=V.unobserve,W=V.disconnect;return x(s),i({on:f,off:d,observe:C,unobserve:F,disconnect:W,feedWheel:g,updateOptions:x})}({preventWheelAction:w,reverseSign:[!0,!0,!1]});function D(){j=("x"===w?b.containerRect.width:b.containerRect.height)/2}var S,P=y.observe(E),T=y.on("wheel",(function(e){var t=e.axisDelta,n=t[0],i=t[1],o="x"===w?i:n,r=e.isEnding&&!e.isMomentum||e.isMomentum&&e.previous&&!e.previous.isMomentum;Math.abs("x"===w?n:i)>Math.abs(o)&&!A&&!e.isMomentum&&!L&&function(e){try{X(S=new MouseEvent("mousedown",e.event))}catch(e){return m()}A=!0,O=0,document.documentElement.addEventListener("mousemove",F,!0),document.documentElement.addEventListener("mouseup",F,!0),document.documentElement.addEventListener("mousedown",F,!0),l.wheelDraggingClass&&E.classList.add(l.wheelDraggingClass)}(e),L&&e.isEnding&&(L=!1),A&&(function(e){var t=Y(e);if(t.isAtBoundary&&!e.isMomentum){if((O+=Math.abs(t.primaryAxisDelta))>j)return L=!0,V(e),!0}else O=0;return!1}(e)||(r?V(e):X(W("mousemove",e))))})),A=!1,O=0,j=0,L=!1;function V(e){A=!1,X(W("mouseup",e)),C(),l.wheelDraggingClass&&E.classList.remove(l.wheelDraggingClass)}function C(){document.documentElement.removeEventListener("mousemove",F,!0),document.documentElement.removeEventListener("mouseup",F,!0),document.documentElement.removeEventListener("mousedown",F,!0)}function F(e){A&&e.isTrusted&&e.stopImmediatePropagation()}function W(e,t){var n,i;if(w===b.options.axis){var o=t.axisMovement;n=o[0],i=o[1]}else{var r=t.axisMovement;i=r[0],n=r[1]}if(Y(t).isAtBoundary){var a=Math.min(O/j,1),s=O*(n>0?-1:1)*(.25+.5*a);n+=s,i+=s}if(!b.options.skipSnaps&&!b.options.dragFree){var u=b.containerRect.width,c=b.containerRect.height;n=n<0?Math.max(n,-u):Math.min(n,u),i=i<0?Math.max(i,-c):Math.min(i,c)}return new MouseEvent(e,{clientX:S.clientX+n,clientY:S.clientY+i,screenX:S.screenX+n,screenY:S.screenY+i,movementX:n,movementY:i,button:0,bubbles:!0,cancelable:!0,composed:!0})}function X(e){f.containerNode().dispatchEvent(e)}function Y(e){var t=e.axisDelta,n=t[0],i=t[1],o=f.scrollProgress(),r="x"===w?n:i;return{isAtBoundary:r<0&&!(o<1)||r>0&&!(o>0),primaryAxisDelta:r}}D(),f.on("resize",D),m=function(){P(),T(),f.off("resize",D),C()}},destroy:function(){return m()}}}return u.globalOptions=void 0,u})); //# sourceMappingURL=embla-carousel-wheel-gestures.umd.js.map