"""
Constants and metadata for the Text Texture Generator addon.
"""

# Version information
VERSION_TYPE = "full"  # "free" or "full"

bl_info = {
    "name": "Text Texture Generator" + (" Free" if VERSION_TYPE == "free" else " Full"),
    "author": "Marc Mintel <marc@mintel.me>",
    "version": (1, 2, 5),
    "blender": (4, 0, 0),
    "location": "3D View > Sidebar (N) > Tool Tab | Shader Editor > Sidebar > Tool Tab",
    "description": "Generate image textures from text with accurate dimensions and instant live preview" + (" - Free Version (Limited Features)" if VERSION_TYPE == "free" else " - Full Version"),
    "category": "Material",
}

# Feature configuration based on version type
ENABLED_FEATURES = ["basic", "preview"] if VERSION_TYPE == "free" else [
    "basic", "preview", "presets", "normal_maps", "batch_processing",
    "image_overlays", "basic_utilities", "advanced_utilities", "advanced_styling",
    "stroke_effects", "blur_effects", "shadow_glow_effects", "shader_generation",
    "text_fitting"
]

# Version-specific limits (applied at build time through file exclusions)
def get_version_limits():
    """Get version-specific limits."""
    if VERSION_TYPE == "free":
        return {
            "max_concurrent_operations": 4
        }
    else:
        return {
            "max_concurrent_operations": 4
        }

def is_free_version():
    """Check if this is the free version."""
    return VERSION_TYPE == "free"

def is_full_version():
    """Check if this is the full version."""
    return VERSION_TYPE == "full"

# UI Helper Functions for Version Display
def get_version_badge_text():
    """Get version badge text for UI display."""
    return "FREE" if is_free_version() else "PRO"

def get_version_badge_icon():
    """Get appropriate icon for version badge."""
    return 'GIFT' if is_free_version() else 'STAR'

def get_upgrade_hint_text(feature_name):
    """Get contextual upgrade hint text for specific features."""
    if not is_free_version():
        return ""
        
    return f"Upgrade to Pro version to access {feature_name}"

# Feature availability functions
def has_feature(feature_name):
    """Check if a specific feature is available."""
    return feature_name in ENABLED_FEATURES

def has_image_overlays():
    """Check if image overlay features are available"""
    return has_feature("image_overlays")

def has_basic_utilities():
    """Check if basic utility operations are available"""
    return has_feature("basic_utilities")

def has_presets():
    """Check if preset features are available"""
    return has_feature("presets")

def has_normal_maps():
    """Check if normal map generation is available"""
    return has_feature("normal_maps")

def has_batch_processing():
    """Check if batch processing is available"""
    return has_feature("batch_processing")

def has_advanced_utilities():
    """Check if advanced utility operations are available"""
    return has_feature("advanced_utilities")

def has_advanced_styling():
    """Check if advanced styling options are available"""
    return has_feature("advanced_styling")

def has_stroke_effects():
    """Check if stroke effects are available"""
    return has_feature("stroke_effects")

def has_blur_effects():
    """Check if blur effects are available"""
    return has_feature("blur_effects")

def has_shadow_glow_effects():
    """Check if shadow and glow effects are available"""
    return has_feature("shadow_glow_effects")

def has_shader_generation():
    """Check if shader generation is available"""
    return has_feature("shader_generation")

def has_text_fitting():
    """Check if text fitting is available"""
    return has_feature("text_fitting")



def get_max_resolution():
    """Get maximum texture resolution based on version.
    
    Returns:
        None if texture resolution is unrestricted, otherwise an integer limit.
    """
    limits = get_version_limits()
    return limits.get("max_texture_size")

def should_show_feature_lock(feature_name):
    """Check if feature lock indicator should be shown."""
    # Map feature names to their availability functions
    feature_checks = {
        'presets': has_presets,
        'normal_maps': has_normal_maps,
        'batch_processing': has_batch_processing,
        'advanced_utilities': has_advanced_utilities,
        'advanced_styling': has_advanced_styling,
        'image_overlays': has_image_overlays,
        'basic_utilities': has_basic_utilities,
        'stroke_effects': has_stroke_effects,
        'blur_effects': has_blur_effects,
        'shadow_glow_effects': has_shadow_glow_effects,
        'shader_generation': has_shader_generation,
        'text_fitting': has_text_fitting
    }
    
    if is_full_version():
        return False
    
    # For free version, show lock if feature is not available
    if feature_name in feature_checks:
        return not feature_checks[feature_name]()
    
    return True  # Show lock for unknown features

def get_feature_availability_text():
    """Get text describing current feature availability."""
    if is_free_version():
        return "Free version - Basic features available"
    return "Pro version - All features available"

def get_version_info_details():
    """Get detailed version information for display."""
    limits = get_version_limits()
    max_texture_size = limits.get('max_texture_size')
    if not max_texture_size:
        max_texture_size = 'Unlimited'
    info = {
        'version_type': VERSION_TYPE.upper(),
        'max_texture_size': max_texture_size,
        'max_concurrent_operations': limits.get('max_concurrent_operations', 'Unlimited'),
        'features_enabled': len(ENABLED_FEATURES),
        'upgrade_available': is_free_version()
    }
    return info
