/**
 * Snippet Capture Strategy -- Audit-Runner Integration Wrapper
 * --------------------------------------------------------------
 * Thin wrapper around the snippet capture orchestrator.
 * Adds error boundary so any uncaught throw returns null gracefully.
 *
 * Internal module.
 */

import { generateSnippetCaptureStrategy } from "../../snippet-capture/orchestrator";
import type { SnippetCaptureStrategy } from "../../snippet-capture/types";
import type { AiSnippetEligibility } from "../types";

export type { SnippetCaptureStrategy };

export async function aggregateSnippetCaptureStrategy({
  aiSnippetEligibility,
  brandName,
  brandDomain,
  vertical,
}: {
  aiSnippetEligibility: AiSnippetEligibility | null | undefined;
  brandName: string;
  brandDomain: string;
  vertical: string;
}): Promise<SnippetCaptureStrategy | null> {
  try {
    return await generateSnippetCaptureStrategy({
      existingAuditContext: { aiSnippetEligibility },
      brandContext: { brandName, brandDomain, vertical },
    });
  } catch (err) {
    console.warn("[snippet-capture-strategy] uncaught error:", err instanceof Error ? err.message : err);
    return null;
  }
}
