{#
  Parameters:
    - title: (string) (default: '')
    - title_tag: (string) (default: 'h1')
    - title_link: (link object) (default: {})
    - title_attributes: (drupal attrs)
    - background: (string) (default: 'white')
      options: [ white, gray ]
    - image (object) (default: {})
    - image_size: (string) (default: 'md')
      options: ['md', 'lg', 'xl']
    - date: (date block object) (default: {})
    - copyright: (string) (default: '')
    - copyright_label: (string) (default: '')

    Card inheritance
      - badges (badge[]) (default: [])
      - links (link[]) (default: [])
      - content (string) (default: '')
      - subtitle (object) (default: {})
        format: {
          content: '',
          tag: '',
          classes: ''
        }
      - text (object) (default: {})
        format: {
          content: '',
          tag: '',
          classes: ''
        }

    - attributes: (drupal attrs)

  Blocks
    - "action_bar" (string)
#}

{%- set _title = title|default('') %}
{% set _title_tag = title_tag|default('h1') %}
{% set _title_link = title_link|default({}) %}
{% set _title_attributes = title_attributes ?: create_attribute() %}
{% set _background = background|default('white') %}
{% set _image = image|default({}) %}
{% set _image_size = image_size|default('md') %}
{% set _action_bar = action_bar|default('') %}
{% set _date = date|default({}) %}
{% set _copyright = copyright|default('') %}
{% set _copyright_label = copyright_label|default('') %}
{%- set _action_bar_content -%}
  {%- block action_bar -%}
    {{ _action_bar }}
  {%- endblock -%}
{%- endset -%}

{%- if attributes is empty %}
  {%- set attributes = create_attribute() %}
{% endif %}

{%- set _classes = [
  'bcl-content-banner',
] %}

{%- if _background != 'white' %}
  {%- set _classes = _classes|merge([
    'pb-md-4-75',
    'pb-4',
    'pt-4',
    'pt-md-4-75',
  ]) %}
{% else %}
  {%- set _classes = _classes|merge([
    'pt-4',
    'pt-md-4-75',
  ]) %}
{% endif %}

{%- set _modifiers = {
  'white': 'bg-white',
  'gray': 'bg-lighter',
} %}

{%- set _body_classes = 'pt-0 px-0 pb-0' %}
{% set _right_col_classes = 'col-md col-lg-9 col-xxl-8' %}

{%- if _image is not empty %}
  {%- set _left_col_classes = 'bcl-card-start-col' %}
  {%- set _body_classes = 'pt-4 pt-md-0 px-0 px-md-1-5 pb-0' %}
  {%- if _image_size == 'lg' %}
    {%- set _left_col_classes = _left_col_classes ~ ' bcl-size-large' %}
    {%- set _right_col_classes = 'col-md col-xl-9 col-xxl-8' %}
  {%- endif %}
  {%- if _image_size == 'xl' %}
    {%- set _left_col_classes = _left_col_classes ~ ' bcl-size-extra-large' %}
    {%- set _body_classes = 'pt-4 pt-lg-0 px-0 px-lg-1-5 pb-0' %}
    {%- set _right_col_classes = 'col-lg' %}
  {%- endif %}
{% endif %}
{% if _date is not empty %}
  {%- set _left_col_classes = 'bcl-card-start-col' %}
  {%- set _right_col_classes = 'col-12 col-md col-xxl-9' %}
  {%- if _image is empty %}
    {%- set _body_classes = 'pt-4 pt-md-0 px-0 px-md-1-5 pb-0' %}
  {%- endif %}
{% endif %}
{% if _image is empty and _date is empty %}
  {%- set _right_col_classes = 'col-lg-10 col-xl-9 col-xxl-8' %}
{% endif %}

{%- set _horizontal_classes = {
  left_col_classes: _left_col_classes,
  right_col_classes: _right_col_classes,
} %}

{%- set _card = {
  title: _title,
  title_tag: _title_tag,
  title_link: _title_link,
  title_attributes: _title_attributes.addClass('fs-1'),
  horizontal: true,
  horizontal_grid: _horizontal_classes,
  extra_classes_header: 'bg-transparent pt-0 pb-0 border-0',
  extra_classes_body: _body_classes,
  image_copyright: _copyright,
  image_copyright_label: _copyright_label,
  attributes: create_attribute().addClass(['bg-transparent', 'border-0']),
} %}

{%- set _classes = _classes|merge([_modifiers[_background]]) %}
{% set attributes = attributes.addClass(_classes) %}

{%- if _button is not empty %}
  {%- set _card =  _card|merge({
    attributes: _card.attributes.addClass(['col-md-10']),
  }) %}
{% endif -%}

<div {{ attributes }}>{# -#}
  <div class="container">
  {%- include '@oe-bcl/bcl-card/card.html.twig' with _card %}
    {%- if _action_bar_content|trim is not empty -%}
      <div class="position-relative z-1">{# -#}
        {{- _action_bar_content -}}
      </div>{# -#}
    {%- endif -%}
  </div>{# -#}
</div>
{#--#}
