/*
MiniBar 0.4.2
http://mobius.ovh/

Released under the MIT license
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(n){var h=0;return function(){return h<n.length?{done:!1,value:n[h++]}:{done:!0}}};$jscomp.arrayIterator=function(n){return{next:$jscomp.arrayIteratorImpl(n)}};$jscomp.makeIterator=function(n){var h="undefined"!=typeof Symbol&&Symbol.iterator&&n[Symbol.iterator];return h?h.call(n):$jscomp.arrayIterator(n)};
(function(n){var h=window,k=document,A=k.body,B={x:"left",y:"top"},p={x:"width",y:"height"},m={x:"scrollLeft",y:"scrollTop"},r={x:"scrollWidth",y:"scrollHeight"},C={x:"offsetWidth",y:"offsetHeight"},x={x:"pageX",y:"pageY"},v=function(a,b){for(var c=Object(a),e=1;e<a rguments.length;e++){var d=arguments[e];if(null!=d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(c[f]=d[f])}return c},d={css:function(a,b){var c=a&&a.style,e="[object Object]"===Object.prototype.toString.call(b);if(c){if(!b)return h.getComputedStyle(a);
e&&q(b,function(a,b){a in c||(a="-webkit-"+a);c[a]=b+("string"==typeof b?"":"opacity"===a?"":"px")})}},rect:function(a){a=a.getBoundingClientRect();var b=k.documentElement||A.parentNode||A,c=void 0!==h.pageXOffset?h.pageXOffset:b.scrollLeft;b=void 0!==h.pageYOffset?h.pageYOffset:b.scrollTop;return{x:a.left+c,y:a.top+b,x2:a.left+a.width+c,y2:a.top+a.height+b,height:Math.round(a.height),width:Math.round(a.width)}},classList:{contains:function(a,b){if(a)return a.classList?a.classList.contains(b):!!a.className&&
!!a.className.match(new RegExp("(\\s|^)"+b+"(\\s|$)"))},add:function(a,b){d.classList.contains(a,b)||(a.classList?a.classList.add(b):a.className=a.className.trim()+" "+b)},remove:function(a,b){d.classList.contains(a,b)&&(a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("(^|\\s)"+b.split(" ").join("|")+"(\\s|$)","gi")," "))},toggle:function(a,b,c){(c=this.contains(a,b)?!0!==c&&"remove":!1!==c&&"add")&&this[c](a,b)}},on:function(a,b,c){a.addEventListener(b,c,!1)},off:function(a,
b,c){a.removeEventListener(b,c)},isCollection:function(a){return Array.isArray(a)||a instanceof HTMLCollection||a instanceof NodeList},scrollWidth:function(){var a=0,b=k.createElement("div");return b.style.cssText="width: 100; height: 100; overflow: scroll; position: absolute; top: -9999;",k.body.appendChild(b),a=b.offsetWidth-b.clientWidth,k.body.removeChild(b),a}},q=function(a,b,c){if("[object Object]"===Object.prototype.toString.call(a))for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&
b.call(c,e,a[e]);else{e=0;for(var d=a.length;e<d;e++)b.call(c,e,a[e])}},E=function(a,b,c){var e;return function(){var d=this,f=arguments,D=c&&!e;clearTimeout(e);e=setTimeout(function(){e=null;c||a.apply(d,f)},b);D&&a.apply(d,f)}},w=h.requestAnimationFrame||function(){var a=0;return h.webkitRequestAnimationFrame||h.mozRequestAnimationFrame||function(b){var c,d=(new Date).getTime();return c=Math.max(0,16-(d-a)),a=d+c,setTimeout(function(){b(d+c)},c)}}(),t;(t=h.cancelAnimationFrame)||(clearTimeout(void 0),
t=void 0);var y=t;t=function(a,b){this.container="string"===typeof a?k.querySelector(a):a;this.config={barType:"default",minBarSize:10,alwaysShowBars:!1,horizontalMouseScroll:!1,scrollX:!0,scrollY:!0,navButtons:!1,scrollAmount:10,mutationObserver:{attributes:!1,childList:!0,subtree:!0},onInit:function(){},onUpdate:function(){},onStart:function(){},onScroll:function(){},onEnd:function(){},classes:{container:"mb-container",content:"mb-content",track:"mb-track",bar:"mb-bar",visible:"mb-visible",progress:"mb-progress",
hover:"mb-hover",scrolling:"mb-scrolling",textarea:"mb-textarea",wrapper:"mb-wrapper",nav:"mb-nav",btn:"mb-button",btns:"mb-buttons",increase:"mb-increase",decrease:"mb-decrease",item:"mb-item",itemVisible:"mb-item-visible",itemPartial:"mb-item-partial",itemHidden:"mb-item-hidden"}};b?this.config=v({},this.config,b):h.MiniBarOptions&&(this.config=v({},this.config,h.MiniBarOptions));this.css=h.getComputedStyle(this.container);this.size=d.scrollWidth();this.textarea="textarea"===this.container.nodeName.toLowerCase();
this.bars={x:{},y:{}};this.tracks={x:{},y:{}};this.lastY=this.lastX=0;this.scrollDirection={x:0,y:0};this.events={};for(var c="update scroll mouseenter mousedown mousemove mouseup wheel".split(" "),e=0;e<c.length;e++)this.events[c[e]]=this[c[e]].bind(this);this.events.debounce=E(this.events.update,50);this.init()};var l=t.prototype;l.init=function(){var a=this,b=a.config,c=a.events;if(!a.initialised){if(a.textarea)a.content=a.container,a.container=k.createElement("div"),d.classList.add(a.container,
b.classes.textarea),a.wrapper=k.createElement("div"),d.classList.add(a.wrapper,b.classes.wrapper),a.container.appendChild(a.wrapper),a.content.parentNode.insertBefore(a.container,a.content),a.content.addEventListener("input",function(b){a.update()});else for(a.content=k.createElement("div");a.container.firstChild;)a.content.appendChild(a.container.firstChild);d.classList.add(a.container,b.classes.container);d.classList.add(a.content,b.classes.content);b.alwaysShowBars&&d.classList.add(a.container,
b.classes.visible);q(a.tracks,function(e,g){a.bars[e].node=k.createElement("div");g.node=k.createElement("div");d.classList.add(g.node,b.classes.track);d.classList.add(g.node,b.classes.track+"-"+e);d.classList.add(a.bars[e].node,b.classes.bar);g.node.appendChild(a.bars[e].node);if(b.navButtons){var f=k.createElement("button"),u=k.createElement("button"),h=k.createElement("div"),z=b.scrollAmount;f.className=b.classes.btn+" "+b.classes.decrease;u.className=b.classes.btn+" "+b.classes.increase;h.className=
b.classes.btns+" "+b.classes.btns+"-"+e;h.appendChild(f);h.appendChild(g.node);h.appendChild(u);a.container.appendChild(h);d.classList.add(a.container,b.classes.nav);d.on(h,"mousedown",function(b){var c=b.target;y(a.frame);if(c===u||c===f){var d=a.content[m[e]],g=function(b){switch(a.content[m[e]]=d,c){case f:d-=z;break;case u:d+=z}a.frame=w(g)};g()}});d.on(h,"mouseup",function(b){b=b.target;var c=5*z;y(a.frame);b!==u&&b!==f||a.scrollBy(b===f?-c:c,e)})}else a.container.appendChild(g.node);"progress"===
b.barType&&d.classList.add(g.node,b.classes.progress);d.on(g.node,"mousedown",c.mousedown);d.on(g.node,"mouseenter",function(c){d.classList.add(a.container,b.classes.hover+"-"+e)});d.on(g.node,"mouseleave",function(c){a.down||d.classList.remove(a.container,b.classes.hover+"-"+e)})});a.textarea?a.wrapper.appendChild(a.content):a.container.appendChild(a.content);"static"===a.css.position&&(a.manualPosition=!0,a.container.style.position="relative");if(b.observableItems){var e=this.getItems();if(e.length&&
"IntersectionObserver"in window){a.items=e;for(var g=[],f=0;1>f;f+=.01)g.push(f);f=function(a,c){a.forEach(function(a){var c=a.target,e=a.intersectionRatio;a=a.isIntersecting;var g=!a&&0>=e,f=a&&0<e&&1>e;d.classList.toggle(c,b.classes.itemVisible,a&&1<=e);d.classList.toggle(c,b.classes.itemPartial,f);d.classList.toggle(c,b.classes.itemHidden,g)})};this.intersectionObserver=new IntersectionObserver(f,{root:null,rootMargin:"0px",threshold:g});q(e,function(b,c){a.intersectionObserver.observe(c)})}}a.update();
d.on(a.content,"scroll",c.scroll);d.on(a.container,"mouseenter",c.mouseenter);if(b.horizontalMouseScroll)d.on(a.content,"wheel",c.wheel);d.on(h,"resize",c.debounce);d.on(k,"DOMContentLoaded",c.update);d.on(h,"load",c.update);"MutationObserver"in window&&(f=function(b,c){if(a.intersectionObserver)for(var e=$jscomp.makeIterator(b),d=e.next();!d.done;d=e.next())if(d=d.value,"childList"==d.type){for(var g=$jscomp.makeIterator(d.addedNodes),f=g.next();!f.done;f=g.next())f=f.value,a.intersectionObserver.observe(f);
d=$jscomp.makeIterator(d.removedNodes);for(f=d.next();!f.done;f=d.next())f=f.value,a.intersectionObserver.unobserve(f)}a.intersectionObserver&&(a.items=a.getItems());a.update()},this.mutationObserver=new MutationObserver(f),this.mutationObserver.observe(this.content,this.config.mutationObserver));a.initialised=!0;setTimeout(function(){a.config.onInit.call(a,a.getData())},10)}};l.scroll=function(a){a=this.getData(!0);a.scrollLeft>this.lastX?this.scrollDirection.x=1:a.scrollLeft<this.lastX&&(this.scrollDirection.x=
-1);a.scrollTop>this.lastY?this.scrollDirection.y=1:a.scrollTop<this.lastY&&(this.scrollDirection.y=-1);this.updateBars();this.config.onScroll.call(this,a);this.lastX=a.scrollLeft;this.lastY=a.scrollTop};l.getItems=function(){var a=this.config,b;"string"===typeof a.observableItems&&(b=this.content.querySelectorAll(a.observableItems));if(a.observableItems instanceof HTMLCollection||a.observableItems instanceof NodeList)b=[].slice.call(a.observableItems);return b};l.getData=function(a){a=this.content;
return{scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,scrollHeight:a.scrollHeight,scrollWidth:a.scrollWidth,offsetWidth:a.offsetWidth,offsetHeight:a.offsetHeight,containerRect:this.rect,barSize:this.size}};l.scrollTo=function(a,b){b=b||"y";var c=this.getData(),d;"string"===typeof a?"start"===a?d=-c[m[b]]:"end"===a&&(d=c[r[b]]-c[C[b]]-c[m[b]]):d=a-c[m[b]];this.scrollBy(d,b)};l.scrollBy=function(a,b,c,d){b=b||"y";if(0===c)this.content[m[b]]+=a;else{void 0===c&&(c=250);d=d||function(a,b,c,d){a/=d;return-c*
a*(a-2)+b};var e=this,f=Date.now(),h=e.content[m[b]],k=function(){var g=Date.now()-f;g>c?(y(e.frame),e.content[m[b]]=Math.ceil(h+a)):(e.content[m[b]]=Math.ceil(d(g,h,a,c)),e.frame=w(k))};e.frame=k()}};l.wheel=function(a){a.preventDefault();this.scrollBy(100*a.deltaY,"x")};l.mouseenter=function(a){this.updateBars()};l.mousedown=function(a){a.preventDefault();var b=this.config,c=a.target===this["progress"===b.barType?"tracks":"bars"].x.node?"x":"y";if(d.classList.contains(a.target,"mb-track"))return c=
a.target===this.tracks.x.node?"x":"y",b=this.tracks[c],this.scrollTo((a[x[c]]-b[c])/b[p[c]]*(this.content[r[c]]-this.rect[p[c]]),c);this.down=!0;this.currentAxis=c;this.update();d.classList.add(this.container,b.classes.visible);d.classList.add(this.container,b.classes.scrolling+"-"+c);"progress"===b.barType?(this.origin={x:a.pageX-this.tracks[c].x,y:a.pageY-this.tracks[c].y},this.mousemove(a)):this.origin={x:a.pageX-this.bars[c].x,y:a.pageY-this.bars[c].y};d.on(k,"mousemove",this.events.mousemove);
d.on(k,"mouseup",this.events.mouseup)};l.mousemove=function(a){a.preventDefault();var b=this,c=this.origin,d=this.currentAxis,g=b.tracks[d],f="progress"===b.config.barType;a=(f?a[x[d]]-g[d]:a[x[d]]-c[d]-g[d])/g[p[d]];var h=f?a*(b.content[r[d]]-b.rect[p[d]]):a*b[r[d]];w(function(){b.content[m[d]]=h})};l.mouseup=function(a){var b=this.config,c=this.events;d.classList.toggle(this.container,b.classes.visible,b.alwaysShowBars);d.classList.remove(this.container,b.classes.scrolling+"-"+this.currentAxis);
d.classList.contains(a.target,b.classes.bar)||(d.classList.remove(this.container,b.classes.hover+"-x"),d.classList.remove(this.container,b.classes.hover+"-y"));this.currentAxis=null;this.down=!1;d.off(k,"mousemove",c.mousemove);d.off(k,"mouseup",c.mouseup)};l.update=function(){var a=this,b=a.config,c=a.content,e=a.size;a.rect=d.rect(a.container);a.scrollTop=c.scrollTop;a.scrollLeft=c.scrollLeft;a.scrollHeight=c.scrollHeight;a.scrollWidth=c.scrollWidth;a.offsetWidth=c.offsetWidth;a.offsetHeight=c.offsetHeight;
a.clientWidth=c.clientWidth;a.clientHeight=c.clientHeight;var g=a.scrollWidth>a.offsetWidth&&!a.textarea,f=a.scrollHeight>a.offsetHeight;d.classList.toggle(a.container,"mb-scroll-x",g&&b.scrollX&&!b.hideBars);d.classList.toggle(a.container,"mb-scroll-y",f&&b.scrollY&&!b.hideBars);d.css(c,{overflowX:g?"auto":"",overflowY:f?"auto":"",marginBottom:g?-e:"",paddingBottom:g?e:"",marginRight:f?-e:"",paddingRight:f&&!b.hideBars?e:""});a.scrollX=g;a.scrollY=f;q(a.tracks,function(b,c){v(c,d.rect(c.node));v(a.bars[b],
d.rect(a.bars[b].node))});a.updateBars();a.wrapperPadding=0;a.textarea&&(b=d.css(a.wrapper),a.wrapperPadding=parseInt(b.paddingTop,10)+parseInt(b.paddingBottom,10),!a.down&&a.content.selectionStart>=a.content.value.length&&(a.content.scrollTop=a.scrollHeight+1E3));this.config.onUpdate.call(this,this.getData())};l.updateBar=function(a){var b=this,c={},e=b.config,g=b.tracks[a][p[a]],f=b.rect[p[a]]-b.wrapperPadding,h=g/b[r[a]],k=b.content[m[a]]/(b[r[a]]-f);"progress"===e.barType?c[p[a]]=Math.floor(g*
k):(c[p[a]]=Math.max(Math.floor(h*f),e.minBarSize),c[B[a]]=Math.floor((g-c[p[a]])*k));w(function(){d.css(b.bars[a].node,c)})};l.updateBars=function(){q(this.bars,function(a,b){this.updateBar(a)},this)};l.destroy=function(){var a=this.config,b=this.container;if(this.initialised){d.off(b,"mouseenter",this.events.mouseenter);d.off(h,"resize",this.events.debounce);d.classList.remove(b,a.classes.visible);d.classList.remove(b,a.classes.container);d.classList.remove(b,a.classes.nav);for(q(this.tracks,function(c,
e){b.removeChild(a.navButtons?e.node.parentNode:e.node);d.classList.remove(b,"mb-scroll-"+c)});this.content.firstChild;)b.appendChild(this.content.firstChild);b.removeChild(this.content);this.manualPosition&&(b.style.position="");this.bars={x:{},y:{}};this.tracks={x:{},y:{}};this.content=null;this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=!1);a.observableItems&&(this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=!1),q(this.items,
function(b,e){var c=e.node||e;d.classList.remove(c,a.classes.item);d.classList.remove(c,a.classes.itemVisible);d.classList.remove(c,a.classes.itemPartial);d.classList.remove(c,a.classes.itemHidden)}));this.initialised=!1}};n.MiniBar=t})(this);