"use strict";
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("@polkadot/util");
const createClass_1 = require("../create/createClass");
function typeToConstructor(registry, type) {
    return (util_1.isString(type)
        ? createClass_1.ClassOf(registry, type)
        : type);
}
exports.typeToConstructor = typeToConstructor;
/**
 * @description takes an input map of the form `{ [string]: string | Constructor }` and returns a map of `{ [string]: Constructor }`
 */
function mapToTypeMap(registry, input) {
    return Object
        .entries(input)
        .reduce((output, [key, type]) => {
        output[key] = typeToConstructor(registry, type);
        return output;
    }, {});
}
exports.mapToTypeMap = mapToTypeMap;
