"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var prop_types_1 = require("prop-types");
var React = require("react");
var recompose_1 = require("recompose");
var styled_components_1 = require("styled-components");
var styled_system_1 = require("styled-system");
var tag_hoc_1 = require("tag-hoc");
var blacklist_1 = require("./blacklist");
var theme_1 = require("./theme");
var tooltips_1 = require("./tooltips");
var tooltip = new tooltips_1.Tooltips();
var prop = prop_types_1.oneOfType([prop_types_1.number, prop_types_1.string, prop_types_1.arrayOf(prop_types_1.oneOfType([prop_types_1.number, prop_types_1.string]))]);
var propTypes = {
    width: prop,
    w: prop,
    fontSize: prop,
    f: prop,
    color: prop,
    bg: prop,
    m: prop,
    mt: prop,
    mr: prop,
    mb: prop,
    ml: prop,
    mx: prop,
    my: prop,
    p: prop,
    pt: prop,
    pr: prop,
    pb: prop,
    pl: prop,
    px: prop,
    py: prop,
};
var withTooltip = function (Base) {
    return function (_a) {
        var props = __rest(_a, []);
        if (props.tooltip) {
            props = tooltip.bindProps(props);
        }
        delete props.tooltip;
        return React.createElement(Base, __assign({}, props));
    };
};
exports.withStyledSystem = function (child) {
    var Base = styled_components_1.default(child)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t\t", " ", " ", " ", ";\n\t"], ["\n\t\t", " ", " ", " ", ";\n\t"])), styled_system_1.space, styled_system_1.width, styled_system_1.fontSize, styled_system_1.color);
    Base.displayName = recompose_1.getDisplayName(child);
    Base.propTypes = propTypes;
    return function (props) {
        return React.createElement(Base, __assign({}, props));
    };
};
exports.withDefaultTheme = function (Base) {
    if (!Base.defaultProps) {
        Base.defaultProps = {};
    }
    Base.defaultProps.theme = theme_1.default;
    return function (props) {
        return React.createElement(Base, __assign({}, props));
    };
};
var Tag = tag_hoc_1.default(blacklist_1.default);
exports.default = recompose_1.compose(exports.withDefaultTheme, withTooltip, exports.withStyledSystem, Tag);
var templateObject_1;
