/**
 * Website Extractor Service — AI-Powered Auto-Onboarding Pipeline
 *
 * Scrapes a customer's website URL and produces structured PrefillField data
 * for the onboarding flow. Pipeline: fetch HTML → extract metadata → strip to
 * visible text → call Claude via AI SDK generateObject → map to OnboardingPrefill.
 *
 * Architecture:
 * - Uses native fetch for HTTP requests (no Playwright for MVP)
 * - Uses @ai-sdk/anthropic + generateObject for structured LLM extraction
 * - Max 5 pages per domain, 15s fetch timeout, 30s LLM timeout
 * - Partial results returned on failure (graceful degradation)
 *
 * @module services/onboarding/website-extractor.service
 */
import type { OnboardingPrefill, PrefillField, PrefillConfidence } from './brand-onboarding.types.js';
/** Metadata extracted from HTML head and meta tags */
export interface PageMetadata {
    /** Page title from <title> tag */
    title: string;
    /** Meta description */
    description: string;
    /** Open Graph title */
    ogTitle: string;
    /** Open Graph description */
    ogDescription: string;
    /** Open Graph image URL */
    ogImage: string;
    /** Open Graph site name */
    ogSiteName: string;
    /** Canonical URL */
    canonical: string;
}
/** Processed page content ready for LLM extraction */
export interface ProcessedPage {
    /** Source URL */
    url: string;
    /** Extracted metadata */
    metadata: PageMetadata;
    /** Visible text content (HTML stripped) */
    textContent: string;
    /** Social/about links found on the page */
    links: string[];
}
/** Raw LLM extraction result before mapping to PrefillFields */
export interface LlmExtractionResult {
    businessName?: string;
    industry?: string;
    description?: string;
    targetCustomer?: string;
    competitors?: string[];
    personality?: string[];
    tone?: string;
    platforms?: string[];
    goals?: string[];
    contentExamples?: string[];
    /** Per-field confidence as assessed by the LLM */
    fieldConfidence?: Record<string, 'high' | 'medium' | 'low'>;
}
/**
 * Website Extractor Service — singleton that scrapes a website URL and
 * produces structured OnboardingPrefill data for brand onboarding.
 *
 * @example
 * ```typescript
 * const extractor = WebsiteExtractorService.getInstance();
 * const prefill = await extractor.extract('https://example.com');
 * ```
 */
