{namespace vh=Newland\NeosViewHelpers\ViewHelpers}

<span data-vue="poi" style="display: none;">

    <tb-opening-times-line-preview
        :opening-times-definition="{article.openingTimes}"
        opening-times-format="{article.openingTimesFormat}"
        date-format="{vh:translate(id: 'dateFormat', package: 'Newland.Toubiz.Poi.Neos', source: 'Views/OpeningTimes')}"
        @click="toggleOpenState">

        <template #label_open="{ openingTimes }">
            <strong class="tb-hours-now__state text-positive">
                <vh:translate id="heading.open" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
                <vh:translate
                    id="heading.open.until"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.timeRange.end }}' }"/>

            </span>
        </template>

        <template #label_open_closing_soon_reopens_today="{ openingTimes }">
            <strong class="tb-hours-now__state text-orange">
                    <vh:translate id="heading.closingSoon" package="Newland.Toubiz.Poi.Neos"
                                  source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
            <vh:translate
                id="subtext.closesAt"
                package="Newland.Toubiz.Poi.Neos"
                source="Views/OpeningTimes"
                arguments="{ 0: '{{ openingTimes.timeRange.end }}' }"/>

            </span>
            <span class="inline-block">
                <vh:translate
                    id="subtext.opensAgainAt"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning }}', 1: '{{ openingTimes.nextTimeRange.end }}' }"/>

            </span>
        </template>

        <template #label_open_closing_soon="{ openingTimes }">
            <strong class="tb-hours-now__state text-orange">
                <vh:translate id="heading.closingSoon" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.closesAt"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.timeRange.end }}' }"/>

            </span>
       </template>

        <template #label_open_reopens_today="{ openingTimes }">
            <strong class="tb-hours-now__state text-positive">
                <vh:translate id="heading.open" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <vh:translate
                id="heading.open.until"
                package="Newland.Toubiz.Poi.Neos"
                source="Views/OpeningTimes"
                arguments="{ 0: '{{ openingTimes.timeRange.end }}' }"/>

            <span class="inline-block">
                <vh:translate
                    id="subtext.opensAgainAt"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning }}', 1: '{{ openingTimes.nextTimeRange.end }}' }"/>

            </span>
        </template>

        <template #label_closed_opens_soon="{ openingTimes }">
            <strong class="tb-hours-now__state text-orange">
                <vh:translate id="heading.openSoon" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.openTime"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

            </span>
        </template>

        <template #label_closed_opens_today="{ openingTimes }">
             <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closed" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
             </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.openTime"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning }}', 1: '{{ openingTimes.nextTimeRange.end }}' }"/>

            </span>
        </template>

        <template #label_closed_opens_tomorrow="{ openingTimes }">
             <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closedToday" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
             </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.openTomorrow"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning }}', 1: '{{ openingTimes.nextTimeRange.end }}' }"/>

            </span>
        </template>

        <template #label_closed_opens_day_after_tomorrow="{ openingTimes }">
            <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closedToday" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
             </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.openDayAfterTomorrow"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning }}', 1: '{{ openingTimes.nextTimeRange.end }}' }"/>

            </span>
        </template>

        <template #label_closed_opens_within_next_week="{ openingTimes }">
            <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closedToday" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
                <template v-if="openingTimes.nextOpenWeekday === 1">
                    <vh:translate
                        id="subtext.openOnWeekday.monday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 2">
                    <vh:translate
                        id="subtext.openOnWeekday.tuesday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 3">
                    <vh:translate
                        id="subtext.openOnWeekday.wednesday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 4">
                    <vh:translate
                        id="subtext.openOnWeekday.thursday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 5">
                    <vh:translate
                        id="subtext.openOnWeekday.friday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 6">
                    <vh:translate
                        id="subtext.openOnWeekday.saturday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else-if="openingTimes.nextOpenWeekday === 7 || openingTimes.nextOpenWeekday === 0">
                    <vh:translate
                        id="subtext.openOnWeekday.sunday"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
                <template v-else>
                    <!-- This case should never happen but was added as a safeguard -->
                    <vh:translate
                        id="closed_opensWithinNextWeek"
                        package="Newland.Toubiz.Poi.Neos"
                        source="Views/OpeningTimes"
                        arguments="{ 0: '{{ openingTimes.nextTimeRange.beginning}}', 1: '{{ openingTimes.nextTimeRange.end}}' }"/>

                </template>
            </span>
        </template>

        <template #label_closed_opens_on_date="{ openingTimes, nextOpenDate }">
            <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closedToday" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
            <span class="inline-block">
                <vh:translate
                    id="subtext.opensOn"
                    package="Newland.Toubiz.Poi.Neos"
                    source="Views/OpeningTimes"
                    arguments="{ 0: '{{ nextOpenDate }}', 1: '{{ openingTimes.nextTimeRange.beginning}}', 2: '{{ openingTimes.nextTimeRange.end}}' }"/>

            </span>
        </template>

        <template #label_closed="{ openingTimes }">
            <strong class="tb-hours-now__state text-negative">
                <vh:translate id="heading.closedToday" package="Newland.Toubiz.Poi.Neos" source="Views/OpeningTimes"/>
            </strong>
        </template>

        <f:if condition="{displayTable}">
            <template #additional_label>
                <svg class="c-icon" aria-hidden="true">
                    <use :xlink:href="open ? '#icon-arrow-up' : '#icon-arrow-down'"></use>
                </svg>
            </template>

            <template #additional_information="{ openingTimes, upcomingOpeningTimes }" v-if="open">
            <h3>
                <vh:translate
                    id="tableHeader"
                    source="Views/OpeningTimes"
                    package="Newland.Toubiz.Poi.Neos"/>

            </h3>

            <table class="tb-table tb-table--mobile-stack-third-cell-and-up">
                <tbody>
                    <tr v-for="upcoming in upcomingOpeningTimes">
                        <td>{{ $t('day.' + upcoming.weekday) }}</td>
                        <td v-if="upcoming.times && upcoming.times.timeRanges.length > 0">
                            {{ upcoming.times.timeRanges.join(', ') }}
                        </td>
                        <td v-else class="text-negative">
                            <vh:translate
                                id="closed"
                                source="Views/OpeningTimes"
                                package="Newland.Toubiz.Poi.Neos"/>

                        </td>
                    </tr>
                </tbody>
            </table>
        </template>
        </f:if>
    </tb-opening-times-line-preview>
</span>
