import type { FrequencyBand } from '@/types/index.ts';

export const COMMON_FREQUENCIES: FrequencyBand[] = [
  {
    value: 800,
    name: 'Band 20',
    range: '791-862 MHz',
    type: 'LTE',
    characteristics: {
      range: 'long',
      penetration: 'excellent',
      typical: 'Rural coverage, deep building penetration',
    },
  },
  {
    value: 1800,
    name: 'Band 3',
    range: '1710-1880 MHz',
    type: 'LTE',
    characteristics: {
      range: 'medium',
      penetration: 'good',
      typical: 'Urban/suburban, most common in Ukraine',
    },
  },
  {
    value: 1900,
    name: 'Band 2',
    range: '1850-1990 MHz',
    type: 'LTE',
    characteristics: {
      range: 'medium',
      penetration: 'good',
      typical: 'North America, some military equipment',
    },
  },
  {
    value: 2100,
    name: 'Band 1',
    range: '1920-2170 MHz',
    type: 'LTE',
    characteristics: {
      range: 'medium',
      penetration: 'good',
      typical: 'Most deployed LTE band globally (IMT 2100)',
    },
  },
  {
    value: 2600,
    name: 'Band 7',
    range: '2500-2690 MHz',
    type: 'LTE',
    characteristics: {
      range: 'short',
      penetration: 'fair',
      typical: 'High capacity urban, shorter range',
    },
  },
  {
    value: 150,
    name: 'VHF High',
    range: '136-174 MHz',
    type: 'VHF',
    characteristics: {
      range: 'long',
      penetration: 'excellent',
      typical: 'Tactical radio, emergency services',
    },
  },
  {
    value: 450,
    name: 'UHF',
    range: '400-470 MHz',
    type: 'UHF',
    characteristics: {
      range: 'medium',
      penetration: 'good',
      typical: 'Military tactical radio, PMR446',
    },
  },
  {
    value: 3500,
    name: 'Band 42/43 (n78)',
    range: '3400-3800 MHz',
    type: '5G',
    characteristics: {
      range: 'short',
      penetration: 'poor',
      typical: '5G NR, high bandwidth',
    },
  },
];

export const QUICK_FREQUENCIES = [800, 1800, 1900, 2100, 2600];

export function getFrequencyInfo(frequency: number): FrequencyBand | null {
  return (
    COMMON_FREQUENCIES.find((band) => Math.abs(band.value - frequency) < 50) ||
    null
  );
}

export function getWavelength(frequencyMHz: number): string {
  const wavelengthMeters = 300 / frequencyMHz;
  if (wavelengthMeters >= 1) {
    return `${wavelengthMeters.toFixed(2)} m`;
  }
  return `${(wavelengthMeters * 100).toFixed(1)} cm`;
}
