var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/user-action/Tooltip.tsx
var Tooltip_exports = {};
__export(Tooltip_exports, {
  Tooltip: () => Tooltip
});
module.exports = __toCommonJS(Tooltip_exports);

// src/hooks/useHoverState.ts
var import_react = require("react");
var defaultUseHoverStateProps = {
  closingDelay: 200,
  isDisabled: false
};
var useHoverState = (props = void 0) => {
  const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
  const [isHovered, setIsHovered] = (0, import_react.useState)(false);
  const [timer, setTimer] = (0, import_react.useState)();
  const onMouseEnter = () => {
    if (isDisabled) {
      return;
    }
    clearTimeout(timer);
    setIsHovered(true);
  };
  const onMouseLeave = () => {
    if (isDisabled) {
      return;
    }
    setTimer(setTimeout(() => {
      setIsHovered(false);
    }, closingDelay));
  };
  (0, import_react.useEffect)(() => {
    if (timer) {
      return () => {
        clearTimeout(timer);
      };
    }
  });
  (0, import_react.useEffect)(() => {
    if (timer) {
      clearTimeout(timer);
    }
  }, [isDisabled]);
  return {
    isHovered,
    setIsHovered,
    handlers: { onMouseEnter, onMouseLeave }
  };
};

// src/components/user-action/Tooltip.tsx
var import_clsx = require("clsx");
var import_jsx_runtime = require("react/jsx-runtime");
var Tooltip = ({
  tooltip,
  children,
  animationDelay = 650,
  tooltipClassName = "",
  containerClassName = "",
  position = "bottom",
  zIndex = 10
}) => {
  const { isHovered, handlers } = useHoverState();
  const positionClasses = {
    top: `bottom-full left-1/2 -translate-x-1/2 mb-[6px]`,
    bottom: `top-full left-1/2 -translate-x-1/2 mt-[6px]`,
    left: `right-full top-1/2 -translate-y-1/2 mr-[6px]`,
    right: `left-full top-1/2 -translate-y-1/2 ml-[6px]`
  };
  const triangleSize = 6;
  const triangleClasses = {
    top: `top-full left-1/2 -translate-x-1/2 border-t-tooltip-background border-l-transparent border-r-transparent`,
    bottom: `bottom-full left-1/2 -translate-x-1/2 border-b-tooltip-background border-l-transparent border-r-transparent`,
    left: `left-full top-1/2 -translate-y-1/2 border-l-tooltip-background border-t-transparent border-b-transparent`,
    right: `right-full top-1/2 -translate-y-1/2 border-r-tooltip-background border-t-transparent border-b-transparent`
  };
  const triangleStyle = {
    top: { borderWidth: `${triangleSize}px ${triangleSize}px 0 ${triangleSize}px` },
    bottom: { borderWidth: `0 ${triangleSize}px ${triangleSize}px ${triangleSize}px` },
    left: { borderWidth: `${triangleSize}px 0 ${triangleSize}px ${triangleSize}px` },
    right: { borderWidth: `${triangleSize}px ${triangleSize}px ${triangleSize}px 0` }
  };
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
    "div",
    {
      className: (0, import_clsx.clsx)("relative inline-block", containerClassName),
      ...handlers,
      children: [
        children,
        isHovered && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
          "div",
          {
            className: (0, import_clsx.clsx)(
              `opacity-0 absolute text-xs font-semibold text-tooltip-text px-2 py-1 rounded whitespace-nowrap
           animate-tooltip-fade-in shadow-around-md bg-tooltip-background`,
              positionClasses[position],
              tooltipClassName
            ),
            style: { zIndex, animationDelay: animationDelay + "ms" },
            children: [
              tooltip,
              /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
                "div",
                {
                  className: (0, import_clsx.clsx)(`absolute w-0 h-0`, triangleClasses[position]),
                  style: { ...triangleStyle[position], zIndex: zIndex + 1 }
                }
              )
            ]
          }
        )
      ]
    }
  );
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Tooltip
});
//# sourceMappingURL=Tooltip.cjs.map