!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BScroll={})}(this,function(t){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function e(t,e){function o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var c=function(){return(c=Object.assign||function(t){for(var e,o=1,i=arguments.length;odocument.documentElement.clientWidth-a||h>document.documentElement.clientHeight-a||rthis.minScrollPos||othis.minScrollPos&&this.options.bounces[0]||othis.minScrollPos?this.minScrollPos:this.maxScrollPos),o},ut.prototype.end=function(t){var e,o={duration:0},i=Math.abs(this.currentPos-this.startPos);return this.options.momentum&&tthis.options.momentumLimitDistance?(e=-1===this.direction&&this.options.bounces[0]||1===this.direction&&this.options.bounces[1]?this.wrapperSize:0,o=this.hasScroll?this.momentum(this.currentPos,this.startPos,t,this.maxScrollPos,this.minScrollPos,e,this.options):{destination:this.currentPos,duration:0}):this.hooks.trigger(this.hooks.eventTypes.end,o),o},ut.prototype.momentum=function(t,e,o,i,s,n,r){void 0===r&&(r=this.options);var h=t-e,a=Math.abs(h)/o,c=r.deceleration,l=r.swipeBounceTime,p={destination:t+a/c*(h<0?-1:1),duration:r.swipeTime,rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,p,h),p.destinations&&(p.destination=n?Math.min(s+n/4,s+n/p.rate*a):s,p.duration=l),p.destination=Math.round(p.destination),p},ut.prototype.updateDirection=function(){var t=Math.round(this.currentPos)-this.absStartPos;this.setDirection(t)},ut.prototype.refresh=function(t){var e=this.options.rect,o=e.size,i=e.position,s="static"===window.getComputedStyle(this.wrapper,null).position,n=X(this.wrapper);this.wrapperSize=n[o],this.setContent(t);var r=X(this.content);this.contentSize=r[o],this.relativeOffset=r[i],s&&(this.relativeOffset-=n[i]),this.computeBoundary(),this.setDirection(0)},ut.prototype.setContent=function(t){t!==this.content&&(this.content=t,this.resetState())},ut.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},ut.prototype.computeBoundary=function(){this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);var t={minScrollPos:0,maxScrollPos:this.wrapperSize-this.contentSize};t.maxScrollPos<0&&(t.maxScrollPos-=this.relativeOffset,0===this.options.specifiedIndexAsContent&&(t.minScrollPos=-this.relativeOffset)),this.hooks.trigger(this.hooks.eventTypes.computeBoundary,t),this.minScrollPos=t.minScrollPos,this.maxScrollPos=t.maxScrollPos,this.hasScroll=this.options.scrollable&&this.maxScrollPosthis.minScrollPos?e=this.minScrollPos:ee+this.directionLockThreshold?this.directionLocked="horizontal":e>=t+this.directionLockThreshold?this.directionLocked="vertical":this.directionLocked="none")},yt.prototype.handleEventPassthrough=function(t){var e=ft[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return dt.yes(t);if(this.eventPassthrough===e.no)return dt.no(t)}return!1},yt);function yt(t,e,o){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=o,this.reset()}var mt=(gt.prototype.bindActionsHandler=function(){var s=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,function(t){return!s.enabled||s.handleStart(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,function(t){var e=t.deltaX,o=t.deltaY,i=t.e;return!s.enabled||s.handleMove(e,o,i)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,function(t){return!s.enabled||s.handleEnd(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,function(t){s.enabled&&!t._constructed&&s.handleClick(t)})},gt.prototype.handleStart=function(t){var e=u();this.moved=!1,this.startTime=e,this.directionLockAction.reset(),this.scrollBehaviorX.start(),this.scrollBehaviorY.start(),this.animater.doStop(),this.scrollBehaviorX.resetStartPos(),this.scrollBehaviorY.resetStartPos(),this.hooks.trigger(this.hooks.eventTypes.start,t)},gt.prototype.handleMove=function(t,e,o){if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,o)){var i=this.scrollBehaviorX.getAbsDist(t),s=this.scrollBehaviorY.getAbsDist(e),n=u();if(this.checkMomentum(i,s,n))return!0;if(this.directionLockAction.checkMovingDirection(i,s,o))return this.actionsHandler.setInitiated(),!0;var r=this.directionLockAction.adjustDelta(t,e),h=this.scrollBehaviorX.move(r.deltaX),a=this.scrollBehaviorY.move(r.deltaY);this.moved||(this.moved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.animater.translate({x:h,y:a}),this.dispatchScroll(n)}},gt.prototype.dispatchScroll=function(t){t-this.startTime>this.options.momentumLimitTime&&(this.startTime=t,this.scrollBehaviorX.updateStartPos(),this.scrollBehaviorY.updateStartPos(),1===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())),1this.options.momentumLimitTime&&ethis.scrollBehaviorX.minScrollPos||o.newXthis.scrollBehaviorY.minScrollPos||o.newY