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

'use strict';

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

var hooks_useConfig = require('../../hooks/useConfig.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('@babel/runtime/helpers/defineProperty');
require('lodash/camelCase');

function useRenderLine(props) {
  var componentName = hooks_useConfig.usePrefixClass("tree").value;
  var renderLine = function renderLine(h) {
    var node = props.node,
      treeScope = props.treeScope;
    var scopedSlots = treeScope.scopedSlots;
    var treeProps = (treeScope === null || treeScope === void 0 ? void 0 : treeScope.treeProps) || {};
    var line = treeProps.line;
    var iconVisible = !!treeProps.icon;
    var lineNode = null;
    if (line === true) {
      if (scopedSlots !== null && scopedSlots !== void 0 && scopedSlots.line) {
        lineNode = scopedSlots.line({
          node: node === null || node === void 0 ? void 0 : node.getModel()
        });
      } else if (node.parent && node.tree) {
        var vmIsLeaf = node.vmIsLeaf,
          vmIsFirst = node.vmIsFirst,
          level = node.level;
        var lineClasses = [];
        lineClasses.push("".concat(componentName, "__line"));
        if (vmIsLeaf || !iconVisible) lineClasses.push("".concat(componentName, "__line--leaf"));
        if (vmIsFirst && iconVisible) lineClasses.push("".concat(componentName, "__line--first"));
        var shadowStyles = [];
        var parents = node.getParents();
        parents.pop();
        parents.forEach(function (pnode, index) {
          if (!pnode.vmIsLast) shadowStyles.push("calc(-".concat(index + 1, " * var(--space)) 0 var(--color)"));
        });
        var styles = {
          "--level": level ? String(level) : void 0,
          "box-shadow": shadowStyles.join(",")
        };
        lineNode = h("span", {
          "class": lineClasses,
          "style": styles
        });
      }
    } else {
      lineNode = tree_util.getTNode(line, {
        createElement: h,
        node: node
      });
    }
    return lineNode;
  };
  return {
    renderLine: renderLine
  };
}

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