"use strict";

exports.__esModule = true;
exports.default = void 0;
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _toggler = _interopRequireDefault(require("../../organism/accordion/toggler"));
var _select = _interopRequireDefault(require("../../atom/select"));
var _inputReadonly = _interopRequireDefault(require("../../atom/input-readonly"));
var _inputText = _interopRequireDefault(require("../../atom/input-text"));
var _inputCheckbox = _interopRequireDefault(require("../../atom/input-checkbox"));
var _inputDoublestep = _interopRequireDefault(require("../../atom/input-doublestep"));
var _inputSwitch = _interopRequireDefault(require("../../atom/input-switch"));
var _inputFileDraggable = _interopRequireDefault(require("../../atom/input-file-draggable"));
var _setupCohortItem = _interopRequireDefault(require("../setup-cohort-item"));
var _messagePopin = _interopRequireDefault(require("../message-popin"));
var _brandDownloadBox = _interopRequireDefault(require("../brand-download-box"));
var _title = _interopRequireDefault(require("../../atom/title"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const SetupSlider = props => {
  const {
    tabProps = [],
    slides = []
  } = props;
  const buildSlides = slides_ => {
    return _map2.default.convert({
      cap: false
    })((slide, key) => {
      const buildInput = field => {
        const {
          type,
          ...rest
        } = field;
        switch (type) {
          case 'switch':
            return /*#__PURE__*/_react.default.createElement(_inputSwitch.default, field);
          case 'select':
            return /*#__PURE__*/_react.default.createElement(_select.default, _extends({}, field, {
              theme: 'coorpmanager'
            }));
          case 'checkbox':
            return /*#__PURE__*/_react.default.createElement(_inputCheckbox.default, field);
          case 'image':
            return /*#__PURE__*/_react.default.createElement("div", {
              className: _style.default.imageUploadContainer
            }, /*#__PURE__*/_react.default.createElement(_inputFileDraggable.default, field));
          case 'splitForm':
            return /*#__PURE__*/_react.default.createElement(_setupCohortItem.default, {
              field: field
            });
          case 'alert':
            return /*#__PURE__*/_react.default.createElement(_messagePopin.default, {
              header: field.title,
              content: field.subtitle
            });
          case 'readonly':
            return /*#__PURE__*/_react.default.createElement(_inputReadonly.default, field);
          case 'doublestep':
            return /*#__PURE__*/_react.default.createElement(_inputDoublestep.default, field);
          case 'downloadbox':
            return /*#__PURE__*/_react.default.createElement(_brandDownloadBox.default, field);
          case 'form-group':
            return /*#__PURE__*/_react.default.createElement(_title.default, field);
          case 'slider':
            return /*#__PURE__*/_react.default.createElement(_toggler.default, {
              tabProps: field.tabProps,
              type: 'all',
              theme: 'setup'
            }, buildSlides(field.slides));
          case 'text':
          case 'password':
            return /*#__PURE__*/_react.default.createElement(_inputText.default, field);
          default:
            return /*#__PURE__*/_react.default.createElement(_inputText.default, _extends({}, rest, {
              type: 'text'
            }));
        }
      };
      const buildField = (field, index) => {
        const input = buildInput(field);
        return /*#__PURE__*/_react.default.createElement("div", {
          className: _style.default.field,
          key: index
        }, input);
      };
      const fieldsList = _map2.default.convert({
        cap: false
      })(buildField, slide.fields);
      return /*#__PURE__*/_react.default.createElement("div", {
        className: _style.default.wrapper,
        key: key
      }, fieldsList);
    }, slides_);
  };
  const slidesView = buildSlides(slides);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapperStyle
  }, /*#__PURE__*/_react.default.createElement(_toggler.default, {
    tabProps: tabProps,
    type: 'all',
    theme: 'setup'
  }, slidesView));
};
const SlidePropTypes = process.env.NODE_ENV !== "production" ? _propTypes.default.shape({
  fields: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({
    ...SetupSlider.propTypes,
    type: _propTypes.default.oneOf(['slider'])
  }), _propTypes.default.shape({
    ..._inputSwitch.default.propTypes,
    type: _propTypes.default.oneOf(['switch'])
  }), _propTypes.default.shape({
    ..._select.default.propTypes,
    type: _propTypes.default.oneOf(['select'])
  }), _propTypes.default.shape({
    ..._inputCheckbox.default.propTypes,
    type: _propTypes.default.oneOf(['checkbox'])
  }), _propTypes.default.shape({
    ..._inputFileDraggable.default.propTypes,
    type: _propTypes.default.oneOf(['image'])
  }), _propTypes.default.shape({
    ..._inputReadonly.default.propTypes,
    type: _propTypes.default.oneOf(['readonly'])
  }), _propTypes.default.shape({
    ..._inputText.default.propTypes,
    type: _propTypes.default.oneOf(['text', 'password'])
  }), _propTypes.default.shape({
    ..._inputDoublestep.default.propTypes,
    type: _propTypes.default.oneOf(['doublestep'])
  }), _propTypes.default.shape({
    ..._setupCohortItem.default.propTypes,
    type: _propTypes.default.oneOf(['splitForm'])
  }), _propTypes.default.shape({
    ..._messagePopin.default.propTypes,
    type: _propTypes.default.oneOf(['alert'])
  }), _propTypes.default.shape(_inputText.default.propTypes), _propTypes.default.shape({
    ..._brandDownloadBox.default.propTypes,
    type: _propTypes.default.oneOf(['downloadbox'])
  })]))
}) : {};
const SetupSliderPropTypes = process.env.NODE_ENV !== "production" ? {
  tabProps: _propTypes.default.arrayOf(_propTypes.default.shape(_toggler.default.propTypes)),
  slides: _propTypes.default.arrayOf(SlidePropTypes)
} : {};
SetupSlider.propTypes = process.env.NODE_ENV !== "production" ? SetupSliderPropTypes : {};
var _default = exports.default = SetupSlider;
//# sourceMappingURL=index.js.map