import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
import React from "react";
import classNames from "classnames";
import { View } from "@tarojs/components";
import { ComponentDefaults } from "../../utils/typings";
import CellGroupContext from "./context";
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
    title: '',
    description: '',
    divider: true
});
var classPrefix = 'nut-cell-group';
export var CellGroup = function(props) {
    var _ref = _object_spread({}, defaultProps, props), children = _ref.children, className = _ref.className, title = _ref.title, description = _ref.description, divider = _ref.divider, rest = _object_without_properties(_ref, [
        "children",
        "className",
        "title",
        "description",
        "divider"
    ]);
    return /*#__PURE__*/ React.createElement(View, _object_spread({
        className: classNames(classPrefix, className)
    }, rest), title ? /*#__PURE__*/ React.createElement(View, {
        className: "".concat(classPrefix, "-title")
    }, title) : null, description ? /*#__PURE__*/ React.createElement(View, {
        className: "".concat(classPrefix, "-description")
    }, description) : null, /*#__PURE__*/ React.createElement(View, {
        className: "".concat(classPrefix, "-wrap")
    }, /*#__PURE__*/ React.createElement(CellGroupContext.Provider, {
        value: {
            divider: divider,
            group: true
        }
    }, React.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) === 'NutCell' ? /*#__PURE__*/ React.cloneElement(child, {
            isLast: index === React.Children.count(children) - 1
        }) : child;
    }))));
};
CellGroup.displayName = 'NutCellGroup';
