{% set classes = [
  'dropdown',
] %}

{% set dropdown_toggle_classes = [
  'dropdown-toggle',
]|merge(dropdown_toggle_extra_classes ?: []) %}

{% set dropdown_content_classes = [
  'w-max',
]|merge(dropdown_content_extra_classes ?: []) %}

{% set dropdown_item_classes = [
  'dropdown-item',
]|merge(dropdown_item_extra_classes ?: []) %}

<details {{ attributes.addClass(classes)}}>
  <summary class="{{ dropdown_toggle_classes|join(' ') }}">{{ toggle }}</summary>
  <ul class="{{ dropdown_content_classes|join(' ') }}" tabindex="0">
    {%- for item in items -%}
      <li class="{{ dropdown_item_classes|join(' ') }}">
        {% if item.is_expanded and item.below %}
          {{ link(item.title, item.url) }}
        <ul>
          {%- for item in item.below -%}
            <li>
              {{ link(item.title, item.url) }}
            </li>
          {%- endfor -%}
        </ul>
        {% else %}
          {{ link(item.title, item.url) }}
        {% endif %}
      </li>
    {%- endfor -%}
  </ul>
</details>
