"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2);exports.default=confirm;var _react=require("react"),React=_interopRequireWildcard(_react),_reactDom=require("react-dom"),ReactDOM=_interopRequireWildcard(_reactDom),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon),_Modal=require("./Modal"),_Modal2=_interopRequireDefault(_Modal),_ActionButton=require("./ActionButton"),_ActionButton2=_interopRequireDefault(_ActionButton),_locale=require("./locale"),_checkbox=require("../checkbox"),_checkbox2=_interopRequireDefault(_checkbox);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var IS_REACT_16=!!ReactDOM.createPortal,ConfirmDialog=function(e){function r(e){(0,_classCallCheck3.default)(this,r);var t=(0,_possibleConstructorReturn3.default)(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.state={okBtnDisabled:e.doubleCheck||!1},t}return(0,_inherits3.default)(r,e),(0,_createClass3.default)(r,[{key:"render",value:function(){var t=this,e=this.props,r=e.onCancel,a=e.onOk,o=e.close,n=e.zIndex,s=e.afterClose,l=e.visible,i=this.props.iconType||"question-circle",c=this.props.okType||"primary",u=this.props.prefixCls||"dt-confirm",p=!("okCancel"in this.props)||this.props.okCancel,d=this.props.width||(this.state.doubleCheck?630:550),_=this.props.style||{},h=void 0!==this.props.maskClosable&&this.props.maskClosable,f=(0,_locale.getConfirmLocale)(),m=this.props.okText||(p?f.okText:f.justOkText),C=this.props.cancelText||f.cancelText,b=(0,_classnames2.default)(u,u+"-"+this.props.type,this.props.className),R=p?[React.createElement(_ActionButton2.default,{key:"cancel",type:"secondary",actionFn:r,closeModal:o},C)]:[],k=this.props.doubleCheck?React.createElement("div",{className:u+"-doubleCheckContent"},React.createElement(_checkbox2.default,{onChange:function(e){t.setState({okBtnDisabled:!e.target.checked})}}),React.createElement("span",null,this.props.subContent)):React.createElement("div",{className:u+"-content"},this.props.subContent),q=R.concat([React.createElement(_ActionButton2.default,{key:"ok",type:c,actionFn:a,closeModal:o,disabled:this.state.okBtnDisabled,autoFocus:!0},m)]);return React.createElement(_Modal2.default,{className:b,onCancel:o.bind(this,{triggerCancel:!0}),visible:l,title:this.props.title,transitionName:"zoom",footer:q,maskTransitionName:"fade",maskClosable:h,style:_,width:d,zIndex:n,afterClose:s},React.createElement("div",{className:u+"-body-wrapper"},React.createElement("div",{className:u+"-body"},React.createElement(_icon2.default,{type:i}),React.createElement("span",{className:u+"-title"},this.props.content),k)))}}]),r}(React.Component);function confirm(o){var n=document.createElement("div");function a(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];IS_REACT_16?l((0,_extends3.default)({},o,{close:a,visible:!1,afterClose:s.bind.apply(s,[this].concat(t))})):s.apply(void 0,t)}function s(){ReactDOM.unmountComponentAtNode(n)&&n.parentNode&&n.parentNode.removeChild(n);for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=t&&t.length&&t.some(function(e){return e&&e.triggerCancel});o.onCancel&&a&&o.onCancel.apply(o,t)}function l(e){ReactDOM.render(React.createElement(ConfirmDialog,e),n)}return document.body.appendChild(n),l((0,_extends3.default)({},o,{visible:!0,close:a})),{destroy:a}}module.exports=exports.default;