export declare class WebsiteExtractorService {
    private static instance;
    private readonly logger;
    /** Injected fetch function — allows test mocking */
    private fetchFn;
    /** Injected LLM call function — allows test mocking */
    private llmExtractFn;
    private constructor();
    /**
     * Get the singleton instance.
     *
     * @returns WebsiteExtractorService instance
     */
    static getInstance(): WebsiteExtractorService;
    /**
     * Reset the singleton (for testing).
     */
    static resetInstance(): void;
    /**
     * Override the fetch function (for testing).
     *
     * @param fn - Custom fetch implementation
     */
    setFetchFn(fn: typeof globalThis.fetch): void;
    /**
     * Override the LLM extraction function (for testing).
     *
     * @param fn - Custom LLM extraction implementation
     */
    setLlmExtractFn(fn: (prompt: string, pageData: ProcessedPage[]) => Promise<LlmExtractionResult>): void;
    /**
     * Extract brand profile data from a website URL.
     *
     * Pipeline steps:
     * 1. Fetch homepage HTML
     * 2. Extract metadata (title, og tags, meta description)
     * 3. Extract visible text content (strip HTML)
     * 4. Find about/social links
     * 5. Optionally fetch about page for richer context
     * 6. Call LLM with structured extraction prompt
     * 7. Map to OnboardingPrefill with confidence + sourceUrls
     *
     * @param url - Website URL to scrape
     * @returns OnboardingPrefill with extracted fields
     */
    extract(url: string): Promise<OnboardingPrefill>;
    /**
     * Fetch a URL and process the HTML into structured page data.
     *
     * @param url - URL to fetch
     * @returns Processed page data or null if fetch fails
     */
    fetchAndProcess(url: string): Promise<ProcessedPage | null>;
    /**
     * Extract metadata from HTML head section.
     *
     * @param html - Raw HTML string
     * @returns Extracted metadata
     */
    extractMetadata(html: string): PageMetadata;
    /**
     * Extract visible text content from HTML, stripping all tags.
     * Removes scripts, styles, and navigation elements.
     *
     * @param html - Raw HTML string
     * @returns Clean text content
     */
    extractVisibleText(html: string): string;
    /**
     * Extract links from HTML, focusing on about/social/important pages.
     *
     * @param html - Raw HTML string
     * @param baseUrl - Base URL for resolving relative links
     * @returns Array of absolute URLs
     */
    extractLinks(html: string, baseUrl: string): string[];
    /**
     * Find important links to follow (about, team, services pages, social profiles).
     *
     * @param page - Processed homepage data
     * @param baseUrl - Homepage URL for same-domain filtering
     * @returns Prioritized list of URLs to fetch
     */
    findImportantLinks(page: ProcessedPage, baseUrl: string): string[];
    /**
     * Call Claude to extract structured brand profile data from page content.
     *
     * @param pages - Processed page data
     * @returns Structured extraction result
     */
    callLlmExtraction(pages: ProcessedPage[]): Promise<LlmExtractionResult>;
    /**
     * Parse the LLM text response into a structured extraction result.
     * Handles JSON wrapped in markdown code fences.
     *
     * @param text - Raw LLM response text
     * @returns Parsed extraction result
     */
    parseLlmResponse(text: string): LlmExtractionResult;
    /**
     * Map LLM extraction result to OnboardingPrefill with PrefillField wrappers.
     *
     * @param result - Raw LLM extraction result
     * @param pages - Source pages for URL attribution
     * @returns Structured OnboardingPrefill
     */
    mapToPrefill(result: LlmExtractionResult, pages: ProcessedPage[]): OnboardingPrefill;
    /**
     * Build a metadata-only prefill when LLM extraction fails.
     * Uses page title, og tags, and social links as fallback.
     *
     * @param pages - Processed pages
     * @returns Partial OnboardingPrefill from metadata only
     */
    buildMetadataOnlyPrefill(pages: ProcessedPage[]): OnboardingPrefill;
    /**
     * Create a PrefillField with the given value and confidence.
     *
     * @param value - Extracted value
     * @param sourceUrls - URLs from which this was extracted
     * @param confidence - Confidence level
     * @returns PrefillField wrapper
     */
    createPrefillField(value: string | string[], sourceUrls: string[], confidence: PrefillConfidence): PrefillField;
    /**
     * Detect platform names from social media URLs.
     *
     * @param links - Array of social media URLs
     * @returns Platform name strings
     */
    detectPlatformsFromLinks(links: string[]): string[];
    /**
     * Normalize a URL (add protocol if missing).
     *
     * @param url - Raw URL string
     * @returns Normalized URL with protocol
     */
    normalizeUrl(url: string): string;
    /**
     * Extract text content matching a regex group from HTML.
     *
     * @param html - HTML string
     * @param regex - Regex with a capture group
     * @returns Captured text or empty string
     */
    private extractTag;
    /**
     * Extract content from a meta name tag.
     *
     * @param html - HTML string
     * @param name - Meta tag name attribute
     * @returns Content value or empty string
     */
    private extractMetaContent;
    /**
     * Extract content from a meta property (og:*) tag.
     *
     * @param html - HTML string
     * @param property - Meta tag property attribute
     * @returns Content value or empty string
     */
    private extractMetaProperty;
    /**
     * Extract href from a link rel tag.
     *
     * @param html - HTML string
     * @param rel - Link rel attribute value
     * @returns Href value or empty string
     */
    private extractLinkHref;
}
//# sourceMappingURL=website-extractor.service.d.ts.map