{#
/**
 * @file
 * Dark+'s theme implementation to display a block.
 *
 * Available variables:
 * - plugin_id: The ID of the block implementation.
 * - label: The configured label of the block if visible.
 * - configuration: A list of the block's configuration values.
 *   - label: The configured label for the block.
 *   - label_display: The display settings for the label.
 *   - module: The module that provided this block plugin.
 *   - cache: The cache settings.
 *   - Block plugin specific settings will also be stored here.
 * - content: The content of this block.
 * - attributes: array of HTML attributes populated by modules, intended to
 *   be added to the main container tag of this template.
 *   - id: A valid HTML ID and guaranteed unique.
 * - title_attributes: Same as attributes, except applied to the main title
 *   tag that appears in the template.
 * - content_attributes: Same as attributes, except applied to the main content
 *   tag that appears in the template.
 * - title_prefix: Additional output populated by modules, intended to be
 *   displayed in front of the main title tag that appears in the template.
 * - title_suffix: Additional output populated by modules, intended to be
 *   displayed after the main title tag that appears in the template.
 *
 * @see template_preprocess_block()
 *
 * @ingroup themeable
 */
#}
{{ attach_library('darkplus/hero-v2-block') }}
{%
  set classes = [
    'block',
    'block-' ~ configuration.provider|clean_class,
    'block-' ~ plugin_id|clean_class,
    'block-mt-hero-v2'
  ]
%}
{%
  set title_classes = [
    'title'
  ]
%}
{% set column_first_order = null %}
{% set column_second_order = null %}
{% set column_first_grid_classes = null %}
{% set column_second_grid_classes = null %}
{% set mt_vertical_aligment = content['#block_content'].field_mt_hero_v2_ver_alignment.value %}
{% if content['#block_content'].field_mt_hero_v2_hor_alignment.value == "image-right" %}
  {% set column_first_order = "order-lg-1 order-2" %}
  {% set column_second_order = "order-lg-2 text-right" %}
{% else %}
  {% set column_first_order = "order-lg-2 order-2" %}
  {% set column_second_order = "order-lg-1" %}
{% endif %}
{% if content['#block_content'].field_mt_hero_v2_layout.value == "two-col-33-67" %}
  {% set column_first_grid_classes = "col-lg-4 pt-xl-4 pt-0 hero-column-first" %}
  {% set column_second_grid_classes = "col-lg-8 hero-column-second" %}
  {% set columns = "two-columns" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "two-col-42-58" %}
  {% set column_first_grid_classes = "col-lg-5 pt-xl-4 pt-0 hero-column-first" %}
  {% set column_second_grid_classes = "col-lg-7 hero-column-second" %}
  {% set columns = "two-columns" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "two-col-50-50" %}
  {% set column_first_grid_classes = "col-lg-6 pt-xl-4 pt-0 hero-column-first" %}
  {% set column_second_grid_classes = "col-lg-6 hero-column-second" %}
  {% set columns = "two-columns" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "two-col-58-42" %}
  {% set column_first_grid_classes = "col-lg-7 pt-xl-4 pt-0 hero-column-first" %}
  {% set column_second_grid_classes = "col-lg-5 hero-column-second" %}
  {% set columns = "two-columns" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "two-col-67-33" %}
  {% set column_first_grid_classes = "col-lg-8 pt-xl-4 pt-0 hero-column-first" %}
  {% set column_second_grid_classes = "col-lg-4 hero-column-second" %}
  {% set columns = "two-columns" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-60 mt-image-first" %}
  {% set column_first_grid_classes = "col-lg-6 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-6 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column image-first" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-80 mt-image-first" %}
  {% set column_first_grid_classes = "col-lg-8 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-8 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column image-first" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-100 mt-image-first" %}
  {% set column_first_grid_classes = "col-lg-12 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-12 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column image-first" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-60 mt-text-first" %}
  {% set column_first_grid_classes = "col-lg-6 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-6 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column text-first" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-80 mt-text-first" %}
  {% set column_first_grid_classes = "col-lg-8 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-8 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column text-first" %}
{% elseif content['#block_content'].field_mt_hero_v2_layout.value == "one-col-100 mt-text-first" %}
  {% set column_first_grid_classes = "col-lg-12 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set column_second_grid_classes = "col-lg-12 pt-lg-4 pt-0 mr-auto ml-auto text-center" %}
  {% set columns = "one-column text-first" %}
{% endif %}

<div{{ attributes.addClass(classes) }}>
  {{ title_prefix }}
  {% if label %}
    <h2{{ title_attributes.addClass(title_classes) }}>{{ label }}</h2>
  {% endif %}
  {{ title_suffix }}
  {% block content %}
    <div{{ content_attributes.addClass('content').addClass(columns).addClass(mt_vertical_aligment) }}>
      <div class="container">
        <div class="row {{ mt_vertical_aligment }}">
          <div class="{{ column_first_grid_classes }} {{ column_first_order }}">
            {% if columns == "one-column image-first" and content.field_mt_hero_v2_image|render %}
              <div class="mb-4 pb-5">
                {% if (content.field_mt_hero_v2_action|render and content['#block_content'].field_mt_hero_v2_action['0'].uri) %}
                  <div class="overlay-container">
                    <span class="overlay">
                      {% if content.field_mt_hero_v2_action['0']['#url'].isExternal() %}
                        <a target="_blank" class="overlay-target-link" href="{{ content['#block_content'].field_mt_hero_v2_action['0'].uri }}"></a>
                      {% else %}
                        <a class="overlay-target-link" href="{{ path(content.field_mt_hero_v2_action['0']['#url'].getRouteName(), content.field_mt_hero_v2_action['0']['#url'].getRouteParameters()) }}"></a>
                      {% endif %}
                    </span>
                    {{ content.field_mt_hero_v2_image }}
                  </div>
                {% else %}
                  {{ content.field_mt_hero_v2_image }}
                {% endif %}
              </div>
            {% endif %}
            {{ content|without('field_mt_hero_v2_image', 'field_mt_hero_v2_layout') }}
            {% if columns == "one-column text-first" and content.field_mt_hero_v2_image|render %}
              <div class="mt-4 pt-5">
                {% if (content.field_mt_hero_v2_action|render and content['#block_content'].field_mt_hero_v2_action['0'].uri) %}
                  <div class="overlay-container">
                    <span class="overlay">
                      {% if content.field_mt_hero_v2_action['0']['#url'].isExternal() %}
                        <a target="_blank" class="overlay-target-link" href="{{ content['#block_content'].field_mt_hero_v2_action['0'].uri }}"></a>
                      {% else %}
                        <a class="overlay-target-link" href="{{ path(content.field_mt_hero_v2_action['0']['#url'].getRouteName(), content.field_mt_hero_v2_action['0']['#url'].getRouteParameters()) }}"></a>
                      {% endif %}
                    </span>
                    {{ content.field_mt_hero_v2_image }}
                  </div>
                {% else %}
                  {{ content.field_mt_hero_v2_image }}
                {% endif %}
              </div>
            {% endif %}
          </div>
          {% if columns == "two-columns" and content.field_mt_hero_v2_image|render %}
            <div class="{{ column_second_grid_classes }}  {{ column_second_order }}">
                {% if (content.field_mt_hero_v2_action|render and content['#block_content'].field_mt_hero_v2_action['0'].uri) %}
                  <div class="overlay-container">
                    <span class="overlay">
                      {% if content.field_mt_hero_v2_action['0']['#url'].isExternal() %}
                        <a target="_blank" class="overlay-target-link" href="{{ content['#block_content'].field_mt_hero_v2_action['0'].uri }}"></a>
                      {% else %}
                        <a class="overlay-target-link" href="{{ path(content.field_mt_hero_v2_action['0']['#url'].getRouteName(), content.field_mt_hero_v2_action['0']['#url'].getRouteParameters()) }}"></a>
                      {% endif %}
                    </span>
                    {{ content.field_mt_hero_v2_image }}
                  </div>
                {% else %}
                  {{ content.field_mt_hero_v2_image }}
                {% endif %}
            </div>
          {% endif %}
        </div>
      </div>

    </div>
  {% endblock %}
</div>
