export type Level = "Low" | "Medium" | "High";

export type Detection = {
  imageIndex?: number;
  kind?: "mold" | "moisture" | "leak";
  moldDetected?: "Yes" | "No" | "Possible";
  severity?: Level;
  confidence?: number;
  surface?: string;
  areaEstimate?: string;
  box?: { x: number; y: number; w: number; h: number };
};

export type LeakSource = { indicator?: string; confidence?: number };

export type Assessment = {
  verdict: string;
  confidence: number;
  severity: string;
  factors: string[];
  recommendations: string[];
  summary: string;
  environmental?: Partial<
    Record<"ventilation" | "humidity" | "condensation" | "leakage" | "dampness" | "airCirculation", Level>
  >;
  leakage?: { verdict: string; signs: string[] };
  thermal?: { coldSpots?: string; notes?: string; moistureIntrusion?: string; findings?: string };
  detections?: Detection[];
  leakSources?: Partial<Record<"ceiling" | "wall" | "roof" | "pipe" | "window" | "floor", LeakSource>>;
  causes?: { cause: string; likelihood?: Level; reason?: string }[];
  risks?: Partial<Record<"health" | "structural" | "moisture" | "moldGrowth" | "urgentInspection", Level>>;
  video?: { areasDetected?: string[]; progression?: string; moisture?: string; combined?: string };
  conclusion?: {
    visibleMold?: string;
    location?: string;
    likelyCauses?: string;
    severity?: Level;
    professionalInspection?: string;
    treatment?: string;
    priority?: Level;
    statement?: string;
  };
};

export type ReportMedia = { dataUrl: string; caption: string };

export type ReportInput = {
  reportNo: string;
  createdAt: Date;
  customerName: string;
  propertyAddress: string;
  analysisType: "Photo" | "Video";
  images: ReportMedia[];
  annotated: ReportMedia[];
  thermalImage?: string | null;
  thermalNormal?: string | null;
  video?: { duration?: number | null; framesAnalyzed?: number | null };
  before?: ReportMedia[];
  after?: ReportMedia[];
  improvement?: string;
  remainingRisks?: string;
  measurements?: {
    temperatureLevel?: string;
    temperatureValue?: string | number | null;
    temperatureScore?: number | null;
    humidityLevel?: string;
    humidityValue?: string | number | null;
    humidityScore?: number | null;
    moisture?: string;
    moistureScore?: number | null;
    detector?: string;
    thermalNotes?: string;
    inspectorComments?: string;
    overallRisk?: string;
    overallRiskScore?: number | null;
    overallRiskNote?: string;
  };
  assessment: Assessment;
  verifyUrl: string;
  logoDataUrl?: string | null;
};