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

import { toRefs, computed } from '@vue/composition-api';
import { usePrefixClass } from '../../hooks/useConfig.js';
import '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../../_chunks/dep-67ff4010.js';
import '../../config-provider/type.js';

function formatCSSUnit(unit) {
  if (!unit) return unit;
  return isNaN(Number(unit)) ? unit : "".concat(unit, "px");
}
function useTreeStyles(props, state) {
  var componentName = usePrefixClass("tree").value;
  var classPrefix = usePrefixClass().value;
  var treeState = state;
  var virtualConfig = treeState.virtualConfig,
    isScrolling = treeState.isScrolling;
  var _toRefs = toRefs(props),
    height = _toRefs.height,
    maxHeight = _toRefs.maxHeight;
  var treeClasses = computed(function () {
    var list = [componentName];
    var disabled = props.disabled,
      hover = props.hover,
      transition = props.transition,
      checkable = props.checkable,
      draggable = props.draggable,
      expandOnClickNode = props.expandOnClickNode,
      scroll = props.scroll;
    if (disabled) list.push("".concat(classPrefix, "-is-disabled"));
    if (hover) list.push("".concat(componentName, "--hoverable"));
    if (checkable) list.push("".concat(componentName, "--checkable"));
    if (draggable) list.push("".concat(componentName, "--draggable"));
    if (transition) list.push("".concat(componentName, "--transition"));
    if (expandOnClickNode) list.push("".concat(componentName, "--block-node"));
    var isVirtual = virtualConfig === null || virtualConfig === void 0 ? void 0 : virtualConfig.isVirtualScroll.value;
    if (isVirtual) {
      list.push("".concat(componentName, "__vscroll"));
      if (isScrolling.value) list.push("".concat(componentName, "--scrolling"));
    } else if (scroll && scroll.type === "lazy") {
      list.push("".concat(componentName, "__lazyload"));
    }
    return list;
  });
  var treeContentStyles = computed(function () {
    return {
      height: formatCSSUnit(height.value),
      maxHeight: formatCSSUnit(maxHeight.value)
    };
  });
  var scrollStyles = computed(function () {
    var isVirtual = virtualConfig === null || virtualConfig === void 0 ? void 0 : virtualConfig.isVirtualScroll.value;
    var translateY = isVirtual ? virtualConfig === null || virtualConfig === void 0 ? void 0 : virtualConfig.translateY.value : 0;
    var transform = "translateY(".concat(translateY, "px)");
    var posStyle = {
      transform: transform,
      "-ms-transform": transform,
      "-moz-transform": transform,
      "-webkit-transform": transform
    };
    return posStyle;
  });
  var cursorStyles = computed(function () {
    var isVirtual = virtualConfig === null || virtualConfig === void 0 ? void 0 : virtualConfig.isVirtualScroll.value;
    var translateY = isVirtual ? virtualConfig === null || virtualConfig === void 0 ? void 0 : virtualConfig.translateY.value : 0;
    var translate = "translate(0, ".concat(translateY, "px)");
    return {
      "transform": translate,
      "-ms-transform": translate,
      "-moz-transform": translate,
      "-webkit-transform": translate
    };
  });
  return {
    treeClasses: treeClasses,
    treeContentStyles: treeContentStyles,
    scrollStyles: scrollStyles,
    cursorStyles: cursorStyles
  };
}

export { useTreeStyles as default, formatCSSUnit };
//# sourceMappingURL=useTreeStyles.js.map
