jQuery(document).ready(function ($) {
    $('.justified').justifiedGallery({
        rowHeight: 250,
        margins: 5,
        lastRow: 'center',
        captions: false
    }).on('jg.complete', function () {
        $('.justified').css('opacity', 1);

        const leftArrowSVGString = '<svg aria-hidden="true" class="pswp__icn" viewBox="0 0 100 125" width="100" height="125"><path d="M5,50L50,5l3,3L11,50l42,42l-3,3L5,50z M92,95l3-3L53,50L95,8l-3-3L47,50L92,95z"/></svg>';

        const lightbox = new PhotoSwipeLightbox({
            arrowPrevSVG: leftArrowSVGString,
            arrowNextSVG: leftArrowSVGString,
            gallery: '.imgGallery',
            children: 'a.imgLink',
            pswpModule: PhotoSwipe,
            captionContent: (slide) => {
                return slide.data.element.dataset.pswpCaption || '';
            }
        });
        lightbox.init();
    });
});