"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DoubleClickStep = void 0;
const mablscriptFind_1 = require("../mablscriptFind");
const ActionsUtils_1 = require("./ActionsUtils");
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
class DoubleClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
    static stepName = 'DoubleClick';
    static actionCode = 'double_click';
    static mablScriptStepNames = [DoubleClickStep.actionCode];
    static yamlMablScriptNames = [DoubleClickStep.stepName];
    constructor(descriptor, findAction) {
        super(DoubleClickStep.stepName, descriptor, DoubleClickStep.actionCode, findAction);
    }
    getStepName() {
        return DoubleClickStep.stepName;
    }
    static fromYaml(_stepName, stepArgs) {
        return new DoubleClickStep(stepArgs);
    }
    static fromLegacyMablscript(_args, actions) {
        const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
        const stepDescriptor = buildStepDescriptor(findAction);
        const step = new DoubleClickStep(stepDescriptor, findAction);
        step.actions = actions;
        return step;
    }
    toMablscript() {
        return `${this.findAction.toMablscript()}.double_click()`;
    }
    getInputVariables() {
        return this.findAction.getInputVariables();
    }
    stepDescription() {
        const elementDescription = this.humanizeFind();
        return `Double click on ${elementDescription}`;
    }
}
exports.DoubleClickStep = DoubleClickStep;
function buildStepDescriptor(findAction) {
    const find = findAction.toDescriptor();
    switch (find.findType) {
        case mablscriptFind_1.FindType.FIND_FIRST:
        case mablscriptFind_1.FindType.FIND_LAST:
        case mablscriptFind_1.FindType.FIND_ANY:
        case mablscriptFind_1.FindType.FIND_ONE:
            return {
                find,
                actionCode: DoubleClickStep.actionCode,
            };
        default:
            throw new Error(`Error generating step descriptor for ${DoubleClickStep.stepName}: Unexpected find type ${find.findType}`);
    }
}
