{% load i18n static %}
<span class="djangocms-oidc">
    {% if djangocms_oidc_user_info %}
        {% translate "You are verified as" %} <span class="djangocms-oidc-verified_as">{% spaceless %}
            {% if instance.provider.account_url %}
                <a href="{{ instance.provider.account_url }}" class="djangocms-oidc-account {{ instance.provider.slug }}">{{ djangocms_oidc_verified_as }}</a>
            {% else %}
                {{ djangocms_oidc_verified_as }}
            {% endif %}
        {% endspaceless %}</span>.
        <a href="{% url 'djangocms_oidc_dismiss' %}" class="djangocms-oidc-dismiss {{ instance.provider.slug }}" title="{% spaceless %}
            {% blocktranslate with provider_name=instance.provider.name trimmed %}
                Dismiss data from {{ provider_name }}.
            {% endblocktranslate %}
        {% endspaceless %}">{% translate "Dismiss" %}</a>
        {% if all_required_handovered %}
            <a href="{% url 'djangocms_oidc_signup' instance.consumer_type instance.pk %}" class="djangocms-oidc-signup update-data {{ instance.provider.slug }}"
                data-consumer_type="{{ registration_consumer_info.consumer_type }}"
                data-client_id="{{ registration_consumer_info.client_id|default_if_none:"" }}"
                data-expires_at="{{ registration_consumer_info.expires_at|default_if_none:""|date:"c" }}">
                {% translate "Update data" %}
            </a>
        {% else %}
            <span class="all-required-not-handovered">
                <span>{% translate "Not all required data has been handovered." %}</span>
                <a href="{% url 'djangocms_oidc_signup' instance.consumer_type instance.pk 'consent' %}" class="djangocms-oidc-signup remaining-data {{ instance.provider.slug }}">
                    {% translate "Handover the remaining data" %}
                </a>
            </span>
        {% endif %}
        {% if instance.provider.logout_url %}
            <div>
                {% blocktranslate with logout_url=instance.provider.logout_url provider_name=instance.provider.name provider_slug=instance.provider.slug trimmed %}
                    You can also log out of provider <a href="{{ logout_url }}" class="djangocms-oidc-logout {{ provider_slug }}">{{ provider_name }}</a> if you wish.
                {% endblocktranslate %}
            </div>
        {% endif %}
    {% endif %}
    {% if user.is_authenticated %}
        {% if not djangocms_oidc_user_info %}
            <a href="{% url 'djangocms_oidc_signup' instance.consumer_type instance.pk %}"
                class="djangocms-oidc-signup {{ instance.provider.slug }}"
                title="{% translate "Pair my account with an identity provider" %}">{% spaceless %}
                {% if instance.button_label %}
                    {{ instance.button_label }}
                {% else %}
                    {% blocktranslate with provider_name=instance.provider.name trimmed %}
                        Pair by {{ provider_name }}
                    {% endblocktranslate %}
                {% endif %}
            {% endspaceless %}</a>
        {% endif %}
        <a href="{% url 'djangocms_oidc_logout' %}" class="logout-from-editation">{% translate "Logout" %}</a>
    {% else %}
        {% if instance.no_new_user %}
            <span class="pair-info">
                <a href="{% url 'login' %}" class="djangocms-oidc-login" title="{% translate "To pair your account with an identity provider, sign in first." %}">{% translate "Login" %}</a>
            </span>
            <a href="{% url 'djangocms_oidc_signup' instance.consumer_type instance.pk %}" class="djangocms-oidc-signup {{ instance.provider.slug }} login-required"
                data-consumer_type="{{ registration_consumer_info.consumer_type }}"
                data-client_id="{{ registration_consumer_info.client_id|default_if_none:"" }}"
                data-expires_at="{{ registration_consumer_info.expires_at|default_if_none:""|date:"c" }}">{% spaceless %}
                {% if instance.button_label %}
                    {{ instance.button_label }}
                {% else %}
                    {% blocktranslate with provider_name=instance.provider.name trimmed %}
                        Pair by {{ provider_name }}
                    {% endblocktranslate %}
                {% endif %}
            {% endspaceless %}</a>
        {% else %}
            <a href="{% url 'djangocms_oidc_signup' instance.consumer_type instance.pk %}" class="djangocms-oidc-signup {{ instance.provider.slug }}"
                data-consumer_type="{{ registration_consumer_info.consumer_type }}"
                data-client_id="{{ registration_consumer_info.client_id|default_if_none:"" }}"
                data-expires_at="{{ registration_consumer_info.expires_at|default_if_none:""|date:"c" }}">{% spaceless %}
                {% if instance.button_label %}
                    {{ instance.button_label }}
                {% else %}
                    {% blocktranslate with provider_name=instance.provider.name trimmed %}
                        Login by {{ provider_name }}
                    {% endblocktranslate %}
                {% endif %}
            {% endspaceless %}</a>
        {% endif %}
    {% endif %}
</span>
