<?php

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Http\RequestHandlers\UserListPage;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Media;
use Fisharebest\Webtrees\Module\ModuleSidebarInterface;
use Fisharebest\Webtrees\Module\ModuleTabInterface;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\User;
use Illuminate\Support\Collection;

/**
 * @var string                             $age
 * @var Collection<Fact>                   $clipboard_facts
 * @var Collection<Media>                  $individual_media
 * @var Individual                         $record
 * @var Collection<string>                 $shares
 * @var Collection<ModuleSidebarInterface> $sidebars
 * @var Collection<ModuleTabInterface>     $tabs
 * @var Tree                               $tree
 * @var Collection<User>                   $users
 */
?>

<?= view('individual-page-pending', ['record' => $record]) ?>

<div class="d-flex mb-4">
    <h2 class="wt-page-title mx-auto">
        <?= $record->fullName() ?>, <?= $record->lifespan() ?> <?= $age ?>
        <?php foreach ($users as $user) : ?>
            — <a href="<?= e(route(UserListPage::class, ['filter' => $user->email()])) ?>">
                <?= e($user->userName()) ?>
            </a>
        <?php endforeach ?>
    </h2>

    <?php if ($record->canEdit()) : ?>
        <?= view('individual-page-menu', ['clipboard_facts' => $clipboard_facts, 'record' => $record, 'shares' => $shares]) ?>
    <?php endif ?>
</div>

<div class="row">
    <div class="col">
        <div class="row mb-4">
            <?= view('individual-page-images', ['individual_media' => $individual_media, 'record' => $record, 'tree' => $tree]) ?>

            <?= view('individual-page-names', ['record' => $record]) ?>
        </div>

        <?= view('individual-page-tabs', ['record' => $record, 'tabs' => $tabs]) ?>
    </div>

    <?php if ($sidebars->isNotEmpty()) : ?>
        <?= view('individual-page-sidebars', ['record' => $record, 'sidebars' => $sidebars]) ?>
    <?php endif ?>
</div>

<?= view('modals/ajax') ?>
<?= view('modals/shares', ['shares' => $shares, 'title' => I18N::translate('Share') . ' — ' . $record->fullName()]) ?>
