import React, { isValidElement, useContext } from "react";
import classnames from "classnames";
import { getSizeStyle } from "../utils";
import { Network } from "./Network";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const PRESET_IMAGES = ["error", "search", "default"];
const Empty = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("empty", prefixCls);
  const renderImage = () => {
    let {
      image
    } = props;
    if (/* @__PURE__ */ isValidElement(image)) {
      return image;
    }
    if (image === "network") {
      return Network;
    }
    if (PRESET_IMAGES.includes(image)) {
      image = `https://img.yzcdn.cn/vant/empty-image-${image}.png`;
    }
    return /* @__PURE__ */ React.createElement("img", {
      src: image,
      alt: ""
    });
  };
  const renderDescription = () => {
    if (props.description) {
      return /* @__PURE__ */ React.createElement("p", {
        className: classnames(bem("description"))
      }, props.description);
    }
    return null;
  };
  const renderBottom = () => {
    if (props.children) {
      return /* @__PURE__ */ React.createElement("div", {
        className: classnames(bem("bottom"))
      }, props.children);
    }
    return null;
  };
  return /* @__PURE__ */ React.createElement("div", {
    className: classnames(props.className, bem()),
    style: props.style
  }, /* @__PURE__ */ React.createElement("div", {
    className: classnames(bem("image")),
    style: getSizeStyle(props.imageSize)
  }, renderImage()), renderDescription(), renderBottom());
};
Empty.defaultProps = {
  image: "default"
};
var stdin_default = Empty;
export {
  stdin_default as default
};
