import {
    IWatermark,
    WATERMARK_HORIZONTAL_ALIGNMENTS,
    WATERMARK_VERTICAL_ALIGNMENTS,
    WatermarkAlignment,
    WatermarkHorizontalAlignment,
    WatermarkOrientation,
    WatermarkVerticalAlignment,
} from './watermark';
import { Entity } from '@iqser/common-ui';

export class Watermark extends Entity<IWatermark, number> {
    readonly id: number;
    readonly dossierTemplateId: string;
    readonly enabled: boolean;
    readonly fontSize: number;
    readonly fontType: string;
    readonly hexColor: string;
    readonly opacity: number;
    readonly orientation: WatermarkOrientation;
    readonly horizontalTextAlignment: WatermarkHorizontalAlignment;
    readonly verticalTextAlignment: WatermarkVerticalAlignment;
    readonly text: string;
    readonly name: string;
    readonly createdBy?: string;
    readonly dateAdded?: string;
    readonly dateModified?: string;

    readonly routerLink = undefined;

    constructor(watermark: IWatermark) {
        super(watermark);
        this.id = watermark.id;
        this.dossierTemplateId = watermark.dossierTemplateId;
        this.enabled = watermark.enabled;
        this.fontSize = watermark.fontSize;
        this.fontType = watermark.fontType === 'arial' ? 'helvetica' : watermark.fontType;
        this.hexColor = watermark.hexColor;
        this.opacity = watermark.opacity;
        this.orientation = watermark.orientation;
        this.horizontalTextAlignment = watermark.horizontalTextAlignment ?? WATERMARK_HORIZONTAL_ALIGNMENTS.CENTER;
        this.verticalTextAlignment = watermark.verticalTextAlignment ?? WATERMARK_VERTICAL_ALIGNMENTS.CENTER;
        this.text = watermark.text;
        this.name = watermark.name;
        this.createdBy = watermark.createdBy;
        this.dateAdded = watermark.dateAdded;
        this.dateModified = watermark.dateModified;
    }

    get searchKey(): string {
        return this.name;
    }
}
