"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Button = void 0;
const react_1 = __importDefault(require("react"));
const styled_1 = __importDefault(require("@emotion/styled"));
const Icon = ({ fontSize, className, ariaHidden }) => {
    const I = styled_1.default.i({ fontSize });
    return react_1.default.createElement(I, { className: className, "aria-hidden": ariaHidden });
};
/**
 * Primary UI component for user interaction
 */
const Button = ({ primary, size = "medium", backgroundColor, label, nobg, navbar = false, icon, secondary, color, imgSrc, iconSize, className, children, disabled, iconOnly, type, form, ...props }) => {
    const mode = primary && !navbar
        ? "on-button--primary"
        : secondary && !navbar
            ? "on-button--secondary"
            : nobg && !navbar
                ? "on-no-background"
                : !navbar
                    ? "on-button--default"
                    : "on-button--navbar";
    const iconWithText = icon && label && !iconOnly
        ? "icon-text"
        : imgSrc && label
            ? "img-icon-text"
            : null;
    const fontIcon = icon
        ? react_1.default.createElement(Icon, { fontSize: iconSize, className: icon, ariaHidden: "true" })
        : null;
    const imgIcon = imgSrc
        ? (react_1.default.createElement("img", { style: { width: iconSize }, src: imgSrc, alt: label, "aria-hidden": "true" }))
        : null;
    return (react_1.default.createElement("button", { form: form, disabled: disabled, role: "button", type: type ? type : "button", className: [
            "on-button",
            `on-button--${size}`,
            mode,
            iconWithText,
            `${className}`,
        ].join(" "), style: { backgroundColor, color }, "aria-label": label, ...props },
        imgIcon,
        fontIcon,
        iconOnly ? null : label,
        children));
};
exports.Button = Button;
