"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Space", {
    enumerable: true,
    get: function() {
        return Space;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _components = require("@tarojs/components");
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _index = require("../configprovider/index");
var prefixCls = 'nut-space';
var defaultProps = {
    direction: 'horizontal'
};
var Space = function Space(props) {
    var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, children = _$_object_spread.children, wrap = _$_object_spread.wrap, align = _$_object_spread.align, direction = _$_object_spread.direction, justify = _$_object_spread.justify;
    var rtl = (0, _index.useRtl)();
    var _obj;
    var cls = (0, _classnames.default)(prefixCls, (_obj = {}, (0, _define_property._)(_obj, "".concat(prefixCls, "-").concat(direction), direction), (0, _define_property._)(_obj, "".concat(prefixCls, "-").concat(direction, "-wrap"), wrap), (0, _define_property._)(_obj, "".concat(prefixCls, "-align-").concat(align), align), (0, _define_property._)(_obj, "".concat(prefixCls, "-justify-").concat(justify), justify), (0, _define_property._)(_obj, "".concat(className), className), _obj));
    var _obj1;
    var itemCls = (0, _classnames.default)("".concat(prefixCls, "-item"), (_obj1 = {}, (0, _define_property._)(_obj1, "".concat(prefixCls, "-").concat(direction, "-item"), direction), (0, _define_property._)(_obj1, "".concat(prefixCls, "-").concat(direction, "-wrap-item"), wrap), (0, _define_property._)(_obj1, "".concat(prefixCls, "-item-rtl"), rtl), _obj1));
    var childrenCount = _react.default.Children.count(children);
    return /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: cls,
        style: style
    }, _react.default.Children.map(children, function(child, idx) {
        var isLast = idx === childrenCount - 1;
        return child !== null && child !== undefined && /*#__PURE__*/ _react.default.createElement(_components.View, {
            className: (0, _classnames.default)(itemCls, isLast && "".concat(prefixCls, "-").concat(direction, "-item-last"))
        }, child);
    }));
};
Space.displayName = 'NutSpace';
