import { useMergeParentKey } from "./hooks/useMergeParentKey.js";
import { FormElement } from "./FormElement.js";
import { useSortedPropertyNames } from "./hooks/useSortPropertyNames.js";
import { c } from "react/compiler-runtime";
import React from "react";
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
const ObjectController = (o) => {
	let s = c(23), { name: l, schema: u, ui: d, form: f, disabled: p, parentKey: m, viewOnly: h } = o, g = u, _ = d, v;
	s[0] === g.properties ? v = s[1] : (v = g.properties ?? {}, s[0] = g.properties, s[1] = v);
	let y = useSortedPropertyNames(v, _?.order), b = useMergeParentKey(m, l), x;
	s[2] === g.required ? x = s[3] : (x = g.required ?? [], s[2] = g.required, s[3] = x);
	let S = x, C;
	if (s[4] !== p || s[5] !== f || s[6] !== b || s[7] !== g.properties || s[8] !== _?.properties || s[9] !== y || s[10] !== S || s[11] !== h) {
		let e;
		s[13] !== p || s[14] !== f || s[15] !== b || s[16] !== g.properties || s[17] !== _?.properties || s[18] !== S || s[19] !== h ? (e = (e) => {
			let a = g.properties?.[e];
			return a ? /* @__PURE__ */ jsx(FormElement, {
				form: f,
				disabled: p,
				viewOnly: h,
				parentKey: b,
				name: e,
				schema: a,
				ui: _?.properties?.[e],
				required: S.includes(e)
			}, `el-${e}`) : null;
		}, s[13] = p, s[14] = f, s[15] = b, s[16] = g.properties, s[17] = _?.properties, s[18] = S, s[19] = h, s[20] = e) : e = s[20], C = y.map(e), s[4] = p, s[5] = f, s[6] = b, s[7] = g.properties, s[8] = _?.properties, s[9] = y, s[10] = S, s[11] = h, s[12] = C;
	} else C = s[12];
	let w;
	return s[21] === C ? w = s[22] : (w = /* @__PURE__ */ jsx(Fragment$1, { children: C }), s[21] = C, s[22] = w), w;
};
export { ObjectController };
