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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, ref, toRefs, computed, createVNode, mergeProps } from 'vue';
import { Popup } from '../popup/index.js';
import { usePrefixClass } from '../hooks/useConfig.js';
import props from './props.js';
import useSingle from './useSingle.js';
import useMultiple from './useMultiple.js';
import useOverlayInnerStyle from './useOverlayInnerStyle.js';
import { useTNodeJSX } from '../hooks/tnode.js';
import '../utils/withInstall.js';
import '../popup/popup.js';
import '@babel/runtime/helpers/slicedToArray';
import '@popperjs/core';
import 'lodash/isString';
import 'lodash/isFunction';
import 'lodash/isObject';
import '../utils/dom.js';
import '../_chunks/dep-e041f5b0.js';
import 'lodash/isArray';
import '../utils/easing.js';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../_common/js/utils/set-style.js';
import '../hooks/useVModel.js';
import '../popup/props.js';
import '../popup/container.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'lodash/isUndefined';
import '../hooks/useResizeObserver.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import 'dayjs';
import 'lodash/pick';
import '../input/index.js';
import '../input/input.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@ldesign/icons-vue-next';
import '../form/hooks.js';
import '../hooks/useGlobalIcon.js';
import '../input/props.js';
import '../input/useInput.js';
import '../form/const.js';
import '../input/useLengthLimit.js';
import 'lodash/isNumber';
import '../_common/js/log/log.js';
import '../_common/js/utils/helper.js';
import 'lodash/isNull';
import '../input/useInputEventHandler.js';
import '../input/useInputWidth.js';
import '../input/input-group.js';
import '../input/input-group-props.js';
import '../loading/index.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../loading/loading.js';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.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-input/hooks/useHover.js';
import '../tag-input/hooks/useDragSorter.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 useComponentClassName = function useComponentClassName() {
  return {
    NAME_CLASS: usePrefixClass("select-input"),
    BASE_CLASS_BORDERLESS: usePrefixClass("select-input--borderless"),
    BASE_CLASS_MULTIPLE: usePrefixClass("select-input--multiple"),
    BASE_CLASS_POPUP_VISIBLE: usePrefixClass("select-input--popup-visible"),
    BASE_CLASS_EMPTY: usePrefixClass("select-input--empty")
  };
};
var _SelectInput = defineComponent({
  name: "TSelectInput",
  props: _objectSpread({}, props),
  setup: function setup(props2, context) {
    var _useComponentClassNam = useComponentClassName(),
      NAME_CLASS = _useComponentClassNam.NAME_CLASS,
      BASE_CLASS_BORDERLESS = _useComponentClassNam.BASE_CLASS_BORDERLESS,
      BASE_CLASS_MULTIPLE = _useComponentClassNam.BASE_CLASS_MULTIPLE,
      BASE_CLASS_POPUP_VISIBLE = _useComponentClassNam.BASE_CLASS_POPUP_VISIBLE,
      BASE_CLASS_EMPTY = _useComponentClassNam.BASE_CLASS_EMPTY;
    var classPrefix = usePrefixClass();
    var renderTNodeJSX = useTNodeJSX();
    var selectInputRef = ref();
    var popupRef = ref();
    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 classes = computed(function () {
      var _popupVisible$value, _ref;
      return ["".concat(NAME_CLASS.value), (_ref = {}, _defineProperty(_ref, BASE_CLASS_MULTIPLE.value, multiple.value), _defineProperty(_ref, BASE_CLASS_BORDERLESS.value, borderless.value), _defineProperty(_ref, BASE_CLASS_POPUP_VISIBLE.value, (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty(_ref, BASE_CLASS_EMPTY.value, Array.isArray(value.value) ? !value.value.length : !value.value), _ref)];
    });
    return {
      classPrefix: classPrefix,
      NAME_CLASS: NAME_CLASS,
      innerPopupVisible: innerPopupVisible,
      commonInputProps: commonInputProps,
      tOverlayInnerStyle: tOverlayInnerStyle,
      selectInputRef: selectInputRef,
      popupRef: popupRef,
      classes: classes,
      onInnerClear: onInnerClear,
      renderTNodeJSX: renderTNodeJSX,
      renderSelectSingle: renderSelectSingle,
      renderSelectMultiple: renderSelectMultiple,
      onInnerPopupVisibleChange: onInnerPopupVisibleChange
    };
  },
  render: function render() {
    var _this$popupVisible,
      _this$popupProps,
      _this = this;
    var visibleProps = {
      visible: (_this$popupVisible = this.popupVisible) !== null && _this$popupVisible !== void 0 ? _this$popupVisible : this.innerPopupVisible
    };
    var mainContent = createVNode(Popup, mergeProps({
      "ref": "popupRef",
      "trigger": ((_this$popupProps = this.popupProps) === null || _this$popupProps === void 0 ? void 0 : _this$popupProps.trigger) || "click",
      "placement": "bottom-left"
    }, visibleProps, {
      "content": this.panel,
      "hideEmptyPopup": true
    }, _objectSpread(_objectSpread({
      onVisibleChange: this.onInnerPopupVisibleChange
    }, this.popupProps), {}, {
      overlayInnerStyle: this.tOverlayInnerStyle
    })), _objectSpread({
      "default": function _default() {
        return [_this.multiple ? _this.renderSelectMultiple({
          commonInputProps: _this.commonInputProps,
          onInnerClear: _this.onInnerClear,
          popupVisible: visibleProps.visible
        }) : _this.renderSelectSingle(visibleProps.visible)];
      }
    }, _objectSpread(_objectSpread({}, this.$slots), {}, {
      content: this.$slots.panel
    })));
    var tipsNode = this.renderTNodeJSX("tips");
    return createVNode("div", {
      "ref": "selectInputRef",
      "class": this.classes
    }, [mainContent, tipsNode && createVNode("div", {
      "class": "".concat(this.classPrefix, "-input__tips ").concat(this.classPrefix, "-input__tips--").concat(this.status || "normal")
    }, [tipsNode])]);
  }
});

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