<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\CardRendererInterface;

/** @var CardRendererInterface|Template $block */

$ccNumberView = $block->escapeHtml($block->getNumberLast4Digits());
?>
<tr>
    <td data-th="<?= $block->escapeHtml(__('Card Number')) ?>" class="col card-number">
        <span><?= $block->escapeHtml(__('ending')) ?></span> <?= /* @noEscape */ $ccNumberView ?>
    </td>
    <td data-th="<?= $block->escapeHtml(__('Expiration Date')) ?>" class="col card-expire">
        <?= $block->escapeHtml($block->getExpDate()) ?>
    </td>
    <td data-th="<?= $block->escapeHtml(__('Type')) ?>" class="col card-type">
        <img src="<?= /* @noEscape */ $block->getIconUrl() ?>"
             width="<?= /* @noEscape */ $block->getIconWidth() ?>"
             height="<?= /* @noEscape */ $block->getIconHeight() ?>"
        >
    </td>
    <td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
        <form
            class="form"
            action="<?= $block->escapeUrl($block->getUrl('vault/cards/deleteaction')) ?>"
            method="post"
            >
            <?= $block->getBlockHtml('formkey') ?>
            <input
                name="<?= /* @noEscape */ PaymentTokenInterface::PUBLIC_HASH ?>"
                value="<?= /* @noEscape */ $block->getToken()->getPublicHash() ?>"
                type="hidden"/>
            <button type="submit"
                    class="action delete"
                    data-mage-init='{
                                    "Magento_Vault/js/customer_account/deleteWidget":{
                                        "type": "popup",
                                        "modalClass": "my-credit-cards-popup",
                                        "toggleEvent": "click",
                                        "title": "<?= $block->escapeHtml(__('Delete')) ?>",
                                        "content": "<?= $block->escapeHtml(__('Are you sure you want to delete this card: %1?', $ccNumberView)) ?>"
                                    }
                                }'>
                <span><?= $block->escapeHtml(__('Delete')) ?></span>
            </button>
        </form>
    </td>
</tr>
