"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Row", {
    enumerable: true,
    get: function() {
        return Row;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _components = require("@tarojs/components");
var _context = require("./context");
var _typings = require("../../utils/typings");
var classPrefix = 'nut-row';
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    type: '',
    justify: 'start',
    align: 'flex-start',
    wrap: 'nowrap',
    gutter: '0'
});
var Row = function Row(props) {
    var _$_object_spread = (0, _object_spread._)({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, children = _$_object_spread.children, type = _$_object_spread.type, justify = _$_object_spread.justify, align = _$_object_spread.align, wrap = _$_object_spread.wrap, gutter = _$_object_spread.gutter, onClick = _$_object_spread.onClick;
    var getClass = function getClass(prefix, type) {
        var classType = type ? "nut-row-".concat(prefix, "-").concat(type) : '';
        if (prefix) return classType;
        if (type) return "nut-row-".concat(type);
        return '';
    };
    var getClasses = function getClasses() {
        return (0, _classnames.default)(classPrefix, getClass('', type), getClass('justify', justify), getClass('align', align), getClass('flex', wrap));
    };
    var parentRow = {
        gutter: gutter
    };
    return /*#__PURE__*/ _react.default.createElement(_context.DataContext.Provider, {
        value: parentRow
    }, /*#__PURE__*/ _react.default.createElement(_components.View, {
        className: (0, _classnames.default)(getClasses(), className),
        style: style,
        onClick: function onClick1(e) {
            onClick === null || onClick === void 0 ? void 0 : onClick(e, 'row');
        }
    }, _react.default.Children.map(children, function(child, index) {
        var _child_type;
        // @ts-ignore
        return (child === null || child === void 0 ? void 0 : (_child_type = child.type) === null || _child_type === void 0 ? void 0 : _child_type.displayName) === 'NutCol' ? /*#__PURE__*/ _react.default.cloneElement(child, {
            isFirst: index === 0,
            isLast: index === _react.default.Children.count(children) - 1
        }) : child;
    })));
};
Row.displayName = 'NutRow';
