{% extends theme_base_filename %}
{% load static i18n combo gadjo pwa thumbnail assets %}

{% block meta_icons %}
  {% if favicon %}
    <link rel="shortcut icon" href="{{site_base}}{% static "" %}{{favicon}}" />
  {% elif pwa_settings.application_icon %}
    <link rel="shortcut icon"
        {% thumbnail pwa_settings.application_icon '32x32' crop='center' format='PNG' as im %}
        href="{{ site_base }}{{ im.url }}"/>
        {% endthumbnail %}
  {% endif %}
  {% if pwa_settings.application_icon %}
    {% for icon_size in pwa_settings.APPLICATION_ICON_SIZES %}
      <link rel="apple-touch-icon" sizes="{{icon_size}}"
        {% thumbnail pwa_settings.application_icon icon_size crop='center' format='PNG' as im %}
        href="{{ site_base }}{{ im.url }}">
        {% endthumbnail %}
    {% endfor %}
  {% else %}
    {% for icon_size in icon_sizes %}
      <link rel="apple-touch-icon" sizes="{{icon_size}}x{{icon_size}}"
        href="{{ site_base }}{% static "" %}{{ css_variant }}/{{ icon_prefix }}{{ icon_size }}px.png">
    {% endfor %}
  {% endif %}
{% endblock %}

{% block extra_top_head %}
{{ block.super }}
{% block extra_top_head_js %}
<script src="{{site_base}}{% xstatic 'jquery' 'jquery.min.js' %}"></script>
{% endblock %}
{% skeleton_extra_placeholder extra-top-head %}
{% end_skeleton_extra_placeholder %}
{% if page.picture %}
<style>
:root {
  --page-picture: url("{{site_base}}{{page.picture.url}}");
}
{% block msie_css_page_picture %}
{# IE11 doesn't support CSS variable and supports() API, so we set it here #}
{# and themes that do need a different CSS will have to redefine the       #}
{# msie_css_page_picture block.                                            #}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  body.has-picture nav::after {
    background-image: url("{{site_base}}{{page.picture.url}}");
  }
}
{% endblock %}
</style>
{% endif %}
{% endblock %}

{% block extra_scripts %}
{% if portal_agent_url and portal_agent_title %}
<script>
const PUBLIK_PORTAL_AGENT_URL = "{{portal_agent_url|escapejs}}";
const PUBLIK_PORTAL_AGENT_TITLE = "{{portal_agent_title|escapejs}}";
</script>
{% endif %}
<script src="{{site_base}}{% static 'js/combo.public.js' %}?{% start_timestamp %}" async></script>
<script src="{{site_base}}{% static 'js/combo.back.js' %}?{% start_timestamp %}" async></script>
{% if not no_extra_js %}
<script src="{{site_base}}{% static "" %}{{css_variant}}/extra.js?{% start_timestamp %}" async></script>
{% endif %}
{% skeleton_extra_placeholder extra-head %}
{% end_skeleton_extra_placeholder %}
{% endblock %}

{% block bodyattrs %}
data-api-root="{{ site_base }}/api/"
{% if check_badges %}data-check-badges="true"{% endif %}
{% if page.picture %}data-picture="{{site_base}}{{page.picture.url}}"{% endif %}
{% skeleton_extra_placeholder extra-body-args %}
{% end_skeleton_extra_placeholder %}
{% endblock %}

{% block bodyclasses %}
  {% if pwa_display %}{% pwa_navigation as pwa_navigation %}{% if pwa_navigation %}has-pwa-navigation{% endif %}{% endif %}
  {% get_asset "header:background" as header_background %}{% if header_background %}has-header-background{% endif %}
  page-{{ page.slug }}
  page-template-{{ page.template_name }}
  {% with pages.0.slug as section %}{% if section %}section-{{section}}{% endif %}{% endwith %}
  {% if page.picture %}has-picture{% endif %}
  {% skeleton_extra_placeholder extra-body-class %}
    {% if user.is_authenticated %}authenticated-user{% else %}anonymous-user{% endif %}
  {% end_skeleton_extra_placeholder %}
{% endblock %}

{% block title %} - {% if render_skeleton %}{% skeleton_extra_placeholder title %}{% firstof page_title site_title %}{% end_skeleton_extra_placeholder %}{% else %}{{page.title}}{% endif %}{% endblock %}

{% block header-title %}
  {% get_asset "header:logo" as header_logo %}
  <h1 id="logo" class="{% if header_logo %}has-logo{% endif %}">
    <a title="Accueil - {% firstof global_title site_title "Compte Citoyen" %}" accesskey="1" href="{% firstof logo_link_url portal_url '/' %}">
      {% block header-title-content %}
        {% firstof global_title site_title "Compte Citoyen" %}
      {% endblock %}
    </a>
  </h1>
{% endblock %}

{% block nav %}
  {% include 'includes/nav.html' %}
{% endblock %}

{% block before-main-content %}
{{ block.super }}
{% if pwa_display == "standalone" %}
{% pwa_navigation %}
{% endif %}
{% endblock %}

{% block messages %}
{{ block.super }}
{% placeholder "messages" %}
{% endblock %}

{% block content %}
  {% block combo-content %}
    {% block page-content %}
      {% block sidebar %}{% endblock %}
      <div id="columns-wrapper">
        {% block columns-top %}
        {% placeholder "columns-top" name=_('Top of content') optional=True acquired=False outer_tag=True %}
        {% endblock %}
        <div id="columns" class="clearfix">
          {% block columns %}
          {% trans "Content" as name %}
          {% placeholder "content" name=name %}
          {% endblock %}
        </div>
        {% block columns-bottom %}
        {% placeholder "columns-bottom" name=_('Bottom of content') optional=True acquired=False outer_tag=True %}
        {% endblock %}
      </div>
    {% endblock %}
  {% endblock %}
{% endblock %}

{% block footer %}
  {% trans "Footer" as name %}
  {% placeholder "footer" acquired=True name=name optional=True %}
{% endblock %}

{% block top-links %}
  {% include 'includes/user-info.html' %}
{% endblock %}

{% block back-top %}
  {% include 'includes/back-top.html' %}
{% endblock %}

{% block body-bottom %}
{% skeleton_extra_placeholder service-worker %}
{% if page.pk %}  {# limit this to concrete pages on combo (ex: not 404) #}
  {% if pwa_display == "standalone" %}
    <script src="/service-worker-registration.js"></script>
  {% endif %}
{% endif %}
{% end_skeleton_extra_placeholder %}
{% endblock %}
