<!DOCTYPE html>
<html lang="{{ app.request.locale|split('_')|first|default('en') }}" dir="{{ easyadmin_config('design.rtl') ? 'rtl' : 'ltr' }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noodp, noimageindex, notranslate, nocache" />
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <meta name="generator" content="EasyAdmin" />

        <title>{% block page_title %}{{ block('content_title')|striptags|raw }}{% endblock %}</title>

        {% block head_stylesheets %}
            <link rel="stylesheet" href="{{ asset('bundles/easyadmin/app.css') }}">
        {% endblock %}

        {% block head_custom_stylesheets %}
            {% for css_asset in easyadmin_config('design.assets.css') %}
                <link rel="stylesheet" href="{{ asset(css_asset) }}">
            {% endfor %}
        {% endblock head_custom_stylesheets %}

        {% if easyadmin_config('design.brand_color') != 'hsl(230, 55%, 60%)' %}
        <style>
            :root { --color-primary: {{ easyadmin_config('design.brand_color') }}; }
        </style>
        {% endif %}

        {% block head_favicon %}
            {% set favicon = easyadmin_config('design.assets.favicon') %}
            <link rel="icon" type="{{ favicon.mime_type }}" href="{{ asset(favicon.path) }}" />
        {% endblock %}

        {% block head_javascript %}
            <script src="{{ asset('bundles/easyadmin/app.js') }}"></script>
        {% endblock head_javascript %}

        {% if easyadmin_config('design.rtl') %}
            <link rel="stylesheet" href="{{ asset('bundles/easyadmin/app.rtl.css') }}">
            <link rel="stylesheet" href="{{ asset('bundles/easyadmin/app-custom-rtl.css') }}">
        {% endif %}
    </head>

    {% block body %}
    <body id="{% block body_id %}{% endblock %}" class="easyadmin {% block body_class %}{% endblock %}">
        <script>
            document.body.classList.add(
                'easyadmin-content-width-' + (localStorage.getItem('easyadmin/content/width') || 'normal'),
                'easyadmin-sidebar-width-' + (localStorage.getItem('easyadmin/sidebar/width') || 'normal')
            );
        </script>

        {% block wrapper_wrapper %}
        <div class="wrapper">
        {% block wrapper %}
            <header class="main-header">
                {% block header %}
                    <nav class="navbar" role="navigation">
                        <button id="navigation-toggler" type="button" aria-label="Toggle navigation">
                            <i class="fa fa-fw fa-bars"></i>
                        </button>

                        <div id="header-logo">
                            {% block header_logo %}
                                <a class="logo {{ easyadmin_config('site_name')|length > 14 ? 'logo-long' }}" title="{{ easyadmin_config('site_name')|striptags }}" href="{{ path('easyadmin') }}">
                                    {{ easyadmin_config('site_name')|raw }}
                                </a>
                            {% endblock header_logo %}
                        </div>
                    </nav>

                    {% set _user_name = easyadmin_read_property(app.user, easyadmin_config('user.name_property_path'))|default('user.unnamed'|trans(domain = 'EasyAdminBundle')) %}
                    {% set _logout_path = easyadmin_logout_path() %}
                    {% set _user_has_logout = _logout_path is not empty %}
                    {% set _user_is_impersonated = is_granted('ROLE_PREVIOUS_ADMIN') %}
                    {% set _user_menu_content %}
                        <div class="popover-content-section user-details {{ _user_has_logout or _user_is_impersonated ? 'user-has-actions' }}">
                            <p class="small text-muted mb-0">{{ 'user.logged_in_as'|trans(domain = 'EasyAdminBundle') }}</p>
                            <p class="user-details-name">
                                {% if app.user|default(false) == false %}
                                    {{ 'user.anonymous'|trans(domain = 'EasyAdminBundle') }}
                                {% else %}
                                    {{ _user_name }}
                                {% endif %}
                            </p>
                        </div>

                        {% block user_menu %}
                            {% if _user_has_logout or _user_is_impersonated %}
                                <div class="popover-content-section user-menu">
                                    {% if _user_has_logout %}
                                        <a class="user-action user-action-logout" href="{{ _logout_path }}">{{ 'user.signout'|trans(domain = 'EasyAdminBundle') }}</a>
                                    {% endif %}
                                    {% if _user_is_impersonated %}
                                        <a class="user-action user-action-exit-impersonation" href="?_switch_user=_exit">{{ 'user.exit_impersonation'|trans(domain = 'EasyAdminBundle') }}</a>
                                    {% endif %}
                                </div>
                            {% endif %}
                        {% endblock user_menu %}
                    {% endset %}

                    <div class="content-top navbar-custom-menu">
                        {% block header_custom_menu %}
                            <div class="user user-menu-wrapper {{ _user_is_impersonated ? 'user-is-impersonated' }}" data-toggle="popover" data-placement="bottom" data-container=".user-menu-wrapper" data-content="{{ _user_menu_content|e('html_attr') }}" data-html="true">
                                {% if easyadmin_config('user.display_avatar') %}
                                    {% set _avatar_image_path = easyadmin_read_property(app.user, easyadmin_config('user.avatar_property_path')) %}
                                    {% if null == _avatar_image_path %}
                                        <i class="fa fa-fw {{ app.user is not null ? 'fa-user-circle' : 'fa-user-times' }} user-avatar"></i>
                                    {% else %}
                                        <img class="user-avatar" src="{{ _avatar_image_path }}" />
                                    {% endif %}
                                {% endif %}
                                {% if easyadmin_config('user.display_name') %}
                                    <span class="user-name">{{ _user_name }}</span>
                                {% endif %}
                            </div>
                        {% endblock header_custom_menu %}
                    </div>
                {% endblock header %}
            </header>

            <aside class="main-sidebar">
            {% block sidebar %}
                <section class="sidebar">
                    {% block main_menu_wrapper %}
                        {{ include([
                            _entity_config is defined ? _entity_config.templates.menu,
                            easyadmin_config('design.templates.menu'),
                            '@EasyAdmin/default/menu.html.twig'
                        ]) }}
                    {% endblock main_menu_wrapper %}
                </section>

            {% endblock sidebar %}
            </aside>

            <div class="content-wrapper">
                {% block flash_messages %}
                    {{ include(_entity_config is defined ? _entity_config.templates.flash_messages : '@EasyAdmin/default/flash_messages.html.twig') }}
                {% endblock flash_messages %}

                <div id="sidebar-resizer-handler" class="resizer-handler resizer-handler-left"></div>

                {% block content %}
                    <div class="content">
                        {% block content_header_wrapper %}
                        {% set _has_content_help = _entity_config is defined and _entity_config[app.request.query.get('action')]['help']|default(false) %}
                        <section class="content-header {{ _has_content_help ? 'has-content-help' }}">
                            {% block content_header %}
                                <div class="d-flex flex-row justify-content-between align-content-center w-100">
                                    <div class="content-header-title">
                                        <h1 class="title">{% block content_title %}{% endblock %}</h1>
                                    </div>

                                    {% block global_actions_wrapper %}
                                        <div class="global-actions">{% block global_actions %}{% endblock %}</div>
                                    {% endblock %}
                                </div>

                                {% block content_help %}
                                    {% if _entity_config is defined and _entity_config[app.request.query.get('action')]['help']|default(false) %}
                                        <div class="content-header-help">
                                            {{ _entity_config[app.request.query.get('action')]['help']|trans(domain = _entity_config.translation_domain)|raw }}
                                        </div>
                                    {% endif %}
                                {% endblock content_help %}
                            {% endblock content_header %}
                        </section>
                        {% endblock content_header_wrapper %}

                        <section id="main" class="content-body">
                            {% block main %}{% endblock %}
                        </section>

                        {% block content_footer_wrapper %}
                            <section class="content-footer">
                                {% block content_footer %}{% endblock %}
                            </section>
                        {% endblock %}
                    </div>
                {% endblock content %}

                <div id="content-resizer-handler" class="resizer-handler resizer-handler-right"></div>
            </div>
        {% endblock wrapper %}
        </div>
        {% endblock wrapper_wrapper %}

        {% block body_javascript %}{% endblock body_javascript %}

        {% block body_custom_javascript %}
            {% for js_asset in easyadmin_config('design.assets.js') %}
                <script src="{{ asset(js_asset) }}"></script>
            {% endfor %}
        {% endblock body_custom_javascript %}

    </body>
    {% endblock body %}
</html>
