import { defineComponent, ref, watch, onMounted, withDirectives, openBlock, createElementBlock, unref, normalizeStyle, createVNode, createElementVNode, toDisplayString, withCtx, createTextVNode, vShow } from "vue";
import TuiButton from "../Button.vue.mjs";
import SvgIcon from "../SvgIcon.vue.mjs";
import CloseIcon from "../../icons/CloseIcon.vue.mjs";
import useZIndex from "../../../../hooks/useZIndex.mjs";
import { isMobile } from "../../../../utils/environment.mjs";
import ApplyTipsIcon from "../../icons/ApplyTipsIcon.vue.mjs";
const _hoisted_1 = { class: "tui-notification" };
const _hoisted_2 = { class: "tui-notification-mobile-content" };
const _hoisted_3 = { class: "tui-notification-header" };
const _hoisted_4 = { class: "tui-notification-title" };
const _hoisted_5 = { class: "close" };
const _hoisted_6 = { class: "tui-notification-footer" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    message: { default: "" },
    confirm: { type: [Function, null], default: null },
    cancel: { type: [Function, null], default: null },
    confirmButtonText: { default: "" },
    cancelButtonText: { default: "" }
  },
  emits: ["close"],
  setup(__props, { emit: __emit }) {
    const visible = ref(false);
    const overlayContainerStyle = ref({});
    const { nextZIndex } = useZIndex();
    const props = __props;
    const emit = __emit;
    watch(visible, (val) => {
      if (val) {
        overlayContainerStyle.value = { zIndex: nextZIndex() };
      }
    });
    function handleClose() {
      visible.value = false;
      emit("close");
    }
    function handleAgree() {
      if (props.confirm) {
        props.confirm();
      }
      handleClose();
    }
    function handleReject() {
      if (props.cancel) {
        props.cancel();
      }
      handleClose();
    }
    function onOpen() {
      visible.value = true;
    }
    onMounted(async () => {
      onOpen();
    });
    return (_ctx, _cache) => {
      return withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
        unref(isMobile) ? (openBlock(), createElementBlock("div", {
          key: 0,
          class: "tui-notification-container-mobile",
          style: normalizeStyle(overlayContainerStyle.value)
        }, [
          createVNode(SvgIcon, {
            icon: ApplyTipsIcon,
            class: "tui-notification-mobile-icon"
          }),
          createElementVNode("span", _hoisted_2, toDisplayString(_ctx.message), 1),
          createElementVNode("div", {
            class: "tui-notification-mobile-check",
            onClick: handleAgree
          }, toDisplayString(_ctx.confirmButtonText), 1)
        ], 4)) : (openBlock(), createElementBlock("div", {
          key: 1,
          class: "tui-notification-container",
          style: normalizeStyle(overlayContainerStyle.value)
        }, [
          createElementVNode("div", _hoisted_3, [
            createElementVNode("div", _hoisted_4, toDisplayString(_ctx.message), 1),
            createElementVNode("div", _hoisted_5, [
              createVNode(SvgIcon, {
                size: 16,
                icon: CloseIcon,
                onClick: handleClose
              })
            ])
          ]),
          createElementVNode("div", _hoisted_6, [
            createVNode(TuiButton, {
              size: "default",
              onClick: handleAgree
            }, {
              default: withCtx(() => [
                createTextVNode(toDisplayString(_ctx.confirmButtonText), 1)
              ]),
              _: 1
            }),
            createVNode(TuiButton, {
              size: "default",
              type: "primary",
              class: "button",
              onClick: handleReject
            }, {
              default: withCtx(() => [
                createTextVNode(toDisplayString(_ctx.cancelButtonText), 1)
              ]),
              _: 1
            })
          ])
        ], 4))
      ], 512)), [
        [vShow, visible.value]
      ]);
    };
  }
});
export {
  _sfc_main as default
};
