"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyPendingPlanningState = applyPendingPlanningState;
exports.withoutPendingPlanningState = withoutPendingPlanningState;
function applyPendingPlanningState(workflowState, mutation) {
    if (mutation.kind === "clear") {
        return withoutPendingPlanningState(workflowState);
    }
    const nextWorkflowState = {
        ...workflowState,
        pendingPlanningIntent: mutation.pendingPlanningIntent,
        pendingPlanningReason: mutation.pendingPlanningReason,
    };
    if (mutation.pendingPlanningSource === undefined) {
        delete nextWorkflowState.pendingPlanningSource;
    }
    else {
        nextWorkflowState.pendingPlanningSource = mutation.pendingPlanningSource;
    }
    return nextWorkflowState;
}
function withoutPendingPlanningState(workflowState) {
    const { pendingPlanningIntent: _pendingPlanningIntent, pendingPlanningReason: _pendingPlanningReason, pendingPlanningSource: _pendingPlanningSource, ...nextWorkflowState } = workflowState;
    return nextWorkflowState;
}
