{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider #}
{% extends ea.hasContext ? ea.templatePath('layout') : '@EasyAdmin/page/login_minimal.html.twig' %}
{% trans_default_domain ea.hasContext ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}

{% block body_class 'page-login' %}
{% block page_title %}{{ page_title is defined ? page_title|raw : (ea.hasContext ? ea.dashboardTitle|raw : '') }}{% endblock %}

{% block head_favicon %}
    {% if favicon_path|default(false) %}
        <link rel="shortcut icon" href="{{ favicon_path }}">
    {% else %}
        {{ parent() }}
    {% endif %}
{% endblock %}

{% block wrapper_wrapper %}
    {% set page_title = block('page_title') %}
    {% set _username_label = username_label is defined ? username_label|trans : 'login_page.username'|trans({}, 'EasyAdminBundle') %}
    {% set _password_label = password_label is defined ? password_label|trans : 'login_page.password'|trans({}, 'EasyAdminBundle') %}
    {% set _forgot_password_label = forgot_password_label is defined ? forgot_password_label|trans : 'login_page.forgot_password'|trans({}, 'EasyAdminBundle') %}
    {% set _remember_me_label = remember_me_label is defined ? remember_me_label|trans : 'login_page.remember_me'|trans({}, 'EasyAdminBundle') %}
    {% set _sign_in_label = sign_in_label is defined ? sign_in_label|trans : 'login_page.sign_in'|trans({}, 'EasyAdminBundle') %}

    {% include '@EasyAdmin/flash_messages.html.twig' %}

    <div class="login-wrapper">
        <header class="main-header">
            <div id="header-logo">
                {% block header_logo %}
                    {% if page_title %}
                        {% if ea.hasContext %}
                            <a class="logo {{ page_title|length > 14 ? 'logo-long' }}" title="{{ page_title|striptags }}" href="{{ path(ea.dashboardRouteName) }}">
                                {{ page_title|raw }}
                            </a>
                        {% else %}
                            <div class="logo {{ page_title|length > 14 ? 'logo-long' }}">
                                {{ page_title|raw }}
                            </div>
                        {% endif %}
                    {% endif %}
                {% endblock header_logo %}
            </div>
        </header>

        <section class="content">
            {% if error|default(false) %}
                <div class="w-100 alert alert-danger rounded mb-3">
                    {{ error.messageKey|trans(error.messageData, 'security') }}
                </div>
            {% endif %}

            <form method="post" action="{{ action|default('') }}">
                {% if csrf_token_intention|default(false) %}
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token(csrf_token_intention) }}">
                {% endif %}

                <input type="hidden" name="{{ target_path_parameter|default('_target_path') }}" value="{{ target_path|default(ea.hasContext ? path(ea.dashboardRouteName) : '/') }}" />

                <div class="form-group">
                    <label class="form-control-label required" for="username">{{ _username_label }}</label>
                    <div class="form-widget">
                        <input type="text" id="username" name="{{ username_parameter|default('_username') }}" class="form-control" value="{{ last_username|default('') }}" required autofocus autocomplete="username">
                    </div>
                </div>

                <div class="form-group">
                    <label class="form-control-label required" for="password">{{ _password_label }}</label>
                    <div class="form-widget">
                        <input type="password" id="password" name="{{ password_parameter|default('_password') }}" class="form-control" required autocomplete="current-password">
                    </div>

                    {% if forgot_password_enabled|default(false) %}
                        <div class="form-text">
                            <a href="{{ forgot_password_path|default('#') }}">{{ _forgot_password_label }}</a>
                        </div>
                    {% endif %}
                </div>

                {% if remember_me_enabled|default(false) %}
                    <div class="form-group">
                        <input class="form-check-input" type="checkbox" id="remember_me" name="{{ remember_me_parameter|default('_remember_me') }}" {{ remember_me_checked|default(false) ? 'checked' }}>
                        <label class="form-check-label" for="remember_me">
                            {{ _remember_me_label }}
                        </label>
                    </div>
                {% endif %}

                <button type="submit" class="btn btn-primary btn-lg btn-block">{{ _sign_in_label }}</button>
            </form>

            <script src="{{ asset('login.js', constant('EasyCorp\\Bundle\\EasyAdminBundle\\Asset\\AssetPackage::PACKAGE_NAME')) }}"></script>
        </section>
    </div>
{% endblock %}
