const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_asyncToGenerator = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_index = require("../../../../../select/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let ahooks = require("ahooks");
//#region src/components/table/Table/fields/select/Edit/index.tsx
const _excluded = [
	"value",
	"onChange",
	"onBlur",
	"style",
	"bordered",
	"options",
	"waitTime"
];
const Edit = (props, ref) => {
	const { value, onChange, onBlur, style, bordered, options, waitTime = 500 } = props, others = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const [resolvedOptions, setResolvedOptions] = (0, react.useState)([]);
	const fetchOptions = (0, react.useCallback)(function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* (searchValue) {
			if (typeof options === "function") try {
				setResolvedOptions((yield options(searchValue)) || []);
			} catch (error) {}
			else setResolvedOptions(options || []);
		});
		return function(_x) {
			return _ref.apply(this, arguments);
		};
	}(), [options]);
	const { run: debouncedFetchOptions } = (0, ahooks.useDebounceFn)(fetchOptions, { wait: waitTime || 500 });
	(0, react.useEffect)(() => {
		fetchOptions();
	}, [options]);
	return /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, others), {}, {
		options: resolvedOptions,
		bordered,
		onSearch: debouncedFetchOptions,
		ref,
		value,
		onChange,
		style,
		onBlur,
		onClick: (e) => e.stopPropagation()
	}));
};
var Edit_default = (0, react.forwardRef)(Edit);
//#endregion
exports.default = Edit_default;
