// The site form's two report-site keys (site.json `search` and `reports`), // pure so the parse is tested without a server (saveSiteAction calls it). // // `search` is the form's checkbox, opt-out like `archives`: an unchecked box // sends no field and is written as `search: false` (report-only). A legacy // `publish: "cited"` read from the file is never written back. // `reports` is NOT edited by this form (the site's Reports tab manages it): the // Site is rebuilt from the form on save, so the list already stored is carried // over, and saving any other field never drops a published report. import { parseSiteReports, type Site } from "yt-dlp-transcript-common/lib/site"; export function reportSiteKeysFromForm( formData: FormData, stored: Pick | undefined, ): Pick { const search = formData.get("search") === "on"; const reports = parseSiteReports(stored?.reports); return { ...(search ? {} : { search: false }), ...(reports.length > 0 ? { reports } : {}), }; }