<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
/** @var array $arParams */
/** @var array $arResult */
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponentTemplate $this */
/** @var string $templateName */
/** @var string $templateFile */
/** @var string $templateFolder */
/** @var string $componentPath */
/** @var CBitrixComponent $component */
$this->setFrameMode(true);

?>
<div id="page">
    <div class="events-list">
        <div class="events__top-events">
            <?php foreach ($arResult["ITEMS"] as $k => $arItem) {
                if ($k > 1) break;
                $imgSrcMob = CFile::GetPath($arItem["PROPERTIES"]['PREVIEW_PICTURE_MOB']['VALUE']);
                $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
                $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
                ?>
                <div class="article-card events__top-events-card article-card--top-events">
                    <a class="article-card__inner" href="<?=$arItem['DETAIL_PAGE_URL']?>">
                        <div class="article-card__status">
                            <?
                            $soontop=soon($arItem['PROPERTIES']["DATE"]["VALUE"]);
                            if ($soontop=="прошло"){
                                $classtop="tag-text--red-dot";
                            } else   $classtop="tag-text--green";
                            ?>
                            <div class="tag-text  <?=$classtop?> tag-text--top-events">
                                <p class="tag-text__text"><?=$soontop?></p>
                            </div>
                        </div>
                        <div class="article-card__image">
                        <? if ($arItem['PREVIEW_PICTURE']['SRC']) {
                            $imgSrcMob = CFile::GetPath($arItem['PROPERTIES']['PREVIEW_PICTURE_MOB']['VALUE']);
                            ?>
                                <picture>
                                    <source media="(min-width: 768px)"
                                            srcset="<?= $arItem['PREVIEW_PICTURE']['SRC'] ?>"
                                            type="image/webp">
                                    <source media="(max-width: 767px)"
                                            srcset="<?= $imgSrcMob ?>"
                                            type="image/webp">
                                    <img src="<?= $arItem['PREVIEW_PICTURE']["SRC"] ?>"
                                         srcset="<?= $arItem['PREVIEW_PICTURE']['SRC'] ?>, <?= $arItem['PREVIEW_PICTURE']['SRC'] ?>"
                                         alt="<?= $arItem['NAME'] ?>" width="148" height="101" loading="lazy">
                                </picture>

                        <? } ?>
                        </div>
                        <h2 class="title article-card__title"><?= $arItem['NAME'] ?> </h2>
                        <div class="article-card__text">
                            <p><?= $arItem['PREVIEW_TEXT'] ?> </p>
                        </div>
                        <div class="item-info item-info--top-events">
                            <div class="item-info__wrap">
                                <p class="item-info__category">
                                    <?=$arItem['PROPERTIES']['LINE']['VALUE']?>
                                </p>

                                <time class="item-info__date item-info__date--hot" datetime="2024-08-25">
                                    <svg width="0.95em" height="1em" viewBox="0 0 18 19" data-icon="icon-flame">

                                        <symbol id="ai:local:icon-flame">
                                            <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
                                                  stroke-width="1.4"
                                                  d="M9 9.5c1.5-2.22 0-5.25-.75-6C8.25 5.779 6.92 7.056 6 8c-.92.945-1.5 2.43-1.5 3.75a4.5 4.5 0 1 0 9 0c0-1.149-.792-2.955-1.5-3.75-1.34 2.25-2.093 2.25-3 1.5Z"></path>
                                        </symbol>
                                        <use xlink:href="#ai:local:icon-flame"></use>

                                    </svg>
                                    <?=rusdate($arItem['PROPERTIES']["DATE"]["VALUE"])?>
                                </time>

                            </div>

                        </div>
                    </a>
                </div>
            <? } ?>
        </div>
        <div id="page-events">
            <ul class="events__list is-show-half">
            <?php foreach ($arResult["ITEMS"] as $k=>$arItem) :
                if ($k<2) continue;
                $imgSrcMob=CFile::GetPath($arItem["PROPERTIES"]['PREVIEW_PICTURE_MOB']['VALUE']);
                $this->AddEditAction($arItem['ID'], $arItem['EDIT_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_EDIT"));
                $this->AddDeleteAction($arItem['ID'], $arItem['DELETE_LINK'], CIBlock::GetArrayByID($arItem["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
                if($arItem['PROPERTIES']["LINE"]["VALUE"]=="онлайн"){
                    $hash="online";
                } elseif($arItem['PROPERTIES']["LINE"]["VALUE"]=="оффлайн") {
                    $hash="offline";
                }else{
                    $hash = "";
                }
                ?>
                <li data-hash="<?=$hash?>" class="events__item"  id="<?= $this->GetEditAreaId($arItem['ID']); ?>">
                    <div class="article-card article-card--events-list">
                        <a class="article-card__inner" href="<?= $arItem['DETAIL_PAGE_URL'] ?>">
                            <div class="article-card__status">
                                <?
                                 $soon=soon($arItem['PROPERTIES']["DATE"]["VALUE"]);
                                 if ($soon=="прошло"){
                                     $class="tag-text--red-dot";
                                 } else   $class="tag-text--green";
                                ?>
                                <div class="tag-text <?=$class?> tag-text--events-list">
                                    <p class="tag-text__text"><?=$soon?></p>
                                </div>
                            </div>
                            <?if ($arItem['PREVIEW_PICTURE']['SRC']){
                                $imgSrcMob=CFile::GetPath($arItem['PROPERTIES']['PREVIEW_PICTURE_MOB']['VALUE']);
                                ?>
                                <div class="article-card__image">
                                    <picture>
                                        <source media="(min-width: 768px)"
                                                srcset="<?= $arItem['PREVIEW_PICTURE']['SRC'] ?>, <?= $arItem['PREVIEW_PICTURE']['SRC'] ?>, <?= $arItem['PREVIEW_PICTURE']['SRC'] ?>"
                                                type="image/webp">
                                        <source media="(max-width: 767px)"
                                                srcset="<?= $imgSrcMob ?>, <?= $imgSrcMob ?>, <?= $imgSrcMob ?>"
                                                type="image/webp">
                                        <img src="<?= $arItem['PREVIEW_PICTURE']["SRC"] ?>"
                                             srcset="<?= $arItem['PREVIEW_PICTURE']['SRC'] ?>, <?= $arItem['PREVIEW_PICTURE']['SRC'] ?>"
                                             alt="<?= $arItem['NAME'] ?>" width="148" height="101" loading="lazy">
                                    </picture>

                                </div>
                            <?}?>
                            <h2 class="title article-card__title"><?= $arItem['NAME'] ?> </h2>
                            <div class="article-card__text">
                                <p><?= $arItem['PREVIEW_TEXT'] ?> </p>
                            </div>
                            <div class="item-info item-info--events-list">
                                <div class="item-info__wrap">
                                    <p class="item-info__category"> <?=$arItem['PROPERTIES']['LINE']['VALUE']?></p>
                                    <time class="item-info__date"
                                          datetime="<?= $arItem['PROPERTIES']["DATE"]["VALUE"] ?>">
                                        <?= explode(' ', $arItem['PROPERTIES']["DATE"]["VALUE"])[0] ?>
                                    </time>
                                </div>

                            </div>
                        </a>
                    </div>
                </li>
            <?endforeach;?>


        </ul>
        </div>
    </div>
</div>
<?php if ($arParams["DISPLAY_BOTTOM_PAGER"]) { ?>
    <?= $arResult["NAV_STRING"] ?>
<?php } ?>