/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var iconsVue = require('@ldesign/icons-vue');
var hooks_useConfig = require('../../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../../hooks/useGlobalIcon.js');
var loading_index = require('../../loading/index.js');
var tree_util = require('../util.js');
require('@vue/composition-api');
require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../_common/js/global-config/default-config.js');
require('../../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../../_chunks/dep-7c884501.js');
require('dayjs');
require('../../utils/withInstall.js');
require('@babel/runtime/helpers/defineProperty');
require('vue');
require('lodash/capitalize');
require('../../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../../loading/plugin.js');
require('../../config.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../loading/loading.js');
require('../../utils/render-tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../utils/transfer-dom.js');
require('../../config-provider/config-receiver.js');
require('../../utils/mixins.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');

function useRenderIcon(props) {
  var classPrefix = hooks_useConfig.usePrefixClass().value;
  var componentName = hooks_useConfig.usePrefixClass("tree").value;
  var getFolderIcon = function getFolderIcon(h) {
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        CaretRightSmallIcon: iconsVue.CaretRightSmallIcon
      }),
      CaretRightSmallIcon = _useGlobalIcon.CaretRightSmallIcon;
    return h(CaretRightSmallIcon);
  };
  var handleMousedown = function handleMousedown(evt) {
    evt.preventDefault();
  };
  var renderIcon = function renderIcon(h) {
    var node = props.node,
      treeScope = props.treeScope;
    var scopedSlots = treeScope.scopedSlots;
    var treeProps = (treeScope === null || treeScope === void 0 ? void 0 : treeScope.treeProps) || {};
    var icon = treeProps.icon;
    var isDefaultIcon = false;
    var iconNode = null;
    if (icon === true) {
      if (scopedSlots !== null && scopedSlots !== void 0 && scopedSlots.icon) {
        iconNode = scopedSlots.icon({
          node: node === null || node === void 0 ? void 0 : node.getModel()
        });
      } else if (!node.vmIsLeaf) {
        isDefaultIcon = true;
        iconNode = getFolderIcon(h);
        if (node.loading && node.expanded) iconNode = h(loading_index.Loading);
      } else {
        iconNode = "";
      }
    } else if (icon) {
      iconNode = tree_util.getTNode(icon, {
        createElement: h,
        node: node
      });
    }
    var wrapIconNode = h("span", {
      "class": ["".concat(componentName, "__icon"), "".concat(classPrefix, "-folder-icon"), isDefaultIcon ? "".concat(componentName, "__icon--default") : ""],
      "attrs": {
        "trigger": "expand",
        "ignore": "active"
      },
      "on": {
        "mousedown": handleMousedown
      }
    }, [iconNode]);
    return wrapIconNode;
  };
  return {
    renderIcon: renderIcon
  };
}

exports["default"] = useRenderIcon;
//# sourceMappingURL=useRenderIcon.js.map
