import { memo, createElement } from "react";
import { useDesugaredRelativeSingleField } from "@contember/binding";
import { ButtonGroup, Button } from "@contember/ui";
const AddNewBlockButtonInner = memo((props) => {
  const desugaredDiscriminationField = useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ createElement(ButtonGroup, {
    orientation: "vertical"
  }, Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ createElement(Button, {
    key: i,
    distinction: "seamless",
    flow: "generousBlock",
    disabled: props.isMutating,
    onClick: () => {
      props.requestClose();
      const targetValue = discriminateBy;
      props.createNewEntity((getNewlyAdded) => {
        const discriminationField = getNewlyAdded().getRelativeSingleField(desugaredDiscriminationField);
        discriminationField.updateValue(targetValue);
      });
    }
  }, !!blockProps.description && /* @__PURE__ */ createElement("span", null, blockProps.label, /* @__PURE__ */ createElement("br", null), /* @__PURE__ */ createElement("small", null, blockProps.description)), !blockProps.description && blockProps.label)));
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export { AddNewBlockButtonInner };
//# sourceMappingURL=AddNewBlockButtonInner.js.map
