{#
  Copyright (C) 2020-2021 Graz University of Technology.
  Copyright (C) 2025 I-Form Advanced Manufacturing Research Centre.

  invenio-theme-iform is free software; you can redistribute it and/or
  modify it under the terms of the MIT License; see LICENSE file for more
  details.
#}

{% set lang_attr = g.ln.split('_', 1)[0]|safe if g.ln else '' %}
{% set html_class_attr = html_css_classes|join(' ') if html_css_classes else '' %}
{% set body_class_attr = body_css_classes|join(' ') if body_css_classes else '' %}
{% set rtl_attr = rtl_direction|safe if rtl_direction and g.ln else '' %}

<!doctype html>
<html
    {% if html_class_attr %}class="{{ html_class_attr }}"{% endif %}
    lang="{{ lang_attr }}"
    dir="{{ rtl_attr }}"
>
    <head>
        {%- block head %}
            {%- block head_meta %}
                <meta charset="utf-8" />
                <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                <meta name="viewport" content="width=device-width, initial-scale=1" />
                {%- if description %}
                    <meta name="description" content="{{ description }}" />
                {% endif %}
                {%- if keywords %}<meta name="keywords" content="{{ keywords }}" />{% endif %}
                {%- if config.get('THEME_GOOGLE_SITE_VERIFICATION', None) %}
                    {%- for google_id in config.THEME_GOOGLE_SITE_VERIFICATION %}
                        <meta name="google-site-verification" content="{{ google_id }}" />
                    {%- endfor %}
                {%- endif %}
            {%- endblock head_meta %}
            {%- block head_title %}
                {%- set title = title or config.THEME_SITENAME %}
                <title>{{ title }}</title>
            {%- endblock head_title %}
            {%- block head_links %}
                <link rel="shortcut icon" href="{{ url_for('invenio_theme_iform.static', filename='favicon.ico') }}" />
                {%- if keywords %}<link rel="canonical" href="{{ canonical_url }}" />{% endif %}
                {%- block head_links_langs %}
                    {%- if alternate_urls %}
                        {%- for alt_ln, alternate_url in alternate_urls.items() %}
                            <link
                                rel="alternate"
                                hreflang="{{ alt_ln }}"
                                href="{{ alternate_url }}"
                            />
                        {%- endfor %}
                    {%- endif %}
                {%- endblock %}
                {%- block head_apple_icons %}
                    {%- for size in [144, 114, 72, 57] %}
                        {%- set icon_name = 'apple-touch-icon-%d-precomposed.png' | format(size) %}
                        <link
                            rel="apple-touch-icon-precomposed"
                            sizes="{{ size }}x{{ size }}"
                            href="{{ url_for('invenio_theme_iform.static', filename=icon_name) }}"
                        />
                    {%- endfor %}
                {%- endblock head_apple_icons %}
            {%- endblock head_links %}
            {%- block header %}
            {% endblock header %}
            {%- block css %}
                {{ webpack['theme.css'] }}
                {{ webpack['invenio-theme-iform-theme.css'] }}
                <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
                <!--[if lt IE 9]>
                    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
                    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
                <![endif]-->
            {%- endblock css %}
        {%- endblock head %}
    </head>
    <body
        ng-csp
        {% if body_class_attr %}class="{{ body_class_attr }}"{% endif %}
        {% if lang_attr %}lang="{{ lang_attr }}"{% endif %}
        {{ rtl_attr }}
        itemscope
        itemtype="http://schema.org/WebPage"
        data-spy="scroll"
        data-target=".scrollspy-target"
    >
        {% if not config.THEME_IFORM_PRODUCTION %}
            <div class="ui sticky test-instance">
                <h4>"Test Instance"</h4>
                <p>"This is the test instance of the I-Form Repository."</p>
            </div>
        {% endif %}
        {%- block body %}
            {%- block browserupgrade %}
                <!--[if lt IE 8]>
                    <p class="browserupgrade">
                        You are using an <strong>outdated</strong> browser. Please
                        <a href="http://browsehappy.com/">upgrade your browser</a> to improve your
                        experience.
                    </p>
                <![endif]-->
            {%- endblock browserupgrade %}
            {%- block body_inner %}

                {%- block navbar_header %}
                    {%- include "invenio_theme_iform/navbar.html" %}
                    <!--Flask messages for accounts-->
                    {%- block flashmessages %}
                        {%- from "invenio_theme/macros/messages.html" import flashed_messages with context -%}
                        {{ flashed_messages() }}
                    {%- endblock flashmessages %}
                {%- endblock navbar_header %}

                {#
      {%- block page_header %}
      {% include config.THEME_HEADER_TEMPLATE %}
          {%- endblock page_header %}
      #}

                {%- block page_body %}
                    {% include "invenio_theme/body.html" %}
                {%- endblock page_body %}
            {%- endblock body_inner %}
            {%- block javascript %}
                {% include config.THEME_JAVASCRIPT_TEMPLATE %}
            {%- endblock javascript %}
            {%- block trackingcode %}
                {% include config.THEME_TRACKINGCODE_TEMPLATE %}
            {%- endblock %}
        {%- endblock body %}
    </body>
</html>
