export const AXEL_SEARCH_URL =
  "https://services.mothership.com/axel/location/search";
export const AXEL_PLACE_BASE =
  "https://services.mothership.com/axel/location/place/";
export const AXEL_QUOTE_URL = "https://services.mothership.com/axel/quote";

export const AXEL_ORIGIN = "https://www.mothership.com";
export const AXEL_REFERER = "https://www.mothership.com/";

export const DEFAULT_AXEL_USER_AGENT =
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";

export const AXEL_QUOTE_TIMEOUT_MS = 120_000;
export const AXEL_QUOTE_RETRIES = 2;

/** 地址候选 fetchPlace 校验条数上限（env 可覆盖，默认 3） */
export const AXEL_CANDIDATE_VERIFY_TOP_K_DEFAULT = 3;

export function getAxelCandidateVerifyTopK(): number {
  const raw = process.env.AXEL_CANDIDATE_VERIFY_TOP_K?.trim();
  if (!raw) {
    return AXEL_CANDIDATE_VERIFY_TOP_K_DEFAULT;
  }
  const parsed = Number.parseInt(raw, 10);
  if (!Number.isFinite(parsed) || parsed < 1) {
    return AXEL_CANDIDATE_VERIFY_TOP_K_DEFAULT;
  }
  return Math.min(parsed, 25);
}
