import { useCallback } from "react";
import cs from "../_util/classNames.js";
import { isFunction } from "../_util/is.js";
import IconExclamationCircleFill from "../../icon/react-icon/IconExclamationCircleFill/index.js";
import { jsxs, jsx } from "../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __read = globalThis && globalThis.__read || function(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m)
    return o;
  var i = m.call(o), r, ar = [], e;
  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
      ar.push(r.value);
  } catch (error) {
    e = {
      error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"]))
        m.call(i);
    } finally {
      if (e)
        throw e.error;
    }
  }
  return ar;
};
var __spreadArray = globalThis && globalThis.__spreadArray || function(to, from, pack) {
  if (pack || arguments.length === 2)
    for (var i = 0, l = from.length, ar; i < l; i++) {
      if (ar || !(i in from)) {
        if (!ar)
          ar = Array.prototype.slice.call(from, 0, i);
        ar[i] = from[i];
      }
    }
  return to.concat(ar || Array.prototype.slice.call(from));
};
var StepsProgress = function(props) {
  var _a;
  var size = props.size, prefixCls = props.prefixCls, percent = props.percent, status = props.status, color = props.color, type = props.type, showText = props.showText, formatText = props.formatText, trailColor = props.trailColor;
  var strokeWidth = props.strokeWidth || (size === "small" ? 8 : 4);
  var cls = prefixCls + "-" + type;
  var height = strokeWidth;
  var getText = useCallback(function() {
    if (isFunction(formatText)) {
      return formatText(percent);
    }
    switch (status) {
      case "error":
        return /* @__PURE__ */ jsxs("span", {
          children: [percent, "% ", /* @__PURE__ */ jsx(IconExclamationCircleFill, {})]
        });
      default:
        return percent + "%";
    }
  }, [formatText, percent, status]);
  return /* @__PURE__ */ jsxs("div", {
    className: cls + "-wrapper",
    children: [/* @__PURE__ */ jsx("div", {
      className: cls + "-outer",
      role: "progressbar",
      "aria-valuemin": 0,
      "aria-valuemax": 100,
      "aria-valuenow": percent,
      style: {
        height
      },
      children: __spreadArray([], __read(new Array(props.steps)), false).map(function(_, index) {
        var _a2;
        var isActive = percent > 100 / props.steps * index;
        return /* @__PURE__ */ jsx("div", {
          className: cs(cls + "-item", (_a2 = {}, _a2[cls + "-item-active"] = isActive, _a2)),
          style: {
            backgroundColor: isActive ? color : trailColor || ""
          }
        }, index);
      })
    }), showText && /* @__PURE__ */ jsx("div", {
      className: cs(cls + "-text", (_a = {}, _a[cls + "-text-with-icon"] = status, _a)),
      children: getText()
    })]
  });
};
StepsProgress.defaultProps = {
  showText: true,
  size: "default",
  status: "normal"
};
const StepsProgress$1 = StepsProgress;
export {
  StepsProgress,
  StepsProgress$1 as default
};
//# sourceMappingURL=steps-progress.js.map
