import type {
    ConnectionType,
    Support,
    Beam,
    Angle,
    Bolts,
    GeometryCheck,
} from '../types/connection';

export function performGeometryChecks(
    _connectionType: ConnectionType,
    _support: Support,
    beam: Beam,
    angle: Angle,
    _bolts: Bolts
): GeometryCheck[] {
    const checks: GeometryCheck[] = [];

    // Check beam gap from support
    const minGap = 0.5; // inches
    checks.push({
        description: 'Beam Gap from Support',
        status: beam.gapFromSupport >= minGap ? 'OK' : 'NG',
    });

    // Check top flange cope
    checks.push({
        description: 'Top Flange Cope',
        lengthC: beam.topFlangeCopeLengthC ? 'Uncoped' : 'Uncoped',
        heightDc: beam.topFlangeCopeHeightDc ? 'Uncoped' : 'Uncoped',
        status: 'OK',
    });

    // Check bottom flange cope
    checks.push({
        description: 'Bottom Flange Cope ..',
        lengthC: beam.bottomFlangeCopeLengthC ? 'Uncoped' : 'Uncoped',
        heightDc: beam.bottomFlangeCopeHeightDc ? 'Uncoped' : 'Uncoped',
        status: 'OK',
    });

    // Check angle leg on support
    const minLeg = 3.0; // inches
    checks.push({
        description: 'Angle Leg on Support ...',
        status: angle.legOnSupport >= minLeg ? 'OK' : 'NG',
    });

    // Check angle leg on beam
    checks.push({
        description: 'Angle Leg on Beam ......',
        status: angle.legOnBeam >= minLeg ? 'OK' : 'OK',
    });

    // Check angle thickness
    const minThickness = 0.25; // inches
    const maxLength = Math.max(angle.legOnSupport, angle.legOnBeam);
    checks.push({
        description: `Angle Thickness = ${angle.thickness} in  ,  L = ${maxLength.toFixed(2)} in`,
        status: angle.thickness >= minThickness ? 'OK' : 'NG',
    });

    // Check eccentricity
    checks.push({
        description: 'Eccentricity to Beam CL ...........',
        status: 'OK', // Always OK for now
    });

    // Check edge distance
    const minEdge = 1.0; // inches
    checks.push({
        description: 'Edge Distance ...........',
        status: (angle.edgeDistanceHorizontal >= minEdge && angle.edgeDistanceVertical >= minEdge) ? 'OK' : 'NG',
    });

    return checks;
}
