"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EchoStep = void 0;
const mablscriptFind_1 = require("../mablscriptFind");
const MablAction_1 = require("../MablAction");
const MablStepV2_1 = require("../MablStepV2");
const MablSymbol_1 = require("../MablSymbol");
class EchoStep extends MablStepV2_1.MablStepV2 {
    static stepName = 'Echo';
    static actionCode = 'echo';
    static mablScriptStepNames = [EchoStep.actionCode];
    static yamlMablScriptNames = [EchoStep.stepName];
    echoValue;
    constructor(descriptor) {
        super(EchoStep.stepName, descriptor, EchoStep.actionCode);
        this.echoValue = descriptor.value;
    }
    static getStepName() {
        return EchoStep.stepName;
    }
    getStepName() {
        return EchoStep.stepName;
    }
    static fromYaml(_stepName, stepArgs) {
        if (stepArgs.value) {
            stepArgs.value = (0, MablSymbol_1.isMablSymbolObject)(stepArgs.value)
                ? (0, MablSymbol_1.formatSymbol)(stepArgs.value)
                : stepArgs.value.toString();
        }
        return new EchoStep(stepArgs);
    }
    static fromLegacyMablscript(args, _actions) {
        const value = (0, MablSymbol_1.isMablSymbolObject)(args[0])
            ? (0, MablSymbol_1.formatSymbol)(args[0])
            : args[0]?.toString();
        const stepDescriptor = {
            actionCode: EchoStep.actionCode,
            value,
        };
        const step = new EchoStep(stepDescriptor);
        step.actions = _actions;
        return step;
    }
    toMablscript() {
        return `echo("${(0, mablscriptFind_1.escapeMablscriptString)(this.echoValue)}")`;
    }
    getInputVariables() {
        return MablAction_1.MablAction.findUniqueVariableReferencesInValue(this.echoValue);
    }
    stepDescription() {
        return `Echo: "${this.echoValue}"`;
    }
    static create(descriptor) {
        descriptor.id = descriptor.id ?? MablStepV2_1.MablStepV2.generateStepId();
        return new EchoStep(descriptor);
    }
}
exports.EchoStep = EchoStep;
