"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WORKFLOW_RETRY_AUTO_MERGE_STATES = exports.WORKFLOW_AUTO_MERGE_STATES = void 0;
exports.isWorkflowAutoMergeState = isWorkflowAutoMergeState;
exports.hasActiveAutoMergeState = hasActiveAutoMergeState;
exports.isRetryAutoMergeState = isRetryAutoMergeState;
exports.resolveNextRetryAutoMergeState = resolveNextRetryAutoMergeState;
exports.WORKFLOW_AUTO_MERGE_STATES = {
    pending: "pending",
    retry1: "retry-1",
    retry2: "retry-2",
    retry3: "retry-3",
};
exports.WORKFLOW_RETRY_AUTO_MERGE_STATES = [
    exports.WORKFLOW_AUTO_MERGE_STATES.retry1,
    exports.WORKFLOW_AUTO_MERGE_STATES.retry2,
    exports.WORKFLOW_AUTO_MERGE_STATES.retry3,
];
const WORKFLOW_AUTO_MERGE_STATE_SET = new Set(Object.values(exports.WORKFLOW_AUTO_MERGE_STATES));
function isWorkflowAutoMergeState(value) {
    return (typeof value === "string" &&
        WORKFLOW_AUTO_MERGE_STATE_SET.has(value));
}
function hasActiveAutoMergeState(workflowState) {
    return workflowState?.autoMergeState !== undefined;
}
function isRetryAutoMergeState(autoMergeState) {
    return exports.WORKFLOW_RETRY_AUTO_MERGE_STATES.includes(autoMergeState);
}
function resolveNextRetryAutoMergeState(autoMergeState) {
    switch (autoMergeState) {
        case exports.WORKFLOW_AUTO_MERGE_STATES.pending:
        case undefined:
        case null:
            return exports.WORKFLOW_AUTO_MERGE_STATES.retry1;
        case exports.WORKFLOW_AUTO_MERGE_STATES.retry1:
            return exports.WORKFLOW_AUTO_MERGE_STATES.retry2;
        case exports.WORKFLOW_AUTO_MERGE_STATES.retry2:
            return exports.WORKFLOW_AUTO_MERGE_STATES.retry3;
        case exports.WORKFLOW_AUTO_MERGE_STATES.retry3:
            return null;
    }
}
