import { ref, onMounted, onUnmounted } from "vue";
import { useI18n } from "../../../locales/index.mjs";
function useUserInfo() {
  const { t } = useI18n();
  const userInfoRef = ref();
  const showUserControl = ref(false);
  function handleUserControl() {
    showUserControl.value = !showUserControl.value;
  }
  function hideUserControl(event) {
    var _a;
    if (!((_a = userInfoRef.value) == null ? void 0 : _a.contains(event.target))) {
      showUserControl.value = false;
    }
  }
  onMounted(() => {
    window.addEventListener("click", hideUserControl);
  });
  onUnmounted(() => {
    window.removeEventListener("click", hideUserControl);
  });
  return {
    t,
    showUserControl,
    userInfoRef,
    handleUserControl
  };
}
export {
  useUserInfo as default
};
