import { HnAlgoliaEngine } from "../../engines/hn-algolia.js";
import { LobstersEngine } from "../../engines/lobsters.js";
import { BingNewsEngine } from "../../engines/bing-news.js";
import { wrapWithRetryAndBreaker } from "../engine-base.js";
import { RssFeedEngine } from "../rss/rss-engine.js";
import { loadFeedConfig } from "../rss/feed-config.js";
import { countFeedItems } from "../rss/feed-store.js";
import { createLogger } from "../../../logger.js";
const log = createLogger("search");
let cached = null;
function hasRssConfigured() {
  try {
    if (loadFeedConfig().feeds.length > 0) return true;
  } catch {
  }
  try {
    if (countFeedItems() > 0) return true;
  } catch {
  }
  return false;
}
function getNewsEngines() {
  if (cached) return cached;
  const entries = [
    { engine: wrapWithRetryAndBreaker(new HnAlgoliaEngine()), weight: 1.2, supportsDateFilter: true, quality: "medium" },
    // Lobsters /search.json has no native date filter; engine applies client-side
    // filtering. Mark false so the orchestrator treats it as date-naive.
    // Quality tier 'low': frequently falls back to "N score · N comments" when
    // description is missing — see engine-quality.ts.
    { engine: wrapWithRetryAndBreaker(new LobstersEngine()), weight: 1, supportsDateFilter: false, quality: "low" },
    // Bing News widens reach beyond HN/Lobsters' tech-only feed. The engine
    // scrapes /search?filters=tnews and surfaces .news_dt → published_date so
    // the recency layer can rank it like the other date-aware engines.
    { engine: wrapWithRetryAndBreaker(new BingNewsEngine()), weight: 0.9, supportsDateFilter: false, quality: "medium" }
  ];
  if (hasRssConfigured()) {
    entries.push({
      engine: wrapWithRetryAndBreaker(new RssFeedEngine()),
      weight: 1.5,
      supportsDateFilter: true,
      quality: "medium"
    });
    log.info("news vertical: rss-feed engine attached");
  }
  cached = entries;
  return cached;
}
function _resetNewsEnginesForTest() {
  cached = null;
}
export {
  _resetNewsEnginesForTest,
  getNewsEngines
};
//# sourceMappingURL=news.js.map