/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _defineProperty } from '../_chunks/dep-eb20e23f.mjs';
import { defineComponent, computed, createVNode } from 'vue';
import { CloseCircleFilledIcon, CheckCircleFilledIcon, ErrorCircleFilledIcon, CloseIcon, CheckIcon, ErrorIcon } from '@ldesign/icons-vue-next';
import { i as isObject_1 } from '../_chunks/dep-0f0c89ff.mjs';
import { i as isString_1 } from '../_chunks/dep-1cf2b129.mjs';
import { getBackgroundColor } from '../utils/helper.mjs';
import { usePrefixClass } from '../hooks/useConfig.mjs';
import { useGlobalIcon } from '../hooks/useGlobalIcon.mjs';
import { useTNodeJSX } from '../hooks/tnode.mjs';
import props from './props.mjs';
import { CIRCLE_SIZE_PX, CIRCLE_SIZE, PRO_THEME, CIRCLE_FONT_SIZE_RATIO, STATUS_ICON } from './constants.mjs';
import '../_chunks/dep-b4041200.mjs';
import '../_chunks/dep-a0b4a044.mjs';
import '../_chunks/dep-c959a6fb.mjs';
import '../_chunks/dep-e3b14d70.mjs';
import '../_chunks/dep-66d6733b.mjs';
import '../_chunks/dep-c31e1d9e.mjs';
import '../_chunks/dep-b6a73f93.mjs';
import '../_chunks/dep-55846619.mjs';
import '../_chunks/dep-cfcedf47.mjs';
import '../_chunks/dep-f6649a46.mjs';
import '../_chunks/dep-37ba476d.mjs';
import '../_chunks/dep-be27d184.mjs';
import '../_chunks/dep-1fe0ad42.mjs';
import '../_chunks/dep-d54f2690.mjs';
import '../_chunks/dep-59c8420d.mjs';
import '../_chunks/dep-74848b92.mjs';
import '../_chunks/dep-30451c48.mjs';
import '../_chunks/dep-6f89b77e.mjs';
import '../_chunks/dep-6eea369f.mjs';
import '../config-provider/useConfig.mjs';
import '../_chunks/dep-44417261.mjs';
import '../_chunks/dep-bf74f1c2.mjs';
import '../_chunks/dep-79821ff2.mjs';
import '../_chunks/dep-0bfbf721.mjs';
import '../_chunks/dep-39cc276d.mjs';
import '../_chunks/dep-6b22dd27.mjs';
import '../_chunks/dep-8f777748.mjs';
import '../_chunks/dep-ae357f26.mjs';
import '../_chunks/dep-352691c2.mjs';
import '../_chunks/dep-2cfd5b3a.mjs';
import '../_chunks/dep-05fa17c9.mjs';
import '../_chunks/dep-a9c8a5d5.mjs';
import '../_chunks/dep-10085c61.mjs';
import '../_chunks/dep-1b058de3.mjs';
import '../_chunks/dep-c852a61a.mjs';
import '../_chunks/dep-92e7085e.mjs';
import '../_chunks/dep-44f056cd.mjs';
import '../_chunks/dep-23a0f453.mjs';
import '../_chunks/dep-99920870.mjs';
import '../_chunks/dep-c7e9ce16.mjs';
import '../_chunks/dep-3afa94cf.mjs';
import '../_chunks/dep-ba3c0b2e.mjs';
import '../_chunks/dep-ee57d235.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/zh_CN.mjs';
import '../_chunks/dep-6b4aa943.mjs';
import '../_chunks/dep-d52291a9.mjs';
import '../config-provider/type.mjs';
import '../_chunks/dep-c4e1a112.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-bd03960e.mjs';

