import { jsx, jsxs } from "react/jsx-runtime";
import { useDesugaredRelativeSingleField } from "@contember/react-binding";
import { ButtonGroup, Button } from "@contember/ui";
import { memo } from "react";
const AddNewBlockButtonInner = memo((props) => {
  const desugaredDiscriminationField = useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ jsx(ButtonGroup, { direction: "vertical", children: Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ jsxs(
    Button,
    {
      disabled: props.isMutating,
      display: "block",
      distinction: "seamless",
      onClick: () => {
        props.requestClose();
        const targetValue = discriminateBy;
        props.createNewEntity((getNewlyAdded) => {
          const discriminationField = getNewlyAdded().getRelativeSingleField(desugaredDiscriminationField);
          discriminationField.updateValue(targetValue);
        });
      },
      padding: "padding",
      children: [
        !!blockProps.description && /* @__PURE__ */ jsxs("span", { children: [
          blockProps.label,
          /* @__PURE__ */ jsx("br", {}),
          /* @__PURE__ */ jsx("small", { children: blockProps.description })
        ] }),
        !blockProps.description && blockProps.label
      ]
    },
    i
  )) });
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export {
  AddNewBlockButtonInner
};
//# sourceMappingURL=AddNewBlockButtonInner.js.map
