import _extends from 'babel-runtime/helpers/extends';

var _jsxFileName = 'src/msgbox/Msgbox.jsx',
    _this = this;

/**
 * msgbox.jsx
 *
 * @Author: Aubrey
 * @Date: 17/8/28 17:29
 */

import React from 'react';
// import classNames from 'classnames'
// import PropTypes from 'prop-types';
import Notification from './Notification';

var prefixCls = 'ne-msgbox';
var notification = void 0;
var getNotification = function getNotification() {
    if (!notification) {
        notification = Notification.reWrite();
    }
    return notification;
};

var notice = function notice(options) {
    console.log(options);
    var notificationInstance = getNotification();
    var title = options.title,
        msg = options.msg,
        yesBtn = options.yesBtn,
        noBtn = options.noBtn,
        yesCallback = options.yesCallback,
        noCallback = options.noCallback;

    var props = {};

    var content = React.createElement(
        'div',
        { className: prefixCls + '-box', __source: {
                fileName: _jsxFileName,
                lineNumber: 29
            },
            __self: _this
        },
        React.createElement(
            'div',
            { className: 'content', __source: {
                    fileName: _jsxFileName,
                    lineNumber: 30
                },
                __self: _this
            },
            title && React.createElement(
                'div',
                { className: 'title', __source: {
                        fileName: _jsxFileName,
                        lineNumber: 31
                    },
                    __self: _this
                },
                title
            ),
            msg && React.createElement(
                'div',
                { className: 'msg', __source: {
                        fileName: _jsxFileName,
                        lineNumber: 32
                    },
                    __self: _this
                },
                msg
            )
        ),
        React.createElement(
            'div',
            { className: 'btn-box', __source: {
                    fileName: _jsxFileName,
                    lineNumber: 34
                },
                __self: _this
            },
            noBtn && React.createElement(
                'div',
                { className: 'noBtn', __source: {
                        fileName: _jsxFileName,
                        lineNumber: 35
                    },
                    __self: _this
                },
                noBtn
            ),
            yesBtn && React.createElement(
                'div',
                { className: 'yesBtn', __source: {
                        fileName: _jsxFileName,
                        lineNumber: 36
                    },
                    __self: _this
                },
                yesBtn
            )
        )
    );
    props.content = content;
    props.yesCallback = yesCallback;
    props.noCallback = noCallback;
    props.hide = notification.destroy;
    notificationInstance.notice(_extends({
        prefixCls: prefixCls
    }, props));
};

export default {
    show: function show(options) {
        return notice(options);
    },
    hide: function hide() {
        if (notification) {
            notification.destroy();
            notification = null;
        }
    }
};