"use client";
import { getSingleElementChild } from "../../../core/utils/get-single-element-child/get-single-element-child.mjs";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { factory } from "../../../core/factory/factory.mjs";
import { Popover } from "../../Popover/Popover.mjs";
import { useComboboxContext } from "../Combobox.context.mjs";
import { useComboboxTargetProps } from "../use-combobox-target-props/use-combobox-target-props.mjs";
import { cloneElement } from "react";
import { useMergedRef } from "@mantine/hooks";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Combobox/ComboboxTarget/ComboboxTarget.tsx
const defaultProps = {
	refProp: "ref",
	targetType: "input",
	withKeyboardNavigation: true,
	withAriaAttributes: true,
	withExpandedAttribute: false,
	autoComplete: "off"
};
const ComboboxTarget = factory((props) => {
	const { children, refProp, withKeyboardNavigation, withAriaAttributes, withExpandedAttribute, targetType, autoComplete, ref, ...others } = useProps("ComboboxTarget", defaultProps, props);
	const child = getSingleElementChild(children);
	if (!child) throw new Error("Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");
	const ctx = useComboboxContext();
	const clonedElement = cloneElement(child, {
		...useComboboxTargetProps({
			targetType,
			withAriaAttributes,
			withKeyboardNavigation,
			withExpandedAttribute,
			onKeyDown: child.props.onKeyDown,
			onClick: child.props.onClick,
			autoComplete
		}),
		...others
	});
	return /* @__PURE__ */ jsx(Popover.Target, {
		refProp,
		ref: useMergedRef(ref, ctx.store.targetRef),
		children: clonedElement
	});
});
ComboboxTarget.displayName = "@mantine/core/ComboboxTarget";
//#endregion
export { ComboboxTarget };

//# sourceMappingURL=ComboboxTarget.mjs.map