import { jsx } from "react/jsx-runtime";
import { store as blocksStore } from "@wordpress/blocks";
import {
  registerCoreBlocks,
  __experimentalGetCoreBlocks,
  __experimentalRegisterExperimentalCoreBlocks
} from "@wordpress/block-library";
import { dispatch } from "@wordpress/data";
import { createRoot, StrictMode } from "@wordpress/element";
import { store as preferencesStore } from "@wordpress/preferences";
import {
  registerLegacyWidgetBlock,
  registerWidgetGroupBlock
} from "@wordpress/widgets";
import "./hooks";
import { store as editSiteStore } from "./store";
import PostsApp from "./components/posts-app";
function initializePostsDashboard(id, settings) {
  if (!globalThis.IS_GUTENBERG_PLUGIN) {
    return;
  }
  const target = document.getElementById(id);
  const root = createRoot(target);
  dispatch(blocksStore).reapplyBlockTypeFilters();
  const coreBlocks = __experimentalGetCoreBlocks().filter(
    ({ name }) => name !== "core/freeform"
  );
  registerCoreBlocks(coreBlocks);
  dispatch(blocksStore).setFreeformFallbackBlockName("core/html");
  registerLegacyWidgetBlock({ inserter: false });
  registerWidgetGroupBlock({ inserter: false });
  if (globalThis.IS_GUTENBERG_PLUGIN) {
    __experimentalRegisterExperimentalCoreBlocks({
      enableFSEBlocks: true
    });
  }
  dispatch(preferencesStore).setDefaults("core/edit-site", {
    welcomeGuide: true,
    welcomeGuideStyles: true,
    welcomeGuidePage: true,
    welcomeGuideTemplate: true
  });
  dispatch(preferencesStore).setDefaults("core", {
    allowRightClickOverrides: true,
    distractionFree: false,
    editorMode: "visual",
    editorTool: "edit",
    fixedToolbar: false,
    focusMode: false,
    inactivePanels: [],
    keepCaretInsideBlock: false,
    openPanels: ["post-status"],
    showBlockBreadcrumbs: true,
    showListViewByDefault: false,
    enableChoosePatternModal: true
  });
  dispatch(editSiteStore).updateSettings(settings);
  window.addEventListener("dragover", (e) => e.preventDefault(), false);
  window.addEventListener("drop", (e) => e.preventDefault(), false);
  root.render(
    /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(PostsApp, {}) })
  );
  return root;
}
export {
  initializePostsDashboard
};
//# sourceMappingURL=posts.js.map
