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

'use strict';

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

var vue = require('vue');
var isString = require('lodash/isString');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_tnode = require('../hooks/tnode.js');
var loading_index = require('../loading/index.js');
var card_props = require('./props.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
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-7f0559c3.js');
require('dayjs');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('../utils/withInstall.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('@babel/runtime/helpers/defineProperty');
require('../utils/dom.js');
require('../utils/easing.js');
require('../loading/loading.js');
require('@babel/runtime/helpers/slicedToArray');
require('../hooks/useTeleport.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('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');

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

var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
}
var _Card = vue.defineComponent({
  name: "TCard",
  props: card_props["default"],
  setup: function setup(props2, _ref) {
    var slots = _ref.slots;
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("card");
    var _useCommonClassName = hooks_useConfig.useCommonClassName(),
      SIZE = _useCommonClassName.SIZE;
    var baseCls = vue.computed(function () {
      var defaultClass = [COMPONENT_NAME.value];
      if (props2.size === "small") defaultClass.push("".concat(SIZE.value[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 = vue.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 = hooks_useConfig.usePrefixClass("card__header-wrapper");
    var headerAvatarCls = hooks_useConfig.usePrefixClass("card__avatar");
    var headerTitleCls = hooks_useConfig.usePrefixClass("card__title");
    var headerSubTitleCls = hooks_useConfig.usePrefixClass("card__subtitle");
    var headerDescriptionCls = hooks_useConfig.usePrefixClass("card__description");
    var actionsCls = hooks_useConfig.usePrefixClass("card__actions");
    var bodyCls = hooks_useConfig.usePrefixClass("card__body");
    var coverCls = hooks_useConfig.usePrefixClass("card__cover");
    var footerCls = hooks_useConfig.usePrefixClass("card__footer");
    var footerWrapperCls = hooks_useConfig.usePrefixClass("card__footer-wrapper");
    var isPoster2 = vue.computed(function () {
      return props2.theme === "poster2";
    });
    var showTitle = vue.computed(function () {
      return props2.title || slots.title;
    });
    var showHeader = vue.computed(function () {
      return props2.header || slots.header;
    });
    var showSubtitle = vue.computed(function () {
      return props2.subtitle || slots.subtitle;
    });
    var showAvatar = vue.computed(function () {
      return props2.avatar || slots.avatar;
    });
    var showDescription = vue.computed(function () {
      return props2.description || slots.description;
    });
    var showStatus = vue.computed(function () {
      return props2.status || slots.status;
    });
    var showActions = vue.computed(function () {
      return props2.actions || slots.actions;
    });
    var showFooter = vue.computed(function () {
      return props2.footer || slots.footer;
    });
    var showCover = vue.computed(function () {
      return props2.cover || slots.cover;
    });
    var showLoading = vue.computed(function () {
      return props2.loading || slots.loading;
    });
    var showContent = vue.computed(function () {
      return props2.content || slots.content || props2["default"] || slots["default"];
    });
    var isHeaderRender = vue.computed(function () {
      return showHeader.value || showTitle.value || showSubtitle.value || showDescription.value || showAvatar.value || showStatus.value && isPoster2.value || showActions.value && !isPoster2.value;
    });
    var isFooterRender = vue.computed(function () {
      return showFooter.value || showActions.value && isPoster2.value;
    });
    var renderHeader = function renderHeader() {
      if (showHeader.value) return vue.createVNode("div", {
        "class": headerCls.value
      }, [renderTNodeJSX("header")]);
      return vue.createVNode("div", {
        "class": headerCls.value
      }, [vue.createVNode("div", {
        "class": headerWrapperCls.value
      }, [showAvatar.value && vue.createVNode("div", {
        "class": headerAvatarCls.value
      }, [renderTNodeJSX("avatar")]), vue.createVNode("div", null, [showTitle.value && vue.createVNode("span", {
        "class": headerTitleCls.value
      }, [renderTNodeJSX("title")]), showSubtitle.value && vue.createVNode("span", {
        "class": headerSubTitleCls.value
      }, [renderTNodeJSX("subtitle")]), showDescription.value && vue.createVNode("p", {
        "class": headerDescriptionCls.value
      }, [renderTNodeJSX("description")])])]), showActions.value && !isPoster2.value && vue.createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("actions")]), showStatus.value && vue.createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("status")])]);
    };
    var renderCover = function renderCover() {
      var textCover = isString__default["default"](props2.cover);
      return vue.createVNode("div", {
        "class": coverCls.value
      }, [textCover ? vue.createVNode("img", {
        "src": props2.cover
      }, null) : renderTNodeJSX("cover")]);
    };
    return function () {
      var content = vue.createVNode("div", {
        "class": baseCls.value
      }, [isHeaderRender.value ? renderHeader() : null, showCover.value ? renderCover() : null, showContent.value && vue.createVNode("div", {
        "class": bodyCls.value
      }, [renderTNodeJSX("default") || renderTNodeJSX("content")]), isFooterRender.value && vue.createVNode("div", {
        "class": footerCls.value
      }, [vue.createVNode("div", {
        "class": footerWrapperCls.value
      }, [renderTNodeJSX("footer")]), showActions.value && isPoster2.value && vue.createVNode("div", {
        "class": actionsCls.value
      }, [renderTNodeJSX("actions")])])]);
      if (showLoading.value) return renderTNodeJSX("loading") || vue.createVNode(loading_index.Loading, null, _isSlot(content) ? content : {
        "default": function _default() {
          return [content];
        }
      });
      return content;
    };
  }
});

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