using Dalamud.Game.Text;
using LightlessSync.UtilsEnum.Enum;
using LightlessSync.LightlessConfiguration.Models;
using LightlessSync.UI;
using LightlessSync.UI.Models;
using Microsoft.Extensions.Logging;

namespace LightlessSync.LightlessConfiguration.Configurations;

[Serializable]
public class LightlessConfig : ILightlessConfiguration
{
    public bool AcceptedAgreement { get; set; } = false;
    public string CacheFolder { get; set; } = string.Empty;
    public bool DisableOptionalPluginWarnings { get; set; } = false;
    public bool EnableDtrEntry { get; set; } = false;
    public bool ShowUidInDtrTooltip { get; set; } = true;
    public bool PreferNoteInDtrTooltip { get; set; } = false;
    public bool IsNameplateColorsEnabled { get; set; } = false;
    public DtrEntry.Colors NameplateColors { get; set; } = new(Foreground: 0xE69138u, Glow: 0xFFBA47u);
    public Dictionary<string, string> CustomUIColors { get; set; } = new(StringComparer.OrdinalIgnoreCase);
    public bool UseColorsInDtr { get; set; } = true;
    public DtrEntry.Colors DtrColorsDefault { get; set; } = default;
    public DtrEntry.Colors DtrColorsNotConnected { get; set; } = new(Glow: 0x0428FFu);
    public DtrEntry.Colors DtrColorsPairsInRange { get; set; } = new(Glow: 0xFFBA47u);
    public bool ShowLightfinderInDtr { get; set; } = false;
    public bool UseLightfinderColorsInDtr { get; set; } = true;
    public DtrEntry.Colors DtrColorsLightfinderEnabled { get; set; } = new(Foreground: 0xB590FFu, Glow: 0x4F406Eu);
    public DtrEntry.Colors DtrColorsLightfinderDisabled { get; set; } = new(Foreground: 0xD44444u, Glow: 0x642222u);
    public DtrEntry.Colors DtrColorsLightfinderCooldown { get; set; } = new(Foreground: 0xFFE97Au, Glow: 0x766C3Au);
    public DtrEntry.Colors DtrColorsLightfinderUnavailable { get; set; } = new(Foreground: 0x000000u, Glow: 0x000000u);
    public LightfinderDtrDisplayMode LightfinderDtrDisplayMode { get; set; } = LightfinderDtrDisplayMode.PendingPairRequests;
    public bool UseLightlessRedesign { get; set; } = true;
    public bool EnableRightClickMenus { get; set; } = true;
    public NotificationLocation ErrorNotification { get; set; } = NotificationLocation.Both;
    public string ExportFolder { get; set; } = string.Empty;
    public bool FileScanPaused { get; set; } = false;
    public NotificationLocation InfoNotification { get; set; } = NotificationLocation.Toast;
    public bool InitialScanComplete { get; set; } = false;
    public LogLevel LogLevel { get; set; } = LogLevel.Information;
    public bool LogPerformance { get; set; } = false;
    public double MaxLocalCacheInGiB { get; set; } = 20;
    public bool OpenGposeImportOnGposeStart { get; set; } = false;
    public bool OpenPopupOnAdd { get; set; } = true;
    public int ParallelDownloads { get; set; } = 10;
    public int ParallelUploads { get; set; } = 8;
    public bool EnablePairProcessingLimiter { get; set; } = true;
    public int MaxConcurrentPairApplications { get; set; } = 3;
    public int DownloadSpeedLimitInBytes { get; set; } = 0;
    public DownloadSpeeds DownloadSpeedType { get; set; } = DownloadSpeeds.MBps;
    public bool PreferNotesOverNamesForVisible { get; set; } = false;
    public VisiblePairSortMode VisiblePairSortMode { get; set; } = VisiblePairSortMode.Alphabetical;
    public OnlinePairSortMode OnlinePairSortMode { get; set; } = OnlinePairSortMode.Alphabetical;
    public float ProfileDelay { get; set; } = 1.5f;
    public bool ProfilePopoutRight { get; set; } = false;
    public bool ProfilesAllowNsfw { get; set; } = false;
    public bool ProfilesShow { get; set; } = true;
    public bool ShowSyncshellUsersInVisible { get; set; } = true;
    public bool ShowCharacterNameInsteadOfNotesForVisible { get; set; } = false;
    public bool ShowOfflineUsersSeparately { get; set; } = true;
    public bool ShowSyncshellOfflineUsersSeparately { get; set; } = true;
    public bool ShowGroupedSyncshellsInAll { get; set; } = true;
    public bool GroupUpSyncshells { get; set; } = true;
    public bool ShowOnlineNotifications { get; set; } = false;
    public bool ShowOnlineNotificationsOnlyForIndividualPairs { get; set; } = true;
    public bool ShowOnlineNotificationsOnlyForNamedPairs { get; set; } = false;
    public bool ShowVisiblePairsGreenEye { get; set; } = false;
    public bool ShowTransferBars { get; set; } = true;
    public bool ShowTransferWindow { get; set; } = false;
    public bool ShowPlayerLinesTransferWindow { get; set; } = true;
    public bool ShowPlayerSpeedBarsTransferWindow { get; set; } = true;
    public bool UseNotificationsForDownloads { get; set; } = true;
    public bool ShowUploading { get; set; } = true;
    public bool ShowUploadingBigText { get; set; } = true;
    public bool ShowVisibleUsersSeparately { get; set; } = true;
    public bool EnableDirectDownloads { get; set; } = true;
    public int TimeSpanBetweenScansInSeconds { get; set; } = 30;
    public int TransferBarsHeight { get; set; } = 12;
    public bool TransferBarsShowText { get; set; } = true;
    public int TransferBarsWidth { get; set; } = 250;
    public bool UseAlternativeFileUpload { get; set; } = false;
    public bool UseCompactor { get; set; } = false;
    public bool DebugStopWhining { get; set; } = false;
    public bool AutoPopulateEmptyNotesFromCharaName { get; set; } = false;
    public int Version { get; set; } = 1;
    public NotificationLocation WarningNotification { get; set; } = NotificationLocation.Both;
    
