"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildExistingIssueWorkflowPublishRequest = buildExistingIssueWorkflowPublishRequest;
exports.buildPullRequestThreadWorkflowPublishRequest = buildPullRequestThreadWorkflowPublishRequest;
exports.buildNewIssueWorkflowPublishRequest = buildNewIssueWorkflowPublishRequest;
const publisher_state_support_1 = require("./publisher-state-support");
function buildTargetedWorkflowPublishRequest(input) {
    return (0, publisher_state_support_1.buildWorkflowPublishRequest)({
        target: input.target,
        workflowState: input.workflowState,
        visibleWorkflowState: input.visibleWorkflowState,
        appendCanonicalWorkflowStateComment: input.appendCanonicalWorkflowStateComment,
        invalidWorkflowStatePolicy: input.invalidWorkflowStatePolicy,
        publishPrecondition: input.publishPrecondition,
        workflowProjection: input.workflowProjection,
        trackerFields: input.trackerFields,
        dependencyChanges: input.dependencyChanges,
        visibleUpdate: input.visibleUpdate,
        visibleUpdateDedupeCursor: input.visibleUpdateDedupeCursor,
        commentCursorPolicy: input.commentCursorPolicy,
        terminalAction: input.terminalAction,
        responseLanguage: input.responseLanguage,
    });
}
function buildExistingIssueWorkflowPublishRequest(input) {
    const target = {
        kind: "existing_issue",
        issueId: input.issueId,
    };
    if (input.preloadedIssue !== undefined) {
        target.preloadedIssue = input.preloadedIssue;
    }
    return buildTargetedWorkflowPublishRequest({
        target,
        workflowState: input.workflowState,
        visibleWorkflowState: input.visibleWorkflowState,
        appendCanonicalWorkflowStateComment: input.appendCanonicalWorkflowStateComment,
        invalidWorkflowStatePolicy: input.invalidWorkflowStatePolicy,
        publishPrecondition: input.publishPrecondition,
        workflowProjection: input.workflowProjection,
        trackerFields: input.trackerFields,
        dependencyChanges: input.dependencyChanges,
        visibleUpdate: input.visibleUpdate,
        visibleUpdateDedupeCursor: input.visibleUpdateDedupeCursor,
        commentCursorPolicy: input.commentCursorPolicy,
        terminalAction: input.terminalAction,
        responseLanguage: input.responseLanguage,
    });
}
function buildPullRequestThreadWorkflowPublishRequest(input) {
    const target = {
        kind: "pull_request_thread",
        pullRequestThreadId: input.pullRequestThreadId,
        sourceIssueId: input.sourceIssueId,
    };
    if (input.preloadedIssue !== undefined) {
        target.preloadedIssue = input.preloadedIssue;
    }
    return buildTargetedWorkflowPublishRequest({
        target,
        workflowState: input.workflowState,
        visibleWorkflowState: input.visibleWorkflowState,
        appendCanonicalWorkflowStateComment: input.appendCanonicalWorkflowStateComment,
        invalidWorkflowStatePolicy: input.invalidWorkflowStatePolicy,
        publishPrecondition: input.publishPrecondition,
        workflowProjection: input.workflowProjection,
        trackerFields: input.trackerFields,
        dependencyChanges: input.dependencyChanges,
        visibleUpdate: input.visibleUpdate,
        visibleUpdateDedupeCursor: input.visibleUpdateDedupeCursor,
        commentCursorPolicy: input.commentCursorPolicy,
        terminalAction: input.terminalAction,
        responseLanguage: input.responseLanguage,
    });
}
function buildNewIssueWorkflowPublishRequest(input) {
    return (0, publisher_state_support_1.buildWorkflowPublishRequest)({
        target: {
            kind: "new_issue",
            source: input.source,
            title: input.title,
            body: input.body,
        },
        workflowState: input.workflowState,
        visibleWorkflowState: input.visibleWorkflowState,
        appendCanonicalWorkflowStateComment: input.appendCanonicalWorkflowStateComment,
        invalidWorkflowStatePolicy: input.invalidWorkflowStatePolicy,
        workflowProjection: input.workflowProjection,
        trackerFields: input.trackerFields,
        dependencyChanges: input.dependencyChanges,
        visibleUpdate: input.visibleUpdate,
        visibleUpdateDedupeCursor: input.visibleUpdateDedupeCursor,
        commentCursorPolicy: input.commentCursorPolicy,
        newIssueFailurePolicy: input.newIssueFailurePolicy,
        responseLanguage: input.responseLanguage,
    });
}
