import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                      */
/* empty css                                                                     */
/* empty css                                                                     */
import { useSlots, computed, ref, watch, createBlock, openBlock, unref, normalizeStyle, normalizeClass, isRef, createSlots, withCtx, renderSlot, createElementVNode, toDisplayString, createVNode, createElementBlock, createTextVNode, Fragment, createCommentVNode } from "vue";
/* empty css                   */
import { ElDialog } from "../../../../../../node_modules/element-plus/es/components/dialog/index.mjs";
import { ElButton } from "../../../../../../node_modules/element-plus/es/components/button/index.mjs";
const _sfc_main = {
  __name: "CustomDialog",
  props: {
    modelValue: {
      type: Boolean,
      default: false
    },
    initOption: {
      type: Object,
      default: {
        width: ""
      }
    },
    width: {
      type: String,
      default: ""
    },
    height: {
      type: String,
      default: "auto"
    },
    //max,default,min
    size: {
      type: String,
      default: "default"
    },
    class: {
      type: String,
      default: ""
    },
    title: {
      type: String,
      default: "标题"
    },
    submitButtonText: {
      type: String,
      default: "确定"
    },
    cancelButtonText: {
      type: String,
      default: "取消"
    },
    query: {
      type: Boolean,
      default: false
    },
    appendToBody: {
      type: Boolean,
      default: false
    },
    hiddenFooter: {
      type: Boolean,
      default: false
    }
  },
  emits: ["submit", "onClose", "update:modelValue"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const slotFooter = !!useSlots().footer;
    const dialogWidth = computed(() => {
      let w = props.initOption.width || props.width;
      if (w) {
        return w;
      } else {
        if (props.size == "default") {
          return "65%";
        } else if (props.size == "max") {
          return "80%";
        } else if (props.size == "min") {
          return "50%";
        }
      }
    });
    const dialogVisible = ref(false);
    const emit = __emit;
    const onClose = () => {
      emit("onClose");
      emit("update:modelValue", false);
    };
    ref();
    function submit() {
      emit("submit");
    }
    const isFullscreen = ref(false);
    function changeFullscreen() {
      isFullscreen.value = !isFullscreen.value;
    }
    watch(
      () => props.modelValue,
      (visible) => {
        if (visible) {
          isFullscreen.value = false;
        }
        dialogVisible.value = visible;
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_dialog = ElDialog;
      return openBlock(), createBlock(_component_el_dialog, {
        modelValue: unref(dialogVisible),
        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(dialogVisible) ? dialogVisible.value = $event : null),
        title: props.title,
        onClose,
        "destroy-on-close": "",
        draggable: "",
        "append-to-body": props.appendToBody,
        "close-on-click-modal": false,
        "close-on-press-escape": false,
        width: unref(dialogWidth),
        class: normalizeClass(props.class + " custom-dialog"),
        style: normalizeStyle("height:" + __props.height),
        fullscreen: unref(isFullscreen)
      }, createSlots({
        header: withCtx(() => [
          createElementVNode("span", null, toDisplayString(props.title), 1),
          createElementVNode("i", {
            class: "iconfont icon-MaxScreen max-screen",
            onClick: changeFullscreen
          })
        ]),
        default: withCtx(() => [
          renderSlot(_ctx.$slots, "default")
        ]),
        _: 2
      }, [
        !__props.hiddenFooter ? {
          name: "footer",
          fn: withCtx(() => [
            createVNode(_component_el_button, {
              onClick: _cache[0] || (_cache[0] = ($event) => dialogVisible.value = false)
            }, {
              default: withCtx(() => [
                createTextVNode(toDisplayString(props.cancelButtonText), 1)
              ]),
              _: 1
            }),
            slotFooter ? renderSlot(_ctx.$slots, "footer", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
              !props.query ? (openBlock(), createBlock(_component_el_button, {
                key: 0,
                type: "primary",
                onClick: submit,
                size: "default"
              }, {
                default: withCtx(() => [
                  createTextVNode(toDisplayString(props.submitButtonText), 1)
                ]),
                _: 1
              })) : createCommentVNode("", true)
            ], 64))
          ]),
          key: "0"
        } : void 0
      ]), 1032, ["modelValue", "title", "append-to-body", "width", "class", "style", "fullscreen"]);
    };
  }
};
export {
  _sfc_main as default
};
