<?php
/**
 * @var $featureImage string
 * @var $featureImageThumb string
 * @var $cdnUse string
 * @var $imageList string
 * @var $isCloned string
 * @var $templateImageList string
 * @var $cdnUseCondition boolean
 * @var $images array WP_Post[]|array
 * @var $video string
 * @var $onlyForUserAuth bool
 */

use auctionforge\inc\abs\ImageModel;
use auctionforge\inc\helpers\Tools;

?>
<div id="wrpLotImages" class="bp-body__gallery bp-d-flex bp-f-wrap bp-lg-f-index-0" data-image-cloned="<?= ($isCloned == '1') ? 1 : 0 ?>"
     data-image-list="<?= $imageList ?>" data-image-template="<?= $templateImageList ?>">
    <div class="swiper-container bp-gallery-top">
        <div id="lotImages" class="swiper-wrapper">
            <?php do_action('bp_after_gallery_top', $featureImage, $images, $video); ?>
            <?php if (!empty($video) && Tools::isYouTube($video)) { ?>
                <?php $ytId = Tools::getYouTubeID($video); ?>
                <?php if (!empty($ytId)) { ?>
                <div class="swiper-slide bp-swiper-slide_youtube">
                    <iframe width="807" height="455" src="https://www.youtube.com/embed/<?= esc_attr($ytId) ?>?showinfo=0" frameborder="0" allowfullscreen></iframe>
                </div>
                <?php } ?>
            <?php } ?>
            <?php if (!empty($featureImage)) { ?>
                <a href="<?= $featureImage ?>" data-fancybox-bp="gallery" class="swiper-slide" style="background-image:url('<?= $featureImageThumb ?>')"></a>
            <?php } ?>
            <?php if (!empty($images) && !$onlyForUserAuth) { ?>
                <?php foreach ($images as $image) { ?>
                    <?php if ($cdnUseCondition) { ?>
                        <a href="<?= $image[ImageModel::LABEL_ORIGINAL] ?>"
                           data-fancybox-bp="gallery" class="swiper-slide"
                           style="background-image:url('<?= $image[ImageModel::LABEL_CUSTOM] ?>')">
                        </a>
                    <?php } else { ?>
                        <?php $src = wp_get_attachment_image_url($image->ID, 'lot-slide'); ?>
                        <a href="<?= $image->guid ?>"
                           data-fancybox-bp="gallery"
                           class="swiper-slide"
                           style="background-image:url('<?= $src ?>')">
                        </a>
                    <?php } ?>
                <?php } ?>
            <?php } ?>
            <?php do_action('bp_before_gallery_top', $featureImage, $images, $video); ?>
        </div>
        <!-- Add Arrows -->
        <div class="swiper-button-next swiper-button-white"></div>
        <div class="swiper-button-prev swiper-button-white"></div>
    </div>
    <div class="swiper-container bp-gallery-thumbs">
        <div class="swiper-wrapper">
            <?php do_action('bp_after_gallery_thumbs', $featureImage, $images, $video); ?>
            <?php if (!empty($video)) { ?>
                <div class="swiper-slide bp-swiper-slide_youtube" style="background-image:url('<?= $featureImage ?>')"></div>
            <?php } ?>
            <?php if (!empty($featureImageThumb)) { ?>
                <div class="swiper-slide" style="background-image:url('<?= $featureImageThumb ?>')"></div>
            <?php } ?>
            <?php if (!empty($images) && !$onlyForUserAuth) { ?>
                <?php foreach ($images as $image) { ?>
                    <?php if ($cdnUseCondition) { ?>
                        <div class="swiper-slide" style="background-image:url('<?= $image[ImageModel::LABEL_MEDIUM] ?>')"></div>
                    <?php } else { ?>
                        <?php $thumb = wp_get_attachment_image_url($image->ID, 'lot-thumbnail-min'); ?>
                        <div class="swiper-slide" style="background-image:url('<?= $thumb ?>')"></div>
                    <?php } ?>
                <?php } ?>
            <?php } ?>
            <?php do_action('bp_before_gallery_thumbs', $featureImage, $images, $video); ?>
        </div>
    </div>
    <?php do_action('bp_after_gallery_thumbs_action', $featureImage, $images, $video, $onlyForUserAuth); ?>
</div>
