import { useEnvironment } from "@contember/react-binding";
import { useConstantValueInvariant } from "@contember/react-utils";
import { useMemo } from "react";
import { getEditorTemplate } from "./getEditorTemplate.js";
import { useBlockProps } from "../../../blocks/useBlockProps.js";
import { useDiscriminatedData } from "../../../discrimination/useDiscriminatedData.js";
const useEditorReferenceBlocks = (children) => {
  useConstantValueInvariant(children, `BlockEditor: cannot change the set of Blocks between renders!`);
  const env = useEnvironment();
  const propList = useBlockProps(children);
  const propsWithTemplates = useMemo(() => {
    return propList.map(
      (props) => ({
        ...props,
        template: getEditorTemplate(props.children, env)
      })
    );
  }, [env, propList]);
  return useDiscriminatedData(propsWithTemplates);
};
export {
  useEditorReferenceBlocks
};
//# sourceMappingURL=useEditorReferenceBlocks.js.map
