<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
/**
 * @var \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer $block
 * @var \Magento\Framework\Locale\LocaleFormatter $localeFormatter
 */
?>
<?php $_item = $block->getItem() ?>
<?php $_order = $block->getItem()->getOrderItem()->getOrder() ?>
<tr id="order-item-row-<?= (int) $_item->getId() ?>">
    <td class="col name" data-th="<?= $block->escapeHtmlAttr(__('Product Name')) ?>">
        <strong class="product name product-item-name"><?= $block->escapeHtml($_item->getName()) ?></strong>
        <?php if ($_options = $block->getItemOptions()): ?>
            <dl class="item-options">
            <?php foreach ($_options as $_option): ?>
                <dt><?= $block->escapeHtml($_option['label']) ?></dt>
                <?php if (!$block->getPrintStatus()): ?>
                    <?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
                    <dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
                        <?= $block->escapeHtml($_formatedOptionValue['value'], ['a']) ?>
                        <?php if (isset($_formatedOptionValue['full_view'])): ?>
                        <div class="tooltip content">
                            <dl class="item options">
                                <dt><?= $block->escapeHtml($_option['label']) ?></dt>
                                <dd><?= $block->escapeHtml($_formatedOptionValue['full_view']) ?></dd>
                            </dl>
                        </div>
                        <?php endif; ?>
                    </dd>
                <?php else: ?>
                    <dd>
                        <?= $block->escapeHtml($_option['print_value'] ?? $_option['value']) ?>
                    </dd>
                <?php endif; ?>
            <?php endforeach; ?>
            </dl>
        <?php endif; ?>

        <?php /* downloadable */ ?>
        <?php if ($links = $block->getLinks()): ?>
            <dl class="item options">
                <dt><?= $block->escapeHtml($block->getLinksTitle()) ?></dt>
                <?php foreach ($links->getPurchasedItems() as $link): ?>
                    <dd><?= $block->escapeHtml($link->getLinkTitle()) ?></dd>
                <?php endforeach; ?>
            </dl>
        <?php endif; ?>
        <?php /* EOF downloadable */ ?>

        <?php $addInfoBlock = $block->getProductAdditionalInformationBlock(); ?>
        <?php if ($addInfoBlock): ?>
            <?= $addInfoBlock->setItem($_item->getOrderItem())->toHtml() ?>
        <?php endif; ?>
        <?= $block->escapeHtml($_item->getDescription()) ?>
    </td>
    <td class="col sku" data-th="<?= $block->escapeHtml(__('SKU')) ?>">
        <?= /* @noEscape */ $block->prepareSku($block->getSku()) ?>
    </td>
    <td class="col price" data-th="<?= $block->escapeHtml(__('Price')) ?>">
        <?= $block->getItemPriceHtml() ?>
    </td>
    <td class="col qty" data-th="<?= $block->escapeHtml(__('Qty')) ?>">
        <?= /* @noEscape */ $localeFormatter->formatNumber((float) $_item->getQty()) ?>
    </td>
    <td class="col subtotal" data-th="<?= $block->escapeHtml(__('Subtotal')) ?>">
        <?= $block->getItemRowTotalHtml() ?>
    </td>
    <td class="col discount" data-th="<?= $block->escapeHtml(__('Discount Amount')) ?>">
        <?= /* @noEscape */ $_order->formatPrice(-$_item->getDiscountAmount()) ?>
    </td>
    <td class="col total" data-th="<?= $block->escapeHtml(__('Row Total')) ?>">
        <?= $block->getItemRowTotalAfterDiscountHtml() ?>
    </td>
</tr>
