import { createVNode as _createVNode } from "vue";
import { computed, defineComponent } from 'vue';
import { generateColor } from '../util';
var Gradient = defineComponent({
  name: 'ColorBlock',
  props: ['direction', 'prefixCls', 'type', 'colors'],
  setup: function setup(props, _ref) {
    var slots = _ref.slots;
    var direction = computed(function () {
      return props.direction || 'to right';
    });
    var gradientColors = computed(function () {
      var colors = props.colors,
        type = props.type;
      return colors.map(function (color, idx) {
        var result = generateColor(color);
        if (type === 'alpha' && idx === colors.length - 1) {
          result.setAlpha(1);
        }
        return result.toRgbString();
      }).join(',');
    });
    return function () {
      var _slots$children;
      return _createVNode("div", {
        "class": "".concat(props.prefixCls, "-gradient"),
        "style": {
          position: 'absolute',
          inset: 0,
          background: "linear-gradient(".concat(direction.value, ", ").concat(gradientColors.value, ")")
        }
      }, [(_slots$children = slots.children) === null || _slots$children === void 0 ? void 0 : _slots$children.call(slots)]);
    };
  }
});
export default Gradient;