// packages/block-library/src/more/edit.js
import { __ } from "@wordpress/i18n";
import {
  __experimentalToolsPanel as ToolsPanel,
  __experimentalToolsPanelItem as ToolsPanelItem,
  ToggleControl
} from "@wordpress/components";
import {
  InspectorControls,
  PlainText,
  useBlockProps
} from "@wordpress/block-editor";
import { getDefaultBlockName, createBlock } from "@wordpress/blocks";
import { useToolsPanelDropdownMenuProps } from "../utils/hooks";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var DEFAULT_TEXT = __("Read more");
function MoreEdit({
  attributes: { customText, noTeaser },
  insertBlocksAfter,
  setAttributes
}) {
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsx(
      ToolsPanel,
      {
        label: __("Settings"),
        resetAll: () => {
          setAttributes({
            noTeaser: false
          });
        },
        dropdownMenuProps,
        children: /* @__PURE__ */ jsx(
          ToolsPanelItem,
          {
            label: __("Hide excerpt"),
            isShownByDefault: true,
            hasValue: () => noTeaser,
            onDeselect: () => setAttributes({ noTeaser: false }),
            children: /* @__PURE__ */ jsx(
              ToggleControl,
              {
                __nextHasNoMarginBottom: true,
                label: __(
                  "Hide the excerpt on the full content page"
                ),
                checked: !!noTeaser,
                onChange: () => setAttributes({ noTeaser: !noTeaser }),
                help: (checked) => checked ? __("The excerpt is hidden.") : __("The excerpt is visible.")
              }
            )
          }
        )
      }
    ) }),
    /* @__PURE__ */ jsx("div", { ...useBlockProps(), children: /* @__PURE__ */ jsx(
      PlainText,
      {
        __experimentalVersion: 2,
        tagName: "span",
        "aria-label": __('"Read more" text'),
        value: customText,
        placeholder: DEFAULT_TEXT,
        onChange: (value) => setAttributes({ customText: value }),
        disableLineBreaks: true,
        __unstableOnSplitAtEnd: () => insertBlocksAfter(
          createBlock(getDefaultBlockName())
        )
      }
    ) })
  ] });
}
export {
  MoreEdit as default
};
//# sourceMappingURL=edit.js.map
