<div class="PrePlayPageHeader-altPageHeader-3bZbS PrePlayPageHeader-pageHeader-2o14F PageHeader-pageHeader-18RSw">
    <div class="PageHeaderLeft-pageHeaderLeft-2TxSo">
        <a href="/tvshow/<?php echo $season->getTvShow()->id; ?>"
                role="link" class="PageHeaderBreadcrumbButton-link-1N0DD Link-link-2XYrU Link-default-32xSO"><?php echo $season->getTvShow()->title; ?></a>
        <button aria-haspopup="true" role="button"
                class="PageHeaderBreadcrumbButton-button-1uaPj DisclosureArrowButton-disclosureArrowButton-3tbYZ DisclosureArrowButton-medium-3-Y37  Link-link-2XYrU Link-default-32xSO"
                type="button"><?php echo $season->title; ?>
            <div class="DisclosureArrowButton-disclosureArrow-34Wg3 DisclosureArrow-disclosureArrow-1sBFv DisclosureArrowButton-down-bd2wx DisclosureArrowButton-medium-3-Y37 DisclosureArrow-down-1U7WW DisclosureArrow-up-rjGpc DisclosureArrow-default-3_FCW DisclosureArrow-medium-3VjTd "></div>
        </button>
    </div>
    <div class="PageHeaderRight-pageHeaderRight-2CT0g">
        <div class="pageHeaderToolbar-toolbarContainer-2N-IJ Measure-container-2XznZ">
            <div class="pageHeaderToolbar-toolbar-1lW-M">
                <button id="id-22" title="<?php echo __('play'); ?>" data-toggle="tooltip" data-placement="bottom" role="button"
                        class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO"
                        type="button"><i class="plex-icon-toolbar-play-560"></i></button>
                <button id="id-23" title="<?php echo __('random_order'); ?>" data-toggle="tooltip" data-placement="bottom" role="button"
                        class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO"
                        type="button"><i class="plex-icon-toolbar-shuffle-560"></i></button>
                <button id="id-24" title="<?php echo __('add_to_queue'); ?>" data-toggle="tooltip" data-placement="bottom"
                        role="button"
                        class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO"
                        type="button"><i class="plex-icon-toolbar-add-to-playlist-560"></i></button>
                <button id="id-21" title="<?php echo __('more'); ?>..." data-toggle="tooltip" data-placement="bottom" role="button"
                        class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO"
                        type="button"><i class="plex-icon-toolbar-more-560"></i></button>
            </div>
            <div class="Measure-scrollContainer-3vb4J">
                <div class="Measure-expandContent-1JQfL"></div>
            </div>
            <div class="Measure-scrollContainer-3vb4J">
                <div class="Measure-shrinkContent-32Udi Measure-expandContent-1JQfL"></div>
            </div>
        </div>
        <div class="PrePlayPageHeader-divider-WQRk8 PageHeaderDivider-pageHeaderDivider-DvwUq"></div>
        <button id="id-15" title="<?php echo __('show_poster'); ?>" data-toggle="tooltip" data-placement="bottom" role="button"
                class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO" type="button">
            <i class="plex-icon-toolbar-artwork-560" aria-hidden="true"></i></button>
        <div class="PageHeaderDivider-pageHeaderDivider-DvwUq"></div>
        <div>
            <button id="id-18" data-qa-id="toolbarPrevious" role="button"
                    class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO isDisabled "
                    type="button" disabled=""><i class="plex-icon-page-prev-560"
                                                                          aria-hidden="true"></i></button>
            <button id="id-19" data-qa-id="toolbarNext" role="button"
                    class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO isDisabled "
                    type="button" disabled=""><i class="plex-icon-page-next-560"
                                                                          aria-hidden="true"></i></button>
        </div>
    </div>
