/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
const require_index = require('../../../node_modules/classnames/index.js');
const require_settings = require('../../../settings.js');
const require_devtools = require('../../../global/js/utils/devtools.js');
const require_FilterPanelCheckbox = require('../FilterPanelCheckbox/FilterPanelCheckbox.js');
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");

//#region src/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.jsx
/**
* Copyright IBM Corp. 2024, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const blockClass = `${require_settings.pkg.prefix}--filter-panel-checkbox-with-overflow`;
const componentName = "FilterPanelCheckboxWithOverflow";
const defaults = { overflowMenuProps: {} };
/**
* Provides a filter panel checkbox with an overflow menu.
*
* This component's props refer to the Carbon Checkbox,
* just like FilterPanelCheckbox.
*
* Use `overflowMenuProps` for properties specific to the OverflowMenu.
* @deprecated This component is deprecated
*/
let FilterPanelCheckboxWithOverflow = react.default.forwardRef(({ children, className, count, id, labelText, overflowMenuProps = defaults.overflowMenuProps, title, ...rest }, ref) => {
	const [menuIsOpen, setMenuIsOpen] = (0, react.useState)(false);
	const [showMenuButton, setShowMenuButton] = (0, react.useState)(false);
	const { ...other } = overflowMenuProps;
	const backupRef = (0, react.useRef)(void 0);
	const localRef = ref || backupRef;
	const setHideButton = (activeElement) => {
		if (!menuIsOpen && !localRef.current.contains(activeElement)) setShowMenuButton(false);
	};
	(0, react.useEffect)(() => {
		setShowMenuButton(menuIsOpen);
	}, [menuIsOpen]);
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, import_classnames.default)(blockClass, className, { [`${blockClass}--open`]: menuIsOpen }),
		onBlur: ({ relatedTarget }) => setHideButton(relatedTarget),
		onFocus: () => setShowMenuButton(true),
		onMouseDown: (event) => event.preventDefault(),
		onMouseEnter: () => setShowMenuButton(true),
		onMouseLeave: () => setHideButton(document.activeElement),
		ref: localRef,
		...require_devtools.getDevtoolsProps(componentName)
	}, /* @__PURE__ */ react.default.createElement(require_FilterPanelCheckbox.FilterPanelCheckbox, {
		...rest,
		className: (0, import_classnames.default)(`${blockClass}__checkbox`),
		count,
		id,
		labelText,
		title
	}), showMenuButton && /* @__PURE__ */ react.default.createElement(_carbon_react.OverflowMenu, {
		open: overflowMenuProps?.open,
		className: (0, import_classnames.default)(`${blockClass}__overflow-button`, overflowMenuProps?.menuClass),
		menuOptionsClass: (0, import_classnames.default)(`${blockClass}__overflow-options`, overflowMenuProps?.menuOptionsClass),
		"aria-label": overflowMenuProps?.["aria-label"],
		iconDescription: overflowMenuProps?.["aria-label"],
		onOpen: () => setMenuIsOpen(true),
		onClose: () => setMenuIsOpen(false),
		flipped: overflowMenuProps?.flipped || true,
		selectorPrimaryFocus: overflowMenuProps?.selectorPrimaryFocus,
		...other
	}, children));
});
FilterPanelCheckboxWithOverflow.deprecated = {
	level: "warn",
	details: `This component is deprecated`
};
FilterPanelCheckboxWithOverflow = require_settings.pkg.checkComponentEnabled(FilterPanelCheckboxWithOverflow, componentName);
FilterPanelCheckboxWithOverflow.displayName = componentName;
FilterPanelCheckboxWithOverflow.propTypes = {
	children: prop_types.default.node.isRequired,
	className: prop_types.default.string,
	count: prop_types.default.oneOfType([prop_types.default.number, prop_types.default.string]),
	id: prop_types.default.string.isRequired,
	labelText: prop_types.default.node.isRequired,
	onChange: prop_types.default.func,
	overflowMenuProps: prop_types.default.shape({
		["aria-label"]: prop_types.default.string,
		flipped: prop_types.default.bool,
		menuClass: prop_types.default.string,
		menuOptionsClass: prop_types.default.string,
		open: prop_types.default.bool,
		selectorPrimaryFocus: prop_types.default.string
	}),
	title: prop_types.default.string
};

//#endregion
Object.defineProperty(exports, 'FilterPanelCheckboxWithOverflow', {
  enumerable: true,
  get: function () {
    return FilterPanelCheckboxWithOverflow;
  }
});