import { defineComponent, ref, createElementBlock, openBlock, createVNode, unref, withCtx, createElementVNode } from "vue";
import { useUIKit, IconVirtualBackground, TUIDialog, TUIToast } from "@tencentcloud/uikit-base-component-vue3";
import { useVirtualBackgroundState, useDeviceState, VirtualBackgroundPanel } from "tuikit-atomicx-vue3/room";
import IconButton from "../base/IconButton.vue2.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    const { t } = useUIKit();
    const virtualBackgroundVisible = ref(false);
    const { isSupported } = useVirtualBackgroundState();
    const { cameraList } = useDeviceState();
    const handleClick = () => {
      if (cameraList.value.length === 0) {
        TUIToast.error({ message: t("VirtualBackground.NoCamera") });
        return;
      }
      if (!isSupported()) {
        TUIToast.error({ message: t("VirtualBackground.NotSupported") });
        return;
      }
      virtualBackgroundVisible.value = true;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", null, [
        createVNode(IconButton, {
          title: unref(t)("VirtualBackground.Title"),
          disabled: !unref(isSupported)() || unref(cameraList).length === 0,
          onClick: handleClick
        }, {
          default: withCtx(() => [
            createVNode(unref(IconVirtualBackground), { size: 24 })
          ]),
          _: 1
        }, 8, ["title", "disabled"]),
        createVNode(unref(TUIDialog), {
          visible: virtualBackgroundVisible.value,
          "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => virtualBackgroundVisible.value = $event),
          title: unref(t)("VirtualBackground.Title"),
          "custom-classes": ["virtual-background-dialog"],
          appendTo: "#roomPage"
        }, {
          footer: withCtx(() => [..._cache[2] || (_cache[2] = [
            createElementVNode("div", null, null, -1)
          ])]),
          default: withCtx(() => [
            createVNode(unref(VirtualBackgroundPanel), {
              onClose: _cache[0] || (_cache[0] = ($event) => virtualBackgroundVisible.value = false)
            })
          ]),
          _: 1
        }, 8, ["visible", "title"])
      ]);
    };
  }
});
export {
  _sfc_main as default
};
