(function(n,t){typeof define=="function"&&define.amd?define(["jquery"],function(n){return t(n)}):typeof module=="object"&&module.exports?module.exports=t(require("jquery")):t(n.jQuery)})(this,function(n){(function(n){"use strict";function e(t){return n.each([{re:/[\xC0-\xC6]/g,ch:"A"},{re:/[\xE0-\xE6]/g,ch:"a"},{re:/[\xC8-\xCB]/g,ch:"E"},{re:/[\xE8-\xEB]/g,ch:"e"},{re:/[\xCC-\xCF]/g,ch:"I"},{re:/[\xEC-\xEF]/g,ch:"i"},{re:/[\xD2-\xD6]/g,ch:"O"},{re:/[\xF2-\xF6]/g,ch:"o"},{re:/[\xD9-\xDC]/g,ch:"U"},{re:/[\xF9-\xFC]/g,ch:"u"},{re:/[\xC7-\xE7]/g,ch:"c"},{re:/[\xD1]/g,ch:"N"},{re:/[\xF1]/g,ch:"n"}],function(){t=t?t.replace(this.re,this.ch):""}),t}function s(i){var f=arguments,r=i,u,e;return[].shift.apply(f),e=this.each(function(){var o=n(this),i,e,h,s;if(o.is("select")){if(i=o.data("selectpicker"),e=typeof r=="object"&&r,i){if(e)for(s in e)e.hasOwnProperty(s)&&(i.options[s]=e[s])}else h=n.extend({},t.DEFAULTS,n.fn.selectpicker.defaults||{},o.data(),e),h.template=n.extend({},t.DEFAULTS.template,n.fn.selectpicker.defaults?n.fn.selectpicker.defaults.template:{},o.data().template,e.template),o.data("selectpicker",i=new t(this,h));typeof r=="string"&&(u=i[r]instanceof Function?i[r].apply(i,f):i.options[r])}}),typeof u!="undefined"?u:e}var i,u,f,h;String.prototype.includes||function(){var i={}.toString,n=function(){try{var n={},t=Object.defineProperty,i=t(n,n,n)&&t}catch(r){}return i}(),r="".indexOf,t=function(n){var u,s;if(this==null)throw new TypeError;if(u=String(this),n&&i.call(n)=="[object RegExp]")throw new TypeError;var f=u.length,e=String(n),h=e.length,o=arguments.length>1?arguments[1]:undefined,t=o?Number(o):0;return(t!=t&&(t=0),s=Math.min(Math.max(t,0),f),h+s>f)?!1:r.call(u,e,t)!=-1};n?n(String.prototype,"includes",{value:t,configurable:!0,writable:!0}):String.prototype.includes=t}();String.prototype.startsWith||function(){var n=function(){try{var n={},t=Object.defineProperty,i=t(n,n,n)&&t}catch(r){}return i}(),i={}.toString,t=function(n){var u,f,r;if(this==null)throw new TypeError;if(u=String(this),n&&i.call(n)=="[object RegExp]")throw new TypeError;var e=u.length,o=String(n),s=o.length,h=arguments.length>1?arguments[1]:undefined,t=h?Number(h):0;if(t!=t&&(t=0),f=Math.min(Math.max(t,0),e),s+f>e)return!1;for(r=-1;++r<s;)if(u.charCodeAt(f+r)!=o.charCodeAt(r))return!1;return!0};n?n(String.prototype,"startsWith",{value:t,configurable:!0,writable:!0}):String.prototype.startsWith=t}();Object.keys||(Object.keys=function(n,t,i){i=[];for(t in n)i.hasOwnProperty.call(n,t)&&i.push(t);return i});i={useDefault:!1,_set:n.valHooks.select.set};n.valHooks.select.set=function(t,r){return r&&!i.useDefault&&n(t).data("selected",!0),i._set.apply(this,arguments)};u=null;f=function(){try{return new Event("change"),!0}catch(n){return!1}}();n.fn.triggerNative=function(n){var i=this[0],t;i.dispatchEvent?(f?t=new Event(n,{bubbles:!0}):(t=document.createEvent("Event"),t.initEvent(n,!0,!1)),i.dispatchEvent(t)):i.fireEvent?(t=document.createEventObject(),t.eventType=n,i.fireEvent("on"+n,t)):this.trigger(n)};n.expr.pseudos.icontains=function(t,i,r){var u=n(t).find("a"),f=(u.data("tokens")||u.text()).toString().toUpperCase();return f.includes(r[3].toUpperCase())};n.expr.pseudos.ibegins=function(t,i,r){var u=n(t).find("a"),f=(u.data("tokens")||u.text()).toString().toUpperCase();return f.startsWith(r[3].toUpperCase())};n.expr.pseudos.aicontains=function(t,i,r){var u=n(t).find("a"),f=(u.data("tokens")||u.data("normalizedText")||u.text()).toString().toUpperCase();return f.includes(r[3].toUpperCase())};n.expr.pseudos.aibegins=function(t,i,r){var u=n(t).find("a"),f=(u.data("tokens")||u.data("normalizedText")||u.text()).toString().toUpperCase();return f.startsWith(r[3].toUpperCase())};var o=function(n){var i=function(t){return n[t]},t="(?:"+Object.keys(n).join("|")+")",r=RegExp(t),u=RegExp(t,"g");return function(n){return n=n==null?"":""+n,r.test(n)?n.replace(u,i):n}},r=o({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"}),c=o({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`"}),t=function(r,u){i.useDefault||(n.valHooks.select.set=i._set,i.useDefault=!0);this.$element=n(r);this.$newElement=null;this.$button=null;this.$menu=null;this.$lis=null;this.options=u;this.options.title===null&&(this.options.title=this.$element.attr("title"));var f=this.options.windowPadding;typeof f=="number"&&(this.options.windowPadding=[f,f,f,f]);this.val=t.prototype.val;this.render=t.prototype.render;this.refresh=t.prototype.refresh;this.setStyle=t.prototype.setStyle;this.selectAll=t.prototype.selectAll;this.deselectAll=t.prototype.deselectAll;this.destroy=t.prototype.destroy;this.remove=t.prototype.remove;this.show=t.prototype.show;this.hide=t.prototype.hide;this.init()};t.VERSION="1.12.4";t.DEFAULTS={noneSelectedText:resources.NoneSelected,noneResultsText:"No results matched {0}",countSelectedText:function(n){return n==1?resources.ItemSelectedFormat:resources.ItemsSelectedFormat},maxOptionsText:function(n,t){return[n==1?"Limit reached ({n} item max)":"Limit reached ({n} items max)",t==1?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)"]},selectAllText:resources.SelectAll,deselectAllText:resources.DeselectAll,doneButton:!1,doneButtonText:"Close",multipleSeparator:", ",styleBase:"btn",style:"btn-default",size:"auto",title:null,selectedTextFormat:"values",width:!1,container:!1,hideDisabled:!1,showSubtext:!1,showIcon:!0,showContent:!0,dropupAuto:!0,header:!1,liveSearch:!1,liveSearchPlaceholder:null,liveSearchNormalize:!1,liveSearchStyle:"contains",actionsBox:!1,iconBase:"glyphicon",tickIcon:"glyphicon-ok",showTick:!1,template:{caret:'<span class="caret"><\/span>'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0};t.prototype={constructor:t,init:function(){var t=this,i=this.$element.attr("id");this.$element.addClass("bs-select-hidden");this.liObj={};this.multiple=this.$element.prop("multiple");this.autofocus=this.$element.prop("autofocus");this.$newElement=this.createView(i);this.$element.after(this.$newElement).appendTo(this.$newElement);this.$button=this.$newElement.children("button");this.$menu=this.$newElement.children(".dropdown-menu");this.$menuInner=this.$menu.children(".inner");this.$searchbox=this.$menu.find("input");this.$element.removeClass("bs-select-hidden");this.options.dropdownAlignRight===!0&&this.$menu.addClass("dropdown-menu-right");typeof i!="undefined"&&(this.$button.attr("data-id",i),n('label[for="'+i+'"]').click(function(n){n.preventDefault();t.$button.focus()}));this.checkDisabled();this.clickListener();this.options.liveSearch&&this.liveSearchListener();this.render();this.setStyle();this.setWidth();this.options.container&&this.selectPosition();this.$menu.data("this",this);this.$newElement.data("this",this);this.options.mobile&&this.mobile();this.$newElement.on({"hide.bs.dropdown":function(n){t.$menuInner.attr("aria-expanded",!1);t.$element.trigger("hide.bs.select",n)},"hidden.bs.dropdown":function(n){t.$element.trigger("hidden.bs.select",n)},"show.bs.dropdown":function(n){t.$menuInner.attr("aria-expanded",!0);t.$element.trigger("show.bs.select",n)},"shown.bs.dropdown":function(n){t.$element.trigger("shown.bs.select",n)}});if(t.$element[0].hasAttribute("required"))this.$element.on("invalid",function(){t.$button.addClass("bs-invalid");t.$element.on({"focus.bs.select":function(){t.$button.focus();t.$element.off("focus.bs.select")},"shown.bs.select":function(){t.$element.val(t.$element.val()).off("shown.bs.select")},"rendered.bs.select":function(){this.validity.valid&&t.$button.removeClass("bs-invalid");t.$element.off("rendered.bs.select")}});t.$button.on("blur.bs.select",function(){t.$element.focus().blur();t.$button.off("blur.bs.select")})});setTimeout(function(){t.$element.trigger("loaded.bs.select")})},createDropdown:function(t){var i=this.multiple||this.options.showTick?" show-tick":"",u=this.$element.parent().hasClass("input-group")?" input-group-btn":"",f=this.autofocus?" autofocus":"",e=this.options.header?'<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;<\/button>'+this.options.header+"<\/div>":"",o=this.options.liveSearch?'<div class="bs-searchbox"><input type="text" class="form-control" autocomplete="off"'+(null===this.options.liveSearchPlaceholder?"":' placeholder="'+r(this.options.liveSearchPlaceholder)+'"')+' role="textbox" aria-label="Search"><\/div>':"",s=this.multiple&&this.options.actionsBox?'<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button type="button" class="actions-btn bs-select-all btn btn-default" title="'+this.options.selectAllText+'">'+this.options.selectAllText+'<\/button><button type="button" class="actions-btn bs-deselect-all btn btn-default" title="'+this.options.deselectAllText+'">'+this.options.deselectAllText+"<\/button><\/div><\/div>":"",h=this.multiple&&this.options.doneButton?'<div class="bs-donebutton"><div class="btn-group btn-block"><button type="button" class="btn btn-sm btn-default">'+this.options.doneButtonText+"<\/button><\/div><\/div>":"",c='<div class="btn-group bootstrap-select'+i+u+'"><button type="button" class="'+this.options.styleBase+' dropdown-toggle" data-toggle="dropdown"'+f+' role="button" aria-labelledby="'+this.$element.attr("aria-labelledby")+'"><span class="filter-option pull-left"><\/span>&nbsp;<span class="bs-caret">'+this.options.template.caret+'<\/span><\/button><div class="dropdown-menu open" role="combobox'+(t!=null?'"id="'+t+"-Combobox":"")+'">'+e+o+s+'<ul class="dropdown-menu inner" role="listbox" aria-expanded="false"><\/ul>'+h+"<\/div><\/div>";return n(c)},createView:function(n){var t=this.createDropdown(n),i=this.createLi();return t.find("ul")[0].innerHTML=i,t},reloadLi:function(){var n=this.createLi();this.$menuInner[0].innerHTML=n},createLi:function(){var t=this,i=[],o=0,s=document.createElement("option"),u=-1,f=function(n,t,i,r){return"<li"+(typeof i!="undefined"&&""!==i?' class="'+i+'"':"")+(typeof t!="undefined"&&null!==t?' data-original-index="'+t+'"':"")+(typeof r!="undefined"&&null!==r?'data-optgroup="'+r+'"':"")+">"+n+"<\/li>"},c=function(i,u,f,o){return'<a tabindex="0"'+(typeof u!="undefined"?' class="'+u+'"':"")+(f?' style="'+f+'"':"")+(t.options.liveSearchNormalize?' data-normalized-text="'+e(r(n(i).html()))+'"':"")+(typeof o!="undefined"||o!==null?' data-tokens="'+o+'"':"")+' role="option">'+i+'<span class="'+t.options.iconBase+" "+t.options.tickIcon+' check-mark"><\/span><\/a>'},h,a,l;return this.options.title&&!this.multiple&&(u--,this.$element.find(".bs-title-option").length||(h=this.$element[0],s.className="bs-title-option",s.innerHTML=this.options.title,s.value="",h.insertBefore(s,h.firstChild),a=n(h.options[h.selectedIndex]),a.attr("selected")===undefined&&this.$element.data("selected")===undefined&&(s.selected=!0))),l=this.$element.find("option"),l.each(function(e){var s=n(this),tt,it,w,b;if(u++,!s.hasClass("bs-title-option")){var k=this.className||"",d=r(this.style.cssText),v=s.data("content")?s.data("content"):s.html(),g=s.data("tokens")?s.data("tokens"):null,ft=typeof s.data("subtext")!="undefined"?'<small class="text-muted">'+s.data("subtext")+"<\/small>":"",y=typeof s.data("icon")!="undefined"?'<span class="'+t.options.iconBase+" "+s.data("icon")+'"><\/span> ':"",h=s.parent(),nt=h[0].tagName==="OPTGROUP",ut=nt&&h[0].disabled,p=this.disabled||ut,a;if(y!==""&&p&&(y="<span>"+y+"<\/span>"),t.options.hideDisabled&&(p&&!nt||ut)){a=s.data("prevHiddenIndex");s.next().data("prevHiddenIndex",a!==undefined?a:e);u--;return}if(s.data("content")||(v=y+'<span class="text" title="'+v.trim()+'">'+v+ft+"<\/span>"),nt&&s.data("divider")!==!0){if(t.options.hideDisabled&&p&&(h.data("allOptionsDisabled")===undefined&&(tt=h.children(),h.data("allOptionsDisabled",tt.filter(":disabled").length===tt.length)),h.data("allOptionsDisabled"))){u--;return}if(it=" "+h[0].className||"",s.index()===0){o+=1;var rt=h[0].label,et=typeof h.data("subtext")!="undefined"?'<small class="text-muted">'+h.data("subtext")+"<\/small>":"",ot=h.data("icon")?'<span class="'+t.options.iconBase+" "+h.data("icon")+'"><\/span> ':"";rt=ot+'<span class="text">'+r(rt)+et+"<\/span>";e!==0&&i.length>0&&(u++,i.push(f("",null,"divider",o+"div")));u++;i.push(f(rt,null,"dropdown-header"+it,o))}if(t.options.hideDisabled&&p){u--;return}i.push(f(c(v,"opt "+k+it,d,g),e,"",o))}else s.data("divider")===!0?i.push(f("",e,"divider")):s.data("hidden")===!0?(a=s.data("prevHiddenIndex"),s.next().data("prevHiddenIndex",a!==undefined?a:e),i.push(f(c(v,k,d,g),e,"hidden is-hidden"))):(w=this.previousElementSibling&&this.previousElementSibling.tagName==="OPTGROUP",!w&&t.options.hideDisabled&&(a=s.data("prevHiddenIndex"),a!==undefined&&(b=l.eq(a)[0].previousElementSibling,b&&b.tagName==="OPTGROUP"&&!b.disabled&&(w=!0))),w&&(u++,i.push(f("",null,"divider",o+"div"))),i.push(f(c(v,k,d,g),e)));t.liObj[e]=u}}),this.multiple||this.$element.find("option:selected").length!==0||this.options.title||this.$element.find("option").eq(0).prop("selected",!0).attr("selected","selected"),i.join("")},findLis:function(){return this.$lis==null&&(this.$lis=this.$menu.find("li")),this.$lis},render:function(t){var i=this,s,e=this.$element.find("option"),r,u,f,o,h;t!==!1&&e.each(function(n){var t=i.findLis().eq(i.liObj[n]);i.setDisabled(n,this.disabled||this.parentNode.tagName==="OPTGROUP"&&this.parentNode.disabled,t);i.setSelected(n,this.selected,t)});this.togglePlaceholder();this.tabIndex();r=e.map(function(){if(this.selected){if(i.options.hideDisabled&&(this.disabled||this.parentNode.tagName==="OPTGROUP"&&this.parentNode.disabled))return;var t=n(this),u=t.data("icon")&&i.options.showIcon?'<i class="'+i.options.iconBase+" "+t.data("icon")+'"><\/i> ':"",r;return r=i.options.showSubtext&&t.data("subtext")&&!i.multiple?' <small class="text-muted">'+t.data("subtext")+"<\/small>":"",typeof t.attr("title")!="undefined"?t.attr("title"):t.data("content")&&i.options.showContent?t.data("content").toString():u+t.html()+r}}).toArray();u=this.multiple?r.join(this.options.multipleSeparator):r[0];this.multiple&&this.options.selectedTextFormat.indexOf("count")>-1&&(f=this.options.selectedTextFormat.split(">"),(f.length>1&&r.length>f[1]||f.length==1&&r.length>=2)&&(s=this.options.hideDisabled?", [disabled]":"",o=e.not('[data-divider="true"], [data-hidden="true"]'+s).length,h=typeof this.options.countSelectedText=="function"?this.options.countSelectedText(r.length,o):this.options.countSelectedText,u=h.replace("{0}",r.length.toString()).replace("{1}",o.toString())));this.options.title==undefined&&(this.options.title=this.$element.attr("title"));this.options.selectedTextFormat=="static"&&(u=this.options.title);u||(u=typeof this.options.title!="undefined"?this.options.title:this.options.noneSelectedText);this.$button.attr("title",c(n.trim(u.replace(/<[^>]*>?/g,"").replace(/\s+/g," "))));this.$button.children(".filter-option").html(u);this.$element.trigger("rendered.bs.select")},setStyle:function(n,t){this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,""));var i=n?n:this.options.style;t=="add"?this.$button.addClass(i):t=="remove"?this.$button.removeClass(i):(this.$button.removeClass(this.options.style),this.$button.addClass(i))},liHeight:function(t){var y;if(t||this.options.size!==!1&&!this.sizeInfo){var e=document.createElement("div"),u=document.createElement("div"),o=document.createElement("ul"),l=document.createElement("li"),w=document.createElement("li"),a=document.createElement("a"),v=document.createElement("span"),s=this.options.header&&this.$menu.find(".popover-title").length>0?this.$menu.find(".popover-title")[0].cloneNode(!0):null,f=this.options.liveSearch?document.createElement("div"):null,h=this.options.actionsBox&&this.multiple&&this.$menu.find(".bs-actionsbox").length>0?this.$menu.find(".bs-actionsbox")[0].cloneNode(!0):null,c=this.options.doneButton&&this.multiple&&this.$menu.find(".bs-donebutton").length>0?this.$menu.find(".bs-donebutton")[0].cloneNode(!0):null;v.className="text";e.className=this.$menu[0].parentNode.className+" open";u.className="dropdown-menu open";o.className="dropdown-menu inner";l.className="divider";v.appendChild(document.createTextNode("Inner text"));a.appendChild(v);w.appendChild(a);o.appendChild(w);o.appendChild(l);s&&u.appendChild(s);f&&(y=document.createElement("input"),f.className="bs-searchbox",y.className="form-control",f.appendChild(y),u.appendChild(f));h&&u.appendChild(h);u.appendChild(o);c&&u.appendChild(c);e.appendChild(u);document.body.appendChild(e);var b=a.offsetHeight,k=s?s.offsetHeight:0,d=f?f.offsetHeight:0,g=h?h.offsetHeight:0,nt=c?c.offsetHeight:0,tt=n(l).outerHeight(!0),i=typeof getComputedStyle=="function"?getComputedStyle(u):!1,r=i?null:n(u),p={vert:parseInt(i?i.paddingTop:r.css("paddingTop"))+parseInt(i?i.paddingBottom:r.css("paddingBottom"))+parseInt(i?i.borderTopWidth:r.css("borderTopWidth"))+parseInt(i?i.borderBottomWidth:r.css("borderBottomWidth")),horiz:parseInt(i?i.paddingLeft:r.css("paddingLeft"))+parseInt(i?i.paddingRight:r.css("paddingRight"))+parseInt(i?i.borderLeftWidth:r.css("borderLeftWidth"))+parseInt(i?i.borderRightWidth:r.css("borderRightWidth"))},it={vert:p.vert+parseInt(i?i.marginTop:r.css("marginTop"))+parseInt(i?i.marginBottom:r.css("marginBottom"))+2,horiz:p.horiz+parseInt(i?i.marginLeft:r.css("marginLeft"))+parseInt(i?i.marginRight:r.css("marginRight"))+2};document.body.removeChild(e);this.sizeInfo={liHeight:b,headerHeight:k,searchHeight:d,actionsHeight:g,doneButtonHeight:nt,dividerHeight:tt,menuPadding:p,menuExtras:it}}},setSize:function(){var l,rt,ut;if(this.findLis(),this.liHeight(),this.options.header&&this.$menu.css("padding-top",0),this.options.size!==!1){var i=this,t=this.$menu,k=this.$menuInner,o=n(window),ft=this.$newElement[0].offsetHeight,d=this.$newElement[0].offsetWidth,g=this.sizeInfo.liHeight,a=this.sizeInfo.headerHeight,v=this.sizeInfo.searchHeight,y=this.sizeInfo.actionsHeight,p=this.sizeInfo.doneButtonHeight,et=this.sizeInfo.dividerHeight,s=this.sizeInfo.menuPadding,u=this.sizeInfo.menuExtras,nt=this.options.hideDisabled?".disabled":"",r,tt,f,w,e,h,c,b,it=function(){var f=i.$newElement.offset(),u=n(i.options.container),t,r;i.options.container&&!u.is("body")?(t=u.offset(),t.top+=parseInt(u.css("borderTopWidth")),t.left+=parseInt(u.css("borderLeftWidth"))):t={top:0,left:0};r=i.options.windowPadding;e=f.top-t.top-o.scrollTop();h=o.height()-e-ft-t.top-r[2];c=f.left-t.left-o.scrollLeft();b=o.width()-c-d-t.left-r[1];e-=r[0];c-=r[3]};if(it(),this.options.size==="auto"){l=function(){var o,nt=function(t,i){return function(r){return i?r.classList?r.classList.contains(t):n(r).hasClass(t):!(r.classList?r.classList.contains(t):n(r).hasClass(t))}},rt=i.$menuInner[0].getElementsByTagName("li"),l=Array.prototype.filter?Array.prototype.filter.call(rt,nt("hidden",!1)):i.$lis.not(".hidden"),ut=Array.prototype.filter?Array.prototype.filter.call(l,nt("dropdown-header",!0)):l.filter(".dropdown-header");it();r=h-u.vert;tt=b-u.horiz;i.options.container?(t.data("height")||t.data("height",t.height()),f=t.data("height"),t.data("width")||t.data("width",t.width()),w=t.data("width")):(f=t.height(),w=t.width());i.options.dropupAuto&&i.$newElement.toggleClass("dropup",e>h&&r-u.vert<f);i.$newElement.hasClass("dropup")&&(r=e-u.vert);i.options.dropdownAlignRight==="auto"&&t.toggleClass("dropdown-menu-right",c>b&&tt-u.horiz<w-d);o=l.length+ut.length>3?g*3+u.vert-2:0;t.css({"max-height":r+"px",overflow:"hidden","min-height":o+a+v+y+p+"px"});k.css({"max-height":r-a-v-y-p-s.vert+"px","overflow-y":"auto","min-height":Math.max(o-s.vert,0)+"px"})};l();this.$searchbox.off("input.getSize propertychange.getSize").on("input.getSize propertychange.getSize",l);o.off("resize.getSize scroll.getSize").on("resize.getSize scroll.getSize",l)}else this.options.size&&this.options.size!="auto"&&this.$lis.not(nt).length>this.options.size&&(rt=this.$lis.not(".divider").not(nt).children().slice(0,this.options.size).last().parent().index(),ut=this.$lis.slice(0,rt+1).filter(".divider").length,r=g*this.options.size+ut*et+s.vert,i.options.container?(t.data("height")||t.data("height",t.height()),f=t.data("height")):f=t.height(),i.options.dropupAuto&&this.$newElement.toggleClass("dropup",e>h&&r-u.vert<f),t.css({"max-height":r+a+v+y+p+"px",overflow:"hidden","min-height":""}),k.css({"max-height":r-s.vert+"px","overflow-y":"auto","min-height":""}))}},setWidth:function(){if(this.options.width==="auto"){this.$menu.css("min-width","0");var n=this.$menu.parent().clone().appendTo("body"),t=this.options.container?this.$newElement.clone().appendTo("body"):n,i=n.children(".dropdown-menu").outerWidth(),r=t.css("width","auto").children("button").outerWidth();n.remove();t.remove();this.$newElement.css("width",Math.max(i,r)+"px")}else this.options.width==="fit"?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""),this.$newElement.css("width",""));this.$newElement.hasClass("fit-width")&&this.options.width!=="fit"&&this.$newElement.removeClass("fit-width")},selectPosition:function(){this.$bsContainer=n('<div class="bs-container" />');var t=this,i=n(this.options.container),u,r,f,e=function(n){t.$bsContainer.addClass(n.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass("dropup",n.hasClass("dropup"));u=n.offset();i.is("body")?r={top:0,left:0}:(r=i.offset(),r.top+=parseInt(i.css("borderTopWidth"))-i.scrollTop(),r.left+=parseInt(i.css("borderLeftWidth"))-i.scrollLeft());f=n.hasClass("dropup")?0:n[0].offsetHeight;t.$bsContainer.css({top:u.top-r.top+f,left:u.left-r.left,width:n[0].offsetWidth})};this.$button.on("click",function(){var i=n(this);t.isDisabled()||(e(t.$newElement),t.$bsContainer.appendTo(t.options.container).toggleClass("open",!i.hasClass("open")).append(t.$menu))});n(window).on("resize scroll",function(){e(t.$newElement)});this.$element.on("hide.bs.select",function(){t.$menu.data("height",t.$menu.height());t.$bsContainer.detach()})},setSelected:function(n,t,i){i||(this.togglePlaceholder(),i=this.findLis().eq(this.liObj[n]));i.toggleClass("selected",t).find("a").attr("aria-selected",t)},setDisabled:function(n,t,i){i||(i=this.findLis().eq(this.liObj[n]));t?i.addClass("disabled").children("a").attr("href","#").attr("tabindex",-1).attr("aria-disabled",!0):i.removeClass("disabled").children("a").removeAttr("href").attr("tabindex",0).attr("aria-disabled",!1)},isDisabled:function(){return this.$element[0].disabled},checkDisabled:function(){var n=this;this.isDisabled()?(this.$newElement.addClass("disabled"),this.$button.addClass("disabled").attr("tabindex",-1).attr("aria-disabled",!0)):(this.$button.hasClass("disabled")&&(this.$newElement.removeClass("disabled"),this.$button.removeClass("disabled").attr("aria-disabled",!1)),this.$button.attr("tabindex")!=-1||this.$element.data("tabindex")||this.$button.removeAttr("tabindex"));this.$button.click(function(){return!n.isDisabled()})},togglePlaceholder:function(){var n=this.$element.val();this.$button.toggleClass("bs-placeholder",n===null||n===""||n.constructor===Array&&n.length===0)},tabIndex:function(){this.$element.data("tabindex")!==this.$element.attr("tabindex")&&this.$element.attr("tabindex")!==-98&&this.$element.attr("tabindex")!=="-98"&&(this.$element.data("tabindex",this.$element.attr("tabindex")),this.$button.attr("tabindex",this.$element.data("tabindex")));this.$element.attr("tabindex",-98)},clickListener:function(){var t=this,i=n(document);i.data("spaceSelect",!1);this.$button.on("keyup",function(n){/(32)/.test(n.keyCode.toString(10))&&i.data("spaceSelect")&&(n.preventDefault(),i.data("spaceSelect",!1))});this.$button.on("click",function(){t.setSize()});this.$element.on("shown.bs.select",function(){var i,n;if(t.options.liveSearch||t.multiple){if(!t.multiple){if(i=t.liObj[t.$element[0].selectedIndex],typeof i!="number"||t.options.size===!1)return;n=t.$lis.eq(i)[0].offsetTop-t.$menuInner[0].offsetTop;n=n-t.$menuInner[0].offsetHeight/2+t.sizeInfo.liHeight/2;t.$menuInner[0].scrollTop=n}}else t.$menuInner.find(".selected a").focus()});this.$menuInner.on("click","li a",function(i){var h=n(this),o=h.parent().data("originalIndex"),nt=t.$element.val(),tt=t.$element.prop("selectedIndex"),a=!0,p,w,g;if(t.multiple&&t.options.maxOptions!==1&&i.stopPropagation(),i.preventDefault(),!t.isDisabled()&&!h.parent().hasClass("disabled")){var c=t.$element.find("option"),e=c.eq(o),v=e.prop("selected"),y=e.parent("optgroup"),r=t.options.maxOptions,f=y.data("maxOptions")||!1;if(t.multiple){if(e.prop("selected",!v),t.setSelected(o,!v),h.blur(),(r!==!1||f!==!1)&&(p=r<c.filter(":selected").length,w=f<y.find("option:selected").length,r&&p||f&&w))if(r&&r==1)c.prop("selected",!1),e.prop("selected",!0),t.$menuInner.find(".selected").removeClass("selected"),t.setSelected(o,!0);else if(f&&f==1)y.find("option:selected").prop("selected",!1),e.prop("selected",!0),g=h.parent().data("optgroup"),t.$menuInner.find('[data-optgroup="'+g+'"]').removeClass("selected"),t.setSelected(o,!0);else{var b=typeof t.options.maxOptionsText=="string"?[t.options.maxOptionsText,t.options.maxOptionsText]:t.options.maxOptionsText,s=typeof b=="function"?b(r,f):b,k=s[0].replace("{n}",r),d=s[1].replace("{n}",f),l=n('<div class="notify"><\/div>');s[2]&&(k=k.replace("{var}",s[2][r>1?0:1]),d=d.replace("{var}",s[2][f>1?0:1]));e.prop("selected",!1);t.$menu.append(l);r&&p&&(l.append(n("<div>"+k+"<\/div>")),a=!1,t.$element.trigger("maxReached.bs.select"));f&&w&&(l.append(n("<div>"+d+"<\/div>")),a=!1,t.$element.trigger("maxReachedGrp.bs.select"));setTimeout(function(){t.setSelected(o,!1)},10);l.delay(750).fadeOut(300,function(){n(this).remove()})}}else c.prop("selected",!1),e.prop("selected",!0),t.$menuInner.find(".selected").removeClass("selected").find("a").attr("aria-selected",!1),t.setSelected(o,!0);!t.multiple||t.multiple&&t.options.maxOptions===1?t.$button.focus():t.options.liveSearch&&t.$searchbox.focus();a&&(nt!=t.$element.val()&&t.multiple||tt!=t.$element.prop("selectedIndex")&&!t.multiple)&&(u=[o,e.prop("selected"),v],t.$element.triggerNative("change"))}});this.$newElement.find("li").on("click",function(t){var i,r;if(t.preventDefault(),i=n(this).closest(".bootstrap-select"),r=i.find("select"),i.length&&r.prop("multiple")){var u=n(this).data("optgroup")-1,f=u+1,r=n(this).closest(".bootstrap-select").find("select");n(this).hasClass("dropdown-header")&&(i.find("li[data-optgroup="+f+"]:not(.selected)").length===1?n(this).closest(".bootstrap-select").find("select > optgroup:eq("+u+") > option").prop("selected",!1):n(this).closest(".bootstrap-select").find("select > optgroup:eq("+u+") > option").prop("selected",!0),r.selectpicker("render"))}});this.$menu.on("click","li.disabled a, .popover-title, .popover-title :not(.close)",function(i){i.currentTarget==this&&(i.preventDefault(),i.stopPropagation(),t.options.liveSearch&&!n(i.target).hasClass("close")?t.$searchbox.focus():t.$button.focus())});this.$menuInner.on("click",".divider, .dropdown-header",function(n){n.preventDefault();n.stopPropagation();t.options.liveSearch?t.$searchbox.focus():t.$button.focus()});this.$menu.on("click",".popover-title .close",function(){t.$button.click()});this.$searchbox.on("click",function(n){n.stopPropagation()});this.$menu.on("click",".actions-btn",function(i){t.options.liveSearch?t.$searchbox.focus():t.$button.focus();i.preventDefault();i.stopPropagation();n(this).hasClass("bs-select-all")?t.selectAll():t.deselectAll()});this.$element.change(function(){t.render(!1);t.$element.trigger("changed.bs.select",u);u=null})},liveSearchListener:function(){var t=this,i=n('<li class="no-results"><\/li>');this.$button.on("click.dropdown.data-api",function(){t.$menuInner.find(".active").removeClass("active");!t.$searchbox.val()||(t.$searchbox.val(""),t.$lis.not(".is-hidden").removeClass("hidden"),!i.parent().length||i.remove());t.multiple||t.$menuInner.find(".selected").addClass("active");setTimeout(function(){t.$searchbox.focus()},10)});this.$searchbox.on("click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api",function(n){n.stopPropagation()});this.$searchbox.on("input propertychange",function(){var f,o,s,u;t.$lis.not(".is-hidden").removeClass("hidden");t.$lis.filter(".active").removeClass("active");i.remove();t.$searchbox.val()&&(f=t.$lis.not(".is-hidden, .divider, .dropdown-header"),o=t.options.liveSearchNormalize?f.not(":a"+t._searchStyle()+'("'+e(t.$searchbox.val())+'")'):f.not(":"+t._searchStyle()+'("'+t.$searchbox.val()+'")'),o.length===f.length?(i.html(t.options.noneResultsText.replace("{0}",'"'+r(t.$searchbox.val())+'"')),t.$menuInner.append(i),t.$lis.addClass("hidden")):(o.addClass("hidden"),s=t.$lis.not(".hidden"),s.each(function(t){var i=n(this);i.hasClass("divider")?u===undefined?i.addClass("hidden"):(u&&u.addClass("hidden"),u=i):i.hasClass("dropdown-header")&&s.eq(t+1).data("optgroup")!==i.data("optgroup")?i.addClass("hidden"):u=null}),u&&u.addClass("hidden"),f.not(".hidden").first().addClass("active"),t.$menuInner.scrollTop(0)))})},_searchStyle:function(){return{begins:"ibegins",startsWith:"ibegins"}[this.options.liveSearchStyle]||"icontains"},val:function(n){return typeof n!="undefined"?(this.$element.val(n),this.render(),this.$element):this.$element.val()},changeAll:function(t){var r,f;if(this.multiple){typeof t=="undefined"&&(t=!0);this.findLis();var e=this.$element.find("option"),i=this.$lis.not(".divider, .dropdown-header, .disabled, .hidden"),o=i.length,u=[];if(t){if(i.filter(".selected").length===i.length)return}else if(i.filter(".selected").length===0)return;for(i.toggleClass("selected",t),r=0;r<o;r++)f=i[r].getAttribute("data-original-index"),u[u.length]=e.eq(f)[0];n(u).prop("selected",t);this.render(!1);this.togglePlaceholder();this.$element.triggerNative("change")}},selectAll:function(){return this.changeAll(!0)},deselectAll:function(){return this.changeAll(!1)},toggle:function(n){n=n||window.event;n&&n.stopPropagation();this.$button.trigger("click")},keydown:function(t){var e=n(this),y=e.is("input")?e.parent().parent():e.parent(),r,i=y.data("this"),u,h,o,l=":not(.disabled, .hidden, .dropdown-header, .divider)",a={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},s,f,v,c;if(o=i.$newElement.hasClass("open"),!o&&(t.keyCode>=48&&t.keyCode<=57||t.keyCode>=96&&t.keyCode<=105||t.keyCode>=65&&t.keyCode<=90)){i.options.container?i.$button.trigger("click"):(i.setSize(),i.$menu.parent().addClass("open"),o=!0);i.$searchbox.focus();return}if(i.options.liveSearch&&/(^9$|27)/.test(t.keyCode.toString(10))&&o&&(t.preventDefault(),t.stopPropagation(),i.$menuInner.click(),i.$button.focus()),/(38|40)/.test(t.keyCode.toString(10))){if(r=i.$lis.filter(l),!r.length)return;u=i.options.liveSearch?r.index(r.filter(".active")):r.index(r.find("a").filter(":focus").parent());h=i.$menuInner.data("prevIndex");t.keyCode==38?((i.options.liveSearch||u==h)&&u!=-1&&u--,u<0&&(u+=r.length)):t.keyCode==40&&((i.options.liveSearch||u==h)&&u++,u=u%r.length);i.$menuInner.data("prevIndex",u);i.options.liveSearch?(t.preventDefault(),e.hasClass("dropdown-toggle")||(r.removeClass("active").eq(u).addClass("active").children("a").focus(),e.focus())):r.eq(u).children("a").focus()}else e.is("input")||(s=[],r=i.$lis.filter(l),r.each(function(i){n.trim(n(this).children("a").text().toLowerCase()).substring(0,1)==a[t.keyCode]&&s.push(i)}),f=n(document).data("keycount"),f++,n(document).data("keycount",f),v=n.trim(n(":focus").text().toLowerCase()).substring(0,1),v!=a[t.keyCode]?(f=1,n(document).data("keycount",f)):f>=s.length&&(n(document).data("keycount",0),f>s.length&&(f=1)),r.eq(s[f-1]).children("a").focus());(/(13|32)/.test(t.keyCode.toString(10))||/(^9$)/.test(t.keyCode.toString(10))&&i.options.selectOnTab)&&o&&(/(32)/.test(t.keyCode.toString(10))||t.preventDefault(),i.options.liveSearch?/(32)/.test(t.keyCode.toString(10))||(i.$menuInner.find(".active a").click(),e.focus()):(c=n(":focus"),c.click(),c.focus(),t.preventDefault(),n(document).data("spaceSelect",!0)),n(document).data("keycount",0));(/(^9$|27)/.test(t.keyCode.toString(10))&&o&&(i.multiple||i.options.liveSearch)||/(27)/.test(t.keyCode.toString(10))&&!o)&&(i.$menu.parent().removeClass("open"),i.options.container&&i.$newElement.removeClass("open"),i.$button.focus())},mobile:function(){this.$element.addClass("mobile-device")},refresh:function(){this.$lis=null;this.liObj={};this.reloadLi();this.render();this.checkDisabled();this.liHeight(!0);this.setStyle();this.setWidth();this.$lis&&this.$searchbox.trigger("propertychange");this.$element.trigger("refreshed.bs.select")},hide:function(){this.$newElement.hide()},show:function(){this.$newElement.show()},remove:function(){this.$newElement.remove();this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove();this.$bsContainer?this.$bsContainer.remove():this.$menu.remove();this.$element.off(".bs.select").removeData("selectpicker").removeClass("bs-select-hidden selectpicker")}};h=n.fn.selectpicker;n.fn.selectpicker=s;n.fn.selectpicker.Constructor=t;n.fn.selectpicker.noConflict=function(){return n.fn.selectpicker=h,this};n(document).data("keycount",0).on("keydown.bs.select",'.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input',t.prototype.keydown).on("focusin.modal",'.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input',function(n){n.stopPropagation()});n(window).on("load.bs.select.data-api",function(){n(".selectpicker").each(function(){var t=n(this);s.call(t,t.data())})})})(n)})