import { defineComponent, ref, onMounted, onBeforeUnmount, createElementBlock, openBlock, createElementVNode, normalizeClass, createVNode, unref, toDisplayString, withCtx, createTextVNode } from "vue";
import { useUIKit, IconScreenSharing, TUIButton, TUIMessageBox } from "@tencentcloud/uikit-base-component-vue3";
import { useDeviceState } from "tuikit-atomicx-vue3/room";
const _hoisted_1 = { class: "local-screen-info" };
const _hoisted_2 = { class: "text" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "LocalScreenViewUI",
  setup(__props) {
    const { t } = useUIKit();
    const { stopScreenShare } = useDeviceState();
    const localScreenContainerRef = ref();
    const isMiniRegion = ref(false);
    function handleStopSharing() {
      TUIMessageBox.confirm({
        title: t("ScreenShare.EndSharing"),
        content: t("ScreenShare.StopSharingConfirm"),
        callback: async (action) => {
          if (action === "confirm") {
            await stopScreenShare();
          }
        }
      });
    }
    const resizeObserver = new ResizeObserver(() => {
      var _a;
      isMiniRegion.value = ((_a = localScreenContainerRef.value) == null ? void 0 : _a.offsetHeight) <= 200;
    });
    onMounted(() => {
      resizeObserver.observe(localScreenContainerRef.value);
    });
    onBeforeUnmount(() => {
      resizeObserver.unobserve(localScreenContainerRef.value);
      resizeObserver.disconnect();
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        ref_key: "localScreenContainerRef",
        ref: localScreenContainerRef,
        class: "local-screen-container"
      }, [
        createElementVNode("div", {
          class: normalizeClass(["local-screen-control-container", { mini: isMiniRegion.value }])
        }, [
          createElementVNode("div", _hoisted_1, [
            createVNode(unref(IconScreenSharing), { size: "44" }),
            createElementVNode("span", _hoisted_2, toDisplayString(unref(t)("RoomView.YouAreSharingTheScreen")), 1)
          ]),
          createVNode(unref(TUIButton), {
            color: "red",
            type: "primary",
            onClick: handleStopSharing
          }, {
            default: withCtx(() => [
              createTextVNode(toDisplayString(unref(t)("RoomView.EndSharing")), 1)
            ]),
            _: 1
          })
        ], 2)
      ], 512);
    };
  }
});
export {
  _sfc_main as default
};
