import { Property } from '../property.js';

export class Font extends Property {
    public static Italic =      new Font(style => style.fontStyle = 'italic', 'italic');
    public static Underline =   new Font(style => style.textDecoration = ' underline', 'underline');

    #impelementation: (style: CSSStyleDeclaration) => void;
    #value: string;

    private constructor(impelementation: (style: CSSStyleDeclaration) => void, value: string) {
        super();

        this.#impelementation = impelementation;
        this.#value = value;
    }

    public override equals(other: Property): boolean {
        if (!(other instanceof Font)) return false;

        return other.#impelementation === this.#impelementation;
    }

    public override apply(element: HTMLElement): void {
        this.#impelementation(element.style);
    }

    public override inspect(indent: number): string {
        return `Font { ${this.#value} }`;
    }
}
