jQuery(document).ready(function(e){function t(t,i,r){if(0!==i.length){var a,n,o=(a=function(){r(t)},function(){var e=this,t=arguments;clearTimeout(n),n=setTimeout(function(){n=null,a.apply(e,t)},100)});if(o(),e(window).on("resize.shutterpress",o),"undefined"!=typeof ResizeObserver){var s=new ResizeObserver(o);s.observe(i[0]),i.data("sp-ro",s)}}}function i(t){var i=t.find(".sp-gallery-masonry-gallery"),r=i.find(".sp-gallery-masonry-item");if(0!==i.length&&0!==r.length){var a=function(){var t=e(window).width(),a=elementorFrontend.config.breakpoints;const n=i.data("columns");var o;t>=a.lg?o=n.desktop:t>=a.md&&t<a.lg?o=n.tablet:t<a.md&&(o=n.mobile);let s=parseInt(i.attr("data-gap"));s=isNaN(s)||null===s?10:s;const l=(i.width()-(o-1)*s)/o,d=Array(o).fill(0);r.each(function(){this.style.removeProperty("top"),this.style.removeProperty("left")}),r.each(function(){const t=e(this),i=Math.min(...d),r=d.indexOf(i);t.css({position:"absolute",top:`${i}px`,left:r*(l+s)+"px","margin-bottom":"0px"}),d[r]+=t.outerHeight(!0)+s});const p=Math.max(...d);i.css("height",`${p}px`)};"function"==typeof i.imagesLoaded?i.imagesLoaded(a):a()}}function r(t){var i=t.find(".sp-gallery-justified-gallery");if(0!==i.length){var r=function(){var t=parseInt(i.attr("data-row-height"))||200,r=parseInt(i.attr("data-gap"),10);isNaN(r)&&(r=10);var a=i.width();shutterpressData.debug&&console.log("containerWidth:",a);var n=i.find(".sp-gallery-justified-item");n.each(function(){this.style.removeProperty("width"),this.style.removeProperty("height"),this.style.removeProperty("left"),this.style.removeProperty("top"),this.style.removeProperty("position")});var o=[],s=0,l=0;n.each(function(){var i=e(this),d=i.find("img")[0],p=(d.naturalWidth||parseInt(d.getAttribute("width")))/(d.naturalHeight||parseInt(d.getAttribute("height"))),h=t*p;o.push({$el:i,width:h,height:t,aspectRatio:p}),s+=h+r;var g=i.is(n.last());if(s>a&&o.length>1||g){var f=(o.length-1)*r,u=o.reduce((e,t)=>e+t.width,0),y=g&&s<=a,c=y?1:(a-f)/u,m=0;o.forEach(function(e){var i=Math.round(e.width*c),a=Math.round(t*c);y&&(a=t),e.$el.css({width:i+"px",height:a+"px",position:"absolute",left:m+"px",top:l+"px"}),m+=i+r}),l+=(y?t:Math.round(t*c))+r,s=0,o=[]}}),i.css("height",l+"px"),i.css("position","relative")};"function"==typeof i.imagesLoaded?i.imagesLoaded(r):r()}}function a(t){var i=t.find(".sp-gallery-grid-gallery");if(0===i.length)return;var r=e(window).width(),a=elementorFrontend.config.breakpoints;const n=i.data("columns");var o;o=r>=a.lg?n.desktop:r>=a.md&&r<a.lg?n.tablet:n.mobile;let s=parseInt(i.attr("data-gap"));s=isNaN(s)||null===s?10:s,i.find(".sp-gallery-grid-item").each(function(){this.style.removeProperty("width"),this.style.removeProperty("height")}),i.css({display:"grid",gridTemplateColumns:"repeat("+o+", 1fr)",gridGap:s+"px",gap:s+"px"}),i.find(".sp-gallery-grid-item").css({opacity:1}),i.css("position","relative")}elementorFrontend.hooks.addAction("frontend/element_ready/shutterpress_gallery.default",function(e){var n=e.find(".sp-gallery-masonry-gallery"),o=e.find(".sp-gallery-justified-gallery"),s=e.find(".sp-gallery-grid-gallery");n.length&&t(e,n,i),o.length&&t(e,o,r),s.length&&t(e,s,a),e.find(".sp-gallery-elementor-gallery").removeClass("sp-gallery-hidden")})});