{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_forms') }}
{{ attach_library('ui_patterns/form-form.form_lib') }}
{{ attach_library('ui_patterns/libraries.bs_card') }}

{# VARIABLES #}
{% set css_classes = [
  'card',
  'mb-3',
  'js-form-wrapper',
] %}

{% set summary_classes = [
  'card-header',
  required ? 'js-form-required',
  required ? 'form-required',
] %}

<details{{ attributes.addClass(css_classes) }}>

  {%- if summary_title -%}
    <summary {{ summary_attributes.addClass(summary_classes) }}>
      {{ summary_title }}
      {%- if required == 'before' -%}
        <span class="reqd">*</span>
      {%- endif -%}
    </summary>
  {%- endif -%}

  <div class="card-body">

    {% if description_content %}
      <small class="help-block fshb">
        {{ description_content }}
      </small>
    {% endif %}

    {%- if children -%}
      {{ children }}
    {%- endif -%}

    {%- if value -%}
      {{ value }}
    {%- endif -%}

    {% if errors %}
      <div class="alert alert-danger form-item--error-message">
        <strong>{{ errors }}</strong>
      </div>
    {% endif %}

  </div>

</details>
