import { isEspnRelated, needsEspnArtEnrichment, normalizeEspnArtUrl, normalizeEspnChannel, parseEspnChannelHint, pickBestEspnMatch, type EspnWatchEvent, } from "./espn-watch-art"; function assert(cond: unknown, msg: string) { if (!cond) throw new Error(msg); } assert(isEspnRelated({ provider: "espn" }), "provider espn"); assert(isEspnRelated({ provider: "odido", name: "ESPN4: NFL Blitz", channel: "ESPN4" }), "odido espn"); assert(!isEspnRelated({ provider: "ziggosport", name: "GT World", channel: "Ziggo Sport 1" }), "not ziggo"); assert( needsEspnArtEnrichment({ provider: "odido", channel: "ESPN", name: "ESPN: Dit was het Weekend", imageLandscape: null, images: [], }), "needs empty" ); assert(parseEspnChannelHint("ESPN2 • Eurojackpot Vrouwen Eredivisie") === "ESPN2", "hint espn2"); assert(normalizeEspnChannel("ESPN4") === "ESPN4", "ch espn4"); assert(normalizeEspnChannel("ESPN") === "ESPN", "ch espn"); const art = normalizeEspnArtUrl( "https://artwork.api.espn.com/artwork/collections/airings/abc/default?width=640&apikey=1ngjw23osgcis1i1vbj96lmfqs" ); assert(art.includes("width=960"), "widen"); const candidates: EspnWatchEvent[] = [ { id: "1", name: "FC Dordrecht - Almere City FC", subtitle: "ESPN4 • Herhaling • Keuken Kampioen Divisie", catalog: "Soccer,Dutch Keuken Kampioen Divisie", utcMs: Date.parse("2026-09-26T03:55:00+02:00"), imageHref: "https://artwork.api.espn.com/artwork/collections/airings/955dd918/default?width=640&apikey=x", channelHint: "ESPN4", }, { id: "2", name: "Jong Oranje - Jong Noorwegen", subtitle: "ESPN • Voetbal", catalog: "Soccer", utcMs: Date.parse("2026-09-25T18:30:00+02:00"), imageHref: "https://artwork.api.espn.com/artwork/collections/airings/other/default?width=640", channelHint: "ESPN", }, ]; const hit = pickBestEspnMatch(candidates, { title: "ESPN4: Keuken Kampioen Divisie Samenvatting", startMs: Date.parse("2026-09-26T01:55:00Z"), endMs: Date.parse("2026-09-26T02:55:00Z"), channel: "ESPN4", }); assert(hit?.id === "1", "pick KKD on ESPN4"); console.log("espn-watch-art tests ok");