'use strict';

var merge = require('../icon/merge.js');
var tree = require('./tree.js');

/**
* Get icon data, using prepared aliases tree
*/
function internalGetIconData(data, name, tree) {
	const icons = data.icons;
	const aliases = data.aliases || Object.create(null);
	let currentProps = {};
	function parse(name$1) {
		currentProps = merge.mergeIconData(icons[name$1] || aliases[name$1], currentProps);
	}
	parse(name);
	tree.forEach(parse);
	return merge.mergeIconData(data, currentProps);
}
/**
* Get data for icon
*/
function getIconData(data, name) {
	if (data.icons[name]) return internalGetIconData(data, name, []);
	const tree$1 = tree.getIconsTree(data, [name])[name];
	return tree$1 ? internalGetIconData(data, name, tree$1) : null;
}

exports.getIconData = getIconData;
exports.internalGetIconData = internalGetIconData;
