import { computed, defineComponent, createVNode as _createVNode } from 'vue';
import '../interface';
import { Color } from '../color';
import { generateColor } from '../util';
import { initDefaultProps } from '../../_util/props-util';
const gradientProps = () => ({
  colors: Array,
  direction: String,
  type: String,
  prefixCls: String
});
const Gradient = defineComponent({
  name: 'Gradient',
  inheritAttrs: false,
  props: initDefaultProps(gradientProps(), {
    direction: 'to right'
  }),
  setup(props, {
    slots
  }) {
    const gradientColors = computed(() => props.colors.map((color, idx) => {
      let result = generateColor(color);
      if (props.type === 'alpha' && idx === props.colors.length - 1) {
        result = new Color(result.setA(1));
      }
      return result.toRgbString();
    }).join(','));
    return () => {
      var _a;
      const {
        direction,
        prefixCls
      } = props;
      return _createVNode("div", {
        "class": `${prefixCls}-gradient`,
        "style": {
          position: 'absolute',
          inset: 0,
          background: `linear-gradient(${direction}, ${gradientColors.value})`
        }
      }, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]);
    };
  }
});
export default Gradient;