import { cdnUrl } from "../core/consts.js";
import cache from "../icons/cache.js";
import { IconReplacements } from "../icons/iconReplacements.js";

//#region src/icon/helpers.ts
const PREFIX_MAP = {
	con: "con",
	bra: "brand"
};
/** Optimized prefix normalization with constant time lookup */
function normalizeIconPrefix(prefix) {
	return PREFIX_MAP[prefix] || (prefix.startsWith("ui") ? "fa" : prefix);
}
/**
* 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(iconName) {
	if (!iconName) return {};
	const icon = IconReplacements?.[iconName] ?? iconName;
	if (!cache.has(icon)) return { src: `${cdnUrl}/common/icons/ui/${normalizeIconPrefix(icon.slice(0, 3))}/${icon}.svg` };
	const { details, name, pathProps = [], svgProps = {} } = cache.get(icon);
	const [width, height, , , d] = details;
	const viewBox = `0 0 ${width} ${height}`;
	return { customIcon: {
		d: Array.isArray(d) ? d : [d],
		pathProps: Array.isArray(pathProps) ? pathProps : [pathProps],
		svgProps: {
			"data-name": name,
			viewBox,
			...svgProps
		}
	} };
}

//#endregion
export { getIconDetails };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=helpers.js.map