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

'use strict';

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

var helper = require('../_chunks/dep-c3e1ffac.js');
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var isArray = require('lodash/isArray');
var isFunction = require('lodash/isFunction');
var tree_index = require('../tree/index.js');
var selectInput_index = require('../select-input/index.js');
var commonComponents_fakeArrow = require('../common-components/fake-arrow.js');
var hooks_tnode = require('../hooks/tnode.js');
var treeSelect_props = require('./props.js');
var treeSelect_useTreeSelect = require('./useTreeSelect.js');
require('../utils/map-props.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('vue');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../tree/td-tree.js');
require('lodash/upperFirst');
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');
require('../utils/render-tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../tree/props.js');
require('../tree/hooks/useTreeStore.js');
require('lodash/pick');
require('../_common/js/tree/tree-store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('lodash/isNumber');
require('lodash/isString');
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/isNull');
require('lodash/uniqueId');
require('lodash/isNil');
require('lodash/get');
require('../_common/js/log/log.js');
require('../_common/js/tree/tree-node-model.js');
require('lodash/isUndefined');
require('lodash/isBoolean');
require('lodash/omit');
require('../tree/hooks/useTreeStyles.js');
require('../tree/hooks/useTreeState.js');
require('../tree/hooks/useTreeAction.js');
require('../tree/util.js');
require('../tree/hooks/useTreeScroll.js');
require('../hooks/useVirtualScrollNew.js');
require('@babel/runtime/helpers/slicedToArray');
require('../hooks/useResizeObserver.js');
require('../tree/hooks/useTreeNodes.js');
require('../tree/tree-item.js');
require('../config-provider/config-receiver.js');
require('../utils/ripple.js');
require('../_common/js/utils/set-style.js');
require('../config.js');
require('../tree/hooks/useTreeItem.js');
require('../hooks/useLazyLoad.js');
require('../_common/js/utils/observe.js');
require('../tree/hooks/useItemEvents.js');
require('../tree/hooks/useRenderIcon.js');
require('@ldesign/icons-vue');
require('../hooks/useGlobalIcon.js');
require('../loading/index.js');
require('../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../utils/dom.js');
require('raf');
require('../utils/easing.js');
require('../loading/loading.js');
require('../utils/transfer-dom.js');
require('../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/helper.js');
require('../tree/hooks/useRenderLabel.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('lodash/intersection');
require('../utils/event.js');
require('../utils/helper.js');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../checkbox/checkbox-group-props.js');
require('../tree/hooks/useRenderLine.js');
require('../tree/hooks/useRenderOperations.js');
require('../tree/hooks/useDraggable.js');
require('lodash/throttle');
require('../tree/hooks/useTreeEvents.js');
require('../tree/hooks/useDragHandle.js');
require('../select-input/select-input.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../popup/props.js');
require('../popup/container.js');
require('../popup/utils.js');
require('../popup/trigger.js');
require('../popup/plugin.js');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('../input/index.js');
require('../input/input.js');
require('../input/props.js');
require('../input/input-group.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('../hooks/useVModel.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('lodash/isEmpty');
require('../hooks/render-tnode.js');
require('../select-input/useOverlayInnerStyle.js');
require('../hooks/useFormDisabled.js');
require('./utils.js');

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

var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

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 _TreeSelect = VueCompositionAPI.defineComponent({
  name: "TTreeSelect",
  props: _objectSpread({}, treeSelect_props["default"]),
  setup: function setup(props2, context) {
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var renderDefaultTNode = hooks_tnode.useTNodeDefault();
    var treeSelectInfo = treeSelect_useTreeSelect["default"](props2, context);
    var dropdownInnerSize = treeSelectInfo.dropdownInnerSize,
      treeSelectValue = treeSelectInfo.treeSelectValue;
    var multiLimitDisabled = VueCompositionAPI.computed(function () {
      return props2.multiple && !!props2.max && isArray__default["default"](treeSelectValue.value) && props2.max <= treeSelectValue.value.length;
    });
    return _objectSpread(_objectSpread({}, treeSelectInfo), {}, {
      dropdownInnerSize: dropdownInnerSize,
      multiLimitDisabled: multiLimitDisabled,
      renderTNodeJSX: renderTNodeJSX,
      renderDefaultTNode: renderDefaultTNode
    });
  },
  methods: {
    renderSuffixIcon: function renderSuffixIcon() {
      var _ref;
      var h = this.$createElement;
      return h(commonComponents_fakeArrow["default"], {
        "attrs": {
          "isActive": this.innerVisible,
          "disabled": this.disabled,
          "overlayClassName": (_ref = {}, _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-fake-arrow--highlight"), this.innerVisible), _defineProperty__default["default"](_ref, "".concat(this.classPrefix, "-fake-arrow--disable"), this.disabled), _ref)
        }
      });
    },
    renderLabel: function renderLabel() {
      var h = this.$createElement;
      var label = this.renderTNodeJSX("label");
      var prefixIcon = this.renderTNodeJSX("prefixIcon");
      if (label && prefixIcon) {
        return h("div", [label, prefixIcon]);
      }
      return label || prefixIcon;
    },
    getTreePanel: function getTreePanel() {
      var _this = this;
      var h = this.$createElement;
      return h("div", {
        "class": ["".concat(this.classPrefix, "-select__dropdown-inner"), "".concat(this.classPrefix, "-select__dropdown-inner--size-").concat(this.dropdownInnerSize)]
      }, [this.loading && !this.tDisabled ? h("p", {
        "class": ["".concat(this.classPrefix, "-select__loading-tips"), "".concat(this.classPrefix, "-select__right-icon-polyfill")]
      }, [this.renderDefaultTNode("loadingText", {
        defaultNode: h("div", {
          "class": "".concat(this.classPrefix, "-select__empty")
        }, [this.global.loadingText])
      })]) : null, !this.loading ? h(tree_index.Tree, helper.helper([{
        "ref": "treeRef"
      }, {
        "props": _objectSpread({
          keys: this.tKeys,
          value: _toConsumableArray__default["default"](this.multipleChecked),
          actived: this.singleActivated,
          hover: true,
          data: this.data,
          activable: !this.multiple,
          checkable: this.multiple,
          disabled: this.tDisabled || this.multiLimitDisabled,
          size: this.size,
          filter: this.filterByText,
          icon: !this.filterByText,
          activeMultiple: this.multiple,
          onExpand: this.treeNodeExpand,
          onLoad: this.treeNodeLoad,
          onChange: this.treeNodeChange,
          onActive: this.treeNodeActive,
          expandOnClickNode: true,
          empty: function empty() {
            return _this.renderDefaultTNode("empty", {
              defaultNode: h("div", {
                "class": "".concat(_this.classPrefix, "-select__empty")
              }, [_this.global.empty])
            });
          }
        }, this.treeProps)
      }])) : null]);
    },
    renderCollapsedItems: function renderCollapsedItems() {
      var selectedNodeInfo = this.nodeInfo || [];
      var value = Array.isArray(selectedNodeInfo) ? selectedNodeInfo : [selectedNodeInfo];
      return this.renderTNodeJSX("collapsedItems", {
        params: {
          value: value,
          collapsedSelectedItems: value.slice(this.minCollapsedNum),
          count: value.length - this.minCollapsedNum
        }
      });
    }
  },
  render: function render() {
    var _this2 = this;
    var h = arguments[0];
    var slots = this.$scopedSlots;
    return h(selectInput_index.SelectInput, {
      "scopedSlots": {
        tips: slots.tips,
        suffix: slots.suffix
      },
      "class": "".concat(this.classPrefix, "-tree-select"),
      "props": _objectSpread({}, _objectSpread({
        keys: this.tKeys,
        value: this.nodeInfo,
        inputValue: this.innerInputValue,
        popupVisible: this.innerVisible,
        disabled: this.tDisabled,
        multiple: this.multiple,
        loading: this.loading,
        clearable: this.clearable,
        autofocus: this.autofocus,
        autoWidth: this.autoWidth,
        borderless: this.borderless,
        readonly: this.readonly,
        placeholder: this.inputPlaceholder,
        status: this.status,
        tips: this.tips,
        suffix: this.suffix,
        allowInput: Boolean(this.filterable || isFunction__default["default"](this.filter) || this.$listeners.search || this.onSearch),
        minCollapsedNum: this.minCollapsedNum,
        collapsedItems: this.renderCollapsedItems,
        popupProps: _objectSpread({
          overlayClassName: this.popupClass
        }, this.popupProps),
        inputProps: _objectSpread({
          size: this.size
        }, this.inputProps),
        tagInputProps: {
          size: this.size
        },
        tagProps: _objectSpread({
          maxWidth: 300
        }, this.tagProps),
        label: this.renderLabel,
        suffixIcon: this.renderSuffixIcon,
        onClear: this.clear,
        onBlur: this.onInnerBlur,
        onFocus: this.onInnerFocus,
        onInputChange: this.inputChange,
        onTagChange: this.tagChange,
        onEnter: this.onInnerEnter,
        onPopupVisibleChange: this.onInnerPopupVisibleChange,
        valueDisplay: function valueDisplay() {
          var _ref2;
          return _this2.renderTNodeJSX("valueDisplay", {
            params: _this2.multiple ? {
              value: _this2.nodeInfo,
              onClose: function onClose(value, context) {
                _this2.tagChange(value, context);
              }
            } : {
              value: _this2.nodeInfo || (_ref2 = {}, _defineProperty__default["default"](_ref2, _this2.tKeys.label, ""), _defineProperty__default["default"](_ref2, _this2.tKeys.value, void 0), _ref2)
            }
          });
        },
        panel: this.getTreePanel
      }, this.selectInputProps))
    });
  }
});

exports["default"] = _TreeSelect;
//# sourceMappingURL=tree-select.js.map
