import type { ImageMetadata } from "astro";
import type { GiteaRepoInfo } from "./utils/gitea";
import type { IconName } from "./config/icons";

export interface Talk {
  id: string;
  name: string;
  description: string;
  link: string;
  date?: string;
}

export interface Project {
  id: string;
  name: string;
  description: string;
  webLink?: string;
  status?: string;
  iosLink?: string;
  androidLink?: string;
  gitLink?: string;
  giteaInfo?: GiteaRepoInfo;
}

export interface SocialLink {
  id: string;
  name: string;
  url: string;
  icon: IconName;
  ariaLabel: string;
}

export interface TechLink {
  id: string;
  name: string;
  url: string;
  icon: IconName;
  ariaLabel: string;
}

export interface NavigationItem {
  id: string;
  name: string;
  path: string;
  tooltip: string;
  icon: IconName;
  enabled?: boolean;
  isActive?: (path: string) => boolean;
}

export type ResumeSectionKey =
  | "summary"
  | "experience"
  | "education"
  | "skills"
  | "volunteer"
  | "profiles"
  | "awards";

export interface ResumeConfig {
  tomlFile: string;
  layout?: {
    leftColumn?: ResumeSectionKey[];
    rightColumn?: ResumeSectionKey[];
  };
  sections: {
    enabled: ResumeSectionKey[];
    summary?: {
      title?: string;
    };
    experience?: {
      title?: string;
    };
    education?: {
      title?: string;
    };
    skills?: {
      title?: string;
    };
    volunteer?: {
      title?: string;
    };
    profiles?: {
      title?: string;
    };
    awards?: {
      title?: string;
    };
  };
}

export interface ResumeData {
  basics: {
    name: string;
    email: string;
    phone?: string;
    website?: string;
    profiles: {
      network: string;
      username: string;
      url: string;
    }[];
  };
  layout?: {
    left_column?: string[];
    right_column?: string[];
  };
  summary: {
    content: string;
  };
  experience: {
    company: string;
    position: string;
    location: string;
    date: string;
    description: string[];
    url?: string;
  }[];
  education: {
    institution: string;
    degree: string;
    field: string;
    date: string;
    details?: string[];
  }[];
  skills: {
    name: string;
    level: number;
  }[];
  volunteer: {
    organization: string;
    position: string;
    date: string;
  }[];
  awards: {
    title: string;
    organization: string;
    date: string;
    description?: string;
  }[];
}

export interface PersonalInfo {
  name: string;
  profileImage: {
    src: ImageMetadata;
    alt: string;
    width?: number;
    height?: number;
  };
  tagline: string;
  description?: string;
}

export interface HomepageSections {
  socialLinks: {
    title: string;
    description?: string;
  };
  techStack: {
    title: string;
    description?: string;
  };
}

export interface OpenGraphImage {
  url: string;
  width: number;
  height: number;
  type: string;
  alt: string;
}

export interface OpenGraphConfig {
  image: OpenGraphImage;
  type?: "website" | "article";
  locale?: string;
  siteName?: string;
}

export interface PageOpenGraph {
  title?: string;
  description?: string;
  image?: OpenGraphImage;
  type?: "website" | "article";
}

export interface SiteConfig {
  personal: PersonalInfo;
  homepage: HomepageSections;
  resume: ResumeConfig;
  meta: {
    title: string;
    description: string;
    url: string;
    author: string;
  };
  openGraph: OpenGraphConfig;
  pageOpenGraph: {
    home: PageOpenGraph;
    posts: PageOpenGraph;
    projects: PageOpenGraph;
    talks: PageOpenGraph;
    resume: PageOpenGraph;
  };
  giteaDomains?: string[];
}

export interface Config {
  personalInfo: PersonalInfo;
  homepageSections: HomepageSections;
  resumeConfig: ResumeConfig;
  siteConfig: SiteConfig;
  talks: readonly Talk[];
  projects: readonly Project[];
  sections: {
    readonly resume: {
      readonly name: string;
      readonly path: string;
      readonly description: string;
    };
    readonly posts: {
      readonly name: string;
      readonly path: string;
      readonly description: string;
    };
    readonly talks: {
      readonly name: string;
      readonly path: string;
      readonly description: string;
    };
    readonly projects: {
      readonly name: string;
      readonly path: string;
      readonly description: string;
    };
  };
  socialLinks: readonly SocialLink[];
  techLinks: readonly TechLink[];
  navigationItems: readonly NavigationItem[];
}
