"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const reactBinding = require("@contember/react-binding");
const ui = require("@contember/ui");
const react = require("react");
const AddNewBlockButtonInner = react.memo((props) => {
  const desugaredDiscriminationField = reactBinding.useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ jsxRuntime.jsx(ui.ButtonGroup, { direction: "vertical", children: Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ jsxRuntime.jsxs(
    ui.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__ */ jsxRuntime.jsxs("span", { children: [
          blockProps.label,
          /* @__PURE__ */ jsxRuntime.jsx("br", {}),
          /* @__PURE__ */ jsxRuntime.jsx("small", { children: blockProps.description })
        ] }),
        !blockProps.description && blockProps.label
      ]
    },
    i
  )) });
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
exports.AddNewBlockButtonInner = AddNewBlockButtonInner;
//# sourceMappingURL=AddNewBlockButtonInner.cjs.map
