var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  default: () => stdin_default
});
module.exports = __toCommonJS(stdin_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_swiper = __toESM(require("../swiper"));
var import_ConfigProviderContext = __toESM(require("../config-provider/ConfigProviderContext"));
const TabsContent = (props) => {
  const {
    prefixCls,
    createNamespace
  } = (0, import_react.useContext)(import_ConfigProviderContext.default);
  const [bem] = createNamespace("tabs", prefixCls);
  const swipeRef = (0, import_react.useRef)();
  const innerEffect = (0, import_react.useRef)(false);
  const {
    animated,
    swipeable,
    duration
  } = props;
  const renderChildren = () => {
    if (animated || swipeable) {
      return /* @__PURE__ */ import_react.default.createElement(import_swiper.default, {
        ref: swipeRef,
        loop: false,
        autoplay: false,
        allowTouchMove: swipeable,
        className: (0, import_classnames.default)(bem("track")),
        autoplayInterval: +duration,
        indicator: false,
        onIndexChange: (idx) => {
          var _a;
          if (innerEffect.current) {
            innerEffect.current = false;
            return;
          }
          (_a = props.onChange) == null ? void 0 : _a.call(props, idx);
        }
      }, import_react.default.Children.map(props.children, (child) => /* @__PURE__ */ import_react.default.createElement(import_swiper.default.Item, {
        style: {
          cursor: !swipeable ? "auto" : void 0
        },
        className: (0, import_classnames.default)(bem("pane-wrapper"))
      }, child)));
    }
    return props.children;
  };
  const swipeToCurrentTab = (index) => {
    const swipe = swipeRef.current;
    if (!swipe)
      return;
    if (swipe.activeIndex !== index) {
      innerEffect.current = true;
      swipe.swipeTo(index);
    }
  };
  (0, import_react.useEffect)(() => {
    swipeToCurrentTab(props.currentIndex);
  }, [props.currentIndex]);
  return /* @__PURE__ */ import_react.default.createElement("div", {
    className: (0, import_classnames.default)(bem("content", {
      animated: animated || swipeable
    }))
  }, renderChildren());
};
var stdin_default = TabsContent;
