/**
 * Helper function to update Bot Management configuration for a zone
 * Maps high-level options to Cloudflare API fields
 */
export async function updateBotManagement(api, zoneId, botManagement, oldBotManagement) {
    const payload = createUpdateBotManagementPayload(botManagement);
    const oldPayload = createUpdateBotManagementPayload(oldBotManagement);
    if (JSON.stringify(payload) === JSON.stringify(oldPayload)) {
        return;
    }
    const response = await api.put(`/zones/${zoneId}/bot_management`, payload);
    if (!response.ok) {
        const body = await response.text();
        throw new Error(`Failed to update bot management settings: ${response.status} ${response.statusText}\n${body}`);
    }
}
const createUpdateBotManagementPayload = (props) => props === undefined
    ? {}
    : {
        fight_mode: props.fightMode,
        ai_bots_protection: props
            .aiBotsProtection,
        crawler_protection: props
            .crawlerProtection,
        enable_js: props.enableJs,
        is_robots_txt_managed: props
            .isRobotsTxtManaged,
        auto_update_model: props.autoUpdateModel,
        optimize_wordpress: props
            .optimizeWordpress,
        suppress_session_score: props
            .suppressSessionScore,
        sbfm_likely_automated: props
            .sbfmLikelyAutomated,
        sbfm_definitely_automated: props.sbfmDefinitelyAutomated,
        sbfm_verified_bots: props.sbfmVerifiedBots,
        sbfm_static_resource_protection: props.sbfmStaticResourceProtection,
    };
//# sourceMappingURL=zone-bot-management.js.map