"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveAcceptedCommandSnapshotAndWorkflowState = resolveAcceptedCommandSnapshotAndWorkflowState;
const config_decision_support_1 = require("./config-decision-support");
async function resolveAcceptedCommandSnapshotAndWorkflowState(input) {
    const nextSnapshot = await (0, config_decision_support_1.resolveNextSnapshotAfterCommand)({
        ticketTracker: input.ticketTracker,
        issue: input.issue,
        comments: input.comments,
        currentNeedsHumanReason: input.currentNeedsHumanReason,
        previousEffectiveConfig: input.previousEffectiveConfig,
        effectiveConfig: input.effectiveConfig,
        previousConsecutiveAiRuns: input.previousConsecutiveAiRuns,
        workflowState: input.workflowState,
        promotesReady: input.command.workflowSelection !== undefined ||
            input.command.bodyAfterCommand.trim().length > 0,
    });
    return {
        nextSnapshot: nextSnapshot.snapshot,
        workflowState: (0, config_decision_support_1.applyAcceptedIssueCompletionAutoMergeState)({
            config: input.effectiveConfig,
            issue: input.issue,
            nextSnapshot: nextSnapshot.snapshot,
            workflowState: input.workflowState,
        }),
    };
}
