import { z } from 'zod'; export const EventCategory = z.enum([ 'military', 'sanctions', 'infrastructure', 'energy', 'cyber', 'diplomatic', 'humanitarian', ]); export type EventCategory = z.infer; export const EventSeverity = z.enum(['low', 'medium', 'high', 'critical']); export type EventSeverity = z.infer; export const GeopoliticalEventSchema = z.object({ title: z.string(), description: z.string(), category: EventCategory, severity: EventSeverity, timestamp: z.coerce.date(), sourceUrl: z.string().nullable().optional(), }); export type GeopoliticalEvent = z.infer; export const GeopoliticalEventSeedSchema = z.array(GeopoliticalEventSchema); /** Color mapping for event categories (used for chart annotations) */ export const EVENT_CATEGORY_COLORS: Record = { military: '#ef4444', // red-500 sanctions: '#f97316', // orange-500 infrastructure: '#f59e0b', // amber-500 energy: '#eab308', // yellow-500 cyber: '#a855f7', // purple-500 diplomatic: '#3b82f6', // blue-500 humanitarian: '#6b7280', // gray-500 }; /** Severity level numeric values for sorting */ export const SEVERITY_ORDER: Record = { low: 0, medium: 1, high: 2, critical: 3, }; /** String-keyed versions for safe runtime lookup without type assertions */ const CATEGORY_COLOR_MAP: Record = EVENT_CATEGORY_COLORS; const SEVERITY_ORDER_MAP: Record = SEVERITY_ORDER; /** Safe lookup for event category color — returns fallback for unknown categories */ export function getCategoryColor(category: string): string { return CATEGORY_COLOR_MAP[category] ?? '#6b7280'; } /** Safe lookup for severity order — returns 0 for unknown severities */ export function getSeverityOrder(severity: string): number { return SEVERITY_ORDER_MAP[severity] ?? 0; }