import R from 'ramda';
import React from 'react';

var rejectEmptyStrings = R.filter(R.test(/\S/));

export default function multilinedText(content) {
	var Component = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'p';
	var wrapText = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : R.identity;

	return R.pipe(R.concat([]), R.map(R.pipe(R.defaultTo(''), R.split('\n\n'), rejectEmptyStrings, R.map(function (text) {
		return React.createElement(Component, { children: wrapText(text) });
	}))))(content);
}