"use strict";
require("react");
const index$3 = require("../../../icon/react-icon/IconLeft/index.js");
const index$2 = require("../../../icon/react-icon/IconRight/index.js");
const index = require("../../../icon/react-icon/IconUp/index.js");
const index$1 = require("../../../icon/react-icon/IconDown/index.js");
const iconHover = require("../../_class/icon-hover.js");
const classNames = require("../../_util/classNames.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var TabNavIcon = function(props) {
  var _a, _b, _c, _d;
  var direction = props.direction, headerSize = props.headerSize, headerWrapperSize = props.headerWrapperSize, prefixCls = props.prefixCls, iconPos = props.iconPos, curOffset = props.currentOffset, align = props.align, rtl = props.rtl;
  var wrapHeight = headerWrapperSize.height, wrapWidth = headerWrapperSize.width;
  var headerHeight = headerSize.height, headerWidth = headerSize.width;
  var maxHeightOffset = headerHeight - wrapHeight;
  var maxWidthOffset = headerWidth - wrapWidth;
  var onChange = function(offset) {
    if (offset !== props.currentOffset) {
      props.onChange && props.onChange(offset);
    }
  };
  var handleHozClick = function(e, pos) {
    e.preventDefault();
    var nextOffset;
    if (align === "left") {
      nextOffset = pos === "left" ? curOffset - wrapWidth : curOffset + wrapWidth;
    } else {
      nextOffset = pos === "left" ? curOffset + wrapWidth : curOffset - wrapWidth;
    }
    onChange(nextOffset);
  };
  var handleVerticalClick = function(e, pos) {
    e.preventDefault();
    var nextOffset;
    if (pos === "up") {
      nextOffset = curOffset - wrapHeight;
    } else {
      nextOffset = curOffset + wrapHeight;
      if (nextOffset >= headerHeight)
        return;
    }
    onChange(nextOffset);
  };
  var disabledPrev = false;
  var disabledNext = false;
  if (align === "left") {
    disabledPrev = curOffset <= 0;
    disabledNext = direction === "vertical" ? curOffset >= maxHeightOffset : curOffset >= maxWidthOffset;
  } else {
    disabledPrev = direction === "vertical" ? curOffset >= maxHeightOffset : curOffset >= maxWidthOffset;
    disabledNext = curOffset <= 0;
  }
  return direction === "vertical" ? iconPos === "prev" ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(iconHover, {
    disabled: disabledPrev,
    prefix: prefixCls,
    className: classNames(prefixCls + "-up-icon", (_a = {}, _a[prefixCls + "-nav-icon-disabled"] = disabledPrev, _a)),
    onClick: function(e) {
      handleVerticalClick(e, "up");
    },
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index, {})
  }) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(iconHover, {
    prefix: prefixCls,
    className: classNames(prefixCls + "-down-icon", (_b = {}, _b[prefixCls + "-nav-icon-disabled"] = disabledNext, _b)),
    disabled: disabledNext,
    onClick: function(e) {
      handleVerticalClick(e, "down");
    },
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {})
  }) : iconPos === "prev" ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(iconHover, {
    prefix: prefixCls,
    disabled: disabledPrev,
    className: classNames(prefixCls + "-left-icon", (_c = {}, _c[prefixCls + "-nav-icon-disabled"] = disabledPrev, _c)),
    onClick: function(e) {
      handleHozClick(e, "left");
    },
    children: rtl ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {}) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {})
  }) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(iconHover, {
    prefix: prefixCls,
    className: classNames(prefixCls + "-right-icon", (_d = {}, _d[prefixCls + "-nav-icon-disabled"] = disabledNext, _d)),
    disabled: disabledNext,
    onClick: function(e) {
      handleHozClick(e, "right");
    },
    children: rtl ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {}) : /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {})
  });
};
const TabNavIcon$1 = TabNavIcon;
module.exports = TabNavIcon$1;
//# sourceMappingURL=tab-nav-icon.js.map
