"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PULL_REQUEST_MERGE_POLICY_CLI_VALUES = exports.PULL_REQUEST_REVIEW_POLICY_CLI_VALUES = exports.ISSUE_COMPLETION_TARGET_CLI_VALUES = exports.PULL_REQUEST_MERGE_POLICY_VALUES = exports.PULL_REQUEST_REVIEW_POLICY_VALUES = exports.ISSUE_COMPLETION_TARGET_VALUES = void 0;
exports.isIssueCompletionTarget = isIssueCompletionTarget;
exports.isPullRequestReviewPolicy = isPullRequestReviewPolicy;
exports.isPullRequestMergePolicy = isPullRequestMergePolicy;
exports.parseIssueCompletionTargetCliValue = parseIssueCompletionTargetCliValue;
exports.parsePullRequestReviewPolicyCliValue = parsePullRequestReviewPolicyCliValue;
exports.parsePullRequestMergePolicyCliValue = parsePullRequestMergePolicyCliValue;
exports.formatIssueCompletionTargetForCli = formatIssueCompletionTargetForCli;
exports.formatPullRequestReviewPolicyForCli = formatPullRequestReviewPolicyForCli;
exports.formatPullRequestMergePolicyForCli = formatPullRequestMergePolicyForCli;
exports.shouldAlwaysRunPullRequestReview = shouldAlwaysRunPullRequestReview;
exports.shouldEvaluatePullRequestReviewNecessity = shouldEvaluatePullRequestReviewNecessity;
exports.shouldSkipPullRequestReview = shouldSkipPullRequestReview;
exports.shouldReleaseReviewReadyPullRequest = shouldReleaseReviewReadyPullRequest;
exports.isPullRequestAutoMergePolicyEnabled = isPullRequestAutoMergePolicyEnabled;
exports.ISSUE_COMPLETION_TARGET_VALUES = [
    "pause_on_issue",
    "pull_request",
];
exports.PULL_REQUEST_REVIEW_POLICY_VALUES = [
    "never",
    "if_needed",
    "always",
];
exports.PULL_REQUEST_MERGE_POLICY_VALUES = ["manual", "auto"];
exports.ISSUE_COMPLETION_TARGET_CLI_VALUES = [
    "pause-on-issue",
    "pull-request",
    "default",
];
exports.PULL_REQUEST_REVIEW_POLICY_CLI_VALUES = [
    "never",
    "if-needed",
    "always",
    "default",
];
exports.PULL_REQUEST_MERGE_POLICY_CLI_VALUES = [
    "manual",
    "auto",
    "default",
];
function isIssueCompletionTarget(value) {
    return exports.ISSUE_COMPLETION_TARGET_VALUES.includes(value);
}
function isPullRequestReviewPolicy(value) {
    return exports.PULL_REQUEST_REVIEW_POLICY_VALUES.includes(value);
}
function isPullRequestMergePolicy(value) {
    return exports.PULL_REQUEST_MERGE_POLICY_VALUES.includes(value);
}
function parseIssueCompletionTargetCliValue(token) {
    switch (token) {
        case "pause-on-issue":
            return "pause_on_issue";
        case "pull-request":
            return "pull_request";
        case "default":
            return "default";
        default:
            return null;
    }
}
function parsePullRequestReviewPolicyCliValue(token) {
    switch (token) {
        case "never":
            return "never";
        case "if-needed":
            return "if_needed";
        case "always":
            return "always";
        case "default":
            return "default";
        default:
            return null;
    }
}
function parsePullRequestMergePolicyCliValue(token) {
    switch (token) {
        case "manual":
            return "manual";
        case "auto":
            return "auto";
        case "default":
            return "default";
        default:
            return null;
    }
}
function formatIssueCompletionTargetForCli(target) {
    switch (target) {
        case "pause_on_issue":
            return "pause-on-issue";
        case "pull_request":
            return "pull-request";
    }
}
function formatPullRequestReviewPolicyForCli(policy) {
    switch (policy) {
        case "never":
            return "never";
        case "if_needed":
            return "if-needed";
        case "always":
            return "always";
    }
}
function formatPullRequestMergePolicyForCli(policy) {
    switch (policy) {
        case "manual":
            return "manual";
        case "auto":
            return "auto";
    }
}
function shouldAlwaysRunPullRequestReview(issueCompletion) {
    return issueCompletion.pullRequest.reviewPolicy === "always";
}
function shouldEvaluatePullRequestReviewNecessity(issueCompletion) {
    return issueCompletion.pullRequest.reviewPolicy === "if_needed";
}
function shouldSkipPullRequestReview(issueCompletion) {
    return issueCompletion.pullRequest.reviewPolicy === "never";
}
function shouldReleaseReviewReadyPullRequest(issueCompletion) {
    return (issueCompletion.pullRequest.reviewPolicy !== "never" ||
        issueCompletion.pullRequest.mergePolicy === "auto");
}
function isPullRequestAutoMergePolicyEnabled(issueCompletion) {
    return issueCompletion.pullRequest.mergePolicy === "auto";
}
