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