// Inspection Replay data — derived from the REAL test run 20260527_215327.
// Each detection points at processed frames (iron current / fabricated past /
// difference overlay) generated from the actual FLIR Y8 capture for that cell.
// Temps are the real per-cell min/max from the .temp sidecar files.

const PRIORITY = {
  critical: { label: 'CRITICAL', color: '#e54545', glow: 'rgba(229,69,69,0.4)', rank: 0 },
  high:     { label: 'HIGH',     color: '#ff8a3d', glow: 'rgba(255,138,61,0.4)', rank: 1 },
  medium:   { label: 'MEDIUM',   color: '#e5b94a', glow: 'rgba(229,185,74,0.3)', rank: 2 },
  low:      { label: 'LOW',      color: '#7d96b8', glow: 'rgba(125,150,184,0.3)', rank: 3 },
};

const STATUS = {
  new:            { label: 'NEW',             color: '#e54545' },
  acknowledged:   { label: 'ACKNOWLEDGED',    color: '#3b8fe0' },
  resolved:       { label: 'RESOLVED',        color: '#5bba6f' },
  false_positive: { label: 'FALSE POSITIVE',  color: '#7a7a7a' },
};

const MISSION = 'OMV-A · Gas Distribution Hub 4';
const RUN_DATE = '2026-05-27';

// Plant-frame normalization from the gantry cell coordinates (cm).
// Columns scanned at X 150 / 250 cm; rows Y 33 → 567 cm.
function norm(x, y) {
  return { x: +((x - 100) / 200).toFixed(3), y: +(y / 600).toFixed(3) };
}

// cell, pri, status, area, pass, time, conf, tMax, tMin, notes
const RAW = [
  ['150_300', 'critical', 'new',            'East riser · Sector 4',     '07', '21:54', 0.96, 44.7, 19.0,
    'Persistent hotspot across three consecutive cells. Δ exceeds the +24 °C critical threshold — joint failure suspected on the riser weld.'],
  ['250_433', 'critical', 'new',            'Compressor skid · Sector 3','11', '21:58', 0.94, 44.4, 18.8,
    'Sharp localized anomaly at the skid inlet. Flagged automatically; awaiting operator response.'],
  ['150_433', 'high',     'acknowledged',   'South pipe rack · Sector 2','09', '21:56', 0.90, 44.5, 18.7,
    'Confirmed and acknowledged on this pass. Maintenance team notified for follow-up.'],
  ['250_300', 'high',     'new',            'Central manifold · Sector 3','10','21:57', 0.89, 44.6, 19.0, ''],
  ['150_567', 'high',     'new',            'West manifold · Sector 2',  '12', '21:59', 0.92, 43.9, 18.1, ''],
  ['150_233', 'medium',   'new',            'North wall · Sector 1',     '06', '21:54', 0.78, 44.3, 18.5, ''],
  ['250_33',  'medium',   'acknowledged',   'Inlet flange · Sector 1',   '02', '21:53', 0.74, 42.1, 22.5, ''],
  ['250_167', 'low',      'new',            'East riser · Sector 4',     '04', '21:53', 0.66, 41.3, 21.5, ''],
  ['150_167', 'low',      'resolved',       'Valve cluster · Sector 4',  '05', '21:54', 0.61, 40.6, 21.4,
    'Minor warm reading; cleared on the following re-scan. No action required.'],
  ['250_100', 'low',      'false_positive', 'Floor heater duct · Sector 2','03','21:53', 0.55, 39.4, 21.6,
    'Known warm-air return from the floor heating duct. Misclassified by the comparator; filtered going forward.'],
];

const DETECTIONS = RAW.map(([cell, priority, status, area, pass, time, confidence, tMax, tMin, notes], i) => {
  const [x, y] = cell.split('_').map(Number);
  const delta = +(tMax - tMin).toFixed(1);
  return {
    id: `L-527-${(100 - i * 7).toString().padStart(3, '0')}`,
    cell, priority, status, pass, time, date: RUN_DATE,
    temp: `${tMax.toFixed(1)}°C`, tempVal: tMax,
    ambient: tMin,
    delta: `+${delta.toFixed(1)}°C`, deltaVal: delta,
    confidence,
    location: { x, y, z: 60 },           // gantry cell coordinates, cm
    locNorm: norm(x, y),
    area, mission: MISSION, notes,
    frames: {
      raw:  `frames/${cell}_raw.jpg`,
      cur:  `frames/${cell}_cur.png`,
      past: `frames/${cell}_past.png`,
      diff: `frames/${cell}_diff.png`,
    },
  };
});

Object.assign(window, { PRIORITY, STATUS, DETECTIONS, MISSION, RUN_DATE });
