{% load i18n %}

<tbody class="form-group relative {% if nested_inline %}group/nested{% else %}group/parent{% endif %} {% if forloop.revcounter == 2 and inline_admin_formset.has_add_permission %}last{% endif %} {% if inline_admin_form.original or inline_admin_form.show_url %}original{% else %}template{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form{% endif %}" {% if inline_admin_formset.opts.ordering_field %}x-sort:item{% endif %}>
    {% include "unfold/helpers/edit_inline/tabular_error.html" %}

    {% include "unfold/helpers/edit_inline/tabular_title.html" %}

    <tr class="form-row has-[.delete:checked]:[&+.form-delete]:table-row ">
        {% spaceless %}
            {% for fieldset in inline_admin_form %}
                {% for line in fieldset %}
                    {% for field in line %}
                        {% if not field.is_readonly and field.field.is_hidden %}
                            {{ field.field }}
                        {% endif %}
                    {% endfor %}
                {% endfor %}
            {% endfor %}
        {% endspaceless %}

        {% for fieldset in inline_admin_form %}
            {% for line in fieldset %}
                {% for field in line %}
                    {% if field.is_readonly or not field.field.is_hidden %}
                        <td{% if field.field.name %} class="min-h-[62.5px] align-middle border-b max-md:border-b border-base-200 {% if nested_inline %}lg:group-[.last]/nested:border-b-0{% elif not inline_admin_form.form.nested_formsets %}lg:group-[.last]/parent:border-b-0{% endif %} dark:border-base-800 field-{{ field.field.name }} group field-tabular {% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %} flex items-center before:capitalize before:font-semibold before:content-[attr(data-label)] before:text-font-important-light dark:before:text-font-important-dark before:mr-auto before:font-text before:pr-4 lg:before:hidden font-normal px-3 lg:first:pl-3 lg:last:pr-3 lg:px-1.5 text-left lg:table-cell {% if field.field.is_hidden %} hidden!{% endif %} {% if inline_admin_formset.opts.ordering_field and field.field.name == inline_admin_formset.opts.ordering_field and inline_admin_formset.opts.hide_ordering_field %}hidden!{% endif %}"{% endif %} data-label="{{ field.field.label }}">
                            {% include "unfold/helpers/edit_inline/tabular_field.html" %}
                        </td>
                    {% endif %}
                {% endfor %}
            {% endfor %}
        {% endfor %}

        {% include "unfold/helpers/edit_inline/tabular_delete.html" %}
    </tr>

    {% if inline_admin_form.original %}
        <tr class="hidden form-delete">
            <td colspan="100%">
                {% include "unfold/helpers/edit_inline/inline_delete_undo.html" %}
            </td>
        </tr>
    {% endif %}

    {% if inline_admin_form.form.nested_formsets %}
        <tr class="form-nested">
            <td class="bg-striped border-b border-base-200 relative dark:border-base-800 group-[.last]/parent:border-b-0" colspan="100%">
                <div class="flex flex-col p-3 gap-3 shadow-inner">
                    {% for nested_formset in inline_admin_form.form.nested_formsets %}
                        {% if nested_formset.inline_type == "tabular" %}
                            {% include "unfold/helpers/edit_inline/tabular_table.html" with inline_admin_formset=nested_formset nested_inline=True %}
                        {% elif nested_formset.inline_type == "stacked" %}
                            {% include "unfold/helpers/edit_inline/stacked_list.html" with inline_admin_formset=nested_formset nested_inline=True %}
                        {% endif %}
                    {% endfor %}
                </div>
            </td>
        </tr>
    {% endif %}
</tbody>
