<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

use Bitrix\Main\Localization\Loc;
use intec\core\helpers\Html;

/**
 * @var string $sTemplateId
 * @var string $sVariable
 * @var array $arValues
 * @var array $arYearList
 * @var array $arYearTabs
 * @var array $arYears
 * @var CAllMain $APPLICATION
 */

$currentYear = $arValues[$sVariable] ?? null;

if (empty($currentYear)) {
    $currentYear = Loc::getMessage('BX_PHOTO_PANEL_RESET');
}

?>
<!--noindex-->
<?= Html::beginTag('div', [
    'class' => Html::cssClassFromArray([
        'news-panel' => true,
        'flex' => true,
        'ui-round-tiny' => true,
        'flex--a-h-end' => $arVisual['PANEL']['ALIGN'] === 'right',
        'flex--a-h-start' => $arVisual['PANEL']['ALIGN'] === 'left',
    ], true),
    'data' => [
        'role' => 'panel',
        'side' => $arVisual["SIDEBAR"]["USE"] ? 'true' : 'false',
    ]
]) ?>
    <?php if ($arVisual['PANEL']['SHOW']) { ?>
        <?= Html::beginTag('div', [
            'class' => Html::cssClassFromArray([
                'news-panel-content' => true,
                'flex' => true,
                'ui-btn-drop' => true,
                'flex-item' => true,
                'flex-item--grow-1' => true,
                'flex--a-h-end' => $arVisual['PANEL']['ALIGN'] === 'right',
                'flex--a-h-start' => $arVisual['PANEL']['ALIGN'] === 'left',
            ], true),
            'data' => [
                'role' => 'panel',
                'side' => $arVisual["SIDEBAR"]["USE"] ? 'true' : 'false',
            ]
        ]) ?>
            <?= Html::beginTag('div', [
                'class' => [
                    'news-panel-date-button',
                    'flex',
                    'ui' => [
                        'text-ntr-sd',
                        'bg-ntr-b',
                        'round-tiny',
                    ]
                ],
                'data' => [
                    'type' => 'button',
                    'drop-direction' => 'bottom',
                    'drop-offset' => '0,0'
                ]
            ]) ?>
                <?= Html::tag('div', Html::encode($currentYear), ['class' => 'news-panel-title']) ?>
                <?= Html::beginTag('div', [
                    'class' => [
                        'flex',
                        'news-panel-more',
                        'flex--a-v-center',
                    ],
                    'data-type' => 'arrow',
                    'data-state' => 'false',
                ]) ?>
                    <div class="news-panel-indicator flex-item ui-svg ui-svg-24 ui-svg-stroke-ntr-sd ui-svg-stroke-prm-hover">
                        <svg xmlns="http://www.w3.org/2000/svg">
                            <use xlink:href="#angleDown"></use>
                        </svg>
                    </div>
                <?= Html::endTag('div') ?>
            <?= Html::endTag('div'); ?>
            <div class="ui-btn-drop-content slim ind-m-t-10" data-type="content" data-state="false">
                <div class="flex flex--o-vertical news-panel-wrapper">
                    <?php if (!empty($sVariable)) { ?>
                        <?= Html::tag(empty($arValues[$sVariable]) ? 'span' : 'a', Loc::getMessage('BX_PHOTO_PANEL_RESET'), [
                            'class' => [
                                'news-panel-date-item',
                                'flex-item',
                                'ui' => [
                                    'round-tiny',
                                    'text-ntr-sd',
                                    'text-prm-b-hover'
                                ]
                            ],
                            'href' => !empty($arValues[$sVariable]) ?
                                $APPLICATION->GetCurPageParam('', [$sVariable]) :
                                null,
                            'data' => [
                                'state' => empty($arValues[$sVariable]) ? 'active' : 'none',
                                'view' => 'all'
                            ]
                        ]) ?>
                    <?php } ?>
                    <?php foreach ($arYears as $arYear) { ?>
                        <?= Html::tag($arYear != $arValues[$sVariable] ? 'a' : 'span', $arYear, [
                            'class' => [
                                'news-panel-date-item',
                                'flex-item',
                                'ui' => [
                                    'text-height-2',
                                    'text-small',
                                    'round-tiny',
                                    'text-ntr-sd',
                                    'text-prm-b-hover'
                                ],
                                'ind' => [
                                    //'p-v-4',
                                    //'p-h-15'
                                ]
                            ],
                            'href' => $arYear != $arValues[$sVariable] ?
                                $APPLICATION->GetCurPageParam($sVariable.'='.$arYear, [$sVariable]) :
                                null,
                            'data-state' => $arYear == $arValues[$sVariable] ? 'active' : null
                        ]) ?>
                    <?php } ?>
                </div>
            </div>
        <?= Html::endTag('div'); ?>
    <?php } ?>
<?= Html::endTag('div'); ?>
<!--/noindex-->
