function readBaseurlAllowlist(env = process.env) {
  const raw = env.AI_RUNTIME_BASEURL_ALLOWLIST ?? "";
  return raw.split(",").map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0);
}
function isBaseurlAllowlisted(baseUrl, allowlist) {
  const trimmed = baseUrl.trim();
  if (!trimmed) return true;
  if (allowlist.length === 0) return false;
  let parsedHostname;
  try {
    parsedHostname = new URL(trimmed).hostname.toLowerCase();
  } catch {
    return false;
  }
  for (const pattern of allowlist) {
    if (pattern.startsWith("*.")) {
      const suffix = pattern.slice(2);
      if (parsedHostname.endsWith(`.${suffix}`)) return true;
    } else if (pattern === parsedHostname) {
      return true;
    }
  }
  return false;
}
export {
  isBaseurlAllowlisted,
  readBaseurlAllowlist
};
//# sourceMappingURL=baseurl-allowlist.js.map
