!function(s){"use strict";s(document).ready(function(){var t,e,i,r,a,o;t=s(".woocommerce-product-search"),e=s(".ajax-search .woocommerce-product-search .search-field"),i=s(".ajax-search-result"),r=wp.template("ajax-live-search-template"),a=s(".input-dropdown-inner"),o=s("> .list-wrapper",a),s("body").on("click",function(){i.hide(),o.slideUp(100),a.removeClass("dd-shown")}),s(".input-dropdown-inner > a").on("click",function(e){return e.preventDefault(),a.hasClass("dd-shown")?(a.removeClass("dd-shown"),o.slideUp(100)):(a.addClass("dd-shown"),o.slideDown(100)),i.hide(),!1}),s(".input-dropdown-inner > .list-wrapper").on("click","a",function(e){e.preventDefault();var n=s(this).data("val"),t=s(this).text();s(".input-dropdown-inner > .list-wrapper").find(".current-item").removeClass("current-item"),s(this).parent().addClass("current-item"),0!=n?o.find("ul:not(.children) > li:first-child").show():0==n&&o.find("ul:not(.children) > li:first-child").hide(),s(".input-dropdown-inner > a span").text(t),s(".input-dropdown-inner > select").val(n).trigger("cat_selected"),o.slideUp(100),a.removeClass("dd-shown")}),s(".input-dropdown-inner > select").change(function(){var e=s(this).val(),n=s(this).find("option:selected").text();s(".input-dropdown-inner > .list-wrapper").find(".current-item").removeClass("current-item"),s(this).parent().addClass("current-item"),0!=e?o.find("ul:not(.children) > li:first-child").show():0==e&&o.find("ul:not(.children) > li:first-child").hide(),s(".input-dropdown-inner > a span").text(n)}),e.length&&e.keyup(function(){if(2<this.value.length){var e=s('select[name="product_cat"]',t).val();s.ajax({url:umimoAjax.ajaxurl,type:"post",data:{action:"umimo_ajax_search_products",query:this.value,product_cat:e},beforeSend:function(){t.addClass("loading")},success:function(e){t.removeClass("loading");var n=s.parseJSON(e);i.empty(),i.show(),s.each(n,function(e,n){i.append(r({url:n.url,title:n.value,img:n.img,price:n.price}))})}})}else i.hide()}).on("click",function(e){e.stopPropagation()}).on("focus",function(e){o.slideUp(100),a.removeClass("dd-shown"),2<this.value.length&&i.show()})})}(jQuery);