{% set locale = app.request.get('_locale') %}
{% set url = app.request.uri %}
{% set languages = ['tr', 'en', 'de'] %}
{% set paths = {
    "corporate": "about_us",
    "expertise": "services",
    "blogs": "blog",
    "services": "services"
}
%}
{% set services = getServices(app.request) %}
{% set serviceLangs = [] %}
{% set serviceContents = [] %}
{% set appSetting = getAppSetting() %}
{% set routeName = app.request.attributes.get(("_route")) %}
{% for service in services %}
    {% set serviceLangs = serviceLangs|merge([getLang(service.serviceLangs(), app.request)]) %}
    {% set serviceContents = serviceContents|merge([service.content]) %}
{% endfor %}
{% set footerPagesArray = {} %}
{% set footerPages = getPages({'footer': true}, app.request) %}
{% for page in footerPages %}
    {% set pageLang = getLang(page.getPageLangs(), app.request) %}
    {% if pageLang %}
        {% set footerPagesArray = footerPagesArray|merge({(page.name): {'page': page, 'pageLang': pageLang}}) %}
    {% endif %}
{% endfor %}
{% set currentLocation = getLocations({'countryCode': locale}) %}
{% if not currentLocation %}
    {% set currentLocation = getLocations({'countryCode': 'en'}) %}
{% endif %}
{% set currentLocation = currentLocation[0] %}
{% set currentLocationLang = getLang(currentLocation.getLocationLangs(), app.request) %}

<!DOCTYPE html>
<html lang="{{ locale }}">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        {% if not pageTitle is defined %}
            {% set pageTitle = "Technoone" %}
        {% endif %}
        <link rel="shortcut icon" type="image/x-icon" href="{{asset('img/favicon.png')}}" />
        <meta name="format-detection" content="telephone=no">
        <meta property="og:url" content="{{url}}" />
        <meta property="og:type" content="{% block og_type %}website{% endblock %}" />
        <meta property="og:title" content="{{pageTitle}}">
        {% if app.request.attributes.get('alias') %}
            <link rel="canonical" href="{{ path(app.request.attributes.get('_route'), {'alias': app.request.attributes.get('alias'), '_locale': locale}) }}" />
        {% elseif app.request.attributes.get('project_name') %}
            <link rel="canonical" href="{{ path(app.request.attributes.get('_route'), {'project_name': app.request.attributes.get('project_name'), '_locale': locale}) }}" />
        {% else %}
            <link rel="canonical" href="{{ path(app.request.attributes.get('_route'), {'_locale': locale}) }}" />
        {% endif %}
        {% block meta %}
        {% endblock %}
        {% set detailPage = app.request.attributes.get('alias') %}
        {% if detailPage %}
            {% set languagesAlter = [] %}
            {% for index, language in languages %}
                {% if language != locale %}
                    {% if service is defined %}
                        {% set detail = getServiceLang(service, language) %}
                    {% elseif blog is defined %}
                        {% set detail = getBlogLang(blog, language) %}
                    {% elseif page is defined %}
                        {% set detail = getPageLang(page, language) %}
                    {% else %}
                        {% set detail = null %}
                    {% endif %}
                    {% if detail %}
                        <link rel="alternate" hreflang="{{ language }}" href="{{ path(app.request.attributes.get('_route'), {'alias': detail.alias, '_locale': language}) }}" />
                    {% endif %}
                    {% set languagesAlter = languagesAlter|merge([detail])  %}
                {% else %}
                    {% set languagesAlter = languagesAlter|merge([language])  %}
                {% endif %}
            {% endfor %}
            {% set languages = languagesAlter %}
        {% endif %}
        {% block alternatePages %}
            {% if not detailPage %}
                {% for language in languages %}
                    {% if language != locale %}
                        <link rel="alternate" hreflang="{{ language }}" href="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')|merge({'_locale': language})) }}" />
                    {% endif %}
                {% endfor %}
            {% endif %}
        {% endblock %}

        {% block title %}
            {% if not titleExtension is defined %}{% set titleExtension = pageTitle %}{% endif %}
            {% if breadcrumb is defined %}
                {% for link in breadcrumb|reverse %}
                    {% set titleExtension = titleExtension ~ " | " ~ link|trans|title %}</a>
                {% endfor %}
            {% endif %}
            {% if not titleExtension is defined %}
                <title>{{ pageTitle }}{% if inner is not defined or inner == true %} | Technoone{% endif %}</title>
            {% else %}
                <title>{{ titleExtension }} | Technoone</title>
                
            {% endif %}
        {% endblock %}


        <script>window.urlRoot="{{ url('homepage', {'_locale': ''}) }}"</script>
        {{ importmap('app') }}
        {% block importScripts %}
        {% endblock %}
        {% block stylesheets %}
        {% endblock %}
            <link rel='stylesheet' href='{{ asset("styles/responsive.css") }}'>
        {% if innerPage is not defined or innerPage == true %}
            <link rel='stylesheet' href='{{ asset("styles/inner.css") }}'>
        {% endif %}
    </head>
    <body>
        <div class="loader"></div>
        {% block body %}
            <div id="smooth-wrapper">
                {% block heder %}
                    {% include "_header.html.twig" %}
                {% endblock %}
                <div id="smooth-content">
                    <section class="main-section">
                        {% block content %}
                        {% endblock content %}
                    </section>
                    {% include "_footer.html.twig" %}
                </div>
            </div>
        {% endblock %}
    </body>
    <script src="{{ asset('js/lenis.min.js') }}"></script>
    <script>
        const lenis = new Lenis({
            wheelMultiplier: 1.25,
            lerp: .07
        });
        window.lenis = lenis
        function raf(time) {
            lenis.raf(time)
            requestAnimationFrame(raf)
        }
        requestAnimationFrame(raf)
    </script>
    {% block javascripts %}
    {% endblock %}
</html>
