import { jsxDEV } from "react/jsx-dev-runtime";
import { useDesugaredRelativeSingleField } from "@contember/binding";
import { ButtonGroup, Button } from "@contember/ui";
import { memo } from "react";
const AddNewBlockButtonInner = memo((props) => {
  const desugaredDiscriminationField = useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ jsxDEV(ButtonGroup, { orientation: "vertical", children: Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ jsxDEV(
    Button,
    {
      distinction: "seamless",
      flow: "generousBlock",
      disabled: props.isMutating,
      onClick: () => {
        props.requestClose();
        const targetValue = discriminateBy;
        props.createNewEntity((getNewlyAdded) => {
          const discriminationField = getNewlyAdded().getRelativeSingleField(desugaredDiscriminationField);
          discriminationField.updateValue(targetValue);
        });
      },
      children: [
        !!blockProps.description && /* @__PURE__ */ jsxDEV("span", { children: [
          blockProps.label,
          /* @__PURE__ */ jsxDEV("br", {}, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
            lineNumber: 39,
            columnNumber: 8
          }, globalThis),
          /* @__PURE__ */ jsxDEV("small", { children: blockProps.description }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
            lineNumber: 40,
            columnNumber: 8
          }, globalThis)
        ] }, void 0, true, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
          lineNumber: 37,
          columnNumber: 7
        }, globalThis),
        !blockProps.description && blockProps.label
      ]
    },
    i,
    true,
    {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
      lineNumber: 21,
      columnNumber: 5
    },
    globalThis
  )) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
    lineNumber: 19,
    columnNumber: 3
  }, globalThis);
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export {
  AddNewBlockButtonInner
};
//# sourceMappingURL=AddNewBlockButtonInner.js.map
