const BLOCKLIST = /* @__PURE__ */ new Set([
  "elitepvpers.com",
  "zhihu.com",
  "baidu.com",
  "zhidao.baidu.com",
  "jingyan.baidu.com",
  "wenku.baidu.com",
  "tieba.baidu.com"
]);
const REDIRECT_HOSTS = /* @__PURE__ */ new Set([
  "duckduckgo.com",
  "r.jina.ai"
]);
function isValidCandidateUrl(u) {
  try {
    const parsed = new URL(u);
    if (!["http:", "https:"].includes(parsed.protocol)) return false;
    if (REDIRECT_HOSTS.has(parsed.hostname)) {
      if (parsed.hostname === "duckduckgo.com" && parsed.pathname.startsWith("/l/")) return false;
      if (parsed.hostname === "r.jina.ai") return false;
    }
    return true;
  } catch {
    return false;
  }
}
function isBlocklistedDomain(u) {
  try {
    const host = new URL(u).hostname.toLowerCase();
    if (BLOCKLIST.has(host)) return true;
    for (const dom of BLOCKLIST) {
      if (host.endsWith(`.${dom}`)) return true;
    }
    return false;
  } catch {
    return true;
  }
}
function preFilterCandidates(items) {
  const kept = [];
  const excluded = [];
  for (const it of items) {
    if (!isValidCandidateUrl(it.url)) {
      excluded.push({ item: it, reason: "invalid_url" });
      continue;
    }
    if (isBlocklistedDomain(it.url)) {
      excluded.push({ item: it, reason: "blocklisted_domain" });
      continue;
    }
    kept.push(it);
  }
  return { kept, excluded };
}
export {
  isBlocklistedDomain,
  isValidCandidateUrl,
  preFilterCandidates
};
//# sourceMappingURL=relevance.js.map