import Foundation

@objc public protocol BrickModuleRegistableViewControllerType {
    @objc var moduleRegistry: BrickModuleRegistry? { get }
}
/**
 * Minimal protocol that all Brick modules must implement
 * Contains only essential properties for module identification
 */
public protocol BrickModuleBase {
    /// The name of the module (required for registration)
    var moduleName: String { get }
    var controller: BrickModuleRegistableViewControllerType { get set }
    
    init (controller: BrickModuleRegistableViewControllerType)
}

/**
 * Error types for Brick modules
 */
public enum BrickModuleError: Error, LocalizedError {
    case typeMismatch(String)
    case executionError(String)
    case invalidDefinition(String)
    case methodNotFound(String)
    case moduleNotFound(String)
    
    public var errorDescription: String? {
        switch self {
        case .typeMismatch(let message):
            return "Type mismatch: \(message)"
        case .executionError(let message):
            return "Execution error: \(message)"
        case .invalidDefinition(let message):
            return "Invalid definition: \(message)"
        case .methodNotFound(let message):
            return "Method not found: \(message)"
        case .moduleNotFound(let message):
            return "Module not found: \(message)"
        }
    }
    
    public var errorCode: String {
        switch self {
        case .typeMismatch:
            return "TYPE_ERROR"
        case .executionError:
            return "EXECUTION_ERROR"
        case .invalidDefinition:
            return "DEFINITION_ERROR"
        case .methodNotFound:
            return "METHOD_NOT_FOUND"
        case .moduleNotFound:
            return "MODULE_NOT_FOUND"
        }
    }
}


public protocol BrickModuleAddableViewControllerType: UIViewController {
    func addBrickModule(_ module: BrickModuleBase)
}


  
