{% extends "@MauticCore/FormTheme/form_tabbed.html.twig" %}
{% form_theme form _self %}
{% block channel_row %}
    {% if form.children.channel is defined %}
        {% set channel = form.children.channel.vars.data %}
        {% set enabled = form.children.isEnabled.vars.data %}
        {% set channelContent = customContent('channel.right', _context) %}
        {% set leftCol = channelContent ? 6 : 12 %}
        {% set enableCol = channelContent ? '' : 'col-md-2' %}
        {% set propsCol = channelContent ? '' : 'col-md-10' %}

        {{ form_row(form.children.channel) }}
        {{ form_errors(form) }}
        <div class="row">
            <div class="col-md-{{ leftCol }}">
                <div class="{{ enableCol }}">
                    {{ form_row(form.children.isEnabled) }}
                </div>
                <div class="{{ propsCol }}">
                    <div class="message_channel_properties_{{ channel }}{% if not enabled %} hide{% endif %}">
                        {% if form.children.channelId is defined %}
                            {{ form_row(form.children.channelId) }}
                        {% endif %}

                        {% if form.children.properties is defined and form.children.properties is not empty %}
                            {{ form_row(form.children.properties) }}
                        {% endif %}
                    </div>
                </div>
            </div>
            {% if channelContent %}
            <div class="col-md-6">
                {{ channelContent }}
            </div>
            {% endif %}
        </div>
    {% endif %}
{% endblock %}
{# active, id, name, content #}
{% set tabs, active = [], true %}
{% set _channel = '' %}
{% for channel, config in channels %}
    {% if form.channels[channel] is defined %}
        {% set tab = {
            'active'        : active,
            'id'            : 'channel_' ~ channel,
            'name'          : config.label,
            'content'       : form_row(form.channels[channel]),
            'containerAttr' : {
                'style' : 'min-height: 200px;',
            },
        } %}
        {% if formContainsErrors(form.channels[channel]) %}
            {% set tab = tab|merge({'class': 'text-danger', 'icon': 'ri-alert-fill'}) %}
        {% elseif form.channels[channel].isEnabled.vars.data %}
            {% set tab = tab|merge({'published': true}) %}
        {% endif %}

        {% set tabs, active = tabs|merge([tab]), false %}
    {% endif %}
{% endfor %}
{% set formTabs = tabs %}

{% block aboveTabsContent %}
<div class="pa-md row">
    <div class="col-md-12">
        {{ form_row(form.name) }}
        {{ form_row(form.description) }}
    </div>
</div>
{% endblock %}

{% block rightFormContent %}
{{ form_row(form.category) }}
{{ form_row(form.isPublished, {
    'attr': {
        'data-none': 'mautic.core.form.unavailable_regardless_of_scheduling',
        'data-start': 'mautic.core.form.available_on_scheduled_date',
        'data-both': 'mautic.core.form.available_during_scheduled_period',
        'data-end': 'mautic.core.form.available_until_scheduled_end'
    }
}) }}
{{ form_row(form.publishUp, {'label': 'mautic.core.form.available.available_from'}) }}
{{ form_row(form.publishDown, {'label': 'mautic.core.form.available.unavailable_from'}) }}
{% endblock %}
{% block _content %}{% endblock %}