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