"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const RoomInvitationH5 = require("./RoomInvitationH5.vue2.js");
const ROOM_INVITATION_H5_CONTAINER_ID = "room-invitation-h5-container";
let roomInvitationH5Container = null;
let currentRoomInvitationH5App = null;
const hideRoomInvitationH5 = () => {
  if (currentRoomInvitationH5App) {
    vue.render(null, roomInvitationH5Container);
    currentRoomInvitationH5App = null;
  }
  if (roomInvitationH5Container) {
    document.body.removeChild(roomInvitationH5Container);
    roomInvitationH5Container = null;
  }
};
const showRoomInvitationH5 = (options) => new Promise((resolve) => {
  if (currentRoomInvitationH5App) {
    hideRoomInvitationH5();
  }
  if (!roomInvitationH5Container) {
    roomInvitationH5Container = document.createElement("div");
    roomInvitationH5Container.id = ROOM_INVITATION_H5_CONTAINER_ID;
    roomInvitationH5Container.style.cssText = `
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10000;
      `;
    document.body.appendChild(roomInvitationH5Container);
  }
  const wrappedOptions = {
    ...options,
    onAccept: () => {
      var _a;
      (_a = options.onAccept) == null ? void 0 : _a.call(options);
      hideRoomInvitationH5();
      resolve("accept");
    },
    onCancel: () => {
      var _a;
      (_a = options.onCancel) == null ? void 0 : _a.call(options);
      hideRoomInvitationH5();
      resolve("cancel");
    },
    onTimeout: () => {
      var _a;
      (_a = options.onTimeout) == null ? void 0 : _a.call(options);
      hideRoomInvitationH5();
      resolve("timeout");
    }
  };
  const vNode = vue.createVNode(RoomInvitationH5.default, {
    options: wrappedOptions
  });
  currentRoomInvitationH5App = vNode;
  if (roomInvitationH5Container) {
    vue.render(vNode, roomInvitationH5Container);
  }
});
exports.ROOM_INVITATION_H5_CONTAINER_ID = ROOM_INVITATION_H5_CONTAINER_ID;
exports.hideRoomInvitationH5 = hideRoomInvitationH5;
exports.showRoomInvitationH5 = showRoomInvitationH5;
