"""
Detection utilities for JavaScript sites and protection mechanisms
"""

def detect_js_site(url: str) -> bool:
    """Heuristic to detect if site likely needs JavaScript."""
    js_indicators = [
        'spa', 'react', 'angular', 'vue', 'nextjs', 'nuxt',
        'app', 'dashboard', 'admin', 'portal', 'api',
        'gmail', 'facebook', 'twitter', 'linkedin',
        'youtube', 'instagram', 'tiktok'
    ]
    
    url_lower = url.lower()
    return any(indicator in url_lower for indicator in js_indicators)


def detect_protection_indicators():
    """Returns common protection mechanism indicators."""
    return {
        "CAPTCHA": ["[class*='captcha']", "[id*='captcha']", ".g-recaptcha", ".h-captcha", ".cf-turnstile"],
        "Cloudflare": ["[data-cf-beacon]", ".cf-browser-verification", ".cf-error-details", ".cf-wrapper"],
        "Bot Detection": [".bot-detection", "[data-bot-challenge]", ".anti-bot", ".security-check"],
        "Rate Limiting": [".rate-limit", ".too-many-requests", ".throttle", ".temporarily-blocked"],
        "Two Factor": ["[name*='2fa']", "[name*='totp']", ".two-factor", "[class*='mfa']"]
    }


def detect_login_error_selectors():
    """Returns common login error selectors."""
    return [
        ".error", ".alert-error", ".login-error", ".auth-error", ".field-error",
        "[class*='error']", "[class*='invalid']", "[class*='wrong']", "[class*='fail']",
        ".message-error", ".validation-error", ".form-error", ".alert-danger",
        ".alert-warning", ".notification-error", "[role='alert']"
    ]
