import type { PickingInfo, Layer } from '@deck.gl/core';
import type { Port } from '../../data/ports';
import type { WindFarm } from '../../data/windFarms';
import type { MilitaryBase } from '../../data/militaryBases';
import type { GovBuilding } from '../../data/govBuildings';
import type { NKLaunchSite } from '../../data/nkLaunchSites';
import type { NKMissileEvent } from '../../data/nkMissileEvents';
import type { CoastGuardFacility } from '../../services/coastGuard';
import type { KoreanAirport } from '../../services/airports';
import type { NavWarning } from '../../services/navWarning';
import type { PiracyZone } from '../../services/piracy';
import type { PowerFacility } from '../../services/infra';
import type { HazardFacility, HazardType } from '../../data/hazardFacilities';
import type { CnFacility } from '../../data/cnFacilities';
import type { JpFacility } from '../../data/jpFacilities';

export type StaticPickedObject =
  | Port | WindFarm | MilitaryBase | GovBuilding
  | NKLaunchSite | NKMissileEvent | CoastGuardFacility | KoreanAirport
  | NavWarning | PiracyZone | PowerFacility | HazardFacility
  | CnFacility | JpFacility;

export type StaticLayerKind =
  | 'port' | 'windFarm' | 'militaryBase' | 'govBuilding'
  | 'nkLaunch' | 'nkMissile' | 'coastGuard' | 'airport'
  | 'navWarning' | 'piracy' | 'infra' | 'hazard'
  | 'cnFacility' | 'jpFacility';

export interface StaticPickInfo {
  kind: StaticLayerKind;
  object: StaticPickedObject;
}

export interface LayerFactoryConfig {
  sc: number;  // sizeScale (zoom-based)
  fs: number;  // fontScale (user preference, default 1.0)
  onPick: (info: StaticPickInfo) => void;
}

export type { PickingInfo, Layer };
export type { Port, WindFarm, MilitaryBase, GovBuilding, NKLaunchSite, NKMissileEvent };
export type { CoastGuardFacility, KoreanAirport, NavWarning, PiracyZone };
export type { PowerFacility, HazardFacility, HazardType, CnFacility, JpFacility };

export function hexToRgb(hex: string): [number, number, number] {
  const r = parseInt(hex.slice(1, 3), 16);
  const g = parseInt(hex.slice(3, 5), 16);
  const b = parseInt(hex.slice(5, 7), 16);
  return [r, g, b];
}
