import { GefestStyle } from "./modules/Gefest/style";
import { GefestElement } from "./modules/Gefest/element";
import { Navbar } from "./pages/navbar";
import { isNewsUI, NewsUserInterface } from "./pages/feed/news";

export abstract class SkeletonStyle extends GefestStyle {
    protected abstract navbar(element: GefestElement): void;
    protected abstract newsui(element: GefestElement): void;
    protected abstract styleHandle(element: GefestElement): void;
    applyStyle(html: string, element?: GefestElement): string {
        if (!element)
            element = GefestElement.fromHTML(html);
        //element.addClass("light-mode");
        this.styleHandle(element);
        this.navbar(element);
        this.newsui(element);
        return element.build(true);
    }
}

export class DarkStyle extends SkeletonStyle {
    newsui(element: GefestElement): void {
        if (isNewsUI(element)) {
            element.removeClass("bg-dark");
            element.addClass("dark-news-ui");
        }

        if (element instanceof NewsUserInterface) {
            element.removeClass("bg-dark");
        }
    }

    navbar(element: GefestElement): void {
        if (element instanceof Navbar) {
            element.addClass("dark-navbar");
        }
    }

    protected styleHandle(element: GefestElement): void {
        element.addClass("bg-dark");
        element.addClass("text-light");
    }
}

export class LightStyle extends SkeletonStyle {
    newsui(element: GefestElement): void {
        if (isNewsUI(element)) {
            element.removeClass("bg-light");
            element.addClass("light-news-ui");
        }

        if (element instanceof NewsUserInterface) {
            element.removeClass("bg-light");
        }
    }

    navbar(element: GefestElement): void {
        //element.addClass("light-navbar");
    }

    protected styleHandle(element: GefestElement): void {
        element.addClass("bg-light");
        element.addClass("text-dark");
    }
}

export type SupportedStyles = SkeletonStyle;

export const defaultStyle = new LightStyle();