import random


def random_user_agent() -> str:
    """Create a randomly generated sorta valid User Agent string."""
    uas = {
        "Edge": (
            "AppleWebKit/537.36 (KHTML, like Gecko) "
            "Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43"
        ),
        "Chrome": (
            "AppleWebKit/537.36 (KHTML, like Gecko) "
            "Chrome/97.0.4692.99 Safari/537.36"
        ),
        "Firefox": "Gecko/20100101 Firefox/96.0",
        "iphone": (
            "AppleWebKit/605.1.15 (KHTML, like Gecko) "
            "Version/15.2 Mobile/15E148 Safari/604.1"
        ),
        "Safari": (
            "AppleWebKit/605.1.15 (KHTML, like Gecko) " "Version/11.1.2 Safari/605.1.15"
        ),
    }
    os = {
        "windows": "Windows NT 10.0; Win64; x64",
        "iphone": "iPhone; CPU iPhone OS 15_2_1 like Mac OS X",
        "mac": "Macintosh; Intel Mac OS X 10_11_6",
    }
    template = "Mozilla/5.0 ({os}) {ua}"

    return template.format(
        os=random.choice(list(os.values())), ua=random.choice(list(uas.values()))
    )