"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),React=_interopRequireWildcard(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_classnames=_interopRequireDefault(require("classnames")),_reactPortal=require("react-portal"),_ButtonBase=_interopRequireDefault(require("@material-ui/core/ButtonBase")),_withStyles=_interopRequireDefault(require("../../hoc/withStyles")),_types=require("../../config/types"),_ErrorBoundary=_interopRequireDefault(require("../../hoc/ErrorBoundary")),_Button=_interopRequireDefault(require("../Button")),_styles=_interopRequireDefault(require("./styles")),Modal=/*#__PURE__*/function(_React$Component){function Modal(){return(0,_classCallCheck2.default)(this,Modal),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(Modal).apply(this,arguments))}return(0,_inherits2.default)(Modal,_React$Component),(0,_createClass2.default)(Modal,[{key:"_defaultContentRender",value:function _defaultContentRender(){var _this$props=this.props,classes=_this$props.classes,title=_this$props.title,description=_this$props.description,buttons=_this$props.buttons,theme=_this$props.theme,showCloseButton=_this$props.showCloseButton,onClose=_this$props.onClose;return React.createElement("div",{className:classes.content},React.createElement("div",{className:classes.contentInnerWrapper},showCloseButton&&React.createElement(_ButtonBase.default,{classes:{root:classes.closeButton},onClick:onClose},React.createElement("i",{className:"ion ion-close"})),title&&React.createElement("div",{className:classes.title},title),description&&React.createElement("div",{className:classes.description},description),buttons&&0<buttons.length&&React.createElement("div",{className:classes.buttons},buttons.map(function(buttonProps,index){return React.createElement(_Button.default,(0,_extends2.default)({key:index,classes:{component:(0,_classnames.default)(classes.button,{cancel:"cancel"===buttonProps.type}),text:(0,_classnames.default)((0,_defineProperty2.default)({},classes.cancelButtonText,"cancel"===buttonProps.type))},buttonColor:theme.palette.primary.color2},buttonProps))}))))}},{key:"render",value:function render(){var _this$props2=this.props,classes=_this$props2.classes,visible=_this$props2.visible,renderContent=_this$props2.renderContent;return visible?React.createElement(_ErrorBoundary.default,null,React.createElement(_reactPortal.Portal,null,React.createElement("div",{className:classes.component},renderContent?renderContent():this._defaultContentRender()))):null}}]),Modal}(React.Component);(0,_defineProperty2.default)(Modal,"propTypes",(0,_objectSpread2.default)({visible:_propTypes.default.bool,overlayColor:_propTypes.default.string,onClose:_propTypes.default.func,title:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.node]),description:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.node]),titleColor:_propTypes.default.string,buttons:_propTypes.default.arrayOf(_propTypes.default.any),renderContent:_propTypes.default.func,showCloseButton:_propTypes.default.bool},_types.withStylesProps)),(0,_defineProperty2.default)(Modal,"defaultProps",{visible:!1,onClose:function onClose(){},overlayColor:"rgba(0,0,0,0.5)",buttons:[],title:"",description:"",showCloseButton:!1});var _default=(0,_withStyles.default)(_styles.default)(Modal);exports.default=_default;