// packages/block-library/src/query/edit/enhanced-pagination-modal.js
import {
  Button,
  Modal,
  __experimentalVStack as VStack
} from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { useState, useEffect } from "@wordpress/element";
import { useDispatch } from "@wordpress/data";
import { store as blockEditorStore } from "@wordpress/block-editor";
import { useUnsupportedBlocks } from "../utils.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
var modalDescriptionId = "wp-block-query-enhanced-pagination-modal__description";
function EnhancedPaginationModal({
  clientId,
  attributes: { enhancedPagination },
  setAttributes
}) {
  const [isOpen, setOpen] = useState(false);
  const hasUnsupportedBlocks = useUnsupportedBlocks(clientId);
  const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
  useEffect(() => {
    if (enhancedPagination && hasUnsupportedBlocks) {
      __unstableMarkNextChangeAsNotPersistent();
      setAttributes({ enhancedPagination: false });
      setOpen(true);
    }
  }, [
    enhancedPagination,
    hasUnsupportedBlocks,
    setAttributes,
    __unstableMarkNextChangeAsNotPersistent
  ]);
  const closeModal = () => {
    setOpen(false);
  };
  const notice = __(
    "Currently, avoiding full page reloads is not possible when non-interactive or non-client Navigation compatible blocks from plugins are present inside the Query block."
  ) + " " + __(
    'If you still want to prevent full page reloads, remove that block, then disable "Reload full page" again in the Query Block settings.'
  );
  return isOpen && /* @__PURE__ */ jsx(
    Modal,
    {
      title: __("Query block: Reload full page enabled"),
      className: "wp-block-query__enhanced-pagination-modal",
      aria: {
        describedby: modalDescriptionId
      },
      role: "alertdialog",
      focusOnMount: "firstElement",
      isDismissible: false,
      onRequestClose: closeModal,
      children: /* @__PURE__ */ jsxs(VStack, { alignment: "right", spacing: 5, children: [
        /* @__PURE__ */ jsx("span", { id: modalDescriptionId, children: notice }),
        /* @__PURE__ */ jsx(
          Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            onClick: closeModal,
            children: __("OK")
          }
        )
      ] })
    }
  );
}
export {
  EnhancedPaginationModal as default
};
//# sourceMappingURL=enhanced-pagination-modal.mjs.map
