<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes 2020-present. All rights reserved.
 * This product is licensed per Magento install
 * See https://hyva.io/license
 */

declare(strict_types=1);

use Hyva\Theme\Block\SortableItem;
use Hyva\Theme\Model\ViewModelRegistry;
use Hyva\Theme\ViewModel\CustomerRegistration;
use Magento\Framework\Escaper;

/** @var SortableItem $block */
/** @var Escaper $escaper */
/** @var ViewModelRegistry $viewModels */
/** @var CustomerRegistration $customerRegistration */

$customerRegistration = $viewModels->require(CustomerRegistration::class);

$label = $block->getLabel() ? $block->getLabel() : __('Create an Account');
?>

<?php if ($customerRegistration->isAllowed()): ?>
    <a id="<?= $escaper->escapeHtmlAttr($block->getNameInLayout()) ?>"
       class="block px-4 py-2 lg:px-5 lg:py-2 hover:bg-gray-100 text-black font-inter"
       href="<?= $escaper->escapeUrl($customerRegistration->getRegisterUrl()) ?>"
       title="<?= $escaper->escapeHtmlAttr($label) ?>"
    >
        <?= $escaper->escapeHtml($label) ?>
    </a>
<?php endif; ?>
