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

{% set assetPath = vite_asset('assets') %}
{% set cspNonce = csp_nonce() %}

{% set govukRebrand = false %}

{% block pageTitle %}MHCLG Funding Service{% endblock pageTitle %}

{% block headIcons %}
  <link rel="icon" sizes="48x48" href="{{ assetPath }}/images/favicon.ico" />
  <link rel="icon" sizes="any" href="{{ assetPath }}/images/favicon.svg" type="image/svg+xml" />
  <link rel="mask-icon" href="{{ assetPath }}/images/govuk-icon-mask.svg" color="{{ themeColor }}" />
  <link rel="apple-touch-icon" href="{{ assetPath }}/images/govuk-icon-180.png" />

  {# All we do here is remove the `manifest.json` link - which we don't need to serve and otherwise logs 401s in the console #}
{% endblock %}

{% block head %}
  {% if config["ASSETS_VITE_LIVE_ENABLED"] %}
    <script type="module" src="{{ vite_asset('@vite/client') }}"></script>
  {% endif %}
  <link rel="stylesheet" href="{{ vite_asset('app/assets/main.scss') }}" type="text/css" />
{% endblock head %}

{% block header %}
  {{ mhclgRequestTracingBanner() }}
  {# todo: have this header read a homepageUrl variable, then any subclasses can just use super() calls #}
  {{
    mhclgHeader(
      params={
        "homepageUrl": url_for("index"),
        "assetPath": assetPath
      },
      currentUser=current_user,
    )
  }}
{% endblock header %}

{% block main %}
  <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>
{% endblock %}

{% block bodyEnd %}
  <script type="module" src="{{ vite_asset('app/assets/main.js') }}"></script>
{% endblock %}

{% block footer %}
  {{
    govukFooter({
      "contentLicence": none,
      "meta": {
        "items": [
          {
            "href": config.SERVICE_DESK_URL,
            "text": "Contact us"
          }
        ]
      }
    })
  }}
{% endblock footer %}
