import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-DdHUxIdC.js';
import { r as renderIcon } from './renderIcon-tlvMyboj.js';
import { Label as Label$1 } from './primitives/Label.js';
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './primitives/Tooltip.js';
import { P as Popover } from './Popover-BFMrtVPq.js';
import { B as Button } from './Button-Q7MPG6ph.js';
import { c as createLucideIcon } from './createLucideIcon-C8ycilSN.js';

/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
  ["path", { d: "M12 17h.01", key: "p32p05" }]
];
const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode);

const SIDE_MAP = {
    top: "top",
    bottom: "bottom",
    left: "left",
    right: "right",
    auto: "top",
};

const Label = forwardRef(({ required, helpIconProps, className, children, ...otherProps }, ref) => {
    const helpIcon = helpIconProps?.icon ?? CircleQuestionMark;
    const iconElement = (jsx("span", { className: cn("inline-flex cursor-help text-muted-foreground transition-colors hover:text-foreground", helpIconProps?.onClick && "cursor-pointer", helpIconProps?.className), onClick: helpIconProps?.onClick, children: renderIcon(helpIcon, "size-3.5") }));
    const renderHelpIcon = () => {
        if (!helpIconProps)
            return null;
        // Popover mode
        if (helpIconProps.popoverProps) {
            const { title, description, helpLinkProps } = helpIconProps.popoverProps;
            return (jsxs(Popover, { trigger: iconElement, children: [title && jsx(Popover.Title, { children: title }), description && (jsx("p", { className: "text-sm text-muted-foreground", children: description })), helpLinkProps && (jsx(Button, { variant: "link", size: "sm", className: "mt-1 h-auto self-start p-0", ...helpLinkProps, href: helpLinkProps.href }))] }));
        }
        // Tooltip mode
        if (helpIconProps.tooltipProps?.content) {
            const side = SIDE_MAP[helpIconProps.tooltipProps.position ?? "auto"] ?? "top";
            return (jsx(TooltipProvider, { children: jsxs(Tooltip, { children: [jsx(TooltipTrigger, { asChild: true, children: iconElement }), jsx(TooltipContent, { side: side, children: helpIconProps.tooltipProps.content })] }) }));
        }
        // Icon only (with optional onClick)
        return iconElement;
    };
    return (jsxs(Label$1, { ref: ref, className: cn(className), ...otherProps, children: [children, required && (jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" })), renderHelpIcon()] }));
});
Label.displayName = "Label";

export { Label as L };
//# sourceMappingURL=Label-BVy4hy9Z.js.map
