{% set contact = this.getContact() %}

<section {{ attributes.defaults({ class: 'theme-legal-page' }) }}>
    <div class="theme-container">
        <article class="theme-legal-content">
            {% if contact %}
                {% if this.legal %}
                    {% set legalNoticeContent = this.legalNoticeContent %}
                    {% if legalNoticeContent|trim is not empty %}
                        <section class="theme-legal-block">
                            {{ legalNoticeContent|raw }}
                        </section>
                    {% else %}
                        <section class="theme-legal-block">
                            <p>{{ 'legal_pages.legal.empty'|trans }}</p>
                        </section>
                    {% endif %}

                    {% include '@components/legal/_agec.html.twig' with { contact: contact } only %}

                    <section class="theme-legal-block">
                        <h2>{{ 'legal_pages.links.title'|trans }}</h2>
                        <p class="theme-legal-link">
                            <a href="{{ path('private-policy') }}" title="{{ 'legal.button'|trans }}">
                                {{ 'legal.sections.personal_data.link'|trans }}
                            </a>
                        </p>
                        <p class="theme-legal-link">
                            <a href="{{ path('cgv') }}" title="{{ 'cgv.button'|trans }}">
                                {{ 'legal_pages.links.cgv'|trans }}
                            </a>
                        </p>
                    </section>

                    {% if contact.legalNoticeExtraParagraph|trim is not empty %}
                        <section class="theme-legal-block">
                            <p>{{ contact.legalNoticeExtraParagraph|nl2br }}</p>
                        </section>
                    {% endif %}
                {% elseif this.cgv %}
                    {% set cgvContent = this.cgvContent %}
                    <section class="theme-legal-block">
                        {% if cgvContent %}
                            {{ cgvContent|raw }}
                        {% else %}
                            <p>{{ 'legal_pages.cgv.empty'|trans }}</p>
                        {% endif %}
                    </section>

                    {% include '@components/legal/_agec.html.twig' with { contact: contact } only %}
                {% elseif this.privacyPolicy %}
                    {% set privacyPolicyContent = this.privacyPolicyContent %}
                    {% if privacyPolicyContent|trim is not empty %}
                        <section class="theme-legal-block">
                            {{ privacyPolicyContent|raw }}
                        </section>
                    {% else %}
                        <section class="theme-legal-block">
                            <p>{{ 'legal_pages.privacy_policy.empty'|trans }}</p>
                        </section>
                    {% endif %}

                    {% if contact.privacyPolicyExtraParagraph|trim is not empty %}
                        <section class="theme-legal-block">
                            <p>{{ contact.privacyPolicyExtraParagraph|nl2br }}</p>
                        </section>
                    {% endif %}
                {% endif %}
            {% else %}
                <p>{{ 'legal_pages.missing_contact'|trans }}</p>
            {% endif %}
        </article>
    </div>
</section>
