/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

'use strict';

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

var hooks_useConfig = require('../../../hooks/useConfig.js');
var components_tree_utils = require('../utils.js');
require('@vue/composition-api');
require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../../../chunks/zh_CN.js');
require('lodash/camelCase');

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

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