'use strict';

exports.__esModule = true;
exports.useWithFallback = undefined;

var _ramda = require('ramda');

var _ramda2 = _interopRequireDefault(_ramda);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactSeeds = require('react-seeds');

var _rgba = require('react-sow/rgba');

var _rgba2 = _interopRequireDefault(_rgba);

var _divider = require('./divider');

var _divider2 = _interopRequireDefault(_divider);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var tiles = function tiles(tags, mentions, content, children, renderElement, resolveContent) {
	return _react2.default.createElement(
		_reactSeeds.Seed,
		{
			row: true, wrap: true, reverse: _ramda2.default.has('reverse', tags), justifyContent: 'center',
			width: '100%'
		},
		// Render content, interleaving an optional divider
		_ramda2.default.pipe(_ramda2.default.converge(_ramda2.default.concat, [_ramda2.default.pipe(_ramda2.default.init, _ramda2.default.chain(_ramda2.default.pipe(renderElement, _ramda2.default.of, _ramda2.default.append((0, _divider2.default)(_ramda2.default.defaultTo(8, _ramda2.default.unless(_ramda2.default.isNil, resolveContent, tags['divider']))))))), _ramda2.default.pipe(_ramda2.default.last, _ramda2.default.ifElse(_ramda2.default.isNil, _ramda2.default.always([]), renderElement))]))(children)
	);
};

var useWithFallback = exports.useWithFallback = function useWithFallback(fallback) {
	return _ramda2.default.cond([[_ramda2.default.has('tiles'), _ramda2.default.curry(tiles)], [_ramda2.default.T, fallback]]);
};