/* @oracle/oraclejet-preact: undefined */
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var jsxRuntime = require('preact/jsx-runtime');
var hooks = require('preact/hooks');
require('./FormContext-d1d05967.js');
var useFormContext = require('./useFormContext-a794f7b6.js');
require('./FormFieldContext-69fe83d2.js');
var useFormFieldContext = require('./useFormFieldContext-4632eb73.js');
var CheckboxSet = require('./CheckboxSet-6865f4fd.js');
var CheckboxControl = require('./CheckboxControl-d37c7764.js');
require('preact');
require('preact/compat');
require('./useFormFieldContextProps-0fa67f6c.js');

require('./useId-6c0eeb27.js');
require('./Flex-3a257bc3.js');
require('./useTestId-4f53d561.js');
require('./LayerHost-3cd73603.js');
require('./index-0aa99b92.js');
require('./UNSAFE_Layer/themes/LayerHostStyles.css.js');

require('./classNames-c14c6ef3.js');
require('./boxalignment-e287d370.js');
require('./size-1914356b.js');
require('./utils-c0efcd5e.js');
require('./themeContract.css-f3d431c6.js');
require('./colorUtils-01f3caa2.js');
require('./_curry1-e8f0d7ea.js');
require('./arrayUtils-7d8dcfc3.js');

require('./vanilla-extract-sprinkles-createRuntimeSprinkles.esm-d68f3e0f.js');
require('./dimensions-6101ca1f.js');
require('./flexbox-2cae9a01.js');

require('./flexitem-fee13e26.js');

require('./mergeInterpolations-6727b536.js');
require('./mergeDeepWithKey-210b024d.js');
require('./_curry3-18677bca.js');
require('./_curry2-c15d89cd.js');
require('./_isObject-28636267.js');

require('./CheckboxRadioField-24e06523.js');
require('./useCollectionFocusRing-bed0aa16.js');
require('./collectionUtils-f1d3183f.js');
require('./keys-25710458.js');
require('./clientHints-c40c5250.js');
require('./Selector-6550b8e0.js');
require('./BaseSelector-2dc69917.js');
require('./useActive-6770f917.js');
require('./useToggle-3ebba7d8.js');
require('./useFocus-1b288fb9.js');
require('./useHover-49b0430d.js');
require('./mergeProps-e3da7237.js');
require('./StyledCheckbox-9047ed7d.js');
require('./Check-1272bb86.js');
require('./Icon-56789beb.js');
require('./useTooltip-34accecc.js');
require('./useTooltipControlled-0a95856c.js');
require('./useTouch-4dec8729.js');
require('./useAnimation-65c0e455.js');
require('./useComponentTheme-082fc8e4.js');
require('./logger-2b636482.js');
require('./useThemeInterpolations-a37b37d9.js');
require('./useColorScheme-f8b1447d.js');
require('./useScale-db16c2b8.js');
require('./theme-dfd6a9fe.js');
require('./Theme-f06687af.js');
require('./useDensity-0b9fd9ca.js');
require('./unsafeDomAccess-c3a492f0.js');
require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentTheme.js');
require('./hooks/UNSAFE_useTooltip/themes/TooltipContentStyles.css.js');

require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.css.js');

require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');

require('./vanilla-extract-recipes-createRuntimeFn.esm-d1301b2d.js');
require('./tooltipUtils-2bc15136.js');
require('./EnvironmentProvider-5f2435e6.js');
require('./LayerManager-c535d963.js');
require('./Floating-79cbe5ad.js');
require('./useFloating-c753a7f9.js');
require('./useUser-1295b5cb.js');
require('./positionUtils-a780137e.js');
require('./refUtils-a9872e75.js');
require('./useOutsideClick-dbf3d604.js');
require('./Layer-b60deb1b.js');
require('./UNSAFE_Layer/themes/LayerStyles.css.js');

require('./useModal-0739a528.js');
require('./UNSAFE_Floating/themes/redwood/FloatingTheme.js');
require('./UNSAFE_Floating/themes/FloatingStyles.css.js');

require('./UNSAFE_Floating/themes/redwood/FloatingBaseTheme.css.js');

require('./UNSAFE_Floating/themes/redwood/FloatingVariants.css.js');
require('./vanilla-extract-dynamic.esm-2e1b7c25.js');
require('./UNSAFE_Floating/themes/FloatingContract.css.js');
require('./useUnsafeDomElementRef-f22a2f0c.js');
require('./UNSAFE_Icon/themes/IconStyle.css.js');

require('./CheckboxOff-a3ed334d.js');
require('./CheckboxOn-b5dda28b.js');
require('./CheckboxMixed-a17c8298.js');
require('./HiddenAccessible-087eb49a.js');

