import base64
import json
from pathlib import Path

raw_contact: list[dict[str, str]] = [
    {
        "platform": "Github",
        "href": "https://github.com/passthem-desu",
        "name": "passthem-desu",
    },
    {
        "platform": "Wakatime",
        "href": "https://wakatime.com/@passthem",
        "name": "@passthem",
    },
    {
        "platform": "Youtube",
        "href": "https://www.youtube.com/@Passthem183",
        "name": "@Passthem183",
    },
    {
        "platform": "OtoSite",
        "href": "https://otomad.site/@passthem",
        "name": "@passthem",
    },
    {
        "platform": "Email",
        "href": "mailto:passthem183@gmail.com",
        "name": "passthem183@gmail.com",
    },
    {
        "platform": "Bilibili",
        "href": "https://space.bilibili.com/92852604",
        "name": "passthem",
    },
]


def hack(raw: str) -> str:
    return base64.b64encode(raw[::-1].encode()).decode()


hacked_contact = [{k: hack(v) for k, v in c.items()} for c in raw_contact]
(Path(__file__).parent / "../src/lib/data").mkdir(exist_ok=True)
_ = (Path(__file__).parent / "../src/lib/data/contact.json").write_text(
    json.dumps(hacked_contact)
)
