• Exports a full sync report to a JSON file.

    Parameters

    Returns void

    If the report is missing, a warning is logged and no file is exported.

    exportSyncReport(report);
    
    export function exportSyncReport(report: SyncReport): void {
    if (!report) {
    console.warn("No report to export");
    return;
    }

    try {
    // Convert to JSON string with pretty formatting
    const jsonContent = JSON.stringify(report, null, 2);

    // Create blob and URL
    const blob = new Blob([jsonContent], { type: "application/json" });
    const url = URL.createObjectURL(blob);

    // Create element to trigger download
    const link = document.createElement("a");
    link.href = url;

    // Generate filename with date
    const date = new Date(report.timestamp);
    const dateStr = date.toISOString().split("T")[0]; // YYYY-MM-DD format
    link.download = `anilist-sync-report-${dateStr}.json`;

    // Trigger download
    document.body.appendChild(link);
    link.click();

    // Clean up
    document.body.removeChild(link);
    URL.revokeObjectURL(url);

    console.log("Sync report exported successfully");
    } catch (error) {
    console.error("Failed to export sync report:", error);
    }
    }