import { ListTodo, FileText, CalendarDays, Layers, type LucideIcon } from 'lucide-react';
import { User, Brain, Shield, CreditCard, Palette, Bot } from 'lucide-react';

export type SectionId = 'profile' | 'account' | 'billing' | 'appearance' | 'agents' | 'memory';

export const SECTIONS: { id: SectionId; labelKey: string; icon: LucideIcon }[] = [
  { id: 'profile',        labelKey: 'settings.profile',           icon: User       },
  { id: 'memory',         labelKey: 'settings.memory.title',      icon: Brain      },
  { id: 'account',        labelKey: 'settings.account',           icon: Shield     },
  { id: 'billing',        labelKey: 'settings.billing',           icon: CreditCard },
  { id: 'appearance',     labelKey: 'settings.appearance',        icon: Palette    },
  { id: 'agents',         labelKey: 'settings.agents',            icon: Bot        },
];

export const SCHEDULE_OPTIONS = [
  { value: '*/15 * * * *', label: 'Every 15 minutes' },
  { value: '0 * * * *', label: 'Every hour' },
  { value: '0 */6 * * *', label: 'Every 6 hours' },
  { value: '0 0 * * *', label: 'Daily at midnight' },
  { value: '@manual', label: 'Manual only' },
];

export const DATA_TYPES = ['tasks', 'notes', 'timelineEvents', 'projects'] as const;

export const DATA_TYPE_CONFIG = [
  { value: 'tasks',          label: 'Tasks',    Icon: ListTodo     },
  { value: 'notes',          label: 'Notes',    Icon: FileText     },
  { value: 'timelineEvents', label: 'Timeline', Icon: CalendarDays },
  { value: 'projects',       label: 'Projects', Icon: Layers       },
] as const;

/** Mirrors LocalAgentLocalConfig from electron-store (tRPC infers it). */
export interface LocalAgentConfig {
  id: string;
  name: string;
  directory: string;
  dataTypes: string[];
  /** Structured extraction config produced by the Journey setup flow. */
  agentConfig: Record<string, unknown> | null;
  scheduleCron: string;
  enabled: boolean;
  lastRunAt: number | null;
}

export function formatTs(ts: number | null | undefined) {
  if (!ts) return '—';
  const ms = ts < 1e12 ? ts * 1000 : ts;
  return new Date(ms).toLocaleString(undefined, {
    month: 'short', day: 'numeric',
    hour: '2-digit', minute: '2-digit',
  });
}
