<import src="../common/template/icon.wxml" />
<wxs src="../common/utils.wxs" module="_" />
<wxs src="./avatar.wxs" module="this" />

<view class="{{classPrefix}}__wrapper {{prefix}}-class" style="{{this.getAvatarStyles(isShow, zIndex, customStyle)}}">
  <t-badge
    color="{{badgeProps.color}}"
    content="{{badgeProps.content}}"
    count="{{badgeProps.count}}"
    dot="{{badgeProps.dot}}"
    max-count="{{badgeProps.maxCount || 99}}"
    offset="{{badgeProps.offset}}"
    shape="{{badgeProps.shape || 'circle'}}"
    show-zero="{{badgeProps.showZero}}"
    size="{{badgeProps.size || 'medium'}}"
    t-class="{{badgeProps.tClass}}"
    t-class-content="{{badgeProps.tClassContent}}"
    t-class-count="{{badgeProps.tClassCount}}"
  >
    <view
      class="{{this.getAvatarOuterClass(classPrefix, size, shape, bordered)}} {{prefix}}-class-image "
      style="{{this.getAvatarSizePx(size)}}"
      aria-label="{{ ariaLabel || alt ||'头像'}}"
      aria-role="{{ ariaRole || 'img'}}"
      aria-hidden="{{ ariaHidden }}"
    >
      <t-image
        wx:if="{{image}}"
        class="{{prefix}}-image"
        t-class="{{classPrefix}}__image"
        t-class-load="{{prefix}}-class-alt"
        customStyle="{{imageProps.customStyle}}"
        src="{{image}}"
        mode="{{imageProps.mode || 'aspectFill'}}"
        lazy="{{imageProps.lazy}}"
        loading="{{imageProps.loading}}"
        shape="{{imageProps.shape || 'round'}}"
        webp="{{imageProps.webp}}"
        error="{{alt}}"
        bind:error="onLoadError"
      />
      <template
        wx:elif="{{iconName || _.isNoEmptyObj(iconData)}}"
        is="icon"
        data="{{class: classPrefix + '__icon', tClass: prefix + '-class-icon', name: iconName, ...iconData}}"
      />
      <view wx:else class="{{classPrefix}}__text {{prefix}}-class-content">
        <slot />
      </view>
    </view>
  </t-badge>
</view>
