').append(b)),b.on("keydown.sumo",function(b){let c=$(this);switch(b.which){case 32:case 13:c.trigger("click");break;case 9:if(c.hasClass("btnOk"))return;break;case 27:a._cnbtn(),a.hideOpts();return}b.stopPropagation(),b.preventDefault()})},_okbtn(){let a=this,b=0;e.triggerChangeCombined&&(a.E.find("option:checked").length!==a.Pstate.length?b=1:a.E.find("option").each((c,d)=>{d.selected&&0>a.Pstate.indexOf(c)&&(b=1)}),b&&(a.callChange(),a.setText()))},_cnbtn(){let a=this;a.E.find("option:checked").each(function(){this.selected=!1}),a.optDiv.find("li.selected").removeClass("selected");for(let b=0;b
= +e.max?this.optDiv.find("li.opt").not(".hidden").each((b,a)=>{$(a).hasClass("selected")||$(a).addClass("temporary-disabled disabled")}):this.optDiv.find("li.opt").not(".hidden").each((b,a)=>{$(a).hasClass("temporary-disabled")&&$(a).removeClass("temporary-disabled disabled")}))},SelAll(){let a=this;a.is_multi&&(a.selAll=$('
'),[,,a.selAll.find("label")[0].innerText]=e.locale,a.optDiv.addClass("selall"),a.selAll.on("click",()=>{a.selAll.toggleClass("selected"),a.toggSelAll(a.selAll.hasClass("selected"),1)}),a.optDiv.prepend(a.selAll))},Search(){let a=this,c=a.CaptionCont.addClass("search"),d=$(''),f=b.searchFn&&"function"==typeof b.searchFn?b.searchFn:e.searchFn;a.ftxt=$('').on("click",a=>{a.stopPropagation()}),a.ftxt[0].placeholder=e.searchText,c.append(a.ftxt),a.optDiv.children("ul").after(d),a.ftxt.on("keyup.sumo",()=>{let b=a.optDiv.find("ul.options li.opt").each((e,d)=>{let b=$(d),{0:c}=b.data("opt");c.hidden=f(b.text(),a.ftxt.val(),b),b.toggleClass("hidden",c.hidden)}).not(".hidden");a.optDiv[0].querySelectorAll("li.group").forEach(a=>{a.querySelector("li:not(.hidden)")?a.classList.remove("hidden"):a.classList.add("hidden")}),d.html(e.noMatch.replace(/\{0\}/g,"")).toggle(!b.length),d.find("em").text(a.ftxt.val()),a.selAllState()})},selAllState(){let a=this;if(e.selectAll&&a.is_multi){let b=0,c=0;a.optDiv.find("li.opt").not(".hidden .disabled").each((d,a)=>{$(a).hasClass("selected")&&b++,c++}),b===c?a.selAll.removeClass("partial").addClass("selected"):0===b?a.selAll.removeClass("selected partial"):a.selAll.addClass("partial")}},showOpts(){let a=this;if(!a.E.attr("disabled")){if(a.E.trigger("sumo:opening",a),a.is_opened=!0,a.select.addClass("open").attr("aria-expanded","true"),a.E.trigger("sumo:opened",a),a.ftxt?a.ftxt.focus():a.select.focus(),$(document).on("click.sumo",b=>{!a.select.is(b.target)&&0===a.select.has(b.target).length&&a.is_opened&&(a.hideOpts(),e.okCancelInMulti&&(e.isClickAwayOk?a._okbtn():a._cnbtn()))}),a.is_floating){let b=a.optDiv.children("ul").outerHeight()+2;a.is_multi&&(b+=+a.optDiv.css("padding-bottom")),a.optDiv.css("height",b),$("body").addClass("sumoStopScroll")}a.setPstate()}},setPstate(){let a=this;a.is_multi&&(a.is_floating||e.okCancelInMulti)&&(a.Pstate=[],a.E.find("option").each((b,c)=>{c.selected&&a.Pstate.push(b)}))},callChange(){this.E.get().forEach(a=>{c(a,"change"),c(a,"click")})},hideOpts(){let a=this;a.is_opened&&(a.E.trigger("sumo:closing",a),a.is_opened=!1,a.select.removeClass("open").attr("aria-expanded","false").find("ul li.sel").removeClass("sel"),a.E.trigger("sumo:closed",a),$(document).off("click.sumo"),$("body").removeClass("sumoStopScroll"),e.search&&(a.ftxt.val(""),a.ftxt.trigger("keyup.sumo")))},setOnOpen(){let a=this,b=a.optDiv.find("li.opt:not(.hidden)").eq(e.search?0:a.E[0].selectedIndex);(!b.hasClass("disabled")||(b=b.next(":not(disabled)")).length)&&(a.optDiv.find("li.sel").removeClass("sel"),b.addClass("sel"),a.showOpts())},nav(i){let b=this,g=null,a=b.ul.find("li.opt.sel:not(.hidden)"),e=b.ul.find("li.opt:not(.disabled):not(.hidden)"),c=e.index(a);if(b.is_opened&&a.length){if(i&&c>0)g=e.eq(c-1);else{if(i||!(c -1))return;g=e.eq(c+1)}a.removeClass("sel"),a=g.addClass("sel");let{ul:d}=b,h=d.scrollTop(),f=a.position().top+h;f>=h+d.height()-a.outerHeight()&&d.scrollTop(f-d.height()+a.outerHeight()),f{a.E.trigger("click"),a.is_opened?a.hideOpts():a.showOpts(),b.stopPropagation()}),a.select.on("keydown.sumo",b=>{switch(b.which){case 38:a.nav(!0);break;case 40:a.nav(!1);break;case 65:if(!a.is_multi||e.max||!b.ctrlKey)return;a.toggSelAll(!b.shiftKey,1);break;case 32:if(e.search&&a.ftxt.is(b.target))return;break;case 13:a.is_opened?a.optDiv.find("ul li.sel").trigger("click"):a.setOnOpen();break;case 9:e.okCancelInMulti||a.hideOpts();return;case 27:e.okCancelInMulti&&a._cnbtn(),a.hideOpts();return;default:return}b.preventDefault()}),$(window).on("resize.sumo",()=>{a.floatingList()})},onOptClick(a){let b=this;a.click(function(){let a=$(this);a.hasClass("disabled")||(b.is_multi?(a.toggleClass("selected"),a.data("opt")[0].selected=a.hasClass("selected"),!1===a.data("opt")[0].selected?(b.lastUnselected=a.data("opt")[0].textContent,b.selectedCount--):b.selectedCount++,e.max&&b._handleMax(),b.selAllState()):(a.parent().find("li.selected").removeClass("selected"),a.toggleClass("selected"),a.data("opt")[0].selected=!0,b.selectedCount=1),b.is_multi&&e.triggerChangeCombined&&(b.is_floating||e.okCancelInMulti)||(b.setText(),b.callChange()),b.is_multi||b.hideOpts())})},setText(){let a=this;if(a.placeholder="",a.is_multi){let b=a.E.find(":checked").not(":disabled");e.csvDispCount&&b.length>e.csvDispCount?b.length===a.E.find("option").length&&e.captionFormatAllSelected?a.placeholder=e.captionFormatAllSelected.replace(/\{0\}/g,b.length):a.placeholder=e.captionFormat.replace(/\{0\}/g,b.length):a.placeholder=b.toArray().map(a=>a.innerText).join(", ")}else a.placeholder=a.E.find(":checked").not(":disabled").text();let c=!1;a.placeholder||(c=!0,a.placeholder=a.E.attr("placeholder"),a.placeholder||(a.placeholder=a.E.find("option:disabled:checked").text())),a.placeholder=a.placeholder?`${e.prefix} ${a.placeholder}`:e.placeholder,a.caption.text(a.placeholder),e.showTitle&&a.CaptionCont.attr("title",a.placeholder);let d=a.select.find("input.HEMANT123");return d.length&&d.val(a.getSelStr()),c?a.caption.addClass("placeholder"):a.caption.removeClass("placeholder"),a.placeholder},isMobile(){let b=navigator.userAgent||navigator.vendor||window.opera;for(let a=0;a0)return e.nativeOnDevice[a];return!1},setNativeMobile(){let a=this;a.E.addClass("SelectClass"),a.mob=!0,a.E.change(()=>{a.setText()})},floatingList(){let a=this;a.is_floating=$(window).width()<=e.floatWidth,a.optDiv.toggleClass("isFloating",a.is_floating),a.is_floating||a.optDiv.css("height",""),a.optDiv.toggleClass("okCancelInMulti",e.okCancelInMulti&&!a.is_floating)},vRange(a){let b=this,c=b.E.find("option");if(c.length<=a||a<0)throw new Error("index out of bounds");return b},toggSel(d,c){let b=this,a=null;"number"==typeof c?(b.vRange(c),a=b.E.find("option")[c]):a=b.E.find(`option[value="${c}"]`)[0]||0,a&&!a.disabled&&a.selected!==d&&(e.max&&!a.selected&&b.selectedCount{$(a).data("li").hasClass("hidden")||(a.selected=!0,$(a).data("li").toggleClass("selected",!0))}):a.E.find("option:checked:not(:disabled):not(:hidden)").toArray().forEach(a=>{$(a).data("li").hasClass("hidden")||(a.selected=!1,$(a).data("li").toggleClass("selected",!1))}):b?console.warn("You called `SelectAll` on a non-multiple select"):a.E[0].selectedIndex=-1,$.each(d,(_,b)=>{$.each(b,(c,b)=>{a.E.on(b.type,b.handler)})}),(!a.is_multi||e.okCancelInMulti)&&a.is_multi||(a.callChange(),a.setText()),c||(!a.mob&&a.selAll&&a.selAll.removeClass("partial").toggleClass("selected",!!b),a.setText(),a.setPstate())},reload(){let a=this.unload();return $(a).SumoSelect(e)},unload(){let b=this;return b.select.before(b.E),b.E.show(),b.E[0].classList.remove("SumoUnder"),e.outputAsCSV&&b.is_multi&&b.select.find("input.HEMANT123").length&&b.E.attr("name",b.select.find("input.HEMANT123").attr("name")),b.select.remove(),delete a.sumo,b.E.trigger("sumo:unloaded",b),a},add(d,e,j,g){if(void 0===d)throw new Error("No value to add");let b=this,h=b.E.find("option"),k=d,i=e,c=j;"number"==typeof e?(c=e,i=d):void 0===e&&(i=d);let f=$("").val(k).html(i);if(g&&"object"==typeof g&&$.each(g,(a,b)=>{f.attr(a,b)}),h.length=0;a--)!0!==c[a].selected&&b.remove(a)},find(c){let d=this,a=d.E.find("option");for(let b in a)if(a[b].value===c)return+b;return -1},selectItem(a){this.toggSel(!0,a)},unSelectItem(a){this.toggSel(!1,a)},selectAll(){this.toggSelAll(!0)},unSelectAll(){this.toggSelAll(!1)},disableItem(a){this.toggDis(!0,a)},enableItem(a){this.toggDis(!1,a)},enabled:!0,enable(){return this.toggSumo(!1)},disable(){return this.toggSumo(!0)},init(){let a=this;return a.createElems(),a.setText(),a.E.trigger("sumo:initialized",a),a}},a.sumo.init()});return 1===a.length?a[0]:a}})