<v:ChromelessWindow xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:m="using:SourceGit.Models"
                    xmlns:vm="using:SourceGit.ViewModels"
                    xmlns:v="using:SourceGit.Views"
                    mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                    x:Class="SourceGit.Views.RepositoryConfigure"
                    x:DataType="vm:RepositoryConfigure"
                    x:Name="ThisControl"
                    Icon="/App.ico"
                    Title="{DynamicResource Text.Configure}"
                    Width="600" SizeToContent="Height"
                    CanResize="False"
                    WindowStartupLocation="CenterOwner">
  <Grid RowDefinitions="Auto,Auto">
    <!-- TitleBar -->
    <Grid Grid.Row="0" Height="28" IsVisible="{Binding !#ThisControl.UseSystemWindowFrame}">
      <Border Background="{DynamicResource Brush.TitleBar}"
              BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border0}"
              PointerPressed="BeginMoveWindow"/>

      <Path Width="14" Height="14"
            Margin="10,0,0,0"
            HorizontalAlignment="Left"
            Data="{StaticResource Icons.Settings}"
            IsVisible="{OnPlatform True, macOS=False}"/>

      <TextBlock Classes="bold"
                 Text="{DynamicResource Text.Configure}"
                 HorizontalAlignment="Center" VerticalAlignment="Center"
                 IsHitTestVisible="False"/>

      <v:CaptionButtons HorizontalAlignment="Right"
                        IsCloseButtonOnly="True"
                        IsVisible="{OnPlatform True, macOS=False}"/>
    </Grid>

    <!-- Body -->
    <TabControl Grid.Row="1">
      <TabItem>
        <TabItem.Header>
          <TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.Git}"/>
        </TabItem.Header>

        <Grid Margin="16,4,16,8" RowDefinitions="32,32,32,32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
          <TextBlock Grid.Row="0" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.User}"/>
          <TextBox Grid.Row="0" Grid.Column="1"
                   Height="28"
                   CornerRadius="3"
                   Watermark="{DynamicResource Text.Configure.User.Placeholder}"
                   Text="{Binding UserName, Mode=TwoWay}"
                   v:AutoFocusBehaviour.IsEnabled="True"/>

          <TextBlock Grid.Row="1" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.Email}"/>
          <TextBox Grid.Row="1" Grid.Column="1"
                   Height="28"
                   CornerRadius="3"
                   Watermark="{DynamicResource Text.Configure.Email.Placeholder}"
                   Text="{Binding UserEmail, Mode=TwoWay}"/>

          <TextBlock Grid.Row="2" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.Git.DefaultRemote}"/>
          <ComboBox Grid.Row="2" Grid.Column="1"
                    Height="28" Padding="8,0"
                    VerticalAlignment="Center" HorizontalAlignment="Stretch"
                    ItemsSource="{Binding Remotes}"
                    SelectedItem="{Binding DefaultRemote, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
              <DataTemplate>
                <StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
                  <Path Margin="0,2,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Remote}"/>
                  <TextBlock Text="{Binding}"/>
                </StackPanel>
              </DataTemplate>
            </ComboBox.ItemTemplate>
          </ComboBox>

          <TextBlock Grid.Row="3" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.Git.PreferredMergeMode}"/>
          <ComboBox Grid.Row="3" Grid.Column="1"
                    Height="28" Padding="8,0"
                    VerticalAlignment="Center" HorizontalAlignment="Stretch"
                    ItemsSource="{Binding Source={x:Static m:MergeMode.Supported}}"
                    SelectedIndex="{Binding PreferredMergeMode, Mode=TwoWay}"
                    Grid.IsSharedSizeScope="True">
            <ComboBox.ItemTemplate>
              <DataTemplate DataType="m:MergeMode">
                <Grid Height="20">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeNameColumn"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeDescriptionColumn"/>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeOptionColumn"/>
                  </Grid.ColumnDefinitions>

                  <TextBlock Grid.Column="0" Text="{Binding Name}"/>
                  <TextBlock Grid.Column="1" Text="{Binding Desc}" Margin="8,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
                  <TextBlock Grid.Column="2" Text="{Binding Arg}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
                </Grid>
              </DataTemplate>
            </ComboBox.ItemTemplate>

            <ComboBox.SelectionBoxItemTemplate>
              <DataTemplate DataType="m:MergeMode">
                <Grid ColumnDefinitions="Auto,*">
                  <TextBlock Grid.Column="0" Text="{Binding Name}" Margin="0,0,8,0"/>
                  <TextBlock Grid.Column="1" Text="{Binding Desc}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
                </Grid>
              </DataTemplate>
            </ComboBox.SelectionBoxItemTemplate>
          </ComboBox>

          <TextBlock Grid.Row="4" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.Proxy}"/>
          <TextBox Grid.Row="4" Grid.Column="1"
                   Height="28"
                   CornerRadius="3"
                   Watermark="{DynamicResource Text.Configure.Proxy.Placeholder}"
                   Text="{Binding HttpProxy, Mode=TwoWay}">
            <TextBox.InnerRightContent>
              <Button Classes="icon_button" IsVisible="{Binding HttpProxy, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" Command="{Binding ClearHttpProxy}">
                <Path Width="16" Height="16" Margin="0,0,0,0" Data="{StaticResource Icons.Clear}" Fill="{DynamicResource Brush.FG1}"/>
              </Button>
            </TextBox.InnerRightContent>
          </TextBox>

          <TextBlock Grid.Row="5" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Preferences.GPG.UserKey}"/>
          <TextBox Grid.Row="5" Grid.Column="1"
                   Height="28"
                   CornerRadius="3"
                   Watermark="{DynamicResource Text.Preferences.GPG.UserKey.Placeholder}"
                   Text="{Binding GPGUserSigningKey, Mode=TwoWay}"/>

          <TextBlock Grid.Row="6" Grid.Column="0"
                     Text="{DynamicResource Text.Configure.Git.ConventionalTypesOverride}"
                     HorizontalAlignment="Right"
                     Margin="0,0,8,0"/>
          <TextBox Grid.Row="6" Grid.Column="1"
                   Height="28"
                   CornerRadius="3"
                   Text="{Binding ConventionalTypesOverride, Mode=TwoWay}">
            <TextBox.InnerRightContent>
              <Button Classes="icon_button" Width="30" Height="30" Click="SelectConventionalTypesFile">
                <Path Data="{StaticResource Icons.Folder.Open}" Fill="{DynamicResource Brush.FG1}"/>
              </Button>
            </TextBox.InnerRightContent>
          </TextBox>

          <CheckBox Grid.Row="7" Grid.Column="1"
                    Content="{DynamicResource Text.Preferences.GPG.CommitEnabled}"
                    IsChecked="{Binding GPGCommitSigningEnabled, Mode=TwoWay}"/>

          <CheckBox Grid.Row="8" Grid.Column="1"
                    Content="{DynamicResource Text.Preferences.GPG.TagEnabled}"
                    IsChecked="{Binding GPGTagSigningEnabled, Mode=TwoWay}"/>

          <CheckBox Grid.Row="9" Grid.Column="1"
                    Content="{DynamicResource Text.Preferences.Git.EnablePruneOnFetch}"
                    IsChecked="{Binding EnablePruneOnFetch, Mode=TwoWay}"/>

          <StackPanel Grid.Row="10" Grid.Column="1" Orientation="Horizontal">
            <CheckBox x:Name="AutoFetchCheckBox"
                      Content="{DynamicResource Text.Configure.Git.AutoFetch}"
                      IsChecked="{Binding EnableAutoFetch, Mode=TwoWay}"/>

            <NumericUpDown Minimum="1" Maximum="60" Increment="1"
                           Height="26" Width="110"
                           Margin="8,0,0,0" Padding="4"
                           BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
                           CornerRadius="3"
                           ParsingNumberStyle="Integer"
                           FormatString="0"
                           Value="{Binding AutoFetchInterval, Mode=TwoWay, FallbackValue=10}"
                           IsEnabled="{Binding #AutoFetchCheckBox.IsChecked}"/>

            <TextBlock VerticalAlignment="Center"
                       Margin="5,0,0,0"
                       Text="{DynamicResource Text.Configure.Git.AutoFetchIntervalSuffix}" />
          </StackPanel>
        </Grid>
      </TabItem>

      <TabItem>
        <TabItem.Header>
          <TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.CommitMessageTemplate}"/>
        </TabItem.Header>

        <Grid ColumnDefinitions="200,*" Height="300" Margin="0,8,0,16">
          <Border Grid.Column="0"
                  BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
                  Background="{DynamicResource Brush.Contents}">
            <Grid RowDefinitions="*,1,Auto">
              <ListBox Grid.Row="0"
                       Background="Transparent"
                       ItemsSource="{Binding CommitTemplates}"
                       SelectedItem="{Binding SelectedCommitTemplate, Mode=TwoWay}"
                       SelectionMode="Single">
                <ListBox.Styles>
                  <Style Selector="ListBoxItem">
                    <Setter Property="MinHeight" Value="0"/>
                    <Setter Property="Height" Value="26"/>
                    <Setter Property="Padding" Value="4,2"/>
                  </Style>
                </ListBox.Styles>

                <ListBox.ItemsPanel>
                  <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"/>
                  </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

                <ListBox.ItemTemplate>
                  <DataTemplate DataType="m:CommitTemplate">
                    <Grid ColumnDefinitions="Auto,*">
                      <Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Code}"/>
                      <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="8,0" TextTrimming="CharacterEllipsis"/>
                    </Grid>
                  </DataTemplate>
                </ListBox.ItemTemplate>
              </ListBox>

              <Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>

              <StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
                <Button Classes="icon_button" Command="{Binding AddCommitTemplate}">
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
                </Button>

                <Button Classes="icon_button" Command="{Binding RemoveSelectedCommitTemplate}">
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Minus}"/>
                </Button>
              </StackPanel>
            </Grid>
          </Border>

          <ContentControl Grid.Column="1" Margin="16,0,0,0">
            <ContentControl.Content>
              <Binding Path="SelectedCommitTemplate">
                <Binding.TargetNullValue>
                  <Path Width="64" Height="64"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Fill="{DynamicResource Brush.FG2}"
                        Data="{StaticResource Icons.Empty}"/>
                </Binding.TargetNullValue>
              </Binding>
            </ContentControl.Content>

            <ContentControl.DataTemplates>
              <DataTemplate DataType="m:CommitTemplate">
                <StackPanel Orientation="Vertical">
                  <TextBlock Text="{DynamicResource Text.Configure.CommitMessageTemplate.Name}"/>
                  <TextBox Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>

                  <Grid ColumnDefinitions="*,Auto" Margin="0,12,0,0">
                    <TextBlock Grid.Column="0" Text="{DynamicResource Text.Configure.CommitMessageTemplate.Content}"/>
                    <Border Grid.Column="1" Width="14" Height="14" Background="Transparent" ToolTip.Tip="{DynamicResource Text.Configure.CommitMessageTemplate.BuiltinVars}">
                      <Path Data="{StaticResource Icons.Info}"/>
                    </Border>
                  </Grid>

                  <v:CommitMessageToolBox Margin="0,4,0,0" Height="200" CommitMessage="{Binding Content, Mode=TwoWay}"/>
                </StackPanel>
              </DataTemplate>
            </ContentControl.DataTemplates>
          </ContentControl>
        </Grid>
      </TabItem>

      <TabItem>
        <TabItem.Header>
          <TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.IssueTracker}"/>
        </TabItem.Header>

        <Grid ColumnDefinitions="200,*" Height="250" Margin="0,8,0,16">
          <Border Grid.Column="0"
                  BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
                  Background="{DynamicResource Brush.Contents}">
            <Grid RowDefinitions="*,1,Auto">
              <ListBox Grid.Row="0"
                       Background="Transparent"
                       ItemsSource="{Binding IssueTrackers}"
                       SelectedItem="{Binding SelectedIssueTracker, Mode=TwoWay}"
                       SelectionMode="Single">
                <ListBox.Styles>
                  <Style Selector="ListBoxItem">
                    <Setter Property="MinHeight" Value="0"/>
                    <Setter Property="Height" Value="26"/>
                    <Setter Property="Padding" Value="4,2"/>
                  </Style>
                </ListBox.Styles>

                <ListBox.ItemsPanel>
                  <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"/>
                  </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

                <ListBox.ItemTemplate>
                  <DataTemplate DataType="m:IssueTracker">
                    <Grid ColumnDefinitions="Auto,*">
                      <Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Issue}"/>
                      <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="8,0" TextTrimming="CharacterEllipsis"/>
                    </Grid>
                  </DataTemplate>
                </ListBox.ItemTemplate>
              </ListBox>

              <Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>

              <StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
                <Button Classes="icon_button">
                  <Button.Flyout>
                    <MenuFlyout Placement="BottomEdgeAlignedLeft">
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.NewRule}" Click="OnNewCustomIssueTracker"/>
                      <MenuItem Header="-"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGitHub}" Click="OnAddGitHubIssueTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleJira}" Click="OnAddJiraIssueTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleAzure}" Click="OnAddAzureWorkItemTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGitLabIssue}" Click="OnAddGitLabIssueTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGitLabMergeRequest}" Click="OnAddGitLabMergeRequestTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGiteeIssue}" Click="OnAddGiteeIssueTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGiteePullRequest}" Click="OnAddGiteePullRequestTracker"/>
                      <MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGerritChangeIdCommit}" Click="OnAddGerritChangeIdTracker"/>
                    </MenuFlyout>
                  </Button.Flyout>
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
                </Button>

                <Button Classes="icon_button" Click="OnRemoveIssueTracker">
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Minus}"/>
                </Button>

              </StackPanel>
            </Grid>
          </Border>

          <ContentControl Grid.Column="1" Margin="16,0,0,0">
            <ContentControl.Content>
              <Binding Path="SelectedIssueTracker">
                <Binding.TargetNullValue>
                  <Path Width="64" Height="64"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Fill="{DynamicResource Brush.FG2}"
                        Data="{StaticResource Icons.Empty}"/>
                </Binding.TargetNullValue>
              </Binding>
            </ContentControl.Content>

            <ContentControl.DataTemplates>
              <DataTemplate DataType="m:IssueTracker">
                <Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,32">
                  <TextBlock Grid.Row="0" Text="{DynamicResource Text.Configure.IssueTracker.RuleName}"/>
                  <TextBox Grid.Row="1" Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>

                  <TextBlock Grid.Row="2" Margin="0,12,0,0" Text="{DynamicResource Text.Configure.IssueTracker.Regex}"/>
                  <TextBox Grid.Row="3" Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding RegexString, Mode=TwoWay}">
                    <TextBox.InnerRightContent>
                      <Path Margin="4,0" Width="12" Height="12" Data="{StaticResource Icons.Error}" Fill="OrangeRed" IsVisible="{Binding !IsRegexValid}"/>
                    </TextBox.InnerRightContent>
                  </TextBox>

                  <TextBlock Grid.Row="4" Margin="0,12,0,0" Text="{DynamicResource Text.Configure.IssueTracker.URLTemplate}"/>
                  <TextBox Grid.Row="5" Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding URLTemplate, Mode=TwoWay}"/>
                  <TextBlock Grid.Row="6" Margin="0,2,0,0" Text="{DynamicResource Text.Configure.IssueTracker.URLTemplate.Tip}" Foreground="{DynamicResource Brush.FG2}"/>

                  <CheckBox Grid.Row="7" Grid.Column="1"
                            Margin="0,4,0,0"
                            Content="{DynamicResource Text.Configure.IssueTracker.Share}"
                            IsChecked="{Binding IsShared, Mode=TwoWay}"/>
                </Grid>
              </DataTemplate>
            </ContentControl.DataTemplates>
          </ContentControl>
        </Grid>
      </TabItem>

      <TabItem>
        <TabItem.Header>
          <TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.CustomAction}"/>
        </TabItem.Header>

        <Grid ColumnDefinitions="200,*" MinHeight="360" Margin="0,8,0,16">
          <Border Grid.Column="0"
                  BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
                  Background="{DynamicResource Brush.Contents}">
            <Grid RowDefinitions="*,1,Auto">
              <ListBox Grid.Row="0"
                       Background="Transparent"
                       ItemsSource="{Binding CustomActions}"
                       SelectedItem="{Binding SelectedCustomAction, Mode=TwoWay}"
                       SelectionMode="Single">
                <ListBox.Styles>
                  <Style Selector="ListBoxItem">
                    <Setter Property="MinHeight" Value="0"/>
                    <Setter Property="Height" Value="26"/>
                    <Setter Property="Padding" Value="4,2"/>
                  </Style>
                </ListBox.Styles>

                <ListBox.ItemsPanel>
                  <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical"/>
                  </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

                <ListBox.ItemTemplate>
                  <DataTemplate DataType="m:CustomAction">
                    <Grid Margin="4,0" ColumnDefinitions="Auto,*">
                      <Path Grid.Column="0" Width="12" Height="12" Data="{StaticResource Icons.Action}" Fill="{DynamicResource Brush.FG1}"/>
                      <TextBlock Grid.Column="1" Text="{Binding Name}" Margin="6,0,0,0" TextTrimming="CharacterEllipsis"/>
                    </Grid>
                  </DataTemplate>
                </ListBox.ItemTemplate>
              </ListBox>

              <Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>

              <Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
                <Button Grid.Column="0"
                        Classes="icon_button"
                        Width="28" Height="28"
                        Command="{Binding AddNewCustomAction}">
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
                </Button>
                <Button Grid.Column="1"
                        Classes="icon_button"
                        Width="28" Height="28"
                        Command="{Binding RemoveSelectedCustomAction}">
                  <Path Width="14" Height="14" Data="{StaticResource Icons.Minus}"/>
                </Button>
                <Button Grid.Column="3"
                        Classes="icon_button"
                        Width="28" Height="28"
                        Command="{Binding MoveSelectedCustomActionUp}"
                        IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
                  <Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
                </Button>
                <Button Grid.Column="4"
                        Classes="icon_button"
                        Width="28" Height="28"
                        Command="{Binding MoveSelectedCustomActionDown}"
                        IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
                  <Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
                </Button>
              </Grid>
            </Grid>
          </Border>

          <ContentControl Grid.Column="1" Margin="16,0,0,0">
            <ContentControl.Content>
              <Binding Path="SelectedCustomAction">
                <Binding.TargetNullValue>
                  <Path Width="64" Height="64"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Fill="{DynamicResource Brush.FG2}"
                        Data="{StaticResource Icons.Empty}"/>
                </Binding.TargetNullValue>
              </Binding>
            </ContentControl.Content>

            <ContentControl.DataTemplates>
              <DataTemplate DataType="m:CustomAction">
                <StackPanel Orientation="Vertical">
                  <TextBlock Text="{DynamicResource Text.Configure.CustomAction.Name}"/>
                  <TextBox Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>

                  <TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.Configure.CustomAction.Scope}"/>
                  <ComboBox Margin="0,4,0,0" Height="28" HorizontalAlignment="Stretch" SelectedIndex="{Binding Scope, Mode=TwoWay}">
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.Repository}"/>
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.Commit}"/>
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.Branch}"/>
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.Tag}"/>
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.Remote}"/>
                    <ComboBoxItem Content="{DynamicResource Text.Configure.CustomAction.Scope.File}"/>
                  </ComboBox>

                  <TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls}"/>
                  <Button Margin="0,4,0,0" Classes="flat" Height="28" Click="EditCustomActionControls">
                    <StackPanel Orientation="Horizontal">
                      <Path Width="14" Height="14" Data="{StaticResource Icons.Edit}" Fill="{DynamicResource Brush.FG1}"/>
                      <TextBlock Margin="4,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Edit}"/>
                      <Border Height="16" Background="{DynamicResource Brush.Badge}" CornerRadius="8" VerticalAlignment="Center">
                        <TextBlock Text="{Binding Controls.Count}" Margin="8,0" FontSize="10" Foreground="{DynamicResource Brush.BadgeFG}"/>
                      </Border>
                    </StackPanel>
                  </Button>

                  <TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.Configure.CustomAction.Executable}"/>
                  <TextBox Margin="0,4,0,0" Height="28" CornerRadius="3" Text="{Binding Executable, Mode=TwoWay}">
                    <TextBox.InnerRightContent>
                      <Button Classes="icon_button" Width="30" Height="30" Click="SelectExecutableForCustomAction">
                        <Path Data="{StaticResource Icons.Folder.Open}" Fill="{DynamicResource Brush.FG1}"/>
                      </Button>
                    </TextBox.InnerRightContent>
                  </TextBox>

                  <TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.Configure.CustomAction.Arguments}"/>
                  <TextBox Margin="0,4,0,0" Height="28" CornerRadius="3" Text="{Binding Arguments, Mode=TwoWay}">
                    <TextBox.InnerRightContent>
                      <Border Width="28" Height="28" Background="Transparent" VerticalAlignment="Center" ToolTip.Tip="{DynamicResource Text.Configure.CustomAction.Arguments.Tip}">
                        <Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="{DynamicResource Brush.FG1}"/>
                      </Border>
                    </TextBox.InnerRightContent>
                  </TextBox>

                  <CheckBox Margin="0,8,0,0" Content="{DynamicResource Text.Configure.CustomAction.WaitForExit}" IsChecked="{Binding WaitForExit, Mode=TwoWay}"/>
                </StackPanel>
              </DataTemplate>
            </ContentControl.DataTemplates>
          </ContentControl>
        </Grid>
      </TabItem>

      <TabItem>
        <TabItem.Header>
          <TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.OpenAI}"/>
        </TabItem.Header>

        <Grid Margin="16,4,16,8" RowDefinitions="32,Auto" ColumnDefinitions="Auto,*">
          <TextBlock Grid.Row="0" Grid.Column="0"
                     HorizontalAlignment="Right" VerticalAlignment="Center"
                     Margin="0,0,8,0"
                     Text="{DynamicResource Text.Configure.OpenAI.Preferred}"/>
          <ComboBox Grid.Row="0" Grid.Column="1"
                    Height="28" Padding="8,0"
                    VerticalAlignment="Center" HorizontalAlignment="Stretch"
                    ItemsSource="{Binding AvailableOpenAIServices}"
                    SelectedItem="{Binding PreferredOpenAIService, Mode=TwoWay}">
            <ComboBox.ItemTemplate>
              <DataTemplate>
                <StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
                  <Path Width="12" Height="12" Data="{StaticResource Icons.AIAssist}" Fill="{DynamicResource Brush.FG1}"/>
                  <TextBlock Margin="6,0,0,0" Text="{Binding}"/>
                </StackPanel>
              </DataTemplate>
            </ComboBox.ItemTemplate>
          </ComboBox>

          <TextBlock Grid.Row="1" Grid.Column="1"
                     Margin="0,6,0,0"
                     Text="{DynamicResource Text.Configure.OpenAI.Preferred.Tip}"
                     TextWrapping="Wrap"
                     Foreground="{DynamicResource Brush.FG2}"/>
        </Grid>
      </TabItem>
    </TabControl>
  </Grid>
</v:ChromelessWindow>
