import { defineComponent, useSlots, ref, computed, watchEffect, openBlock, createBlock, unref, createSlots, withCtx, renderSlot, createElementVNode, createElementBlock, createVNode, createCommentVNode } from "vue";
import { _ as _sfc_main$3, s as select_plat_icon } from "./index11.js";
import { _ as _sfc_main$2 } from "./index3.js";
import { Popover } from "vant";
import "./index4.js";
import "./index5.js";
import "@wltech/svg";
const __default__$1 = {
  name: "WlPopover"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    actions: { default: null },
    modelValue: { type: Boolean, default: false }
  },
  emits: ["update:modelValue", "onSelect"],
  setup(__props, { emit }) {
    const props = __props;
    const slots = useSlots();
    const hasDefault = ref(slots.default !== void 0);
    const slotName = computed(() => hasDefault.value ? "default" : "content");
    const popoverVisible = ref(false);
    const onTogglePopover = (bool) => {
      popoverVisible.value = bool;
      emit("update:modelValue", bool);
    };
    const onSelect = (val) => {
      emit("onSelect", val);
      onTogglePopover(false);
    };
    watchEffect(() => {
      popoverVisible.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Popover), {
        show: popoverVisible.value,
        "onUpdate:show": _cache[1] || (_cache[1] = ($event) => popoverVisible.value = $event),
        actions: __props.actions,
        onSelect
      }, createSlots({
        reference: withCtx(() => [
          renderSlot(_ctx.$slots, "reference")
        ]),
        _: 2
      }, [
        hasDefault.value ? {
          name: unref(slotName),
          fn: withCtx(() => [
            createElementVNode("div", {
              onClick: _cache[0] || (_cache[0] = ($event) => popoverVisible.value = false)
            }, [
              renderSlot(_ctx.$slots, "default")
            ])
          ])
        } : void 0
      ]), 1032, ["show", "actions"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = { class: "select-input" };
const _hoisted_2 = { class: "input-wrap" };
const _hoisted_3 = { class: "arrow-wrap" };
const __default__ = {
  name: "RfSelectInput"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { default: "" },
    placeholder: { default: "" },
    actions: { default: null }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const inputValue = ref("");
    const popoverVisible = ref(false);
    watchEffect(() => {
      inputValue.value = props.modelValue;
    });
    const onChange = (val) => {
      emit("update:modelValue", val);
    };
    const onSelect = (data) => {
      popoverVisible.value = false;
      inputValue.value = data.text;
      emit("update:modelValue", data.text);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createVNode(_sfc_main$2, {
            paddingLeft: 0,
            modelValue: inputValue.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
            onOnChange: onChange,
            placeholder: __props.placeholder,
            onFocus: _cache[1] || (_cache[1] = ($event) => popoverVisible.value = false)
          }, null, 8, ["modelValue", "placeholder"])
        ]),
        __props.actions && __props.actions.length > 0 ? (openBlock(), createBlock(_sfc_main$1, {
          key: 0,
          modelValue: popoverVisible.value,
          "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => popoverVisible.value = $event),
          trigger: "click",
          actions: __props.actions,
          placement: "bottom-end",
          onSelect
        }, {
          reference: withCtx(() => [
            createElementVNode("div", _hoisted_3, [
              createVNode(_sfc_main$3, { src: unref(select_plat_icon) }, null, 8, ["src"])
            ])
          ]),
          _: 1
        }, 8, ["modelValue", "actions"])) : createCommentVNode("", true)
      ]);
    };
  }
});
export { _sfc_main as default };
