"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const jsxRuntime = require("react/jsx-runtime");
const clsx = require("clsx");
const React = require("react");
const index = require("../../icons/index.cjs");
;/* empty css                                                                                                                                                                                        */
;/* empty css                                                                                                                                                                                         */
;/* empty css                                                                                                                                                                                                 */
;/* empty css                                                                                                                                                                                            */
;/* empty css                                                                                                                                                                                            */
const Loader = require("../../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.cjs");
function renderSwitcherIcon(prefixCls, switcherIcon, showLine, treeNodeProps) {
  const { isLeaf, expanded, loading } = treeNodeProps;
  if (loading) {
    return /* @__PURE__ */ jsxRuntime.jsx(Loader.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 (React.isValidElement(leafIcon)) {
        return React.cloneElement(leafIcon, {
          //@ts-ignore
          className: clsx(leafIcon.props.className || "", leafCls)
        });
      }
      return leafIcon;
    }
    return showLeafIcon ? /* @__PURE__ */ jsxRuntime.jsx(index.IconFile02, { className: `${prefixCls}-switcher-line-icon` }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${prefixCls}-switcher-leaf-line` });
  }
  const switcherCls = `${prefixCls}-switcher-icon`;
  const switcher = typeof switcherIcon === "function" ? switcherIcon(treeNodeProps) : switcherIcon;
  if (React.isValidElement(switcher)) {
    return React.cloneElement(switcher, {
      //@ts-ignore
      className: clsx(switcher.props.className || "", switcherCls)
    });
  }
  if (switcher) {
    return switcher;
  }
  if (showLine) {
    return expanded ? /* @__PURE__ */ jsxRuntime.jsx(index.IconMinus, { size: 14, className: `${prefixCls}-switcher-line-icon` }) : /* @__PURE__ */ jsxRuntime.jsx(index.IconPlus, { size: 14, className: `${prefixCls}-switcher-line-icon` });
  }
  return /* @__PURE__ */ jsxRuntime.jsx(index.IconChevronDownFill, { size: 14, className: switcherCls });
}
exports.default = renderSwitcherIcon;
