@inherits Dynamicweb.Rendering.ViewModelTemplate<UserViewModel>
@using Dynamicweb.Frontend


@if (Model?.ID is null) return;

<span class="hstack me-auto position-relative" hx-swap-oob="true outerHTML:[data-swift-avatar-mini-image]" data-swift-avatar-mini-image>

    @if(Model.TryGetImageFile(out ImageFileViewModel? image))
    {
        <span style="height:2rem; aspect-ratio:1; display:inline-flex;">
            <img src="@image.ToGetImage(new(){ Width = 32, Ratio = "1/1" })" alt="@Model.Name" class="img-thumbnail rounded-circle" itemprop="image"/>
        </span>
    }
    else
    {
        <span class="btn btn-primary rounded-circle hstack justify-content-center p-0" style="height:2rem; aspect-ratio:1;" data-dw-button>
            <span class="d-flex float-start fs-8 fw-bold lh-1 m-0 text-decoration-none">
                @(Model.GetTwoLetterInitials())
            </span>
        </span>
    }

    @if ((!string.IsNullOrEmpty(Model?.FirstName) && !string.IsNullOrEmpty(Model?.LastName)) || (!string.IsNullOrEmpty(Model?.Name))) {
        <span class="text-nowrap ms-2">@((!string.IsNullOrEmpty(Model?.FirstName) && !string.IsNullOrEmpty(Model?.LastName)) ? $"{Model.FirstName} {Model.LastName}" : Model?.Name)</span>
    }

</span>