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

use Bitrix\Main\Localization\Loc;
use intec\core\helpers\Html;
use intec\core\platform\main\Component;

/** @var array $arParams */
/** @var array $arResult */
/** @var CBitrixComponentTemplate $this */
/** @var CBitrixComponent $component */

$this->setFrameMode(true);
$templateId = Html::getUniqueId(null, Component::getUniqueId($this, false));
$visual = &$arResult['VISUAL'];
$templateId = $templateId . '_' . $visual['INPUT']['ID'];

?>
<!--googleoff: all-->
<!--noindex-->
<?= Html::beginTag('div', [
    'id' => $templateId,
    'class' => [
        'ns-bitrix',
        'c-search-title',
        'c-search-title-popup-1'
    ],
    'data-theme' => $visual['THEME'],
    'data-full' => $visual['FULL'] ? 'true' : null
]) ?>
    <?php if (empty($visual['INPUT']['ID'])) { ?>
        <div style="text-align: center; color: red; padding: 30px 0">
            <?= Loc::getMessage('C_SEARCH_TITLE_POPUP_1_ERROR_INPUT_ID_EMPTY') ?>
        </div>
    <?php } else { ?>
        <?= Html::beginTag('div', [
            'class' => [
                'search-title-button',
                'search-main-theme',
                Html::cssClassFromArray([
                    'ui' => [
                        'text' => [
                            'ntr-d' => !$visual['BUTTON']['LIGHT'],
                            'ntr-b' => $visual['BUTTON']['LIGHT']
                        ]
                    ]
                ], true)

            ],
            'data-action' => 'search.open'
        ]) ?>
            <div class="flex flex--a-v-end">
                <div class="search-title-button-icon flex-item ui-svg-24">
                    <svg xmlns="http://www.w3.org/2000/svg">
                        <use xlink:href="#loupe"></use>
                    </svg>
                </div>
                <?php if ($visual['BUTTON']['TEXT']['SHOW']) { ?>
                    <div class="flex-item ind-p-l-8" data-hidden="mobile">
                        <?= !empty($visual['BUTTON']['TEXT']['VALUE']) ?
                            $visual['BUTTON']['TEXT']['VALUE'] :
                            Loc::getMessage('C_SEARCH_TITLE_POPUP_1_BUTTON');
                        ?>
                    </div>
                <?php } ?>
            </div>
        <?= Html::endTag('div') ?>
        <?= Html::tag('div', null, [
            'class' => 'search-title-overlay',
            'data' => [
                'role' => 'overlay',
                'action' => 'search.close'
            ]
        ]) ?>
        <?= Html::beginTag('div', [
            'class' => Html::cssClassFromArray([
                'search-title' => true,
                'ui-bg-ntr-b' => !$visual['FULL'],
                'ind-m-ng-b-2' => true
            ], true),
            'data-role' => 'panel',
            'id' => $templateId . '-panel'
        ]) ?>
            <div class="search-title-wrapper template-container template-container-ignore ind-p-v-45 ind-768-p-v-11">
                <?= Html::beginForm($arResult['FORM_ACTION'], 'get', [
                    'class' => [
                        'search-title-form-wrapper',
                        'flex'
                    ],
                    'data-role' => 'search.form'
                ]) ?>
                    <div class="flex-item flex-item--grow-1">
                        <?= Html::textInput('q', null, [
                            'class' => [
                                'search-title-form-input',
                                'ui-input-text'
                            ],
                            'id' => $visual['INPUT']['ID'],
                            'autocomplete' => 'off',
                            'placeholder' => $visual['INPUT']['TEXT'],
                            'data' => [
                                'role' => 'input'
                            ]
                        ]) ?>
                        <div class="search-title-form-clear flex flex--a-v-center">
                            <div class="search-title-form-clear-button flex-item" data-action="search.clear" data-hidden="true">
                                <?= Html::tag('div', Loc::getMessage('C_SEARCH_TITLE_POPUP_1_BUTTON_CLEAR'), [
                                    'class' => [
                                        'search-title-form-clear-button-text',
                                        'ui-text' => [
                                            'large',
                                            'height-2',
                                            'ntr-qd',
                                            'prm-hover'
                                        ]
                                    ],
                                    'data-hidden' => 'mobile'
                                ]) ?>
                                <div class="search-title-form-clear-button-svg ui-svg-24 ui-svg-stroke-prm" data-hidden="desktop">
                                    <svg xmlns="http://www.w3.org/2000/svg">
                                        <use xlink:href="#cross"></use>
                                    </svg>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="flex-item ind-p-l-24" data-hidden="mobile">
                        <?= Html::submitButton(Loc::getMessage('C_SEARCH_TITLE_POPUP_1_BUTTON_START'), [
                            'class' => [
                                'search-title-form-button-submit',
                                'ind-p-h-32',
                                'ui' => [
                                    'button' => [
                                        '',
                                    ],
                                    'text-large'
                                ]
                            ],
                            'data-action' => 'search.submit'
                        ]) ?>
                    </div>
                    <div class="flex-item flex-item--a-center ind-p-l-32 ind-768-p-l-16">
                        <div class="search-title-form-button-close" data-action="search.close">
                            <div class="ui-text-small ui-text-prm" data-hidden="desktop">
                                <?= Loc::getMessage('C_SEARCH_TITLE_POPUP_1_BUTTON_CLOSE') ?>
                            </div>
                            <div class="ui-svg-32 ui-svg-stroke-ntr-sd" data-hidden="mobile">
                                <svg xmlns="http://www.w3.org/2000/svg">
                                    <use xlink:href="#cross"></use>
                                </svg>
                            </div>
                        </div>
                    </div>
                <?= Html::endForm() ?>
            </div>
        <?= Html::endTag('div') ?>
        <?php include(__DIR__ . '/parts/script.php') ?>
    <?php } ?>
<?= Html::endTag('div') ?>
<!--/noindex-->
<!--googleon: all-->