@namespace Lumeo.Docs.Shared

@{
    var icons = GetIconsForLibrary();
    var displayIcons = Count > 0 ? icons.Take(Count).ToList() : icons;
    var cols = Count > 0 ? "grid-cols-6" : "grid-cols-6";
}
<div class="@($"{(Count > 0 ? "" : "p-3")} {Class}".Trim())" @attributes="AdditionalAttributes">
    <div class="grid @cols gap-1.5">
        @foreach (var (icon, name) in displayIcons)
        {
            <Flex Class="flex-col items-center gap-0.5">
                <Blazicon Svg="@icon" class="@(Count > 0 ? "h-3.5 w-3.5 text-foreground" : "h-5 w-5 text-foreground")" />
                @if (Count == 0)
                {
                    <Lumeo.Text As="span" Class="text-[9px] text-muted-foreground truncate w-full text-center">@name</Lumeo.Text>
                }
            </Flex>
        }
    </div>
    @if (Count == 0)
    {
        <Lumeo.Text Class="text-[10px] text-muted-foreground text-center mt-2">@GetIconCount() icons · @GetPackageName()</Lumeo.Text>
    }
</div>

@code {
    [Parameter] public string Library { get; set; } = "lucide";
    [Parameter] public int Count { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private List<(SvgIcon Icon, string Name)> GetIconsForLibrary() => Library switch
    {
        "lucide" => [(Lucide.Search, "Search"), (Lucide.Settings, "Settings"), (Lucide.User, "User"), (Lucide.Heart, "Heart"), (Lucide.Star, "Star"), (Lucide.Bell, "Bell"), (Lucide.Mail, "Mail"), (Lucide.Calendar, "Calendar"), (Lucide.Check, "Check"), (Lucide.Plus, "Plus"), (Lucide.Minus, "Minus"), (Lucide.Eye, "Eye"), (Lucide.Lock, "Lock"), (Lucide.Trash, "Trash"), (Lucide.Share, "Share"), (Lucide.Download, "Download"), (Lucide.Upload, "Upload"), (Lucide.Phone, "Phone"), (Lucide.Camera, "Camera"), (Lucide.Image, "Image"), (Lucide.Music, "Music"), (Lucide.Play, "Play"), (Lucide.Sun, "Sun"), (Lucide.Moon, "Moon")],
        "bootstrap" => [(BootstrapIcon.Search, "Search"), (BootstrapIcon.Heart, "Heart"), (BootstrapIcon.Star, "Star"), (BootstrapIcon.Bell, "Bell"), (BootstrapIcon.MailboxFlag, "Mailbox"), (BootstrapIcon.Calendar, "Calendar"), (BootstrapIcon.Check, "Check"), (BootstrapIcon.Plus, "Plus"), (BootstrapIcon.Eye, "Eye"), (BootstrapIcon.Lock, "Lock"), (BootstrapIcon.Trash, "Trash"), (BootstrapIcon.Share, "Share"), (BootstrapIcon.Download, "Download"), (BootstrapIcon.Upload, "Upload"), (BootstrapIcon.Phone, "Phone"), (BootstrapIcon.Camera, "Camera"), (BootstrapIcon.Image, "Image"), (BootstrapIcon.MusicNoteBeamed, "Music"), (BootstrapIcon.Play, "Play"), (BootstrapIcon.Sun, "Sun"), (BootstrapIcon.Moon, "Moon"), (BootstrapIcon.Cloud, "Cloud"), (BootstrapIcon.Map, "Map"), (BootstrapIcon.Globe, "Globe")],
        "fluentui" => [(FluentUiIcon.Home, "Home"), (FluentUiIcon.Search, "Search"), (FluentUiIcon.Settings, "Settings"), (FluentUiIcon.Heart, "Heart"), (FluentUiIcon.Star, "Star"), (FluentUiIcon.Mail, "Mail"), (FluentUiIcon.Calendar, "Calendar"), (FluentUiIcon.Check, "Check"), (FluentUiIcon.Eye, "Eye"), (FluentUiIcon.LockClosed, "Lock"), (FluentUiIcon.Edit, "Edit"), (FluentUiIcon.Share, "Share"), (FluentUiIcon.Phone, "Phone"), (FluentUiIcon.Camera, "Camera"), (FluentUiIcon.Image, "Image"), (FluentUiIcon.MusicNote1, "Music"), (FluentUiIcon.Play, "Play"), (FluentUiIcon.Cloud, "Cloud"), (FluentUiIcon.Map, "Map"), (FluentUiIcon.Globe, "Globe"), (FluentUiIcon.AccessTime, "Time"), (FluentUiIcon.Accessibility, "Access"), (FluentUiIcon.AccessibilityCheckmark, "Check2"), (FluentUiIcon.AccessibilityError, "Error")],
        "font-awesome" => [(FontAwesomeSolidIcon.User, "User"), (FontAwesomeSolidIcon.Heart, "Heart"), (FontAwesomeSolidIcon.Star, "Star"), (FontAwesomeSolidIcon.Bell, "Bell"), (FontAwesomeSolidIcon.Calendar, "Calendar"), (FontAwesomeSolidIcon.Check, "Check"), (FontAwesomeSolidIcon.Plus, "Plus"), (FontAwesomeSolidIcon.Minus, "Minus"), (FontAwesomeSolidIcon.Eye, "Eye"), (FontAwesomeSolidIcon.Lock, "Lock"), (FontAwesomeSolidIcon.Trash, "Trash"), (FontAwesomeSolidIcon.Share, "Share"), (FontAwesomeSolidIcon.Download, "Download"), (FontAwesomeSolidIcon.Upload, "Upload"), (FontAwesomeSolidIcon.Phone, "Phone"), (FontAwesomeSolidIcon.Camera, "Camera"), (FontAwesomeSolidIcon.Image, "Image"), (FontAwesomeSolidIcon.Music, "Music"), (FontAwesomeSolidIcon.Play, "Play"), (FontAwesomeSolidIcon.Sun, "Sun"), (FontAwesomeSolidIcon.Moon, "Moon"), (FontAwesomeSolidIcon.Cloud, "Cloud"), (FontAwesomeSolidIcon.Map, "Map"), (FontAwesomeSolidIcon.Globe, "Globe")],
        "google-material" => [(GoogleMaterialOutlinedIcon.Home, "Home"), (GoogleMaterialOutlinedIcon.Search, "Search"), (GoogleMaterialOutlinedIcon.Settings, "Settings"), (GoogleMaterialOutlinedIcon.HeartBroken, "Heart"), (GoogleMaterialOutlinedIcon.Star, "Star"), (GoogleMaterialOutlinedIcon.Mail, "Mail"), (GoogleMaterialOutlinedIcon.CalendarMonth, "Calendar"), (GoogleMaterialOutlinedIcon.Check, "Check"), (GoogleMaterialOutlinedIcon.PlusOne, "Plus"), (GoogleMaterialOutlinedIcon.Lock, "Lock"), (GoogleMaterialOutlinedIcon.Edit, "Edit"), (GoogleMaterialOutlinedIcon.Share, "Share"), (GoogleMaterialOutlinedIcon.Download, "Download"), (GoogleMaterialOutlinedIcon.Upload, "Upload"), (GoogleMaterialOutlinedIcon.Phone, "Phone"), (GoogleMaterialOutlinedIcon.Camera, "Camera"), (GoogleMaterialOutlinedIcon.Image, "Image"), (GoogleMaterialOutlinedIcon.MusicNote, "Music"), (GoogleMaterialOutlinedIcon.PlaylistAdd, "Playlist"), (GoogleMaterialOutlinedIcon.Cloud, "Cloud"), (GoogleMaterialOutlinedIcon.Map, "Map"), (GoogleMaterialOutlinedIcon.FileCopy, "Copy")],
        "ionicons" => [(Ionicon.Home, "Home"), (Ionicon.Search, "Search"), (Ionicon.Settings, "Settings"), (Ionicon.Heart, "Heart"), (Ionicon.Star, "Star"), (Ionicon.Mail, "Mail"), (Ionicon.Calendar, "Calendar"), (Ionicon.CheckboxOutline, "Check"), (Ionicon.Eye, "Eye"), (Ionicon.LockClosedOutline, "Lock"), (Ionicon.Trash, "Trash"), (Ionicon.Share, "Share"), (Ionicon.Download, "Download"), (Ionicon.PhoneLandscapeOutline, "Phone"), (Ionicon.Camera, "Camera"), (Ionicon.Image, "Image"), (Ionicon.MusicalNoteOutline, "Music"), (Ionicon.Play, "Play"), (Ionicon.SunnyOutline, "Sun"), (Ionicon.Moon, "Moon"), (Ionicon.Cloud, "Cloud"), (Ionicon.Map, "Map"), (Ionicon.Globe, "Globe"), (Ionicon.FileTrayFullOutline, "Files")],
        "material-design" => [(MdiIcon.Home, "Home"), (MdiIcon.SearchWeb, "Search"), (MdiIcon.SettingsHelper, "Settings"), (MdiIcon.Heart, "Heart"), (MdiIcon.Star, "Star"), (MdiIcon.Bell, "Bell"), (MdiIcon.Mail, "Mail"), (MdiIcon.Calendar, "Calendar"), (MdiIcon.Check, "Check"), (MdiIcon.Plus, "Plus"), (MdiIcon.Minus, "Minus"), (MdiIcon.Eye, "Eye"), (MdiIcon.Lock, "Lock"), (MdiIcon.TrashCanOutline, "Trash"), (MdiIcon.Share, "Share"), (MdiIcon.Download, "Download"), (MdiIcon.Upload, "Upload"), (MdiIcon.Phone, "Phone"), (MdiIcon.Camera, "Camera"), (MdiIcon.Image, "Image"), (MdiIcon.Music, "Music"), (MdiIcon.Play, "Play"), (MdiIcon.SunAngleOutline, "Sun"), (MdiIcon.MoonFirstQuarter, "Moon")],
        "devicon" => [(DeviconOriginal.Homebrew, "Homebrew"), (DeviconOriginal.Playwright, "Playwright"), (DeviconOriginal.Cloudflare, "Cloudflare"), (DeviconOriginal.Mapbox, "Mapbox"), (DeviconOriginal.Filezilla, "Filezilla"), (DeviconOriginal.Adonisjs, "Adonis"), (DeviconOriginal.Aerospike, "Aerospike"), (DeviconOriginal.Aframe, "Aframe"), (DeviconOriginal.Algolia, "Algolia"), (DeviconOriginal.Almalinux, "Almalinux"), (DeviconOriginal.Alpinejs, "Alpine"), (DeviconOriginal.Anaconda, "Anaconda"), (DeviconOriginal.Android, "Android"), (DeviconOriginal.Angular, "Angular"), (DeviconOriginal.Ansible, "Ansible"), (DeviconOriginal.Apache, "Apache"), (DeviconOriginal.AmazonwebservicesWordmark, "AWS"), (DeviconOriginal.Akka, "Akka"), (DeviconOriginal.Aftereffects, "AE"), (DeviconOriginal.Aarch64, "Aarch64")],
        "flag-icons" => [(FlagIcon4x3.Ad, "AD"), (FlagIcon4x3.Ae, "AE"), (FlagIcon4x3.Af, "AF"), (FlagIcon4x3.Ag, "AG"), (FlagIcon4x3.Ai, "AI"), (FlagIcon4x3.Al, "AL"), (FlagIcon4x3.Am, "AM"), (FlagIcon4x3.Ao, "AO"), (FlagIcon4x3.Ar, "AR"), (FlagIcon4x3.As, "AS"), (FlagIcon4x3.At, "AT"), (FlagIcon4x3.Au, "AU"), (FlagIcon4x3.Aw, "AW"), (FlagIcon4x3.Az, "AZ"), (FlagIcon4x3.Ba, "BA"), (FlagIcon4x3.Bb, "BB"), (FlagIcon4x3.Bd, "BD"), (FlagIcon4x3.Be, "BE"), (FlagIcon4x3.Bf, "BF"), (FlagIcon4x3.Bg, "BG")],
        _ => [(Lucide.Search, "Search"), (Lucide.Settings, "Settings"), (Lucide.User, "User"), (Lucide.Heart, "Heart"), (Lucide.Star, "Star"), (Lucide.Bell, "Bell"), (Lucide.Mail, "Mail"), (Lucide.Calendar, "Calendar"), (Lucide.Check, "Check"), (Lucide.Plus, "Plus"), (Lucide.Minus, "Minus"), (Lucide.Eye, "Eye"), (Lucide.Lock, "Lock"), (Lucide.Trash, "Trash"), (Lucide.Share, "Share"), (Lucide.Download, "Download"), (Lucide.Upload, "Upload"), (Lucide.Phone, "Phone"), (Lucide.Camera, "Camera"), (Lucide.Image, "Image"), (Lucide.Music, "Music"), (Lucide.Play, "Play"), (Lucide.Sun, "Sun"), (Lucide.Moon, "Moon")],
    };

    private string GetIconCount() => Library switch
    {
        "lucide" => "1548",
        "bootstrap" => "2078",
        "fluentui" => "2406",
        "font-awesome" => "1402",
        "google-material" => "2122",
        "ionicons" => "1357",
        "material-design" => "7447",
        "devicon" => "940",
        "flag-icons" => "271",
        _ => "1548"
    };

    private string GetPackageName() => Library switch
    {
        "lucide" => "Blazicons.Lucide",
        "bootstrap" => "Blazicons.BootstrapIcons",
        "fluentui" => "Blazicons.FluentUiSystemIcons",
        "font-awesome" => "Blazicons.FontAwesome",
        "google-material" => "Blazicons.GoogleMaterialIcons",
        "ionicons" => "Blazicons.Ionicons",
        "material-design" => "Blazicons.MaterialDesignIcons",
        "devicon" => "Blazicons.Devicon",
        "flag-icons" => "Blazicons.FlagIcons",
        _ => "Blazicons.Lucide"
    };
}
