/**
 * 어구 그룹 타입 카탈로그
 *
 * SSOT: backend group_polygon_snapshots.group_type
 * 사용처: RealGearGroups
 */

import type { BadgeIntent } from '@lib/theme/variants';

export type GearGroupType = 'FLEET' | 'GEAR_IN_ZONE' | 'GEAR_OUT_ZONE';

interface GearGroupTypeMeta {
  code: GearGroupType;
  i18nKey: string;
  fallback: { ko: string; en: string };
  intent: BadgeIntent;
}

export const GEAR_GROUP_TYPES: Record<GearGroupType, GearGroupTypeMeta> = {
  FLEET: {
    code: 'FLEET',
    i18nKey: 'gearGroupType.FLEET',
    fallback: { ko: '선단', en: 'Fleet' },
    intent: 'info',
  },
  GEAR_IN_ZONE: {
    code: 'GEAR_IN_ZONE',
    i18nKey: 'gearGroupType.GEAR_IN_ZONE',
    fallback: { ko: '구역 내 어구', en: 'In-Zone Gear' },
    intent: 'high',
  },
  GEAR_OUT_ZONE: {
    code: 'GEAR_OUT_ZONE',
    i18nKey: 'gearGroupType.GEAR_OUT_ZONE',
    fallback: { ko: '구역 외 어구', en: 'Out-Zone Gear' },
    intent: 'purple',
  },
};

export function getGearGroupTypeIntent(t: string): BadgeIntent {
  return GEAR_GROUP_TYPES[t as GearGroupType]?.intent ?? 'muted';
}
export function getGearGroupTypeLabel(
  type: string,
  t: (k: string, opts?: { defaultValue?: string }) => string,
  lang: 'ko' | 'en' = 'ko',
): string {
  const meta = GEAR_GROUP_TYPES[type as GearGroupType];
  if (!meta) return type;
  return t(meta.i18nKey, { defaultValue: meta.fallback[lang] });
}
