import { HourCategorizationFields } from '../types/hourCategorization/hourCategorizationFields';
import { HourCategorizationOperators } from '../types/hourCategorization/hourCategorizationOperators';
import { HourCategorizationValidValues } from '../types/hourCategorization/hourCategorizationValidValues';
import { HourCategorizationValueTypes } from '../types/hourCategorization/hourCategorizationValueTypes';

export type TimeSlot = [string, string];

export class HourCategory {
    constructor(props: {
        id: number;
        name: string;
        description?: string;
        effectiveFrom: string;
        effectiveTo?: string;
        instanceId: number;
        rules: HourCategorizationRule[];
    }) {
        this.id = props.id;
        this.name = props.name;
        this.description = props.description;
        this.effectiveFrom = props.effectiveFrom;
        this.effectiveTo = props.effectiveTo;
        this.instanceId = props.instanceId;
        this.rules = props.rules;
    }

    id: number;
    name: string;
    description?: string;
    effectiveFrom: string;
    effectiveTo?: string;
    instanceId: number;
    rules: HourCategorizationRule[];
}

export interface HourCategoryForCreation {
    name: string;
    description?: string;
    effectiveFrom: string;
    effectiveTo?: string;
    instanceId: number;
    rules: HourCategorizationRuleForCreation[];
}

export interface HourCategoryForUpdate {
    name?: string;
    description?: string;
    effectiveFrom?: string;
    effectiveTo?: string;
    instanceId: number;
    rules?: HourCategorizationRuleForCreation[];
}

export interface RuleCondition {
    field: HourCategorizationFields;
    valueType: HourCategorizationValueTypes;
    operator: HourCategorizationOperators;
    value: HourCategorizationValidValues;
}

export class HourCategorizationRule {
    constructor(props: { id: number; hourCategoryId: number; operator: 'AND' | 'OR'; conditions: RuleCondition[] }) {
        this.id = props.id;
        this.hourCategoryId = props.hourCategoryId;
        this.operator = props.operator;
        this.conditions = props.conditions;
    }

    id: number;
    hourCategoryId: number;
    operator: 'AND' | 'OR';
    conditions: RuleCondition[];
}

export interface HourCategorizationRuleForCreation {
    operator: 'AND' | 'OR';
    conditions: RuleCondition[];
}

export class HourCategoryIdentifier {
    constructor(props: { id: number; instanceId: number; name: string; description?: string }) {
        this.id = props.id;
        this.instanceId = props.instanceId;
        this.name = props.name;
        this.description = props.description;
    }

    id: number;
    instanceId: number;
    name: string;
    description?: string;
}
