import { detectShop, type Shop } from '@/lib/shops' import type { PriceScraper, ScrapeResult } from './types' const registry = new Map() export function registerScraper(scraper: PriceScraper) { registry.set(scraper.shop, scraper) } export async function scrapeUrl(url: string): Promise { const shop = detectShop(url) if (!shop) throw new Error(`Unsupported URL: ${url}`) const scraper = registry.get(shop) if (!scraper) throw new Error(`No scraper registered for shop: ${shop}`) return scraper.scrape(url) } export function registerScraperForTest(s: PriceScraper) { registry.set(s.shop, s) } export function resetScrapersForTest() { registry.clear() }