{# Keep track of the outer group field #}
{% set repeaterField = field %}

{% if value %}
    <div style="margin: 1em 0;">
        <table style="width: 100%; margin: 1em 0; border-collapse: collapse;">
            {% for row in value %}
                <thead>
                    {% if not loop.first %}
                        <tr>
                            <th colspan="2">&nbsp;</th>
                        </tr>
                    {% endif %}

                    <tr>
                        <th style="text-align: left; font-size: inherit; padding: 4px; border: 1px solid;" colspan="2">
                            {{- 'Row #{row}' | t('formie', { row: loop.index }) -}}
                        </th>
                    </tr>
                </thead>

                <tbody>
                    {% for field in field.getFields() %}
                        {# Update the namespace for the field, to include the specific block index #}
                        {% do field.setParentField(repeaterField, loop.parent.loop.index0) %}

                        {% set fieldValue = submission.getFieldValue(field.fieldKey) ?? field.normalizeValue(field.getDefaultValue(), null) %}

                        {% set html = field.getEmailHtml(submission, notification, fieldValue) %}

                        {% if html %}
                            <tr>
                                <th style="text-align: left; font-size: inherit; width: 30%; padding: 4px; border: 1px solid; background-color: rgba(0, 0, 0, 0.05);">
                                    {% if field.hasLabel %}
                                        {{ field.label | t('formie') }}
                                    {% endif %}
                                </th>

                                <td style="padding: 4px; border: 1px solid;">
                                    {{ html | raw }}
                                </td>
                            </tr>
                        {% endif %}
                    {% endfor %}
                </tbody>
            {% endfor %}
        </table>
    </div>
{% endif %}