{% extends "common/base.html" %}
{% from "common/partials/mhclg-header.html" import mhclgHeader %}
{% from "common/partials/mhclg-test-banner.html" import mhclgRequestTracingBanner with context %}
{% from "common/macros/navigation.html" import deliverGrantFundingServiceNavigation %}
{% from "govuk_frontend_jinja/components/footer/macro.html" import govukFooter %}
{% from "common/macros/standard-error-summary.html" import standardErrorSummary with context %}

{% set nav_items = nav_items or [] %}
{% set right_nav_items = right_nav_items or [] %}

{% block pageTitle %}{{ page_title }} - {{ super() }}{% endblock pageTitle %}
{% block head %}
  <!-- Google Tag Manager -->
  <script nonce="{{csp_nonce()}}">
    (function (w, d, s, l, i) {
      w[l] = w[l] || [];
      w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js", env: "{{get_current_env_name()}}" });
      var f = d.getElementsByTagName(s)[0],
        j = d.createElement(s),
        dl = l != "dataLayer" ? "&l=" + l : "";
      j.async = true;
      j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
      var n = d.querySelector("[nonce]");
      n && j.setAttribute("nonce", n.nonce || n.getAttribute("nonce"));
      f.parentNode.insertBefore(j, f);
    })(window, document, "script", "dataLayer", "{{ get_google_tag_manager_id() }}");
  </script>

  <!-- End Google Tag Manager -->
  {{ super() }}
{% endblock %}
{% block header %}
  {{ mhclgRequestTracingBanner() }}
  {{
    mhclgHeader(
      params={
        "homepageUrl": url_for("deliver_grant_funding.list_grants"),
        "assetPath": assetPath
      },
      currentUser=current_user,
    )
  }}
  {{ deliverGrantFundingServiceNavigation(nav_items, right_nav_items) }}
{% endblock header %}

{% block main %}
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-T8XPM3NL" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->
  <div>
    <div class="govuk-width-container {% if containerClasses %}{{ containerClasses }}{% endif %}">
      {% block beforeContent %}{% endblock %}
      <div class="govuk-main-wrapper {% if mainClasses %}{{ mainClasses }}{% endif %}">
        {% block mainWrapper %}
          <main id="main-content" {% if mainLang %}lang="{{ mainLang }}"{% endif %}>
            {% block errorSummary %}
              {{ standardErrorSummary(form) }}
            {% endblock errorSummary %}

            {% block content %}
            {% endblock content %}
          </main>
        {% endblock mainWrapper %}
      </div>
    </div>
  </div>
{% endblock %}

{% block footer %}
  {{
    govukFooter({
      "contentLicence": none,
      "meta": {
        "items": [
          {
            "href": url_for("deliver_grant_funding.latest_updates"),
            "text": "Latest updates"
          },
          {
            "href": config.DELIVER_SERVICE_DESK_URL,
            "text": "Contact us"
          }
        ]
      }
    })
  }}
{% endblock footer %}
