"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const isElement = require("../../../core/utils/is-element/is-element.cjs");
const createEventHandler = require("../../../core/utils/create-event-handler/create-event-handler.cjs");
require("clsx");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const Popover = require("../../Popover/Popover.cjs");
const HoverCard_context = require("../HoverCard.context.cjs");
const defaultProps = {
  refProp: "ref"
};
const HoverCardTarget = React.forwardRef((props, ref) => {
  const { children, refProp, eventPropsWrapperName, ...others } = useProps.useProps(
    "HoverCardTarget",
    defaultProps,
    props
  );
  if (!isElement.isElement(children)) {
    throw new Error(
      "HoverCard.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported"
    );
  }
  const ctx = HoverCard_context.useHoverCardContext();
  const onMouseEnter = createEventHandler.createEventHandler(children.props.onMouseEnter, ctx.openDropdown);
  const onMouseLeave = createEventHandler.createEventHandler(children.props.onMouseLeave, ctx.closeDropdown);
  const eventListeners = { onMouseEnter, onMouseLeave };
  return /* @__PURE__ */ jsxRuntime.jsx(Popover.Popover.Target, { refProp, ref, ...others, children: React.cloneElement(
    children,
    eventPropsWrapperName ? { [eventPropsWrapperName]: eventListeners } : eventListeners
  ) });
});
HoverCardTarget.displayName = "@mantine/core/HoverCardTarget";
exports.HoverCardTarget = HoverCardTarget;
