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

{# VARIABLES #}
{% set status = status|default('secondary') %}
{% set type = type|default('dbl') %}
{% set initial_state = initial_state|default('on') %}
{% set type_class = 'tgl-sgl' %}
{% set hidden_class = 'display-hidden' %}
{% if type == 'dbl' %}
  {% set type_class = 'tgl-dbl btn-group' %}
  {% set hidden_class = 'disabled' %}
{% endif %}

{# TEMPLATE #}
<div class="{{ type_class }}" role="group" aria-label="Toggle auto update">
  <button type="button"
          id="{{ target }}-on"
          data-altcom-ajax-toggle="on"
          data-altcom-ajax-target="{{ target }}"
          class="button btn btn-{{ status }} btn-sm {{ initial_state == 'on' ? hidden_class }}"
    {{ initial_state == 'on' ? 'disabled' }} >
    {{ on|raw }}</button>
  <button type="button"
          id="{{ target }}-off"
          data-altcom-ajax-toggle="off"
          data-altcom-ajax-target="{{ target }}"
          class="button btn btn-{{ status }} btn-sm {{ initial_state == 'off' ? hidden_class }}"
    {{ initial_state == 'off' ? 'disabled' }} >
    {{ off|raw }}</button>
</div>
