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

import { h as helper } from '../../_chunks/dep-29915b8e.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 '../../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/dep-cf772670.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../_chunks/dep-70c789e5.js';
import '../../_chunks/dep-5210251b.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/dep-def4c2ce.js';
import '../../utils/mixins.js';
import '../popup/props.js';
import '../popup/container.js';
import 'lodash/isObject';
import 'lodash/pick';
import '../input/index.js';
import '../input/input.js';
import '@ldesign/icons-vue';
import 'lodash/kebabCase';
import '../../_chunks/dep-47d77fc8.js';
import '../../utils/event.js';
import '../input/props.js';
import '../input/group.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../_chunks/dep-eb467ddf.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 '../../hooks/use-vmodel.js';
import '../tag-input/hooks/use-hover.js';
import '../tag-input/hooks/use-drag-sorter.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
