import { defineComponent, ref, watchEffect, unref, openBlock, createElementBlock, normalizeClass, withModifiers, createElementVNode, toDisplayString, createCommentVNode, renderSlot } from "vue";
import "../../../adapter-vue.mjs";
import { TUITranslateService } from "@tencentcloud/chat-uikit-engine";
import { isPC, isUniFrameWork, isH5 } from "../../../utils/env.mjs";
const _hoisted_1 = {
  key: 0,
  class: "dialog-main-header"
};
const _hoisted_2 = { class: "dialog-main-title" };
const _hoisted_3 = {
  key: 1,
  class: "dialog-main-footer"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    show: {
      type: Boolean,
      default: false
    },
    isHeaderShow: {
      type: Boolean,
      default: true
    },
    isFooterShow: {
      type: Boolean,
      default: true
    },
    background: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: ""
    },
    center: {
      type: Boolean,
      default: false
    }
  },
  emits: ["update:show", "submit"],
  setup(__props, { emit: __emit }) {
    const clickType = {
      OUTSIDE: "outside",
      INSIDE: "inside"
    };
    const props = __props;
    const showDialog = ref(false);
    const isHeaderShowDialog = ref(true);
    const isFooterShowDialog = ref(true);
    const backgroundDialog = ref(true);
    const showTitle = ref("");
    watchEffect(() => {
      showDialog.value = props.show;
      showTitle.value = props.title;
      isHeaderShowDialog.value = props.isHeaderShow;
      isFooterShowDialog.value = props.isFooterShow;
      backgroundDialog.value = props.background;
    });
    const emit = __emit;
    const toggleView = (type) => {
      if (type === clickType.OUTSIDE) {
        close();
      }
    };
    const close = () => {
      showDialog.value = !showDialog.value;
      emit("update:show", showDialog.value);
    };
    const submit = () => {
      emit("submit");
      close();
    };
    return (_ctx, _cache) => {
      return unref(showDialog) ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: normalizeClass(["dialog", [!unref(isPC) ? "dialog-h5" : "", __props.center ? "center" : ""]]),
        onClick: _cache[1] || (_cache[1] = withModifiers(($event) => toggleView(clickType.OUTSIDE), ["stop", "prevent"]))
      }, [
        createElementVNode("main", {
          class: normalizeClass(["dialog-main", [!unref(backgroundDialog) ? "dialog-main-back" : ""]]),
          onClick: _cache[0] || (_cache[0] = withModifiers(($event) => toggleView(clickType.INSIDE), ["stop", "prevent"]))
        }, [
          unref(isHeaderShowDialog) ? (openBlock(), createElementBlock("header", _hoisted_1, [
            createElementVNode("h1", _hoisted_2, toDisplayString(unref(showTitle)), 1),
            createElementVNode("i", {
              class: "icon icon-close",
              onClick: close
            })
          ])) : createCommentVNode("", true),
          createElementVNode("div", {
            class: normalizeClass(["dialog-main-content", [unref(isUniFrameWork) && unref(isH5) ? "dialog-main-content-uniapp" : ""]])
          }, [
            renderSlot(_ctx.$slots, "default", {}, void 0, true)
          ], 2),
          unref(isFooterShowDialog) ? (openBlock(), createElementBlock("footer", _hoisted_3, [
            createElementVNode("button", {
              class: "btn btn-cancel",
              onClick: close
            }, toDisplayString(unref(TUITranslateService).t("component.取消")), 1),
            createElementVNode("button", {
              class: "btn btn-default",
              onClick: submit
            }, toDisplayString(unref(TUITranslateService).t("component.确定")), 1)
          ])) : createCommentVNode("", true)
        ], 2)
      ], 2)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
