export const DEFAULT_INSTANCE_TYPE = "t3.medium";

export const INSTANCE_TYPES = [
  { value: "t3.medium", label: "t3.medium", cost: "$0.042/hr" },
  { value: "t3.large", label: "t3.large", cost: "$0.083/hr" },
  { value: "t3a.medium", label: "t3a.medium", cost: "$0.038/hr" },
  { value: "t3a.large", label: "t3a.large", cost: "$0.075/hr" },
  { value: "t4g.medium", label: "t4g.medium", cost: "$0.034/hr" },
  { value: "t4g.large", label: "t4g.large", cost: "$0.067/hr" },
  { value: "m5.large", label: "m5.large", cost: "$0.096/hr" },
  { value: "c5.large", label: "c5.large", cost: "$0.085/hr" },
];

export function normalizeInstanceType(value?: string | null, emptyFallback = DEFAULT_INSTANCE_TYPE): string {
  const raw = (value || "").trim();
  if (!raw) return emptyFallback;
  if (raw.startsWith("t2.")) return DEFAULT_INSTANCE_TYPE;
  return raw;
}

export function isPresetInstanceType(value?: string | null): boolean {
  return INSTANCE_TYPES.some(t => t.value === value);
}
