<?php

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\View;
use Illuminate\Support\Collection;

/**
 * @var bool             $can_edit
 * @var Collection<Fact> $clipboard_facts
 * @var Collection<Fact> $facts
 * @var bool             $has_associate_facts
 * @var bool             $has_historic_facts
 * @var bool             $has_relative_facts
 * @var Individual       $individual
 */

?>

<div class="wt-tab-facts py-4">
    <table class="table wt-facts-table">
        <tbody>
            <tr>
                <td colspan="2">
                    <?php if ($has_associate_facts) : ?>
                        <label>
                            <input id="show-associate-facts" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-associate-fact" data-wt-persist="associates">
                            <?= I18N::translate('Associated events') ?>
                        </label>
                    <?php endif ?>

                    <?php if ($has_relative_facts) : ?>
                        <label>
                            <input id="show-relatives-facts" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-relation-fact" data-wt-persist="relatives">
                            <?= I18N::translate('Events of close relatives') ?>
                        </label>
                    <?php endif ?>

                    <?php if ($has_historic_facts) : ?>
                        <label>
                            <input id="show-historical-facts" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-historic-fact" data-wt-persist="historic-facts">
                            <?= I18N::translate('Historic events') ?>
                        </label>
                    <?php endif ?>
                </td>
            </tr>

            <?php foreach ($facts as $fact) : ?>
                <?php FunctionsPrintFacts::printFact($fact, $individual) ?>
            <?php endforeach ?>

            <?php if ($facts->isEmpty()) : ?>
                <tr>
                    <td colspan="2">
                        <?= I18N::translate('There are no facts for this individual.') ?>
                    </td>
                </tr>
            <?php endif ?>

            <?php if ($individual->canEdit()) : ?>
                <?php FunctionsPrint::printAddNewFact($individual) ?>
            <?php endif ?>
        </tbody>
    </table>
</div>
