var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
import React, { useContext, useMemo } from "react";
import classnames from "classnames";
import { addUnit, getSizeStyle } from "../utils";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const SpinIcon = ({
  bem
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, Array(12).fill(null).map((_, index) => /* @__PURE__ */ React.createElement("i", {
  key: index,
  className: classnames(bem("line", String(index + 1)))
})));
const CircularIcon = ({
  bem
}) => /* @__PURE__ */ React.createElement("svg", {
  className: classnames(bem("circular")),
  viewBox: "25 25 50 50"
}, /* @__PURE__ */ React.createElement("circle", {
  cx: "50",
  cy: "50",
  r: "20",
  fill: "none"
}));
const BallIcon = ({
  bem
}) => /* @__PURE__ */ React.createElement("div", {
  className: classnames(bem("ball"))
}, /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement("div", null));
const Icon = (bem) => ({
  spinner: /* @__PURE__ */ React.createElement(SpinIcon, {
    bem
  }),
  circular: /* @__PURE__ */ React.createElement(CircularIcon, {
    bem
  }),
  ball: /* @__PURE__ */ React.createElement(BallIcon, {
    bem
  })
});
const Loading = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("loading", prefixCls);
  const {
    className,
    type,
    vertical,
    color,
    size,
    textColor,
    children,
    textSize
  } = props;
  const spinnerStyle = useMemo(() => __spreadValues({
    color
  }, getSizeStyle(size)), [color, size]);
  const renderText = () => {
    if (children) {
      return /* @__PURE__ */ React.createElement("span", {
        className: classnames(bem("text")),
        style: {
          fontSize: addUnit(textSize),
          color: textColor != null ? textColor : color
        }
      }, children);
    }
    return null;
  };
  return /* @__PURE__ */ React.createElement("div", {
    className: classnames(className, bem([type, {
      vertical
    }]))
  }, /* @__PURE__ */ React.createElement("span", {
    className: classnames(bem("spinner", type)),
    style: spinnerStyle
  }, Icon(bem)[type]), renderText());
};
Loading.defaultProps = {
  type: "circular"
};
var stdin_default = Loading;
export {
  stdin_default as default
};
