/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var configProvider_useConfig = require('../config-provider/useConfig.js');
var hooks_useCommonClassName = require('../hooks/useCommonClassName.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var loading_index = require('../loading/index.js');
var card_props = require('./props.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('vue');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/withInstall.js');
require('lodash/capitalize');
require('../loading/directive.js');
require('lodash/isObject');
require('lodash/mapKeys');
require('lodash/isEqual');
require('../loading/plugin.js');
require('../config.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../loading/loading.js');
require('../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('../utils/mixins.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

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__default["default"](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 = VueCompositionAPI.defineComponent({
  name: "TCard",
  components: {
    TLoading: loading_index.Loading
  },
  props: _objectSpread({}, card_props["default"]),
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var _useCommonClassName = hooks_useCommonClassName["default"](),
      sizeClassNames = _useCommonClassName.sizeClassNames;
    var COMPONENT_NAME = configProvider_useConfig.usePrefixClass("card");
    var baseCls = VueCompositionAPI.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 = VueCompositionAPI.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 = configProvider_useConfig.usePrefixClass("card__header-wrapper");
    var headerAvatarCls = configProvider_useConfig.usePrefixClass("card__avatar");
    var headerTitleCls = configProvider_useConfig.usePrefixClass("card__title");
    var headerSubTitleCls = configProvider_useConfig.usePrefixClass("card__subtitle");
    var headerDescriptionCls = configProvider_useConfig.usePrefixClass("card__description");
    var actionsCls = configProvider_useConfig.usePrefixClass("card__actions");
    var bodyCls = configProvider_useConfig.usePrefixClass("card__body");
    var coverCls = configProvider_useConfig.usePrefixClass("card__cover");
    var footerCls = configProvider_useConfig.usePrefixClass("card__footer");
    var footerWrapperCls = configProvider_useConfig.usePrefixClass("card__footer-wrapper");
    var isPoster2 = VueCompositionAPI.computed(function () {
      return props2.theme === "poster2";
    });
    var showTitle = VueCompositionAPI.computed(function () {
      return props2.title || slots.title;
    });
    var showHeader = VueCompositionAPI.computed(function () {
      return props2.header || slots.header;
    });
    var showSubtitle = VueCompositionAPI.computed(function () {
      return props2.subtitle || slots.subtitle;
    });
    var showAvatar = VueCompositionAPI.computed(function () {
      return props2.avatar || slots.avatar;
    });
    var showDescription = VueCompositionAPI.computed(function () {
      return props2.description || slots.description;
    });
    var showStatus = VueCompositionAPI.computed(function () {
      return props2.status || slots.status;
    });
    var showActions = VueCompositionAPI.computed(function () {
      return props2.actions || slots.actions;
    });
    var showFooter = VueCompositionAPI.computed(function () {
      return props2.footer || slots.footer;
    });
    var showCover = VueCompositionAPI.computed(function () {
      return props2.cover || slots.cover;
    });
    var showLoading = VueCompositionAPI.computed(function () {
      return props2.loading || slots.loading;
    });
    var showContent = VueCompositionAPI.computed(function () {
      return props2.content || slots.content || props2["default"] || slots["default"];
    });
    var isHeaderRender = VueCompositionAPI.computed(function () {
      return showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value;
    });
    var isFooterRender = VueCompositionAPI.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
        }
      }) : utils_renderTnode.renderTNodeJSX(this, "cover")]);
    },
    renderHeader: function renderHeader() {
      var h = this.$createElement;
      if (this.showHeader) return h("div", {
        "class": this.headerCls
      }, [utils_renderTnode.renderTNodeJSX(this, "header")]);
      return h("div", {
        "class": this.headerCls
      }, [h("div", {
        "class": this.headerWrapperCls
      }, [this.showAvatar && h("div", {
        "class": this.headerAvatarCls
      }, [utils_renderTnode.renderTNodeJSX(this, "avatar")]), h("div", [this.showTitle && h("span", {
        "class": this.headerTitleCls
      }, [utils_renderTnode.renderTNodeJSX(this, "title")]), this.showSubtitle && h("span", {
        "class": this.headerSubTitleCls
      }, [utils_renderTnode.renderTNodeJSX(this, "subtitle")]), this.showDescription && h("p", {
        "class": this.headerDescriptionCls
      }, [utils_renderTnode.renderTNodeJSX(this, "description")])])]), this.showActions && !this.isPoster2 && h("div", {
        "class": this.actionsCls
      }, [utils_renderTnode.renderTNodeJSX(this, "actions")]), this.showStatus && h("div", {
        "class": this.actionsCls
      }, [utils_renderTnode.renderTNodeJSX(this, "status")])]);
    }
  },
  render: function render() {
    var h = arguments[0];
    if (this.loading) {
      return utils_renderTnode.renderTNodeJSX(this, "loading", {
        defaultNode: h("l-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_renderTnode.renderContent(this, "default", "content")]), this.isFooterRender && h("div", {
      "class": this.footerCls
    }, [h("div", {
      "class": this.footerWrapperCls
    }, [utils_renderTnode.renderTNodeJSX(this, "footer")]), this.showActions && this.isPoster2 && h("div", {
      "class": this.actionsCls
    }, [utils_renderTnode.renderTNodeJSX(this, "actions")])])]);
  }
});

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