"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isIfConditionStep = isIfConditionStep;
exports.isGetVariableValue = isGetVariableValue;
exports.isElseIfConditionStep = isElseIfConditionStep;
exports.getOptionalComparisonType = getOptionalComparisonType;
exports.isComparisonConditionDescriptor = isComparisonConditionDescriptor;
exports.isFindEmailDescriptor = isFindEmailDescriptor;
exports.isFindCookieDescriptor = isFindCookieDescriptor;
const IfConditionStep_1 = require("@mablhq/test-model/steps/IfConditionStep");
const ElseIfConditionStep_1 = require("@mablhq/test-model/steps/ElseIfConditionStep");
const ConditionDescriptor_1 = require("@mablhq/test-model/types/ConditionDescriptor");
const mablscriptFind_1 = require("@mablhq/test-model/mablscriptFind");
function isIfConditionStep(step) {
    return step?.getStepName() === IfConditionStep_1.IfConditionStep.stepName;
}
function isGetVariableValue(value) {
    return value?.variable && value?.name === 'get_variable_value';
}
function isElseIfConditionStep(step) {
    return step?.getStepName() === ElseIfConditionStep_1.ElseIfConditionStep.stepName;
}
function getOptionalComparisonType(descriptor) {
    if (descriptor === undefined) {
        return undefined;
    }
    switch (descriptor.conditionType) {
        case ConditionDescriptor_1.ConditionType.Comparison:
            return descriptor.comparisonType;
        case ConditionDescriptor_1.ConditionType.Presence:
            return descriptor.presenceType;
        case ConditionDescriptor_1.ConditionType.Truthy:
            return 'equals';
        case ConditionDescriptor_1.ConditionType.AIPrompt:
            return 'ai_prompt';
        default:
            return undefined;
    }
}
function isComparisonConditionDescriptor(value) {
    return value?.conditionType === ConditionDescriptor_1.ConditionType.Comparison;
}
function isFindEmailDescriptor(value) {
    return (value && value.findType === mablscriptFind_1.FindType.FIND_EMAIL);
}
function isFindCookieDescriptor(value) {
    return (value && value.findType === mablscriptFind_1.FindType.FIND_COOKIE);
}
