@using AIStudio.Settings
@inherits MSGComponentBase

<MudTooltip Placement="Placement.Top" Text="@T("Start a new chat with a chat template")">
    <MudMenu AnchorOrigin="Origin.TopLeft" TransformOrigin="@Origin.BottomLeft" Class="@this.MarginClass">
        <ActivatorContent>
            @if (this.CurrentChatTemplate != ChatTemplate.NO_CHAT_TEMPLATE)
            {
                <MudButton IconSize="Size.Large" StartIcon="@this.ChatTemplateIcon(this.CurrentChatTemplate)" IconColor="Color.Default">
                    @this.CurrentChatTemplate.GetSafeName()
                </MudButton>
            }
            else
            {
                <MudIconButton Icon="@Icons.Material.Filled.RateReview" />
            }
        </ActivatorContent>
        <ChildContent>
            <MudMenuItem Icon="@Icons.Material.Filled.Settings" Label="@T("Manage your templates")" OnClick="@(async () => await this.OpenSettingsDialog())" />
            <MudDivider/>
            <MudMenuItem Icon="@Icons.Material.Filled.AddComment" Label="@T("Create template from current chat")" OnClick="@(async () => await this.CreateNewChatTemplateFromChat())" Disabled="@(!this.CanChatThreadBeUsedForTemplate)"/>
            <MudDivider/>
            @foreach (var chatTemplate in this.SettingsManager.ConfigurationData.ChatTemplates.GetAllChatTemplates())
            {
                <MudMenuItem Icon="@this.ChatTemplateIcon(chatTemplate)" OnClick="@(async () => await this.SelectionChanged(chatTemplate))">
                    @chatTemplate.GetSafeName()
                </MudMenuItem>
            }
        </ChildContent>
    </MudMenu>
</MudTooltip>