"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Icon = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("../core");
const svg_1 = require("../svg");
const utils_1 = require("../utils");
const helpers_1 = require("./helpers");
/** Displays and Svg element with a given icon. Handles icon names or definition objects. */
exports.Icon = (0, core_1.vui)((props, ref) => {
    var _a, _b, _c, _d;
    const _e = (0, core_1.omitThemingProps)(props), { className, icon, name = props.icon, rotate, scale } = _e, rest = __rest(_e, ["className", "icon", "name", "rotate", "scale"]);
    const styles = (0, core_1.useStyleConfig)('Icon', props);
    const { customIcon, src } = (0, helpers_1.getIconDetails)(name);
    const scaledSize = scale ? 16 * scale : undefined;
    const aliasedProps = (0, utils_1.filterUndefined)({
        h: scaledSize,
        transform: rotate !== undefined ? `rotate(${rotate}deg)` : undefined,
        w: scaledSize,
    });
    return ((0, jsx_runtime_1.jsx)(svg_1.Svg, Object.assign({ className: (0, utils_1.cs)('vui-icon', className), clipRule: ((_a = customIcon === null || customIcon === void 0 ? void 0 : customIcon.pathProps) === null || _a === void 0 ? void 0 : _a.clipRule) || ((_b = props === null || props === void 0 ? void 0 : props.pathProps) === null || _b === void 0 ? void 0 : _b.clipRule) || 'evenodd', display: "inline-flex", fillRule: ((_c = customIcon === null || customIcon === void 0 ? void 0 : customIcon.pathProps) === null || _c === void 0 ? void 0 : _c.fillRule) || ((_d = props === null || props === void 0 ? void 0 : props.pathProps) === null || _d === void 0 ? void 0 : _d.fillRule) || 'evenodd', flexShrink: 0, ref: ref, src: src }, styles, customIcon === null || customIcon === void 0 ? void 0 : customIcon.svgProps, aliasedProps, rest, { children: customIcon === null || customIcon === void 0 ? void 0 : customIcon.d.map((d, i) => (0, jsx_runtime_1.jsx)("path", Object.assign({ d: d, fill: "currentColor" }, customIcon.pathProps[i]), i)) })));
});
exports.Icon.displayName = 'Icon';
exports.default = exports.Icon;
//# sourceMappingURL=icon.js.map