"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIconDetails = getIconDetails;
const core_1 = require("../core");
const icons_1 = require("../icons");
/**
 * Returns an object with either 'src' or 'customIcon', depending on whether the provided icon is:
 * - not in library:    'src' as CDN url
 * - in library:            'customIcon' as icon definition object
 */
function getIconDetails(icon) {
    if (!icon)
        return {};
    // Compute CDN url if icon is not in library cache
    if (!icons_1.iconsCache.has(icon)) {
        const prefix = icon.slice(0, 3);
        return {
            src: `${core_1.cdnUrl}/common/icons/ui/${prefix}/${icon}.svg`,
        };
    }
    // Compute relevant properties based on icon definition from the library
    const { details, name, pathProps = [], svgProps = {} } = icons_1.iconsCache.get(icon);
    const [width, height, , , d] = details;
    const viewBox = `0 0 ${width} ${height}`;
    const customIcon = {
        d: Array.isArray(d) ? d : [d],
        pathProps: Array.isArray(pathProps) ? pathProps : [pathProps],
        svgProps: Object.assign({ 'data-name': name, viewBox }, svgProps),
    };
    return {
        customIcon,
    };
}
//# sourceMappingURL=helpers.js.map