!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).BetterScroll={})}(this,function(t){"use strict";var s=function(t,e){return(s=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}s(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var a=function(){return(a=Object.assign||function(t){for(var e,o=1,s=arguments.length;on[0]&&e[1]document.documentElement.clientWidth-l||h>document.documentElement.clientHeight-l||nthis.minScrollPos||othis.minScrollPos&&this.options.bounces[0]||othis.minScrollPos?this.minScrollPos:this.maxScrollPos),o},mt.prototype.end=function(t){var e,o={duration:0},s=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},mt.prototype.momentum=function(t,e,o,s,i,r,n){void 0===n&&(n=this.options);var h=t-e,l=Math.abs(h)/o,a=n.deceleration,c=n.swipeBounceTime,p={destination:t+l/a*(h<0?-1:1),duration:n.swipeTime,rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,p,h),p.destinationi&&(p.destination=r?Math.min(i+r/4,i+r/p.rate*l):i,p.duration=c),p.destination=Math.round(p.destination),p},mt.prototype.updateDirection=function(){var t=Math.round(this.currentPos)-this.absStartPos;this.setDirection(t)},mt.prototype.refresh=function(){var t=this.options.rect,e=t.size,o=t.position,s="static"===window.getComputedStyle(this.wrapper,null).position,i=H(this.wrapper);this.wrapperSize=i[e];var r=H(this.content);this.contentSize=r[e],this.relativeOffset=r[o],s&&(this.relativeOffset-=i[o]),this.computeBoundary(),this.setDirection(0)},mt.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,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")},Pt.prototype.handleEventPassthrough=function(t){var e=Tt[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return kt.yes(t);if(this.eventPassthrough===e.no)return kt.no(t)}return!1},Pt);function Pt(t,e,o){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=o,this.reset()}var wt=(St.prototype.bindActionsHandler=function(){var i=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,function(t){return!i.enabled||i.handleStart(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,function(t){var e=t.deltaX,o=t.deltaY,s=t.e;return!i.enabled||i.handleMove(e,o,s)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,function(t){return!i.enabled||i.handleEnd(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,function(t){i.enabled&&!t._constructed&&i.handleClick(t)})},St.prototype.handleStart=function(t){var e=f();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)},St.prototype.handleMove=function(t,e,o){if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,o)){var s=this.scrollBehaviorX.getAbsDist(t),i=this.scrollBehaviorY.getAbsDist(e),r=f();if(this.checkMomentum(s,i,r))return!0;if(this.directionLockAction.checkMovingDirection(s,i,o))return this.actionsHandler.setInitiated(),!0;var n=this.directionLockAction.adjustDelta(t,e),h=this.scrollBehaviorX.move(n.deltaX),l=this.scrollBehaviorY.move(n.deltaY);this.moved||(this.moved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.animater.translate({x:h,y:l}),this.dispatchScroll(r)}},St.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.newYe.minScrollPos||e.currentPoso.minScrollPos||o.currentPos=this.pages[o][0].cx);o++);for(i=this.pages[o].length;s=this.pages[0][s].cy);s++);return{pageX:o,pageY:s}},Qt.prototype.buildPagesMatrix=function(t,e){for(var o,s,i=[],r=0,n=0,h=this.scroll.scroller.scrollBehaviorX.maxScrollPos,l=this.scroll.scroller.scrollBehaviorY.maxScrollPos,a=Math.round(t/2),c=Math.round(e/2);r>-this.scrollerWidth;){for(i[n]=[],o=s=0;o>-this.scrollerHeight;)i[n][s]={x:Math.max(r,h),y:Math.max(o,l),width:t,height:e,cx:r-a,cy:o-c},o-=e,s++;r-=t,n++}return i},Qt);function Qt(t){this.scroll=t,this.init()}var te={pageX:0,pageY:0,x:0,y:0},ee=(oe.prototype.refresh=function(){this.pagesMatrix=new Jt(this.scroll);var t=this.currentPage,e=t.pageX,o=t.pageY,s=this.pagesMatrix.getPageStats(e,o),i=s.x,r=s.y;this.currentPage={pageX:e,pageY:o,x:i,y:r},this.checkSlideLoop()},oe.prototype.setCurrentPage=function(t){this.currentPage=t},oe.prototype.getInternalPage=function(t,e){t>=this.pagesMatrix.pageLengthOfX?t=this.pagesMatrix.pageLengthOfX-1:t<0&&(t=0),e>=this.pagesMatrix.pageLengthOfY?e=this.pagesMatrix.pageLengthOfY-1:e<0&&(e=0);var o=this.pagesMatrix.getPageStats(t,e);return{pageX:t,pageY:e,x:o.x,y:o.y}},oe.prototype.getInitialPage=function(){var t=this.loopX?1:0,e=this.loopY?1:0,o=this.currentPage.pageX||t,s=this.currentPage.pageY||e,i=this.pagesMatrix.getPageStats(o,s);return{pageX:o,pageY:s,x:i.x,y:i.y}},oe.prototype.getExposedPage=function(){var t=g({},this.currentPage);return this.loopX&&(t.pageX=this.fixedPage(t.pageX,this.pagesMatrix.pageLengthOfX-2)),this.loopY&&(t.pageY=this.fixedPage(t.pageY,this.pagesMatrix.pageLengthOfY-2)),t},oe.prototype.getWillChangedPage=function(t){return t=g({},t),this.loopX&&(t.pageX=this.fixedPage(t.pageX,this.pagesMatrix.pageLengthOfX-2),t.x=this.pagesMatrix.getPageStats(t.pageX+1,0).x),this.loopY&&(t.pageY=this.fixedPage(t.pageY,this.pagesMatrix.pageLengthOfY-2),t.y=this.pagesMatrix.getPageStats(0,t.pageY+1).y),t},oe.prototype.fixedPage=function(t,e){for(var o=[],s=0;s=t.minScrollX&&-1===r.movingDirection,l=t.x<=t.maxScrollX&&1===r.movingDirection,a=t.y>=t.minScrollY&&-1===n.movingDirection,c=t.y<=t.maxScrollY&&1===n.movingDirection;{if(s)return a||c;if(o)return h||l}return!1}(e)||(e.disable(),t.enable())}))}},fe=(ge.prototype.setup=function(t){this.appendBScroll(t),this.handleContainRelationship(),this.handleCompatible()},ge.prototype.addHooks=function(t){var e=this;t.on("destroy",function(){e.teardown(t)})},ge.prototype.teardown=function(t){this.removeBScroll(t),this.handleContainRelationship(),this.handleCompatible()},ge.prototype.appendBScroll=function(t){this.stores.push(t)},ge.prototype.removeBScroll=function(t){var e=this.stores.indexOf(t);-1!==e&&(t.wrapper.isBScrollContainer=void 0,this.stores.splice(e,1))},ge.prototype.handleContainRelationship=function(){var t=this.stores;if(t.length<=1)t[0]&&t[0].__parentInfo&&(t[0].__parentInfo=void 0);else for(var e,o,s,i=0;ithis.list.length&&(e=o-this.list.length,this.addEmptyData(e)),[2,this.checkToFetch(o)]})})},Pe.prototype.add=function(t){for(var e=0;e=t.length&&(e=t.length-1),o>t.length&&(o=t.length),this.collectUnusedDom(t,e,o),this.createDom(t,e,o),this.cacheHeight(t,e,o);var s=this.positionDom(t,e,o);return{start:e,startPos:s.startPos,startDelta:s.startDelta,end:o,endPos:s.endPos}},Me.prototype.collectUnusedDom=function(t,e,o){for(var s,i=0;ithis.scroll.maxScrollY&&(this.scroll.maxScrollY=-(i-this.scroll.scroller.scrollBehaviorY.wrapperSize)),{end:o,startPos:s,endPos:i}},Be.prototype.destroy=function(){for(var t=this.scroll.scroller,e=t.content,o=t.scrollBehaviorY;e.firstChild;)e.removeChild(e.firstChild);this.domManager.destroy(),this.scroll.off("scroll",this.update),this.scroll.off("destroy",this.destroy),o.hooks.off(o.hooks.eventTypes.computeBoundary)},Be.pluginName="infinity",Be);function Be(t){this.scroll=t,this.start=0,this.end=0,this.init()}var Ee=(De.prototype.handleHooks=function(){var t=this;this.hooksFn=[];function e(t,e){e.options.scrollable&&0