"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageIcon = exports.Icon = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var asset_1 = require("../utils/asset");
var assets_1 = require("../constants/assets");
var Icon = function (props) {
    var spStyle = tslib_1.__assign({}, (props.style || {}));
    if (!spStyle.display) {
        spStyle.display = "inline-block";
    }
    return React.createElement("div", tslib_1.__assign({ style: spStyle, onClick: props.onClick }, props.otherProps), props.children(props.baseSize));
};
exports.Icon = Icon;
/**
 * An image icon component
 * @param props
 * @since 0.13
 */
var ImageIcon = function (props) {
    if (!props.url && !props.spriteClass) {
        return React.createElement("noscript", null);
    }
    var url;
    var spriteClass = props.spriteClass;
    if (props.url && props.url != assets_1.STD_CSS_SPRITE_RELPATH) {
        url = (0, asset_1.getAssetPath)(props.url);
        spriteClass = undefined;
    }
    if (spriteClass) {
        var spStyle = tslib_1.__assign({}, (props.style || {}));
        if (!spStyle.display) {
            spStyle.display = "inline-block";
        }
        return React.createElement("div", tslib_1.__assign({ style: spStyle, onClick: props.onClick, className: "icon ".concat(spriteClass) }, props.otherProps));
    }
    return React.createElement("img", tslib_1.__assign({ className: "icon", style: props.style, src: url, onClick: props.onClick }, props.otherProps, { onError: function (e) { return e.currentTarget.src = assets_1.ICON_ERROR; } }));
};
exports.ImageIcon = ImageIcon;
//# sourceMappingURL=icon.js.map