var _Progress = defineComponent({
  name: "TProgress",
  props: props,
  setup: function setup(props2) {
    var renderTNodeJSX = useTNodeJSX();
    var COMPONENT_NAME = usePrefixClass("progress");
    var _useGlobalIcon = useGlobalIcon({
        CloseCircleFilledIcon: CloseCircleFilledIcon,
        CheckCircleFilledIcon: CheckCircleFilledIcon,
        ErrorCircleFilledIcon: ErrorCircleFilledIcon,
        CloseIcon: CloseIcon,
        CheckIcon: CheckIcon,
        ErrorIcon: ErrorIcon
      }),
      CloseCircleFilledIcon$1 = _useGlobalIcon.CloseCircleFilledIcon,
      CheckCircleFilledIcon$1 = _useGlobalIcon.CheckCircleFilledIcon,
      ErrorCircleFilledIcon$1 = _useGlobalIcon.ErrorCircleFilledIcon,
      CloseIcon$1 = _useGlobalIcon.CloseIcon,
      CheckIcon$1 = _useGlobalIcon.CheckIcon,
      ErrorIcon$1 = _useGlobalIcon.ErrorIcon;
    var statusStyle = computed(function () {
      if (props2.percentage >= 100) return "success";
      return props2.status || "default";
    });
    var trackBgStyle = computed(function () {
      var style = {};
      if (props2.strokeWidth) {
        var height = isString_1(props2.strokeWidth) ? props2.strokeWidth : "".concat(props2.strokeWidth, "px");
        style.height = height;
        style.borderRadius = height;
      }
      if (props2.trackColor) style.backgroundColor = props2.trackColor;
      return style;
    });
    var barStyle = computed(function () {
      return {
        width: "".concat(props2.percentage, "%"),
        background: props2.color && getBackgroundColor(props2.color)
      };
    });
    var circlePathStyle = computed(function () {
      var strokeColor = isObject_1(props2.color) ? "" : props2.color;
      return {
        stroke: strokeColor
      };
    });
    var circleOuterStyle = computed(function () {
      var strokeColor = isObject_1(props2.trackColor) ? "" : props2.trackColor;
      return {
        stroke: strokeColor
      };
    });
    var diameter = computed(function () {
      var diameter2 = CIRCLE_SIZE_PX.MEDIUM;
      if (!props2.size) return diameter2;
      var SMALL = CIRCLE_SIZE.SMALL,
        LARGE = CIRCLE_SIZE.LARGE,
        MEDIUM = CIRCLE_SIZE.MEDIUM;
      switch (props2.size) {
        case SMALL:
          diameter2 = CIRCLE_SIZE_PX.SMALL;
          break;
        case MEDIUM:
          diameter2 = CIRCLE_SIZE_PX.MEDIUM;
          break;
        case LARGE:
          diameter2 = CIRCLE_SIZE_PX.LARGE;
          break;
        default:
          diameter2 = Number(props2.size);
          break;
      }
      return diameter2;
    });
    var rPoints = computed(function () {
      return diameter.value / 2;
    });
    var radius = computed(function () {
      return rPoints.value - circleStrokeWidth.value / 2;
    });
    var circleStyle = computed(function () {
      if (props2.theme !== PRO_THEME.CIRCLE) return {};
      var fontSize = diameter.value * CIRCLE_FONT_SIZE_RATIO.MEDIUM;
      if (diameter.value <= CIRCLE_SIZE_PX.SMALL) fontSize = diameter.value * CIRCLE_FONT_SIZE_RATIO.SMALL;else if (diameter.value >= CIRCLE_SIZE_PX.LARGE) fontSize = diameter.value * CIRCLE_FONT_SIZE_RATIO.LARGE;
      return {
        width: "".concat(diameter.value, "px"),
        height: "".concat(diameter.value, "px"),
        fontSize: "".concat(fontSize, "px")
      };
    });
    var circleStrokeWidth = computed(function () {
      var defaultWidth = props2.size === CIRCLE_SIZE.SMALL ? 4 : 6;
      return props2.strokeWidth ? Number(props2.strokeWidth) : defaultWidth;
    });
    var strokeDashArr = computed(function () {
      var radius2 = (diameter.value - circleStrokeWidth.value) / 2;
      var perimeter = Math.PI * 2 * radius2;
      var percent = props2.percentage / 100;
      return "".concat(perimeter * percent, "  ").concat(perimeter * (1 - percent));
    });
    var getIconMap = function getIconMap() {
      var CIRCLE_ICONS = {
        success: CheckIcon$1,
        warning: ErrorIcon$1,
        error: CloseIcon$1
      };
      var NORMAL_ICONS = {
        success: CheckCircleFilledIcon$1,
        warning: ErrorCircleFilledIcon$1,
        error: CloseCircleFilledIcon$1
      };
      return props2.theme === PRO_THEME.CIRCLE ? CIRCLE_ICONS : NORMAL_ICONS;
    };
    var getLabelContent = function getLabelContent() {
      var labelContent = "".concat(props2.percentage, "%");
      var status = props2.status || "";
      if (STATUS_ICON.includes(status) && props2.theme !== PRO_THEME.PLUMP) {
        var components = getIconMap();
        var component = components[status];
        if (component) labelContent = createVNode(component, {
          "class": ["".concat(COMPONENT_NAME.value, "__icon")]
        }, null);
      }
      return labelContent;
    };
    return function () {
      var labelContent = createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__info")
      }, [renderTNodeJSX("label", getLabelContent())]);
      var PLUMP_SEPARATE = 10;
      var separateClasses = props2.percentage > PLUMP_SEPARATE ? "".concat(COMPONENT_NAME.value, "--over-ten") : "".concat(COMPONENT_NAME.value, "--under-ten");
      return createVNode("div", {
        "class": COMPONENT_NAME.value
      }, [props2.theme === PRO_THEME.LINE && createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "--thin ").concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value)
      }, [createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__bar"),
        "style": trackBgStyle.value
      }, [createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__inner"),
        "style": barStyle.value
      }, null)]), labelContent]), props2.theme === PRO_THEME.PLUMP && createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__bar ").concat(COMPONENT_NAME.value, "--plump ").concat(separateClasses), _defineProperty({}, "".concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value), statusStyle.value)],
        "style": trackBgStyle.value
      }, [createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__inner"),
        "style": barStyle.value
      }, [props2.percentage > PLUMP_SEPARATE && labelContent]), props2.percentage <= PLUMP_SEPARATE && labelContent]), props2.theme === PRO_THEME.CIRCLE && createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "--circle ").concat(COMPONENT_NAME.value, "--status--").concat(statusStyle.value),
        "style": circleStyle.value
      }, [labelContent, createVNode("svg", {
        "width": diameter.value,
        "height": diameter.value,
        "viewBox": "0 0 ".concat(diameter.value, " ").concat(diameter.value)
      }, [createVNode("circle", {
        "cx": rPoints.value,
        "cy": rPoints.value,
        "r": radius.value,
        "stroke-width": circleStrokeWidth.value,
        "fill": "none",
        "class": ["".concat(COMPONENT_NAME.value, "__circle-outer")],
        "style": circleOuterStyle.value
      }, null), props2.percentage > 0 && createVNode("circle", {
        "cx": rPoints.value,
        "cy": rPoints.value,
        "r": radius.value,
        "stroke-width": circleStrokeWidth.value,
        "fill": "none",
        "stroke-linecap": "round",
        "class": ["".concat(COMPONENT_NAME.value, "__circle-inner")],
        "transform": "matrix(0,-1,1,0,0,".concat(diameter.value, ")"),
        "stroke-dasharray": strokeDashArr.value,
        "style": circlePathStyle.value
      }, null)])])]);
    };
  }
});

export { _Progress as default };
//# sourceMappingURL=progress.mjs.map
