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 { withMode } from "../../dataSourceForm/utils.js";
import JsonReadPretty from "./ReadPretty.js";
import React, { useEffect, useState } from "react";
import { Input } from "antd";
//#region src/components/dataSourceComponents/fields/Input.Json/WithMode.tsx
const _excluded = [
	"onChange",
	"onBlur",
	"value"
];
const JsonInput = (props) => {
	const { onChange, onBlur, value } = props, restProps = _objectWithoutProperties(props, _excluded);
	const [innerValue, setInnerValue] = useState(value);
	useEffect(() => {
		setInnerValue(value);
	}, [value]);
	const handleChange = (e) => {
		setInnerValue(e.target.value);
	};
	const handleBlur = (e) => {
		if (onBlur) onBlur(e);
		if (onChange) onChange(e.target.value);
	};
	return /* @__PURE__ */ React.createElement(Input.TextArea, _objectSpread2(_objectSpread2({}, restProps), {}, {
		value: innerValue,
		onChange: handleChange,
		onBlur: handleBlur
	}));
};
const JsonWithMode = withMode(JsonInput, JsonReadPretty);
//#endregion
export { JsonWithMode as default };
