/**
 * 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.
 */

import { __toESM } from "../../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../../node_modules/classnames/index.js";
import { pkg } from "../../../settings.js";
import { getDevtoolsProps } from "../../../global/js/utils/devtools.js";
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import { Search } from "@carbon/react";

//#region src/components/FilterPanel/FilterPanelSearch/FilterPanelSearch.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__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--filter-panel-search`;
const componentName = "FilterPanelSearch";
const defaults = { searchProps: {} };
/**
* An input field and container to show search results.
* @deprecated This component is deprecated
*/
let FilterPanelSearch = React.forwardRef(({ children, className, searchProps = defaults.searchProps, ...rest }, ref) => {
	const [resultsVisible, setResultsVisible] = useState(false);
	let timer;
	const hideResults = () => {
		clearTimeout(timer);
		timer = setTimeout(() => {
			setResultsVisible(false);
		}, 300);
	};
	const showResults = () => {
		clearTimeout(timer);
		setResultsVisible(true);
	};
	useEffect(() => {
		return clearTimeout(timer);
	}, [timer]);
	return /* @__PURE__ */ React.createElement("div", {
		...rest,
		className: (0, import_classnames.default)(blockClass, `${blockClass}__container`, className),
		onBlur: hideResults,
		onFocus: showResults,
		ref,
		...getDevtoolsProps(componentName)
	}, /* @__PURE__ */ React.createElement(Search, {
		className: `${blockClass}__input`,
		...searchProps
	}), resultsVisible && !!children && /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__results` }, children));
});
FilterPanelSearch.deprecated = {
	level: "warn",
	details: `This component is deprecated`
};
FilterPanelSearch = pkg.checkComponentEnabled(FilterPanelSearch, componentName);
FilterPanelSearch.displayName = componentName;
FilterPanelSearch.propTypes = {
	children: PropTypes.node,
	className: PropTypes.string,
	searchProps: PropTypes.shape({ labelText: PropTypes.string.isRequired }).isRequired
};

//#endregion
export { FilterPanelSearch };