"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.areWorkflowSelectionsEqual = areWorkflowSelectionsEqual;
exports.hasWorkflowSelectionOrTemplateChanged = hasWorkflowSelectionOrTemplateChanged;
const template_bindings_1 = require("./template-bindings");
function areWorkflowSelectionsEqual(left, right) {
    if (left.mode !== right.mode) {
        return false;
    }
    if (left.mode === "auto" ||
        left.mode === "auto_select" ||
        left.mode === "no_template") {
        return true;
    }
    return right.mode === "template" && left.templatePath === right.templatePath;
}
function hasWorkflowSelectionOrTemplateChanged(previousBinding, nextBinding) {
    if (previousBinding === null || previousBinding === undefined) {
        return nextBinding !== null && nextBinding !== undefined;
    }
    if (nextBinding === null || nextBinding === undefined) {
        return true;
    }
    return (!areWorkflowSelectionsEqual(previousBinding.selector, nextBinding.selector) ||
        (0, template_bindings_1.getWorkflowTemplateName)(previousBinding) !==
            (0, template_bindings_1.getWorkflowTemplateName)(nextBinding) ||
        (0, template_bindings_1.getWorkflowTemplateDigest)(previousBinding) !==
            (0, template_bindings_1.getWorkflowTemplateDigest)(nextBinding));
}
