<?php
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

$query = $this->get_query_result();
if ( ! $query->found_posts ) {

    rivax_query_not_found_msg ();

    return;
}
?>
<div class="notch-slider">
    <div class="rivax-posts-wrapper">
        <?php $this->render_slider_header(); ?>
        <?php
        if ( $query->have_posts() ) :
            while ( $query->have_posts() ) :
                $query->the_post();

                $this->render_post_body($query->current_post);

            endwhile;
        endif;
        wp_reset_postdata();
        ?>
        <?php $this->render_carousel_footer('slider'); ?>

        <?php
        $id = 'rivax-thumbs-' . $this->get_id();

        $this->add_render_attribute( 'thumbs', 'id', $id );
        $this->add_render_attribute( 'thumbs', 'class', 'thumbs-slider-wrapper' );

        $thumbs_settings = [
            "loop"                  => ( $settings["slider_loop"] == "yes" ),
            "speed"                 => $settings["slider_speed"]["size"],
            "grabCursor"            => ( $settings["slider_grab_cursor"] == "yes" ),
            "slideToClickedSlide"   => true,
            "touchRatio"            => 0.2,
            "spaceBetween"          => 60,
            "loopedSlides"          => 2,
            "slidesPerView"         => 2,
        ];

        $this->add_render_attribute('thumbs', 'data-settings', wp_json_encode(array_filter($thumbs_settings)) );
        ?>
        <div <?php $this->print_render_attribute_string( 'thumbs' ); ?>>
            <div class="swiper thumbs-slider">
                <div class="swiper-wrapper">
                    <?php
                    if ( $query->have_posts() ) :
                        while ( $query->have_posts() ) :
                            $query->the_post();
                            ?>
                            <div class="thumb-wrapper swiper-slide">
                                <div class="image-wrapper">
                                    <?php the_post_thumbnail($settings['thumbnail_size'], array( 'title' => get_the_title() )); ?>
                                </div>
                            </div>
                        <?php
                        endwhile;
                    endif;
                    wp_reset_postdata();
                    ?>
                </div>
            </div>
        </div>
    </div>
</div>
