(function ($) {
  Drupal.behaviors.basepack_image_gallery = {
    attach: function (context, settings) {

      if ($('.basepack-image-gallery.basepack-image-gallery--with-thumbnail').length) {
        let basepackImageGallery = $('.basepack-image-gallery--with-thumbnail .basepack-image-gallery--items');
        let basepackImageGalleryThumbs = $('.basepack-image-gallery--with-thumbnail .basepack-image-gallery--thumbnails');

        basepackImageGallery.not('.slick-initialized').slick({
          autoplay: true,
          slidesToScroll: 1,
          slidesToShow: 1,
          arrows: false,
          dots: false,
          asNavFor: '.basepack-image-gallery--with-thumbnail .basepack-image-gallery--thumbnails',
        }); 

        basepackImageGalleryThumbs.not('.slick-initialized').slick({
          autoplay: true,
          slidesToShow: 4,
          slidesToScroll: 1,
          dots: true,
          focusOnSelect: true,
          asNavFor: '.basepack-image-gallery--with-thumbnail .basepack-image-gallery--items',
        }); 
      };

      if ($('.basepack-image-gallery.basepack-image-gallery--modal').length) {
        if (!$('.basepack-image-gallery.basepack-image-gallery--modal').hasClass('basepack-image-gallery--with-thumbnail')) {
          Fancybox.bind()
        };
      }


    }
  };

})(jQuery);
