{% import _self as navbar_brand %}

{% set classes = [
]|merge(extra_classes ?: []) %}

{% set navbar_brand_logo_container_classes = [
  'navbar-brand__logo',
]|merge(navbar_brand_logo_container_extra_classes ?: []) %}

<a {{ attributes.addClass(classes).setAttribute('href', path('<front>')) }}>
  <div class="{{ navbar_brand_logo_container_classes|join(' ')}}">
    {% if image %}
      {{ navbar_brand.image(image, width, height, alt, webp ?? false) }}
    {% endif %}
  </div>
</a>

{% macro image(src, width, height, alt, webp) %}
  {% if webp %}
    <picture>
      <source type="image/webp" srcset="{{ src|replace({'.jpg': '.webp', '.png': '.webp'}) }}" width="{{ width|default(140) }}" height="{{ height|default('auto') }}">
      <img src="{{ src }}" width="{{ width|default(140) }}" height="{{ height|default('auto') }}" alt="{{ alt|default('') }}" />
    </picture>
  {% else %}
    <img src="{{ src }}" width="{{ width|default(140) }}" height="{{ height|default('auto') }}" alt="{{ alt|default('') }}" />
  {% endif %}
{% endmacro %}
