<?xml version="1.0" encoding="utf-8" ?>
<local:SettingsPageBase
    x:Class="BiliCopilot.UI.Pages.SettingsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:BiliCopilot.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:local="using:BiliCopilot.UI.Pages"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:settings="using:BiliCopilot.UI.Controls.Settings"
    mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="56" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock
            Margin="16,0"
            HorizontalAlignment="Left"
            VerticalAlignment="Center"
            Style="{StaticResource BodyStrongTextBlockStyle}"
            Text="{ext:Locale Name=Settings}" />

        <SelectorBar
            x:Name="SectionSelector"
            HorizontalAlignment="Center"
            SelectionChanged="OnSectionSelectorChangedAsync">
            <SelectorBarItem Tag="0" Text="{ext:Locale Name=App}" />
            <SelectorBarItem Tag="1" Text="{ext:Locale Name=AIService}" />
        </SelectorBar>

        <Border
            Grid.Row="1"
            Height="1"
            HorizontalAlignment="Stretch"
            Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
        <ScrollViewer
            x:Name="GenericContainer"
            Grid.Row="2"
            Padding="16,0"
            Style="{StaticResource PageScrollViewerStyle}">
            <StackPanel Margin="0,12" Spacing="4">
                <StackPanel.ChildrenTransitions>
                    <RepositionThemeTransition IsStaggeringEnabled="False" />
                </StackPanel.ChildrenTransitions>
                <TextBlock
                    Margin="0,8,0,4"
                    HorizontalAlignment="Left"
                    Text="{ext:Locale Name=Player}" />
                <settings:PlayerControlSettingControl />
                <settings:PlayerBehaviorSettingControl />
                <settings:DownloadSettingControl />
                <settings:WebDavSettingControl />
                <TextBlock
                    Margin="0,8,0,4"
                    HorizontalAlignment="Left"
                    Text="{ext:Locale Name=Generic}" />
                <settings:ThemeSettingControl />
                <settings:LayoutSettingSection />
                <settings:NavigationSettingControl />
                <settings:SearchRecommendSettingSection />
                <!--<settings:CloseBehaviorSettingControl />-->
                <settings:NotificationSettingControl />
                <settings:LoggerSettingControl />
                <TextBlock
                    Margin="0,16,0,8"
                    HorizontalAlignment="Left"
                    Text="{ext:Locale Name=AboutThisApp}" />
                <settings:AboutSettingControl />
                <StackPanel
                    Margin="0,12,0,0"
                    Orientation="Horizontal"
                    Spacing="4">
                    <HyperlinkButton
                        Padding="8,4"
                        HorizontalAlignment="Left"
                        Click="OnJoinGroupButtonClick"
                        Content="{ext:Locale Name=JoinQQGroup}">
                        <FlyoutBase.AttachedFlyout>
                            <Flyout>
                                <Flyout.FlyoutPresenterStyle>
                                    <Style BasedOn="{StaticResource DefaultFlyoutPresenterStyle}" TargetType="FlyoutPresenter">
                                        <Setter Property="Padding" Value="0" />
                                    </Style>
                                </Flyout.FlyoutPresenterStyle>
                                <Image
                                    MaxWidth="240"
                                    Source="{ThemeResource QQGroup}"
                                    Stretch="Uniform" />
                            </Flyout>
                        </FlyoutBase.AttachedFlyout>
                    </HyperlinkButton>
                    <StackPanel
                        Width="1"
                        Height="16"
                        Background="{ThemeResource ControlStrokeColorDefaultBrush}" />
                    <HyperlinkButton
                        Padding="8,4"
                        Content="{ext:Locale Name=SendFeedback}"
                        NavigateUri="https://github.com/Richasy/Bili.Copilot/issues/new/choose" />
                    <StackPanel
                        Width="1"
                        Height="16"
                        Background="{ThemeResource ControlStrokeColorDefaultBrush}" />
                    <HyperlinkButton
                        Padding="8,4"
                        Content="{ext:Locale Name=ReadDocument}"
                        NavigateUri="https://bili.richasy.net" />
                </StackPanel>
            </StackPanel>
        </ScrollViewer>
        <ScrollViewer
            x:Name="AIContainer"
            Grid.Row="2"
            Padding="16,0"
            Style="{StaticResource PageScrollViewerStyle}"
            Visibility="Collapsed">
            <StackPanel Margin="0,12">
                <StackPanel.ChildrenTransitions>
                    <RepositionThemeTransition IsStaggeringEnabled="False" />
                </StackPanel.ChildrenTransitions>
                <InfoBar
                    Title="{ext:Locale Name=AISettingHeaderTitle}"
                    Margin="0,0,0,8"
                    HorizontalAlignment="Stretch"
                    IsClosable="False"
                    IsOpen="True"
                    Message="{ext:Locale Name=AISettingHeaderDescription}"
                    Severity="Informational">
                    <InfoBar.IconSource>
                        <ic:SymbolIconSource Symbol="Sparkle" />
                    </InfoBar.IconSource>
                    <InfoBar.ActionButton>
                        <HyperlinkButton Content="{ext:Locale Name=SeeDetail}" NavigateUri="https://agent.richasy.net/chat-config" />
                    </InfoBar.ActionButton>
                </InfoBar>
                <settings:AIResponseSettingControl Margin="0,0,0,4" />
                <settings:PromptTemplateSettingControl Margin="0,0,0,4" />
                <StackPanel x:Name="AIPanel" Spacing="4">
                    <StackPanel.ChildrenTransitions>
                        <RepositionThemeTransition IsStaggeringEnabled="False" />
                    </StackPanel.ChildrenTransitions>
                </StackPanel>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</local:SettingsPageBase>
