export const DEFAULT_INSTANCE_TYPE = "t3.medium";

export const LEGACY_INSTANCE_TYPE_REPLACEMENTS: Record<string, string> = {
  "t2.medium": DEFAULT_INSTANCE_TYPE,
};

export function normalizeInstanceType(value?: unknown): string {
  const raw = typeof value === "string" ? value.trim() : "";
  if (!raw) return DEFAULT_INSTANCE_TYPE;
  if (raw.startsWith("t2.")) return LEGACY_INSTANCE_TYPE_REPLACEMENTS[raw] ?? DEFAULT_INSTANCE_TYPE;
  return raw.slice(0, 64);
}
