import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import icon_default from "../icon/index.js";
import BaseVirtualInput from "./BaseVirtualInput/index.js";
import useThemeTokens from "../../hooks/useThemeTokens.js";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import classNames from "classnames";
import "../../../../../../materials/src/components/virtualInput/index.less";
//#region ../materials/src/components/virtualInput/index.tsx
const _excluded = [
	"topContent",
	"bottomContent",
	"wrapperStyle",
	"wrapperClassName",
	"allowClear",
	"onClear",
	"value",
	"clearButtonStyle",
	"theme"
];
const VirtualInput = forwardRef((_ref, ref) => {
	let { topContent, bottomContent, wrapperStyle, wrapperClassName, allowClear = false, onClear, value, clearButtonStyle = {}, theme } = _ref, virtualInputProps = _objectWithoutProperties(_ref, _excluded);
	const baseInputRef = useRef(null);
	const { colorPrimary } = useThemeTokens(theme);
	const handleClear = () => {
		onClear === null || onClear === void 0 || onClear();
	};
	useImperativeHandle(ref, () => ({
		focus: () => {
			var _baseInputRef$current;
			return (_baseInputRef$current = baseInputRef.current) === null || _baseInputRef$current === void 0 ? void 0 : _baseInputRef$current.focus();
		},
		blur: () => {
			var _baseInputRef$current2;
			return (_baseInputRef$current2 = baseInputRef.current) === null || _baseInputRef$current2 === void 0 ? void 0 : _baseInputRef$current2.blur();
		}
	}));
	return /* @__PURE__ */ React.createElement("div", {
		className: classNames("pisell-virtual-input-wrapper", wrapperClassName),
		style: _objectSpread2(_objectSpread2({}, wrapperStyle || {}), {}, { ["--color-primary"]: colorPrimary })
	}, topContent, /* @__PURE__ */ React.createElement("div", { className: "pisell-virtual-input-container" }, allowClear && /* @__PURE__ */ React.createElement("div", {
		className: "pisell-virtual-input-clear-button",
		style: _objectSpread2(_objectSpread2({}, clearButtonStyle), {}, { visibility: "hidden" })
	}, /* @__PURE__ */ React.createElement(icon_default, { type: "pisell2-delete" })), /* @__PURE__ */ React.createElement(BaseVirtualInput, _objectSpread2({
		ref: baseInputRef,
		value
	}, virtualInputProps)), allowClear && /* @__PURE__ */ React.createElement("div", {
		className: "pisell-virtual-input-clear-button",
		onClick: handleClear,
		style: clearButtonStyle
	}, /* @__PURE__ */ React.createElement(icon_default, { type: "pisell2-delete" }))), bottomContent);
});
VirtualInput.displayName = "VirtualInput";
//#endregion
export { VirtualInput as default };
