<template>
  <component
    :is="$attrs.onSubmit ? 'form': as"
    :class="[ui.base, ui.rounded, ui.divide, ui.ring, ui.shadow, ui.background]"
    v-bind="$attrs"
  >
    <div v-if="$slots.header" :class="[ui.header.base, ui.header.padding, ui.header.background]">
      <slot name="header" />
    </div>
    <div :class="[ui.body.base, ui.body.padding, ui.body.background]">
      <slot />
    </div>
    <div v-if="$slots.footer" :class="[ui.footer.base, ui.footer.padding, ui.footer.background]">
      <slot name="footer" />
    </div>
  </component>
</template>

<script>
import { computed, defineComponent } from "vue";
import { defu } from "defu";
import { useAppConfig } from "#imports";
import appConfig from "#build/app.config";
export default defineComponent({
  inheritAttrs: false,
  props: {
    as: {
      type: String,
      default: "div"
    },
    ui: {
      type: Object,
      default: () => appConfig.ui.card
    }
  },
  setup(props) {
    const appConfig2 = useAppConfig();
    const ui = computed(() => defu({}, props.ui, appConfig2.ui.card));
    return {
      // eslint-disable-next-line vue/no-dupe-keys
      ui
    };
  }
});
</script>
