import * as n from "react";
import I from "../../../classnames/index.mjs";
import pe from "../../../rc-tooltip/es/Tooltip.mjs";
import fe from "../../../rc-util/es/hooks/useMergedState.mjs";
import { useZIndex as de } from "../_util/hooks/useZIndex.mjs";
import { getTransitionName as ue } from "../_util/motion.mjs";
import ve from "../_util/placements.mjs";
import { isValidElement as ye, isFragment as Ce, cloneElement as ge } from "../_util/reactNode.mjs";
import { devUseWarning as be } from "../_util/warning.mjs";
import Oe from "../_util/zindexContext.mjs";
import "../config-provider/index.mjs";
import { NoCompactStyle as Pe } from "../space/Compact.mjs";
import "../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "../../../@ant-design/cssinjs/es/StyleContext.mjs";
import "../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../rc-util/es/warning.mjs";
import "../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import Ne from "../theme/useToken.mjs";
import we from "./PurePanel.mjs";
import he from "./style/index.mjs";
import { parseColor as xe } from "./util.mjs";
import { ConfigContext as Ae } from "../config-provider/context.mjs";
var Ee = globalThis && globalThis.__rest || function(e, p) {
  var s = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && p.indexOf(o) < 0 && (s[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var a = 0, o = Object.getOwnPropertySymbols(e); a < o.length; a++)
      p.indexOf(o[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[a]) && (s[o[a]] = e[o[a]]);
  return s;
};
const x = /* @__PURE__ */ n.forwardRef((e, p) => {
  var s, o;
  const {
    prefixCls: a,
    openClassName: j,
    getTooltipContainer: D,
    overlayClassName: z,
    color: R,
    overlayInnerStyle: $,
    children: f,
    afterOpenChange: y,
    afterVisibleChange: F,
    destroyTooltipOnHide: C,
    arrow: l = !0,
    title: m,
    overlay: g,
    builtinPlacements: A,
    arrowPointAtCenter: b = !1,
    autoAdjustOverflow: H = !0
  } = e, E = !!l, [, d] = Ne(), {
    getPopupContainer: W,
    getPrefixCls: S,
    direction: k
  } = n.useContext(Ae), u = be("Tooltip"), T = n.useRef(null), V = () => {
    var t;
    (t = T.current) === null || t === void 0 || t.forceAlign();
  };
  n.useImperativeHandle(p, () => ({
    forceAlign: V,
    forcePopupAlign: () => {
      u.deprecated(!1, "forcePopupAlign", "forceAlign"), V();
    }
  })), process.env.NODE_ENV !== "production" && ([["visible", "open"], ["defaultVisible", "defaultOpen"], ["onVisibleChange", "onOpenChange"], ["afterVisibleChange", "afterOpenChange"], ["arrowPointAtCenter", "arrow={{ pointAtCenter: true }}"]].forEach((t) => {
    let [r, i] = t;
    u.deprecated(!(r in e), r, i);
  }), process.env.NODE_ENV !== "production" && u(!C || typeof C == "boolean", "usage", "`destroyTooltipOnHide` no need config `keepParent` anymore. Please use `boolean` value directly."), process.env.NODE_ENV !== "production" && u(!l || typeof l == "boolean" || !("arrowPointAtCenter" in l), "deprecated", "`arrowPointAtCenter` in `arrow` is deprecated. Please use `pointAtCenter` instead."));
  const [L, M] = fe(!1, {
    value: (s = e.open) !== null && s !== void 0 ? s : e.visible,
    defaultValue: (o = e.defaultOpen) !== null && o !== void 0 ? o : e.defaultVisible
  }), O = !m && !g && m !== 0, U = (t) => {
    var r, i;
    M(O ? !1 : t), O || ((r = e.onOpenChange) === null || r === void 0 || r.call(e, t), (i = e.onVisibleChange) === null || i === void 0 || i.call(e, t));
  }, X = n.useMemo(() => {
    var t, r;
    let i = b;
    return typeof l == "object" && (i = (r = (t = l.pointAtCenter) !== null && t !== void 0 ? t : l.arrowPointAtCenter) !== null && r !== void 0 ? r : b), A || ve({
      arrowPointAtCenter: i,
      autoAdjustOverflow: H,
      arrowWidth: E ? d.sizePopupArrow : 0,
      borderRadius: d.borderRadius,
      offset: d.marginXXS,
      visibleFirst: !0
    });
  }, [b, l, A, d]), P = n.useMemo(() => m === 0 ? m : g || m || "", [g, m]), Z = /* @__PURE__ */ n.createElement(Pe, null, typeof P == "function" ? P() : P), {
    getPopupContainer: B,
    placement: Y = "top",
    mouseEnterDelay: q = 0.1,
    mouseLeaveDelay: G = 0.1,
    overlayStyle: J,
    rootClassName: K
  } = e, _ = Ee(e, ["getPopupContainer", "placement", "mouseEnterDelay", "mouseLeaveDelay", "overlayStyle", "rootClassName"]), c = S("tooltip", a), Q = S(), ee = e["data-popover-inject"];
  let N = L;
  !("open" in e) && !("visible" in e) && O && (N = !1);
  const w = ye(f) && !Ce(f) ? f : /* @__PURE__ */ n.createElement("span", null, f), v = w.props, oe = !v.className || typeof v.className == "string" ? I(v.className, j || `${c}-open`) : v.className, [te, ne, re] = he(c, !ee), h = xe(c, R), ae = h.arrowStyle, le = Object.assign(Object.assign({}, $), h.overlayStyle), ie = I(z, {
    [`${c}-rtl`]: k === "rtl"
  }, h.className, K, ne, re), [se, me] = de("Tooltip", _.zIndex), ce = /* @__PURE__ */ n.createElement(pe, Object.assign({}, _, {
    zIndex: se,
    showArrow: E,
    placement: Y,
    mouseEnterDelay: q,
    mouseLeaveDelay: G,
    prefixCls: c,
    overlayClassName: ie,
    overlayStyle: Object.assign(Object.assign({}, ae), J),
    getTooltipContainer: B || D || W,
    ref: T,
    builtinPlacements: X,
    overlay: Z,
    visible: N,
    onVisibleChange: U,
    afterVisibleChange: y ?? F,
    overlayInnerStyle: le,
    arrowContent: /* @__PURE__ */ n.createElement("span", {
      className: `${c}-arrow-content`
    }),
    motion: {
      motionName: ue(Q, "zoom-big-fast", e.transitionName),
      motionDeadline: 1e3
    },
    destroyTooltipOnHide: !!C
  }), N ? ge(w, {
    className: oe
  }) : w);
  return te(/* @__PURE__ */ n.createElement(Oe.Provider, {
    value: me
  }, ce));
});
process.env.NODE_ENV !== "production" && (x.displayName = "Tooltip");
x._InternalPanelDoNotUseOrYouWillBeFired = we;
const eo = x;
export {
  eo as default
};
