"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
require("../../../adapter-vue.js");
const TUIChatEngine = require("@tencentcloud/chat-uikit-engine");
const universalApi = require("@tencentcloud/universal-api");
const env = require("../../../utils/env.js");
const _hoisted_1 = { key: 0 };
const _hoisted_2 = {
  key: 0,
  class: "header"
};
const _hoisted_3 = {
  key: 0,
  class: "header-title"
};
const _hoisted_4 = {
  key: 1,
  class: "footer"
};
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "index",
  props: {
    // Whether to display the bottom pop-up dialog box
    show: {
      type: Boolean,
      default: false
    },
    // Whether a mask layer is required, the default is true
    modal: {
      type: Boolean,
      default: true
    },
    // Popup box content area height (excluding mask), default is fit-content
    height: {
      type: String,
      default: "fit-content"
    },
    // Whether the pop-up dialog box can be closed by clicking outside, the default is true
    // uniapp only supports closing the pop-up dialog box by clicking the mask
    closeByClickOutside: {
      type: Boolean,
      default: true
    },
    // The rounded angle of the top border corners is 0px by default, i.e. right angle by default
    borderRadius: {
      type: String,
      default: "0px"
    },
    title: {
      type: String,
      default: ""
    },
    // Whether to display the top close button, not displayed by default
    showHeaderCloseButton: {
      type: Boolean,
      default: false
    },
    // Whether to display the submit button at the bottom, not displayed by default
    showFooterSubmitButton: {
      type: Boolean,
      default: false
    },
    // Bottom submit button text, only valid when showFooterSubmitButton is true
    submitButtonContent: {
      type: String,
      default: () => TUIChatEngine.TUITranslateService.t("确定")
    }
  },
  emits: ["onOpen", "onClose", "onSubmit"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const dialogRef = Vue.ref();
    Vue.watch(
      () => props.show,
      (newVal, oldVal) => {
        if (newVal === oldVal) {
          return;
        }
        switch (newVal) {
          case true:
            emits("onOpen", dialogRef);
            Vue.nextTick(() => {
              if (env.isH5 && !env.isUniFrameWork) {
                if (props.closeByClickOutside) {
                  universalApi.outsideClick.listen({
                    domRefs: dialogRef.value,
                    handler: closeBottomPopup
                  });
                }
              }
            });
            break;
          case false:
            emits("onClose", dialogRef);
            break;
        }
      }
    );
    const closeBottomPopup = () => {
      if (env.isUniFrameWork || env.isH5) {
        emits("onClose", dialogRef);
      }
    };
    const submit = () => {
      emits("onSubmit");
      closeBottomPopup();
    };
    return (_ctx, _cache) => {
      return props.show ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        !Vue.unref(env.isPC) ? (Vue.openBlock(), Vue.createElementBlock("div", {
          key: 0,
          class: Vue.normalizeClass([
            "bottom-popup",
            Vue.unref(env.isUniFrameWork) && "bottom-popup-uni",
            !Vue.unref(env.isPC) && "bottom-popup-h5",
            !Vue.unref(env.isPC) && props.modal && "bottom-popup-modal"
          ]),
          onClick: closeBottomPopup
        }, [
          Vue.createElementVNode("div", {
            ref_key: "dialogRef",
            ref: dialogRef,
            class: Vue.normalizeClass(["bottom-popup-main", !Vue.unref(env.isPC) && "bottom-popup-h5-main"]),
            style: Vue.normalizeStyle({
              height: props.height,
              borderTopLeftRadius: props.borderRadius,
              borderTopRightRadius: props.borderRadius
            }),
            onClick: _cache[0] || (_cache[0] = Vue.withModifiers(() => {
            }, ["stop"]))
          }, [
            __props.title || __props.showHeaderCloseButton ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, [
              __props.title ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_3, Vue.toDisplayString(__props.title), 1)) : Vue.createCommentVNode("", true),
              __props.showHeaderCloseButton ? (Vue.openBlock(), Vue.createElementBlock("div", {
                key: 1,
                class: "header-close",
                onClick: closeBottomPopup
              }, Vue.toDisplayString(Vue.unref(TUIChatEngine.TUITranslateService).t("关闭")), 1)) : Vue.createCommentVNode("", true)
            ])) : Vue.createCommentVNode("", true),
            Vue.renderSlot(_ctx.$slots, "default", {}, void 0, true),
            __props.showFooterSubmitButton ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_4, [
              Vue.createElementVNode("div", {
                class: "footer-submit",
                onClick: submit
              }, Vue.toDisplayString(__props.submitButtonContent), 1)
            ])) : Vue.createCommentVNode("", true)
          ], 6)
        ], 2)) : Vue.renderSlot(_ctx.$slots, "default", { key: 1 }, void 0, true)
      ])) : Vue.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
