"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _antd = require("antd");

var _common = require("../../../../common");

var _BaseConfig = _interopRequireDefault(require("../../../../meta-comp/config-panels/BaseConfig"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var BackgroundConfig =
/** @class */
function (_super) {
  __extends(BackgroundConfig, _super);

  function BackgroundConfig() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {};
    return _this;
  }

  BackgroundConfig.prototype.render = function () {
    var _this = this;

    var data = this.props.data;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "container"
    }, /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: "Background"
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select, {
      onChange: function onChange(bgType) {
        data.bgType = bgType;

        _this.selfRender();
      },
      style: {
        marginBottom: '15px'
      },
      value: data.bgType
    }, /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "color"
    }, "Color"), /*#__PURE__*/_react["default"].createElement(_antd.Select.Option, {
      value: "image"
    }, "Image")), data.bgType === 'color' ? /*#__PURE__*/_react["default"].createElement(_common.ColorPickerInput, {
      colorType: "rgba",
      onChange: function onChange(v) {
        data.opacity = 1;
        data.color = v;

        _this.selfRender();
      },
      value: data.color
    }) : /*#__PURE__*/_react["default"].createElement(_common.ImagePicker, {
      onChange: function onChange(v) {
        data.image = v.url;

        _this.selfRender();
      },
      value: data.image
    })));
  };

  BackgroundConfig.defaultProps = {
    data: {
      opacity: 100,
      color: '#232F46',
      image: '',
      bgType: 'color'
    }
  };
  return BackgroundConfig;
}(_BaseConfig["default"]);

var _default = BackgroundConfig;
exports["default"] = _default;