{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_collapse') }}
{{ attach_library('ui_patterns/menu_ac.menu_ac_lib') }}

{# VARIABLES #}
{% set attributes = attributes|default(create_attribute()) %}

{# TEMPLATE #}
{% if links %}
  <div class="nav-sidebar">

    {% if title %}
      <h2>
        {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
          "text": title,
          "url": url,
          "icon_right": "fas fa-angle-down",
          "class": "nav-title-link",
        } only %}
      </h2>
    {% endif %}

    <nav aria-label="Sidebar menu">
      <ul {{ attributes.addClass('ulc') }} >
        {% for link in links %}
          {% include "@organisms/tm-menu/menu-ac/menu-ac-item.twig" with {
            "lid": link['lid'],
            "title": link['title'],
            "url": link['url'],
            "sub_links": link['sub_links'],
            "in_active_trail": link['in_active_trail'],
            "active": link['active'],
            "expanded": link['expanded'],
          } only %}
        {% endfor %}
      </ul>
    </nav>

  </div>
{% endif %}
