import {
  $4e3b923658d69c60$export$28c660c63b792dea,
  $4e3b923658d69c60$export$8c610744efcf8a1d,
  $f645667febf57a63$export$35a3bebf7ef2d934
} from "./chunk-YNY3GJXN.js";
import {
  __name
} from "./chunk-MM7DTO55.js";

// src/components/components/tooltip/WithTooltip.tsx
import React, { useCallback, useState } from "react";
import { deprecate } from "storybook/internal/client-logger";
import { convertToReactAriaPlacement } from "storybook/internal/components";
var WithTooltip = /* @__PURE__ */ __name(({
  triggerOnFocusOnly = false,
  placement: placementProp = "top",
  offset = 8,
  tooltip,
  children,
  defaultVisible,
  startOpen,
  delayShow = 400,
  delayHide = 200,
  visible,
  onVisibleChange,
  ...props
}) => {
  const placement = convertToReactAriaPlacement(placementProp);
  const child = React.Children.only(children);
  if (startOpen !== void 0) {
    deprecate("The `startOpen` prop is deprecated. Please use `defaultVisible` instead.");
  }
  const [isOpen, setIsOpen] = useState(defaultVisible ?? startOpen ?? false);
  const onOpenChange = useCallback(
    (isOpen2) => {
      setIsOpen(isOpen2);
      onVisibleChange?.(isOpen2);
    },
    [onVisibleChange]
  );
  return React.createElement(
    $4e3b923658d69c60$export$8c610744efcf8a1d,
    {
      delay: delayShow,
      closeDelay: delayHide,
      isOpen: visible ?? isOpen,
      onOpenChange,
      trigger: triggerOnFocusOnly ? "focus" : void 0,
      ...props
    },
    React.createElement($f645667febf57a63$export$35a3bebf7ef2d934, null, React.cloneElement(child, { "aria-describedby": null })),
    React.createElement(
      $4e3b923658d69c60$export$28c660c63b792dea,
      {
        "data-testid": "tooltip",
        placement,
        offset,
        onOpenChange,
        style: { outlineColor: "transparent" },
        ...props
      },
      tooltip
    )
  );
}, "WithTooltip");
export {
  WithTooltip
};
