<template>
  <view :class="avatarClass" :style="avatarStyle">
    <slot>
      <image
        v-if="src"
        :src="src"
        mode="aspectFill"
        :class="classNames(bem.e('image'), bem.m(shape))"
      />

      <sar-icon v-else name="person" :root-class="bem.e('icon')" />
    </slot>
    <slot name="extra"></slot>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed } from "vue";
import { classNames, stringifyStyle, createBem } from "../utils";
import SarIcon from "../icon/icon.vue";
import { avatarProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "avatar",
  props: avatarProps,
  setup(__props, { expose: __expose }) {
    __expose();
    const props = __props;
    const bem = createBem("avatar");
    const avatarClass = computed(() => {
      return classNames(bem.b(), bem.m(props.shape), props.rootClass);
    });
    const avatarStyle = computed(() => {
      return stringifyStyle(
        {
          width: props.size,
          height: props.size,
          color: props.color,
          fontSize: props.iconSize,
          background: props.background
        },
        props.rootStyle
      );
    });
    const __returned__ = { props, bem, avatarClass, avatarStyle, get classNames() {
      return classNames;
    }, SarIcon };
    return __returned__;
  }
});
</script>

<style lang="scss">
@use './index.scss';
</style>