import type { ContentSample } from "../scrapers/firecrawl-content";
import type { PageData } from "../types";
import type { IndustryContext } from "../synthesizers/industry-classifier";
import type { VoiceSearchEligibility } from "../../voice-search-eligibility/types";
import { checkSpeakableSchema } from "../../voice-search-eligibility/checks/speakable-schema";
import { checkConversationalQuery } from "../../voice-search-eligibility/checks/conversational-query";
import { checkFaqReadability } from "../../voice-search-eligibility/checks/faq-readability";
import { checkLocalPackSignals } from "../../voice-search-eligibility/checks/local-pack-signals";
import { scoreVoiceSearchEligibility } from "../../voice-search-eligibility/scorer";

export type { VoiceSearchEligibility };

export function runVoiceSearchEligibility(
  pages: PageData[],
  samples: ContentSample[],
  industryContext: IndustryContext | null,
): VoiceSearchEligibility {
  const speakable = checkSpeakableSchema(pages, samples);
  const conversational = checkConversationalQuery(pages, samples);
  const faq = checkFaqReadability(pages, samples);
  const local = checkLocalPackSignals(pages, samples);
  return scoreVoiceSearchEligibility(speakable, conversational, faq, local, industryContext);
}
