"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const icon = require("../../../utils/vue/icon.js");
const vnode = require("../../../utils/vue/vnode.js");
const index = require("../../../hooks/use-namespace/index.js");
const alert = require("./alert.js");
const index$1 = require("../../icon/index.js");
const Vue = require("vue");
var alert_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElAlert",
  __name: "alert",
  props: alert.alertProps,
  emits: alert.alertEmits,
  setup(__props, { emit: __emit }) {
    const { Close } = icon.TypeComponents;
    const props = __props;
    const emit = __emit;
    const slots = Vue.useSlots();
    const ns = index.useNamespace("alert");
    const visible = Vue.ref(true);
    const iconComponent = Vue.computed(() => icon.TypeComponentsMap[props.type]);
    const hasDesc = Vue.computed(() => {
      var _a;
      if (props.description) return true;
      const slotContent = (_a = slots.default) == null ? void 0 : _a.call(slots);
      if (!slotContent) return false;
      return vnode.flattedChildren(slotContent).some((child) => !vnode.isComment(child));
    });
    const close = (evt) => {
      visible.value = false;
      emit("close", evt);
    };
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.Transition, {
        name: Vue.unref(ns).b("fade"),
        persisted: ""
      }, {
        default: Vue.withCtx(() => [Vue.withDirectives(Vue.createElementVNode("div", {
          class: Vue.normalizeClass([
            Vue.unref(ns).b(),
            Vue.unref(ns).m(__props.type),
            Vue.unref(ns).is("center", __props.center),
            Vue.unref(ns).is(__props.effect)
          ]),
          role: "alert"
        }, [__props.showIcon && (_ctx.$slots.icon || iconComponent.value) ? (Vue.openBlock(), Vue.createBlock(Vue.unref(index$1.ElIcon), {
          key: 0,
          class: Vue.normalizeClass([Vue.unref(ns).e("icon"), Vue.unref(ns).is("big", hasDesc.value)])
        }, {
          default: Vue.withCtx(() => [Vue.renderSlot(_ctx.$slots, "icon", {}, () => [(Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(iconComponent.value)))])]),
          _: 3
        }, 8, ["class"])) : Vue.createCommentVNode("v-if", true), Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(ns).e("content")) }, [
          __props.title || _ctx.$slots.title ? (Vue.openBlock(), Vue.createElementBlock("span", {
            key: 0,
            class: Vue.normalizeClass([Vue.unref(ns).e("title"), { "with-description": hasDesc.value }])
          }, [Vue.renderSlot(_ctx.$slots, "title", {}, () => [Vue.createTextVNode(Vue.toDisplayString(__props.title), 1)])], 2)) : Vue.createCommentVNode("v-if", true),
          hasDesc.value ? (Vue.openBlock(), Vue.createElementBlock("p", {
            key: 1,
            class: Vue.normalizeClass(Vue.unref(ns).e("description"))
          }, [Vue.renderSlot(_ctx.$slots, "default", {}, () => [Vue.createTextVNode(Vue.toDisplayString(__props.description), 1)])], 2)) : Vue.createCommentVNode("v-if", true),
          __props.closable ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 2 }, [__props.closeText ? (Vue.openBlock(), Vue.createElementBlock("div", {
            key: 0,
            class: Vue.normalizeClass([Vue.unref(ns).e("close-btn"), Vue.unref(ns).is("customed")]),
            onClick: close
          }, Vue.toDisplayString(__props.closeText), 3)) : (Vue.openBlock(), Vue.createBlock(Vue.unref(index$1.ElIcon), {
            key: 1,
            class: Vue.normalizeClass(Vue.unref(ns).e("close-btn")),
            onClick: close
          }, {
            default: Vue.withCtx(() => [Vue.createVNode(Vue.unref(Close))]),
            _: 1
          }, 8, ["class"]))], 64)) : Vue.createCommentVNode("v-if", true)
        ], 2)], 2), [[Vue.vShow, visible.value]])]),
        _: 3
      }, 8, ["name"]);
    };
  }
});
exports.default = alert_vue_vue_type_script_setup_true_lang_default;
