/**
 * An application (aanvraag) as the frontend sees it — the parsed, domain-side view
 * of the backend-owned aggregate (see backend ApplicationStore + PRD 0001). Pure
 * types, no Angular. Lives in `registratie` because the dashboard (here) is the
 * consumer and the downstream wizards (`herregistratie → registratie`) produce them.
 *
 * The status is a discriminated union so illegal states are unrepresentable — same
 * reflex as RemoteData. The server computes which tag applies (auto-approval on
 * read); the FE renders it, it does not recompute the lifecycle.
 */
export type AanvraagType = 'registratie' | 'herregistratie' | 'intake';

export type AanvraagStatus =
  | { tag: 'Concept'; stepIndex: number; stepCount: number }
  | { tag: 'InBehandeling'; referentie: string; manual: boolean } // manual=true → "wordt handmatig beoordeeld"
  | { tag: 'Goedgekeurd'; referentie: string }
  | { tag: 'Afgewezen'; referentie: string; reden: string };

export interface Aanvraag {
  id: string;
  type: AanvraagType;
  status: AanvraagStatus;
  documentIds: string[];
  createdAt: string;
  updatedAt: string;
  submittedAt?: string;
}

/** Detail adds the opaque wizard snapshot used to resume a Concept. */
export interface AanvraagDetail extends Aanvraag {
  draft: unknown;
}
