/**
 * Shared types for the report-PDF pipeline.
 *
 * The render entry point (`render-report.ts`) takes a `ReportConfig`
 * discriminated-union plus the resolved data, then dispatches to the
 * matching React-PDF document component. Each kind keeps its own
 * config shape so type-checking surfaces "you forgot to set
 * widgetIds for the dashboard report" inline.
 */

/** Per-port branding pulled from `port_branding`. Single primary
 *  color drives the headings / footer accent; logo is rendered into
 *  the page header. */
export interface ReportBranding {
  /** Public URL to the port's logo (square PNG). Null falls back to
   *  the bundled Port Nimara circular logo. */
  logoUrl: string | null;
  /** Hex string, e.g. "#0F4C81". Drives heading + footer accent. */
  primaryColor: string;
  /** Used in the header and footer attribution. */
  portName: string;
}

export interface DashboardReportConfig {
  kind: 'dashboard';
  /** Widget ids to include - keyed against `widget-registry.ts`. */
  widgetIds: string[];
  /** Date range applied to dashboard data fetches. */
  dateFrom?: string;
  dateTo?: string;
}

export interface ClientListReportConfig {
  kind: 'clients';
  /** Optional column override; defaults to a canonical set. */
  columns?: string[];
  /** Optional filter snapshot - same shape as `/api/v1/clients`. */
  filters?: Record<string, unknown>;
}

export interface BerthListReportConfig {
  kind: 'berths';
  columns?: string[];
  filters?: Record<string, unknown>;
}

export interface InterestListReportConfig {
  kind: 'interests';
  columns?: string[];
  filters?: Record<string, unknown>;
}

export type ReportConfig =
  | DashboardReportConfig
  | ClientListReportConfig
  | BerthListReportConfig
  | InterestListReportConfig;

export interface ReportRequest {
  /** Free-text title shown on the cover / page header. */
  title: string;
  /** Optional subtitle (e.g. date range, "Quarterly review"). */
  subtitle?: string;
  config: ReportConfig;
}
