"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const reactBinding = require("@contember/react-binding");
const AddNewBlockButton = require("./AddNewBlockButton.cjs");
const SortableBlock = require("./SortableBlock.cjs");
const useNormalizedBlocks = require("../../blocks/useNormalizedBlocks.cjs");
const Repeater = require("../Repeater/Repeater.cjs");
const DiscriminatedBlocks = require("../../blocks/DiscriminatedBlocks.cjs");
const BlockRepeater = reactBinding.Component(
  ({ discriminationField, ...props }) => {
    const normalizedBlocks = useNormalizedBlocks.useNormalizedBlocks(props.children);
    const extraProps = {
      normalizedBlocks,
      discriminationField
    };
    return /* @__PURE__ */ jsxRuntime.jsx(
      Repeater.Repeater,
      {
        ...props,
        addButtonComponent: AddNewBlockButton.AddNewBlockButton,
        addButtonComponentExtraProps: extraProps,
        itemComponent: SortableBlock.SortableBlock,
        itemComponentExtraProps: extraProps,
        children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
      }
    );
  },
  (props) => /* @__PURE__ */ jsxRuntime.jsxs(Repeater.Repeater, { ...props, initialEntityCount: 0, children: [
    typeof props.discriminationField === "string" && /* @__PURE__ */ jsxRuntime.jsx(DiscriminatedBlocks.DiscriminatedBlocks, { field: props.discriminationField, label: props.label, children: props.children }),
    typeof props.discriminationField === "string" || /* @__PURE__ */ jsxRuntime.jsx(DiscriminatedBlocks.DiscriminatedBlocks, { ...props.discriminationField, label: props.label, children: props.children })
  ] }),
  "SortableBlockRepeater"
);
exports.BlockRepeater = BlockRepeater;
//# sourceMappingURL=BlockRepeater.cjs.map
