{# ------------------------ #}
{# Available Variables #}
{# ------------------------ #}
{# Attributes: #}
{# type, name, handle, instructions, attribute, default, feed, feedData #}
{# ------------------------ #}
{# Fields: #}
{# name, handle, instructions, feed, feedData, field, fieldClass #}
{# ------------------------ #}

{% import 'feed-me/_macros' as feedMeMacro %}
{% import '_includes/forms' as forms %}

{% if field.useMultipleFields %}

    {# Special case when inside another complex field (Matrix) #}
    {% if parentPath is defined %}
        {% set prefixPath = parentPath %}
    {% else %}
        {% set prefixPath = [handle] %}
    {% endif %}

    {% set classes = ['complex-field'] %}

    <tr class="complex-field complex-field-header">
        <td class="col-field" colspan="3">
            <div class="field">
                <div class="heading">
                    <label class="">{{ name }}</label>
                </div>

                <div class="additional-mapping-fields">
                    {% namespace 'fieldMapping[' ~ prefixPath | join('][') ~ ']' %}
                        <input type="text" name="field" value="{{ className(field) }}">
                    {% endnamespace %}
                </div>
            </div>
        </td>
    </tr>

    {% for option in field.getFields() %}
        {% if option.enabled %}
            {% set nameLabel = option.label %}
            {% set instructionsHandle = handle ~ '[' ~ option.handle ~ ']' %}

            {% set path = prefixPath | merge ([ 'fields', option.handle ]) %}

            {% set default = default ?? {
                type: 'text',
            } %}

            {% embed 'feed-me/_includes/fields/_base' %}
                {% block additionalFieldSettings %}

                {% endblock %}

                {% block fieldSettings %}

                {% endblock %}
            {% endembed %}
        {% endif %}
    {% endfor %}
{% else %}
    {% include 'feed-me/_includes/fields/_base' %}
{% endif %}