<template>
  <view :class="progressBarClass" :style="progressBarStyle">
    <view :class="bem.e('track')" :style="trackStyle">
      <view :class="bem.e('piece')" :style="pieceStyle">
        <view v-if="showText && inside" :class="bem.e('text')">
          <slot>{{ percent }}%</slot>
        </view>
      </view>
    </view>
    <view v-if="showText && !inside && !status" :class="bem.e('text')">
      <slot>{{ percent }}%</slot>
    </view>
    <view v-if="status" :class="bem.e('status')">
      <sar-icon :name="iconName" />
    </view>
  </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 { progressBarProps } from "./common";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "progress-bar",
  props: progressBarProps,
  setup(__props, { expose: __expose }) {
    __expose();
    const props = __props;
    const bem = createBem("progress-bar");
    const iconName = computed(() => {
      if (!props.status) {
        return "";
      }
      return {
        success: "check-circle-fill",
        warning: "warning-fill",
        error: "x-circle-fill"
      }[props.status];
    });
    const progressBarClass = computed(() => {
      return classNames(
        bem.b(),
        bem.m("inside", props.inside),
        bem.m("striped", props.striped),
        bem.m("animated", props.animated),
        bem.m(props.status),
        props.rootClass
      );
    });
    const progressBarStyle = computed(() => {
      return stringifyStyle(props.rootStyle);
    });
    const trackStyle = computed(() => {
      return stringifyStyle({
        height: props.thickness,
        backgroundColor: props.trackColor
      });
    });
    const pieceStyle = computed(() => {
      return stringifyStyle({
        width: `${props.percent}%`,
        backgroundColor: props.color
      });
    });
    const __returned__ = { props, bem, iconName, progressBarClass, progressBarStyle, trackStyle, pieceStyle, SarIcon };
    return __returned__;
  }
});
</script>

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