"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const MemberInfo = require("../MemberItemCommon/MemberInfo.vue.js");
const index = require("../MemberControl/index.js");
const useMemberItemHooks = require("./useMemberItemHooks.js");
const vTap = require("../../../directives/vTap.js");
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "indexH5",
  props: {
    userInfo: {}
  },
  setup(__props) {
    const props = __props;
    const memberItemContainerRef = Vue.ref();
    const { isMemberControlAccessible, openMemberControl, closeMemberControl } = useMemberItemHooks.default(props.userInfo);
    const showMemberControl = Vue.ref(false);
    Vue.watch(isMemberControlAccessible, (accessible) => {
      if (accessible === false) {
        showMemberControl.value = false;
      }
    });
    const handleOpenMemberControl = (event) => {
      event.stopPropagation();
      openMemberControl();
      if (isMemberControlAccessible.value === true) {
        showMemberControl.value = true;
      }
    };
    const handleDocumentTouchend = (event) => {
      var _a;
      if ((_a = memberItemContainerRef.value) == null ? void 0 : _a.contains(event == null ? void 0 : event.target)) {
        return;
      }
      closeMemberControl();
      showMemberControl.value = false;
    };
    Vue.onMounted(() => {
      document.addEventListener("touchend", handleDocumentTouchend);
    });
    Vue.onUnmounted(() => {
      document.removeEventListener("touchend", handleDocumentTouchend);
    });
    return (_ctx, _cache) => {
      return Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", {
        ref_key: "memberItemContainerRef",
        ref: memberItemContainerRef,
        class: "member-item-container"
      }, [
        Vue.createVNode(MemberInfo.default, {
          "show-state-icon": true,
          "user-info": props.userInfo
        }, null, 8, ["user-info"]),
        Vue.withDirectives(Vue.createVNode(Vue.unref(index.default), {
          "show-member-control": showMemberControl.value,
          "user-info": props.userInfo,
          onOnCloseControl: handleDocumentTouchend
        }, null, 8, ["show-member-control", "user-info"]), [
          [Vue.vShow, showMemberControl.value]
        ])
      ])), [
        [Vue.unref(vTap.default), handleOpenMemberControl]
      ]);
    };
  }
});
exports.default = _sfc_main;
