import { useDesugaredRelativeSingleField } from "@contember/binding";
import { ButtonGroup, Button } from "@contember/ui";
import { memo } from "react";
import { jsxDEV } from "react/jsx-dev-runtime";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx";
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: _jsxFileName,
          lineNumber: 36,
          columnNumber: 8
        }, void 0), /* @__PURE__ */ jsxDEV("small", {
          children: blockProps.description
        }, void 0, false, {
          fileName: _jsxFileName,
          lineNumber: 37,
          columnNumber: 8
        }, void 0)]
      }, void 0, true, {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 7
      }, void 0), !blockProps.description && blockProps.label]
    }, i, true, {
      fileName: _jsxFileName,
      lineNumber: 18,
      columnNumber: 5
    }, void 0))
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 16,
    columnNumber: 3
  }, void 0);
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export {
  AddNewBlockButtonInner
};
//# sourceMappingURL=AddNewBlockButtonInner.js.map
