import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-BJnb9o5c.js';
import { r as renderIcon } from './renderIcon-C6twJSqH.js';
import { Label as Label$1 } from './primitives/Label.js';
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './primitives/Tooltip.js';
import { c as createLucideIcon } from './createLucideIcon-C8ycilSN.js';
import { P as Popover } from './Popover-Cco_6txS.js';
import { B as Button } from './Button-BCWJgHDy.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 = /* @__PURE__ */ 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;
      if (helpIconProps.popoverProps) {
        const { title, description, helpLinkProps } = helpIconProps.popoverProps;
        return /* @__PURE__ */ jsxs(Popover, { trigger: iconElement, children: [
          title && /* @__PURE__ */ jsx(Popover.Title, { children: title }),
          description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }),
          helpLinkProps && /* @__PURE__ */ jsx(
            Button,
            {
              variant: "link",
              size: "sm",
              className: "mt-1 h-auto self-start p-0",
              ...helpLinkProps,
              href: helpLinkProps.href
            }
          )
        ] });
      }
      if (helpIconProps.tooltipProps?.content) {
        const side = SIDE_MAP[helpIconProps.tooltipProps.position ?? "auto"] ?? "top";
        return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
          /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: iconElement }),
          /* @__PURE__ */ jsx(TooltipContent, { side, children: helpIconProps.tooltipProps.content })
        ] }) });
      }
      return iconElement;
    };
    return /* @__PURE__ */ jsxs(Label$1, { ref, className: cn(className), ...otherProps, children: [
      children,
      required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" }),
      renderHelpIcon()
    ] });
  }
);
Label.displayName = "Label";

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