<local:GenericLoginCredentialsView x:Class="GitHub.VisualStudio.Views.Dialog.LoginCredentialsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ghfvs="https://github.com/github/VisualStudio"
             xmlns:local="clr-namespace:GitHub.VisualStudio.Views.Dialog"
             xmlns:controls="clr-namespace:GitHub.VisualStudio.UI.Controls"
             mc:Ignorable="d"
             d:DesignWidth="414"
             d:DesignHeight="440"
             Style="{DynamicResource DialogUserControl}"
             xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
             Background="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelBrushKey}}"
             Foreground="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelTextBrushKey}}"
             AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.SignInCustom}">

    <Control.Resources>
        <ResourceDictionary Source="DialogStyles.xaml" />
    </Control.Resources>

    <DockPanel Style="{DynamicResource DialogContainerDockPanel}">
        <DockPanel.Resources>
            <Style TargetType="{x:Type ghfvs:PromptTextBox}" BasedOn="{StaticResource {x:Type ghfvs:PromptTextBox}}">
                <Setter Property="Margin" Value="0" />
            </Style>
            <Style TargetType="{x:Type Border}" x:Key="LoginButtonBorder">
                <Setter Property="Margin" Value="0,0,0,15" />
                <Setter Property="HorizontalAlignment" Value="Center" />
            </Style>
            <Style TargetType="{x:Type ghfvs:SecurePasswordBox}" BasedOn="{StaticResource {x:Type ghfvs:SecurePasswordBox}}">
                <Setter Property="Margin" Value="0" />
            </Style>
        </DockPanel.Resources>
        <StackPanel DockPanel.Dock="Top">
            <ghfvs:OcticonImage Icon="logo_github" Style="{DynamicResource GitHubLogo}" />

            <TextBlock
                x:Name="loginLabelPrefix"
                HorizontalAlignment="Center"
                Margin="0,0,0,10"
                Style="{DynamicResource GitHubH1TextBlock}"
                IsHitTestVisible="False"
                Text="{x:Static ghfvs:Resources.LoginLink}" />
            
            <controls:HorizontalShadowDivider />
        </StackPanel>
        <TabControl 
            x:Name="hostTabControl"
            Margin="30,0"
            Style="{StaticResource LightModalViewTabControl}"
            FocusManager.IsFocusScope="True"
            FocusVisualStyle="{x:Null}"
            ghfvs:AccessKeysManagerScoping.IsEnabled="True"
            AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.SignInHostTab}" >
            <TabControl.Resources>
                <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource LightModalViewTabItem}" />
                <Style TargetType="{x:Type TabPanel}">
                    <Setter Property="HorizontalAlignment" Value="Center" />
                </Style>
                <Style x:Key="TabDockPanel" TargetType="{x:Type DockPanel}">
                    <Setter Property="Margin" Value="0,20,0,0" />
                    <Setter Property="LastChildFill" Value="True" />
                </Style>
                <Style x:Key="FormFieldStackPanel" TargetType="{x:Type StackPanel}">
                    <Setter Property="Margin" Value="0" />
                </Style>
                <Style
                    TargetType="{x:Type ghfvs:ErrorMessageDisplay}"
                    BasedOn="{StaticResource ErrorMessageStyle}">
                    <Setter Property="Margin" Value="0,10" />
                </Style>
            </TabControl.Resources>

            <TabItem x:Name="dotComTab" Header="GitHub" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.SignInDotcomHostTabItem}" >
                <DockPanel Style="{StaticResource TabDockPanel}">
                    <StackPanel DockPanel.Dock="Bottom" Margin="0">
                        <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Margin="0" Text="{x:Static ghfvs:Resources.dontHaveAnAccountText}" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DontHaveDotcomAccountTextBlock}">
                            <Hyperlink x:Name="pricingLink" ToolTip="https://github.com/pricing">
                                <Run Text="{x:Static ghfvs:Resources.SignUpLink}" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DotcomSignUpHyperlink}" />
                            </Hyperlink>
                        </TextBlock>
                    </StackPanel>

                    <StackPanel x:Name="dotComloginControlsPanel">
                        
                        <StackPanel Style="{StaticResource FormFieldStackPanel}">
                            <!--
                                Signing with with username/password is going away, see:
                                https://developer.github.com/changes/2020-02-14-deprecating-oauth-auth-endpoint/
                                Setting Visibility="Collapsed"
                            -->
                            <StackPanel Name="dotComUsernamePasswordPanel" Visibility="Collapsed">
                                <ghfvs:PromptTextBox
                                    x:Name="dotComUserNameOrEmail"
                                    PromptText="{x:Static ghfvs:Resources.UserNameOrEmailPromptText}"
                                    Margin="0,0,0,10" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DotcomUsernameEmailTextBox}" />

                                <ghfvs:SecurePasswordBox x:Name="dotComPassword" PromptText="{x:Static ghfvs:Resources.PasswordPrompt}" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DotcomPasswordTextBox}"/>

                                <Border Style="{StaticResource LoginButtonBorder}" Margin="0 16 0 0">
                                    <Button
                                        x:Name="dotComLogInButton"
                                        Content="{x:Static ghfvs:Resources.LoginLink}"
                                        IsDefault="True"
                                        Command=""
                                        AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DotcomSignInButton}" />
                                </Border>

                                <Grid Margin="0 8">
                                  <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                  </Grid.ColumnDefinitions>
                                  <Rectangle Grid.Column="0" Fill="#FFDDDDDD" Height="1"/>
                                  <TextBlock Grid.Column="1" Margin="8,0,8,4">or</TextBlock>
                                  <Rectangle Grid.Column="2" Fill="#FFDDDDDD" Height="1"/>
                                </Grid>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                              <ghfvs:GitHubActionLink x:Name="dotComSsaLogInButton" Content="{x:Static ghfvs:Resources.SignInWithYourBrowser}"/>
                              <ghfvs:OcticonImage Icon="link_external" Margin="0 1 0 0"/>
                            </StackPanel>

                            <ghfvs:UserErrorMessages x:Name="dotComErrorMessage" Margin="0,10">
                            </ghfvs:UserErrorMessages>

                            <ghfvs:ValidationMessage
                                x:Name="dotComUserNameOrEmailValidationMessage"
                                ValidatesControl="{Binding ElementName=dotComUserNameOrEmail}" />

                            <ghfvs:ValidationMessage
                                x:Name="dotComPasswordValidationMessage"
                                ValidatesControl="{Binding ElementName=dotComPassword}" />
                         
                        </StackPanel>
                    </StackPanel>
                </DockPanel>
            </TabItem>

            <TabItem x:Name="enterpriseTab" Header="GitHub Enterprise" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.SignInEnterpriseHostTabItem}">
                <DockPanel Style="{StaticResource TabDockPanel}">
                    <StackPanel DockPanel.Dock="Bottom">
                        <TextBlock TextWrapping="Wrap" HorizontalAlignment="Center" Margin="0" Text="{x:Static ghfvs:Resources.dontHaveGitHubEnterpriseText}" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.DontHaveEnterpriseTextBlock}" >
                            <Hyperlink x:Name="learnMoreLink" ToolTip="enterprise.github.com"><TextBlock Text="{x:Static ghfvs:Resources.learnMoreLink}" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterpriseLearnMoreHyperlink}"></TextBlock></Hyperlink>
                        </TextBlock>
                    </StackPanel>
                    
                    <StackPanel
                        x:Name="enterpriseloginControlsPanel"
                        Style="{StaticResource FormFieldStackPanel}">

                        <ghfvs:PromptTextBox x:Name="enterpriseUrl"
                                          PromptText="{x:Static ghfvs:Resources.enterpriseUrlPromptText}"
                                          Margin="0,0,0,10"
                                          AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterpriseServerAddressTextBox}">
                          <ghfvs:PromptTextBox.IconContentTemplate>
                            <DataTemplate DataType="{x:Type ghfvs:EnterpriseProbeStatus}">
                                <Grid Margin="4,0">
                                  <ghfvs:Spinner Margin="0,4" Visibility="{Binding Converter={ghfvs:EqualsToVisibilityConverter Checking}}"/>
                                  <ghfvs:OcticonImage Icon="check" Visibility="{Binding Converter={ghfvs:EqualsToVisibilityConverter Valid}}"/>
                                  <ghfvs:OcticonImage Icon="x" Visibility="{Binding Converter={ghfvs:EqualsToVisibilityConverter Invalid}}"/>
                                </Grid>
                            </DataTemplate>
                          </ghfvs:PromptTextBox.IconContentTemplate>
                        </ghfvs:PromptTextBox>

                        <StackPanel Name="enterpriseUsernamePasswordPanel">
                          <ghfvs:PromptTextBox
                              x:Name="enterpriseUserNameOrEmail"
                              PromptText="{x:Static ghfvs:Resources.UserNameOrEmailPromptText}"
                              Margin="0,0,0,10" 
                              AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterpriseUsernameEmailTextBox}" />

                          <ghfvs:SecurePasswordBox x:Name="enterprisePassword"
                                                PromptText="{x:Static ghfvs:Resources.PasswordPrompt}"
                                                AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterprisePasswordTextBox}" />
                        </StackPanel>

                        <StackPanel Name="enterpriseTokenPanel">
                          <ghfvs:SecurePasswordBox x:Name="enterpriseToken"
                                                PromptText="{x:Static ghfvs:Resources.TokenPrompt}"
                                                AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterprisePasswordTextBox}" />
                        </StackPanel>

                        <Border Style="{StaticResource LoginButtonBorder}" Margin="0 16 0 0">
                            <Button
                                x:Name="enterpriseLogInButton"
                                Content="{x:Static ghfvs:Resources.LoginLink}"
                                IsDefault="True" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.EnterpriseSignInButton}"/>
                        </Border>

                        <StackPanel Name="enterpriseSsoPanel">
                          <Grid Margin="0 8">
                            <Grid.ColumnDefinitions>
                              <ColumnDefinition Width="*"/>
                              <ColumnDefinition Width="Auto"/>
                              <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Rectangle Grid.Column="0" Fill="#FFDDDDDD" Height="1"/>
                            <TextBlock Grid.Column="1" Margin="8,0,8,4" Text="{x:Static ghfvs:Resources.orText}"/>
                            <Rectangle Grid.Column="2" Fill="#FFDDDDDD" Height="1"/>
                          </Grid>
                          <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <ghfvs:GitHubActionLink x:Name="enterpriseSsaLogInButton" Content="{x:Static ghfvs:Resources.SignInWithYourBrowser}"/>
                            <ghfvs:OcticonImage Icon="link_external" Margin="0 1 0 0"/>
                          </StackPanel>
                        </StackPanel>

                        <ghfvs:ValidationMessage
                            x:Name="enterpriseUserNameOrEmailValidationMessage"
                            ValidatesControl="{Binding ElementName=enterpriseUserNameOrEmail}"/>

                        <ghfvs:ValidationMessage
                            x:Name="enterprisePasswordValidationMessage"
                            ValidatesControl="{Binding ElementName=enterprisePassword}" />

                        <ghfvs:ValidationMessage
                            x:Name="enterpriseUrlValidationMessage"
                            ValidatesControl="{Binding ElementName=enterpriseUrl}"
                            TextChangeThrottle="1.0"/>

                        <ghfvs:UserErrorMessages x:Name="enterpriseErrorMessage" Margin="0,10">
                        </ghfvs:UserErrorMessages>
                    </StackPanel>
                </DockPanel>
            </TabItem>
        </TabControl>
    </DockPanel>
</local:GenericLoginCredentialsView>
