void 0===TCB_Front.js_modules.dropdown&&TCB_Front.setModuleLoadedStatus("dropdown",!1),(t=>{if(TCB_Front.isModuleLoaded("dropdown"))return;const o=".tve_lg_dropdown, .tcb-form-dropdown, .tve-dynamic-dropdown";t(window).on("tcb_after_dom_ready",(()=>{if(!TCB_Front.Utils.isEditorPage()){const o=t(TCB_Front.Utils.isEditorPage()?"#tve_editor":"body");e.initEvents(o)}t(`${o}`).each((function(o,e){t(e).find("input").attr("readonly","")}))}));const e={initEvents(e){t(".tve-lg-dropdown-trigger").each((function(){t(this).attr("tabindex",-1).removeAttr("href").siblings("input").attr("style","position: absolute; opacity: 0;").attr("autocomplete","off")}));let n="";const d=function(){n="",t(".tve-lg-dropdown-option.tve-state-hover,.tve-dynamic-dropdown-option.tve-state-hover").removeClass("tve-state-hover")};e.off("mousedown.dropdownclick").on("mousedown.dropdownclick",o,(function(e){if(e.stopPropagation(),e.preventDefault(),e.target.classList.contains("tve-lg-dropdown-list"))return!1;const n=t(this).closest(o);n.toggleClass("tve-state-expanded"),n.find("input").trigger("focus")})).off("blur.dropdownblur").on("blur.dropdownblur",".tve_lg_dropdown input, .tcb-form-dropdown input, .tve-dynamic-dropdown input",(function(t){t.stopPropagation(),t.preventDefault(),d(),this.closest(o).classList.remove("tve-state-expanded")})).off("keydown.dropdownkeypress").on("keydown.dropdownkeypress",".tve_lg_dropdown input, .tcb-form-dropdown input, .tve-dynamic-dropdown input",(function(e){const a=t(this).closest(o),i=a.find(".tve-state-active");switch(9!==e.keyCode&&(e.stopPropagation(),e.preventDefault()),e.keyCode){case 13:a.toggleClass("tve-state-expanded"),d();break;case 38:0===i.length?r(a.find(".tve-lg-dropdown-option,.tve-dynamic-dropdown-option").last(),a):i.prev().length&&r(i.prev(),a),d();break;case 40:0===i.length?r(a.find(".tve-lg-dropdown-option,.tve-dynamic-dropdown-option").first(),a):i.next().length&&r(i.next(),a),d();break;case 27:a.removeClass("tve-state-expanded"),d();break;case 8:d();break;default:n+=String.fromCharCode(e.keyCode).toLowerCase(),t(".tve-lg-dropdown-option.tve-state-hover,.tve-dynamic-dropdown-option.tve-state-hover").removeClass("tve-state-hover");const o=a.find(".tve-lg-dropdown-option,.tve-dynamic-dropdown-option").filter((function(){return this.dataset.value.toLowerCase().startsWith(n)})).first();o.length&&(t(".tve-lg-dropdown-list").animate({scrollTop:o.prevAll().length*o.outerHeight()},500),o.addClass("tve-state-hover"))}})),e.off("mousedown.dropdownoptionclick").on("mousedown.dropdownoptionclick",".tve-lg-dropdown-option,.tve-dynamic-dropdown-option",(function(e){e.stopPropagation(),e.preventDefault();const n=t(this),d=n.closest(o);r(n,d),d.removeClass("tve-state-expanded")}));const r=function(t,o){o.find(".tve-lg-dropdown-trigger").find(".tve-disabled-text-inner").html(t.text()),o.find("input").attr("value",t.attr("data-value")).val(t.attr("data-value")),o.find(".tve-state-active").removeClass("tve-state-active"),t.addClass("tve-state-active"),o.trigger("tcb.dropdown_value_changed")}}};TCB_Front.setModuleLoadedStatus("dropdown",!0)})(ThriveGlobal.$j);