{namespace neos=Neos\Neos\ViewHelpers}
{namespace vh=Newland\NeosViewHelpers\ViewHelpers}
{namespace poi=Newland\Toubiz\Poi\Neos\ViewHelpers}

<f:comment>
    <!--
        This partial is responsible for rendering an article as list item,
        e.g. in a search result list.
    -->
</f:comment>

<vh:render section="SplitscreenInformation" arguments="{_all}" />

<f:if condition="{article.isAttraction}">
    <li class="tb-results-list__item" itemscope itemtype="http://schema.org/TouristAttraction">
        <vh:render section="ListItem" arguments="{_all}" />
    </li>
</f:if>

<f:if condition="{article.isGastronomy}">
    <li class="tb-results-list__item" itemscope itemtype="http://schema.org/FoodEstablishment">
        <vh:render section="ListItem" arguments="{_all}" />
    </li>
</f:if>

<f:if condition="{article.isTour}">
    <li class="tb-results-list__item">
        <vh:render section="ListItem" arguments="{_all}" />
    </li>
</f:if>

<f:section name="ListItem">
    <poi:link.article article="{article}" class="tb-teaser tb-teaser--layout-horizontal">
        <vh:render section="ListItemContent" arguments="{_all}" />
    </poi:link.article>
</f:section>

<f:section name="ListItemContent">
    <f:if condition="{article.mainMedium}">
        <f:then>
            <div class="tb-teaser__image-wrapper">
                <img
                    data-src="{article.mainMedium.sourceUri}"
                    alt="{article.mainMedium.title}"
                    class="tb-teaser__image lazyload"
                    itemprop="image" />

            </div>
        </f:then>
        <f:else>
            <div class="tb-teaser__image-wrapper">
                <div class="tb-teaser__image-fallback">
                    <svg class="c-icon">
                        <use xlink:href="#icon-image"></use>
                    </svg>
                </div>
            </div>
        </f:else>
    </f:if>

    <f:if condition="{article.isAttraction}">
        <vh:render section="attractionContent" arguments="{article: article}" />
    </f:if>

    <f:if condition="{article.isGastronomy}">
        <vh:render section="gastronomyContent" arguments="{article: article}" />
    </f:if>

    <f:if condition="{article.isTour}">
        <vh:render section="tourContent" arguments="{article: article}" />
    </f:if>
</f:section>

<f:section name="attractionContent">
    <div class="tb-teaser__text">
        <p class="tb-teaser__topline">
            <strong>{article.categoriesSorted.0.title}</strong>
            <f:if condition="{article.mainAddress.city}">
                • <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">{article.mainAddress.city}</span></span>
            </f:if>
        </p>

        <h3 class="tb-teaser__title" itemprop="name">{article.name}</h3>

        <f:if condition="{article.abstract}">
            <div class="tb-teaser__description" itemprop="description">
                {article.abstract -> f:format.stripTags()}
            </div>
        </f:if>
    </div>
</f:section>

<f:section name="gastronomyContent">
    <div class="tb-teaser__text">
        <p class="tb-teaser__topline">
            <strong>{article.categoriesSorted.0.title}</strong>
            <f:if condition="{article.mainAddress.city}">
                • <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"><span itemprop="addressLocality">{article.mainAddress.city}</span></span>
            </f:if>
        </p>

        <h3 class="tb-teaser__title" itemprop="name">{article.name}</h3>

        <ul class="tb-teaser__characteristics">
            <f:for
                each="{vh:collection.slice(collection: article.flatAttributes.gastronomyStyle, offset: 0, length: 2)}"
                as="item">

                <li class="tb-teaser__characteristics-item" itemprop="servesCuisine">{item}</li>
            </f:for>
        </ul>

        <div class="tb-teaser__description">
            <f:if condition="{article.addresses.0.phoneNumber}">
                <p>
                    {vh:translate(id: 'property.phoneNumber', package: 'Newland.Toubiz.Poi.Neos', source: 'Models/Address')}
                    <span itemprop="telephone">{article.addresses.0.phoneNumber}</span>
                </p>
            </f:if>

            {article.abstract -> f:format.stripTags()}
        </div>
    </div>
