import { mergeAllOfSchemas as y } from "./merge-all-of-schemas.js";
const m = ["oneOf", "anyOf", "allOf", "not"];
function O(i) {
  var p;
  if (!i || typeof i != "object")
    return i;
  let r = { ...i };
  const o = m.find((t) => r == null ? void 0 : r[t]);
  if (!o || o === "not")
    return r;
  const c = r == null ? void 0 : r[o];
  if (!Array.isArray(c))
    return r;
  const l = c.map((t) => {
    if (t.allOf && Array.isArray(t.allOf)) {
      const s = y(t.allOf);
      return Object.keys(t).forEach((f) => {
        !m.includes(f) && !(f in s) && (s[f] = t[f]);
      }), s;
    }
    return t;
  });
  l.some((t) => t.type === "null") && (r.nullable = !0);
  const n = l.filter((t) => t.type !== "null");
  return n.length === 1 && (r != null && r[o]) ? (r = { ...r, ...n[0] }, r == null || delete r[o], r) : (Array.isArray(r == null ? void 0 : r[o]) && ((p = r == null ? void 0 : r[o]) == null ? void 0 : p.length) > 1 && (r[o] = n), r);
}
export {
  m as compositions,
  O as optimizeValueForDisplay
};
