<template>
  <view :class="refClass" :style="refStyle" :id="referenceId" @click="onClick">
    <slot></slot>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed, inject, onMounted, getCurrentInstance } from "vue";
import {
  classNames,
  stringifyStyle,
  getBoundingClientRect,
  uniqid
} from "../utils";
import {
  popoverContextSymbol,
  popoverReferenceProps
} from "../popover/common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "popover-reference",
  props: popoverReferenceProps,
  emits: ["click"],
  setup(__props, { expose: __expose, emit: __emit }) {
    __expose();
    const props = __props;
    const emit = __emit;
    const referenceId = uniqid();
    const instance = getCurrentInstance();
    const context = inject(popoverContextSymbol);
    const getRect = () => {
      return getBoundingClientRect(`#${referenceId}`, instance);
    };
    onMounted(() => {
      context?.register({
        getRect
      });
    });
    const onClick = (event) => {
      context?.show();
      emit("click", event);
    };
    const refClass = computed(() => {
      return classNames(props.rootClass);
    });
    const refStyle = computed(() => {
      return stringifyStyle(props.rootStyle);
    });
    const __returned__ = { props, emit, referenceId, instance, context, getRect, onClick, refClass, refStyle };
    return __returned__;
  }
});
</script>
