import { defineComponent, inject, getCurrentInstance, computed, ref, onMounted, createVNode, mergeProps } from 'vue';
import '../../slot/index.mjs';
import { useTooltipProps, tooltipEmits } from './props.mjs';
import { groupToolTipInjectKey } from './utils.mjs';
import Main from './main.mjs';
import { OnlyChild } from '../../slot/src/only-child.mjs';

const Tooltip = defineComponent({
  name: "ElTooltip",
  props: useTooltipProps,
  emits: tooltipEmits,
  setup(props, ctx) {
    const groupData = inject(groupToolTipInjectKey, null);
    const instance = getCurrentInstance();
    const computedData = computed(() => {
      return {
        ...instance.vnode.props || {},
        ...props,
        content: ctx.slots.content ? ctx.slots.content : props.content,
        __provides__: instance == null ? void 0 : instance.provides
      };
    });
    const main = ref();
    const exposeValue = new Proxy({}, {
      get(target, key) {
        var _a;
        return (_a = main.value) == null ? void 0 : _a[key];
      },
      has(target, p) {
        return main.value ? Reflect.has(main.value, p) : false;
      }
    });
    ctx.expose(exposeValue);
    if (groupData && !props.boolGroupTooltipUncontrolled) {
      onMounted(() => {
        groupData.instanceData.set(instance.proxy.$el, computedData);
      });
      return () => {
        return createVNode(OnlyChild, {
          "class": groupData.key
        }, {
          default: () => [ctx.slots.default()[0]]
        });
      };
    } else {
      const emits = tooltipEmits.reduce((em, item) => {
        em[`on-${item}`.replace(/-(\w)/g, (_, c) => c.toUpperCase())] = (...args) => ctx.emit(item, ...args);
        return em;
      }, {});
      return () => {
        return createVNode(Main, mergeProps({
          "ref": main
        }, props, emits), ctx.slots);
      };
    }
  }
});

export { Tooltip };
//# sourceMappingURL=render.mjs.map
