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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var omit = require('lodash/omit');
var selectInput_index = require('../select-input/index.js');
var commonComponents_fakeArrow = require('../common-components/fake-arrow.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var form_hooks = require('../form/hooks.js');
var cascader_components_Panel = require('./components/Panel.js');
var cascader_props = require('./props.js');
var cascader_hooks = require('./hooks.js');
var cascader_core_effect = require('./core/effect.js');
var cascader_core_helper = require('./core/helper.js');
var cascader_core_className = require('./core/className.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
require('../utils/withInstall.js');
require('../select-input/select-input.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@babel/runtime/helpers/slicedToArray');
require('@popperjs/core');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isObject');
require('../utils/dom.js');
require('../_chunks/dep-f4db2590.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../_common/js/utils/set-style.js');
require('../hooks/useVModel.js');
require('../popup/props.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('lodash/isUndefined');
require('../hooks/useResizeObserver.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('dayjs');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@ldesign/icons-vue-next');
require('../hooks/useGlobalIcon.js');
require('../hooks/tnode.js');
require('../input/props.js');
require('../input/useInput.js');
require('../form/const.js');
require('../input/useLengthLimit.js');
require('lodash/isNumber');
require('../_common/js/log/log.js');
require('../_common/js/utils/helper.js');
require('lodash/isNull');
require('../input/useInputEventHandler.js');
require('../input/useInputWidth.js');
require('../input/input-group.js');
require('../input/input-group-props.js');
require('../loading/index.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../hooks/useDefaultValue.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag/index.js');
require('../tag/tag.js');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../select-input/useOverlayInnerStyle.js');
require('./components/Item.js');
require('../checkbox/index.js');
require('../checkbox/checkbox.js');
require('../hooks/useRipple.js');
require('../utils/set-style.js');
require('../hooks/useKeepAnimation.js');
require('../checkbox/props.js');
require('../checkbox/constants.js');
require('../checkbox/group.js');
require('lodash/intersection');
require('../hooks/slot.js');
require('../checkbox/checkbox-group-props.js');
require('lodash/isEqual');
require('../_common/js/tree/tree-store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('lodash/difference');
require('lodash/isPlainObject');
require('mitt');
require('../_common/js/tree/tree-node.js');
require('@babel/runtime/helpers/asyncToGenerator');
require('@babel/runtime/regenerator');
require('lodash/uniqueId');
require('lodash/isNil');
require('lodash/get');
require('../_common/js/tree/tree-node-model.js');
require('lodash/isBoolean');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);

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__default["default"](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 = vue.defineComponent({
  name: "TCascader",
  props: _objectSpread({}, cascader_props["default"]),
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var disabled = form_hooks.useFormDisabled();
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("cascader");
    var classPrefix = hooks_useConfig.usePrefixClass();
    var _useCommonClassName = hooks_useConfig.useCommonClassName(),
      STATUS = _useCommonClassName.STATUS;
    var overlayClassName = hooks_useConfig.usePrefixClass("cascader__popup");
    var _useConfig = configProvider_useConfig.useConfig("cascader"),
      globalConfig = _useConfig.globalConfig;
    var _useCascaderContext = cascader_hooks.useCascaderContext(props2),
      cascaderContext = _useCascaderContext.cascaderContext,
      isFilterable = _useCascaderContext.isFilterable;
    var displayValue = vue.computed(function () {
      return props2.multiple ? cascader_core_helper.getMultipleContent(cascaderContext.value) : cascader_core_helper.getSingleContent(cascaderContext.value);
    });
    var panels = vue.computed(function () {
      return cascader_core_helper.getPanels(cascaderContext.value.treeNodes);
    });
    var inputPlaceholder = vue.computed(function () {
      var _props2$placeholder;
      return cascaderContext.value.visible && !props2.multiple && cascader_core_helper.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 vue.createVNode(commonComponents_fakeArrow["default"], {
        "overlayClassName": cascader_core_className.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 vue.createVNode(selectInput_index.SelectInput, vue.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;
          cascader_core_effect.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;
          cascader_core_effect.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__default["default"](props2.selectInputProps, ["onTagChange", "onInputChange", "onPopupVisibleChange", "onBlur", "onFocus", "onClear"])), {
        panel: function panel() {
          return vue.createVNode(cascader_components_Panel["default"], {
            "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
      });
    };
  }
});

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