'use strict';

exports.__esModule = true;
exports.title = exports.Preview = exports.button = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.head = head;

var _ramda = require('ramda');

var _ramda2 = _interopRequireDefault(_ramda);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _reactSeeds2 = _interopRequireDefault(_reactSeeds);

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

var _rgba2 = _interopRequireDefault(_rgba);

var _assets = require('./assets');

var assets = _interopRequireWildcard(_assets);

var _Vanilla = require('./Vanilla');

var Vanilla = _interopRequireWildcard(_Vanilla);

var _render = require('./render');

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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

var buttonTagsToClass = _ramda2.default.converge(_ramda2.default.unapply(_ramda2.default.join(' ')), [_ramda2.default.always('mui-btn'), _ramda2.default.ifElse(_ramda2.default.pathEq(['variation', 'texts'], ['raised']), _ramda2.default.always('mui-btn--raised'), _ramda2.default.always('')), _ramda2.default.ifElse(_ramda2.default.pathEq(['variation', 'texts'], ['flat']), _ramda2.default.always('mui-btn--flat'), _ramda2.default.always('')), _ramda2.default.cond([[_ramda2.default.has('primary'), _ramda2.default.always('mui-btn--primary')],
//[ R.has('secondary'), R.always('mui-btn--flat') ],
[_ramda2.default.T, _ramda2.default.always('')]]), _ramda2.default.cond([[_ramda2.default.has('large'), _ramda2.default.always('mui-btn--large')], [_ramda2.default.has('small'), _ramda2.default.always('mui-btn--small')], [_ramda2.default.has('extrasmall'), _ramda2.default.always('mui-btn--small')], [_ramda2.default.T, _ramda2.default.always('')]])]);

var button = exports.button = function button(tags, mentions, texts) {
	return _react2.default.createElement('button', _extends({}, (0, _reactSeeds2.default)({ alignSelf: 'center', margin: { bottom: '0.5rem' }, maxWidth: '20em' }), {
		disabled: _ramda2.default.has('disabled', tags),
		className: buttonTagsToClass(tags),
		children: texts
	}));
};

var elementRendererForTags = Vanilla.extendTagConds([[_ramda2.default.has('field'), _ramda2.default.curry(Vanilla.makeField({ wrapperClassName: 'mui-textfield', wrapInDiv: true }))], [_ramda2.default.has('choice'), _ramda2.default.curry(Vanilla.makeChoice({ wrapperClassName: { select: 'mui-select', checkbox: 'mui-checkbox', radio: 'mui-radio' }, wrapInDiv: true }))], [_ramda2.default.has('button'), _ramda2.default.curry(button)], [_ramda2.default.has('cta'), _ramda2.default.curry(button)]]);

var Preview = exports.Preview = (0, _render.renderTreeUsing)({ elementRendererForTags: elementRendererForTags });

var title = exports.title = 'MuiCSS';

function head() {
	return [_react2.default.createElement('link', { href: '//cdn.muicss.com/mui-0.9.9-rc2/css/mui.min.css', rel: 'stylesheet', type: 'text/css' }), _react2.default.createElement('script', { src: '//cdn.muicss.com/mui-0.9.9-rc2/js/mui.min.js' })];
}