export interface HelpArticleCategory {
  id?: number | string;
  name?: string;
  label?: string;
  label_fr?: string;
}

export interface HelpArticle {
  id: number | string;
  title: string;
  content?: string;
  section?: string;
  help_section_id?: string | number;
  category_id?: string | number;
  help_category_id?: string | number;
  category?: HelpArticleCategory;
  is_draft?: boolean;
  status?: string;
  tags?: string[];
  views?: number;
  views_count?: number;
  satisfaction?: number;
  satisfaction_score?: number;
}

export interface HelpArticleStats {
  total_published: number | string;
  total_articles: number | string;
  total_views: number | string;
  satisfaction_rate: number | string;
  active_sections_count: number | string;
  feedback_evolution: Array<{
    month: string;
    satisfaction: number;
    dissatisfaction: number;
  }>;
  audience_distribution: Array<{
    section: string;
    count: number;
  }>;
  satisfaction_by_category: Array<{
    category_id?: string | number;
    name?: string;
    category?: HelpArticleCategory;
    value?: number;
    average_score?: number;
    views?: number;
    total_views?: number;
  }>;
}

export interface HelpCategoryOption {
  id?: string | number;
  value?: string | number;
  label?: string;
  label_fr?: string;
  name?: string;
  title?: string;
}

/** Palette key of a help section / category, driving the tint of the article blocks. */
export type HelpTone = "blue" | "indigo" | "teal" | "amber" | "green" | "purple" | "rose";

/**
 * A ready-made piece of article layout served by the backend.
 *
 * Article bodies are self-contained HTML — the help centre renders `content` with no stylesheet of
 * its own — so the editor inserts these instead of asking writers to build tables and inline styles
 * by hand.
 */
export interface HelpArticleBlock {
  key: string;
  label: string;
  description: string;
  html: string;
}

export interface HelpArticleBlockLibrary {
  tone: HelpTone;
  /** Single elements: intro callout, numbered step, tip, table… */
  blocks: HelpArticleBlock[];
  /** Whole-article skeletons, offered when the editor is empty. */
  templates: HelpArticleBlock[];
}

export interface CreateHelpArticlePayload {
  title: string;
  content: string;
  section?: string;
  help_section_id?: string | number;
  category_id?: string | number;
  help_category_id?: string | number;
  is_draft: boolean;
  tags: string[];
}

export interface UpdateHelpArticlePayload extends CreateHelpArticlePayload {}
