"use strict";

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

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

var _TextConfig = _interopRequireDefault(require("../../../../../meta-comp/config-panels/TextConfig"));

var _ButtonConfig = _interopRequireDefault(require("../../../../../meta-comp/config-panels/ButtonConfig"));

var _coreUtil = require("../../../../../utils/coreUtil");

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

require("./index.less");

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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");

    _extendStatics(d, b);

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

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

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

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

    _this.state = {};

    _this.reRender = function () {
      (0, _coreUtil.renderPreview)();

      _this.setState({});
    };

    return _this;
  }

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

    var panelProps = this.props.panelProps;
    console.log('panelProps', panelProps);

    var iconSetting = /*#__PURE__*/_react["default"].createElement(_common.Field, {
      title: ""
    }, /*#__PURE__*/_react["default"].createElement(_common.IconPicker, {
      onChange: function onChange(icon) {
        panelProps.icon.url = icon;

        _this.reRender();
      },
      value: panelProps.icon.url
    }));

    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "flash_sale_title"
    }, /*#__PURE__*/_react["default"].createElement(_common.Collapse, {
      headerSize: "middle",
      onRefresh: this.reRender,
      source: [{
        key: '1',
        name: 'Icon',
        value: iconSetting,
        metaOption: panelProps.icon
      }, {
        key: '2',
        name: 'Headline',
        value: /*#__PURE__*/_react["default"].createElement(_TextConfig["default"], {
          data: panelProps.headline
        }),
        metaOption: panelProps.headline
      }, {
        key: '3',
        name: 'Button',
        value: /*#__PURE__*/_react["default"].createElement(_ButtonConfig["default"], {
          data: panelProps.button
        }),
        metaOption: panelProps.button
      }],
      type: "switch"
    }));
  };

  AComponent.defaultProps = {
    panelProps: {
      icon: {
        open: true,
        url: ''
      },
      headline: {},
      button: {}
    }
  };
  return AComponent;
}(_react["default"].Component);

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