import { withDirectives, createVNode, Fragment, resolveDirective, isVNode } from "vue";
import "./styles/card.scss";
import { makeRouterProps, useLink } from "../../composables/router/index.mjs";
import { makeLoadingProps, useLoading } from "../../composables/loading/index.mjs";
import { makeDisabledProps, useDisabled } from "../../composables/disabled/index.mjs";
import { makePaperProps, usePaper } from "../../composables/paper/index.mjs";
import { CardImage } from "./card-image.mjs";
import { CardAvatar } from "./card-avatar.mjs";
import { CardHeader } from "./card-header.mjs";
import { CardHeaderText } from "./card-header-text.mjs";
import { CardTitle } from "./card-title.mjs";
import { CardSubtitle } from "./card-subtitle.mjs";
import { CardText } from "./card-text.mjs";
import { CardActions } from "./card-actions.mjs";
import { Ripple } from "../../directives/ripple/index.mjs";
import { genOverlays } from "../../composables/variant/index.mjs";
import { Image } from "../image/image.mjs";
import { Avatar } from "../avatar/avatar.mjs";
import { Divider } from "../divider/divider.mjs";
import { propsFactory, pick } from "../../utils/dist/index.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const makeCardProps = propsFactory({
  link: Boolean,
  hover: Boolean,
  image: String,
  prependAvatar: String,
  prependIcon: String,
  appendAvatar: String,
  appendIcon: String,
  title: String,
  subtitle: String,
  divided: Boolean,
  text: String,
  ripple: {
    type: Boolean,
    default: true
  },
  ...makeRouterProps(),
  ...makeLoadingProps(),
  ...makeDisabledProps(),
  ...makePaperProps({
    shape: "rounded-sm",
    variant: "contained"
  })
}, "card");
const Card = defineComponent({
  name: "VeCard",
  directives: {
    Ripple
  },
  props: makeCardProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      paperClasses,
      paperStyles
    } = usePaper(props);
    const link = useLink(props, attrs);
    const {
      loadingClasses
    } = useLoading(props);
    const {
      disabledClasses
    } = useDisabled(props);
    return () => {
      let _slot;
      const Tag = link.isLink.value ? "a" : props.tag;
      const hasImage = !!(slots.image || props.image);
      const hasTitle = !!(slots.title || props.title);
      const hasSubtitle = !!(slots.subtitle || props.subtitle);
      const hasHeaderText = !!slots.headerText || hasTitle || hasSubtitle;
      const hasPrepend = !!(slots.prepend || props.prependAvatar || props.prependIcon);
      const hasAppend = !!(slots.append || props.appendAvatar || props.appendIcon);
      const hasHeader = !!slots.header || hasHeaderText || hasPrepend || hasAppend;
      const hasText = !!(slots.text || props.text);
      const isClickable = !props.disabled && (link.isClickable.value || props.link);
      return withDirectives(createVNode(Tag, {
        "class": ["ve-card", {
          "ve-card--hover": props.hover && !props.disabled,
          "ve-card--link": isClickable
        }, paperClasses.value, loadingClasses.value, disabledClasses.value],
        "style": paperStyles.value,
        "href": link.href.value,
        "onClick": isClickable && link.navigate
      }, {
        default: () => {
          var _a, _b;
          return [genOverlays(isClickable, "ve-card"), hasImage && createVNode(CardImage, null, {
            default: () => {
              var _a2, _b2;
              return [(_b2 = (_a2 = slots.image) == null ? void 0 : _a2.call(slots, {
                src: props.image
              })) != null ? _b2 : createVNode(Image, {
                "src": props.image,
                "cover": true
              }, null)];
            }
          }), (_a = slots.media) == null ? void 0 : _a.call(slots), hasHeader && createVNode(CardHeader, null, {
            default: () => {
              var _a2, _b2;
              return [(_b2 = (_a2 = slots.header) == null ? void 0 : _a2.call(slots)) != null ? _b2 : createVNode(Fragment, null, [hasPrepend && createVNode(CardAvatar, null, {
                default: () => {
                  var _a3, _b3;
                  return [(_b3 = (_a3 = slots.prepend) == null ? void 0 : _a3.call(slots)) != null ? _b3 : createVNode(Avatar, {
                    "density": props.density,
                    "icon": props.prependIcon,
                    "image": props.prependAvatar
                  }, null)];
                }
              }), hasHeaderText && createVNode(CardHeaderText, null, {
                default: () => {
                  var _a3, _b3;
                  return [(_b3 = (_a3 = slots.headerText) == null ? void 0 : _a3.call(slots)) != null ? _b3 : createVNode(Fragment, null, [hasTitle && createVNode(CardTitle, null, {
                    default: () => {
                      var _a4, _b4;
                      return [(_b4 = (_a4 = slots.title) == null ? void 0 : _a4.call(slots)) != null ? _b4 : props.title];
                    }
                  }), hasSubtitle && createVNode(CardSubtitle, null, {
                    default: () => {
                      var _a4, _b4;
                      return [(_b4 = (_a4 = slots.subtitle) == null ? void 0 : _a4.call(slots)) != null ? _b4 : props.subtitle];
                    }
                  })])];
                }
              }), hasAppend && createVNode(CardAvatar, null, {
                default: () => {
                  var _a3, _b3;
                  return [(_b3 = (_a3 = slots.append) == null ? void 0 : _a3.call(slots)) != null ? _b3 : createVNode(Avatar, {
                    "density": props.density,
                    "icon": props.appendIcon,
                    "image": props.appendAvatar
                  }, null)];
                }
              })])];
            }
          }), props.divided && createVNode(Divider, null, null), hasText && createVNode(CardText, null, {
            default: () => {
              var _a2, _b2;
              return [(_b2 = (_a2 = slots.text) == null ? void 0 : _a2.call(slots)) != null ? _b2 : props.text];
            }
          }), (_b = slots.default) == null ? void 0 : _b.call(slots), slots.actions && props.divided && createVNode(Divider, null, null), slots.actions && createVNode(CardActions, null, _isSlot(_slot = slots.actions()) ? _slot : {
            default: () => [_slot]
          })];
        }
      }), [[resolveDirective("ripple"), isClickable && props.ripple]]);
    };
  }
});
function filterCardProps(props) {
  return pick(props, Object.keys(Card.props));
}
export {
  Card,
  filterCardProps,
  makeCardProps
};
//# sourceMappingURL=card.mjs.map
