public static function surnameTagCloud(array $surnames, ?ModuleListInterface $module, bool $totals, Tree $tree): string
    {
        $minimum = PHP_INT_MAX;
        $maximum = 1;
        foreach ($surnames as $surn => $surns) {
            foreach ($surns as $spfxsurn => $count) {
                $maximum = max($maximum, $count);
                $minimum = min($minimum, $count);
            }
        }

        $html = '';
        foreach ($surnames as $surn => $surns) {
            foreach ($surns as $spfxsurn => $count) {
                if ($maximum === $minimum) {
                    // All surnames occur the same number of times
                    $size = 150.0;
                } else {
                    $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum);
                }
                
                $tag = ($module instanceof ModuleListInterface) ? 'a' : 'span';
                $html .= '<' . $tag . ' style="font-size:' . $size . '%"';
                if ($module instanceof ModuleListInterface) {
                    $url = $module->listUrl($tree, ['surname' => $surn]);
                    $html .= ' href="' . e($url) . '"';
                }
                $html .= '>';
                if ($totals) {
                    $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $spfxsurn . '</span>', I18N::number($count));
                } else {
                    $html .= $spfxsurn;
                }
                $html .= '</' . $tag . '> ';
            }
        }

        return '<div class="tag_cloud">' . $html . '</div>';
    }