require('./UNSAFE_Checkbox/themes/CheckboxIconContract.css.js');
require('./UNSAFE_Checkbox/themes/redwood/CheckboxIconTheme.js');
require('./UNSAFE_Checkbox/themes/CheckboxIconStyles.css.js');

require('./UNSAFE_Checkbox/themes/redwood/CheckboxIconBaseTheme.css.js');

require('./UNSAFE_Checkbox/themes/redwood/CheckboxIconVariants.css.js');

require('./TabbableModeContext-e99d527e.js');
require('./useTabbableMode-dbd254e8.js');

require('./PRIVATE_BaseSelector/themes/SelectorStyles.css.js');

require('./CollectionInteractionContext-f84ff7a1.js');
require('./useCollectionInteractionContext-6fc0200e.js');
require('./useTranslationBundle-12dd087d.js');
require('./Label-eb654b0e.js');


require('./UNSAFE_UserAssistance/themes/redwood/UserAssistanceVariants.css.js');


require('./UNSAFE_MessageBanner/themes/redwood/MessageBannerVariants.css.js');

require('./IconButton-7503293b.js');
require('./BaseButton-d8f96bfa.js');
require('./UNSAFE_BaseButton/themes/redwood/BaseButtonTheme.js');
require('./UNSAFE_BaseButton/themes/BaseButtonStyles.css.js');

require('./UNSAFE_BaseButton/themes/redwood/BaseButtonVariants.css.js');

require('./BareButton-e8a030d7.js');
require('./useBareButton-463210c9.js');
require('./usePress-886180e4.js');
require('./usePressClick-7a34624a.js');
require('./buttonUtils-dff2ea3e.js');
require('./id-86356250.js');
require('./ButtonLabelLayout-c876923f.js');
require('./Text-056f1ec5.js');
require('./UNSAFE_Text/themes/TextStyles.css.js');

require('./useButtonLabelLayoutTheme-d09db0c9.js');
require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutTheme.js');
require('./UNSAFE_ButtonLabelLayout/themes/ButtonLabelLayoutStyles.css.js');

require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutBaseTheme.css.js');

require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutVariants.css.js');


require('./MessageFormattingUtils-539d75b0.js');
require('./getLocale-8e17dc46.js');
require('./stringUtils-3e19c8af.js');
require('./TransitionGroup-b239d98f.js');
require('./MessagesContext-4e939750.js');


require('./UNSAFE_ComponentMessage/themes/redwood/ComponentMessageVariants.css.js');
require('./InputGroupContext-05f2a46f.js');
require('./Popup-de16d915.js');
require('./tabbableUtils-22a50472.js');
require('./head-68d0992f.js');
require('./_arity-c228159c.js');
require('./_isArray-73160ad5.js');
require('./_isString-f4443c9e.js');
require('./FocusTrap-4873a3f2.js');
require('./FocusTracker-e2ea43c3.js');
require('./PRIVATE_FocusTracker/themes/FocusTrackerStyles.css.js');

require('./Modal-b751b643.js');
require('./UNSAFE_Modal/themes/ModalStyles.css.js');

require('./popupUtils-1d123cbe.js');
require('./WindowOverlay-85d999fa.js');
require('./UNSAFE_WindowOverlay/themes/WindowOverlayStyles.css.js');

require('./UNSAFE_WindowOverlay/themes/WindowOverlayContract.css.js');
require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayTheme.js');
require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.css.js');

require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayVariants.css.js');
require('./usePopupAnimation-f3b34413.js');
require('./useAnimationStatus-8075dc19.js');
require('./popupAnimationUtils-dcace427.js');
require('./LiveRegion-62ce9ac7.js');

require('./UNSAFE_Popup/themes/PopupContract.css.js');
require('./UNSAFE_Popup/themes/redwood/PopupTheme.js');
require('./UNSAFE_Popup/themes/redwood/PopupBaseTheme.css.js');

require('./UNSAFE_Popup/themes/redwood/PopupVariants.css.js');

require('./colors-f3ce979a.js');
require('./UNSAFE_Separator/themes/SeparatorStyles.css.js');

require('./CompactLabelAssistance-e910bb56.js');
require('./Help-dbc23ccd.js');
require('./useFocusWithin-eb7f956a.js');
require('./UNSAFE_UserAssistance/themes/UserAssistanceStyles.css.js');
require('./UNSAFE_Label/themes/redwood/LabelTheme.js');
require('./UNSAFE_Label/themes/LabelStyles.css.js');

require('./UNSAFE_Label/themes/redwood/LabelBaseTheme.css.js');

require('./UNSAFE_Label/themes/redwood/LabelVariants.css.js');
require('./truncationUtils-2d44b04b.js');
require('./UNSAFE_TextField/themes/redwood/TextFieldTheme.js');
require('./UNSAFE_TextField/themes/TextFieldStyles.css.js');



