import { computed, createVNode, mergeProps } from "vue";
import "./styles/tooltip.scss";
import { useProxiedModel } from "../../composables/proxied-model/index.mjs";
import { makeOverlayProps, Overlay } from "../overlay/overlay.mjs";
import { ScaleTransition } from "../transition/scale-transition.mjs";
import { genericComponent } from "../../utils/define-component.mjs";
import { getUid } from "../../utils/dist/index.mjs";
const Tooltip = genericComponent()({
  name: "VeTooltip",
  props: {
    id: String,
    text: String,
    arrow: {
      type: Boolean,
      default: true
    },
    ...makeOverlayProps({
      anchor: "top",
      maxWidth: 300,
      minWidth: 0,
      offset: 10,
      openOnClick: false,
      openOnHover: true,
      origin: "auto",
      positionStrategy: "connected",
      scrollStrategy: "reposition",
      transition: {
        component: ScaleTransition
      }
    })
  },
  emits: {
    "update:modelValue": (_modelValue) => true
  },
  setup(props, {
    slots
  }) {
    const isActive = useProxiedModel(props, "modelValue");
    const id = computed(() => props.id || `ve-tooltip-${getUid()}`);
    const anchor = computed(() => {
      return props.anchor.split(" ").length > 1 ? props.anchor : `${props.anchor} center`;
    });
    const origin = computed(() => {
      return props.origin === "auto" || props.origin === "overlap" || props.origin.split(" ").length > 1 || props.anchor.split(" ").length > 1 ? props.origin : `${props.origin} center`;
    });
    return () => {
      return createVNode(Overlay, mergeProps(props, {
        "absolute": true,
        "activatorProps": {
          "aria-describedby": id.value
        },
        "anchor": anchor.value,
        "class": "ve-tooltip",
        "contentClass": "ve-tooltip__wrapper",
        "id": id.value,
        "origin": origin.value,
        "persistent": true,
        "role": "tooltip",
        "scrim": false,
        "modelValue": isActive.value,
        "onUpdate:modelValue": ($event) => isActive.value = $event
      }), {
        default: () => {
          var _a, _b;
          return [(_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) != null ? _b : props.text, props.arrow && createVNode("div", {
            "class": "ve-tooltip__arrow"
          }, null)];
        },
        activator: slots.activator
      });
    };
  }
});
export {
  Tooltip
};
//# sourceMappingURL=tooltip.mjs.map
