<local:NavigablePage
    x:Class="Microsoft.PowerToys.Settings.UI.Views.AdvancedPastePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
    xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:models="using:Microsoft.PowerToys.Settings.UI.Library"
    xmlns:ptcontrols="using:Microsoft.PowerToys.Common.UI.Controls"
    xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:viewmodels="using:Microsoft.PowerToys.Settings.UI.ViewModels"
    x:Name="RootPage"
    AutomationProperties.LandmarkType="Main"
    mc:Ignorable="d">
    <local:NavigablePage.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.SettingsControls/SettingsExpander/SettingsExpander.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Default">
                    <ImageSource x:Key="OpenAIIconImage">ms-appx:///Assets/Settings/Icons/Models/OpenAI.dark.svg</ImageSource>
                </ResourceDictionary>
                <ResourceDictionary x:Key="Light">
                    <ImageSource x:Key="OpenAIIconImage">ms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg</ImageSource>
                </ResourceDictionary>
                <ResourceDictionary x:Key="HighContrast">
                    <ImageSource x:Key="OpenAIIconImage">ms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg</ImageSource>
                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>
            <Style x:Key="MenuFlyoutItemHeaderStyle" TargetType="MenuFlyoutItem">
                <Setter Property="FontSize" Value="12" />
                <Setter Property="IsEnabled" Value="False" />
                <Setter Property="IsHitTestVisible" Value="False" />
            </Style>

            <converters:ServiceTypeToIconConverter x:Key="ServiceTypeToIconConverter" />
            <DataTemplate x:Key="AdditionalActionTemplate" x:DataType="models:AdvancedPasteAdditionalAction">
                <StackPanel Orientation="Horizontal" Spacing="4">
                    <controls:ShortcutControl
                        MinWidth="{StaticResource SettingActionControlMinWidth}"
                        AllowDisable="True"
                        HotkeySettings="{x:Bind Shortcut, Mode=TwoWay}" />
                    <ToggleSwitch
                        IsOn="{x:Bind IsShown, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        OffContent=""
                        OnContent="" />
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
    </local:NavigablePage.Resources>
    <Grid>
        <controls:SettingsPageControl x:Uid="AdvancedPaste" ModuleImageSource="ms-appx:///Assets/Settings/Modules/AdvancedPaste.png">
            <controls:SettingsPageControl.ModuleContent>
                <StackPanel
                    ChildrenTransitions="{StaticResource SettingsCardsAnimations}"
                    Orientation="Vertical"
                    Spacing="2">
                    <controls:GPOInfoControl ShowWarning="{x:Bind ViewModel.IsEnabledGpoConfigured, Mode=OneWay}">
                        <tkcontrols:SettingsCard
                            Name="AdvancedPasteEnableToggleControlHeaderText"
                            x:Uid="AdvancedPaste_EnableToggleControl_HeaderText"
                            HeaderIcon="{ui:BitmapIcon Source=/Assets/Settings/Icons/AdvancedPaste.png}">
                            <ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.IsEnabled, Mode=TwoWay}" />
                        </tkcontrols:SettingsCard>
                    </controls:GPOInfoControl>
                    <controls:SettingsGroup x:Uid="AdvancedPaste_EnableAISettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
                        <InfoBar
                            x:Uid="GPO_AdvancedPasteAi_SettingIsManaged"
                            IsClosable="False"
                            IsOpen="{x:Bind ViewModel.ShowOnlineAIModelsGpoConfiguredInfoBar, Mode=OneWay}"
                            IsTabStop="{x:Bind ViewModel.ShowOnlineAIModelsGpoConfiguredInfoBar, Mode=OneWay}"
                            Severity="Informational">
                            <InfoBar.IconSource>
                                <FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72E;" />
                            </InfoBar.IconSource>
                        </InfoBar>

                        <!--  Paste with AI  -->
                        <tkcontrols:SettingsExpander
                            Name="AdvancedPasteEnableAISettingsCard"
                            x:Uid="AdvancedPaste_EnableAISettingsCard"
                            IsEnabled="{x:Bind ViewModel.IsOnlineAIModelsDisallowedByGPO, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
                            IsExpanded="{x:Bind ViewModel.IsAIEnabled, Mode=OneWay}"
                            ItemsSource="{x:Bind ViewModel.PasteAIConfiguration.Providers, Mode=OneWay}">
                            <tkcontrols:SettingsExpander.HeaderIcon>
                                <PathIcon Data="M128 766q0-42 24-77t65-48l178-57q32-11 61-30t52-42q50-50 71-114l58-179q13-40 48-65t78-26q42 0 77 24t50 65l58 177q21 66 72 117 49 50 117 72l176 58q43 14 69 48t26 80q0 41-25 76t-64 49l-178 58q-66 21-117 72-32 32-51 73t-33 84-26 83-30 73-45 51-71 20q-42 0-77-24t-49-65l-58-178q-8-25-19-47t-28-43q-34-43-77-68t-89-41-89-27-78-29-55-45-21-75zm1149 7q-76-29-145-53t-129-60-104-88-73-138l-57-176-67 176q-18 48-42 89t-60 78q-34 34-76 61t-89 43l-177 57q75 29 144 53t127 60 103 89 73 137l57 176 67-176q37-97 103-168t168-103l177-57zm-125 759q0-31 20-57t49-36l99-32q34-11 53-34t30-51 20-59 20-54 33-41 58-16q32 0 59 19t38 50q6 20 11 40t13 40 17 38 25 34q16 17 39 26t48 18 49 16 44 20 31 32 12 50q0 33-18 60t-51 38q-19 6-39 11t-41 13-39 17-34 25q-24 25-35 62t-24 73-35 61-68 25q-32 0-59-19t-38-50q-6-18-11-39t-13-41-17-40-24-33q-18-17-41-27t-47-17-49-15-43-20-30-33-12-54zm583 4q-43-13-74-30t-55-41-40-55-32-74q-12 41-29 72t-42 55-55 42-71 31q81 23 128 71t71 129q15-43 31-74t40-54 53-40 75-32z" />
                            </tkcontrols:SettingsExpander.HeaderIcon>
                            <ToggleSwitch
                                x:Name="AdvancedPaste_EnableAIToggle"
                                x:Uid="AdvancedPaste_EnableAIToggle"
                                IsOn="{x:Bind ViewModel.IsAIEnabled, Mode=OneWay}"
                                Toggled="AdvancedPaste_EnableAIToggle_Toggled" />
                            <tkcontrols:SettingsExpander.Description>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock x:Uid="AdvancedPaste_EnableAISettingsCardDescription" />
                                    <HyperlinkButton x:Uid="AdvancedPaste_EnableAISettingsCardDescriptionLearnMore" NavigateUri="https://learn.microsoft.com/windows/powertoys/advanced-paste" />
                                </StackPanel>
                            </tkcontrols:SettingsExpander.Description>
                            <tkcontrols:SettingsExpander.ItemsHeader>
                                <tkcontrols:SettingsCard x:Uid="AdvancedPaste_ModelProviders" Style="{StaticResource DefaultSettingsExpanderItemStyle}">
                                    <Button x:Uid="AdvancedPaste_AddModelButton" Style="{StaticResource AccentButtonStyle}">
                                        <Button.Flyout>
                                            <MenuFlyout x:Name="AddProviderMenuFlyout" Opening="AddProviderMenuFlyout_Opening" />
                                        </Button.Flyout>
                                    </Button>
                                </tkcontrols:SettingsCard>
                            </tkcontrols:SettingsExpander.ItemsHeader>
                            <tkcontrols:SettingsExpander.ItemTemplate>
                                <DataTemplate x:DataType="models:PasteAIProviderDefinition">
                                    <tkcontrols:SettingsCard
                                        Description="{x:Bind ServiceType, Mode=OneWay}"
                                        Header="{x:Bind ModelName, Mode=OneWay}"
                                        HeaderIcon="{x:Bind ServiceType, Mode=OneWay, Converter={StaticResource ServiceTypeToIconConverter}}">
                                        <StackPanel Orientation="Horizontal" Spacing="8">
                                            <Button
                                                Padding="8"
                                                Background="Transparent"
                                                BorderThickness="0"
                                                Tag="{x:Bind}">
                                                <FontIcon FontSize="16" Glyph="&#xE712;" />
                                                <Button.Flyout>
                                                    <MenuFlyout>
                                                        <MenuFlyoutItem
                                                            x:Uid="AdvancedPaste_Edit"
                                                            Click="EditPasteAIProviderButton_Click"
                                                            Icon="{ui:FontIcon Glyph=&#xE70F;}"
                                                            Tag="{x:Bind}" />
                                                        <MenuFlyoutSeparator />
                                                        <MenuFlyoutItem
                                                            x:Uid="AdvancedPaste_Remove"
                                                            Click="RemovePasteAIProviderButton_Click"
                                                            Icon="{ui:FontIcon Glyph=&#xE74D;}"
                                                            Tag="{x:Bind}" />
                                                    </MenuFlyout>
                                                </Button.Flyout>
                                            </Button>
                                        </StackPanel>
                                    </tkcontrols:SettingsCard>
                                </DataTemplate>
                            </tkcontrols:SettingsExpander.ItemTemplate>
                        </tkcontrols:SettingsExpander>
                    </controls:SettingsGroup>

                    <!--  Activation and behavior  -->
                    <controls:SettingsGroup x:Uid="AdvancedPaste_BehaviorSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
                        <tkcontrols:SettingsExpander
                            Name="AdvancedPasteUIShortcut"
                            x:Uid="AdvancedPasteUI_Shortcut"
                            HeaderIcon="{ui:FontIcon Glyph=&#xEDA7;}"
                            IsExpanded="True">
                            <tkcontrols:SettingsExpander.ItemsHeader>
                                <InfoBar
                                    x:Uid="GPO_SettingIsManaged"
                                    IsClosable="False"
                                    IsOpen="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}"
                                    IsTabStop="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}"
                                    Severity="Informational">
                                    <InfoBar.IconSource>
                                        <FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72E;" />
                                    </InfoBar.IconSource>
                                </InfoBar>
                            </tkcontrols:SettingsExpander.ItemsHeader>
                            <controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.AdvancedPasteUIShortcut, Mode=TwoWay}" />
                            <tkcontrols:SettingsExpander.Items>
                                <tkcontrols:SettingsCard Name="AdvancedPasteEnableClipboardPreview" ContentAlignment="Left">
                                    <ptcontrols:CheckBoxWithDescriptionControl x:Uid="AdvancedPaste_EnableClipboardPreview" IsChecked="{x:Bind ViewModel.EnableClipboardPreview, Mode=TwoWay}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard Name="AdvancedPasteAutoCopySelectionCustomAction" ContentAlignment="Left">
                                    <ptcontrols:CheckBoxWithDescriptionControl x:Uid="AdvancedPaste_AutoCopySelectionForCustomActionHotkey" IsChecked="{x:Bind ViewModel.AutoCopySelectionForCustomActionHotkey, Mode=TwoWay}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard
                                    Name="AdvancedPasteClipboardHistoryEnabledSettingsCard"
                                    ContentAlignment="Left"
                                    IsEnabled="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=OneWay}">
                                    <ptcontrols:CheckBoxWithDescriptionControl x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard" IsChecked="{x:Bind ViewModel.ClipboardHistoryEnabled, Mode=TwoWay}" />
                                </tkcontrols:SettingsCard>

                                <tkcontrols:SettingsCard Name="AdvancedPasteCloseAfterLosingFocus" ContentAlignment="Left">
                                    <CheckBox x:Uid="AdvancedPaste_CloseAfterLosingFocus" IsChecked="{x:Bind ViewModel.CloseAfterLosingFocus, Mode=TwoWay}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard Name="AdvancedPasteShowCustomPreviewSettingsCard" ContentAlignment="Left">
                                    <ptcontrols:CheckBoxWithDescriptionControl x:Uid="AdvancedPaste_ShowCustomPreviewSettingsCard" IsChecked="{x:Bind ViewModel.ShowCustomPreview, Mode=TwoWay}" />
                                </tkcontrols:SettingsCard>
                            </tkcontrols:SettingsExpander.Items>
                        </tkcontrols:SettingsExpander>
                    </controls:SettingsGroup>

                    <!--  Built-in actions  -->
                    <controls:SettingsGroup x:Uid="AdvancedPaste_Direct_Access_Hotkeys_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
                        <tkcontrols:SettingsCard
                            Name="PasteAsPlainTextShortcut"
                            x:Uid="PasteAsPlainText_Shortcut"
                            HeaderIcon="{ui:FontIcon Glyph=&#xE8E9;}">
                            <controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.PasteAsPlainTextShortcut, Mode=TwoWay}" />
                        </tkcontrols:SettingsCard>
                        <tkcontrols:SettingsCard
                            Name="PasteAsMarkdownShortcut"
                            x:Uid="PasteAsMarkdown_Shortcut"
                            HeaderIcon="{ui:FontIcon Glyph=&#xe8a5;}">
                            <controls:ShortcutControl
                                MinWidth="{StaticResource SettingActionControlMinWidth}"
                                AllowDisable="True"
                                HotkeySettings="{x:Bind Path=ViewModel.PasteAsMarkdownShortcut, Mode=TwoWay}" />
                        </tkcontrols:SettingsCard>
                        <tkcontrols:SettingsCard
                            Name="PasteAsJsonShortcut"
                            x:Uid="PasteAsJson_Shortcut"
                            HeaderIcon="{ui:FontIcon Glyph=&#xE943;}">
                            <controls:ShortcutControl
                                MinWidth="{StaticResource SettingActionControlMinWidth}"
                                AllowDisable="True"
                                HotkeySettings="{x:Bind Path=ViewModel.PasteAsJsonShortcut, Mode=TwoWay}" />
                        </tkcontrols:SettingsCard>
                        <tkcontrols:SettingsCard
                            Name="ImageToText"
                            x:Uid="ImageToText"
                            DataContext="{x:Bind ViewModel.AdditionalActions.ImageToText, Mode=OneWay}"
                            HeaderIcon="{ui:FontIcon Glyph=&#xE91B;}">
                            <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                        </tkcontrols:SettingsCard>
                        <tkcontrols:SettingsExpander
                            Name="PasteAsFile"
                            x:Uid="PasteAsFile"
                            DataContext="{x:Bind ViewModel.AdditionalActions.PasteAsFile, Mode=OneWay}"
                            HeaderIcon="{ui:FontIcon Glyph=&#xEC50;}"
                            IsExpanded="{Binding IsShown, Mode=OneWay}">
                            <tkcontrols:SettingsExpander.Content>
                                <ToggleSwitch
                                    IsOn="{Binding IsShown, Mode=TwoWay}"
                                    OffContent=""
                                    OnContent="" />
                            </tkcontrols:SettingsExpander.Content>
                            <tkcontrols:SettingsExpander.Items>
                                <!--  HACK: For some weird reason, a ShortcutControl does not work correctly if it's the first or last item in the expander, so we add an invisible card.  -->
                                <tkcontrols:SettingsCard Visibility="Collapsed" />
                                <tkcontrols:SettingsCard
                                    Name="PasteAsTxtFile"
                                    x:Uid="PasteAsTxtFile"
                                    DataContext="{Binding PasteAsTxtFile, Mode=TwoWay}"
                                    IsEnabled="{x:Bind ViewModel.AdditionalActions.PasteAsFile.IsShown, Mode=OneWay}">
                                    <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard
                                    Name="PasteAsPngFile"
                                    x:Uid="PasteAsPngFile"
                                    DataContext="{Binding PasteAsPngFile, Mode=TwoWay}"
                                    IsEnabled="{x:Bind ViewModel.AdditionalActions.PasteAsFile.IsShown, Mode=OneWay}">
                                    <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard
                                    Name="PasteAsHtmlFile"
                                    x:Uid="PasteAsHtmlFile"
                                    DataContext="{Binding PasteAsHtmlFile, Mode=TwoWay}"
                                    IsEnabled="{x:Bind ViewModel.AdditionalActions.PasteAsFile.IsShown, Mode=OneWay}">
                                    <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                                </tkcontrols:SettingsCard>
                                <!--  HACK: For some weird reason, a ShortcutControl does not work correctly if it's the first or last item in the expander, so we add an invisible card.  -->
                                <tkcontrols:SettingsCard Visibility="Collapsed" />
                            </tkcontrols:SettingsExpander.Items>
                        </tkcontrols:SettingsExpander>
                        <tkcontrols:SettingsExpander
                            Name="Transcode"
                            x:Uid="Transcode"
                            DataContext="{x:Bind ViewModel.AdditionalActions.Transcode, Mode=OneWay}"
                            HeaderIcon="{ui:FontIcon Glyph=&#xEA69;}"
                            IsExpanded="{Binding IsShown, Mode=OneWay}">
                            <tkcontrols:SettingsExpander.Content>
                                <ToggleSwitch
                                    IsOn="{Binding IsShown, Mode=TwoWay}"
                                    OffContent=""
                                    OnContent="" />
                            </tkcontrols:SettingsExpander.Content>
                            <tkcontrols:SettingsExpander.Items>
                                <!--  HACK: For some weird reason, a ShortcutControl does not work correctly if it's the first or last item in the expander, so we add an invisible card.  -->
                                <tkcontrols:SettingsCard Visibility="Collapsed" />
                                <tkcontrols:SettingsCard
                                    Name="TranscodeToMp3"
                                    x:Uid="TranscodeToMp3"
                                    DataContext="{Binding TranscodeToMp3, Mode=TwoWay}"
                                    IsEnabled="{x:Bind ViewModel.AdditionalActions.Transcode.IsShown, Mode=OneWay}">
                                    <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                                </tkcontrols:SettingsCard>
                                <tkcontrols:SettingsCard
                                    Name="TranscodeToMp4"
                                    x:Uid="TranscodeToMp4"
                                    DataContext="{Binding TranscodeToMp4, Mode=TwoWay}"
                                    IsEnabled="{x:Bind ViewModel.AdditionalActions.Transcode.IsShown, Mode=OneWay}">
                                    <ContentControl ContentTemplate="{StaticResource AdditionalActionTemplate}" />
                                </tkcontrols:SettingsCard>
                                <!--  HACK: For some weird reason, a ShortcutControl does not work correctly if it's the first or last item in the expander, so we add an invisible card.  -->
                                <tkcontrols:SettingsCard Visibility="Collapsed" />
                            </tkcontrols:SettingsExpander.Items>
                        </tkcontrols:SettingsExpander>
                        <InfoBar
                            x:Uid="AdvancedPaste_ShortcutWarning"
                            IsClosable="False"
                            IsOpen="{x:Bind ViewModel.IsAdditionalActionConflictingCopyShortcut, Mode=OneWay}"
                            IsTabStop="{x:Bind ViewModel.IsAdditionalActionConflictingCopyShortcut, Mode=OneWay}"
                            Severity="Warning" />
                    </controls:SettingsGroup>

                    <!--  Custom actions  -->
                    <controls:SettingsGroup x:Uid="AdvancedPaste_Additional_Actions_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
                        <tkcontrols:SettingsExpander
                            Name="AdvancedPasteUIActions"
                            x:Uid="AdvancedPasteUI_Actions"
                            HeaderIcon="{ui:FontIcon Glyph=&#xE792;}"
                            IsEnabled="{x:Bind ViewModel.IsAIEnabled, Mode=OneWay}"
                            IsExpanded="True"
                            ItemsSource="{x:Bind ViewModel.CustomActions, Mode=OneWay}">
                            <Button
                                x:Uid="AdvancedPasteUI_AddCustomActionButton"
                                Click="AddCustomActionButton_Click"
                                Style="{ThemeResource AccentButtonStyle}" />
                            <tkcontrols:SettingsExpander.ItemTemplate>
                                <DataTemplate x:DataType="models:AdvancedPasteCustomAction">
                                    <tkcontrols:SettingsCard
                                        Margin="0,0,0,2"
                                        Click="EditCustomActionButton_Click"
                                        Description="{x:Bind Description, Mode=OneWay}"
                                        Header="{x:Bind Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                        IsActionIconVisible="False"
                                        IsClickEnabled="True"
                                        Tag="{x:Bind}">
                                        <tkcontrols:SettingsCard.Resources>
                                            <x:Double x:Key="SettingsCardActionButtonWidth">0</x:Double>
                                        </tkcontrols:SettingsCard.Resources>
                                        <ToolTipService.ToolTip>
                                            <TextBlock Text="{x:Bind Prompt, Mode=OneWay}" TextWrapping="Wrap" />
                                        </ToolTipService.ToolTip>
                                        <StackPanel Orientation="Horizontal" Spacing="4">
                                            <controls:ShortcutControl
                                                MinWidth="{StaticResource SettingActionControlMinWidth}"
                                                AllowDisable="True"
                                                HotkeySettings="{x:Bind Path=Shortcut, Mode=TwoWay}" />
                                            <ToggleSwitch
                                                x:Uid="Enable_CustomAction"
                                                AutomationProperties.HelpText="{x:Bind Name, Mode=OneWay}"
                                                IsOn="{x:Bind IsShown, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                OffContent=""
                                                OnContent="" />
                                            <Button
                                                x:Uid="More_Options_Button"
                                                Grid.Column="1"
                                                VerticalAlignment="Center"
                                                Content="&#xE712;"
                                                FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                                Style="{StaticResource SubtleButtonStyle}"
                                                Tag="{x:Bind}">
                                                <Button.Flyout>
                                                    <MenuFlyout>
                                                        <MenuFlyoutItem
                                                            x:Uid="MoveUp"
                                                            Click="ReorderButtonUp_Click"
                                                            Icon="{ui:FontIcon Glyph=&#xE74A;}"
                                                            IsEnabled="{x:Bind CanMoveUp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                            Tag="{x:Bind}" />
                                                        <MenuFlyoutItem
                                                            x:Uid="MoveDown"
                                                            Click="ReorderButtonDown_Click"
                                                            Icon="{ui:FontIcon Glyph=&#xE74B;}"
                                                            IsEnabled="{x:Bind CanMoveDown, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                            Tag="{x:Bind}" />
                                                        <MenuFlyoutSeparator />
                                                        <MenuFlyoutItem
                                                            x:Uid="RemoveItem"
                                                            Click="DeleteCustomActionButton_Click"
                                                            Icon="{ui:FontIcon Glyph=&#xE74D;}"
                                                            IsEnabled="true"
                                                            Tag="{x:Bind}" />
                                                    </MenuFlyout>
                                                </Button.Flyout>
                                                <ToolTipService.ToolTip>
                                                    <TextBlock x:Uid="More_Options_ButtonTooltip" />
                                                </ToolTipService.ToolTip>
                                            </Button>
                                        </StackPanel>
                                    </tkcontrols:SettingsCard>
                                </DataTemplate>
                            </tkcontrols:SettingsExpander.ItemTemplate>
                        </tkcontrols:SettingsExpander>
                        <InfoBar
                            x:Uid="AdvancedPaste_ShortcutWarning"
                            IsClosable="False"
                            IsOpen="{x:Bind ViewModel.IsConflictingCopyShortcut, Mode=OneWay}"
                            IsTabStop="{x:Bind ViewModel.IsConflictingCopyShortcut, Mode=OneWay}"
                            Severity="Warning" />
                    </controls:SettingsGroup>
                </StackPanel>
            </controls:SettingsPageControl.ModuleContent>
            <controls:SettingsPageControl.PrimaryLinks>
                <controls:PageLink x:Uid="LearnMore_AdvancedPaste" Link="https://aka.ms/PowerToysOverview_AdvancedPaste" />
            </controls:SettingsPageControl.PrimaryLinks>
        </controls:SettingsPageControl>
        <ContentDialog
            x:Name="CustomActionDialog"
            x:Uid="CustomActionDialog"
            Closed="CustomActionDialog_Closed"
            IsPrimaryButtonEnabled="{Binding IsValid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
            IsSecondaryButtonEnabled="True"
            PrimaryButtonStyle="{ThemeResource AccentButtonStyle}">
            <ContentDialog.DataContext>
                <models:AdvancedPasteCustomAction />
            </ContentDialog.DataContext>
            <StackPanel Spacing="16">
                <TextBox
                    x:Uid="AdvancedPasteUI_CustomAction_Name"
                    Width="340"
                    HorizontalAlignment="Left"
                    Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <TextBox
                    x:Uid="AdvancedPasteUI_CustomAction_Description"
                    Width="340"
                    HorizontalAlignment="Left"
                    Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <TextBox
                    x:Uid="AdvancedPasteUI_CustomAction_Prompt"
                    Width="340"
                    Height="280"
                    HorizontalAlignment="Left"
                    AcceptsReturn="true"
                    Text="{Binding Prompt, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    TextWrapping="Wrap" />
            </StackPanel>
        </ContentDialog>

        <!--  Paste AI provider dialog  -->
        <ContentDialog
            x:Name="PasteAIProviderConfigurationDialog"
            x:Uid="AdvancedPaste_EndpointDialog"
            Closed="PasteAIProviderConfigurationDialog_Closed"
            PrimaryButtonClick="PasteAIProviderConfigurationDialog_PrimaryButtonClick"
            PrimaryButtonStyle="{ThemeResource AccentButtonStyle}">
            <ContentDialog.Resources>
                <x:Double x:Key="ContentDialogMaxWidth">900</x:Double>
                <x:Double x:Key="ContentDialogMaxHeight">700</x:Double>
                <StaticResource x:Key="ContentDialogTopOverlay" ResourceKey="NavigationViewContentBackground" />
            </ContentDialog.Resources>
            <ScrollViewer
                MaxHeight="550"
                Margin="-16,0,-24,-24"
                HorizontalScrollBarVisibility="Disabled"
                VerticalScrollBarVisibility="Auto">
                <StackPanel
                    MinWidth="640"
                    Padding="16,0,16,16"
                    Spacing="16">
                    <InfoBar
                        x:Name="PasteAIProviderGpoInfoBar"
                        x:Uid="GPO_SettingIsManaged"
                        Margin="0,12,0,0"
                        IsClosable="False"
                        IsOpen="{x:Bind ViewModel.ShowPasteAIProviderGpoConfiguredInfoBar, Mode=OneWay}"
                        IsTabStop="{x:Bind ViewModel.ShowPasteAIProviderGpoConfiguredInfoBar, Mode=OneWay}"
                        Severity="Informational">
                        <InfoBar.IconSource>
                            <FontIconSource FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72E;" />
                        </InfoBar.IconSource>
                    </InfoBar>
                    <StackPanel
                        Margin="0,12,0,0"
                        Orientation="Vertical"
                        Spacing="8"
                        Visibility="{x:Bind GetServiceLegalVisibility(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}">
                        <TextBlock
                            Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                            Style="{StaticResource CaptionTextBlockStyle}"
                            Text="{x:Bind GetServiceLegalDescription(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}"
                            TextWrapping="Wrap" />
                        <StackPanel
                            Margin="0,0,0,0"
                            Orientation="Horizontal"
                            Spacing="8">
                            <HyperlinkButton
                                Padding="0"
                                Content="{x:Bind GetServiceTermsLabel(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}"
                                FontSize="12"
                                NavigateUri="{x:Bind GetServiceTermsUri(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}"
                                Visibility="{x:Bind GetServiceTermsVisibility(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}" />
                            <HyperlinkButton
                                Padding="0"
                                Content="{x:Bind GetServicePrivacyLabel(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}"
                                FontSize="12"
                                NavigateUri="{x:Bind GetServicePrivacyUri(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}"
                                Visibility="{x:Bind GetServicePrivacyVisibility(ViewModel.PasteAIProviderDraft?.ServiceType), Mode=OneWay}" />
                        </StackPanel>
                    </StackPanel>
                    <Rectangle Height="1" Fill="{ThemeResource DividerStrokeColorDefaultBrush}" />
                    <StackPanel
                        Margin="0,8,0,48"
                        Orientation="Vertical"
                        Spacing="16">
                        <TextBox
                            x:Name="PasteAIModelNameTextBox"
                            x:Uid="AdvancedPaste_ModelName"
                            MinWidth="200"
                            HorizontalAlignment="Stretch"
                            PlaceholderText="gpt-4o"
                            Text="{x:Bind ViewModel.PasteAIProviderDraft.ModelName, Mode=TwoWay}" />
                        <TextBox
                            x:Name="PasteAIEndpointUrlTextBox"
                            x:Uid="AdvancedPaste_EndpointURL"
                            MinWidth="200"
                            HorizontalAlignment="Stretch"
                            PlaceholderText="https://your-resource.openai.azure.com/"
                            Text="{x:Bind ViewModel.PasteAIProviderDraft.EndpointUrl, Mode=TwoWay}" />
                        <PasswordBox
                            x:Name="PasteAIApiKeyPasswordBox"
                            x:Uid="AdvancedPaste_APIKey"
                            MinWidth="200" />
                        <TextBox
                            x:Name="PasteAIApiVersionTextBox"
                            x:Uid="AdvancedPaste_APIVersion"
                            MinWidth="200"
                            HorizontalAlignment="Stretch"
                            PlaceholderText="2024-10-01"
                            Text="{x:Bind ViewModel.PasteAIProviderDraft.ApiVersion, Mode=TwoWay}"
                            Visibility="Collapsed" />
                        <TextBox
                            x:Name="PasteAIDeploymentNameTextBox"
                            x:Uid="AdvancedPaste_DeploymentName"
                            MinWidth="200"
                            PlaceholderText="gpt-4o"
                            Text="{x:Bind ViewModel.PasteAIProviderDraft.DeploymentName, Mode=TwoWay}" />
                        <TextBox
                            x:Name="PasteAISystemPromptTextBox"
                            x:Uid="AdvancedPaste_SystemPrompt"
                            MinWidth="200"
                            MinHeight="76"
                            HorizontalAlignment="Stretch"
                            AcceptsReturn="True"
                            Text="{x:Bind ViewModel.PasteAIProviderDraft.SystemPrompt, Mode=TwoWay}"
                            TextWrapping="Wrap" />
                        <Grid
                            x:Name="FoundryLocalPanel"
                            Margin="0,8,0,0"
                            Visibility="Collapsed">
                            <controls:FoundryLocalModelPicker x:Name="FoundryLocalPicker" />
                        </Grid>

                        <StackPanel
                            x:Name="PasteAIModelPanel"
                            Orientation="Horizontal"
                            Spacing="8">
                            <TextBox
                                x:Name="PasteAIModelPathTextBox"
                                x:Uid="AdvancedPaste_ModelPath"
                                MinWidth="200"
                                HorizontalAlignment="Stretch"
                                PlaceholderText="C:\Models\phi-3.onnx"
                                Text="{x:Bind ViewModel.PasteAIProviderDraft.ModelPath, Mode=TwoWay}" />
                            <Button
                                VerticalAlignment="Bottom"
                                Click="BrowsePasteAIModelPath_Click"
                                Content="{ui:FontIcon Glyph=&#xE8DA;,
                                                      FontSize=16}"
                                Style="{StaticResource SubtleButtonStyle}" />
                        </StackPanel>

                        <ToggleSwitch
                            x:Name="PasteAIModerationToggle"
                            x:Uid="AdvancedPaste_EnablePasteAIModerationToggle"
                            IsOn="{x:Bind ViewModel.PasteAIProviderDraft.ModerationEnabled, Mode=TwoWay}"
                            Visibility="Collapsed" />

                        <ToggleSwitch
                            x:Name="PasteAIEnableAdvancedAICheckBox"
                            IsOn="{x:Bind ViewModel.PasteAIProviderDraft.EnableAdvancedAI, Mode=TwoWay}"
                            Toggled="PasteAIEnableAdvancedAICheckBox_Toggled"
                            Visibility="Collapsed">
                            <ToggleSwitch.Header>
                                <TextBlock>
                                    <Run x:Uid="AdvancedPaste_EnableAdvancedAI" /> <LineBreak />
                                    <Run x:Uid="AdvancedPaste_EnableAdvancedAIDescription" Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                                </TextBlock>
                            </ToggleSwitch.Header>
                        </ToggleSwitch>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </ContentDialog>
    </Grid>
</local:NavigablePage>
