@php
    $activeLang = getActiveLocale();
@endphp
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="token" content="{{ csrf_token() }}">
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1.0">

@if(isset($metaData))
    <title>{{ $metaData->meta_title }}</title>
    <meta property="og:title" content="{{ htmlspecialchars($metaData->meta_title) }}" />
    @if (!isset($metaImage) && isset($metaData->metaImage))
        <meta property="twitter:card" content="summary_large_image" />
        <meta property="twitter:image" content="{{ $metaData->metaImage }}" />
    @endif
    @if($metaData->meta_keywords)
        <meta name="keywords" content="{{ htmlspecialchars($metaData->meta_keywords) }}">
    @else
        <meta name="keywords" content="south pole, emission reduction, carbon footprint, carbon credits, carbon offsets, CO₂ calculator, greenhouse gas emissions, carbon neutral, climate change, Gold Standard, CDM, Biomass, Cooking stoves, Run-of-river hydro, Waste heat energy, Small hydro, video, fact sheet, Landfill gas, Geothermal, Micro run-of-river, Reforestation, REDD">
    @endif

    @if($metaData->meta_description)
        <meta name="description" content="{{ htmlspecialchars($metaData->meta_description) }}">
    @else
        <meta name="description" content="south pole is the world's leading premium emission reduction project developer, named Best Project Developer in Environmental Finance's Voluntary Carbon Markets Survey 2011 2012 2013 2014. Profit from our wealth of experience!" />
    @endif

    <meta property="og:description" content="{{ htmlspecialchars($metaData->meta_description) }}" />
    @if (!isset($metaImage) && isset($metaData->metaImage))
        <meta property="og:image" content="{{ $metaData->metaImage }}" />
    @endif
    @if(isset($metaData->no_index) && $metaData->no_index)
        <meta name="robots" content="noindex">
    @endif
    @if(isset($metaData->canonical_url) && !empty($metaData->canonical_url))
        <link rel="canonical" href="{{ $metaData->canonical_url }}" />
    @else
        <link rel="canonical" href="{{lang_url(request()->url())}}" />
    @endif
@else
    <title>South Pole</title>
    <meta property="og:title" content="South Pole" />
    <meta name="keywords" content="south pole, emission reduction, carbon footprint, carbon credits, carbon offsets, CO₂ calculator, greenhouse gas emissions, carbon neutral, climate change, Gold Standard, CDM, Biomass, Cooking stoves, Run-of-river hydro, Waste heat energy, Small hydro, video, fact sheet, Landfill gas, Geothermal, Micro run-of-river, Reforestation, REDD">
    <meta name="description" content="South pole is the world's leading premium emission reduction project developer, named Best Project Developer in Environmental Finance's Voluntary Carbon Markets Survey 2011 2012 2013 2014. Profit from our wealth of experience!" />
    <!-- CANONICAL URL -->
    <link rel="canonical" href="{{lang_url(request()->url())}}" />
    <!-- FAVICON -->
@endif

@if (isset($metaUrl))
    <meta property="og:url" content="{{ $metaUrl }}" />
@endif
@if (isset($metaImage))
    <meta property="og:image" content="{{ $metaImage }}" />
@endif

<meta property="og:site_name" content="South Pole" />

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

@php
    $preloadImages = getRequestContext('preloadImages');
    $preloadImages = $preloadImages ?? [];
@endphp
@foreach($preloadImages as $preloadImage)
    <link rel="preload" href="{{ $preloadImage['url'] }}" as="image" type="{{ $preloadImage['type'] }}">
@endforeach
@if($activeLang == 'ja')
    <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,300;0,600;1,300;1,600&family=Barlow:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&family=Noto+Sans+JP:wght@400;500;600;700&display=swap" media="print" onload="this.onload=null;this.removeAttribute('media');" rel="stylesheet">
@else
    <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,300;0,600;1,300;1,600&family=Barlow:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap" media="print" onload="this.onload=null;this.removeAttribute('media');" rel="stylesheet">
@endif

@vite(['resources/sass/app.scss', 'resources/js/app.js'])

@if(isset($css))
<style>
    {{ $css }}
</style>
@endif

<script>
    /**
    * JAVASCRIPT GLOBAL ENVIRONMENT SETUP
    */
    window.Eae = window.Eae || {};
    window.Eae.Config = {
        url : "{{ lang_url('/') }}",
        base_url: "{{ url('/') }}",
        defaultLang : "{{ getDefaultLocale() }}",
        recaptcha: @json(config('google.recaptcha.siteKey'))
    };
</script>

@if(!empty($hasMaps) || getRequestContext('load-google-maps'))
    <script src="https://maps.googleapis.com/maps/api/js?key={{config('google.apiKey')}}&libraries=places,maps"></script>
@endif
@if(!empty($hasRecaptcha))
    @include('common.includes.recaptcha_head')
@endif

@if (config('google.analyticsId'))
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '{{ config("google.analyticsId") }}', 'auto');
  ga('send', 'pageview');
</script>
@endif

<script>
    var translations = @json(get_frontend_translations());
</script>

@if(isset($embeds))
    @foreach($embeds as $embed)
        @if ($embed->embed_position == 'head')
            {!! $embed->type === 'multi_lang' ? $embed->code_lang : $embed->code !!}
        @endif
    @endforeach
@endif

@if(isset($objectEmbeds) && !empty($objectEmbeds))
    @foreach($objectEmbeds as $embed)
        @if($embed->embed_position == 'head' && !$embed->global && $embed->status == 'published')
            {!! $embed->type === 'multi_lang' ? $embed->code_lang : $embed->code !!}
        @endif
    @endforeach
@endif
