<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Location;
use Fisharebest\Webtrees\Place;

/**
 * @var string            $edit_url
 * @var int               $id
 * @var Place             $place
 * @var bool              $showlink
 * @var string            $sidebar_class
 * @var array<string,int> $stats
 */
?>

<li class="gchart px-md-2 mb-1 <?= $sidebar_class ?>" data-wt-feature-id="<?= $id ?>">
    <div class="row label">
        <div class="col text-break">
            <?php if ($showlink) : ?>
                <a href="<?= e($place->url()) ?>">
                    <?= $place->placeName() ?>
                </a>
            <?php else : ?>
                <?= $place->placeName() ?>
            <?php endif ?>
        </div>
    </div>

    <?php if ($sidebar_class === 'unmapped') : ?>
        <div class="row">
            <div class="col-sm-9"><i><?= I18N::translate('The location of this place is not known.') ?></i></div>
            <?php if ($edit_url === '') : ?>
                <div class="col-sm-3 align-digits"><?= view('icons/warning') ?></div>
            <?php else : ?>
                <div class="col-sm-3 align-digits"><a class="col-sm-3 align-digits"><a href="<?= e($edit_url) ?>"><?= view('icons/edit') ?></a></div>
            <?php endif ?>
        </div>
    <?php endif ?>

    <div class="row">
        <div class="col-sm-9"><?= I18N::translate('Individuals') ?></div>
        <div class="col-sm-3 align-digits"><?= I18N::number($stats[Individual::RECORD_TYPE]) ?></div>
    </div>

    <?php if ($stats[Family::RECORD_TYPE] > 0) : ?>
        <div class="row">
            <div class="col-sm-9"><?= I18N::translate('Families') ?></div>
            <div class="col-sm-3 align-digits"><?= I18N::number($stats[Family::RECORD_TYPE]) ?></div>
        </div>
    <?php endif ?>

    <?php if ($stats[Location::RECORD_TYPE] > 0) : ?>
        <div class="row">
            <div class="col-sm-9"><?= I18N::translate('Locations') ?></div>
            <div class="col-sm-3 align-digits"><?= I18N::number($stats[Location::RECORD_TYPE]) ?></div>
        </div>
    <?php endif ?>
</li>
