/**
 * Extract source-relevant overrides from ResolvedConfig.
 *
 * Used by orchestration steps and command handlers to call loadSource()
 * with typed overrides instead of relying on process.env.
 */
export function configToSourceOverrides(config) {
    return {
        ...(config.allowedOrigins?.length
            ? { allowedOrigins: config.allowedOrigins }
            : {}),
        ...(config.urls?.[0] ? { baseUrl: config.urls[0] } : {}),
        ...(config.datasetOverride ? { dataset: config.datasetOverride } : {}),
        ...(config.sanityDocumentArgs?.length
            ? { documentIds: config.sanityDocumentArgs }
            : {}),
        ...(config.headers ? { headers: config.headers } : {}),
        ...(config.perspectiveOverride
            ? { perspective: config.perspectiveOverride }
            : {}),
        ...(config.projectIdOverride
            ? { projectId: config.projectIdOverride }
            : {}),
        ...(config.studioOriginOverride
            ? { studioOrigin: config.studioOriginOverride }
            : {}),
    };
}