</f:section>

<f:section name="tourContent">
    <f:if condition="{article.flatAttributes.dataSource} == 'outdooractive'">
        <span
            data-oa-tracking
            data-oa-tracking-id="{article.flatAttributes.dataSourceId}"
            data-oa-tracking-type="teaser"></span>

    </f:if>

    <div class="tb-teaser__text">
        <p class="tb-teaser__topline">
            <f:if condition="{article.flatAttributes.difficultyRating} !== 0">
                <strong>
                    <vh:translate
                        id="property.attribute.difficultyRating.values.{article.flatAttributes.difficultyRating}"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Models/Article" />

                </strong>
                •
            </f:if>
            {article.categoriesSorted.0.title}
        </p>

        <h3 class="tb-teaser__title" itemprop="name">{article.name}</h3>

        <f:if condition="{article.abstract}">
            <div class="tb-teaser__description" itemprop="description">
                {article.abstract -> f:format.stripTags()}
            </div>
        </f:if>

        <ul class="tb-teaser__facets">
            <f:if condition="{article.flatAttributes.tourLength.0}">
                <li class="tb-teaser-facet">
                    <svg class="c-icon" aria-hidden="true">
                        <use xlink:href="#icon-distance"></use>
                    </svg>
                    <span class="tb-teaser-facet__label">
                    {article.flatAttributes.tourLength.0 -> vh:math.divide(by: 1000) -> vh:math.round(precision: 1)}
                </span>
                </li>
            </f:if>
            <li class="tb-teaser-facet">
                <svg class="c-icon" aria-hidden="true">
                    <use xlink:href="#icon-duration"></use>
                </svg>
                <span class="tb-teaser-facet__label">
                    {article.flatAttributes.tourDuration.intValue -> vh:math.toHours()} h
                </span>
            </li>
            <li class="tb-teaser-facet">
                <svg class="c-icon" aria-hidden="true">
                    <use xlink:href="#icon-ascend"></use>
                </svg>
                <span class="tb-teaser-facet__label">
                    {article.flatAttributes.ascentElevation} m
                </span>
            </li>
        </ul>
    </div>
</f:section>

<f:section name="SplitscreenInformation">
    <poi:splitscreen.configuration mainType="{article.mainType}" configurationAs="split">
        <f:if condition="{split.enabled} && {article.hasGeocoordinates}">
            <template
                style="display: none"
                data-toubiz-results.splitscreen.marker
                data-toubiz-results.splitscreen.marker.latitude="{article.latitude}"
                data-toubiz-results.splitscreen.marker.longitude="{article.longitude}"
                data-toubiz-results.splitscreen.marker.icon-url="{split.marker.iconUrl}"
            >
                <div class="tb-map-info-window-wrapper">
                    <div class="tb-map-info-window">
                        <button
                            class="tb-map-info-window__close-button"
                            data-toubiz-map-info-window-close-button>

                            <svg class="c-icon" aria-hidden="true">
                                <use xlink:href="#tb-map-close" />
                            </svg>
                        </button>

                        <f:if condition="{article.mainMedium}">
                            <div class="tb-map-info-window__image-wrapper">
                                <img src="{article.mainMedium.sourceUri}" alt="{article.mainMedium.title}" />
                            </div>
                        </f:if>

                        <div class="tb-map-info-window__text">
                            <h2 class="tb-map-info-window__title">{article.name}</h2>
                            <div class="tb-map-info-window__attribute">
                                {article.categories.0.title}
                            </div>
                        </div>

                        <div class="tb-map-info-window__button-wrapper">


                            <poi:link.article article="{article}" class="tb-map-info-window__button">
                                <f:translate
                                    id="marker.infoWindow.moreLinkLabel"
                                    package="Newland.Toubiz.Map.Neos"
                                    source="Views/Map/Show" />

                            </poi:link.article>
                        </div>
                    </div>
                </div>
            </template>
        </f:if>
    </poi:splitscreen.configuration>
</f:section>
