import { jsx } from "react/jsx-runtime";
import clsx from "clsx";
import { isValidElement, cloneElement } from "react";
import { IconFile02, IconMinus, IconPlus, IconChevronDownFill } from "../../icons/index.mjs";
/* empty css                                                                                                                                                                                       */
/* empty css                                                                                                                                                                                        */
/* empty css                                                                                                                                                                                                */
/* empty css                                                                                                                                                                                           */
/* empty css                                                                                                                                                                                           */
import { Loader } from "../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/Loader/Loader.mjs";
function renderSwitcherIcon(prefixCls, switcherIcon, showLine, treeNodeProps) {
  const { isLeaf, expanded, loading } = treeNodeProps;
  if (loading) {
    return /* @__PURE__ */ jsx(Loader, { size: "xs", className: `${prefixCls}-switcher-loading-icon` });
  }
  let showLeafIcon;
  if (showLine && typeof showLine === "object") {
    showLeafIcon = showLine.showLeafIcon;
  }
  if (isLeaf) {
    if (!showLine) {
      return null;
    }
    if (typeof showLeafIcon !== "boolean" && !!showLeafIcon) {
      const leafIcon = typeof showLeafIcon === "function" ? showLeafIcon(treeNodeProps) : showLeafIcon;
      const leafCls = `${prefixCls}-switcher-line-custom-icon`;
      if (isValidElement(leafIcon)) {
        return cloneElement(leafIcon, {
          //@ts-ignore
          className: clsx(leafIcon.props.className || "", leafCls)
        });
      }
      return leafIcon;
    }
    return showLeafIcon ? /* @__PURE__ */ jsx(IconFile02, { className: `${prefixCls}-switcher-line-icon` }) : /* @__PURE__ */ jsx("span", { className: `${prefixCls}-switcher-leaf-line` });
  }
  const switcherCls = `${prefixCls}-switcher-icon`;
  const switcher = typeof switcherIcon === "function" ? switcherIcon(treeNodeProps) : switcherIcon;
  if (isValidElement(switcher)) {
    return cloneElement(switcher, {
      //@ts-ignore
      className: clsx(switcher.props.className || "", switcherCls)
    });
  }
  if (switcher) {
    return switcher;
  }
  if (showLine) {
    return expanded ? /* @__PURE__ */ jsx(IconMinus, { size: 14, className: `${prefixCls}-switcher-line-icon` }) : /* @__PURE__ */ jsx(IconPlus, { size: 14, className: `${prefixCls}-switcher-line-icon` });
  }
  return /* @__PURE__ */ jsx(IconChevronDownFill, { size: 14, className: switcherCls });
}
export {
  renderSwitcherIcon as default
};
