import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import JsonWrapperContext from "./JsonWrapperContext.js";
import { toArr } from "../../utils.js";
import FormItem from "../../formItem.js";
import React, { useContext, useMemo } from "react";
//#region src/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.tsx
const JsonWrapperProvider = (props) => {
	const { children, prefix, label, style } = props;
	const { path: prefixPath = [], level = 0 } = useContext(JsonWrapperContext) || {};
	const concatPath = useMemo(() => [...prefixPath, ...toArr(prefix)], [prefixPath, prefix]);
	const contextValue = useMemo(() => ({
		path: concatPath,
		level: level + 1
	}), [concatPath, level]);
	return /* @__PURE__ */ React.createElement(JsonWrapperContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(FormItem, {
		label,
		style: _objectSpread2({ marginBottom: 0 }, style || {})
	}, /* @__PURE__ */ React.createElement("div", null, children)));
};
//#endregion
export { JsonWrapperProvider as default };
