import type { LotStatus } from '@/types/portal';

export type MasterplanPoint = [number, number];

export interface MasterplanLot {
    databaseId?: number;
    id: string;
    lot: string;
    lotNumber: number | string | null;
    block: string | null;
    blockLabel: string | null;
    area: number | null;
    areaRaw: string | null;
    dimensions: string[];
    status: LotStatus;
    statusEvidence: string | null;
    statusConfidence: number | null;
    polygon: MasterplanPoint[];
    labelPoint: MasterplanPoint | null;
    confidence: number | null;
    pass: string | null;
    needsReview: boolean;
    note: string;
}

export interface MasterplanFrame {
    width: number;
    height: number;
    scale: number;
    units_per_meter: number | null;
    pixels_per_meter: number | null;
    meters_per_pixel: number | null;
}

export interface MasterplanBlockReport {
    expected: number;
    rendered: number;
    missing: string[];
}

export interface MasterplanReport {
    labels_found: number;
    rendered: number;
    with_number: number;
    with_block: number;
    with_area: number;
    with_dimensions: number;
    missing_count: number;
    missing: string[];
    review: string[];
    blocks: Record<string, MasterplanBlockReport>;
    statuses: Record<string, number>;
    coverage: number;
    complete: boolean;
}

export interface MasterplanLayer {
    name: string;
    segments: number;
    role: string;
    colors: string[];
}

export interface MasterplanSource {
    page: number;
    page_count: number;
    type: string;
    extraction: Record<string, string>;
}

export interface Masterplan {
    frame: MasterplanFrame;
    report: MasterplanReport;
    legend: Record<string, string>;
    layers: MasterplanLayer[];
    source: MasterplanSource | null;
    basePlanUrl: string | null;
    lots: MasterplanLot[];
}

export interface PlanInspection {
    page: number;
    page_count: number;
    type: string;
    shx_annotations: number;
    lot_labels: number;
    block_labels: number;
    area_labels: number;
    dimension_labels: number;
    blocks: string[];
    segments: number;
    layers: MasterplanLayer[];
    divider_colors: string[];
    statuses: string[];
    lot_pattern: string | null;
}
