<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Http\RequestHandlers\AutoCompleteSurname;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Tree;

/**
 * @var string $ajax_url
 * @var bool   $soundex_dm
 * @var bool   $soundex_std
 * @var string $surname
 * @var string $title
 * @var Tree   $tree
 */

?>

<h2 class="wt-page-title">
    <?= $title ?>
</h2>

<form method="post" class="wt-page-options wt-page-options-branches d-print-none">
    <div class="row mb-3">
        <label class="col-form-label col-sm-3 wt-page-options-label" for="surname">
            <?= I18N::translate('Surname') ?>
        </label>

        <div class="col-sm-9 wt-page-options-value">
            <input class="form-control" data-wt-autocomplete-url="<?= e(route(AutoCompleteSurname::class, ['tree' => $tree->name()])) ?>" autocomplete="off" type="text" name="surname" id="surname" value="<?= e($surname) ?>" dir="auto" required="required">
        </div>
    </div>

    <fieldset class="row mb-3">
        <legend class="col-form-label col-sm-3 wt-page-options-label">
            <?= I18N::translate('Phonetic search') ?>
        </legend>

        <div class="col-sm-9 wt-page-options-value">
            <?= view('components/checkbox-inline', ['label' => I18N::translate('Russell'), 'name' => 'soundex_std', 'checked' => $soundex_std]) ?>
            <?= view('components/checkbox-inline', ['label' => I18N::translate('Daitch-Mokotoff'), 'name' => 'soundex_dm', 'checked' => $soundex_dm]) ?>
        </div>
    </fieldset>

    <div class="row mb-3">
        <div class="col-sm-3 wt-page-options-label"></div>

        <div class="col-sm-9 wt-page-options-value">
            <button type="submit" class="btn btn-primary">
                <?= /* I18N: A button label. */ I18N::translate('view') ?>
            </button>
        </div>
    </div>

    <?= csrf_field() ?>
</form>

<?php if ($ajax_url !== '') : ?>
    <div class="wt-page-content wt-chart wt-branches" data-wt-ajax-url="<?= e($ajax_url) ?>">
        <?= view('icons/spinner') ?>
    </div>
<?php endif ?>
