import { isDefined } from "@scalar/helpers/array/is-defined";
import { resolve } from "@scalar/workspace-store/resolve";
import { isArraySchema } from "@scalar/workspace-store/schemas/v3.1/strict/type-guards";
import { compositions } from "./schema-composition.js";
import { shouldRenderArrayItemComposition } from "./should-render-array-item-composition.js";
const getCompositionsToRender = (value) => {
  if (!value) {
    return [];
  }
  return compositions.map((composition) => {
    if (shouldRenderArrayItemComposition(value, composition) && isArraySchema(value) && value.items) {
      return {
        composition,
        value: resolve.schema(value.items)
      };
    }
    if (value[composition]) {
      const hasArrayItemComposition = isArraySchema(value) && value.items && typeof value.items === "object" && composition in value.items;
      if (!hasArrayItemComposition) {
        return {
          composition,
          value: resolve.schema(value)
        };
      }
    }
    return null;
  }).filter(isDefined);
};
export {
  getCompositionsToRender
};
