"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _vue = require("vue");
var _util = require("../util");
var _ColorSteppers = _interopRequireDefault(require("./ColorSteppers"));
const colorAlphaInputProps = () => ({
  prefixCls: String,
  value: Object,
  onChange: Function
});
const ColorAlphaInput = (0, _vue.defineComponent)({
  name: 'ColorAlphaInput',
  inheritAttrs: false,
  props: colorAlphaInputProps(),
  setup(props) {
    const colorAlphaInputPrefixCls = (0, _vue.computed)(() => `${props.prefixCls}-alpha-input`);
    const internalValue = (0, _vue.ref)((0, _util.generateColor)(props.value || '#000'));
    const alphaValue = (0, _vue.computed)(() => props.value || internalValue.value);
    const handleAlphaChange = step => {
      var _a;
      const hsba = alphaValue.value.toHsb();
      hsba.a = (step || 0) / 100;
      const genColor = (0, _util.generateColor)(hsba);
      internalValue.value = genColor;
      (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, genColor);
    };
    return () => (0, _vue.createVNode)(_ColorSteppers.default, {
      "value": (0, _util.getColorAlpha)(alphaValue.value),
      "prefixCls": props.prefixCls,
      "formatter": step => `${step}%`,
      "className": colorAlphaInputPrefixCls.value,
      "onChange": handleAlphaChange
    }, null);
  }
});
var _default = exports.default = ColorAlphaInput;