(function(d,g,h,c){var f="histogramSlider",e="plugin_"+f;var m=function(t,q,p,s,o){var r=t[0],n=t[1];d("#"+o+"-value1").html(r);d("#"+o+"-value3").html((n-1));d("#"+s+" .in-range").each(function(u,v){var w=l(p,u,q);if(w[1]<n){if(r>w[1]){b(v,0)}else{if(r<w[0]){b(v,1)}else{b(v,1-(r-w[0])/p)}}}else{if(w[0]>r){if(n>w[1]){b(v,1)}else{if(n<w[0]){b(v,0)}else{b(v,(n-w[0])/p)}}}}})};var l=function(o,q,p){var r=(o*q)+p,n=r+o;return[r,n]};var b=function(n,o){d(n).css("opacity",o)};var a=function(n){return parseInt(5*n+1)};var k=function(p,o){var q=Math.max.apply(null,p);var n=a(q);if(n>o){return o/n}return 1};var j=function(o,n){this.element=o;this.options={sliderRange:[0,1000000],optimalRange:[0,300000],selectedRange:[0,0],height:200,numberOfBins:40,showTooltips:false,showSelectedRange:false};this.init(n)};j.prototype={init:function(q){d.extend(this.options,q);var y=this,s=y.options.data.items,A=new Array(this.options.numberOfBins).fill(0),w=y.options.sliderRange[1]-y.options.sliderRange[0],C=w/this.options.numberOfBins;for(i=0;i<s.length;i++){var u=s[i].index,G=1;if(s[i].count){G=parseInt(s[i].count)}A[u]+=G}var E=y.element.attr("id")+"-histogram",F=y.element.attr("id")+"-slider";var r="<div id='"+E+"' style='height:"+y.options.height+"px; overflow: hidden;'></div><div id='"+F+"'></div>";y.element.html(r);var v=k(A,y.options.height),H=100/this.options.numberOfBins;for(i=0;i<A.length;i++){var I=l(C,i,this.options.sliderRange[0]),t="bin-color-selected",o="bin-color";if(y.options.optimalRange[0]<=I[0]&&I[0]<=y.options.optimalRange[1]){t="bin-color-optimal-selected";o="bin-color-optimal"}var z=y.options.showTooltips?"<span class='tooltiptext'>"+I[0]+" : "+A[i]+" results</span>":"";var D=parseInt(A[i]*v),x=a(D),B=parseInt(y.options.height-x),n=-parseInt(y.options.height-x*2);var p="<div class='tooltip' style='float:left!important;width:"+H+"%'>"+z+"<div class='bin in-range "+t+"' style='height:"+x+"px;bottom:-"+B+"px;position:relative'></div><div class='bin out-of-range "+o+"' style='height:"+x+"px;bottom:"+n+"px;position:relative'></div></div>";d("#"+E).append(p)}d("#"+F).slider({range:true,min:y.options.sliderRange[0],max:y.options.sliderRange[1],value:y.options.selectedRange,tooltip:"hide"}).on("slide",function(J){m(J.value,y.options.sliderRange[0],C,E,F)}).on("slideStop",function(J){m(J.value,y.options.sliderRange[0],C,E,F);update_filter(J.value[0],J.value[1])});if(y.options.showSelectedRange){d("#"+F).after("<p class='selected-range-wrapper'><span id='"+F+"-value1' class='selected-range'></span><span id='"+F+"-value2' class='selected-range-middle'> date filter </span><span id='"+F+"-value3' class='selected-range'></span></p>")}m(y.options.selectedRange,y.options.sliderRange[0],C,E,F)}};d.fn[f]=function(n){var o=this.data(e);if(o instanceof j){if(typeof n!=="undefined"){o.init(n)}}else{o=new j(this,n);this.data(e,o)}return o}}(jQuery,window,document));