$(function () {
  // 内部の slick-slider に li が1つもなければサムネイルの枠非表示
  $('.rgs_thumbnailwrap').each(function(){
    var $wrap = $(this);
    if($wrap.find('.rgs_thumbnail-list').length === 0){
      $wrap.hide(); // サムネ全体を非表示

      // .rgs_bigthumbnailwrap の右矢印だけ非表示
      $('.rgs_bigthumbnailwrap .thumb-next').hide();
    }
  });


  // ---------- サムネイルミニスライダー ----------
  $('.rgs_bigthumbnailblock').slick({
    slidesToShow: 1,
    slidesToScroll: 1,
    arrows: true,
    prevArrow: '.big-prev',
    nextArrow: '.big-next',
    asNavFor: '.rgs_thumbnailblock',
    dots: false,
    infinite: false
  });

  $('.rgs_thumbnailblock').slick({
      slidesToShow: 5,
      slidesToScroll: 1,
      arrows: true,
      asNavFor: '.rgs_bigthumbnailblock',
      focusOnSelect: true,
      prevArrow: '.thumb-prev',
      nextArrow: '.thumb-next',
      dots: false,
      infinite: false,
      variableWidth: true,
      responsive: [
      {
        breakpoint: 690,
        settings: {
          slidesToShow: 4
        }
      }
    ]
  });


  // モーダル
  $('[data-mdlimage]').modaal({
    type: 'image',
    overlay_close  : true,
    background : '#000000',
    overlay_opacity: 0.8,
    content_source: '#rgsModal01',
  });




  // ---------- モーダル02（周辺環境ギャラリー） ----------
  $('[data-mdlimagearound]').modaal({
    type: 'image',
    overlay_close  : true,
    background : '#000000',
    overlay_opacity: 0.8,
    content_source: '#rgsModal02',
  });




  // ---------- シェアボタン ----------
  // ボタンの要素を取得
  const $shareButton = $('#webShareButton');
  // ページのdescriptionを取得
  const description = $("meta[name='description']").attr("content") || '';

  // クリックイベントを設定
  $shareButton.on('click', async function () {
    try {
      await navigator.share({
        title: document.title,
        text: description,
        url: window.location.href
      });
      console.log('シェア成功！');
    } catch (error) {
      console.error('シェア失敗', error);
    }
  });





});//ready