"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildRecurringSyncPlanSpec = buildRecurringSyncPlanSpec;
const publisher_1 = require("../../workflows/publisher");
const recurring_1 = require("../../workflows/recurring");
const config_publish_spec_support_1 = require("./config-publish-spec-support");
function buildRecurringSyncPlanSpec(input) {
    if (!(0, recurring_1.isRecurringParentWorkflowState)(input.workflowState)) {
        return {
            kind: "noop",
            decisionKind: "recurring_sync",
            targetIssueId: input.issue.id,
        };
    }
    const nextProjection = (0, recurring_1.resolveRecurringProjection)({
        snapshot: input.issue.workflowState,
        workflowState: input.workflowState,
    });
    return (0, config_publish_spec_support_1.buildServiceRuntimeProjectedPublishSpec)({
        decisionKind: "recurring_sync",
        issue: input.issue,
        responseLanguage: input.responseLanguage,
        workflowState: input.workflowState,
        scannedInputCursor: null,
        commentCursorPolicyMode: publisher_1.WORKFLOW_COMMENT_CURSOR_POLICY_MODES.preserve,
        workflowLabels: input.workflowLabels,
        nextWorkflowSnapshot: nextProjection.snapshot,
        previousWorkflowState: input.workflowState,
        nextWorkflowState: input.workflowState,
        previousNeedsHumanReason: input.currentNeedsHumanReason,
        nextNeedsHumanReason: input.currentNeedsHumanReason,
    });
}
