(function () {
  if (typeof wp === "undefined" || !wp.data) return;

  function removeFolderraTaxPanel() {
    try {
      wp.data
        .dispatch("core/edit-post")
        .removeEditorPanel("taxonomy-panel-folderra_sfo_content_folder");
    } catch (e) {}

    // Fallback
    try {
      const panels = document.querySelectorAll(
        '.edit-post-sidebar .components-panel__body[id*="taxonomy-panel-folderra_sfo_content_folder"],' +
        '.edit-post-sidebar .components-panel__body .components-panel__body-title button[aria-controls*="taxonomy-panel-folderra_sfo_content_folder"]'
      );
      panels.forEach((el) => {
        // if it's a button, hide the closest wrapper
        const body = el.closest(".components-panel__body") || el;
        body.style.display = "none";
      });
    } catch (e) {}
  }

  if (wp.domReady) {
    wp.domReady(removeFolderraTaxPanel);
  } else {
    document.addEventListener("DOMContentLoaded", removeFolderraTaxPanel);
  }

  // Some setups inject panels after domReady
  setTimeout(removeFolderraTaxPanel, 300);
  setTimeout(removeFolderraTaxPanel, 1200);
})();
