import { useRef, useEffect } from "react";
import isEqualWith_1 from "../../../../../../../lodash@4.17.21/node_modules/lodash/isEqualWith.js";
import cs from "../../_util/classNames.js";
import { getRectDiff } from "../utils.js";
import throttleByRaf from "../../_util/throttleByRaf.js";
import { jsx } from "../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var getInkStyle = function(direction, curTitle, headerRef) {
  var style = {};
  if (curTitle) {
    var diffStyle = getRectDiff(curTitle, headerRef);
    if (direction === "vertical") {
      style = {
        top: diffStyle.top + "px",
        height: curTitle.offsetHeight + "px",
        left: "",
        width: ""
      };
    } else {
      style = {
        left: diffStyle.left + "px",
        width: curTitle.offsetWidth + "px",
        top: "",
        height: ""
      };
    }
  }
  return style;
};
var TabInk = function(_a) {
  var _b;
  var prefixCls = _a.prefixCls, animation = _a.animation, disabled = _a.disabled, direction = _a.direction, getTitleRef = _a.getTitleRef, activeTab = _a.activeTab, getHeaderRef = _a.getHeaderRef;
  var inkRef = useRef();
  var inkStyleRef = useRef();
  useEffect(function() {
    var setInkStyle = throttleByRaf(function() {
      var newStyle = getInkStyle(direction, getTitleRef(activeTab), getHeaderRef("headerRef").current);
      if (newStyle && !isEqualWith_1(inkStyleRef.current, newStyle)) {
        inkStyleRef.current = newStyle;
        Object.keys(newStyle).forEach(function(key) {
          inkRef.current.style[key] = newStyle[key];
        });
      }
    });
    setInkStyle();
    return function() {
      setInkStyle.cancel && setInkStyle.cancel();
    };
  });
  return /* @__PURE__ */ jsx("div", {
    className: cs(prefixCls + "-header-ink", (_b = {}, _b[prefixCls + "-header-ink-no-animation"] = !animation, _b[prefixCls + "-header-ink-disabled"] = disabled, _b)),
    ref: inkRef
  });
};
const TabInk$1 = TabInk;
export {
  TabInk$1 as default
};
//# sourceMappingURL=tab-ink.js.map
