"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportTypeResolver = void 0;
const importType_enum_1 = require("../models/importType.enum");
const options_resolver_1 = require("../options-resolver");
/**
 * Import type resolver
 */
class ImportTypeResolver {
    /**
     * Resolves an import type provided by the user.
     * @param {CreateProfileOptions} options - Command options.
     * @param {string} altText - Alternative text.
     * @param {string} altKey - Alternative key.
     * @returns {Promise<number>}
     */
    async resolve(options, altText, altKey) {
        // interpret other options, default to private key profile in case of conflict
        if ('privateKey' in options || 'mnemonic' in options) {
            if (options.privateKey) {
                return importType_enum_1.ImportType.PrivateKey;
            }
            if (options.mnemonic) {
                return importType_enum_1.ImportType.Mnemonic;
            }
        }
        if (options.ledger) {
            return importType_enum_1.ImportType.Ledger;
        }
        if (options.hd) {
            return importType_enum_1.ImportType.Mnemonic;
        }
        const choices = Object.keys(importType_enum_1.ImportType)
            .filter((key) => Number.isNaN(parseFloat(key)))
            .map((string) => ({
            title: string,
            value: importType_enum_1.ImportType[string],
        }));
        const value = +(await (0, options_resolver_1.OptionsChoiceResolver)(options, altKey ? altKey : 'importType', altText ? altText : 'Select an import type:', choices, 'select', undefined));
        return value;
    }
}
exports.ImportTypeResolver = ImportTypeResolver;
