import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_icons__ from "@chakra-ui/icons";
function FormField({ children, label, tooltip, description, footerDescription, isInvalid, helpText, errorText, _label, _help, _error, isRequired, showRequiredIndicator = true, ...props }) {
    // @ts-ignore
    const isSwitch = children?.type?.render?.displayName === 'Switch';
    const descriptionComponent = description ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Box, {
        fontSize: "sm",
        mb: "2",
        mt: "-1"
    }, description) : null;
    const footerDescriptionComponent = footerDescription ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Box, {
        fontSize: "sm",
        mb: "-1",
        mt: "3"
    }, footerDescription) : null;
    return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.FormControl, {
        isInvalid: isInvalid,
        isRequired: !!showRequiredIndicator && isRequired,
        "aria-required": isRequired,
        ...props
    }, isSwitch ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Stack, {
        spacing: 1
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Flex, {
        alignItems: "center",
        gap: 3
    }, children, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.HStack, null, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.FormLabel, {
        ..._label,
        mb: 0.25,
        mr: 0
    }, label), tooltip ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tooltip, {
        label: tooltip
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_icons__.QuestionOutlineIcon, {
        boxSize: "3"
    })) : null)), descriptionComponent) : /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE_react__["default"].Fragment, null, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Stack, {
        spacing: 1
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.HStack, null, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.FormLabel, {
        ..._label,
        mb: 0.25,
        mr: 0
    }, label), tooltip ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tooltip, {
        label: tooltip
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_icons__.QuestionOutlineIcon, {
        boxSize: "3"
    })) : null), descriptionComponent, children, footerDescriptionComponent)), isInvalid ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.FormErrorMessage, _error, errorText || "Field has an error") : helpText ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.FormHelperText, _help, helpText) : null);
}
/* ESM default export */ const FormField_rslib_entry_ = FormField;
export { FormField_rslib_entry_ as default };
