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(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellCards/components/TabCard/TabCard.tsx
var TabCard_exports = {};
__export(TabCard_exports, {
  default: () => TabCard_default
});
module.exports = __toCommonJS(TabCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_badge = __toESM(require("../../../badge"));
var import_TabCard = require("./TabCard.less");
var TabCard = (props) => {
  const {
    tabKey,
    label,
    icon,
    badge,
    onClick,
    direction = "horizontal",
    size = "medium",
    render,
    active,
    disabled,
    loading,
    className,
    style,
    children,
    dataSource,
    ...restProps
  } = props;
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  console.log("propsprops", props);
  const mergedStyle = (0, import_react.useMemo)(() => {
    let finalStyle = { ...style };
    if ((loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.style)) {
      finalStyle = { ...finalStyle, ...loading.style };
    } else if ((disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.style)) {
      finalStyle = { ...finalStyle, ...disabled.style };
    } else if ((active == null ? void 0 : active.value) && (active == null ? void 0 : active.style)) {
      finalStyle = { ...finalStyle, ...active.style };
    }
    return finalStyle;
  }, [style, active, disabled, loading]);
  const mergedClassName = (0, import_react.useMemo)(() => {
    return (0, import_classnames.default)(
      "tab-card",
      `tab-card--${direction}`,
      `tab-card--${size}`,
      className,
      {
        "tab-card--active": active == null ? void 0 : active.value,
        "tab-card--disabled": disabled == null ? void 0 : disabled.value,
        "tab-card--loading": loading == null ? void 0 : loading.value
      },
      (active == null ? void 0 : active.value) && (active == null ? void 0 : active.className),
      (disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.className),
      (loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.className)
    );
  }, [className, direction, size, active, disabled, loading]);
  const handleClick = (0, import_react.useCallback)(
    (e) => {
      if ((loading == null ? void 0 : loading.value) || (disabled == null ? void 0 : disabled.value)) {
        e.preventDefault();
        return;
      }
      if ((active == null ? void 0 : active.onChange) && !active.value) {
        active.onChange(true);
      }
      if (onClick) {
        onClick(tabKey, e);
      }
    },
    [tabKey, onClick, active, loading, disabled]
  );
  const renderExtra = (0, import_react.useCallback)(() => {
    if ((loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__extra" }, loading.extra);
    }
    if ((disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__extra" }, disabled.extra);
    }
    if ((active == null ? void 0 : active.value) && (active == null ? void 0 : active.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__extra" }, active.extra);
    }
    return null;
  }, [active, disabled, loading]);
  const renderContent = (0, import_react.useCallback)(() => {
    if (render) {
      return render(props);
    }
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__content" }, icon && /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__icon" }, icon), /* @__PURE__ */ import_react.default.createElement("div", { className: "tab-card__label-wrapper" }, badge ? /* @__PURE__ */ import_react.default.createElement(
      import_badge.default,
      {
        count: badge.count,
        dot: badge.dot,
        color: badge.color,
        offset: badge.offset
      },
      /* @__PURE__ */ import_react.default.createElement("span", { className: "tab-card__label" }, label)
    ) : /* @__PURE__ */ import_react.default.createElement("span", { className: "tab-card__label" }, label)));
  }, [icon, label, badge, render, props]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: mergedClassName,
      style: mergedStyle,
      onClick: handleClick,
      "data-active": active == null ? void 0 : active.value,
      "data-disabled": disabled == null ? void 0 : disabled.value,
      "data-loading": loading == null ? void 0 : loading.value,
      "data-tab-key": tabKey,
      role: "tab",
      "aria-selected": active == null ? void 0 : active.value,
      "aria-disabled": disabled == null ? void 0 : disabled.value,
      tabIndex: (disabled == null ? void 0 : disabled.value) ? -1 : 0,
      ...restProps
    },
    renderContent(),
    renderExtra(),
    children
  );
};
var Provider = (props) => /* @__PURE__ */ import_react.default.createElement(TabCard, { ...props == null ? void 0 : props.props, ...props });
var TabCard_default = Provider;
