@if (FaviconBytes != null)
{
    <img src="@_faviconDataUrl" style="width: 50px;" class="mb-4 rounded-lg w-28 sm:mb-0 xl:mb-4 2xl:mb-0" alt="Favicon" />
}
else
{
    <img src="img/service-placeholder.webp" style="width: 50px;" alt="Favicon" />
}

@code {
    /// <summary>
    /// Byte[] of the favicon.
    /// </summary>
    [Parameter]
    public byte[]? FaviconBytes { get; set; }

    private string? _faviconDataUrl;

    /// <inheritdoc />
    protected override void OnParametersSet()
    {
        if (FaviconBytes is not null)
        {
            string base64String = Convert.ToBase64String(FaviconBytes);
            _faviconDataUrl = $"data:image/x-icon;base64,{base64String}";
        }
    }
}
