export class loading_screen {
    static #instance;
    
    #screen;

    constructor(classname = "loading-screen") {
        if (!loading_screen.#instance) {
            loading_screen.#instance = this;
            this.#init(classname);
        }

        return loading_screen.#instance;
    }

    get time() {
        return 400;
    }

    #init(classname) {
        this.#screen = document.querySelector(`.${classname}`);
        this.#screen.style.transitionDuration = `${this.time / 1000}s`;
        this.show();
    }

    get visible() {
        return !this.#screen.classList.contains("hidden");
    }

    show() {
        if (!this.visible) {
            this.#screen.classList.remove("hidden");
        }
    }

    hide() {
        if (this.visible) {
            this.#screen.classList.add("hidden");
        }
    }
}