import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { forwardRef } from "react";
import { bem } from "../@utils/bem.js";
import { UiTag as UiTagComponent } from "../UiTag/UiTag.js";
const { e } = bem("gd-ui-kit-tags");
export const UiTag = forwardRef(function UiTag({ tag, maxWidth, isDeletable, isDisabled, size, deleteLabel, onDelete, onClick }, ref) {
    const canBeDeleted = isDeletable && (tag.isDeletable ?? true);
    const isClickable = onClick !== undefined;
    return (_jsx("div", { className: e("tag"), style: { maxWidth }, "data-tag-id": tag.id, tabIndex: -1, "aria-label": tag.label, children: _jsx(UiTagComponent, { ref: isClickable ? ref : undefined, labelAs: isClickable ? "button" : "span", label: `${tag.label}`, size: size, iconBefore: tag.iconBefore, isDeletable: canBeDeleted, isDisabled: isDisabled, accessibilityConfig: {
                ariaLabel: tag.label,
                deleteAriaLabel: `${deleteLabel ?? "Delete"} ${tag.label}`,
            }, onDelete: canBeDeleted
                ? (e) => {
                    onDelete?.(tag);
                    e.stopPropagation();
                }
                : undefined, onClick: isClickable
                ? (e) => {
                    onClick(tag);
                    e.stopPropagation();
                }
                : undefined }) }));
});
