!function(a){"use strict";function t(t,e){a(t).isotope({layoutMode:"packery",itemSelector:e,isOriginLeft:!a("body.rtl").length,resizable:!0,initLayout:!0})}function e(t,e,i,s){const o=t.dataset.counter;s=s||a(t).parents(".fusion-builder-live-element").length,window[`igRequest-${o}`]&&window[`igRequest-${o}`].abort();const r=t.dataset.limit,d=t.dataset.link_type,l=t.dataset.link_target,g=t.dataset.page||1,c=t.querySelector(".instagram-posts"),u=t.querySelector(".awb-instagram-load-more-btn"),w=t.querySelector(".awb-instagram-infinite-scroll-handle"),m=t.querySelector(".instagram-posts-loading-container"),p=a(t).hasClass("layout-masonry");a(c).hasClass("fusion-hidden")&&a(c).removeClass("fusion-hidden"),i&&a(m).show(),s&&(!s||window.fusionInstagramItems)||!a(t).hasClass("loading")&&!i||(window[`igRequest-${o}`]=a.ajax({type:"POST",url:window.fusionInstagramVars.ajax_url,data:{action:"awb_instagram_get_data",nonce:window.fusionInstagramVars.nonce,limit:r,page:g,next:e||"",args:{layout:a(t).hasClass("layout-masonry")?"masonry":"grid",link_type:d||"",link_target:l||""},counter:o},dataType:"json",success:function(e){let o=e.html;i?(o=a(o),a(c).append(o),p&&a(c).isotope("appended",o)):c.innerHTML=o,s&&!window.fusionInstagramItems&&(window.fusionInstagramItems=o),n(t,s),t.dataset.page=parseInt(g)+1,u&&(e.data&&e.data.paging&&e.data.paging.cursors&&e.data.paging.cursors.after&&e.data.paging.next?u.dataset.url=e.data.paging.cursors.after:delete u.dataset.url),w&&(e.data&&e.data.paging&&e.data.paging.cursors&&e.data.paging.cursors.after&&e.data.paging.next?w.dataset.url=e.data.paging.cursors.after:delete w.dataset.url),t.classList.remove("loading"),i&&a(m).hide()}})),s&&t.classList.remove("loading"),a(t).hasClass("loading")||i||n(t,s)}function n(e,n){const i=e.dataset.counter,s=e.dataset.link_type,o=e.querySelector(".instagram-posts"),r="awb-instagram-"+i,d=e.querySelector(".awb-instagram-infinite-scroll-handle"),l=a(e).hasClass("layout-masonry");a(d).hasClass("is-active")&&a(d).removeClass("is-active"),"lightbox"===s&&(window[r]?(window[r].destroy(),window[r]=a(e).find(`a[data-rel="${r}"]`).iLightBox(window.avadaLightBox.prepare_options(r,!1))):window[r]=a(e).find(`a[data-rel="${r}"]`).iLightBox(window.avadaLightBox.prepare_options(r,!1)),a(e).find(".instagram-post-children").length&&a(".instagram-post-children").each(function(){const t=a(this).find("a:first-child").data("rel");window[t]?(window[t].destroy(),window[t]=a(e).find(`a[data-rel="${t}"]`).iLightBox(window.avadaLightBox.prepare_options(t,!1))):window[t]=a(e).find(`a[data-rel="${t}"]`).iLightBox(window.avadaLightBox.prepare_options(t,!1))})),l&&window.imagesLoaded(o,function(){a(o).data("isotope")?n?(a(o).isotope("destroy"),t(o,".instagram-post")):a(o).isotope("layout"):t(o,".instagram-post")})}function i(t){const n=t.dataset.url,i=a(t).parents(".awb-instagram-element"),s=i.find(".instagram-posts-loading-container");n?e(i[0],n,!0):(s.show(),setTimeout(()=>{s.find(".fusion-loading-spinner").hide(),s.find(".fusion-loading-msg").html(window.fusionInstagramVars.no_more_posts_msg)},500),setTimeout(()=>{s.slideUp(),a(t).hide()},3500))}a(".awb-instagram-element").each(function(){const a=this.dataset.counter;window[`igRequest-${a}`]=null,e(this)}),a(".awb-instagram-load-more-btn").on("click",function(a){a.preventDefault(),i(this)});const s=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&!a(t.target).hasClass("is-active")&&(a(t.target).addClass("is-active"),i(t.target))})});document.querySelectorAll(".awb-instagram-infinite-scroll-handle").forEach(a=>{s.observe(a)}),a(window).on("load fusion-element-render-fusion_instagram",function(a,t){const n="object"==typeof t?t:document.querySelector(`[data-cid="${t}"] .awb-instagram-element`);n&&e(n,!1,!1,!0)})}(jQuery);