{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{% trans_default_domain ea.i18n.translationDomain %}

<!DOCTYPE html>
<html lang="{{ ea.i18n.htmlLocale }}" dir="{{ ea.i18n.textDirection }}">
<head>
    {% block head_metas %}
        <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"/>
    {% endblock head_metas %}

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

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

    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&amp;display=fallback">

    {% block configured_stylesheets %}
        {% for css_asset in ea.assets.cssFiles ?? [] %}
            <link rel="stylesheet" href="{{ asset(css_asset) }}">
        {% endfor %}
        {% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %}
            {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }}
        {% endfor %}
    {% endblock %}

    {% block head_favicon %}
        <link rel="shortcut icon" href="{{ asset(ea.dashboardFaviconPath) }}">
    {% endblock %}

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


    {# {% if 'rtl' == ea.i18n.textDirection %}
        <link rel="stylesheet" href="{{ asset('bundles/easyadmin/app.rtl.css') }}">
        <link rel="stylesheet" href="{{ asset('bundles/easyadmin/app-custom-rtl.css') }}">
    {% endif %} #}

    {# CKEditor #}
    <script type="text/javascript">
        var CKEDITOR_BASEPATH = "{{ ckeditor_base_path("/bundles/fosckeditor/") }}";
    </script>
    <script type="text/javascript" src="{{ asset('bundles/fosckeditor/ckeditor.js') }}"></script>

    {% block configured_head_contents %}
        {% for htmlContent in ea.assets.headContents ?? [] %}
            {{ htmlContent|raw }}
        {% endfor %}
    {% endblock %}
</head>

{% block body %}
    <body id="{% block body_id %}{% endblock %}"
          class="admin sidebar-mini layout-fixed {% block body_class %}{% endblock %}">

    {% block javascript_page_layout %}
        <script>
            document.body.classList.add(
                'ea-content-width-' + (localStorage.getItem('ea/content/width') || '{{ ea.crud.contentWidth ?? ea.dashboardContentWidth ?? 'normal' }}'),
                'ea-sidebar-width-' + (localStorage.getItem('ea/sidebar/width') || '{{ ea.crud.sidebarWidth ?? ea.dashboardSidebarWidth ?? 'normal' }}')
            );
        </script>
    {% endblock javascript_page_layout %}

    {% block wrapper_wrapper %}
        {% block flash_messages %}
            {{ include(ea.templatePath('flash_messages')) }}
        {% endblock flash_messages %}

        <div class="wrapper">
            {% block wrapper %}
                {% block navbar_header %}
                    {{ include('@LcSov/adminlte/block/navbar_header.html.twig') }}
                {% endblock %}

                <aside class="main-sidebar sidebar-dark-primary elevation-4">
                    {% block sidebar %}
                        {% block header_logo %}
                            <a class="brand-link text-center"
                               title="{{ ea.dashboardTitle|striptags }}"
                               href="{{ path(ea.dashboardRouteName) }}">
                                {{ logo_admin()|raw }}
                            </a>
                        {% endblock header_logo %}

                        <div class="sidebar">
                            {% block main_menu_wrapper %}
                                {{ include(ea.templatePath('main_menu')) }}
                            {% endblock main_menu_wrapper %}
                        </div>
                    {% endblock sidebar %}
                </aside>

                <div class="content-wrapper" style="min-height: 554px;">
                    {% block content %}
                        {% block content_header_wrapper %}
                            <section class="content-header">
                                <div class="container-fluid">
                                    <div class="row mb-2">

                                        {% set params_reminders = {crudAction: null, crudControllerFqcn: null, entityId: null} %}
                                        {% set params_reminders_null = params_reminders %}
                                        {% if ea is defined and ea %}
                                            {% if ea.crud is defined and ea.crud %}
                                                {% set params_reminders = params_reminders|merge({crudAction: ea.crud.currentAction}) %}
                                                {% set params_reminders = params_reminders|merge({crudControllerFqcn: ea.crud.controllerFqcn}) %}
                                            {% endif %}
                                            {% if ea.request.query.get('entityId') and ea.entity is defined and ea.entity.instance is defined %}
                                                {% set params_reminders = params_reminders|merge({entityId: ea.entity.instance.id}) %}
                                            {% endif %}
                                        {% endif %}

                                        {% block reminders %}
                                            {% if params_reminders_null != params_reminders %}
                                                {% set reminders = sov_reminders(params_reminders) %}
                                                {% include '@LcSov/admin/reminder/block.html.twig' %}
                                            {% endif %}
                                        {% endblock %}

                                        {% set has_help_message = (ea.crud.helpMessage ?? '') is not empty %}
                                        {% block content_header %}
                                            <div class="col-sm-6">
                                                <h1 class="m-0 text-dark">
                                                    {% block content_title %}{% endblock %}
                                                </h1>

                                                {% block content_breadcrumb %}
                                                {% endblock content_breadcrumb %}
                                                {# {% block content_help %}
                                                    {% if has_help_message %}
                                                        <div class="text-muted">
                                                            {{ ea.crud.helpMessage|e('html_attr') }}
                                                        </div>
                                                    {% endif %}
                                                {% endblock %} #}
                                            </div><!-- /.col -->
                                            <div class="col-sm-6">
                                                {% block page_actions_wrapper %}
                                                    <div class="btn-list float-sm-right">
                                                        {% block page_actions %}{% endblock %}
                                                    </div>
                                                {% endblock %}
                                            </div><!-- /.col -->
                                        {% endblock %}
                                    </div><!-- /.row -->
                                </div><!-- /.container-fluid -->
                            </section>
                        {% endblock %}

                        <section class="content">
                            <div class="container-fluid">
                                {% if replace_content_with_message is defined %}
                                    <div class="alert alert-warning" role="alert">
                                        {{ replace_content_with_message }}
                                    </div>
                                {% else %}
                                    {% block main %}{% endblock %}
                                {% endif %}
                            </div>
                        </section>
                    {% endblock %}
                </div>

                {% block footer %}
                    {% set content_footer = block('content_footer') is defined ? block('content_footer') : '' %}

                    <footer class="main-footer">
                        <div class="float-right d-none d-sm-block">
                            <b>SovBundle Version</b> 1.0
                        </div>
                        <strong>Copyright © {{ 'now'|date('Y') }} <a href="http://laclic.fr">La Clic</a>.</strong> All
                        rights
                        reserved.
                    </footer>
                {% endblock %}


            {% endblock wrapper %}
        </div>
    {% endblock wrapper_wrapper %}

    {% block configured_javascripts %}
        {% for js_asset in ea.assets.jsFiles ?? [] %}
            <script src="{{ asset(js_asset) }}"></script>
        {% endfor %}

        {% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %}
            {{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }}
        {% endfor %}
    {% endblock %}

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

    {% block configured_body_contents %}
        {% for htmlContent in ea.assets.bodyContents ?? [] %}
            {{ htmlContent|raw }}
        {% endfor %}
    {% endblock %}

    {% include '@LcSov/adminlte/block/modal_filemanager.html.twig' %}

    {% if app.session is not null and app.session.started %}
        {% set flash_messages = app.session.flashbag.all %}
        {% if flash_messages|length > 0 %}
            <script type="text/javascript">
                $(document).ready(function () {
                    {% for label, messages in flash_messages %}
                    {% for message in messages %}
                    SovNotification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}");
                    {% endfor %}
                    {% endfor %}
                });
            </script>
        {% endif %}
    {% endif %}

    {% block append_body %}{% endblock %}

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