"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const select = require("../../select/src/select.js");
const index = require("../../select/index.js");
const tree = require("../../tree/src/tree.js");
const index$1 = require("../../tree/index.js");
const select$1 = require("./select.js");
const tree$1 = require("./tree.js");
const cacheOptions = require("./cache-options.js");
const Vue = require("vue");
const pick = require("../../../../../lodash-es/pick.js");
var tree_select_vue_vue_type_script_lang_default = Vue.defineComponent({
  name: "ElTreeSelect",
  inheritAttrs: false,
  props: {
    ...select.selectProps,
    ...tree.treeProps,
    cacheData: {
      type: Array,
      default: () => []
    }
  },
  setup(props, context) {
    const { slots, expose, emit, attrs } = context;
    const childAttrs = {
      ...attrs,
      onChange: void 0
    };
    const select2 = Vue.ref();
    const tree2 = Vue.ref();
    const key = Vue.computed(() => props.nodeKey || props.valueKey || "value");
    const selectProps = select$1.useSelect(props, {
      attrs,
      emit
    }, {
      select: select2,
      tree: tree2,
      key
    });
    const { cacheOptions: cacheOptions$1, ...treeProps } = tree$1.useTree(props, {
      attrs: childAttrs,
      slots,
      emit
    }, {
      select: select2,
      tree: tree2,
      key
    });
    const methods = Vue.reactive({});
    expose(methods);
    Vue.onMounted(() => {
      Object.assign(methods, {
        ...pick.default(tree2.value, [
          "filter",
          "updateKeyChildren",
          "getCheckedNodes",
          "setCheckedNodes",
          "getCheckedKeys",
          "setCheckedKeys",
          "setChecked",
          "getHalfCheckedNodes",
          "getHalfCheckedKeys",
          "getCurrentKey",
          "getCurrentNode",
          "setCurrentKey",
          "setCurrentNode",
          "getNode",
          "remove",
          "append",
          "insertBefore",
          "insertAfter"
        ]),
        ...pick.default(select2.value, [
          "focus",
          "blur",
          "selectedLabel"
        ]),
        treeRef: tree2.value,
        selectRef: select2.value
      });
    });
    return () => Vue.h(
      index.ElSelect,
      /**
      * 1. The `props` is processed into `Refs`, but `v-bind` and
      * render function props cannot read `Refs`, so use `reactive`
      * unwrap the `Refs` and keep reactive.
      * 2. The keyword `ref` requires `Ref`, but `reactive` broke it,
      * so use function.
      */
      Vue.reactive({
        ...selectProps,
        ref: (ref) => select2.value = ref
      }),
      {
        ...slots,
        default: () => [Vue.h(cacheOptions.default, { data: cacheOptions$1.value }), Vue.h(index$1.ElTree, Vue.reactive({
          ...treeProps,
          ref: (ref) => tree2.value = ref
        }))]
      }
    );
  }
});
exports.default = tree_select_vue_vue_type_script_lang_default;
