{#
/**
 * @file
 * Theme override of a datetime form wrapper.
 *
 * @todo Refactor when https://www.drupal.org/node/3010558 is fixed.
 *
 * @see template_preprocess_form_element()
 */
#}
{% set show_description_toggle = description_toggle and description %}
{%
  set classes = [
    'form-item',
    'form-datetime-wrapper',
    show_description_toggle ? 'help-icon__description-container',
  ]
  %}
{%
  set title_classes = [
    'form-item__label',
    required ? 'js-form-required',
    required ? 'form-required',
    errors ? 'has-error',
  ]
%}
{%
  set description_classes = [
    'form-item__description',
    description_display == 'invisible' ? 'visually-hidden',
  ]
%}
<div {{ attributes.addClass(classes) }}>
  {% if show_description_toggle %}
  <div class="help-icon">
  {% endif %}
  {% if title %}
  <h4{{ title_attributes.addClass(title_classes) }}>{{ title }}</h4>
  {% endif %}
  {% if show_description_toggle %}
    {{ attach_library('gin/gin_description_toggle') }}
    <button class="help-icon__description-toggle"></button>
  </div>
  {% endif %}
  {{ content }}
{% if errors %}
  <div class="form-item__error-message">
    {{ errors }}
  </div>
{% endif %}
{% if description %}
  <div{{ description_attributes.addClass(description_classes) }}>
    {{ description }}
  </div>
{% endif %}
</div>
