!function(f){"use strict";f.fn.MinimogGridQuery=function(){var d,s,r,u=!1,g=!1;function i(){var o;f("body").hasClass("elementor-editor-active")||("load-more"===d.data("pagination")?d.children(".minimog-grid-pagination").find(".minimog-load-more-button").on("click",function(i){i.preventDefault(),u||(f(this).hide(),i=p("paged"),m("paged",++i),g=!0,l())}):"load-more-alt"===d.data("pagination")?f(d.data("pagination-custom-button-id")).on("click",function(i){i.preventDefault(),u||(f(this).hide(),i=p("paged"),m("paged",++i),g=!0,l())}):"infinite"===d.data("pagination")&&(o=setInterval(function(){var i,n,t,a,e,r;s.hasClass("loaded")&&(n=.9*(i=f(window).height()),n=parseInt(n),t=d.offset().top,a=d.outerHeight(!0),e=t+a-n,r=0,f(window).scroll(function(){var i,n=f(this).scrollTop();r<n&&e<=n&&(u||(i=p("paged"))<c("max_num_pages")&&(m("paged",++i),g=!0,l())),r=n}),f(window).on("resize",function(){setTimeout(function(){i=f(window).height(),n=parseInt(n=.9*i),t=d.offset().top,a=d.outerHeight(!0),e=t+a-n},100)}),clearInterval(o))},200)))}function l(a){var e;(e=(u=!0)===g?d.find(".minimog-infinite-loader"):s.children(".minimog-grid-loader")).addClass("show"),setTimeout(function(){var i=jQuery.parseJSON(r.val()),i=f.param(i);f.ajax({url:$minimog.ajaxurl,type:"GET",data:i,dataType:"json",success:function(i){i.max_num_pages&&o("max_num_pages",i.max_num_pages),i.found_posts&&o("found_posts",i.found_posts),i.count&&o("count",i.count);var n,t,i=i.template,i=f(f.parseHTML(i)),i=(!0===a&&s.children(".grid-item").remove(),d.trigger("MinimogQueryEnd",[d,i]),d.find(".result-count").first());0<i.length&&(n=c("found_posts"),i.find(".count").text(n)),i=c("found_posts"),n=p("paged"),t=p("posts_per_page"),(i<=n*t?(("load-more-alt"===d.data("pagination")?f(d.data("pagination-custom-button-id")):d.children(".minimog-grid-pagination").children(".pagination-wrapper")).hide(),d.children(".minimog-grid-pagination").children(".minimog-grid-messages")):"load-more-alt"===d.data("pagination")?f(d.data("pagination-custom-button-id")):(d.children(".minimog-grid-pagination").children(".pagination-wrapper").show(),d.children(".minimog-grid-pagination").find(".minimog-load-more-button"))).show(),e.removeClass("show"),g=u=!1}})},500)}function c(i){return jQuery.parseJSON(r.val())[i]}function o(i,n){var t=jQuery.parseJSON(r.val());t[i]=n,r.val(JSON.stringify(t))}function p(i){return jQuery.parseJSON(r.val()).query_vars[i]}function m(i,n){var t=jQuery.parseJSON(r.val());t.query_vars[i]=n,r.val(JSON.stringify(t))}return this.each(function(){d=f(this),s=d.find(".minimog-grid"),r=d.find(".minimog-query-input").first(),d.children(".minimog-grid-filter").data("filter-counter")&&d.find(".btn-filter").each(function(){var i=f(this).data("filter-count");0<f(this).children(".filter-counter").length?f(this).children(".filter-counter").text(i):f(this).append('<span class="filter-counter">'+i+"</span>")}),d.children(".minimog-grid-filter").on("click",".btn-filter",function(i){var n;f(this).hasClass("current")?i.preventDefault():"1"!=d.data("query-main")&&(i.preventDefault(),m("extra_tax_query","*"===(n=(i=f(this)).attr("data-filter"))?"":n),d.trigger("MinimogBeginQuery"),i.siblings().removeClass("current"),i.addClass("current"))}),i(),d.on("MinimogBeginQuery",function(){m("paged",1),l(!0)})})}}(jQuery);