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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../../hooks/useConfig.js');
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');

function formatCSSUnit(unit) {
  if (!unit) return unit;
  return isNaN(Number(unit)) ? unit : "".concat(unit, "px");
}
function useTreeStyles(props, state) {
  var componentName = hooks_useConfig.usePrefixClass("tree").value;
  var classPrefix = hooks_useConfig.usePrefixClass().value;
  var treeState = state;
  var virtualConfig = treeState.virtualConfig,
    isScrolling = treeState.isScrolling;
  var _toRefs = VueCompositionAPI.toRefs(props),
    height = _toRefs.height,
    maxHeight = _toRefs.maxHeight;
  var treeClasses = VueCompositionAPI.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 = VueCompositionAPI.computed(function () {
    return {
      height: formatCSSUnit(height.value),
      maxHeight: formatCSSUnit(maxHeight.value)
    };
  });
  var scrollStyles = VueCompositionAPI.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 = VueCompositionAPI.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
  };
}

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