{#
# Default link menu item
#}
{# @var menu \S360\MegaMenu\Core\Content\Menu\MenuEntity #}
{% block s360_megamenu_item %}
{# @var item \S360\MegaMenu\Core\Content\Menu\MenuItemEntity #}
{% set item = treeItem.item %}
{% set title = item.translated.title %}
{% set isActive = menu.tree.active.id == item.id or (item.linkType == "category" and item.link is same as(page.header.navigation.active.id)) %}
{% set url = item.link %}
{% set noopener = false %}
{% set isFolder = item.categoryLink and item.categoryLink.type == 'folder' %}
{% if item.linkType == "category" and item.categoryLink %}
{% set url = category_url(item.categoryLink) %}
{% elseif item.linkType == 'custom' and url starts with url('frontend.home.page') == false and url starts with path('frontend.home.page') == false %}
{% set noopener = true %}
{% endif %}
<div class="s360-megamenu__item {% if item.align == 'right' %}s360-megamenu__item--right{% else %}s360-megamenu__item--default{% endif %}">
{% block s360_megamenu_item_link %}
{# Use a span tag if we only want to show text instead of a link #}
{% block s360_megamenu_item_link_tag_open %}
<{% if item.linkType == 'none' or url is empty or isFolder %}span{% else %}a{% endif %}
class="{% block s360_megamenu_item_classes %}
s360-megamenu__link s360-megamenu__link--{{ item.id }} s360-megamenu__link--{{ item.linkType }}
{% if (item.icon or item.customIcon) and not item.hideContent %} s360-megamenu__link--icon-with-text{% endif %}
{% if isActive %} active{% endif %}
{% if item.styling.customClass %}{{ item.styling.customClass }}{% endif %}
{% endblock %}"
{% if item.linkType != 'none' and url is not empty or not isFolder %}
href="{{ url }}"
itemprop="url"
title="{{ title }}"
{% endif %}
{% if noopener %}
target="_blank"
rel="noopener"
{% endif %}
{% block s360_megamenu_item_attrs %}data-flyout-menu-trigger="{{ item.id }}"{% endblock %}
>
{% endblock %}
{# Icon Left #}
{% if item.icon and (item.iconPosition == null or item.iconPosition == 'left') %}
{% block s360_megamenu_item_link_icon_left %}
{% sw_include '@Storefront/storefront/s360/megamenu/utilities/icon.html.twig' with { icon: item.icon, position: 'left' } %}
{% endblock %}
{% endif %}
{# Image Left #}
{% if item.customIcon and (item.iconPosition == null or item.iconPosition == 'left') %}
{% block s360_megamenu_item_link_media_left %}
<img src="{{ item.customIcon.url }}" alt="{{ title | sw_sanitize }}" class="img-fluid s360-megamenu__link__image s360-megamenu__link__image--left" />
{% endblock %}
{% endif %}
{# Content #}
{% if not item.hideContent %}
{% block s360_megamenu_item_link_text_content %}
<span itemprop="name">{{ title }}</span>
{% endblock %}
{% endif %}
{# Icon Right #}
{% if item.icon and item.iconPosition == 'right'%}
{% block s360_megamenu_item_link_icon_right %}
{% sw_include '@Storefront/storefront/s360/megamenu/utilities/icon.html.twig' with { icon: item.icon, position: 'right' } %}
{% endblock %}
{% endif %}
{# Image Right #}
{% if item.customIcon and item.iconPosition == 'right' %}
{% block s360_megamenu_item_link_media_right %}
<img src="{{ item.customIcon.url }}" alt="{{ title | sw_sanitize }}" class="img-fluid s360-megamenu__link__image s360-megamenu__link__image--right" />
{% endblock %}
{% endif %}
{# Use a span tag if we only want to show text instead of a link #}
{% block s360_megamenu_item_link_tag_close %}
{% if item.linkType == 'none' or url is empty %}
</span>
{% else %}
</a>
{% endif %}
{% endblock %}
{% endblock %}
{# Flyouts which are not fullscreen and therefore have to be added here in order to have the right positioning! #}
{% block s360_megamenu_item_flyouts %}
{% if (item.contentSettings.dropdownWidth == 'content' or item.contentSettings.dropdownWidth is not defined) and treeItem.shouldDisplayFlyout(page.header.activeLanguage.id) %}
{% block s360_megamenu_item_flyout_container %}
<div class="navigation-flyouts s360-megamenu__dropdown {% if menu.dropdownStyling.customClass %}{{ menu.dropdownStyling.customClass }}{% endif %}">
{% block s360_megamenu_item_flyout %}
{% sw_include '@Storefront/storefront/s360/megamenu/desktop/flyouts/' ~ item.contentType ~ '.html.twig' ignore missing with { treeItem: treeItem, item: item, menu: menu, includeFlyoutWrapper: true } %}
{% endblock %}
</div>
{% endblock %}
{% endif %}
{% endblock %}
</div>
{% endblock %}