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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var components_configProvider_useConfig = require('../config-provider/useConfig.js');
var hooks_useCommonClassname = require('../../hooks/use-common-classname.js');
var utils_renderNode = require('../../utils/render-node.js');
var components_loading_index = require('../loading/index.js');
var components_card_props = require('./props.js');
require('../config-provider/context.js');
require('lodash');
require('../../chunks/zh_CN.js');
require('vue');
require('../../utils/with-install.js');
require('../../config.js');
require('../loading/loading.js');
require('../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../chunks/log.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../utils/easing.js');
require('../../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');
require('../loading/plugin.js');

var _Card = VueCompositionAPI.defineComponent({
  name: "LCard",
  components: {
    TLoading: components_loading_index.Loading
  },
  props: {
    ...components_card_props["default"]
  },
  setup(props2, _ref) {
    let {
      slots
    } = _ref;
    const {
      sizeClassNames
    } = hooks_useCommonClassname["default"]();
    const COMPONENT_NAME = components_configProvider_useConfig.usePrefixClass("card");
    const baseCls = VueCompositionAPI.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 = VueCompositionAPI.computed(() => {
      const defaultClass = [`${COMPONENT_NAME.value}__header`];
      return props2.headerBordered ? defaultClass.concat(`${COMPONENT_NAME.value}__title--bordered`) : [`${COMPONENT_NAME.value}__header`];
    });
    const headerWrapperCls = components_configProvider_useConfig.usePrefixClass("card__header-wrapper");
    const headerAvatarCls = components_configProvider_useConfig.usePrefixClass("card__avatar");
    const headerTitleCls = components_configProvider_useConfig.usePrefixClass("card__title");
    const headerSubTitleCls = components_configProvider_useConfig.usePrefixClass("card__subtitle");
    const headerDescriptionCls = components_configProvider_useConfig.usePrefixClass("card__description");
    const actionsCls = components_configProvider_useConfig.usePrefixClass("card__actions");
    const bodyCls = components_configProvider_useConfig.usePrefixClass("card__body");
    const coverCls = components_configProvider_useConfig.usePrefixClass("card__cover");
    const footerCls = components_configProvider_useConfig.usePrefixClass("card__footer");
    const footerWrapperCls = components_configProvider_useConfig.usePrefixClass("card__footer-wrapper");
    const isPoster2 = VueCompositionAPI.computed(() => props2.theme === "poster2");
    const showTitle = VueCompositionAPI.computed(() => props2.title || slots.title);
    const showHeader = VueCompositionAPI.computed(() => props2.header || slots.header);
    const showSubtitle = VueCompositionAPI.computed(() => props2.subtitle || slots.subtitle);
    const showAvatar = VueCompositionAPI.computed(() => props2.avatar || slots.avatar);
    const showDescription = VueCompositionAPI.computed(() => props2.description || slots.description);
    const showStatus = VueCompositionAPI.computed(() => props2.status || slots.status);
    const showActions = VueCompositionAPI.computed(() => props2.actions || slots.actions);
    const showFooter = VueCompositionAPI.computed(() => props2.footer || slots.footer);
    const showCover = VueCompositionAPI.computed(() => props2.cover || slots.cover);
    const showLoading = VueCompositionAPI.computed(() => props2.loading || slots.loading);
    const showContent = VueCompositionAPI.computed(() => props2.content || slots.content || props2.default || slots.default);
    const isHeaderRender = VueCompositionAPI.computed(() => showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value);
    const isFooterRender = VueCompositionAPI.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
        }
      }) : utils_renderNode.renderLNodeJSX(this, "cover")]);
    },
    renderHeader() {
      const h = this.$createElement;
      if (this.showHeader) return h("div", {
        "class": this.headerCls
      }, [utils_renderNode.renderLNodeJSX(this, "header")]);
      return h("div", {
        "class": this.headerCls
      }, [h("div", {
        "class": this.headerWrapperCls
      }, [this.showAvatar && h("div", {
        "class": this.headerAvatarCls
      }, [utils_renderNode.renderLNodeJSX(this, "avatar")]), h("div", [this.showTitle && h("span", {
        "class": this.headerTitleCls
      }, [utils_renderNode.renderLNodeJSX(this, "title")]), this.showSubtitle && h("span", {
        "class": this.headerSubTitleCls
      }, [utils_renderNode.renderLNodeJSX(this, "subtitle")]), this.showDescription && h("p", {
        "class": this.headerDescriptionCls
      }, [utils_renderNode.renderLNodeJSX(this, "description")])])]), this.showActions && !this.isPoster2 && h("div", {
        "class": this.actionsCls
      }, [utils_renderNode.renderLNodeJSX(this, "actions")]), this.showStatus && h("div", {
        "class": this.actionsCls
      }, [utils_renderNode.renderLNodeJSX(this, "status")])]);
    }
  },
  render() {
    const h = arguments[0];
    if (this.loading) {
      return utils_renderNode.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
    }, [utils_renderNode.renderContent(this, "default", "content")]), this.isFooterRender && h("div", {
      "class": this.footerCls
    }, [h("div", {
      "class": this.footerWrapperCls
    }, [utils_renderNode.renderLNodeJSX(this, "footer")]), this.showActions && this.isPoster2 && h("div", {
      "class": this.actionsCls
    }, [utils_renderNode.renderLNodeJSX(this, "actions")])])]);
  }
});

exports["default"] = _Card;
//# sourceMappingURL=card.js.map
