"use strict";
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const styles_lib_components_Box_Box_cjs = require("../../Box/Box.cjs");
const styles_lib_components_MonthPicker_MonthPicker_cjs = require("../../MonthPicker/MonthPicker.cjs");
const styles_lib_components_Accordion_AccordionItem_cjs = require("../../Accordion/AccordionItem.cjs");
const styles_lib_components_private_touchable_virtualTouchable_cjs = require("../touchable/virtualTouchable.cjs");
const styles_lib_components_private_InlineField_StyledInput_cjs = require("./StyledInput.cjs");
const styles_lib_components_private_InlineField_InlineField_css_cjs = require("./InlineField.css.cjs");
const InlineField = React.forwardRef(
  ({
    id,
    name,
    value,
    checked,
    data,
    onChange,
    label,
    type,
    children,
    description,
    badge,
    message,
    reserveMessageSpace = false,
    tone = "neutral",
    disabled = false,
    required,
    inList = false,
    tabIndex,
    size = "standard",
    "aria-describedby": ariaDescribedBy,
    ...restProps
  }, forwardedRef) => {
    const messageId = `${id}-message`;
    const descriptionId = `${id}-description`;
    const hasMessage = message || reserveMessageSpace;
    if (process.env.NODE_ENV !== "production") {
      if (badge && badge.props.bleedY !== void 0) {
        console.warn(
          `Badge elements cannot set the \`bleedY\` prop when passed to a ${type.charAt(0).toUpperCase()}${type.slice(1)} component`
        );
      }
    }
    return /* @__PURE__ */ jsxRuntime.jsxs(styles_lib_components_Box_Box_cjs.Box, { position: "relative", children: [
      /* @__PURE__ */ jsxRuntime.jsxs(styles_lib_components_Box_Box_cjs.Box, { display: "flex", children: [
        /* @__PURE__ */ jsxRuntime.jsx(
          styles_lib_components_private_InlineField_StyledInput_cjs.StyledInput,
          {
            ...restProps,
            type,
            id,
            checked,
            name,
            value,
            data,
            onChange,
            disabled,
            tone,
            tabIndex,
            required,
            "aria-describedby": styles_lib_components_MonthPicker_MonthPicker_cjs.mergeIds(
              ariaDescribedBy,
              message ? messageId : void 0,
              description ? descriptionId : void 0
            ),
            size,
            ref: forwardedRef
          }
        ),
        /* @__PURE__ */ jsxRuntime.jsxs(styles_lib_components_Box_Box_cjs.Box, { paddingLeft: "small", flexGrow: 1, children: [
          /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Box_Box_cjs.Box, { className: [styles_lib_components_private_InlineField_InlineField_css_cjs.sizeVars[size], styles_lib_components_private_InlineField_InlineField_css_cjs.labelOffset], children: /* @__PURE__ */ jsxRuntime.jsxs(styles_lib_components_Accordion_AccordionItem_cjs.Inline, { space: "small", alignY: "center", children: [
            /* @__PURE__ */ jsxRuntime.jsx(
              styles_lib_components_Box_Box_cjs.Box,
              {
                component: "label",
                htmlFor: id,
                userSelect: "none",
                display: "block",
                cursor: !disabled ? "pointer" : void 0,
                className: styles_lib_components_private_touchable_virtualTouchable_cjs.virtualTouchable(),
                children: /* @__PURE__ */ jsxRuntime.jsx(
                  styles_lib_components_Accordion_AccordionItem_cjs.Text,
                  {
                    weight: checked && !inList ? "strong" : void 0,
                    tone: disabled ? "secondary" : void 0,
                    size,
                    children: label
                  }
                )
              }
            ),
            badge ? React.cloneElement(badge, { bleedY: true }) : null
          ] }) }),
          description ? /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Box_Box_cjs.Box, { paddingTop: "small", children: /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Accordion_AccordionItem_cjs.Text, { tone: "secondary", size, id: descriptionId, children: description }) }) : null,
          children ? /* @__PURE__ */ jsxRuntime.jsx(
            styles_lib_components_Box_Box_cjs.Box,
            {
              position: "relative",
              display: "none",
              paddingTop: "small",
              className: styles_lib_components_private_InlineField_InlineField_css_cjs.children,
              children
            }
          ) : null
        ] })
      ] }),
      hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Box_Box_cjs.Box, { paddingTop: description ? "small" : "xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(
        styles_lib_components_MonthPicker_MonthPicker_cjs.FieldMessage,
        {
          id: messageId,
          tone,
          disabled,
          message,
          reserveMessageSpace
        }
      ) }) : null
    ] });
  }
);
exports.InlineField = InlineField;
