"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 getRegisteredRendererNames () {
        return getNames;
    },
    get getRegisteredRenderers () {
        return getValues;
    },
    get getRenderer () {
        return _getItem;
    },
    get hasRenderer () {
        return hasItem;
    },
    get registerRenderer () {
        return _register;
    },
    get rendererFactory () {
        return rendererFactory;
    }
});
const _staticRegister = require("../utils/staticRegister");
const _errors = require("../helpers/errors");
const { register, getItem, hasItem, getNames, getValues } = (0, _staticRegister.staticRegister)('renderers');
/**
 * Retrieve renderer function.
 *
 * @param {string} name Renderer identification.
 * @returns {Function} Returns renderer function.
 */ function _getItem(name) {
    if (typeof name === 'function') {
        return name;
    }
    if (!hasItem(name)) {
        (0, _errors.throwWithCause)(`No registered renderer found under "${name}" name`);
    }
    return getItem(name);
}
/**
 * Register renderer under its alias.
 *
 * @param {string|Function} name Renderer's alias or renderer function with its descriptor.
 * @param {Function} [renderer] Renderer function.
 */ function _register(name, renderer) {
    if (typeof name !== 'string') {
        renderer = name;
        name = renderer.RENDERER_TYPE;
    }
    register(name, renderer);
}
const rendererFactory = (callback)=>{
    return (instance, td, row, column, prop, value, cellProperties)=>{
        return callback({
            instance,
            td,
            row,
            column,
            prop,
            value,
            cellProperties
        });
    };
};