</div>
<div class="PrePlayPageContent-prePlayPageContentContainer-1ckaM PageContent-pageContent-16mK6">
    <div class="PrePlayPageContent-prePlayPageContent-1fFCH Scroller-scroller-d5-b- Scroller-vertical-1bgGS ">
        <div class="PageContent-innerPageContent-3ktLT">
            <div>
                <div style="position: fixed; top: 180px;">
                    <div class="MetadataPosterCard-cardContainer-2gRcQ"
                         data-qa-id="metadataPosterCard--/library/metadata/28083">
                        <div class="MetadataPosterCard-card-3bztR " style="width: 260px; height: 390px;">
                            <div class="PrePlayPosterCard-face-3rQEj MetadataPosterCardFace-face--dz_D MetadataPosterCardFace-poster-L2P6r MetadataPosterCardFace-faceFront-1bxHG  ">
                                <i class="plex-icon-shows-560  MetadataPosterCardIcon-placeholderIcon-2P76z" aria-hidden="true" style="font-size: 42px; line-height: 390px;"></i>
                                <div class="PosterCardImg-imageContainer-1Ar4M" data-season-id="<?php echo $season->id; ?>">
                                    <div style="background-image: url(); background-size: cover; background-position: center center; background-repeat: no-repeat; width: 100%; height: 100%; position: absolute; z-index: 2;"
                                         class=""></div>
                                </div>
                                <div class=" MetadataPosterCardOverlay-overlay-1uMpL         ">
                                    <div class="MetadataPosterCardOverlay-background-2EwyB"></div>
                                    <div data-qa-id="metadataPosterUnwatchedNumberBadge"
                                         class="MetadataPosterCardOverlay-unwatchedBadge-Qn1fv MetadataPosterCardOverlay-badge-1FU-p">
                                        6
                                    </div>
                                    <button aria-label="Lire Saison 1" tabindex="-1"
                                            data-qa-id="metadataPosterPlayButton" role="button"
                                            class="MetadataPosterCardOverlay-playCoverButton-I7oU3 MetadataPosterCardOverlay-playButton-1fjhk PlayButton-playButton-3WX8X MetadataPosterCardOverlay-button-M43H- Link-link-2XYrU Link-default-32xSO      "
                                            type="button">
                                        <div class="MetadataPosterCardOverlay-playCircle-M67q6 PlayButton-playCircle-3Evfd MetadataPosterCardOverlay-centerCircle-1Mg-s">
                                            <i class="plex-icon-play-560 PlayButton-playIcon-dt3sk"
                                               aria-hidden="true"></i></div>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="PrePlayMetadataContent-content-2ww3j" style="padding-left: 320px;">
                    <div class="Measure-container-2XznZ">
                        <div class="PrePlayMetadataInnerContent-innerContent-1BPzw">
                            <div class="PrePlayPrimaryTitle-primaryTitle-1r9P9" data-qa-id="preplayMainTitle"><a
                                        data-qa-id="metadataTitleLink" title="<?php echo $season->getTvShow()->title; ?>"
                                        href="/tvshow/<?php echo $season->getTvShow()->id; ?>"
                                        role="link" class=" Link-link-2XYrU Link-default-32xSO      "><?php echo $season->getTvShow()->title; ?></a>
                            </div>
                            <div class="PrePlaySecondaryTitle-secondaryTitle-YJRGC PrePlayPrimaryTitle-primaryTitle-1r9P9"
                                 data-qa-id="preplaySecondTitle">
                                <div class="PrePlayLeftTitle-leftTitle-Ev1KG"><?php echo __('season'); ?> <?php echo $season->number; ?></div>
                            </div>
                        </div>
                        <div class="PrePlayDivider-divider-1qvbj"></div>
                        <div class="Measure-scrollContainer-3vb4J">
                            <div class="Measure-expandContent-1JQfL"></div>
                        </div>
                        <div class="Measure-scrollContainer-3vb4J">
                            <div class="Measure-shrinkContent-32Udi Measure-expandContent-1JQfL"></div>
                        </div>
                    </div>
                    <div class="PrePlayMetadataListInnerContent-innerContent-2CsIz">
                        <div class="PrePlayList-container-WZ86O HubCell-hubCell-3Ys17"
                             data-qa-id="preplayContainer--episode">
                            <div class="PrePlayDescendantList-descendantHubCellHeader-2qK3U HubCellHeader-hubCellHeader-2pvYN">
                                <div class="HubCellTitle-hubCellTitle-2abIn"><?php echo $season->leafCount; ?> <?php echo strtoupper(__('episodes')); ?>
                                </div>
                            </div>
                            <div style="margin-top: 15px">
                                <div class=" " style="width: 100%; height: auto;">
                                    <?php foreach ($season->getEpisodes() as $episode) : ?>
                                    <div class=" virtualized-cell-3KPHx " data-qa-id="cellItem" style="display: inline-block; margin-left: 20px;">
                                        <div class="MetadataPosterCard-cardContainer-2gRcQ">
                                            <div class="MetadataPosterCard-card-3bztR "
                                                 style="width: 192px; height: 108px;">
                                                <div class="MetadataPosterCardFace-face--dz_D MetadataPosterCardFace-poster-L2P6r MetadataPosterCardFace-faceFront-1bxHG  ">
                                                    <div class="PosterCardImg-imageContainer-1Ar4M" data-movie-id="<?php echo $episode->id; ?>">
                                                        <div style="background-image: url(); background-size: cover; background-position: center center; background-repeat: no-repeat; width: 100%; height: 100%; position: absolute; z-index: 2;"
                                                             class=""></div>
                                                    </div>
                                                    <div class=" MetadataPosterCardOverlay-overlay-1uMpL">
                                                        <div class="MetadataPosterCardOverlay-background-2EwyB"></div>
                                                        <a href="/episode/<?php echo $episode->id; ?>"
                                                           role="link"
                                                           class="MetadataPosterCardOverlay-link-1Swhl Link-link-2XYrU Link-default-32xSO      "></a>
                                                        <button tabindex="-1" role="button" data-id="<?php echo $episode->id; ?>"
                                                                class="MetadataPosterCardOverlay-playButton-1fjhk PlayButton-playButton-3WX8X MetadataPosterCardOverlay-button-M43H- Link-link-2XYrU Link-default-32xSO      "
                                                                type="button">
                                                            <div class="MetadataPosterCardOverlay-playCircle-M67q6 PlayButton-playCircle-3Evfd MetadataPosterCardOverlay-centerCircle-1Mg-s">
                                                                <i class="plex-icon-play-560 PlayButton-playIcon-dt3sk"
                                                                   aria-hidden="true"></i></div>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div data-qa-id="metadataTitleContainer"
                                             class="MetadataPosterCell-titleContainer-24DI6">
                                            <a title="<?php echo $episode->title; ?>" href="/episode/<?php echo $episode->id; ?>"
                                                    role="link" style="width: 192px;"
                                                    class=" MetadataPosterTitle-singleLineTitle-24_DN MetadataPosterTitle-title-3tU5F Link-link-2XYrU Link-default-32xSO">
                                                <?php echo $episode->title; ?>
                                            </a>
                                            <span class=" MetadataPosterTitle-singleLineTitle-24_DN MetadataPosterTitle-title-3tU5F MetadataPosterTitle-isSecondary-2VUxY "><?php echo __('episode'); ?> <?php echo $episode->number; ?></span>
                                        </div>
                                    </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                        </div>
                        <div class="PrePlayMetadataInnerContent-innerContent-1BPzw">
                            <div class="PrePlayCastList-castList-3dQB5"></div>
                            <div class="PrePlayRelatedList-relatedList-2fY8S"
                                 style="opacity: 0; pointer-events: none;"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="Measure-scrollContainer-3vb4J">
        <div class="Measure-expandContent-1JQfL"></div>
    </div>
    <div class="Measure-scrollContainer-3vb4J">
        <div class="Measure-shrinkContent-32Udi Measure-expandContent-1JQfL"></div>
    </div>
