!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 z=function(t,e){return(z=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}z(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var r=function(){return(r=Object.assign||function(t){for(var e,o=1,i=arguments.length;odocument.documentElement.clientWidth-i||o>document.documentElement.clientHeight-i||ethis.minScrollPos||othis.minScrollPos&&this.options.bounces[0]||othis.minScrollPos?this.minScrollPos:this.maxScrollPos:o},x.prototype.end=function(t){var e={duration:0},o=Math.abs(this.currentPos-this.startPos);return this.options.momentum&&tthis.options.momentumLimitDistance?(o=-1===this.direction&&this.options.bounces[0]||1===this.direction&&this.options.bounces[1]?this.wrapperSize:0,e=this.hasScroll?this.momentum(this.currentPos,this.startPos,t,this.maxScrollPos,this.minScrollPos,o,this.options):{destination:this.currentPos,duration:0}):this.hooks.trigger(this.hooks.eventTypes.end,e),e},x.prototype.momentum=function(t,e,o,i,n,s,r){void 0===r&&(r=this.options);var e=t-e,o=Math.abs(e)/o,h=r.deceleration,a=r.swipeBounceTime,r=r.swipeTime,t={destination:t+o*o/h*(e<0?-1:1),duration:Math.min(r,2*o/h),rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,t,e),t.destinationn&&(t.destination=s?Math.min(n+s/4,n+s/t.rate*o):n,t.duration=a),t.destination=Math.round(t.destination),t},x.prototype.updateDirection=function(){var t=this.currentPos-this.absStartPos;this.setDirection(t)},x.prototype.refresh=function(t){var e=this.options.rect,o=e.size,e=e.position,i="static"===window.getComputedStyle(this.wrapper,null).position,n=G(this.wrapper),t=(this.wrapperSize=this.wrapper["width"===o?"clientWidth":"clientHeight"],this.setContent(t),G(this.content));this.contentSize=t[o],this.relativeOffset=t[e],i&&(this.relativeOffset-=n[e]),this.computeBoundary(),this.setDirection(0)},x.prototype.setContent=function(t){t!==this.content&&(this.content=t,this.resetState())},x.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},x.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?t=this.minScrollPos:te+this.directionLockThreshold?this.directionLocked="horizontal":e>=t+this.directionLockThreshold?this.directionLocked="vertical":this.directionLocked="none")},M.prototype.handleEventPassthrough=function(t){var e=gt[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return mt.yes(t);if(this.eventPassthrough===e.no)return mt.no(t)}return!1},M);function M(t,e,o){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=o,this.reset()}X.prototype.bindActionsHandler=function(){var n=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,function(t){return!n.enabled||n.handleStart(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,function(t){var e,o=t.deltaX,i=t.deltaY,t=t.e;return!n.enabled||(o=o,i=i,e=2===(e=n.options.quadrant)?[i,-o]:3===e?[-o,-i]:4===e?[-i,o]:[o,i],n.hooks.trigger(n.hooks.eventTypes.coordinateTransformation,o={deltaX:e[0],deltaY:e[1]}),n.handleMove(o.deltaX,o.deltaY,t))}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,function(t){return!n.enabled||n.handleEnd(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,function(t){n.enabled&&!t._constructed&&n.handleClick(t)})},X.prototype.handleStart=function(t){var e=u();this.fingerMoved=!1,this.contentMoved=!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)},X.prototype.handleMove=function(t,e,o){var i,n,s;if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,o))return s=this.scrollBehaviorX.getAbsDist(t),n=this.scrollBehaviorY.getAbsDist(e),i=u(),!!this.checkMomentum(s,n,i)||(this.directionLockAction.checkMovingDirection(s,n,o)?(this.actionsHandler.setInitiated(),!0):(s=this.directionLockAction.adjustDelta(t,e),n=this.scrollBehaviorX.getCurrentPos(),o=this.scrollBehaviorX.move(s.deltaX),t=this.scrollBehaviorY.getCurrentPos(),e=this.scrollBehaviorY.move(s.deltaY),void(this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)||(this.fingerMoved||(this.fingerMoved=!0),s=o!==n||e!==t,this.contentMoved||s||this.hooks.trigger(this.hooks.eventTypes.contentNotMoved),!this.contentMoved&&s&&(this.contentMoved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.contentMoved&&s&&(this.animater.translate({x:o,y:e}),this.dispatchScroll(i))))))},X.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