@namespace AntSK.Pages.ChatPage
@using AntSK.Domain.Repositories
@using AntSK.Models
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using AntSK.Pages.ChatPage.Components
@page "/Chat"
@page "/Chat/{AppId}"
@using AntSK.Services.Auth
@inherits AuthComponentBase

<GridRow Gutter="(16, 16)">
    <GridCol Span="12">
        <Card Style="height:75vh;overflow: auto;">
            <TitleTemplate>
                <Icon Type="setting" /> 选择应用
                <Select DataSource="@_list"
                        @bind-Value="@AppId"
                        DefaultValue="@("lucy")"
                        ValueProperty="c=>c.Id"
                        LabelProperty="c=>c.Name"
                        Style="width:200px">
                </Select>
                <a href="@( NavigationManager.BaseUri + "openchat/" + AppId)" target="_blank">分享使用</a>
            </TitleTemplate>
            <Body>
                @if (!string.IsNullOrEmpty(AppId))
                {
                    <ChatView AppId="@AppId" ShowTitle=false OnRelevantSources="OnRelevantSources"></ChatView>
                }
            </Body>
        </Card>
    </GridCol>
    <GridCol Span="12">
        <Card Style="height: 75vh;overflow: auto;">
            <TitleTemplate>
                <Icon Type="search" /> 调试结果
            </TitleTemplate>
            <Extra>

            </Extra>
            <Body>
                <AntList Bordered DataSource="@_relevantSources" Style="padding:10px;">
                    <ChildContent Context="item">
                        <span> <b>@item.SourceName </b>  相似度：<Text Mark> @item.Relevance</Text></span>
                        <Body>
                            @((MarkupString)(@item.Text))
                        </Body>
                    </ChildContent>
                </AntList>
            </Body>
        </Card>
    </GridCol>
</GridRow>

<style>
    #chat {
        height: calc(75vh - 120px);
        display: flex;
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        font-family: Arial, sans-serif;
        margin: 0;
    }

    body {
        font-family: Arial, sans-serif;
        margin: 0;
        justify-content: center;
        align-items: flex-start;
        height: 100vh;
        overflow-y: hidden;
    }
</style>
@code {

}
