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

import { h as helper } from '../../_chunks/dep-c89aafbb.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import { ChevronRightIcon } from '@ldesign/icons-vue';
import { getFullPathLabel } from '../core/helper.js';
import { getCascaderItemClass, getCascaderItemIconClass } from '../core/className.js';
import { Checkbox } from '../../checkbox/index.js';
import { Loading } from '../../loading/index.js';
import { getKeepAnimationMixins } from '../../config-provider/config-receiver.js';
import { usePrefixClass, useCommonClassName } from '../../hooks/useConfig.js';
import { useGlobalIcon } from '../../hooks/useGlobalIcon.js';
import Ripple from '../../utils/ripple.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/isEmpty';
import '@babel/runtime/helpers/toConsumableArray';
import '../../utils/map-props.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'vue';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../utils/event.js';
import '../../utils/helper.js';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/camelCase';
import '../../utils/mixins.js';
import '../../checkbox/checkbox.js';
import '../../utils/render-tnode.js';
import 'lodash/kebabCase';
import '../../checkbox/props.js';
import 'lodash/mergeWith';
import '../../config-provider/context.js';
import 'lodash/merge';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '../../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../../_chunks/dep-67ff4010.js';
import '../../config-provider/type.js';
import '../../checkbox/checkbox-group-props.js';
import '../../checkbox/style';
import '../../checkbox/type.js';
import '../../loading/directive.js';
import 'lodash/isObject';
import 'lodash/mapKeys';
import 'lodash/isEqual';
import '../../loading/plugin.js';
import '../../config.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../loading/loading.js';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import 'lodash/isArray';
import '../../loading/style';
import '../../loading/type.js';
import '../../config-provider/useConfig.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var keepAnimationMixins = getKeepAnimationMixins();
var props = {
  node: {
    type: Object,
    "default": function _default() {
      return {};
    }
  },
  cascaderContext: {
    type: Object
  },
  onChange: Function,
  onClick: Function,
  onMouseenter: Function
};
var Item = defineComponent({
  directives: {
    Ripple: Ripple
  },
  mixins: [keepAnimationMixins],
  props: _objectSpread({}, props),
  setup: function setup(props2) {
    var COMPONENT_NAME = usePrefixClass("cascader__item");
    var classPrefix = usePrefixClass();
    var _useCommonClassName = useCommonClassName(),
      STATUS = _useCommonClassName.STATUS,
      SIZE = _useCommonClassName.SIZE;
    var _useGlobalIcon = useGlobalIcon({
        ChevronRightIcon: ChevronRightIcon
      }),
      ChevronRightIcon$1 = _useGlobalIcon.ChevronRightIcon;
    var itemClass = computed(function () {
      return getCascaderItemClass(classPrefix.value, props2.node, SIZE.value, STATUS.value, props2.cascaderContext);
    });
    var iconClass = computed(function () {
      return getCascaderItemIconClass(classPrefix.value, props2.node, STATUS.value, props2.cascaderContext);
    });
    return {
      COMPONENT_NAME: COMPONENT_NAME,
      ChevronRightIcon: ChevronRightIcon$1,
      iconClass: iconClass,
      itemClass: itemClass
    };
  },
  render: function render() {
    var _this = this;
    var h = arguments[0];
    var iconClass = this.iconClass,
      cascaderContext = this.cascaderContext,
      itemClass = this.itemClass,
      node = this.node,
      COMPONENT_NAME = this.COMPONENT_NAME,
      onChange = this.onChange,
      ChevronRightIcon = this.ChevronRightIcon;
    function RenderLabelInner(node2, cascaderContext2) {
      var inputVal = cascaderContext2.inputVal;
      var labelText = inputVal ? getFullPathLabel(node2) : node2.label;
      if (inputVal) {
        var texts = labelText.split(inputVal);
        var doms = [];
        for (var index = 0; index < texts.length; index++) {
          doms.push(h("span", {
            "key": index
          }, [texts[index]]));
          if (index === texts.length - 1) break;
          doms.push(h("span", {
            "key": "".concat(index, "filter"),
            "class": "".concat(COMPONENT_NAME, "-label--filter")
          }, [inputVal]));
        }
        return doms;
      }
      return labelText;
    }
    function RenderLabelContent(node2, cascaderContext2) {
      var label = RenderLabelInner(node2, cascaderContext2);
      var labelCont = h("span", {
        "attrs": {
          "title": cascaderContext2.inputVal ? getFullPathLabel(node2) : node2.label,
          "role": "label"
        },
        "class": ["".concat(COMPONENT_NAME, "-label"), "".concat(COMPONENT_NAME, "-label--ellipsis")]
      }, [label]);
      return labelCont;
    }
    function RenderCheckBox(node2, cascaderContext2) {
      var checkProps = cascaderContext2.checkProps,
        value = cascaderContext2.value,
        max = cascaderContext2.max,
        inputVal = cascaderContext2.inputVal;
      var label = RenderLabelInner(node2, cascaderContext2);
      return h(Checkbox, helper([{
        "attrs": {
          "checked": node2.checked,
          "indeterminate": node2.indeterminate,
          "disabled": node2.isDisabled() || value.length >= max && max !== 0,
          "name": String(node2.value),
          "title": inputVal ? getFullPathLabel(node2) : node2.label,
          "stopLabelTrigger": !!node2.children
        },
        "on": {
          "change": function change(vale, _ref) {
            var e = _ref.e;
            e.stopPropagation();
            onChange();
          }
        }
      }, checkProps]), [label]);
    }
    return h("li", {
      "class": itemClass,
      "on": {
        "click": function click(e) {
          e.stopPropagation();
          _this.onClick();
        },
        "mouseenter": function mouseenter(e) {
          e.stopPropagation();
          _this.onMouseenter();
        }
      }
    }, [cascaderContext.multiple ? RenderCheckBox(node, cascaderContext) : RenderLabelContent(node, cascaderContext), node.children && (node.loading ? h(Loading, {
      "class": iconClass,
      "attrs": {
        "size": "small"
      }
    }) : h(ChevronRightIcon, {
      "class": iconClass
    }))]);
  }
});

export { Item as default };
//# sourceMappingURL=Item.js.map
