(e=>{function t(e,s){var r=e.find(".tm-product-filter"),o=s(".tm-product-filter__form",r);r.on("click",".term-link",function(e){e.preventDefault();var e=s(this),t=e.closest(".tm-product-filter__filter"),i=e.data("term"),n=e.siblings(".filter-attribute-input"),l=n.val(),r=-1;t.hasClass("tm-product-filter__multiple")?(l=l?l.split(","):[],-1!==(r=-1!==(r=l.indexOf(i))?r:l.indexOf(i.toString()))?l.splice(r,1):l.push(i),n.val(l.join(",")),e.toggleClass("selected"),n.prop("disabled",l.length<=0),t.hasClass("tm-product-filter__attribute")&&(r=n.next("input[name^=query_type_]")).length&&r.prop("disabled",l.length<=1)):e.hasClass("selected")?(e.removeClass("selected"),n.val("").prop("disabled",!0)):(e.addClass("selected").siblings(".selected").removeClass("selected"),n.val(i).prop("disabled",!1));s(document.body).trigger("minimog_products_filter_change")}),r.on("submit",o,function(e){var t=r.find("input[type=hidden]"),i=o.attr("action"),n=-1!==i.indexOf("?")?"&":"?",l={};t.each(function(e){var t=s(this).attr("name"),i=s(this).val();i&&(l[t]=i)}),1<Object.keys(l).length&&(i+=n+s.param(l,!0));"?"===i.slice(-1)&&(i=i.slice(0,-1));return i=i.replace(/%2C/g,","),window.location.href=i,!1}),r.on("click",".tm-button",function(e){e.preventDefault(),o.trigger("submit")})}e(window).on("elementor/frontend/init",function(){elementorFrontend.hooks.addAction("frontend/element_ready/tm-product-filter.default",t)})})(jQuery);