'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../../../_virtual/_tslib.js');
var constants = require('../constants.js');
var makeMessageId = require('./makeMessageId.js');

const generateMessageFromVariant = (dispatch, providerOptions, methodVariant) => {
    return (message, messageOptions) => {
        const messageOptionsFromProvider = _tslib.__rest(providerOptions, ["position"]);
        const defaultMessageOption = Object.assign({ variant: methodVariant || constants.TOAST_VARIANT_DEFAULT }, messageOptionsFromProvider);
        const id = makeMessageId.makeMessageId();
        dispatch({
            type: 'add',
            message: Object.assign(Object.assign({ id: id, message: message, onClose: () => dispatch({ type: 'remove', messageId: id }) }, defaultMessageOption), messageOptions),
        });
    };
};
const createMessageMethods = (dispatch, providerOptions) => {
    return {
        clear: () => dispatch({ type: 'clear' }),
        custom: generateMessageFromVariant(dispatch, providerOptions),
        error: generateMessageFromVariant(dispatch, providerOptions, 'error'),
        info: generateMessageFromVariant(dispatch, providerOptions, 'info'),
        success: generateMessageFromVariant(dispatch, providerOptions, 'positive'),
        warning: generateMessageFromVariant(dispatch, providerOptions, 'warning'),
    };
};

exports.createMessageMethods = createMessageMethods;
