<?php
    $testimonials = $block->getTestimonials();
    if (!count($testimonials)) {
        return;
    }
?>

<div class="widget block testimonials-slider">
    <div class="content-heading">
        <h2 class="title" role="heading"><?= $block->escapeHtml($block->getBlockTitle()) ?></h2>
    </div>
    <div class="block-content">
        <div class="slick-slider" data-mage-init='{"slick": <?= $block->getSliderConfig() ?>}'>
            <?php foreach ($testimonials as $testimonial): ?>
            <div class="slick-slide">
                <figure class="testimonial">
                    <blockquote>
                        <?php if ($ratingPercent = $block->getRatingPercent($testimonial)): ?>
                        <div class="rating nobr">
                            <div class="review-ratings">
                                <div class="rating-summary item">
                                    <span class="label rating-label"><span><?= __('Rating') ?></span></span>
                                    <div class="rating-result" title="<?= $ratingPercent ?>%">
                                        <span style="width:<?= $ratingPercent ?>%">
                                            <span><?= $ratingPercent ?>%</span>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                        <?= $block->escapeHtml($testimonial->getMessage()); ?>
                        <div class="arrow"></div>
                    </blockquote>
                    <img src="<?= $block->getProfileImageUrl($testimonial) ?>" alt="Profile image" />
                    <div class="author">
                        <h5><?= $block->escapeHtml($testimonial->getName()) ?></h5>
                        <?php if ($testimonial->getCompany()): ?>
                        <p><?= $block->escapeHtml($testimonial->getCompany()) ?></p>
                        <?php endif; ?>
                    </div>
                </figure>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>
