import { defineComponent, computed, createVNode } from 'vue';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import { ribbonProps } from './props.mjs';
import { isPresetColor } from '../../../utils/color.mjs';

var ABadgeRibbon = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ABadgeRibbon",
  inheritAttrs: false,
  props: ribbonProps(),
  slots: Object,
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject("ribbon", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const colorInPreset = computed(() => isPresetColor(props.color, false));
    const ribbonCls = computed(() => [prefixCls.value, `${prefixCls.value}-placement-${props.placement}`, {
      [`${prefixCls.value}-rtl`]: direction.value === "rtl",
      [`${prefixCls.value}-color-${props.color}`]: colorInPreset.value
    }]);
    return () => {
      var _a, _b;
      const {
        class: className,
        style,
        ...restAttrs
      } = attrs;
      const colorStyle = {};
      const cornerColorStyle = {};
      if (props.color && !colorInPreset.value) {
        colorStyle.background = props.color;
        cornerColorStyle.color = props.color;
      }
      return wrapSSR(createVNode("div", {
        "class": `${prefixCls.value}-wrapper ${hashId.value}`,
        ...restAttrs
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots), createVNode("div", {
        "class": [ribbonCls.value, className, hashId.value],
        "style": {
          ...colorStyle,
          ...style
        }
      }, [createVNode("span", {
        "class": `${prefixCls.value}-text`
      }, [props.text || ((_b = slots.text) == null ? void 0 : _b.call(slots))]), createVNode("div", {
        "class": `${prefixCls.value}-corner`,
        "style": cornerColorStyle
      }, null)])]));
    };
  }
});

export { ABadgeRibbon as default };
//# sourceMappingURL=Ribbon.mjs.map
