import type { StringBundle } from '@/lib/i18n';

type ItemPurchaseNs = StringBundle['item_purchase'];

const NOTE_KEY_MAP: Record<string, keyof ItemPurchaseNs> = {
  no_carrier_update_14d: 'note_no_carrier_update_14d',
  handle_sla_breached: 'note_handle_sla_breached',
};

/** Maps machine note tokens to localized copy; suppresses unknown snake_case tokens. */
export function shipmentNoteLabel(
  note: string,
  t: (key: keyof ItemPurchaseNs) => string,
): string | null {
  const mapped = NOTE_KEY_MAP[note];
  if (mapped) return t(mapped);
  if (/^[a-z0-9_]+$/.test(note)) return null;
  return note;
}
