/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { h as helper } from '../../chunks/helper.js';
import { defineComponent, ref, toRefs, computed } from '@vue/composition-api';
import { Popup } from '../popup/index.js';
import { useConfig } from '../config-provider/useConfig.js';
import props from './props.js';
import useSingle from './hooks/use-single.js';
import useMultiple from './hooks/use-multiple.js';
import useOverlayInnerStyle from './hooks/use-overlay-innerstyle.js';
import '../../chunks/_commonjsHelpers.js';
import '../../utils/map-props.js';
import 'vue';
import '../../utils/with-install.js';
import 'lodash';
import '../../config.js';
import '../popup/popup.js';
import '@popperjs/core';
import '../../chunks/set-style.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import '../popup/props.js';
import '../popup/container.js';
import '../popup/style/css.js';
import '../popup/type.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../input/index.js';
import '../input/input.js';
import '@ldesign/icons-vue';
import 'lodash/kebabCase';
import '../../chunks/helper2.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../utils/event.js';
import '../input/props.js';
import '../input/group.js';
import '../input/style/css.js';
import '../input/type.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../../hooks/lnode.js';
import 'lodash/isEmpty';
import 'lodash/isFunction';
import '../../hooks/render-lnode.js';
import '../../hooks/use-config.js';
import '../../hooks/use-default-value.js';
import '../tag-input/index.js';
import '../tag-input/tag-input.js';
import '../../hooks/use-global-icon.js';
import '../tag-input/props.js';
import '../tag-input/hooks/use-tag-scroll.js';
import '../tag-input/hooks/use-tag-list.js';
import '../tag/index.js';
import '../tag/tag.js';
import '../tag/props.js';
import '../tag/check-tag.js';
import '../tag/style/css.js';
import '../tag/type.js';
import '../../hooks/use-vmodel.js';
import '../tag-input/hooks/use-hover.js';
import '../tag-input/hooks/use-drag-sorter.js';
import '../tag-input/style/css.js';
import '../tag-input/type.js';

var _SelectInput = defineComponent({
  name: "LSelectInput",
  props: {
    ...props,
    updateScrollTop: {
      type: Function
    }
  },
  setup(props2, context) {
    const selectInputRef = ref();
    const selectInputWrapRef = ref();
    const {
      classPrefix
    } = useConfig("classPrefix");
    const {
      multiple,
      value,
      popupVisible,
      borderless
    } = toRefs(props2);
    const {
      commonInputProps,
      onInnerClear,
      renderSelectSingle
    } = useSingle(props2, context);
    const {
      renderSelectMultiple
    } = useMultiple(props2, context);
    const {
      tOverlayInnerStyle,
      innerPopupVisible,
      onInnerPopupVisibleChange
    } = useOverlayInnerStyle(props2);
    const popupClasses = computed(() => [{
      [`${classPrefix.value}-select-input--borderless`]: borderless.value,
      [`${classPrefix.value}-select-input--multiple`]: multiple.value,
      [`${classPrefix.value}-select-input--popup-visible`]: popupVisible.value ?? innerPopupVisible.value,
      [`${classPrefix.value}-select-input--empty`]: Array.isArray(value.value) ? !value.value.length : !value.value
    }]);
    return {
      selectInputWrapRef,
      innerPopupVisible,
      commonInputProps,
      tOverlayInnerStyle,
      selectInputRef,
      popupClasses,
      onInnerClear,
      renderSelectSingle,
      renderSelectMultiple,
      onInnerPopupVisibleChange,
      classPrefix
    };
  },
  render(h) {
    var _this$popupProps;
    const visibleProps = {
      visible: this.popupVisible ?? this.innerPopupVisible
    };
    const 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.popupVisible ?? this.innerPopupVisible,
        "content": this.panel,
        "hideEmptyPopup": true,
        "disabled": this.disabled
      },
      "scopedSlots": {
        ...this.$scopedSlots,
        content: this.$scopedSlots.panel
      }
    }, {
      "on": {
        "visible-change": this.onInnerPopupVisibleChange
      }
    }, {}, {
      "props": {
        ...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": `${this.classPrefix}-select-input__wrap`
    }, [mainContent, h("div", {
      "class": `${this.classPrefix}-input__tips ${this.classPrefix}-input__tips--${this.status || "normal"}`
    }, [this.tips])]);
  }
});

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