// buttons

const buttons = ["item", "link", "swap"];

for (let button of buttons) {
    document.getElementById(button).addEventListener("click", () => {
        document.body.classList.toggle(button);
    });
}

// theme

let theme;

function theme_get() {
    theme = localStorage.getItem("theme");
    if (! theme) {
        if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
            theme = "dark";
        } else {
            theme = "light";
        }
    }
    theme_set();
}

function theme_set() {
    document.documentElement.setAttribute("data-theme", theme);
    localStorage.setItem("theme", theme);
}

function theme_swap() {
    theme = theme === "light" ? "dark" : "light";
    theme_set();
}

document.getElementById("theme").addEventListener("click", () => {
    theme_swap();
});

theme_get();

//

const a = (t) => atob(`${t}=`);
const ab = (t) => atob(`${t}==`);
const qa = document.getElementById("qa");

qa.style.cursor = ab("cG9pbnRlcg");
const qa0 = ab("Lg");

const qa1 = [
    a("Y3Y"),
].join(qa0);
const qa2 = document.createElement(ab("c3Bhbg"));
qa2.className = a("ZmEgZmEtYXQ");
const qa3 = [
    ab("bWFyYw"),
    ab("YmVuaW5jYQ"),
    ab("bGluaw"),
].join(qa0);
const qa4 = ab("IA")

for (let kg of [qa1, qa4, qa2, qa4, qa3]) {
    qa.append(kg);
}
qa.addEventListener("click", () => {
    window.location.href = [
        atob("bWFpbHRv"),
        [qa1, qa3].join(ab("QA")),
    ].join(ab("Og"));
});
