// Tab-to-fields mapping for reset functionality.
// Keys are PHP option group names; values are arrays of field keys within that group.
export const tabKeysMap = {
    general:     { general:  ["enabled", "sitemaps", "manual_urls"] },
    logging:     { logging:  ["retention_days"] },
    diagnostics: { diagnostics: ["probe_results"] },
    advanced:    { advanced: ["pacing_mode", "pages_per_batch", "throttle_seconds", "max_batch_seconds",
                              "user_agent", "stale_run_minutes", "max_urls_per_run"] },
    priorities:  { priorities: ["post_type_order", "priority_pages"] },
};

export const buildCleanPayload = (defaults, payloadOptions) => {
    const clean = { ...defaults };
    Object.entries(payloadOptions).forEach(([groupKey, groupFields]) => {
        if (typeof groupFields === "object" && groupFields !== null) {
            clean[groupKey] = { ...clean[groupKey], ...groupFields };
        }
    });
    return clean;
};
