def safari(self) -> str:
        """Generate a Safari web browser user agent string."""
        saf: str = (
            f"{self.generator.random.randint(531, 535)}."
            f"{self.generator.random.randint(1, 50)}."
            f"{self.generator.random.randint(1, 7)}"
        )

        ver: str = (
            f"{self.generator.random.randint(4, 5)}.{self.generator.random.randint(0, 1)}"
            if not self.generator.random.getrandbits(1)
            else f"{self.generator.random.randint(4, 5)}.0.{self.generator.random.randint(1, 5)}"
        )

        tmplt_win: str = "(Windows; U; {0}) AppleWebKit/{1} (KHTML, like Gecko) Version/{2} Safari/{3}"
        tmplt_mac: str = "({0} rv:{1}.0; {2}) AppleWebKit/{3} (KHTML, like Gecko) Version/{4} Safari/{5}"
        tmplt_ipod: str = (
            "(iPod; U; CPU iPhone OS {0}_{1} like Mac OS X; {2})"
            " AppleWebKit/{3} (KHTML, like Gecko) Version/{4}.0.5"
            " Mobile/8B{5} Safari/6{6}"
        )
        locale: str = self.generator.locale().replace("_", "-")
        platforms: ElementsType[str] = (
            tmplt_win.format(self.windows_platform_token(), saf, ver, saf),
            tmplt_mac.format(
                self.mac_platform_token(),
                self.generator.random.randint(2, 6),
                locale,
                saf,
                ver,
                saf,
            ),
            tmplt_ipod.format(
                self.generator.random.randint(3, 4),
                self.generator.random.randint(0, 3),
                locale,
                saf,
                self.generator.random.randint(3, 4),
                self.generator.random.randint(111, 119),
                saf,
            ),
        )

        return "Mozilla/5.0 " + self.random_element(platforms)
Generate a Safari web browser user agent string.
faker/providers/user_agent/__init__.py