import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE__PopoverContent_mjs__ from "./PopoverContent.mjs";
const Popover = (0, __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.forwardRef)((props, ref)=>{
    // We'll build out the popover for simple use cases that just need a title and content.
    if (props.content) {
        const { variant, title, content, children, hideCloseButton = false, hasArrow = true, ...rest } = props;
        // ensure child is a valid react element. If we receive text only as a trigger, we wrap it
        // in a <span>.
        let c = props.children;
        const renderedChild = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].isValidElement(c) ? c : /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement("span", null, c);
        return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Popover, {
            placement: "top",
            trigger: "hover",
            ...rest
        }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverTrigger, {
            "data-testid": "popover-trigger"
        }, renderedChild), /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__PopoverContent_mjs__["default"], {
            shadow: 'md',
            ref: ref,
            "data-testid": "popover-content",
            isInPortal: props.isInPortal
        }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverArrow, {
            "data-testid": "popover-arrow"
        }), title && /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverHeader, {
            "data-testid": "popover-header"
        }, 'function' == typeof title ? title() : title), !hideCloseButton && /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverCloseButton, {
            "data-testid": "popover-closebutton"
        }), /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.PopoverBody, {
            "data-testid": "popover-body"
        }, 'function' == typeof content ? content() : content)));
    }
    // Allow caller to build their own Popover using Popover's compound components
    return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Popover, {
        placement: "top",
        trigger: "hover",
        ...props
    });
});
Popover.displayName = 'RPPopover';
/* ESM default export */ const Popover_rslib_entry_ = Popover;
export { Popover_rslib_entry_ as default };
