"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
const vn = require("../../ui/src/vn.js");
require("../../ui/index.js");
const dom = require("../../ui/src/dom.js");
const loading = require("../../loading/src/loading.js");
const XEUtils = require("xe-utils");
const config = require("../../../../@vxe-ui/core/es/src/config.js");
const useFns = require("../../../../@vxe-ui/core/es/src/useFns.js");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const index_esm = require("../../../../@vxe-ui/core/es/index.esm.js");
const VxeCardComponent = comp.defineVxeComponent({
  name: "VxeCard",
  props: {
    title: String,
    showTitleOverflow: {
      type: Boolean,
      default: () => config.getConfig().card.showTitleOverflow
    },
    width: [String, Number],
    height: [String, Number],
    border: {
      type: Boolean,
      default: () => config.getConfig().card.border
    },
    loading: Boolean,
    shadow: {
      type: Boolean,
      default: () => config.getConfig().card.shadow
    },
    padding: {
      type: Boolean,
      default: () => config.getConfig().card.padding
    },
    size: {
      type: String,
      default: () => config.getConfig().card.size || config.getConfig().size
    }
  },
  emits: [],
  setup(props, context) {
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const refElem = vue.ref();
    const { computeSize } = useFns.useSize(props);
    const reactData = vue.reactive({});
    const refMaps = {
      refElem
    };
    const computeCardStyle = vue.computed(() => {
      const { height, width } = props;
      const stys = {};
      if (width) {
        stys.width = dom.toCssUnit(width);
      }
      if (height) {
        stys.height = dom.toCssUnit(height);
      }
      return stys;
    });
    const computeMaps = {
      computeSize
    };
    const $xeCard = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $card: $xeCard }, params));
    };
    const cardMethods = {
      dispatchEvent
    };
    const cardPrivateMethods = {};
    Object.assign($xeCard, cardMethods, cardPrivateMethods);
    const renderVN = () => {
      const { title, border, shadow, padding, loading: loading$1, showTitleOverflow } = props;
      const defaultSlot = slots.default;
      const headerSlot = slots.header;
      const titleSlot = slots.title;
      const extraSlot = slots.extra;
      const footerSlot = slots.footer;
      const leftSlot = slots.left;
      const rightSlot = slots.right;
      const vSize = computeSize.value;
      const cardStyle = computeCardStyle.value;
      return vue.h("div", {
        ref: refElem,
        class: ["vxe-card", {
          [`size--${vSize}`]: vSize,
          "is--border": border,
          "is--shadow": shadow,
          "is--padding": padding
        }],
        style: cardStyle
      }, [
        title || titleSlot || headerSlot ? vue.h("div", {
          class: "vxe-card--header"
        }, headerSlot ? vn.getSlotVNs(headerSlot({})) : [
          vue.h("div", {
            class: ["vxe-card--header-title", {
              "is--ellipsis": showTitleOverflow
            }]
          }, titleSlot ? vn.getSlotVNs(titleSlot({})) : `${title || ""}`),
          extraSlot ? vue.h("div", {
            class: "vxe-card--header-extra"
          }, vn.getSlotVNs(extraSlot({}))) : index_esm.renderEmptyElement()
        ]) : index_esm.renderEmptyElement(),
        vue.h("div", {
          class: "vxe-card--body"
        }, [
          leftSlot ? vue.h("div", {
            class: "vxe-card--body-left"
          }, vn.getSlotVNs(leftSlot({}))) : index_esm.renderEmptyElement(),
          vue.h("div", {
            class: "vxe-card--body-content"
          }, defaultSlot ? vn.getSlotVNs(defaultSlot({})) : []),
          rightSlot ? vue.h("div", {
            class: "vxe-card--body-right"
          }, vn.getSlotVNs(rightSlot({}))) : index_esm.renderEmptyElement()
        ]),
        footerSlot ? vue.h("div", {
          class: "vxe-card--footer"
        }, vn.getSlotVNs(footerSlot({}))) : index_esm.renderEmptyElement(),
        /**
         * 加载中
         */
        vue.h(loading.default, {
          class: "vxe-card--loading",
          modelValue: loading$1
        })
      ]);
    };
    $xeCard.renderVN = renderVN;
    return $xeCard;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeCardComponent;
