/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { defineComponent, computed } from '@vue/composition-api';
import { usePrefixClass } from '../config-provider/useConfig.js';
import useCommonClassName from '../../hooks/use-common-classname.js';
import { renderLNodeJSX, renderContent } from '../../utils/render-node.js';
import { Loading } from '../loading/index.js';
import props from './props.js';
import '../config-provider/context.js';
import 'lodash';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import 'vue';
import '../../utils/with-install.js';
import '../../config.js';
import '../loading/loading.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../chunks/index.js';
import '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../utils/mixins.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';

var _Card = defineComponent({
  name: "LCard",
  components: {
    TLoading: Loading
  },
  props: {
    ...props
  },
  setup(props2, _ref) {
    let {
      slots
    } = _ref;
    const {
      sizeClassNames
    } = useCommonClassName();
    const COMPONENT_NAME = usePrefixClass("card");
    const baseCls = computed(() => {
      const defaultClass = [COMPONENT_NAME.value];
      if (props2.size === "small") defaultClass.push(`${sizeClassNames[props2.size]}`);
      if (props2.bordered) defaultClass.push(`${COMPONENT_NAME.value}--bordered`);
      if (props2.shadow) defaultClass.push(`${COMPONENT_NAME.value}--shadow`);
      if (props2.hoverShadow) defaultClass.push(`${COMPONENT_NAME.value}--shadow-hover`);
      return defaultClass;
    });
    const headerCls = computed(() => {
      const defaultClass = [`${COMPONENT_NAME.value}__header`];
      return props2.headerBordered ? defaultClass.concat(`${COMPONENT_NAME.value}__title--bordered`) : [`${COMPONENT_NAME.value}__header`];
    });
    const headerWrapperCls = usePrefixClass("card__header-wrapper");
    const headerAvatarCls = usePrefixClass("card__avatar");
    const headerTitleCls = usePrefixClass("card__title");
    const headerSubTitleCls = usePrefixClass("card__subtitle");
    const headerDescriptionCls = usePrefixClass("card__description");
    const actionsCls = usePrefixClass("card__actions");
    const bodyCls = usePrefixClass("card__body");
    const coverCls = usePrefixClass("card__cover");
    const footerCls = usePrefixClass("card__footer");
    const footerWrapperCls = usePrefixClass("card__footer-wrapper");
    const isPoster2 = computed(() => props2.theme === "poster2");
    const showTitle = computed(() => props2.title || slots.title);
    const showHeader = computed(() => props2.header || slots.header);
    const showSubtitle = computed(() => props2.subtitle || slots.subtitle);
    const showAvatar = computed(() => props2.avatar || slots.avatar);
    const showDescription = computed(() => props2.description || slots.description);
    const showStatus = computed(() => props2.status || slots.status);
    const showActions = computed(() => props2.actions || slots.actions);
    const showFooter = computed(() => props2.footer || slots.footer);
    const showCover = computed(() => props2.cover || slots.cover);
    const showLoading = computed(() => props2.loading || slots.loading);
    const showContent = computed(() => props2.content || slots.content || props2.default || slots.default);
    const isHeaderRender = computed(() => showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value);
    const isFooterRender = computed(() => showFooter.value || showActions.value && isPoster2.value);
    return {
      isHeaderRender,
      isFooterRender,
      isPoster2,
      showLoading,
      showHeader,
      showTitle,
      showSubtitle,
      showDescription,
      showAvatar,
      showActions,
      showStatus,
      showContent,
      showCover,
      showFooter,
      baseCls,
      bodyCls,
      footerCls,
      footerWrapperCls,
      coverCls,
      actionsCls,
      headerCls,
      headerWrapperCls,
      headerAvatarCls,
      headerTitleCls,
      headerSubTitleCls,
      headerDescriptionCls,
      COMPONENT_NAME
    };
  },
  methods: {
    renderLoading() {},
    renderCover() {
      const h = this.$createElement;
      const textCover = typeof this.cover === "string";
      return h("div", {
        "class": this.coverCls
      }, [textCover ? h("img", {
        "attrs": {
          "src": this.cover
        }
      }) : renderLNodeJSX(this, "cover")]);
    },
    renderHeader() {
      const h = this.$createElement;
      if (this.showHeader) return h("div", {
        "class": this.headerCls
      }, [renderLNodeJSX(this, "header")]);
      return h("div", {
        "class": this.headerCls
      }, [h("div", {
        "class": this.headerWrapperCls
      }, [this.showAvatar && h("div", {
        "class": this.headerAvatarCls
      }, [renderLNodeJSX(this, "avatar")]), h("div", [this.showTitle && h("span", {
        "class": this.headerTitleCls
      }, [renderLNodeJSX(this, "title")]), this.showSubtitle && h("span", {
        "class": this.headerSubTitleCls
      }, [renderLNodeJSX(this, "subtitle")]), this.showDescription && h("p", {
        "class": this.headerDescriptionCls
      }, [renderLNodeJSX(this, "description")])])]), this.showActions && !this.isPoster2 && h("div", {
        "class": this.actionsCls
      }, [renderLNodeJSX(this, "actions")]), this.showStatus && h("div", {
        "class": this.actionsCls
      }, [renderLNodeJSX(this, "status")])]);
    }
  },
  render() {
    const h = arguments[0];
    if (this.loading) {
      return renderLNodeJSX(this, "loading", {
        defaultNode: h("t-loading", [h("div", {
          "class": this.baseCls
        })])
      });
    }
    return h("div", {
      "class": this.baseCls
    }, [this.isHeaderRender ? this.renderHeader() : null, this.showCover ? this.renderCover() : null, this.showContent && h("div", {
      "class": this.bodyCls
    }, [renderContent(this, "default", "content")]), this.isFooterRender && h("div", {
      "class": this.footerCls
    }, [h("div", {
      "class": this.footerWrapperCls
    }, [renderLNodeJSX(this, "footer")]), this.showActions && this.isPoster2 && h("div", {
      "class": this.actionsCls
    }, [renderLNodeJSX(this, "actions")])])]);
  }
});

export { _Card as default };
//# sourceMappingURL=card.js.map
