<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes. All rights reserved.
 * See COPYING.txt for license details.
 */

declare(strict_types=1);

use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\CurrentProduct;
use Magento\Catalog\Model\Product;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;

/** @var Template $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */

$product = $block->getProduct();
$associatedProducts = $block->getAssociatedProducts();
$hasAssociatedProducts = count($associatedProducts) > 0;
?>
<?php if ($block->displayProductStockStatus()): ?>
<div class="text-right">
    <?php if ($product->isAvailable() && $hasAssociatedProducts): ?>
        <p class="flex items-center justify-end align-middle available gap-x-2 stock"
           title="<?= $escaper->escapeHtmlAttr(__('Availability')) ?>">
            <span class="w-3 h-3 bg-green-500 rounded-full shrink-0"></span>
            <span><?= $escaper->escapeHtml(__('In stock')) ?></span>
        </p>
    <?php else: ?>
        <p class="flex items-center justify-end align-middle gap-x-2 unavailable stock"
           title="<?= $escaper->escapeHtmlAttr(__('Availability')) ?>">
            <span class="w-3 h-3 bg-red-500 rounded-full shrink-0"></span>
            <span><?= $escaper->escapeHtml(__('Out of stock')) ?></span>
        </p>
    <?php endif; ?>
</div>
<?php endif; ?>
