(function(){
"use strict";
function bindOverlayGuards(swiperEl){
var sw=swiperEl.swiper;
if(!sw) return;
swiperEl.querySelectorAll('.igs-link-overlay[href]').forEach(function(a){
a.addEventListener('click', function(e){
if(sw&&sw.allowClick===false){
e.preventDefault();
e.stopPropagation();
}}, true);
});
}
function initSwiper(el){
if(!el||el.getAttribute('data-igs-inited')==='1') return;
try{
var opts={};
try { opts=JSON.parse(el.getAttribute('data-igs-swiper')||'{}'); } catch(e){}
var sw=new Swiper(el, {
loop: !!opts.loop,
watchSlidesProgress: true,
pagination: opts.pagination ? {
el: el.querySelector('.swiper-pagination'),
clickable: true,
dynamicBullets: true
}:false,
navigation: opts.navigation ? {
nextEl: el.querySelector('.swiper-button-next'),
prevEl: el.querySelector('.swiper-button-prev')
}:false
});
bindOverlayGuards(el);
el.setAttribute('data-igs-inited','1');
} catch(e){
if(window.console&&console.warn) console.warn('IGS Swiper init error', e);
}}
function initAll(scope){
(scope||document).querySelectorAll('.igs-swiper:not([data-igs-inited])')
.forEach(initSwiper);
}
var observed=new WeakSet();
function watchGrids(root){
var scope=root||document;
var grids=scope.querySelectorAll('.w-grid, .usg-grid, .w-posts, .w-grid-list, .archive-layout, .usg-posts');
grids.forEach(function(g){
if(observed.has(g)) return;
observed.add(g);
initAll(g);
var mo=new MutationObserver(function(muts){
initAll(g);
});
mo.observe(g, { childList: true, subtree: true });
});
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', function(){
initAll(document);
watchGrids(document);
requestAnimationFrame(function(){
initAll(document);
});
});
}else{
initAll(document);
watchGrids(document);
requestAnimationFrame(function(){ initAll(document); });
}
window.addEventListener('almComplete', function(){ initAll(document); watchGrids(document); });
document.addEventListener('us_ajax_loaded', function(){ initAll(document); watchGrids(document); });
})();