"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get applySpacing () {
        return applySpacing;
    },
    get spacing () {
        return spacing;
    },
    get spacingFns () {
        return spacingFns;
    }
});
function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
var baseSpacing = {
    0: '0',
    2: '0.125rem',
    4: '0.25rem',
    8: '0.5rem',
    10: '0.625rem',
    12: '0.75rem',
    16: '1rem',
    18: '1.125rem',
    20: '1.25rem',
    24: '1.5rem',
    32: '2rem'
};
var spacing = _object_spread_props(_object_spread({}, baseSpacing), {
    '0x': baseSpacing[0],
    '1x': baseSpacing[2],
    '2x': baseSpacing[4],
    '4x': baseSpacing[8],
    '5x': baseSpacing[10],
    '6x': baseSpacing[12],
    '8x': baseSpacing[16],
    '9x': baseSpacing[18],
    '10x': baseSpacing[20],
    '12x': baseSpacing[24],
    '16x': baseSpacing[32]
});
var createSpacingFn = function createSpacingFn(params) {
    return function(value) {
        return params.reduce(function(acc, cur) {
            return _object_spread_props(_object_spread({}, acc), _define_property({}, cur, spacing[value]));
        }, {});
    };
};
var m = createSpacingFn([
    'margin'
]);
var mt = createSpacingFn([
    'marginTop'
]);
var mr = createSpacingFn([
    'marginRight'
]);
var ml = createSpacingFn([
    'marginLeft'
]);
var mb = createSpacingFn([
    'marginBottom'
]);
var mx = createSpacingFn([
    'marginLeft',
    'marginRight'
]);
var my = createSpacingFn([
    'marginTop',
    'marginBottom'
]);
var p = createSpacingFn([
    'padding'
]);
var pt = createSpacingFn([
    'paddingTop'
]);
var pr = createSpacingFn([
    'paddingRight'
]);
var pl = createSpacingFn([
    'paddingLeft'
]);
var pb = createSpacingFn([
    'paddingBottom'
]);
var px = createSpacingFn([
    'paddingLeft',
    'paddingRight'
]);
var py = createSpacingFn([
    'paddingTop',
    'paddingBottom'
]);
var spacingFns = {
    m: m,
    mt: mt,
    mr: mr,
    ml: ml,
    mb: mb,
    mx: mx,
    my: my,
    p: p,
    pt: pt,
    pr: pr,
    pl: pl,
    pb: pb,
    px: px,
    py: py
};
var spacingFnsList = Object.entries(spacingFns);
var applySpacing = function applySpacing(props) {
    return spacingFnsList.reduce(function(styles, param) {
        var _param = _sliced_to_array(param, 2), fnName = _param[0], fn = _param[1];
        if (fnName in props) {
            return _object_spread({}, styles, fn(props[fnName]));
        }
        return styles;
    }, {});
};
