!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(f){var h,m,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],t="onwheel"in document||9<=document.documentMode?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],p=Array.prototype.slice;if(f.event.fixHooks)for(var o=e.length;o;)f.event.fixHooks[e[--o]]=f.event.mouseHooks;var g=f.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var e=t.length;e;)this.addEventListener(t[--e],a,!1);else this.onmousewheel=a;f.data(this,"mousewheel-line-height",g.getLineHeight(this)),f.data(this,"mousewheel-page-height",g.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var e=t.length;e;)this.removeEventListener(t[--e],a,!1);else this.onmousewheel=null;f.removeData(this,"mousewheel-line-height"),f.removeData(this,"mousewheel-page-height")},getLineHeight:function(e){var t=f(e),o=t["offsetParent"in f.fn?"offsetParent":"parent"]();return o.length||(o=f("body")),parseInt(o.css("fontSize"),10)||parseInt(t.css("fontSize"),10)||16},getPageHeight:function(e){return f(e).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function a(e){var t,o=e||window.event,a=p.call(arguments,1),n=0,i=0,r=0,l=0,s=0;if((e=f.event.fix(o)).type="mousewheel","detail"in o&&(r=-1*o.detail),"wheelDelta"in o&&(r=o.wheelDelta),"wheelDeltaY"in o&&(r=o.wheelDeltaY),"wheelDeltaX"in o&&(i=-1*o.wheelDeltaX),"axis"in o&&o.axis===o.HORIZONTAL_AXIS&&(i=-1*r,r=0),n=0===r?i:r,"deltaY"in o&&(n=r=-1*o.deltaY),"deltaX"in o&&(i=o.deltaX,0===r&&(n=-1*i)),0!==r||0!==i){if(1===o.deltaMode){var c=f.data(this,"mousewheel-line-height");n*=c,r*=c,i*=c}else if(2===o.deltaMode){var d=f.data(this,"mousewheel-page-height");n*=d,r*=d,i*=d}if(t=Math.max(Math.abs(r),Math.abs(i)),(!m||ti[0].parent().height()?y.call(this):(J(e,r[0].toString(),{dir:"y",dur:0,overwrite:"none"}),t.contentReset.y=null):(y.call(this),"y"===o.axis?T.call(this):"yx"===o.axis&&t.overflowed[1]&&J(e,r[1].toString(),{dir:"x",dur:0,overwrite:"none"}))),"y"!==o.axis&&(t.overflowed[1]?i[1].width()>i[1].parent().width()?y.call(this):(J(e,r[1].toString(),{dir:"x",dur:0,overwrite:"none"}),t.contentReset.x=null):(y.call(this),"x"===o.axis?T.call(this):"yx"===o.axis&&t.overflowed[0]&&J(e,r[0].toString(),{dir:"y",dur:0,overwrite:"none"}))),l&&t&&(2===l&&o.callbacks.onImageLoad&&"function"==typeof o.callbacks.onImageLoad?o.callbacks.onImageLoad.call(this):3===l&&o.callbacks.onSelectorChange&&"function"==typeof o.callbacks.onSelectorChange?o.callbacks.onSelectorChange.call(this):o.callbacks.onUpdate&&"function"==typeof o.callbacks.onUpdate&&o.callbacks.onUpdate.call(this)),Z.call(this)}})},scrollTo:function(l,s){if(void 0!==l&&null!=l){var e=c.call(this);return A(e).each(function(){var e=A(this);if(e.data(H)){var t=e.data(H),o=t.opt,a={trigger:"external",scrollInertia:o.scrollInertia,scrollEasing:"mcsEaseInOut",moveDragger:!1,timeout:60,callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},n=A.extend(!0,{},a,s),i=V.call(this,l),r=0
","
"],i="yx"===o.axis?"mCSB_vertical_horizontal":"x"===o.axis?"mCSB_horizontal":"mCSB_vertical",r="yx"===o.axis?n[0]+n[1]:"x"===o.axis?n[1]:n[0],l="yx"===o.axis?"
":"",s=o.autoHideScrollbar?" "+S[6]:"",c="x"!==o.axis&&"rtl"===t.langDir?" "+S[7]:"";o.setWidth&&e.css("width",o.setWidth),o.setHeight&&e.css("height",o.setHeight),o.setLeft="y"!==o.axis&&"rtl"===t.langDir?"989999px":o.setLeft,e.addClass(h+" _"+H+"_"+t.idx+s+c).wrapInner("
");var d=A("#mCSB_"+t.idx),u=A("#mCSB_"+t.idx+"_container");"y"===o.axis||o.advanced.autoExpandHorizontalScroll||u.css("width",v(u)),"outside"===o.scrollbarPosition?("static"===e.css("position")&&e.css("position","relative"),e.css("overflow","visible"),d.addClass("mCSB_outside").after(r)):(d.addClass("mCSB_inside").append(r),u.wrap(l)),w.call(this);var f=[A("#mCSB_"+t.idx+"_dragger_vertical"),A("#mCSB_"+t.idx+"_dragger_horizontal")];f[0].css("min-height",f[0].height()),f[1].css("min-width",f[1].width())},v=function(e){var t=[e[0].scrollWidth,Math.max.apply(Math,e.children().map(function(){return A(this).outerWidth(!0)}).get())],o=e.parent().width();return oa.parent().width()?a.css({width:n,"min-width":"100%","overflow-x":"inherit"}):a.css({"overflow-x":"inherit",position:"absolute"}).wrap("
").css({width:Math.ceil(a[0].getBoundingClientRect().right+.4)-Math.floor(a[0].getBoundingClientRect().left),"min-width":"100%",position:"relative"}).unwrap()}},w=function(){var e=A(this),t=e.data(H),o=t.opt,a=A(".mCSB_"+t.idx+"_scrollbar:first"),n=ne(o.scrollButtons.tabindex)?"tabindex='"+o.scrollButtons.tabindex+"'":"",i=["","","",""],r=["x"===o.axis?i[2]:i[0],"x"===o.axis?i[3]:i[1],i[2],i[3]];o.scrollButtons.enable&&a.prepend(r[0]).append(r[1]).next(".mCSB_scrollTools").prepend(r[2]).append(r[3])},_=function(){var e=A(this),t=e.data(H),o=A("#mCSB_"+t.idx),a=A("#mCSB_"+t.idx+"_container"),n=[A("#mCSB_"+t.idx+"_dragger_vertical"),A("#mCSB_"+t.idx+"_dragger_horizontal")],i=[o.height()/a.outerHeight(!1),o.width()/a.outerWidth(!1)],r=[parseInt(n[0].css("min-height")),Math.round(i[0]*n[0].parent().height()),parseInt(n[1].css("min-width")),Math.round(i[1]*n[1].parent().width())],l=g&&r[1]o.height(),i>o.width()]},y=function(){var e=A(this),t=e.data(H),o=t.opt,a=A("#mCSB_"+t.idx),n=A("#mCSB_"+t.idx+"_container"),i=[A("#mCSB_"+t.idx+"_dragger_vertical"),A("#mCSB_"+t.idx+"_dragger_horizontal")];if(G(e),("x"!==o.axis&&!t.overflowed[0]||"y"===o.axis&&t.overflowed[0])&&(i[0].add(n).css("top",0),J(e,"_resetY")),"y"!==o.axis&&!t.overflowed[1]||"x"===o.axis&&t.overflowed[1]){var r=dx=0;"rtl"===t.langDir&&(r=a.width()-n.outerWidth(!1),dx=Math.abs(r/t.scrollRatio.x)),n.css("left",r),i[1].css("left",dx),J(e,"_resetX")}},B=function(){var t=A(this),e=t.data(H),o=e.opt;if(!e.bindEvents){var a;if(r.call(this),o.contentTouchScroll&&O.call(this),D.call(this),o.mouseWheel.enable)!function e(){a=setTimeout(function(){A.event.special.mousewheel?(clearTimeout(a),I.call(t[0])):e()},100)}();L.call(this),j.call(this),o.advanced.autoScrollOnFocus&&Y.call(this),o.scrollButtons.enable&&F.call(this),o.keyboard.enable&&q.call(this),e.bindEvents=!0}},T=function(){var e=A(this),t=e.data(H),o=t.opt,a=H+"_"+t.idx,n=".mCSB_"+t.idx+"_scrollbar",i=A("#mCSB_"+t.idx+",#mCSB_"+t.idx+"_container,#mCSB_"+t.idx+"_container_wrapper,"+n+" ."+S[12]+",#mCSB_"+t.idx+"_dragger_vertical,#mCSB_"+t.idx+"_dragger_horizontal,"+n+">a"),r=A("#mCSB_"+t.idx+"_container");o.advanced.releaseDraggableSelectors&&i.add(A(o.advanced.releaseDraggableSelectors)),o.advanced.extraDraggableSelectors&&i.add(A(o.advanced.extraDraggableSelectors)),t.bindEvents&&(A(document).add(A(!X()||top.document)).unbind("."+a),i.each(function(){A(this).unbind("."+a)}),clearTimeout(e[0]._focusTimeout),te(e[0],"_focusTimeout"),clearTimeout(t.sequential.step),te(t.sequential,"step"),clearTimeout(r[0].onCompleteTimeout),te(r[0],"onCompleteTimeout"),t.bindEvents=!1)},k=function(e){var t=A(this),o=t.data(H),a=o.opt,n=A("#mCSB_"+o.idx+"_container_wrapper"),i=n.length?n:A("#mCSB_"+o.idx+"_container"),r=[A("#mCSB_"+o.idx+"_scrollbar_vertical"),A("#mCSB_"+o.idx+"_scrollbar_horizontal")],l=[r[0].find(".mCSB_dragger"),r[1].find(".mCSB_dragger")];"x"!==a.axis&&(o.overflowed[0]&&!e?(r[0].add(l[0]).add(r[0].children("a")).css("display","block"),i.removeClass(S[8]+" "+S[10])):(a.alwaysShowScrollbar?(2!==a.alwaysShowScrollbar&&l[0].css("display","none"),i.removeClass(S[10])):(r[0].css("display","none"),i.addClass(S[10])),i.addClass(S[8]))),"y"!==a.axis&&(o.overflowed[1]&&!e?(r[1].add(l[1]).add(r[1].children("a")).css("display","block"),i.removeClass(S[9]+" "+S[11])):(a.alwaysShowScrollbar?(2!==a.alwaysShowScrollbar&&l[1].css("display","none"),i.removeClass(S[11])):(r[1].css("display","none"),i.addClass(S[11])),i.addClass(S[9]))),o.overflowed[0]||o.overflowed[1]?t.removeClass(S[5]):t.addClass(S[5])},U=function(e){var t=e.type,o=e.target.ownerDocument!==document&&null!==frameElement?[A(frameElement).offset().top,A(frameElement).offset().left]:null,a=X()&&e.target.ownerDocument!==top.document&&null!==frameElement?[A(e.view.frameElement).offset().top,A(e.view.frameElement).offset().left]:[0,0];switch(t){case"pointerdown":case"MSPointerDown":case"pointermove":case"MSPointerMove":case"pointerup":case"MSPointerUp":return o?[e.originalEvent.pageY-o[0]+a[0],e.originalEvent.pageX-o[1]+a[1],!1]:[e.originalEvent.pageY,e.originalEvent.pageX,!1];case"touchstart":case"touchmove":case"touchend":var n=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],i=e.originalEvent.touches.length||e.originalEvent.changedTouches.length;return e.target.ownerDocument!==document?[n.screenY,n.screenX,1-i*y.scrollRatio.y&&(2*E[3]-l*y.scrollRatio.x&&(2*E[2]c.height()&&d("on",40)),"y"!==r.axis&&i.overflowed[1]&&(a<0?d("on",37):a>c.width()&&d("on",39)))}}).bind("mouseup."+e+" dragend."+e,function(e){z||(n&&(n=0,d("off",null)),P=!1)})},I=function(){if(A(this).data(H)){var u=A(this),f=u.data(H),h=f.opt,e=H+"_"+f.idx,m=A("#mCSB_"+f.idx),p=[A("#mCSB_"+f.idx+"_dragger_vertical"),A("#mCSB_"+f.idx+"_dragger_horizontal")],t=A("#mCSB_"+f.idx+"_container").find("iframe");t.length&&t.each(function(){A(this).bind("load",function(){X(this)&&A(this.contentDocument||this.contentWindow.document).bind("mousewheel."+e,function(e,t){o(e,t)})})}),m.bind("mousewheel."+e,function(e,t){o(e,t)})}function o(e,t){if(G(u),!W(u,e.target)){var o="auto"!==h.mouseWheel.deltaFactor?parseInt(h.mouseWheel.deltaFactor):g&&e.deltaFactor<100?100:e.deltaFactor||100,a=h.scrollInertia;if("x"===h.axis||"x"===h.mouseWheel.axis)var n="x",i=[Math.round(o*f.scrollRatio.x),parseInt(h.mouseWheel.scrollAmount)],r="auto"!==h.mouseWheel.scrollAmount?i[1]:i[0]>=m.width()?.9*m.width():i[0],l=Math.abs(A("#mCSB_"+f.idx+"_container")[0].offsetLeft),s=p[1][0].offsetLeft,c=p[1].parent().width()-p[1].width(),d="y"===h.mouseWheel.axis?e.deltaY||t:e.deltaX;else var n="y",i=[Math.round(o*f.scrollRatio.y),parseInt(h.mouseWheel.scrollAmount)],r="auto"!==h.mouseWheel.scrollAmount?i[1]:i[0]>=m.height()?.9*m.height():i[0],l=Math.abs(A("#mCSB_"+f.idx+"_container")[0].offsetTop),s=p[0][0].offsetTop,c=p[0].parent().height()-p[0].height(),d=e.deltaY||t;"y"===n&&!f.overflowed[0]||"x"===n&&!f.overflowed[1]||((h.mouseWheel.invert||e.webkitDirectionInvertedFromDevice)&&(d=-d),h.mouseWheel.normalizeDelta&&(d=d<0?-1:1),(0o.offset().left?-1:1,i=Math.abs(c[0].offsetLeft)-n*(.9*d.width())}else{if(!s.overflowed[0])return;var a="y",n=e.pageY>o.offset().top?-1:1,i=Math.abs(c[0].offsetTop)-n*(.9*d.height())}J(l,i.toString(),{dir:a,scrollEasing:"mcsEaseInOut"})}})},Y=function(){var i=A(this),e=i.data(H),r=e.opt,t=H+"_"+e.idx,l=A("#mCSB_"+e.idx+"_container"),s=l.parent();l.bind("focusin."+t,function(e){var n=A(document.activeElement),t=l.find(".mCustomScrollBox").length;n.is(r.advanced.autoScrollOnFocus)&&(G(i),clearTimeout(i[0]._focusTimeout),i[0]._focusTimer=t?17*t:0,i[0]._focusTimeout=setTimeout(function(){var e=[ie(n)[0],ie(n)[1]],t=[l[0].offsetTop,l[0].offsetLeft],o=[0<=t[0]+e[0]&&t[0]+e[0]a");o.bind("contextmenu."+e,function(e){e.preventDefault()}).bind("mousedown."+e+" touchstart."+e+" pointerdown."+e+" MSPointerDown."+e+" mouseup."+e+" touchend."+e+" pointerup."+e+" MSPointerUp."+e+" mouseout."+e+" pointerout."+e+" MSPointerOut."+e+" click."+e,function(e){if(e.preventDefault(),oe(e)){var t=A(this).attr("class");switch(r.type=i.scrollButtons.scrollType,e.type){case"mousedown":case"touchstart":case"pointerdown":case"MSPointerDown":if("stepped"===r.type)return;P=!0,n.tweenRunning=!1,o("on",t);break;case"mouseup":case"touchend":case"pointerup":case"MSPointerUp":case"mouseout":case"pointerout":case"MSPointerOut":if("stepped"===r.type)return;P=!1,r.dir&&o("off",t);break;case"click":if("stepped"!==r.type||n.tweenRunning)return;o("on",t)}}function o(e,t){r.scrollAmount=i.scrollButtons.scrollAmount,N(a,e,t)}})},q=function(){var l=A(this),s=l.data(H),c=s.opt,d=s.sequential,e=H+"_"+s.idx,t=A("#mCSB_"+s.idx),u=A("#mCSB_"+s.idx+"_container"),f=u.parent(),h="input,textarea,select,datalist,keygen,[contenteditable='true']",o=u.find("iframe"),a=["blur."+e+" keydown."+e+" keyup."+e];function n(e){switch(e.type){case"blur":s.tweenRunning&&d.dir&&r("off",null);break;case"keydown":case"keyup":var t=e.keyCode?e.keyCode:e.which,o="on";if("x"!==c.axis&&(38===t||40===t)||"y"!==c.axis&&(37===t||39===t)){if((38===t||40===t)&&!s.overflowed[0]||(37===t||39===t)&&!s.overflowed[1])return;"keyup"===e.type&&(o="off"),A(document.activeElement).is(h)||(e.preventDefault(),e.stopImmediatePropagation(),r(o,t))}else if(33===t||34===t){if((s.overflowed[0]||s.overflowed[1])&&(e.preventDefault(),e.stopImmediatePropagation()),"keyup"===e.type){G(l);var a=34===t?-1:1;if("x"===c.axis||"yx"===c.axis&&s.overflowed[1]&&!s.overflowed[0])var n="x",i=Math.abs(u[0].offsetLeft)-a*(.9*f.width());else var n="y",i=Math.abs(u[0].offsetTop)-a*(.9*f.height());J(l,i.toString(),{dir:n,scrollEasing:"mcsEaseInOut"})}}else if((35===t||36===t)&&!A(document.activeElement).is(h)&&((s.overflowed[0]||s.overflowed[1])&&(e.preventDefault(),e.stopImmediatePropagation()),"keyup"===e.type)){if("x"===c.axis||"yx"===c.axis&&s.overflowed[1]&&!s.overflowed[0])var n="x",i=35===t?Math.abs(f.width()-u.outerWidth(!1)):0;else var n="y",i=35===t?Math.abs(f.height()-u.outerHeight(!1)):0;J(l,i.toString(),{dir:n,scrollEasing:"mcsEaseInOut"})}}function r(e,t){d.type=c.keyboard.scrollType,d.scrollAmount=c.keyboard.scrollAmount,"stepped"===d.type&&s.tweenRunning||N(l,e,t)}}o.length&&o.each(function(){A(this).bind("load",function(){X(this)&&A(this.contentDocument||this.contentWindow.document).bind(a[0],function(e){n(e)})})}),t.attr("tabindex","0").bind(a[0],function(e){n(e)})},N=function(u,e,t,f,h){var m=u.data(H),p=m.opt,g=m.sequential,v=A("#mCSB_"+m.idx+"_container"),o="stepped"===g.type,x=p.scrollInertia<26?26:p.scrollInertia,w=p.scrollInertia<1?17:p.scrollInertia;switch(e){case"on":if(g.dir=[t===S[16]||t===S[15]||39===t||37===t?"x":"y",t===S[13]||t===S[15]||38===t||37===t?-1:1],G(u),ne(t)&&"stepped"===g.type)return;_(o);break;case"off":clearTimeout(g.step),te(g,"step"),G(u),(o||m.tweenRunning&&g.dir)&&_(!0)}function _(e){p.snapAmount&&(g.scrollAmount=p.snapAmount instanceof Array?"x"===g.dir[0]?p.snapAmount[1]:p.snapAmount[0]:p.snapAmount);var t="stepped"!==g.type,o=h||(e?t?x/1.5:w:1e3/60),a=e?t?7.5:40:2.5,n=[Math.abs(v[0].offsetTop),Math.abs(v[0].offsetLeft)],i=[10=w[1]?_=[w[0],w[1]]:_[0]=-_[0],n[0].mcs||(T(),B("onInit")&&o.callbacks.onInit.call(n[0])),clearTimeout(s[0].onCompleteTimeout),K(g[0],v,Math.round(_[1]),r[1],i.scrollEasing),!t.tweenRunning&&(0===x&&0<=_[0]||x===w[0]&&_[0]<=w[0])||K(s[0],v,Math.round(_[0]),r[0],i.scrollEasing,i.overwrite,{onStart:function(){i.callbacks&&i.onStart&&!t.tweenRunning&&(B("onScrollStart")&&(T(),o.callbacks.onScrollStart.call(n[0])),t.tweenRunning=!0,M(g),t.cbOffsets=[o.callbacks.alwaysTriggerOffsets||x>=w[0]+S,o.callbacks.alwaysTriggerOffsets||x<=-b])},onUpdate:function(){i.callbacks&&i.onUpdate&&B("whileScrolling")&&(T(),o.callbacks.whileScrolling.call(n[0]))},onComplete:function(){if(i.callbacks&&i.onComplete){"yx"===o.axis&&clearTimeout(s[0].onCompleteTimeout);var e=s[0].idleTimer||0;s[0].onCompleteTimeout=setTimeout(function(){B("onScroll")&&(T(),o.callbacks.onScroll.call(n[0])),B("onTotalScroll")&&_[1]>=w[1]-C&&t.cbOffsets[0]&&(T(),o.callbacks.onTotalScroll.call(n[0])),B("onTotalScrollBack")&&_[1]<=y&&t.cbOffsets[1]&&(T(),o.callbacks.onTotalScrollBack.call(n[0])),t.tweenRunning=!1,s[0].idleTimer=0,M(g,"hide")},e)}}})}function B(e){return t&&o.callbacks[e]&&"function"==typeof o.callbacks[e]}function T(){var e=[s[0].offsetTop,s[0].offsetLeft],t=[g[0].offsetTop,g[0].offsetLeft],o=[s.outerHeight(!1),s.outerWidth(!1)],a=[l.height(),l.width()];n[0].mcs={content:s,top:e[0],left:e[1],draggerTop:t[0],draggerLeft:t[1],topPct:Math.round(100*Math.abs(e[0])/(Math.abs(o[0])-a[0])),leftPct:Math.round(100*Math.abs(e[1])/(Math.abs(o[1])-a[1])),direction:i.dir}}},K=function(e,t,o,a,n,i,r){e._mTween||(e._mTween={top:{},left:{}});var l,s,r=r||{},c=r.onStart||function(){},d=r.onUpdate||function(){},u=r.onComplete||function(){},f=$(),h=0,m=e.offsetTop,p=e.style,g=e._mTween[t];"left"===t&&(m=e.offsetLeft);var v=o-m;function x(){g.stop||(h||c.call(),h=$()-f,w(),h>=g.time&&(g.time=h>g.time?h+l-(h-g.time):h+l-1,g.time