{% set attributes = attributes | default(new_attributes()) %}
{% do attributes.setdefault(html_id=generate_html_id()) %}
{% do attributes.html_class.append('accordion') %}
{% if accordion_items | length > 0 %}
    <div {{ attributes }}>
        {% for item in accordion_items %}
            <div class="accordion-item">
                <{{ accordion_heading_element }} class="accordion-header{% if accordion_heading_class is defined %} {{ accordion_heading_class }}{% endif %}">
                    <button class="accordion-button" type="button" data-bs-toggle="collapse"
                            data-bs-target="#{{ attributes.html_id }}-{{ loop.index }}" aria-controls="{{ attributes.html_id }}-{{ loop.index }}">
                        {{ item['header'] }}
                    </button>
                </{{ accordion_heading_element }}>
                <div id="{{ attributes.html_id }}-{{ loop.index }}" class="accordion-collapse collapse" data-bs-parent="#{{ attributes.html_id }}">
                    <div class="accordion-body">
                        {{ item['body'] }}
                    </div>
                </div>
            </div>
        {% endfor %}
    </div>
{% endif %}
