import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-BJnb9o5c.js';
import { Kbd as Kbd$1, KbdGroup as KbdGroup$1 } from './primitives/Kbd.js';
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './primitives/Tooltip.js';

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

const Kbd = forwardRef(
  ({ tooltipProps, className, ...otherProps }, ref) => {
    if (!tooltipProps?.content) {
      return /* @__PURE__ */ jsx(Kbd$1, { ref, className: cn(className), ...otherProps });
    }
    const side = SIDE_MAP[tooltipProps.position ?? "auto"] ?? "top";
    return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
      /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
        Kbd$1,
        {
          ref,
          tabIndex: 0,
          className: cn("pointer-events-auto", className),
          ...otherProps
        }
      ) }),
      /* @__PURE__ */ jsx(TooltipContent, { side, children: tooltipProps.content })
    ] }) });
  }
);
Kbd.displayName = "Kbd";
const KbdGroup = KbdGroup$1;
const KbdNamespace = Object.assign(Kbd, { Group: KbdGroup });

export { KbdNamespace as K };
//# sourceMappingURL=Kbd-CAIAs4OO.js.map
