'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var reactI18next = require('react-i18next');
var utils = require('./utils-CTr7wn5d.js');
var renderIcon = require('./renderIcon-fLF3odqg.js');
var primitives_Badge = require('./primitives/Badge.js');
var x = require('./x-Brw3FJst.js');

const SIZE_CONFIG = {
    sm: {
        iconPl: "pl-1",
        iconPr: "pr-1",
        dismissPr: "pr-0.5",
        btnSize: "size-3",
        iconSize: "size-2",
    },
    default: {
        iconPl: "pl-1.5",
        iconPr: "pr-1.5",
        dismissPr: "pr-1",
        btnSize: "size-3.5",
        iconSize: "size-2.5",
    },
    lg: {
        iconPl: "pl-2",
        iconPr: "pr-2",
        dismissPr: "pr-1",
        btnSize: "size-4.5",
        iconSize: "size-3",
    },
};
const INDICATOR_COLORS = {
    default: "bg-primary",
    secondary: "bg-muted-foreground",
    destructive: "bg-destructive",
    blue: "bg-blue-600",
    green: "bg-green-600",
    amber: "bg-amber-400",
    red: "bg-red-600",
    purple: "bg-purple-700",
    pink: "bg-pink-600",
    teal: "bg-teal-600",
    gray: "bg-gray-400",
};

const Badge = React.forwardRef(({ variant = "default", size = "default", shape = "pill", label, icon, iconPosition = "left", indicator, onDismiss, disabled = false, className, asChild = false, children, ...otherProps }, ref) => {
    const { t } = reactI18next.useTranslation();
    if (asChild) {
        return (jsxRuntime.jsx(primitives_Badge.Badge, { ref: ref, asChild: true, variant: variant, size: size, shape: shape, className: className, ...otherProps, children: children }));
    }
    const renderLabel = label || children;
    const iconElement = icon ? renderIcon.renderIcon(icon) : null;
    const hasDismiss = !!onDismiss && !disabled;
    return (jsxRuntime.jsxs(primitives_Badge.Badge, { ref: ref, variant: variant, size: size, shape: shape, className: utils.cn(disabled && "opacity-50 pointer-events-none", icon && iconPosition === "left" && SIZE_CONFIG[size].iconPl, icon && iconPosition === "right" && SIZE_CONFIG[size].iconPr, hasDismiss && SIZE_CONFIG[size].dismissPr, className), ...otherProps, children: [indicator && (jsxRuntime.jsx("span", { "aria-hidden": "true", className: utils.cn("size-1.5 shrink-0 rounded-full", INDICATOR_COLORS[indicator]) })), iconPosition === "left" && iconElement, renderLabel, iconPosition === "right" && iconElement, onDismiss && !disabled && (jsxRuntime.jsx("button", { type: "button", "aria-label": t("neetoatoms.badge.dismiss", "Dismiss"), onClick: onDismiss, className: utils.cn("inline-flex shrink-0 items-center justify-center rounded-full bg-current/15 transition-[background-color,opacity] hover:bg-current/25 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1", SIZE_CONFIG[size].btnSize), children: jsxRuntime.jsx(x.X, { className: SIZE_CONFIG[size].iconSize }) }))] }));
});
Badge.displayName = "Badge";

exports.Badge = Badge;
//# sourceMappingURL=Badge-_-PRf6aq.js.map
