/**
 * ldesign v0.4.2
 * (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 popup_index = require('../popup/index.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var selectInput_props = require('./props.js');
var selectInput_useSingle = require('./useSingle.js');
var selectInput_useMultiple = require('./useMultiple.js');
var selectInput_useOverlayInnerStyle = require('./useOverlayInnerStyle.js');
var hooks_tnode = require('../hooks/tnode.js');
require('../utils/withInstall.js');
require('../popup/popup.js');
require('@babel/runtime/helpers/slicedToArray');
require('@popperjs/core');
require('lodash/isFunction');
require('lodash/isObject');
require('lodash/isString');
require('../hooks/useVModel.js');
require('lodash/kebabCase');
require('../utils/dom.js');
require('../_chunks/dep-7f0559c3.js');
require('lodash/isArray');
require('../utils/easing.js');
require('../_common/js/utils/set-style.js');
require('../popup/container.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../hooks/useResizeObserver.js');
require('../popup/props.js');
require('../config-provider/useConfig.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('lodash/camelCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/pick');
require('../input/index.js');
require('../input/input.js');
require('@ldesign/icons-vue-next');
require('lodash/isUndefined');
require('../form/hooks.js');
require('../hooks/useGlobalIcon.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('../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');

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

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

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 useComponentClassName = function useComponentClassName() {
  return {
    NAME_CLASS: hooks_useConfig.usePrefixClass("select-input"),
    BASE_CLASS_BORDERLESS: hooks_useConfig.usePrefixClass("select-input--borderless"),
    BASE_CLASS_MULTIPLE: hooks_useConfig.usePrefixClass("select-input--multiple"),
    BASE_CLASS_POPUP_VISIBLE: hooks_useConfig.usePrefixClass("select-input--popup-visible"),
    BASE_CLASS_EMPTY: hooks_useConfig.usePrefixClass("select-input--empty")
  };
};
var _SelectInput = vue.defineComponent({
  name: "TSelectInput",
  props: _objectSpread({}, selectInput_props["default"]),
  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 = hooks_useConfig.usePrefixClass();
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var selectInputRef = vue.ref();
    var popupRef = vue.ref();
    var _toRefs = vue.toRefs(props2),
      multiple = _toRefs.multiple,
      value = _toRefs.value,
      popupVisible = _toRefs.popupVisible,
      borderless = _toRefs.borderless;
    var _useSingle = selectInput_useSingle["default"](props2, context),
      commonInputProps = _useSingle.commonInputProps,
      onInnerClear = _useSingle.onInnerClear,
      renderSelectSingle = _useSingle.renderSelectSingle;
    var _useMultiple = selectInput_useMultiple["default"](props2, context),
      renderSelectMultiple = _useMultiple.renderSelectMultiple;
    var _useOverlayInnerStyle = selectInput_useOverlayInnerStyle["default"](props2),
      tOverlayInnerStyle = _useOverlayInnerStyle.tOverlayInnerStyle,
      innerPopupVisible = _useOverlayInnerStyle.innerPopupVisible,
      onInnerPopupVisibleChange = _useOverlayInnerStyle.onInnerPopupVisibleChange;
    var classes = vue.computed(function () {
      var _popupVisible$value, _ref;
      return ["".concat(NAME_CLASS.value), (_ref = {}, _defineProperty__default["default"](_ref, BASE_CLASS_MULTIPLE.value, multiple.value), _defineProperty__default["default"](_ref, BASE_CLASS_BORDERLESS.value, borderless.value), _defineProperty__default["default"](_ref, BASE_CLASS_POPUP_VISIBLE.value, (_popupVisible$value = popupVisible.value) !== null && _popupVisible$value !== void 0 ? _popupVisible$value : innerPopupVisible.value), _defineProperty__default["default"](_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 = vue.createVNode(popup_index.Popup, vue.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 vue.createVNode("div", {
      "ref": "selectInputRef",
      "class": this.classes
    }, [mainContent, tipsNode && vue.createVNode("div", {
      "class": "".concat(this.classPrefix, "-input__tips ").concat(this.classPrefix, "-input__tips--").concat(this.status || "normal")
    }, [tipsNode])]);
  }
});

exports["default"] = _SelectInput;
//# sourceMappingURL=select-input.js.map
