<?php
declare(strict_types=1);

/**
 * @var \Magento\Framework\View\Element\Template $block
 * @var \Magento\Framework\Escaper $escaper
 * @var \ClawRock\Debug\Model\Collector\CustomerCollector $collector
 */
$collector = $block->getCollector();
?>
<div class="sf-toolbar-block sf-toolbar-block-<?= /* @noEscape */ $collector->getName() ?>">
    <div class="sf-toolbar-icon">
        <img src="<?= /* @noEscape */ $block->getViewFileUrl('ClawRock_Debug::images/collector/customer.svg'); ?>"
             alt="<?= $escaper->escapeHtmlAttr(__('Customer')) ?>"/>
        <span class="sf-toolbar-value">
            <?php if ($collector->isLoggedIn()): ?>
                <?= /* @noEscape */ $collector->getCustomerEmail(); ?>
            <?php else: ?>
                <?= $escaper->escapeHtml(__('@guest')); ?>
            <?php endif; ?>
        </span>
    </div>
    <div class="sf-toolbar-info">
        <?php if ($collector->isLoggedIn()): ?>
            <div class="sf-toolbar-info-piece">
                <strong><?= $escaper->escapeHtml(__('Logged in as')); ?></strong>
                <span><?= /* @noEscape */ $collector->getCustomerEmail(); ?></span>
            </div>
            <div class="sf-toolbar-info-piece">
                <strong><?= $escaper->escapeHtml(__('Name')); ?></strong>
                <span>
                    <?= /* @noEscape */ $collector->getCustomerName(); ?>&nbsp;
                    #<?= /* @noEscape */ $collector->getCustomerId(); ?>
                </span>
            </div>
        <?php endif; ?>
        <div class="sf-toolbar-info-piece">
            <strong><?= $escaper->escapeHtml(__('Customer Group')); ?></strong>
            <span>
                <?= /* @noEscape */ $collector->getCustomerGroupCode(); ?>&nbsp;
                #<?= /* @noEscape */ $collector->getCustomerGroupId(); ?>
            </span>
        </div>
        <div class="sf-toolbar-info-piece">
            <strong><?= $escaper->escapeHtml(__('Tax Class')); ?></strong>
            <span>
                <?= /* @noEscape */ $collector->getCustomerTaxClassName(); ?>&nbsp;
                #<?= /* @noEscape */ $collector->getCustomerTaxClassId(); ?>
            </span>
        </div>
        <div class="sf-toolbar-info-piece">
            <strong><?= $escaper->escapeHtml(__('Actions')); ?></strong>
            <?php if ($collector->isLoggedIn()): ?>
                <span>
                    <a href="<?= $escaper->escapeUrl($block->getUrl('customer/account/logout')); ?>">
                        <?= $escaper->escapeHtml(__('Logout')); ?>
                    </a>
                </span>
            <?php else: ?>
                <span>
                    <a href="<?= $escaper->escapeUrl($block->getUrl('customer/account/login')); ?>">
                        <?= $escaper->escapeHtml(__('Login')); ?>
                    </a>&nbsp;
                    <a href="<?= $escaper->escapeUrl($block->getUrl('customer/account/create')); ?>">
                        <?= $escaper->escapeHtml(__('Register')); ?>
                    </a>
                </span>
            <?php endif; ?>
        </div>
    </div>
</div>
