var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
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_constant = require("../utils/constant");
var import_icon = __toESM(require("../icon"));
var import_ConfigProviderContext = __toESM(require("../config-provider/ConfigProviderContext"));
const StepsItem = (_a) => {
  var _b = _a, {
    children
  } = _b, props = __objRest(_b, [
    "children"
  ]);
  const {
    index,
    parent: parentProps
  } = props;
  const {
    prefixCls,
    createNamespace
  } = (0, import_react.useContext)(import_ConfigProviderContext.default);
  const [bem] = createNamespace("step", prefixCls);
  if (!parentProps) {
    if (process.env.NODE_ENV !== "production") {
      console.error("[rc-ui-lib] <Step> must be a child component of <Steps>.");
    }
  }
  const getStatus = () => {
    const active = +parentProps.active;
    if (index < active) {
      return "finish";
    }
    return index === active ? "process" : "waiting";
  };
  const isActive = () => getStatus() === "process";
  const lineStyle = (0, import_react.useMemo)(() => ({
    background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  }), [index, parentProps.active, parentProps.activeColor, parentProps.inactiveColor]);
  const titleStyle = (0, import_react.useMemo)(() => {
    if (isActive()) {
      return {
        color: parentProps.activeColor
      };
    }
    if (getStatus() === "waiting") {
      return {
        color: parentProps.inactiveColor
      };
    }
    return {};
  }, [index, parentProps.active, parentProps.activeColor, parentProps.inactiveColor]);
  const onClickStep = () => {
    if (parentProps.onClickStep)
      parentProps.onClickStep(index);
  };
  const renderCircle = () => {
    const {
      iconPrefix,
      finishIcon,
      activeIcon,
      activeColor,
      inactiveIcon
    } = parentProps;
    if (isActive()) {
      if (/* @__PURE__ */ import_react.default.isValidElement(parentProps.activeIcon)) {
        return parentProps.activeIcon;
      }
      return /* @__PURE__ */ import_react.default.createElement(import_icon.default, {
        className: (0, import_classnames.default)(bem("icon", "active")),
        name: activeIcon,
        color: activeColor,
        classPrefix: iconPrefix
      });
    }
    if (getStatus() === "finish" && (finishIcon || /* @__PURE__ */ import_react.default.isValidElement(parentProps.finishIcon))) {
      if (/* @__PURE__ */ import_react.default.isValidElement(parentProps.finishIcon)) {
        return parentProps.finishIcon;
      }
      return /* @__PURE__ */ import_react.default.createElement(import_icon.default, {
        className: (0, import_classnames.default)(bem("icon", "finish")),
        name: finishIcon,
        color: activeColor,
        classPrefix: iconPrefix
      });
    }
    if (/* @__PURE__ */ import_react.default.isValidElement(parentProps.inactiveIcon)) {
      return parentProps.inactiveIcon;
    }
    if (inactiveIcon) {
      return /* @__PURE__ */ import_react.default.createElement(import_icon.default, {
        className: (0, import_classnames.default)(bem("icon")),
        name: inactiveIcon,
        classPrefix: iconPrefix
      });
    }
    return /* @__PURE__ */ import_react.default.createElement("i", {
      className: (0, import_classnames.default)(bem("circle")),
      style: lineStyle
    });
  };
  const status = getStatus();
  return /* @__PURE__ */ import_react.default.createElement("div", {
    style: props.style,
    className: (0, import_classnames.default)(props.className, import_constant.BORDER, bem([parentProps.direction, {
      [status]: status
    }]))
  }, /* @__PURE__ */ import_react.default.createElement("div", {
    className: (0, import_classnames.default)(bem("title", {
      active: isActive()
    })),
    style: titleStyle,
    onClick: onClickStep
  }, children), /* @__PURE__ */ import_react.default.createElement("div", {
    className: (0, import_classnames.default)(bem("circle-container")),
    onClick: onClickStep
  }, renderCircle()), /* @__PURE__ */ import_react.default.createElement("div", {
    className: (0, import_classnames.default)(bem("line")),
    style: lineStyle
  }));
};
var stdin_default = StepsItem;