    // Lightless Notification Configuration
    public bool UseLightlessNotifications { get; set; } = true;
    public bool ShowNotificationProgress { get; set; } = true;
    public NotificationLocation LightlessInfoNotification { get; set; } = NotificationLocation.LightlessUi;
    public NotificationLocation LightlessWarningNotification { get; set; } = NotificationLocation.LightlessUi;
    public NotificationLocation LightlessErrorNotification { get; set; } = NotificationLocation.ChatAndLightlessUi;
    public NotificationLocation LightlessPairRequestNotification { get; set; } = NotificationLocation.LightlessUi;
    public NotificationLocation LightlessDownloadNotification { get; set; } = NotificationLocation.TextOverlay;
    public NotificationLocation LightlessPerformanceNotification { get; set; } = NotificationLocation.LightlessUi;
    
    // Basic Settings
    public float NotificationOpacity { get; set; } = 0.95f;
    public int MaxSimultaneousNotifications { get; set; } = 5;
    public bool AutoDismissOnAction { get; set; } = true;
    public bool DismissNotificationOnClick { get; set; } = false;
    public bool ShowNotificationTimestamp { get; set; } = false;
    
    // Position & Layout
    public NotificationCorner NotificationCorner { get; set; } = NotificationCorner.Right;
    public int NotificationOffsetY { get; set; } = 50;
    public int NotificationOffsetX { get; set; } = 0;
    public float NotificationWidth { get; set; } = 350f;
    public float NotificationSpacing { get; set; } = 8f;
    
    // Animation & Effects
    public float NotificationAnimationSpeed { get; set; } = 10f;
    public float NotificationSlideSpeed { get; set; } = 10f;
    public float NotificationAccentBarWidth { get; set; } = 3f;
    
    // Duration per Type
    public int InfoNotificationDurationSeconds { get; set; } = 10;
    public int WarningNotificationDurationSeconds { get; set; } = 15;
    public int ErrorNotificationDurationSeconds { get; set; } = 20;
    public int PairRequestDurationSeconds { get; set; } = 180;
    public int DownloadNotificationDurationSeconds { get; set; } = 30;
    public int PerformanceNotificationDurationSeconds { get; set; } = 20;
    public uint CustomInfoSoundId { get; set; } = 2;  // Se2
    public uint CustomWarningSoundId { get; set; } = 16; // Se15
    public uint CustomErrorSoundId { get; set; } = 16; // Se15
    public uint PairRequestSoundId { get; set; } = 5; // Se5
    public uint PerformanceSoundId { get; set; } = 16; // Se15
    public bool DisableInfoSound { get; set; } = true;
    public bool DisableWarningSound { get; set; } = true;
    public bool DisableErrorSound { get; set; } = true;
    public bool DisablePairRequestSound { get; set; } = true;
    public bool DisablePerformanceSound { get; set; } = true;
    public bool ShowPerformanceNotificationActions { get; set; } = true;
    public bool ShowPairRequestNotificationActions { get; set; } = true;
    public bool UseFocusTarget { get; set; } = false;
    public bool overrideFriendColor { get; set; } = false;
    public bool overridePartyColor { get; set; } = false;
    public bool overrideFcTagColor { get; set; } = false;
    public bool useColoredUIDs { get; set; } = true;
    public bool BroadcastEnabled { get; set; } = false;
    public bool LightfinderAutoEnableOnConnect { get; set; } = false;
    public LightfinderLabelRenderer LightfinderLabelRenderer { get; set; } = LightfinderLabelRenderer.Pictomancy;
    public short LightfinderLabelOffsetX { get; set; } = 0;
    public short LightfinderLabelOffsetY { get; set; } = 0;
    public bool LightfinderLabelUseIcon { get; set; } = false;
    public bool LightfinderLabelShowOwn { get; set; } = true;
    public bool LightfinderLabelShowPaired { get; set; } = true;
    public bool LightfinderLabelShowHidden { get; set; } = false;
    public string LightfinderLabelIconGlyph { get; set; } = SeIconCharExtensions.ToIconString(SeIconChar.Hyadelyn);
    public float LightfinderLabelScale { get; set; } = 1.0f;
    public bool LightfinderAutoAlign { get; set; } = true;
    public LabelAlignment LabelAlignment { get; set; } = LabelAlignment.Left;
    public DateTime BroadcastTtl { get; set; } = DateTime.MinValue;
    public bool SyncshellFinderEnabled { get; set; } = false;
    public string? SelectedFinderSyncshell { get; set; } = null;
    public string LastSeenVersion { get; set; } = string.Empty;
    public HashSet<Guid> OrphanableTempCollections { get; set; } = [];
}