</div>
<div class="Menu-select-season hidden" style="position: absolute; top: 60px;">
    <div id="id-1865">
        <div role="menu" class="MenuContainer-menu-3Gtlw MenuContainer-medium-2XOYJ">
            <div class="Menu-menuScroller-E0NwY Scroller-vertical-1bgGS Scroller-scroller-d5-b- Scroller-vertical-1bgGS Scroller-auto-3t4gM" style="max-height: 591px;">
                <?php foreach ($seasons as $one_season) : ?>
                <a role="menuitem" href="/season/<?php echo $one_season->id; ?>" class="<?php echo $one_season->id === $season->id ? 'SelectedMenuItem-isSelected-3zuEi' : ''; ?> MenuItem-menuItem-25266 MenuItem-default-tX5Cl Link-link-2XYrU Link-default-32xSO">
                    <div class="SelectedMenuItem-menuItemContainer-7SpJZ">
                        <div class="SelectedMenuItem-menuLabel-1tKeW"><?php echo $one_season->title; ?></div>
                    </div>
                </a>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(window).on('load', function() {
        $(document).on('click', '.MetadataPosterCardOverlay-playButton-1fjhk.PlayButton-playButton-3WX8X', function (event) {
            event.stopPropagation();
            var movie_id = $(this).data('id');
            $.ajax({
                url: '/rest/movie/stream',
                method: 'GET',
                data: { movie_id : movie_id },
                dataType: 'html'
            }).done(function(view) {
                launchPlayer(view);
            }).fail(function (data) {
                console.error(data.responseText);
                show_alert('error', data.responseText);
            });
        });
    });
    /** SHOW SEASON LIST **/
    $('.PageHeaderBreadcrumbButton-button-1uaPj').on('click', function (event) {
        event.stopPropagation();
        $(this).find('.DisclosureArrow-disclosureArrow-1sBFv').toggleClass('DisclosureArrowButton-down-bd2wx DisclosureArrowButton-up-2fzdj');
        $('.Menu-select-season').css('left', $(this).position().left + 'px');
        $('.Menu-select-season').toggleClass('hidden');
    });
    $(document).on('mouseup', function() {
        if($('.Menu-select-season').css('display') !== 'none')
            $('.PageHeaderBreadcrumbButton-button-1uaPj').click();
    });
    /** LOAD COVER SEASON **/
    $('.PosterCardImg-imageContainer-1Ar4M[data-season-id]').each(function (index, element) {
        var season_id = $(element).data('season-id');
        $('[data-season-id="' + season_id + '"] > div').css('background-image', 'url("/cover/season?season_id='+ season_id +'&width='+ 338 +'&height='+ 488 +'")');

        /** CHANGE BACKGROUND **/
        var background = $('.background-container .FullPage-container-3qanw > div > div > div');
        $(background).css('background-image', 'url("/cover/season?season_id='+ season_id +'&width='+ 325 +'&height='+ 488 +'")');
        $(background).css('filter', 'blur(100px)');
        $(background).css('opacity', '0.3');
    });
    /** LOAD COVER EPISODE **/
    $('.PosterCardImg-imageContainer-1Ar4M[data-movie-id]').each(function (index, element) {
        var movie_id = $(element).data('movie-id');
        $('[data-movie-id="' + movie_id + '"] > div').css('background-image', 'url("/cover/movie?movie_id='+ movie_id +'&width='+ 240 +'&height='+ 135 +'&thumb=true")');
    });
</script>