require('./UNSAFE_TextField/themes/redwood/TextFieldBaseTheme.css.js');

require('./UNSAFE_TextField/themes/redwood/TextFieldVariants.css.js');

require('./InlineHelp-2add2d34.js');
require('./UNSAFE_UserAssistance/themes/redwood/UserAssistanceTheme.js');
require('./UNSAFE_UserAssistance/themes/redwood/UserAssistanceBaseTheme.css.js');
require('./InlineUserAssistance-cfaa3d3e.js');
require('./ComponentMessageContainer-b692adf3.js');
require('./MessagesManager-cba4bc60.js');
require('./SuccessS-b6757c64.js');
require('./ErrorS-b027f7ad.js');
require('./InformationS-b0bb102b.js');
require('./WarningS-cdb0a7ad.js');
require('./PRIVATE_Message/themes/MessageStyles.css.js');
require('./soundUtils-ff3c9c0d.js');
require('./useMessagesContext-23d62331.js');
require('./Transition-942950ed.js');
require('./UNSAFE_ComponentMessage/themes/redwood/ComponentMessageTheme.js');
require('./UNSAFE_ComponentMessage/themes/ComponentMessageStyles.css.js');
require('./UNSAFE_ComponentMessage/themes/redwood/ComponentMessageBaseTheme.css.js');
require('./useInputGroupContext-4c10bd57.js');
require('./CheckboxRadioFieldStyles.css-b526d45d.js');
require('./useMessageSeverity-cfc4ae9d.js');

require('./CheckboxRadioContext-3b134bd1.js');
require('./LayoutStyles.css-b4025421.js');

require('./CheckboxRadioLabelValueLayout-0ed43779.js');
require('./UNSAFE_RadioItem/themes/redwood/RadioTheme.js');
require('./UNSAFE_RadioItem/themes/RadioStyles.css.js');

require('./UNSAFE_RadioItem/themes/redwood/RadioBaseTheme.css.js');

require('./UNSAFE_RadioItem/themes/redwood/RadioVariants.css.js');

require('./UNSAFE_TextField/themes/redwood/FormLayoutTheme.js');
require('./UNSAFE_TextField/themes/FormLayoutStyles.css.js');
require('./UNSAFE_TextField/themes/redwood/FormLayoutBaseTheme.css.js');

require('./UNSAFE_Checkbox/themes/redwood/CheckboxTheme.js');
require('./UNSAFE_Checkbox/themes/CheckboxStyles.css.js');


require('./UNSAFE_Checkbox/themes/redwood/CheckboxBaseTheme.css.js');

require('./UNSAFE_Checkbox/themes/redwood/CheckboxVariants.css.js');

require('./StyledLabelValueLayout-48da61b9.js');


require('./formControlUtils-31d8bc55.js');
require('./IconUserAssistance-89913ad1.js');

/**
 * CheckboxItem is a child component of CheckboxSet. It contains the checkbox, label, and assistive text.
 */
const CheckboxItem = ({ children, value, assistiveText, helpSourceLink, helpSourceText }) => {
    const { isReadonly: isFormReadonly, isDisabled: isFormDisabled } = useFormContext.useFormContext();
    const { isDisabled: isFieldDisabled, isReadonly: isFieldReadonly } = useFormFieldContext.useFormFieldContext();
    const { name, onCommit, value: groupValue } = CheckboxSet.useCheckboxSetContext();
    const isChecked = groupValue?.has(value);
    const isDisabled = isFieldDisabled ?? isFormDisabled;
    const isReadonly = isFieldReadonly ?? isFormReadonly;
    const onChangeHandler = hooks.useCallback((e) => {
        // return early on keyup if key isn't spacebar
        const { key } = e;
        if (key !== undefined && key !== ' ') {
            return;
        }
        // create a new set from the previous and add or remove the changed value
        const newGroupValue = new Set(groupValue);
        if (newGroupValue.has(value)) {
            newGroupValue.delete(value);
        }
        else {
            newGroupValue.add(value);
        }
        onCommit?.({
            previousValue: groupValue,
            value: newGroupValue.size > 0 ? newGroupValue : undefined
        });
    }, [groupValue, onCommit, value]);
    return (jsxRuntime.jsx(CheckboxControl.CheckboxControl, { name: name, value: value, ...(!isReadonly && !isDisabled
            ? { onChange: onChangeHandler, onKeyUp: onChangeHandler }
            : {}), assistiveText: assistiveText, helpSourceLink: helpSourceLink, helpSourceText: helpSourceText, isChecked: isChecked, isDisabled: isDisabled, isReadonly: isReadonly, children: children }));
};

exports.CheckboxItem = CheckboxItem;
//# sourceMappingURL=UNSAFE_CheckboxItem.js.map
