{#
/**
 * @file
 * Dark+'s theme implementation to display a Product node in metro tile view mode.
 */
#}
{%
  set classes = [
    'node',
    'node--type-' ~ node.bundle|clean_class,
    node.isPromoted() ? 'node--promoted',
    node.isSticky() ? 'node--sticky',
    not node.isPublished() ? 'node--unpublished',
    view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
  ]
%}
{{ attach_library('darkplus/node-view-mode-metro-tile') }}

{% set caption_text_first = content.field_mt_prd_price %}
{% set caption_text_second = content.field_mt_prd_categories %}
{% set image = content.field_mt_prd_teaser_image %}
{% set rendered_content = content|without('field_mt_prd_teaser_image', 'field_mt_prd_categories', 'field_mt_prd_price') %}

{% set caption_items = "one-item" %}
{% if caption_text_first and caption_text_second %}
  {% set caption_items = "three-items" %}
{% elseif ( caption_text_first and not caption_text_second ) or ( not caption_text_first and caption_text_second ) %}
  {% set caption_items = "two-items" %}
{% endif %}

{% if image|render %}
  {% set view_row_index = elements['#mt_view_index'] %}
  {% set view_page_index = elements['#mt_view_page_index'] %}
  {% if view_page_index == 0 and (view_row_index == 2 or view_row_index == 3) %}

    {% set styled_image = image.0 %}
    {% set styled_image = styled_image|merge({'#image_style': 'mt_metro_tile_wide'}) %}
  {% else %}
    {% set styled_image = image %}
  {% endif %}
{% endif %}
{% include '@darkplus/partials/_mt-metro-tile.html.twig' %}
