"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get getCellType () {
        return _getItem;
    },
    get getRegisteredCellTypeNames () {
        return getNames;
    },
    get getRegisteredCellTypes () {
        return getValues;
    },
    get hasCellType () {
        return hasItem;
    },
    get registerCellType () {
        return _register;
    }
});
const _staticRegister = require("../utils/staticRegister");
const _errors = require("../helpers/errors");
const _registry = require("../editors/registry");
const _registry1 = require("../renderers/registry");
const _registry2 = require("../validators/registry");
const { register, getItem, hasItem, getNames, getValues } = (0, _staticRegister.staticRegister)('cellTypes');
/**
 * Retrieve cell type object.
 *
 * @param {string} name Cell type identification.
 * @returns {object} Returns cell type object.
 */ function _getItem(name) {
    if (!hasItem(name)) {
        (0, _errors.throwWithCause)(`You declared cell type "${name}" as a string that is not mapped to a known object.
                 Cell type must be an object or a string mapped to an object registered by
                 "Handsontable.cellTypes.registerCellType" method`);
    }
    return getItem(name);
}
/**
 * Register cell type under specified name.
 *
 * @param {string} name Cell type identification.
 * @param {object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
 */ function _register(name, type) {
    if (typeof name !== 'string') {
        type = name;
        name = type.CELL_TYPE;
    }
    const { editor, renderer, validator } = type;
    if (editor) {
        (0, _registry.registerEditor)(name, editor);
    }
    if (renderer) {
        (0, _registry1.registerRenderer)(name, renderer);
    }
    if (validator) {
        (0, _registry2.registerValidator)(name, validator);
    }
    register(name, type);
}
