using System.Collections.Generic;

namespace Knot.Contracts.Settings.Application.DTOs;

public class SystemConfig
{
    public string ServerTimezone { get; set; } = "UTC";
    public string DomainUrl { get; set; } = "https://example.com";
    public string AdminRoute { get; set; } = "admin";
    public bool EnableRegistration { get; set; } = true;
}

public class StoriesConfig
{
    public bool Enabled { get; set; } = true;
    public int MaxStoriesPerPeriod { get; set; } = 5;
    public int StoryLifetimeHours { get; set; } = 24;
    public bool TextStoriesEnabled { get; set; } = true;
    public int TextStoryDurationSeconds { get; set; } = 15;
    public int MediaStoryMaxDurationSeconds { get; set; } = 30;
    public int MaxMediaSizeBytes { get; set; } = 15 * 1024 * 1024;
}

public class ChatsConfig
{
    public bool SupportGroups { get; set; } = true;
    public int MaxGroupParticipants { get; set; } = 200000;
    public bool EnableAutoClean { get; set; } = false;
    public bool AllowChatToGroupConversion { get; set; } = true;
    public bool EnableFolders { get; set; } = true;
}

public class MessagesConfig
{
    public int DailyMessageLimitPerUser { get; set; } = 0;
    public int ChatMessageLimit { get; set; } = 0;
    public bool AllowMedia { get; set; } = true;
    public int MaxMediaSizeBytes { get; set; } = 50 * 1024 * 1024;
    public int MaxFileSize { get; set; } = 100 * 1024 * 1024;
    public List<string> AllowedMediaTypes { get; set; } = new() { "image/jpeg", "image/png", "video/mp4", "image/gif" };
    public bool AllowVoiceMessages { get; set; } = true;
    public bool AllowForwarding { get; set; } = true;
    public bool AllowReactions { get; set; } = true;
    public bool AllowReplies { get; set; } = true;
    public bool AllowQuoting { get; set; } = true;
    public bool AllowMessageDeletion { get; set; } = true;
    public bool ForbidCopying { get; set; } = false;
    public bool AllowLinks { get; set; } = true;
    public bool AllowPolls { get; set; } = true;
    public bool AllowPinning { get; set; } = true;
}

public class WebRtcConfig
{
    public bool Enabled { get; set; } = false;
    public bool EnableVoiceCalls { get; set; } = true;
    public bool EnableVideoCalls { get; set; } = true;
    public bool EnableScreenSharing { get; set; } = true;
    public string TurnHost { get; set; } = string.Empty;
    public int TurnPort { get; set; } = 3478;
    public string TurnUser { get; set; } = string.Empty;
    public string TurnSecret { get; set; } = string.Empty;
}

public class KlipyConfig
{
    public bool Enabled { get; set; } = false;
    public string ApiKey { get; set; } = string.Empty;
    public string AppName { get; set; } = string.Empty;
}

public class ImportConfig
{
    public bool EnableTelegramImport { get; set; } = false;
}

public class FederationDomainConfig
{
    public string Domain { get; set; } = string.Empty;
    public bool IsEnabled { get; set; } = true;
    public string? PublicKey { get; set; }
    public RemoteCapabilities? Capabilities { get; set; }
}

public class RemoteCapabilities
{
    public bool AllowMedia { get; set; }
    public bool AllowPolls { get; set; }
    public bool AllowVoiceMessages { get; set; }
    public bool AllowVideoCalls { get; set; }
    public bool AllowScreenSharing { get; set; }
}

public class FederationConfig
{
    public bool Enabled { get; set; } = false;
    public string ServerDescription { get; set; } = string.Empty;
    public string? PrivateKey { get; set; }
    public string? PublicKey { get; set; }
    public List<FederationDomainConfig> AllowedDomains { get; set; } = new();
}

public class SystemSettingsDto
{
    public SystemConfig System { get; set; } = new();
    public StoriesConfig Stories { get; set; } = new();
    public ChatsConfig Chats { get; set; } = new();
    public MessagesConfig Messages { get; set; } = new();
    public WebRtcConfig WebRtc { get; set; } = new();
    public KlipyConfig Klipy { get; set; } = new();
    public ImportConfig Import { get; set; } = new();
    public FederationConfig Federation { get; set; } = new();
}
