export type VsiGeometryGroupKey =
  | "frontWheel"
  | "rearWheel"
  | "frontWheelArch"
  | "rearWheelArch"
  | "silhouette"
  | "roofline"
  | "glass"
  | "hood"
  | "frontFascia"
  | "headlamps"
  | "beltline"
  | "doorSeams"
  | "doorHandles"
  | "sideMirror"
  | "rocker"
  | "rearQuarter"
  | "rearLamp"
  | "grille"
  | "landmarks"
  | "secondaryStructuralLines"
  | "developmentGuides";

export type VsiGeometryGroup = {
  label: string;
  selector: string;
  tolerancePx: number;
};

export type VsiAuditAnchor = {
  actual: { x: number; y: number };
  expected: { x: number; y: number };
  feature: VsiGeometryGroupKey;
  id: string;
  label: string;
  tolerancePx: number;
};

export const vsiGeometryGroups: Record<VsiGeometryGroupKey, VsiGeometryGroup> = {
  frontWheel: { label: "Front wheel", selector: "#vsi-front-wheel", tolerancePx: 5 },
  rearWheel: { label: "Rear wheel", selector: "#vsi-rear-wheel", tolerancePx: 5 },
  frontWheelArch: { label: "Front wheel arch", selector: "#vsi-front-wheel-arch", tolerancePx: 5 },
  rearWheelArch: { label: "Rear wheel arch", selector: "#vsi-rear-wheel-arch", tolerancePx: 5 },
  silhouette: { label: "Outer silhouette", selector: "#vsi-silhouette", tolerancePx: 5 },
  roofline: { label: "Roofline", selector: "#vsi-roofline", tolerancePx: 5 },
  glass: { label: "Roof and glass", selector: "#vsi-glass", tolerancePx: 5 },
  hood: { label: "Hood", selector: "#vsi-hood", tolerancePx: 6 },
  frontFascia: { label: "Front fascia", selector: "#vsi-front-fascia", tolerancePx: 6 },
  headlamps: { label: "Headlamps", selector: "#vsi-headlamps", tolerancePx: 4 },
  beltline: { label: "Beltline", selector: "#vsi-beltline", tolerancePx: 6 },
  doorSeams: { label: "Door seams", selector: "#vsi-door-seams", tolerancePx: 7 },
  doorHandles: { label: "Door handles", selector: "#vsi-door-handles", tolerancePx: 5 },
  sideMirror: { label: "Side mirror", selector: "#vsi-side-mirror", tolerancePx: 5 },
  rocker: { label: "Rocker and lower body", selector: "#vsi-rocker", tolerancePx: 7 },
  rearQuarter: { label: "Rear quarter", selector: "#vsi-rear-quarter", tolerancePx: 6 },
  rearLamp: { label: "Rear lamp", selector: "#vsi-rear-lamp", tolerancePx: 6 },
  grille: { label: "Grille", selector: "#vsi-grille", tolerancePx: 7 },
  landmarks: { label: "Landmarks", selector: "#vsi-landmarks", tolerancePx: 6 },
  secondaryStructuralLines: {
    label: "Secondary structural lines",
    selector: "#vsi-secondary-structural-lines",
    tolerancePx: 10
  },
  developmentGuides: {
    label: "Development guides",
    selector: "#vsi-development-guides",
    tolerancePx: 0
  }
};

export const vsiAuditAnchors: VsiAuditAnchor[] = [
  {
    id: "front-wheel-centre",
    feature: "frontWheel",
    label: "Front wheel centre",
    expected: { x: 756, y: 686 },
    actual: { x: 756, y: 686 },
    tolerancePx: 3
  },
  {
    id: "rear-wheel-centre",
    feature: "rearWheel",
    label: "Rear wheel centre",
    expected: { x: 1379, y: 632 },
    actual: { x: 1379, y: 632 },
    tolerancePx: 3
  },
  {
    id: "front-tire-ground",
    feature: "frontWheel",
    label: "Front tire ground contact",
    expected: { x: 731, y: 805 },
    actual: { x: 731, y: 805 },
    tolerancePx: 5
  },
  {
    id: "rear-tire-ground",
    feature: "rearWheel",
    label: "Rear tire ground contact",
    expected: { x: 1341, y: 734 },
    actual: { x: 1341, y: 734 },
    tolerancePx: 5
  },
  {
    id: "front-bumper-tip",
    feature: "silhouette",
    label: "Front bumper tip",
    expected: { x: 79, y: 594 },
    actual: { x: 79, y: 594 },
    tolerancePx: 5
  },
  {
    id: "hood-windshield-junction",
    feature: "glass",
    label: "Hood windshield junction",
    expected: { x: 568, y: 402 },
    actual: { x: 568, y: 402 },
    tolerancePx: 5
  },
  {
    id: "roof-high-point",
    feature: "roofline",
    label: "Roof high point",
    expected: { x: 864, y: 224 },
    actual: { x: 864, y: 224 },
    tolerancePx: 5
  },
  {
    id: "front-mirror-point",
    feature: "sideMirror",
    label: "Front mirror point",
    expected: { x: 1197, y: 417 },
    actual: { x: 1197, y: 417 },
    tolerancePx: 4
  },
  {
    id: "front-door-handle-centre",
    feature: "doorHandles",
    label: "Front door handle centre",
    expected: { x: 1150, y: 456 },
    actual: { x: 1150, y: 456 },
    tolerancePx: 4
  },
  {
    id: "rear-door-handle-centre",
    feature: "doorHandles",
    label: "Rear door handle centre",
    expected: { x: 1313, y: 443 },
    actual: { x: 1313, y: 443 },
    tolerancePx: 4
  },
  {
    id: "headlamp-outer",
    feature: "headlamps",
    label: "Headlamp outer endpoint",
    expected: { x: 657, y: 496 },
    actual: { x: 657, y: 496 },
    tolerancePx: 4
  },
  {
    id: "rear-lamp-upper",
    feature: "rearLamp",
    label: "Rear lamp upper endpoint",
    expected: { x: 1472, y: 373 },
    actual: { x: 1472, y: 373 },
    tolerancePx: 4
  },
  {
    id: "rocker-front",
    feature: "rocker",
    label: "Rocker front point",
    expected: { x: 408, y: 708 },
    actual: { x: 408, y: 708 },
    tolerancePx: 6
  },
  {
    id: "rocker-rear",
    feature: "rocker",
    label: "Rocker rear point",
    expected: { x: 1262, y: 688 },
    actual: { x: 1262, y: 688 },
    tolerancePx: 6
  },
  {
    id: "rear-bumper-point",
    feature: "rearQuarter",
    label: "Rear bumper point",
    expected: { x: 1326, y: 742 },
    actual: { x: 1326, y: 742 },
    tolerancePx: 5
  }
];

export const vsiAuditFeatureOrder = Object.keys(vsiGeometryGroups) as VsiGeometryGroupKey[];
