/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-a4bd011a.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, computed } from '@vue/composition-api';
import { Popup } from '../popup/index.js';
import props from './props.js';
import useSingle from './useSingle.js';
import useMultiple from './useMultiple.js';
import useOverlayInnerStyle from './useOverlayInnerStyle.js';
import { useConfig } from '../config-provider/useConfig.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/typeof';
import '@popperjs/core';
import '../utils/dom.js';
import 'vue';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/utils/set-style.js';
import '../popup/props.js';
import '../popup/container.js';
import '../config-provider/config-receiver.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 '../config-provider/type.js';
import '../utils/mixins.js';
import '../utils/map-props.js';
import '../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../popup/type.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../input/index.js';
import '../input/input.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'tdesign-icons-vue';
import '../_common/js/utils/helper.js';
import '../utils/event.js';
import '../input/props.js';
import '../input/input-group.js';
import '../input/type.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../config.js';
import '../hooks/tnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import '../hooks/render-tnode.js';
import '../hooks/useConfig.js';
import '../hooks/useDefaultValue.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../tag-input/props.js';
import '../tag-input/hooks/useTagScroll.js';
import '../tag-input/useTagList.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/check-tag-props.js';
import '../tag/type.js';
import '../hooks/useVModel.js';
import '../tag-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.js';
import '../hooks/useGlobalIcon.js';
import '../tag-input/type.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 _SelectInput = defineComponent({
  name: "TSelectInput",
  props: _objectSpread(_objectSpread({}, props), {}, {
    updateScrollTop: {
      type: Function
    }
  }),
  setup: function setup(props2, context) {
    var selectInputRef = ref();
    var selectInputWrapRef = ref();

    var _useConfig = useConfig("classPrefix"),
        classPrefix = _useConfig.classPrefix;

    var _toRefs = toRefs(props2),
        multiple = _toRefs.multiple,
        value = _toRefs.value,
        popupVisible = _toRefs.popupVisible,
        borderless = _toRefs.borderless;

    var _useSingle = useSingle(props2, context),
        commonInputProps = _useSingle.commonInputProps,
        onInnerClear = _useSingle.onInnerClear,
        renderSelectSingle = _useSingle.renderSelectSingle;

    var _useMultiple = useMultiple(props2, context),
        renderSelectMultiple = _useMultiple.renderSelectMultiple;

    var _useOverlayInnerStyle = useOverlayInnerStyle(props2),
        tOverlayInnerStyle = _useOverlayInnerStyle.tOverlayInnerStyle,
        innerPopupVisible = _useOverlayInnerStyle.innerPopupVisible,
        onInnerPopupVisibleChange = _useOverlayInnerStyle.onInnerPopupVisibleChange;

    var popupClasses = computed(function () {
      var _popupVisible$value, _ref;

      return [(_ref = {}, _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--borderless"), borderless.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--multiple"), multiple.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--popup-visible"), (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty(_ref, "".concat(classPrefix.value, "-select-input--empty"), value.value instanceof Array ? !value.value.length : !value.value), _ref)];
    });
    return {
      selectInputWrapRef: selectInputWrapRef,
      innerPopupVisible: innerPopupVisible,
      commonInputProps: commonInputProps,
      tOverlayInnerStyle: tOverlayInnerStyle,
      selectInputRef: selectInputRef,
      popupClasses: popupClasses,
      onInnerClear: onInnerClear,
      renderSelectSingle: renderSelectSingle,
      renderSelectMultiple: renderSelectMultiple,
      onInnerPopupVisibleChange: onInnerPopupVisibleChange,
      classPrefix: classPrefix
    };
  },
  render: function render(h) {
    var _this$popupVisible, _this$popupProps, _this$popupVisible2;

    var visibleProps = {
      visible: (_this$popupVisible = this.popupVisible) !== null && _this$popupVisible !== void 0 ? _this$popupVisible : this.innerPopupVisible
    };
    var mainContent = h(Popup, helper([{
      "ref": "selectInputRef",
      "class": this.popupClasses,
      "attrs": {
        "trigger": ((_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.trigger) || "click",
        "placement": "bottom-left",
        "visible": (_this$popupVisible2 = this.popupVisible) !== null && _this$popupVisible2 !== void 0 ? _this$popupVisible2 : this.innerPopupVisible,
        "content": this.panel,
        "hideEmptyPopup": true,
        "disabled": this.disabled
      },
      "scopedSlots": _objectSpread(_objectSpread({}, this.$scopedSlots), {}, {
        content: this.$scopedSlots.panel
      })
    }, {
      "on": {
        "visible-change": this.onInnerPopupVisibleChange
      }
    }, {}, {
      "props": _objectSpread(_objectSpread({}, this.popupProps), {}, {
        overlayInnerStyle: this.tOverlayInnerStyle
      })
    }, {
      "attrs": {
        "updateScrollTop": this.updateScrollTop
      }
    }]), [this.multiple ? this.renderSelectMultiple({
      commonInputProps: this.commonInputProps,
      onInnerClear: this.onInnerClear,
      popupVisible: visibleProps.visible
    }, h) : this.renderSelectSingle(h, visibleProps.visible)]);
    if (!this.tips) return mainContent;
    return h("div", {
      "ref": "selectInputWrapRef",
      "class": "".concat(this.classPrefix, "-select-input__wrap")
    }, [mainContent, h("div", {
      "class": "".concat(this.classPrefix, "-input__tips ").concat(this.classPrefix, "-input__tips--").concat(this.status || "normal")
    }, [this.tips])]);
  }
});

export { _SelectInput as default };
//# sourceMappingURL=select-input.js.map
