export interface LocalizedHtmlContent {
  [locale: string]: string;
}

export interface LocalizedTextContent {
  [locale: string]: string;
}

export interface StaticPageSeoConfig {
  title?: string | LocalizedTextContent;
  description?: string | LocalizedTextContent;
  keywords?: string;
  canonical?: string;
  ogTitle?: string | LocalizedTextContent;
  ogDescription?: string | LocalizedTextContent;
  ogImage?: string;
  robots?: string;
}

export interface StaticPageTranslationConfig {
  title?: string;
  html?: string;
  seo?: {
    title?: string;
    description?: string;
    keywords?: string;
    canonical?: string;
    ogTitle?: string;
    ogDescription?: string;
    ogImage?: string;
    robots?: string;
  };
}

export interface StaticPageConfig {
  id: string;
  slug: string;
  title: string | LocalizedTextContent;
  showInFooter?: boolean;
  showInHeader?: boolean;
  showInSitemap?: boolean;
  icon?: string;
  order?: number;
  visibility?: {
    desktop?: boolean;
    tablet?: boolean;
    mobile?: boolean;
  };
  requiresAuthentication?: boolean;
  footerGroup?: string;
  translations?: Record<string, StaticPageTranslationConfig>;
  html?: string | LocalizedHtmlContent;
  seo?: StaticPageSeoConfig;
  visible?: boolean;
  route?: string;
  content?: LocalizedHtmlContent;
  /** Master on/off switch. Kept in sync with `visible` on serialize; a disabled page never resolves on the storefront regardless of `status`. */
  enabled?: boolean;
  /** Per-page publish lifecycle, independent of the whole-bootstrap draft/publish cycle. A `draft` page never resolves on the storefront even when the surrounding bootstrap is published. */
  status?: 'draft' | 'published';
  customTemplate?: string;
  heroImage?: string;
  heroImageAlt?: string;
  heroImageCaption?: string;
  thumbnail?: string;
  gallery?: string[];
  /** ISO timestamp set whenever the page is saved; drives the CMS content dashboard's last-edited/health metrics. */
  updatedAt?: string;
}

export interface LegacyStaticPageConfig {
  key: string;
  route: string | { path: string; exact?: boolean };
  title?: string | LocalizedTextContent;
  content?: string | LocalizedHtmlContent | { value?: string; contentType?: string; source?: string };
  visible?: boolean;
}

export type StaticPagesConfig = Record<string, StaticPageConfig> | LegacyStaticPageConfig[];

export interface ResolvedStaticPage {
  key: string;
  id: string;
  slug: string;
  route: string;
  title: string;
  html: string;
  icon?: string;
  requiresAuthentication?: boolean;
  seo?: {
    title?: string;
    description?: string;
    keywords?: string;
    canonical?: string;
    ogTitle?: string;
    ogDescription?: string;
    ogImage?: string;
    robots?: string;
  };
  customTemplate?: string;
  heroImage?: string;
  thumbnail?: string;
  gallery?: string[];
}
