import { defineComponent, useAttrs, computed, resolveComponent, createBlock, openBlock, withCtx, createVNode, mergeProps, unref, createSlots, renderSlot } from 'vue';
import '../../../utils/index.mjs';
import { progressBarProps } from './progress-bar.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlProgressBar" },
  __name: "progress-bar",
  props: progressBarProps,
  setup(__props) {
    const props = __props;
    const bem = createNamespace("progress-bar");
    const attrs = useAttrs();
    const value = computed(() => {
      const successPercent = props.success?.percent || 0;
      return (percent) => {
        return props.format && typeof props.format === "function" ? props.format(percent, successPercent) : percent;
      };
    });
    const getStrokeColor = computed(() => {
      if (typeof props.strokeColor === "object") {
        if (Object.keys(props.strokeColor).length > 0) {
          if (props.steps && props.steps > 0) {
            return props.strokeColor[Object.keys(props.strokeColor)[0]];
          } else {
            return props.strokeColor;
          }
        } else {
          return void 0;
        }
      } else {
        return props.strokeColor;
      }
    });
    return (_ctx, _cache) => {
      const _component_ll_html = resolveComponent("ll-html");
      const _component_a_progress = resolveComponent("a-progress");
      const _component_ll_tooltip = resolveComponent("ll-tooltip");
      return openBlock(), createBlock(_component_ll_tooltip, {
        open: _ctx.hoverTip ? void 0 : false,
        tip: _ctx.hoverTip,
        "show-container": false
      }, {
        default: withCtx(() => [
          createVNode(_component_a_progress, mergeProps(unref(attrs), {
            success: _ctx.success,
            steps: _ctx.steps,
            "stroke-color": getStrokeColor.value,
            class: [unref(bem).b(), unref(bem).is(_ctx.textPosition)]
          }), createSlots({
            _: 2
            /* DYNAMIC */
          }, [
            _ctx.format || _ctx.$slots.format ? {
              name: "format",
              fn: withCtx((percent) => [
                renderSlot(_ctx.$slots, "format", { percent }, () => [
                  createVNode(_component_ll_html, {
                    value: value.value(percent)
                  }, null, 8, ["value"])
                ])
              ]),
              key: "0"
            } : void 0
          ]), 1040, ["success", "steps", "stroke-color", "class"])
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["open", "tip"]);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=progress-bar.vue2.mjs.map
