/**
 * Shared types for hour-categorization tracing / explain.
 *
 * The engine moved to an AST-primary model (see `ruleAst.ts`); the old flat `TraceEvent` stream and
 * its emitters were removed. What remains here are the small shared pieces still used by the AST /
 * explain path: the evaluation `scope`, the per-category `input` snapshot, and the trace log message id.
 */

export interface TraceScope {
    instanceId: number;
    // userId and dateString are absent on RUN-level scopes (the run covers multiple users/dates).
    // Everything below the run (CATEGORY/RULE/...) carries both.
    userId?: number;
    dateString?: string;
    hourCategoryId?: number;
    ruleId?: number;
}

export interface CategoryInput {
    dateString: string;
    isWorkday: boolean;
    weekday: string;
    scheduledHours: number;
    scheduleSource: string;
    nightShift: boolean;
    holidays: { id: number; name: string }[];
    timeSlots: { startTime: string; endTime: string }[];
    entries: { entryId: number; type: string; time: string }[];
    workedIntervals: [string, string][];
    timeOffHours: number | null;
}

/**
 * Log message identifier used for all hour-categorization trace lines.
 * Consumers can filter logs by this constant.
 */
export const HOUR_CATEGORIZATION_TRACE_MESSAGE = 'hour-categorization-trace';
