export interface EncDepthColor {
  label: string;
  layerIds: string[];
  color: string;
}

export interface EncMapSettings {
  // 심볼 카테고리별 표시 토글
  showBuoys: boolean;
  showBeacons: boolean;
  showLights: boolean;
  showDangers: boolean;
  showLandmarks: boolean;
  showSoundings: boolean;
  showPilot: boolean;
  showAnchorage: boolean;
  showRestricted: boolean;
  showDredged: boolean;
  showTSS: boolean;
  showContours: boolean;

  // 영역 색상 (nautical.json 기본값 기준)
  landColor: string;
  coastlineColor: string;
  backgroundColor: string;

  // 수심별 색상
  depthDrying: string;
  depthVeryShallow: string;
  depthSafetyZone: string;
  depthMedium: string;
  depthDeep: string;
}

/** nautical.json 기본 색상 기준 */
export const DEFAULT_ENC_MAP_SETTINGS: EncMapSettings = {
  showBuoys: true,
  showBeacons: true,
  showLights: true,
  showDangers: true,
  showLandmarks: true,
  showSoundings: true,
  showPilot: true,
  showAnchorage: true,
  showRestricted: true,
  showDredged: true,
  showTSS: true,
  showContours: true,

  landColor: '#BFBE8D',
  coastlineColor: '#4C5B62',
  backgroundColor: '#93AEBB',

  depthDrying: '#58AF99',
  depthVeryShallow: '#61B7FF',
  depthSafetyZone: '#82CAFF',
  depthMedium: '#A7D9FA',
  depthDeep: '#C9EDFD',
};

/**
 * 심볼 카테고리 → nautical.json 레이어 ID 매핑.
 * 서버 스타일의 49개 레이어를 12개 카테고리로 그룹화.
 */
export const ENC_LAYER_CATEGORIES: Record<string, string[]> = {
  showBuoys: ['boylat', 'boycar', 'boyisd', 'boysaw', 'boyspp'],
  showBeacons: ['lndmrk'],
  showLights: ['lights', 'lights-catlit'],
  showDangers: ['uwtroc', 'obstrn', 'wrecks'],
  showLandmarks: ['lndmrk'],
  showSoundings: ['soundg', 'soundg-critical'],
  showPilot: ['pilbop'],
  showAnchorage: ['achare', 'achare-outline'],
  showRestricted: ['resare-outline', 'resare-symbol', 'mipare'],
  showDredged: [
    'drgare-drying', 'drgare-very-shallow', 'drgare-safety-zone',
    'drgare-medium', 'drgare-deep', 'drgare-pattern', 'drgare-outline', 'drgare-symbol',
  ],
  showTSS: ['tsslpt', 'tsslpt-outline'],
  showContours: ['depcnt', 'depare-safety-edge', 'depare-safety-edge-label'],
};

/** 영역 색상 → 레이어 ID + paint 속성 매핑 */
export const ENC_COLOR_TARGETS: [layerId: string, prop: string, settingsKey: keyof EncMapSettings][] = [
  ['lndare', 'fill-color', 'landColor'],
  ['globe-lndare', 'fill-color', 'landColor'],
  ['coalne', 'line-color', 'coastlineColor'],
  ['globe-coalne', 'line-color', 'coastlineColor'],
];

/** 수심별 색상 → 레이어 ID 매핑 */
export const ENC_DEPTH_COLOR_TARGETS: { key: keyof EncMapSettings; label: string; layerIds: string[] }[] = [
  { key: 'depthDrying', label: '건출 (< 0m)', layerIds: ['depare-drying', 'drgare-drying'] },
  { key: 'depthVeryShallow', label: '극천 (0~2m)', layerIds: ['depare-very-shallow', 'drgare-very-shallow'] },
  { key: 'depthSafetyZone', label: '안전수심 (2~30m)', layerIds: ['depare-safety-zone', 'drgare-safety-zone'] },
  { key: 'depthMedium', label: '중간 (30m~)', layerIds: ['depare-medium', 'drgare-medium'] },
  { key: 'depthDeep', label: '심해', layerIds: ['depare-deep', 'drgare-deep'] },
];
