$(document).ready(function () {
  $("[href='#']").on("click", function (e) {
    e.preventDefault();
  });

  // Main Slider
  new Swiper(".swiper-container-slide", {
    slidesPerView: 5,
    spaceBetween: 20,
    navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
    autoplay: {
      delay: 4000,
      disableOnInteraction: false,
    },
    breakpoints: {
      0: {
        slidesPerView: 1,
      },
      768: {
        slidesPerView: 3,
      },
      992: {
        slidesPerView: 5,
      },
    },
  });

  if ($("body").owlCarousel != undefined) {
    $(".about-carousel").owlCarousel({
      loop: true,
      margin: 10,
      nav: false,
      responsive: {
        0: {
          items: 1,
        },
        600: {
          items: 3,
        },
        1000: {
          items: 5,
        },
      },
    });
    $(".about-carousel-rtl").owlCarousel({
      loop: true,
      margin: 10,
      nav: false,
      rtl: true,
      responsive: {
        0: {
          items: 1,
        },
        600: {
          items: 3,
        },
        1000: {
          items: 5,
        },
      },
    });
  }

  if ($("body").magnificPopup != undefined) {
    $(".popup").magnificPopup({
      type: "image",
      mainClass: "mfp-with-zoom",
      gallery: {
        enabled: true,
        preload: [0, 2],
        navigateByImgClick: true,
        arrowMarkup:
          '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
        tPrev: "Previous (Left arrow key)",
        tNext: "Next (Right arrow key)",
        tCounter: '<span class="mfp-counter">%curr% of %total%</span>',
      },
      zoom: {
        enabled: true,
        duration: 400,
        easing: "ease-in-out",
        opener: function (openerElement) {
          return openerElement.is("img")
            ? openerElement
            : openerElement.find("img");
        },
      },
    });
  }

  //mh
  const mhFix = () => {
    $(".eH-Area").each(function () {
      $(this).find(".eH").matchHeight();
    });
  };

  $(".tp-product-tab .nav-link").on("click", function () {
    setTimeout(function () {
      mhFix();
    }, 500);
  });

  mhFix();

  $(".cat-item-image span").css({
    height: $(".cat-item-image").outerWidth(),
  });
});
