{% set isLiveComments = isLiveComments is defined %}
{% set showBanners = showBanners is defined and not isLiveComments %}
{% for comment in comments %}
{{ _self.recursiveComment(comment, isLiveComments, 1) }}
{% if showBanners %}
<span id="commentBannerPlaceHolder{{ loop.index }}" class="hidden"></span>
{% endif %}
{% endfor %}
{% if pagination is defined and pagination %}
{{ pagination|raw }}
{% endif %}
{% if hasMore and comments|length > 0 %}
<div id="afterCommentsBlock" class="row no-gutters">
{% set lastEntityID = 0 %}
{% set lastComment = comments|last %}
{% set showAddCommentBtn = not isLiveComments and not is_granted(constant('Slivki\\Entity\\UserGroup::COMMENTS_BANNED_ROLE_NAME')) and lastComment.getTypeID() != constant('Slivki\\Entity\\Comment::TYPE_MALL_BRAND_COMMENT') %}
{% if not isLiveComments %}
{% set lastEntityID = comments|last.getEntityID() %}
{% set lastComment = comments|last %}
{% endif %}
<div class="{{ showAddCommentBtn ? 'col-6' : 'col-12' }} p-1">
<button class="btn btn-block alt-font bg-white border" onclick="loadComments({{ lastEntityID }}, {{ lastComment.getID() }}, {{ lastComment.getTypeID() }}{{ categoryID is defined ? ', ' ~ categoryID }}{{ directorID is defined ? ', ' ~ directorID }})">Еще отзывы</button>
</div>
<div class="col-6 p-1">
{% if showAddCommentBtn %}
<a class="btn btn-block text-dark bg-slivki" href="/ostavit-otziv/{{ lastComment.getTypeID() }}/{{ lastEntityID }}">Добавить отзыв</a>
{% endif %}
</div>
</div>
{% endif %}
{% macro recursiveComment(comment, isLiveComments, level) %}
{% include 'Slivki/mobile/comment/item.html.twig' %}
{% for child in comment.getChildren()|filter(child => not child.isHidden() and child.isConfirmedPhone()) %}
{{ level == 1 ? '<div class="child-comment">' }}
{{ _self.recursiveComment(child, isLiveComments, level + 1) }}
{{ level == 1 ? '</div>' }}
{% endfor %}
{% endmacro %}