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

import { _ as _defineProperty } from '../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, computed, createVNode, mergeProps } from 'vue';
import { o as omit_1 } from '../_chunks/dep-350764bc.mjs';
import { SelectInput } from '../select-input/index.mjs';
import FakeArrow from '../common-components/fake-arrow.mjs';
import { usePrefixClass, useCommonClassName } from '../hooks/useConfig.mjs';
import { useFormDisabled } from '../form/hooks.mjs';
import Panel from './components/Panel.mjs';
import props from './props.mjs';
import { useCascaderContext } from './hooks.mjs';
import { handleRemoveTagEffect, closeIconClickEffect } from './core/effect.mjs';
import { getMultipleContent, getSingleContent, getPanels } from './core/helper.mjs';
import { getFakeArrowIconClass } from './core/className.mjs';
import { useConfig } from '../config-provider/useConfig.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-42cc3015.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-2bc37d52.mjs';
import '../_chunks/dep-3da99438.mjs';
import '../_chunks/dep-c989dff3.mjs';
import '../_chunks/dep-9cf86cf1.mjs';
import '../_chunks/dep-bc1d737a.mjs';
import '../_chunks/dep-4d7a675b.mjs';
import '../_chunks/dep-5717e263.mjs';
import '../_chunks/dep-a8bcacea.mjs';
import '../_chunks/dep-2e7f59b1.mjs';
import '../_chunks/dep-855db8bc.mjs';
import '../_chunks/dep-a87f3e4c.mjs';
import '../_chunks/dep-1e566bb5.mjs';
import '../_chunks/dep-1434aa15.mjs';
import '../_chunks/dep-e5eb9f23.mjs';
import '../_chunks/dep-9fe2ef12.mjs';
import '../_chunks/dep-672e7d1a.mjs';
import '../_chunks/dep-42a19209.mjs';
import '../_chunks/dep-9262ee2f.mjs';
import '../_chunks/dep-334a4f6b.mjs';
import '../_chunks/dep-8d3e9aa3.mjs';
import '../_chunks/dep-0d3dd4b5.mjs';
import '../_chunks/dep-8b989474.mjs';
import '../_chunks/dep-f1994936.mjs';
import '../_chunks/dep-6884627f.mjs';
import '../_chunks/dep-0fc02184.mjs';
import '../utils/withInstall.mjs';
import '../select-input/select-input.mjs';
import '../popup/index.mjs';
import '../popup/popup.mjs';
import '../_chunks/dep-84acf3c2.mjs';
import '../_chunks/dep-b8d7992c.mjs';
import '@popperjs/core';
import '../_chunks/dep-876fb3ec.mjs';
import '../utils/dom.mjs';
import '../utils/easing.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-888e80c4.mjs';
import '../_chunks/dep-406cd044.mjs';
import '../_chunks/dep-327559e8.mjs';
import '../_chunks/dep-b2235f26.mjs';
import '../_chunks/dep-1372b2d3.mjs';
import '../_chunks/dep-9a85dac1.mjs';
import '../_common/js/utils/set-style.mjs';
import '../hooks/useVModel.mjs';
import '../popup/props.mjs';
import '../popup/container.mjs';
import '../_chunks/dep-bf1e33c8.mjs';
import '../_chunks/dep-78847b2e.mjs';
import '../hooks/useResizeObserver.mjs';
import '../popup/style/css.mjs';
import '../popup/type.mjs';
import '../_chunks/dep-095107f7.mjs';
import '../_chunks/dep-40d69a9c.mjs';
import '../_chunks/dep-dcc83161.mjs';
import '../_chunks/dep-345e1be3.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/zh_CN.mjs';
import '../_chunks/dep-9888611c.mjs';
import '../_chunks/dep-697a1365.mjs';
import '../config-provider/type.mjs';
import '../hooks/index.mjs';
import '../hooks/icon.mjs';
import '../hooks/slot.mjs';
import '../hooks/tnode.mjs';
import '../hooks/useCommonClassName.mjs';
import '../hooks/useDefaultValue.mjs';
import '../hooks/useDestroyOnClose.mjs';
import '../hooks/useKeepAnimation.mjs';
import '../hooks/useRipple.mjs';
import '../utils/set-style.mjs';
import '../hooks/useVirtualScroll.mjs';
import '../select-input/props.mjs';
import '../select-input/useSingle.mjs';
import '../_chunks/dep-8932db97.mjs';
import '../_chunks/dep-550c24c1.mjs';
import '../input/index.mjs';
import '../input/input.mjs';
import '../_chunks/dep-60fae668.mjs';
import '@ldesign/icons-vue-next';
import '../hooks/useGlobalIcon.mjs';
import '../input/props.mjs';
import '../input/useInput.mjs';
import '../form/const.mjs';
import '../input/useLengthLimit.mjs';
import '../_chunks/dep-3f21269a.mjs';
import '../_common/js/log/index.mjs';
import '../_common/js/log/log.mjs';
import '../_common/js/utils/helper.mjs';
import '../_chunks/dep-ed5ebb35.mjs';
import '../input/useInputEventHandler.mjs';
import '../input/useInputWidth.mjs';
import '../input/input-group.mjs';
import '../input/input-group-props.mjs';
import '../input/style/css.mjs';
import '../input/type.mjs';
import '../loading/index.mjs';
import '../loading/directive.mjs';
import '../loading/plugin.mjs';
import '../loading/loading.mjs';
import '../hooks/useTeleport.mjs';
import '../loading/props.mjs';
import '../loading/icon/gradient.mjs';
import '../_common/js/loading/circle-adapter.mjs';
import '../loading/style/css.mjs';
import '../loading/type.mjs';
import '../select-input/useMultiple.mjs';
import '../tag-input/index.mjs';
import '../tag-input/tag-input.mjs';
import '../tag-input/props.mjs';
import '../tag-input/hooks/useTagScroll.mjs';
import '../tag-input/useTagList.mjs';
import '../tag/index.mjs';
import '../tag/tag.mjs';
import '../tag/props.mjs';
import '../tag/check-tag.mjs';
import '../tag/check-tag-props.mjs';
import '../tag/style/css.mjs';
import '../tag/type.mjs';
import '../tag-input/hooks/useHover.mjs';
import '../tag-input/hooks/useDragSorter.mjs';
import '../tag-input/style/css.mjs';
import '../tag-input/type.mjs';
import '../select-input/useOverlayInnerStyle.mjs';
import '../select-input/style/css.mjs';
import '../select-input/type.mjs';
import './components/Item.mjs';
import '../checkbox/index.mjs';
import '../checkbox/checkbox.mjs';
import '../checkbox/props.mjs';
import '../checkbox/constants.mjs';
import '../checkbox/group.mjs';
import '../_chunks/dep-85ed244c.mjs';
import '../_chunks/dep-c42916c7.mjs';
import '../checkbox/checkbox-group-props.mjs';
import '../checkbox/style/css.mjs';
import '../checkbox/type.mjs';
import '../_chunks/dep-9c7945a2.mjs';
import '../_common/js/tree/tree-store.mjs';
import '../_chunks/dep-ccbc47f4.mjs';
import 'mitt';
import '../_common/js/tree/tree-node.mjs';
import '../_chunks/dep-38ee6a8f.mjs';
import '../_chunks/dep-01e3f446.mjs';
import '../_chunks/dep-c81c0ee4.mjs';
import '../_common/js/tree/tree-node-model.mjs';
import '../_chunks/dep-35e3b1aa.mjs';

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 _Cascader = defineComponent({
  name: "TCascader",
  props: _objectSpread({}, props),
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var disabled = useFormDisabled();
    var COMPONENT_NAME = usePrefixClass("cascader");
    var classPrefix = usePrefixClass();
    var _useCommonClassName = useCommonClassName(),
      STATUS = _useCommonClassName.STATUS;
    var overlayClassName = usePrefixClass("cascader__popup");
    var _useConfig = useConfig("cascader"),
      globalConfig = _useConfig.globalConfig;
    var _useCascaderContext = useCascaderContext(props2),
      cascaderContext = _useCascaderContext.cascaderContext,
      isFilterable = _useCascaderContext.isFilterable;
    var displayValue = computed(function () {
      return props2.multiple ? getMultipleContent(cascaderContext.value) : getSingleContent(cascaderContext.value);
    });
    var panels = computed(function () {
      return getPanels(cascaderContext.value.treeNodes);
    });
    var inputPlaceholder = computed(function () {
      var _props2$placeholder;
      return cascaderContext.value.visible && !props2.multiple && getSingleContent(cascaderContext.value) || ((_props2$placeholder = props2.placeholder) !== null && _props2$placeholder !== void 0 ? _props2$placeholder : globalConfig.value.placeholder);
    });
    var renderSuffixIcon = function renderSuffixIcon() {
      var _cascaderContext$valu = cascaderContext.value,
        visible = _cascaderContext$valu.visible,
        disabled2 = _cascaderContext$valu.disabled;
      return createVNode(FakeArrow, {
        "overlayClassName": getFakeArrowIconClass(classPrefix.value, STATUS.value, cascaderContext.value),
        "isActive": visible,
        "disabled": disabled2
      }, null);
    };
    return function () {
      var _props2$popupProps;
      var _cascaderContext$valu2 = cascaderContext.value,
        setVisible = _cascaderContext$valu2.setVisible,
        visible = _cascaderContext$valu2.visible,
        inputVal = _cascaderContext$valu2.inputVal,
        setInputVal = _cascaderContext$valu2.setInputVal;
      return createVNode(SelectInput, mergeProps({
        "class": COMPONENT_NAME.value,
        "value": displayValue.value,
        "inputValue": visible ? inputVal : "",
        "popupVisible": visible,
        "keys": props2.keys,
        "allowInput": isFilterable.value,
        "min-collapsed-num": props2.minCollapsedNum,
        "collapsed-items": props2.collapsedItems,
        "readonly": props2.readonly,
        "disabled": props2.disabled,
        "clearable": props2.clearable,
        "placeholder": inputPlaceholder.value,
        "multiple": props2.multiple,
        "loading": props2.loading,
        "status": props2.status,
        "tips": props2.tips,
        "suffixIcon": function suffixIcon() {
          return renderSuffixIcon();
        },
        "popupProps": _objectSpread(_objectSpread({}, props2.popupProps), {}, {
          overlayInnerStyle: panels.value.length && !props2.loading ? {
            width: "auto"
          } : "",
          overlayClassName: [overlayClassName.value, (_props2$popupProps = props2.popupProps) === null || _props2$popupProps === void 0 ? void 0 : _props2$popupProps.overlayClassName]
        }),
        "inputProps": _objectSpread({
          size: props2.size
        }, props2.inputProps),
        "tagInputProps": _objectSpread({
          size: props2.size
        }, props2.tagInputProps),
        "tagProps": _objectSpread({}, props2.tagProps),
        "onInputChange": function onInputChange(value, ctx) {
          var _props2$selectInputPr, _props2$selectInputPr2;
          if (!isFilterable.value) return;
          setInputVal("".concat(value));
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr = props2.selectInputProps) === null || _props2$selectInputPr === void 0 ? void 0 : (_props2$selectInputPr2 = _props2$selectInputPr.onInputChange) === null || _props2$selectInputPr2 === void 0 ? void 0 : _props2$selectInputPr2.call(_props2$selectInputPr, value, ctx);
        },
        "onTagChange": function onTagChange(val, ctx) {
          var _props2$selectInputPr3, _props2$selectInputPr4;
          if (ctx.trigger === "enter") return;
          handleRemoveTagEffect(cascaderContext.value, ctx.index, props2.onRemove);
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr3 = props2.selectInputProps) === null || _props2$selectInputPr3 === void 0 ? void 0 : (_props2$selectInputPr4 = _props2$selectInputPr3.onTagChange) === null || _props2$selectInputPr4 === void 0 ? void 0 : _props2$selectInputPr4.call(_props2$selectInputPr3, val, ctx);
        },
        "onPopupVisibleChange": function onPopupVisibleChange(val, context) {
          var _props2$selectInputPr5, _props2$selectInputPr6;
          if (disabled.value) return;
          setVisible(val, context);
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr5 = props2.selectInputProps) === null || _props2$selectInputPr5 === void 0 ? void 0 : (_props2$selectInputPr6 = _props2$selectInputPr5.onPopupVisibleChange) === null || _props2$selectInputPr6 === void 0 ? void 0 : _props2$selectInputPr6.call(_props2$selectInputPr5, val, context);
        },
        "onBlur": function onBlur(val, context) {
          var _props2$onBlur, _props2$selectInputPr7, _props2$selectInputPr8;
          (_props2$onBlur = props2.onBlur) === null || _props2$onBlur === void 0 ? void 0 : _props2$onBlur.call(props2, {
            value: cascaderContext.value.value,
            e: context.e
          });
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr7 = props2.selectInputProps) === null || _props2$selectInputPr7 === void 0 ? void 0 : (_props2$selectInputPr8 = _props2$selectInputPr7.onBlur) === null || _props2$selectInputPr8 === void 0 ? void 0 : _props2$selectInputPr8.call(_props2$selectInputPr7, val, context);
        },
        "onFocus": function onFocus(val, context) {
          var _props2$onFocus, _props2$selectInputPr9, _props2$selectInputPr10;
          (_props2$onFocus = props2.onFocus) === null || _props2$onFocus === void 0 ? void 0 : _props2$onFocus.call(props2, {
            value: cascaderContext.value.value,
            e: context.e
          });
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr9 = props2.selectInputProps) === null || _props2$selectInputPr9 === void 0 ? void 0 : (_props2$selectInputPr10 = _props2$selectInputPr9.onFocus) === null || _props2$selectInputPr10 === void 0 ? void 0 : _props2$selectInputPr10.call(_props2$selectInputPr9, val, context);
        },
        "onClear": function onClear(context) {
          var _props2$selectInputPr11, _props2$selectInputPr12;
          closeIconClickEffect(cascaderContext.value);
          props2 === null || props2 === void 0 ? void 0 : (_props2$selectInputPr11 = props2.selectInputProps) === null || _props2$selectInputPr11 === void 0 ? void 0 : (_props2$selectInputPr12 = _props2$selectInputPr11.onClear) === null || _props2$selectInputPr12 === void 0 ? void 0 : _props2$selectInputPr12.call(_props2$selectInputPr11, context);
        }
      }, omit_1(props2.selectInputProps, ["onTagChange", "onInputChange", "onPopupVisibleChange", "onBlur", "onFocus", "onClear"])), {
        panel: function panel() {
          return createVNode(Panel, {
            "empty": props2.empty,
            "visible": visible,
            "trigger": props2.trigger,
            "loading": props2.loading,
            "loadingText": props2.loadingText,
            "cascaderContext": cascaderContext.value
          }, {
            empty: slots.empty,
            loadingText: slots.loadingText
          });
        },
        collapsedItems: slots.collapsedItems
      });
    };
  }
});

export { _Cascader as default };
//# sourceMappingURL=cascader.mjs.map
