<?php
/**
 * @category    FishPig
 * @package     FishPig_WordPress
 * @author      Ben Tideswell <help@fishpig.co.uk>
 */
// phpcs:ignoreFile -- long lines (todo)
?>
<?php $post = $block->getPost() ?>
<?php $comments = $block->getComments() ?>
<?php if (count($comments) > 0): ?>
    <ol class="comment-list<?php if ($block->getParentId()): ?> children<?php endif; ?>">
        <?php foreach ($comments as $comment): ?>
            <li class="comment-list-item" id="comment-<?= (int)$comment->getId() ?>">
                <div class="comment-list-item-wrapper">
                    <?php if ($avatarUrl = $comment->getAvatarUrl(75)): ?>
                        <div class="comment-image gravatar">
                            <img src="<?= $block->escapeUrl($avatarUrl) ?>" alt="<?= $block->escapeHtml($comment->getCommentAuthor()) ?>" />
                        </div>
                    <?php endif; ?>
                    <div class="comment-meta">
                        <div class="comment-author">
                            <?php if ($comment->getCommentAuthorUrl() !== '#'): ?>
                                <a href="<?= $block->escapeHtml($comment->getCommentAuthorUrl()) ?>" rel="nofollow" class="comment-url"><?= $block->escapeHtml($comment->getCommentAuthor()) ?></a> 
                            <?php else: ?>
                                <span class="comment-url"><?= $block->escapeHtml($comment->getCommentAuthor()) ?></span>
                            <?php endif; ?>
                        </div>
                        <div class="comment-date">
                            <a href="<?= $block->escapeUrl($comment->getUrl()) ?>" rel="nofollow" class="comment-when"><?= $block->escapeHtml(__('%1 at %2', $comment->getCommentDate(), $comment->getCommentTime())) ?></a>
                        </div>
                    </div>
                    <div class="comment-entry"><?= $block->escapeHtml($block->getCommentContent($comment), ['br', 'a']) ?></div>
                    <?php if ($block->canComment()): ?>
                        <div class="reply">
                            <a href="#respond" onclick="document.getElementById('comment_parent').value=<?= (int)$comment->getId() ?>;" class="comment-reply-link"><?= $block->escapeHtml(__('Reply')) ?></a> <span>&darr;</span>
                        </div>
                    <?php endif; ?>
                </div>
                <?= $block->getChildrenCommentsHtml($comment) ?>
            </li>
        <?php endforeach; ?>
    </ol>
<?php endif; ?>