<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}">

<head>
  <title>{{ block "title" . }}{{ .Site.Params.HeadTitle | default .Site.Title }}{{ end }}</title>
  {{ partial "head.html" . }}
</head>

{{ $csClass := "colorscheme-light" }}
{{ if eq .Site.Params.colorScheme "dark" }}
{{ $csClass = "colorscheme-dark" }}
{{ else if eq .Site.Params.colorScheme "auto" }}
{{ $csClass = "colorscheme-auto" }}
{{ end }}

<body class="preload-transitions {{ $csClass }}{{ if .Site.Params.rtl }} rtl{{ end }}">
  {{ partial "float" . }}
  <main class="wrapper">
    {{ partial "header.html" . }}

    <div class="content">
      {{ block "content" . }}{{ end }}
    </div>

    {{ partial "footer.html" . }}
  </main>

  {{ if .HasShortcode "mermaid" }}
  <script src="https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js"
    integrity="sha256-QdTG1YTLLTwD3b95jLqFxpQX9uYuJMNAtVZgwKX4oYU=" crossorigin="anonymous"></script>
  <script>
    mermaid.initialize({ startOnLoad: true });
  </script>
  {{ end }}

  {{ if .Site.Params.disableDefaultJsScripts }}
  {{ if not .Site.Params.hideColorSchemeToggle }}
  {{ errorf "Invalid configuration. Default JS scripts are disabled, but 'hideColorSchemeToggle' is false." }}
  {{end}}
  {{ else if hugo.IsServer }}
  {{ $script := resources.Get "js/coder.js" }}
  <script src="{{ $script.RelPermalink }}"></script>
  {{ else }}
  {{ $script := resources.Get "js/coder.js" | resources.Minify | resources.Fingerprint }}
  <script src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
  {{ end }}

  {{ range .Site.Params.customJS }}
  {{ if hugo.IsServer }}
  {{ $script := resources.Get . }}
  <script src="{{ $script.RelPermalink }}"></script>
  {{ else }}
  {{ $script := resources.Get . | resources.Minify | resources.Fingerprint }}
  <script src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
  {{ end }}
  {{ end }}

  {{ range .Site.Params.customRemoteJS }}
  {{ if hugo.IsServer }}
  {{ $script := resources.GetRemote . }}
  <script src="{{ $script.RelPermalink }}"></script>
  {{ else }}
  {{ $script := resources.GetRemote . | resources.Minify | resources.Fingerprint }}
  <script src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
  {{ end }}
  {{ end }}


  {{ template "_internal/google_analytics.html" . }}

  {{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }}
  {{- partial "analytics/fathom" . -}}
  {{ end }}

  {{ if and .Site.Params.plausibleAnalytics .Site.Params.plausibleAnalytics.domain }}
  {{- partial "analytics/plausible" . -}}
  {{ end }}

  {{ if and .Site.Params.goatCounter .Site.Params.goatCounter.code }}
  {{- partial "analytics/goatcounter" . -}}
  {{ end }}

  {{ if and .Site.Params.cloudflare .Site.Params.cloudflare.token }}
  {{- partial "analytics/cloudflare" . -}}
  {{ end }}

  {{ if and .Site.Params.baidu .Site.Params.baidu.token }}
  {{- partial "analytics/baidu" . -}}
  {{ end }}

  {{ if and .Site.Params.wideAngleAnalytics .Site.Params.wideAngleAnalytics.siteID }}
  {{- partial "analytics/wideangle" . -}}
  {{ end }}

  {{ if and .Site.Params.matomo .Site.Params.matomo.serverURL }}
  {{- partial "analytics/matomo" . -}}
  {{ end }}

  {{ if and .Site.Params.googleTagManager .Site.Params.googleTagManager.id }}
  {{- partial "analytics/googletagmanager" . -}}
  {{ end }}

  {{ if and .Site.Params.applicationInsights .Site.Params.applicationInsights.connectionString }}
  {{- partial "analytics/applicationinsights" . -}}
  {{ end }}

  {{ if and .Site.Params.microAnalytics .Site.Params.microAnalytics.id }}
  {{- partial "analytics/microanalyticsio" . -}}
  {{ end }}

  {{ if and .Site.Params.onedollarstats .Site.Params.onedollarstats.id }}
  {{- partial "analytics/onedollarstats" . -}}
  {{ end }}

  {{ if .Site.Params.vercelAnalytics}}
  {{- partial "analytics/vercel" . -}}
  {{ end }}

  {{ if and .Site.Params.yandexMetrika .Site.Params.yandexMetrika.id }}
  {{- partial "analytics/yandex-metrika" . -}}
  {{ end }}

  {{ if and .Site.Params.umami .Site.Params.umami.siteID }}
  {{- partial "analytics/umami" . -}}
  {{ end }}

  {{ if and .Site.Params.pirsch .Site.Params.pirsch.code }}
  {{- partial "analytics/pirsch" . -}}
  {{ end }}

  {{ if and .Site.Params.clicky .Site.Params.clicky.id }}
  {{- partial "analytics/clicky" . -}}
  {{ end }}

  {{- partial "body/extensions" . -}}
</body>
</html>
