{% set productSets = accommodationResultSet is not empty ? accommodationResultSet.getMinPriceProductSets() : [] %}
{% set isCorridor = isCorridor is defined ? isCorridor : false %}
{% if tvbPackage is defined %}
{% set productSets = [productResultSet] %}
{% endif %}
{% if productSets is not defined or productSets is empty %}
{% set productSets = (productResultSet is defined and productResultSet is not empty and productResultSet.getProducts() is not null) ? productResultSet.getProducts() : [] %}
{% if packages is defined and packages is not null %}
{% set packageSets = [] %}
{% set minPrice = 0 %}
{% for hpm in packages %}
{% set packageSets = packageSets + (hpm.getRoomRows()|first).getProducts() %}
{% endfor %}
{# Cheapest product if there are packages but no rooms (no accommodationResultSet) #}
{% set cp = demi_getMinPriceOfHousePackageMasterResultSet(packageSets)["cP"] %}
{% set productSets = productSets + packageSets %}
{% elseif accommodationResultSet is instanceof('\\Elements\\Demi\\Accommodation\\Search\\ResultSet\\HousePackageMaster') %}
{# Cheapest product (no minPrice and package site) #}
{% set cp = demi_getMinPriceOfHousePackageMasterResultSet(accommodationResultSet)["cP"] %}
{% endif %}
{% if accommodationResultSet is defined and accommodationResultSet is not null and accommodationResultSet.getMinPriceBaseProductId() %}
{% set minId = accommodationResultSet.getMinPriceBaseProductId() %}
{% set productSets = productSets[minId] is defined ? [productSets[minId]] : [] %}
{% elseif availabilityIsChecked is defined and not availabilityIsChecked %}
{% if cp is defined and cp is not empty %}
{% set productSets = [cp] %}
{% endif %}
{% endif %}
{% endif %}
{% if accommodationResultSet is defined and accommodationResultSet is not null %}
{% set accommodation = pimcore_object(accommodationResultSet.getAccommodationId()) %}
{% endif %}
{% set href = "rooms" %}
{% if isPackage is defined and isPackage == true %}
{% set href = "booking" %}
{% endif %}
{% if accommodationResultSet is defined and accommodationResultSet is not null and accommodationResultSet.getRoomRows()|length < productSets|length %}
{% set productSets = productSets|slice(0,accommodationResultSet.getRoomRows()|length) %}
{% endif %}
{% if productSets is defined and productSets is not empty and (productSets|first) is not null %}
{% set rowCounter=0 %}
{% for productSet in productSets %}
{% set accommodationProduct = pimcore_object(productSet.getProductId()) %}
{% set mealObj = demi_getMealTypeByFid(productSet.getMealCode() ?? '') %}
{% if accommodationResultSet is not empty and accommodationResultSet.getRoomRows()[rowCounter] is not empty %}
{% set roomRow = accommodationResultSet.getRoomRows()[rowCounter].getRowObject() ?: null %}
{% endif %}
{% if mealObj is defined and mealObj is not null %}
<div class="small text-nowrap">
<div class="demi-icon demi-icon-restaurant mr-1 icon-in-text" aria-label="{{ 'demi.detail.room.meals'|trans }}" title="{{ "demi.detail.room.meals"|trans }}"></div>
{{ mealObj.getText() }}
</div>
{% endif %}
{% set price = productSet.getPrice()?: productSet.getBasePrice() %}
{% if price > 0 %}
<strong class="font-medium offer-box__price text-success">{{ 'demi.price-from-short'|trans }} {{ demi_paymentGetPriceObject(price, accommodation) }}</strong>
{% endif %}
{% set rowCounter = rowCounter +1 %}
{% if rowCounter == productSets|length %}
{% if roomRow is defined and roomRow is not empty %}
<a href="#{{ href }}"
data-target="#{{ href }}"
aria-controls="{{ href }}"
class="btn btn-success btn-block btn-lg js-open-tab-and-scroll">
<script data-cookieconsent="ignore">
_config.openTabAndSroll = true;
</script>
{{ "demi.detail.show-offer"|trans }}<span class="demi-icon demi-icon-arrow-right btn__icon ml-2" aria-hidden="true"></span>
</a>
{% elseif demi_accoBookableOrOfferable(accommodation, accommodationResultSet,demi_core_configuration("getDisableEnquiry",[])) %}
<button type="button" class="btn btn-success btn-block btn-lg js-overlay__toggle" data-target="#search-overlay">
{{ "demi.list.search-vacancies-button"|trans }}
{% endif %}
<div class="mt-2 text-center text-primary js-search-data__hide-if-submitted" {{ roomRow is defined and roomRow is not empty ? 'hidden' : '' }}>
<a class="js-open-tab-and-scroll" href="#{{ href }}">
<span class="demi-icon demi-icon-arrow-right btn__icon mr-1" aria-hidden="true"></span>{{ "demi.detail.show-all"|trans }} {{ demi_getRoomsTabTranslationKey(accommodation)|trans }}
</a>
</div>
{% else %}
<hr class="hr--border-gray my-4">
{% endif %}
{% endfor %}
{% else %}
{% if isCorridor is defined and isCorridor == true %}
<div>
{% if alternativeResultSet is not defined or alternativeResultSet is null %}
<div class="wysiwyg">
{{ "demi.detail.corridormatrix.choose-date-and-nights"|trans }}
</div>
{% endif %}
<a href="#{{ href }}"
data-target="#{{ href }}"
aria-controls="{{ href }}"
data-tracking-category="Accommodation detail"
data-tracking-category="click booking search info"
class="btn btn-success btn-block btn-lg js-open-tab-and-scroll mt-2 js-tracking--click">
{{ 'demi.detail.show-offers-corridor'|trans }}
</a>
</div>
{% else %}
<div>
<div class="wysiwyg">
{{ 'demi.detail.no-rooms'|trans }}
</div>
<button type="button" class="btn btn-success js-overlay__toggle" data-target="#search-overlay">
{{ "demi.search.change"|trans }}
</button>
</div>
{% endif %}
{% endif %}
{% if useCancellationInfo is defined and productSet is defined and productset is not empty and productSet.getCancellationInformation() is not empty %}
{% set cancellationInformation = productSet.getCancellationInformation() %}
{% set displayInfo = demi_getCancellationDisplayInfo(cancellationInformation,fromDate) %}
{% set freeCancelText = displayInfo.getFreeCancellationText() %}
{% set freeCancelText = freeCancelText == "" ? null : 'demi.list.free-cancellation'|trans %}
{% endif %}
{% if freeCancelText is defined %}
<div class="text-success small text-center mt-2">
{{ freeCancelText }}
</div>
{% endif %}