import Foundation

enum Constants: Sendable {
    nonisolated static let version = "0.8.5"
    nonisolated static let maxMessageBytes = 65536
    nonisolated static let maxImageBytes = 5 * 1024 * 1024      // 5 MB
    nonisolated static let maxFileBytes = 50 * 1024 * 1024       // 50 MB
    nonisolated static let imageChunkSize = 32768                 // 32 KB (matches Python IMAGE_CHUNK_SIZE)
    nonisolated static let selfDeviceId = "00000000-0000-0000-0000-000000000000"

    nonisolated static let opkReplenishThreshold = 20
    nonisolated static let opkBatchSize = 50
    nonisolated static let spkRotationDays = 7

    nonisolated static let maxSkip = 256
    nonisolated static let maxSenderKeySkip = 256

    nonisolated static let deviceBundleCacheTTL: TimeInterval = 300  // 5 minutes
    nonisolated static let sendReceiveTimeout: TimeInterval = 30
    nonisolated static let reconnectBaseDelay: TimeInterval = 1
    nonisolated static let reconnectMaxDelay: TimeInterval = 30

    nonisolated static let pbkdf2Iterations: UInt32 = 600_000
    nonisolated static let ecp1Magic = Data([0x45, 0x43, 0x50, 0x31])  // "ECP1"

    // HKDF info/salt strings matching Python
    nonisolated static let x3dhInfo = "EncryptedChat_X3DH"
    nonisolated static let rootKeyInfo = "EncryptedChat_RootKey"
    nonisolated static let selfEncryptionSalt = "self_encryption"
    nonisolated static let selfEncryptionInfo = "EncryptedChat_SelfKey"
    nonisolated static let localStorageSalt = "local_storage"
    nonisolated static let localStorageInfo = "EncryptedChat_LocalStorage"
    nonisolated static let senderKeyChainInfo = "SenderKeyChain"

    // Server connection defaults
    nonisolated static let defaultHost = "chat.ai-tech.news"
    nonisolated static let defaultPort: UInt16 = 9999
}
