// packages/block-editor/src/components/inspector-controls-tabs/styles-tab.js
import { __ } from "@wordpress/i18n";
import { useDispatch, useSelect } from "@wordpress/data";
import { useMemo } from "@wordpress/element";
import BlockStyles from "../block-styles/index.mjs";
import InspectorControls from "../inspector-controls/index.mjs";
import PositionControls from "./position-controls-panel.mjs";
import { useBorderPanelLabel } from "../../hooks/border.mjs";
import { useBlockSettings } from "../../hooks/utils.mjs";
import { store as blockEditorStore } from "../../store/index.mjs";
import { ElementsEdit } from "../../hooks/elements.mjs";
import { TypographyPanel } from "../../hooks/typography.mjs";
import { BackgroundImagePanel } from "../../hooks/background.mjs";
import { ColorToolsPanel } from "../global-styles/color-panel.mjs";
import { TypographyToolsPanel } from "../global-styles/typography-panel.mjs";
import { BackgroundToolsPanel } from "../global-styles/background-panel.mjs";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function SectionStyleControls({ blockName, clientId, contentClientIds }) {
  const settings = useBlockSettings(blockName);
  const { updateBlockAttributes } = useDispatch(blockEditorStore);
  const { hasButtons, hasHeading } = useSelect(
    (select) => {
      const blockNames = select(blockEditorStore).getBlockNamesByClientId(
        contentClientIds
      );
      return {
        hasButtons: blockNames.includes("core/buttons"),
        hasHeading: blockNames.includes("core/heading")
      };
    },
    [contentClientIds]
  );
  const setAttributes = (newAttributes) => {
    updateBlockAttributes(clientId, newAttributes);
  };
  const typographySettings = useMemo(
    () => ({ ...settings, typography: {} }),
    [settings]
  );
  const backgroundSettings = useMemo(
    () => ({
      ...settings,
      background: {
        ...settings.background,
        backgroundImage: false,
        backgroundSize: false
      }
    }),
    [settings]
  );
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      TypographyPanel,
      {
        clientId,
        name: blockName,
        settings: typographySettings,
        setAttributes,
        asWrapper: TypographyToolsPanel
      }
    ),
    /* @__PURE__ */ jsx(
      BackgroundImagePanel,
      {
        clientId,
        name: blockName,
        settings: backgroundSettings,
        setAttributes,
        asWrapper: BackgroundToolsPanel
      }
    ),
    /* @__PURE__ */ jsx(
      ElementsEdit,
      {
        clientId,
        name: blockName,
        settings,
        setAttributes,
        asWrapper: ColorToolsPanel,
        label: __("Elements"),
        defaultControls: {
          button: hasButtons,
          heading: hasHeading
        }
      }
    )
  ] });
}
var StylesTab = ({
  blockName,
  clientId,
  hasBlockStyles,
  isSectionBlock,
  contentClientIds
}) => {
  const borderPanelLabel = useBorderPanelLabel({ blockName });
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    hasBlockStyles && /* @__PURE__ */ jsx(BlockStyles, { clientId }),
    isSectionBlock && blockName !== "core/template-part" && /* @__PURE__ */ jsx(
      SectionStyleControls,
      {
        blockName,
        clientId,
        contentClientIds
      }
    ),
    (!isSectionBlock || blockName === "core/template-part") && /* @__PURE__ */ jsxs(Fragment, { children: [
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "typography",
          label: __("Typography")
        }
      ),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "color",
          label: __("Color"),
          className: "color-block-support-panel__inner-wrapper"
        }
      ),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "background",
          label: __("Background"),
          className: "background-block-support-panel__inner-wrapper"
        }
      ),
      /* @__PURE__ */ jsx(InspectorControls.Slot, { group: "filter" }),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "layout",
          label: __("Layout")
        }
      ),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "dimensions",
          label: __("Dimensions")
        }
      ),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "border",
          label: borderPanelLabel
        }
      ),
      /* @__PURE__ */ jsx(
        InspectorControls.Slot,
        {
          group: "elements",
          label: __("Elements"),
          className: "elements-block-support-panel__inner-wrapper"
        }
      ),
      /* @__PURE__ */ jsx(PositionControls, {}),
      /* @__PURE__ */ jsx(InspectorControls.Slot, { group: "styles" })
    ] })
  ] });
};
var styles_tab_default = StylesTab;
export {
  styles_tab_default as default
};
//# sourceMappingURL=styles-tab.mjs.map
