{% macro logo(data, class) %}
{% if data %}
<a class="{{ class }}" href="{{ data.url }}" title="{{ data.title|striptags|raw }}">
    <picture>
        <source srcset="{{ data.img.webp.src }}" type="{{ data.img.webp.mimetype }}">
        <source srcset="{{ data.img.image.src }}" type="{{ data.img.image.mimetype }}">
        <img alt="{{ data.title|striptags|raw }}" width="{{ data.img.image.width }}" height="{{ data.img.image.height }}" />
    </picture>
</a>
{% endif %}
{% endmacro %}

{% macro menuPrimary(data) %}
{% if data %}
{% for item in data %}
{% if not item.subitem %}
<li{% if item.active %} class="{{ item.active }}"{% endif %}>
    <a href="{{ item.url}}"{% if item.target %} target="{{ item.target }}"{% endif %} title="{{ item.title|striptags|raw }}">
        {% if item.image %}<img src="{{ item.image }}" alt="{{ item.title|striptags|raw }}">{% endif %}<span>{{ item.title|raw }}</span>
    </a>
</li>
{% else %}
<li class="dropdown">
    <button class="dropdown-toggle" class="{{ item.class }}" title="{{ item.title|striptags|raw }}">
        {{ item.title|raw }} <i class="fa fa-angle-down"></i>
    </button>

    <ul class="dropdown-menu">
        {% for submenu in item.subitem %}
        <li>
            <a href="{{ submenu.url }}"{% if submenu.target %} target="{{ submenu.target }}"{% endif %} title="{{ submenu.title|striptags|raw }}" class="{{ submenu.class }}">
                {{ submenu.title|raw }}
            </a>
        </li>
        {% endfor %}
    </ul>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}

{% macro menuBarTop(core, footer, extra, rounded = false) %}
<li>
    <a href="{{ core.permalink }}/{{ extra.static.localization.scope.key }}" class="{% if not rounded %}social-icon{% else %}social-icon-rounded{% endif %}" title="{{ extra.static.localization.scope.title|striptags|raw }}">
        <i class="fa fa-map-marker"></i>
    </a>
</li>

{% for email in footer.emails %}
<li>
    <a href="mailto:{{ email }}" class="{% if not rounded %}social-icon{% else %}social-icon-rounded{% endif %}" title="{{ email|striptags|raw }}">
        <i class="fa fa-envelope"></i>
    </a>
</li>
{% endfor %}
{% endmacro %}

{% macro socialList(header, colors = true, rounded = false, core) %}
{% if header.social %}
{% for item in header.social %}
<li>
    <a href="{{ item.url }}" class="social-icon{% if rounded %}-rounded{% endif %}{% if colors %} social{% if rounded %}-rounded{% endif %}-{{ item.type.key }}{% endif %}" title="{{ item.type.label|striptags|raw }}" target="_blank">
        <i class="{{ item.type.icon }}"></i>
    </a>
</li>
{% endfor %}
{% endif %}
<li>
    <a href="{{ core.permalink }}/contato" class="{% if not rounded %}social-icon{% else %}social-icon-rounded{% endif %}" title="Contato">
        <i class="fa fa-envelope"></i>
    </a>
</li>
{% if header.whatsapp.number and header.whatsapp.message %}
<li>
    <a href="https://api.whatsapp.com/send?phone={{ header.whatsapp.number|striptags|raw }}&text={{ header.whatsapp.message|striptags|raw }}" class="{% if not rounded %}social-icon{% if colors %} social-whatsapp{% endif %}{% else %}social-icon-rounded social-rounded-whatsapp{% endif %}" title="Entre em contato via Whatsapp!" target="_blank">
        <i class="fa fa-whatsapp"></i>
    </a>
</li>
{% endif %}
{% endmacro %}

{% macro socialWhatsapp(header, colors = true, rounded = false) %}
{% if header.whatsapp.number and header.whatsapp.message %}
<li>
    <a href="https://api.whatsapp.com/send?phone={{ header.whatsapp.number|striptags|raw }}&text={{ header.whatsapp.message|striptags|raw }}" class="{% if not rounded %}social-icon{% if colors %} social-whatsapp{% endif %}{% else %}social-icon-rounded social-rounded-whatsapp{% endif %}" title="Entre em contato via Whatsapp!" target="_blank">
        <i class="fa fa-whatsapp"></i>
    </a>
</li>
{% endif %}
{% endmacro %}

{% macro signature(locale, core, logo = false) %}
<a class="signature" href="{{ locale.signatureurl }}" target="_blank" title="{{ locale.signature|striptags|raw }}" rel="nofollow">
    {% if logo %}
    <img src="{{ core.public }}/img/signature.png" alt="{{ locale.signature|striptags|raw }}" />
    {% else  %}
    {{ locale.signaturemin|raw }}
    {% endif %}
</a>
{% endmacro %}
