// packages/block-editor/src/components/inserter/block-patterns-explorer/index.js
import { Modal } from "@wordpress/components";
import { useState } from "@wordpress/element";
import { __ } from "@wordpress/i18n";
import PatternExplorerSidebar from "./pattern-explorer-sidebar";
import PatternList from "./pattern-list";
import { usePatternCategories } from "../block-patterns-tab/use-pattern-categories";
import { jsx, jsxs } from "react/jsx-runtime";
function PatternsExplorer({ initialCategory, rootClientId, onModalClose }) {
  const [searchValue, setSearchValue] = useState("");
  const [selectedCategory, setSelectedCategory] = useState(
    initialCategory?.name
  );
  const patternCategories = usePatternCategories(rootClientId);
  return /* @__PURE__ */ jsxs("div", { className: "block-editor-block-patterns-explorer", children: [
    /* @__PURE__ */ jsx(
      PatternExplorerSidebar,
      {
        selectedCategory,
        patternCategories,
        onClickCategory: setSelectedCategory,
        searchValue,
        setSearchValue
      }
    ),
    /* @__PURE__ */ jsx(
      PatternList,
      {
        searchValue,
        selectedCategory,
        patternCategories,
        rootClientId,
        onModalClose
      }
    )
  ] });
}
function PatternsExplorerModal({ onModalClose, ...restProps }) {
  return /* @__PURE__ */ jsx(
    Modal,
    {
      title: __("Patterns"),
      onRequestClose: onModalClose,
      isFullScreen: true,
      children: /* @__PURE__ */ jsx(PatternsExplorer, { onModalClose, ...restProps })
    }
  );
}
var block_patterns_explorer_default = PatternsExplorerModal;
export {
  block_patterns_explorer_default as default
};
//# sourceMappingURL=index.js.map
