"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_react=require("react"),React=_interopRequireWildcard(_react),_rcNotification=require("rc-notification"),_rcNotification2=_interopRequireDefault(_rcNotification),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var notificationInstance={},defaultDuration=4.5,defaultTop=24,defaultBottom=24,defaultPlacement="topRight",defaultGetContainer=void 0;function setNotificationConfig(e){var t=e.duration,n=e.placement,o=e.bottom,a=e.top,i=e.getContainer;void 0!==t&&(defaultDuration=t),void 0!==n&&(defaultPlacement=n),void 0!==o&&(defaultBottom=o),void 0!==a&&(defaultTop=a),void 0!==i&&(defaultGetContainer=i)}function getPlacementStyle(e){var t=void 0;switch(e){case"topLeft":t={left:0,top:defaultTop,bottom:"auto"};break;case"topRight":t={right:0,top:defaultTop,bottom:"auto"};break;case"bottomLeft":t={left:0,top:"auto",bottom:defaultBottom};break;default:t={right:0,top:"auto",bottom:defaultBottom}}return t}function getNotificationInstance(e,t,n){var o=e+"-"+t;notificationInstance[o]?n(notificationInstance[o]):_rcNotification2.default.newInstance({prefixCls:e,className:e+"-"+t,style:getPlacementStyle(t),getContainer:defaultGetContainer},function(e){notificationInstance[o]=e,n(e)})}var typeToIcon={success:"check-circle",info:"info-circle",error:"close-circle",warning:"exclamation-circle"};function notice(t){var e=t.prefixCls||"dt-notification",n=e+"-notice",o=void 0===t.duration?defaultDuration:t.duration,a=null;if(t.icon)a=React.createElement("span",{className:n+"-icon"},t.icon);else if(t.type){var i=typeToIcon[t.type];a=React.createElement(_icon2.default,{className:n+"-icon "+n+"-icon-"+t.type,type:i})}var c=!t.description&&a?React.createElement("span",{className:n+"-message-single-line-auto-margin"}):null;getNotificationInstance(e,t.placement||defaultPlacement,function(e){e.notice({content:React.createElement("div",null,React.createElement("div",{className:a?n+"-with-icon":""},a,React.createElement("div",{className:n+"-message"},c,t.message),React.createElement("div",{className:n+"-description"},t.description),t.btn&&!t.footer?React.createElement("span",{className:n+"-btn"},t.btn):null),t.footer?React.createElement("div",{className:n+"-footer"},t.footer):null),duration:o,closable:!0,onClose:t.onClose,key:t.key,style:t.style||{},className:t.className})})}var api={open:notice,close:function(t){Object.keys(notificationInstance).forEach(function(e){return notificationInstance[e].removeNotice(t)})},config:setNotificationConfig,destroy:function(){Object.keys(notificationInstance).forEach(function(e){notificationInstance[e].destroy(),delete notificationInstance[e]})}};["success","info","warning","error"].forEach(function(t){api[t]=function(e){return api.open((0,_extends3.default)({},e,{type:t}))}}),api.warn=api.warning,exports.default=api,module.exports=exports.default;