// frontend/lib/calendar/types.ts — phase-8 일정/회의 타입 (backend schemas.py 와 1:1)
import type { Tone, Task } from "@/lib/types"; // phase-3 재사용

export interface Calendar {
  id: string;
  name: string;
  tone: Tone;
  on: boolean;
  count: number;
}

export interface EventAction {
  text: string;
  when: string;
}

export interface Attendee {
  email: string;
  name: string;
  status: string; // accepted|declined|tentative|needsAction|none
}

export interface CalEvent {
  id: string;
  day: number;
  date: string; // 실제 날짜 ISO "YYYY-MM-DD"
  start: string;
  end: string;
  title: string;
  cal: string;
  loc: string;
  note: string;
  soon: boolean;
  people: string[];
  rrule: string; // 반복 규칙(빈값=단일)
  reminders: number[]; // 시작 N분 전 알림
  attendees: Attendee[];
  response_status: string; // 내 RSVP
  actions: EventAction[];
  has_meeting: boolean;
  meet_label: string;
}

export interface EventWrite {
  title: string;
  date: string; // ISO "YYYY-MM-DD"
  start: string; // "HH:MM" (빈값 = 종일)
  end: string;
  loc: string;
  note: string;
  people: string[];
  cal: string; // 대상 캘린더 id(빈값=기본)
  rrule: string; // 반복 규칙
  reminders: number[]; // 시작 N분 전 알림
}

export interface FocusBlock {
  id: string;
  day: number;
  date: string;
  start: string;
  end: string;
  title: string;
  type: "light" | "deep";
  tag: string;
  task_id: string | null;
  auto: boolean;
}

export interface MeetingAction {
  id: string;
  idx: number;
  text: string;
  who: string;
  when: string;
  added: boolean;
  materialized_task_id: string | null;
}

export interface Meeting {
  id: string;
  event_id: string;
  phase: "done" | "live" | "upcoming";
  one_on_one: boolean;
  meta: string;
  starts_in: string;
  summary: string[];
  decisions: string[];
  agenda: string[];
  last_meeting: { when?: string; note?: string };
  last_actions: { text: string; who: string; done: boolean }[];
  insights: string[];
  docs: string[];
  person: { name?: string; initial?: string; tone?: Tone };
  promises: { text: string; done: boolean }[];
  signals: { k: string; v: string; tone: Tone }[];
  talking_points: string[];
  actions: MeetingAction[];
}

export interface WeekBundle {
  today: number;
  today_date: string; // 실제 오늘 ISO
  mode: "real" | "demo";
  week: number[];
  weekdays: string[];
  calendars: Calendar[];
  events: CalEvent[];
  focus_blocks: FocusBlock[];
}

export interface DayBundle {
  day: number;
  events: CalEvent[];
  focus_blocks: FocusBlock[];
}

export interface MaterializeResult {
  action: MeetingAction;
  task: Task | null;
  all_added: boolean;
}
