/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
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 '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../loading/loading.js';
import '../loading/icon/gradient.js';
import '../../chunks/defineProperty-28395935.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';
import '../../config.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/transfer-dom.js';
import '../loading/props.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../../utils/mixins.js';
import '../../utils/with-install.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Card = defineComponent({
  name: "LCard",
  props: _objectSpread({}, props),
  components: {
    TLoading: Loading
  },
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;

    var _useCommonClassName = useCommonClassName(),
        sizeClassNames = _useCommonClassName.sizeClassNames;

    var COMPONENT_NAME = usePrefixClass("card");
    var baseCls = computed(function () {
      var defaultClass = [COMPONENT_NAME.value];
      if (props2.size === "small") defaultClass.push("".concat(sizeClassNames[props2.size]));
      if (props2.bordered) defaultClass.push("".concat(COMPONENT_NAME.value, "--bordered"));
      if (props2.shadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow"));
      if (props2.hoverShadow) defaultClass.push("".concat(COMPONENT_NAME.value, "--shadow-hover"));
      return defaultClass;
    });
    var headerCls = computed(function () {
      var defaultClass = ["".concat(COMPONENT_NAME.value, "__header")];
      return props2.headerBordered ? defaultClass.concat("".concat(COMPONENT_NAME.value, "__title--bordered")) : ["".concat(COMPONENT_NAME.value, "__header")];
    });
    var headerWrapperCls = usePrefixClass("card__header-wrapper");
    var headerAvatarCls = usePrefixClass("card__avatar");
    var headerTitleCls = usePrefixClass("card__title");
    var headerSubTitleCls = usePrefixClass("card__subtitle");
    var headerDescriptionCls = usePrefixClass("card__description");
    var actionsCls = usePrefixClass("card__actions");
    var bodyCls = usePrefixClass("card__body");
    var coverCls = usePrefixClass("card__cover");
    var footerCls = usePrefixClass("card__footer");
    var footerWrapperCls = usePrefixClass("card__footer-wrapper");
    var isPoster2 = computed(function () {
      return props2.theme === "poster2";
    });
    var showTitle = computed(function () {
      return props2.title || slots.title;
    });
    var showHeader = computed(function () {
      return props2.header || slots.header;
    });
    var showSubtitle = computed(function () {
      return props2.subtitle || slots.subtitle;
    });
    var showAvatar = computed(function () {
      return props2.avatar || slots.avatar;
    });
    var showDescription = computed(function () {
      return props2.description || slots.description;
    });
    var showStatus = computed(function () {
      return props2.status || slots.status;
    });
    var showActions = computed(function () {
      return props2.actions || slots.actions;
    });
    var showFooter = computed(function () {
      return props2.footer || slots.footer;
    });
    var showCover = computed(function () {
      return props2.cover || slots.cover;
    });
    var showLoading = computed(function () {
      return props2.loading || slots.loading;
    });
    var showContent = computed(function () {
      return props2.content || slots.content || props2["default"] || slots["default"];
    });
    var isHeaderRender = computed(function () {
      return showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value;
    });
    var isFooterRender = computed(function () {
      return showFooter.value || showActions.value && isPoster2.value;
    });
    return {
      isHeaderRender: isHeaderRender,
      isFooterRender: isFooterRender,
      isPoster2: isPoster2,
      showLoading: showLoading,
      showHeader: showHeader,
      showTitle: showTitle,
      showSubtitle: showSubtitle,
      showDescription: showDescription,
      showAvatar: showAvatar,
      showActions: showActions,
      showStatus: showStatus,
      showContent: showContent,
      showCover: showCover,
      showFooter: showFooter,
      baseCls: baseCls,
      bodyCls: bodyCls,
      footerCls: footerCls,
      footerWrapperCls: footerWrapperCls,
      coverCls: coverCls,
      actionsCls: actionsCls,
      headerCls: headerCls,
      headerWrapperCls: headerWrapperCls,
      headerAvatarCls: headerAvatarCls,
      headerTitleCls: headerTitleCls,
      headerSubTitleCls: headerSubTitleCls,
      headerDescriptionCls: headerDescriptionCls,
      COMPONENT_NAME: COMPONENT_NAME
    };
  },
  methods: {
    renderLoading: function renderLoading() {},
    renderCover: function renderCover() {
      var h = this.$createElement;
      var textCover = typeof this.cover === "string";
      return h("div", {
        "class": this.coverCls
      }, [textCover ? h("img", {
        "attrs": {
          "src": this.cover
        }
      }) : renderLNodeJSX(this, "cover")]);
    },
    renderHeader: function renderHeader() {
      var 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: function render() {
    var 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
