'use client';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useCSSPropsPolyfill, useGDS } from "../hooks/index.js";
import { cn, getCSSPropsAttributes, splitProps, trimReactNode } from "../utils/index.js";
import { renderAddon } from "./base/Addon.js";
import { LabelMeta } from "./Label.meta.js";
export function Label({ variant, size, description, addon, className, style, children, ...props }) {
    useGDS();
    const { rootProps, nestedProps } = splitProps(props);
    const [cssPropsPolyfillRef, cssPropsPolyfillAttributes] = useCSSPropsPolyfill(LabelMeta, {
        variant,
        size,
    });
    const NestedElement = (props.htmlFor ? 'label' : 'span');
    const { content: descriptionContent, className: descriptionClassName, ...descriptionProps } = typeof description === 'object' && description !== null && 'content' in description
        ? description
        : { content: description };
    return (_jsxs("span", { ref: cssPropsPolyfillRef, className: cn('gds-label root-flex flex-col gap-1 u:wrap-anywhere', className), ...getCSSPropsAttributes(LabelMeta, { variant, size }, style), ...cssPropsPolyfillAttributes, ...rootProps, children: [children ? (_jsxs("span", { className: `
            truncate whitespace-nowrap
            @prop-variant-primary/label:text-default
            @prop-variant-secondary/label:text-muted
            @prop-size-small/label:text-12
            @prop-size-medium/label:text-14
            @prop-size-large/label:text-16
          `, children: [_jsx(NestedElement, { className: "nested/label-ref inline whitespace-normal", ...nestedProps, children: trimReactNode(children) }), addon ? (_jsxs(_Fragment, { children: ["\u2060", _jsx("span", { className: `
                  gds-addon root-flex/inline items-center justify-center align-top
                  u:ms-(--gap-addon) u:h-lh u:min-w-(--gds-addon-size) u:shrink-0
                  u:@prop-size-small/label:addon-small
                  u:@prop-size-medium/label:addon-small
                  u:@prop-size-large/label:addon-medium
                `, children: renderAddon(addon) })] })) : null] })) : null, descriptionContent ? (_jsx("span", { className: cn(`u:@prop-variant-primary/label:text-muted
            u:@prop-variant-secondary/label:text-subtle
            u:@prop-size-small/label:text-12
            u:@prop-size-medium/label:text-12
            u:@prop-size-large/label:text-14`, descriptionClassName), ...descriptionProps, children: descriptionContent })) : null] }));
}
//# sourceMappingURL=Label.js.map