/*
 * Vesktop, a desktop app aiming to give you a snappier Discord Experience
 * Copyright (c) 2023 Vendicated and Vencord contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

import "./themedSplash";
import "./ipcCommands";
import "./appBadge";
import "./fixes";
import "./arrpc";
import "__patches__"; // auto generated by the build script

export * as Components from "./components";

import SettingsUi from "./components/settings/Settings";
import { VesktopLogger } from "./logger";
import { Settings } from "./settings";
export { Settings };

import type SettingsPlugin from "@vencord/types/plugins/_core/settings";

VesktopLogger.log("read if cute :3");
VesktopLogger.log("Vesktop v" + VesktopNative.app.getVersion());

// TODO
const customSettingsSections = (Vencord.Plugins.plugins.Settings as typeof SettingsPlugin).customSections;

customSettingsSections.push(() => ({
    section: "Vesktop",
    label: "Vesktop Settings",
    element: SettingsUi,
    className: "vc-vesktop-settings"
}));

// TODO: remove this legacy workaround once some time has passed
if (!Vencord.Api.Styles.vencordRootNode) {
    const style = document.createElement("style");
    style.id = "vesktop-css-core";

    VesktopNative.app.getRendererCss().then(css => (style.textContent = css));

    document.addEventListener("DOMContentLoaded", () => document.documentElement.append(style), { once: true });
}
