{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_collapse') }}
{{ attach_library('ui_patterns/sa_lb_section.sa_lb_section_lib') }}

{# LIBRARIES #}
{% set title = title|default("Important information") %}
{% set link_icon_left = link_icon_left|default('fas fa-exclamation-triangle') %}
{% set link_icon_right = link_icon_right|default(global_icon_right|default('fas fa-chevron-right')) %}
{% set dismiss = dismess|default("Dismiss") %}
{% set hide_dismiss = hide_dismiss|default(false) %}
{% set id = random() %}

{# TEMPLATE #}
{% if links %}
  <div id="sa-lb-section-{{ id }}" class="sa-lb-section {% if not hide_dismiss %}collapse show{% endif %}">
    <div class="sa-lb-section-inner row">
      <h2 class="col-sm-6">{{ title }}</h2>

      <div class="col-sm-6">
        {% if not hide_dismiss %}
          {% set dismiss_attr = create_attribute()
            .setAttribute('id', 'sa-lb-section-dismiss-' ~ id)
            .setAttribute('data-bs-toggle', 'collapse')
            .setAttribute('tabindex', '0')
            .setAttribute('role', 'button')
            .setAttribute('data-bs-target', "#sa-lb-section-" ~ id)
            .setAttribute('aria-expanded', 'true')
          %}
          {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
            "text": "Dismiss",
            "attr": dismiss_attr,
            "class": "sa-lb-section-dismiss belianu dismiss fr",
            "url": "#sa-lb-section-" ~ id,
            "icon_right": global_icon_up|default('fas fa-chevron-up'),
          } only %}
        {% endif %}
      </div>

      <!-- Link items -->
      {% for link in links %}
        <div class="col-md-6 col-sm-6">
          {% include "@organisms/tm-sa/sa-block-top/sa-block-top.twig" with {
            "text": link['text'],
            "url": link['url'],
            "extra": link['extra'],
            "intro": link['intro'],
            "block_status": link['block_status'],
            "icon_right": link_icon_right,
            "icon_left": link_icon_left,
          } only %}
        </div>
      {% endfor %}
      <!-- / Link items -->
    </div>
  </div>
{% endif %}
